require 'rubygems'
require 'ncurses'
+require 'curses'
require 'fileutils'
require 'trollop'
require "sup"
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
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 :mime_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK
+ 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
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"
end if s.respond_to? :connect
end
- imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } }
+ imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } unless $opts[:no_threads] }
unless $opts[:no_threads]
- PollManager.start_thread
- SuicideManager.start_thread
+ PollManager.start
+ SuicideManager.start
Index.start_lock_update_thread
end
until $exception || SuicideManager.die?
c = Ncurses.nonblocking_getch
next unless c
+ bm.erase_flash
unless bm.handle_input(c)
x = global_keymap.action_for c
bm.flash "Couldn't parse query."
end
when :list_labels
- b = bm.spawn_unless_exists("Label list") { LabelListMode.new }
- b.mode.load_in_background
+ 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 =
+ 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
+
+ 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([user_label])
+ end
+ b.mode.load_threads :num => b.content_height
+ end
+
when :compose
- mode = ComposeMode.new
+ to = BufferManager.ask_for_contacts(:people, "To: ") or next
+ cc = BufferManager.ask_for_contacts(:people, "Cc: ") or next if $config[:ask_for_cc]
+ bcc = BufferManager.ask_for_contacts(:people, "Bcc: ") or next if $config[:ask_for_bcc]
+
+ mode = ComposeMode.new :to => to, :cc => cc, :bcc => bcc
bm.spawn "New Message", mode
- mode.edit
+ mode.edit_message
when :poll
- # bm.raise_to_front PollManager.buffer
reporting_thread { PollManager.poll }
when :recall_draft
case Index.num_results_for :label => :draft
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
bm.draw_screen
- bm.erase_flash
end
rescue Exception => e
$exception ||= e
ensure
+ unless $opts[:no_threads]
+ PollManager.stop if PollManager.instantiated?
+ SuicideManager.stop if PollManager.instantiated?
+ Index.stop_lock_update_thread
+ end
+
Redwood::finish
stop_cursing
+ Redwood::log "stopped cursing"
if SuicideManager.instantiated? && SuicideManager.die?
- Redwood::log "I've been asked to commit sepuku. I obey!"
+ Redwood::log "I've been ordered to commit sepuku. I obey!"
end
case $exception
when nil
- Redwood::log "good night, sweet prince!"
+ Redwood::log "no fatal errors. good job, william."
Index.save
else
Redwood::log "oh crap, an exception"
I'm very sorry, but it seems that an error occurred in Sup.
Please accept my sincere apologies. If you don't mind, please
send the backtrace below and a brief report of the circumstances
-to wmorgan-sup at masanjin dot nets so that I might address this
+to sup-talk at rubyforge dot orgs so that I might address this
problem. Thank you!
Sincerely,
William
----------------------------------------------------------------
-The problem was: #{$exception.message} (error type #{$exception.class.name})
+The problem was: '#{$exception.message}' (error type #{$exception.class.name})
A backtrace follows:
EOS
raise $exception