bin/sup in sup-0.1 vs bin/sup in sup-0.2

- old
+ new

@@ -1,9 +1,10 @@ #!/usr/bin/env ruby require 'rubygems' require 'ncurses' +require 'curses' require 'fileutils' require 'trollop' require "sup" $opts = Trollop::options do @@ -14,13 +15,19 @@ Usage: sup [options] Options are: EOS + opt :list_hooks, "List all hooks and descriptions thereof, and quit." opt :no_threads, "Turn of threading. Helps with debugging. (Necessarily disables background polling for new messages.)" end +if $opts[:list_hooks] + Redwood::HookManager.print_hooks + exit +end + Thread.abort_on_exception = true # make debugging possible module Redwood global_keymap = Keymap.new do |k| @@ -83,10 +90,11 @@ exit end end begin + extend CanSpawnComposeMode Redwood::start Index.load if(s = Index.source_for DraftManager.source_name) DraftManager.source = s @@ -118,10 +126,14 @@ c.add :label_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK c.add :message_patina_color, Ncurses::COLOR_BLACK, Ncurses::COLOR_GREEN c.add :alternate_patina_color, Ncurses::COLOR_BLACK, Ncurses::COLOR_BLUE c.add :missing_message_color, Ncurses::COLOR_BLACK, Ncurses::COLOR_RED c.add :attachment_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK + c.add :cryptosig_valid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK, Ncurses::A_BOLD + c.add :cryptosig_unknown_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK + c.add :cryptosig_invalid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_RED, Ncurses::A_BOLD + c.add :generic_notice_patina_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK c.add :quote_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK c.add :sig_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK c.add :quote_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK c.add :sig_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK c.add :to_me_color, Ncurses::COLOR_GREEN, Ncurses::COLOR_BLACK @@ -137,10 +149,13 @@ Ncurses::A_BOLD c.add :draft_notification_color, Ncurses::COLOR_RED, Ncurses::COLOR_BLACK, Ncurses::A_BOLD c.add :completion_character_color, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK, Ncurses::A_BOLD + c.add :reply_mode_selected_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK, Ncurses::A_BOLD + c.add :reply_mode_unselected_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK + c.add :reply_mode_label_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK end log "initializing buffer manager" bm = BufferManager.new @@ -215,42 +230,44 @@ mode.load_threads :num => mode.buffer.content_height rescue Ferret::QueryParser::QueryParseException => e bm.flash "Couldn't parse query." end when :list_labels - labels = LabelManager.listable_label_strings + labels = LabelManager.listable_labels.map { |l| LabelManager.string_for l } user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels - user_label = bm.spawn_modal("Label list", LabelListMode.new) if user_label && user_label.empty? + user_label = + case user_label + when nil, /^\s*$/ + bm.spawn_modal("Label list", LabelListMode.new) if user_label && user_label.empty? + else + LabelManager.label_for user_label + end - label = LabelManager.label_for user_label if user_label - case label + case user_label when nil when :inbox BufferManager.raise_to_front InboxMode.instance.buffer else b = BufferManager.spawn_unless_exists("All threads with label '#{user_label}'") do - mode = LabelSearchResultsMode.new([label]) + mode = LabelSearchResultsMode.new([user_label]) end b.mode.load_threads :num => b.content_height end when :compose - mode = ComposeMode.new - bm.spawn "New Message", mode - mode.edit + spawn_compose_mode when :poll - # bm.raise_to_front PollManager.buffer reporting_thread { PollManager.poll } when :recall_draft case Index.num_results_for :label => :draft when 0 bm.flash "No draft messages." when 1 m = nil Index.each_id_by_date(:label => :draft) { |mid, builder| m = builder.call } r = ResumeMode.new(m) BufferManager.spawn "Edit message", r - r.edit + r.edit_message else b = BufferManager.spawn_unless_exists("All drafts") do mode = LabelSearchResultsMode.new [:draft] end b.mode.load_threads :num => b.content_height