k.add :quit, "Quit Redwood", 'q'
k.add :help, "Show help", 'H', '?'
k.add :roll_buffers, "Switch to next buffer", 'b'
- k.add :roll_buffers_backwards, "Switch to previous buffer", 'B'
+# k.add :roll_buffers_backwards, "Switch to previous buffer", 'B'
k.add :kill_buffer, "Kill the current buffer", 'x'
- k.add :list_buffers, "List all buffers", 'A'
+ k.add :list_buffers, "List all buffers", 'B'
k.add :list_contacts, "List contacts", 'C'
k.add :redraw, "Redraw screen", :ctrl_l
k.add :search, "Search messages", '/'
c.add :index_old_color, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK
c.add :index_new_color, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK,
Ncurses::A_BOLD
+ c.add :index_starred_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK,
+ Ncurses::A_BOLD
c.add :labellist_old_color, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK
c.add :labellist_new_color, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK,
Ncurses::A_BOLD
c.add :twiddle_color, Ncurses::COLOR_BLUE, Ncurses::COLOR_BLACK
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 :mime_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
Ncurses::A_BOLD
c.add :starred_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_GREEN,
Ncurses::A_BOLD
+ c.add :alternate_starred_patina_color, Ncurses::COLOR_YELLOW,
+ Ncurses::COLOR_BLUE, Ncurses::A_BOLD
c.add :snippet_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK
c.add :option_color, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK
c.add :tagged_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK,
imode = InboxMode.new
ibuf = bm.spawn "inbox", imode
- log "ready for (inter)action!"
+ log "ready for interaction!"
Logger.make_buf
bm.draw_screen
- imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } }
+
+ begin
+ Index.usual_sources.each { |s| s.check }
+ rescue SourceError
+ # do nothing! we'll report it at the next step
+ end
+ Redwood::report_broken_sources
+
+ Index.usual_sources.each do |s|
+ reporting_thread do
+ begin
+ s.connect
+ rescue SourceError => e
+ Redwood::log "fatal error loading from #{s}: #{e.message}"
+ end
+ end if s.respond_to? :connect
+ end
+
+ imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } }
PollManager.start_thread
x = global_keymap.action_for c
case x
when :quit
- break
+ break if bm.kill_all_buffers_safely
when :help
curmode = bm.focus_buf.mode
bm.spawn_unless_exists("<help for #{curmode.name}>") { HelpMode.new curmode, global_keymap }
when :roll_buffers_backwards
bm.roll_buffers_backwards
when :kill_buffer
- bm.kill_buffer bm.focus_buf if bm.focus_buf.mode.killable?
+ bm.kill_buffer_safely bm.focus_buf
when :list_buffers
bm.spawn_unless_exists("Buffer List") { BufferListMode.new }
when :list_contacts
- bm.spawn_unless_exists("Contact List") { ContactListMode.new }
+ b = bm.spawn_unless_exists("Contact List") { ContactListMode.new }
+ b.mode.load_in_background
when :search
text = bm.ask :search, "query: "
next unless text && text !~ /^\s*$/
rescue Ferret::QueryParser::QueryParseException => e
bm.flash "Couldn't parse query."
end
-
when :list_labels
b = bm.spawn_unless_exists("Label List") { LabelListMode.new }
b.mode.load_in_background
bm.spawn "New Message", mode
mode.edit
when :poll
- bm.raise_to_front PollManager.buffer
+# bm.raise_to_front PollManager.buffer
reporting_thread { PollManager.poll }
when :recall_draft
case Index.num_results_for :label => :draft
when 1
m = nil
Index.each_id_by_date(:label => :draft) { |mid, builder| m = builder.call }
- BufferManager.spawn "Edit message", ResumeMode.new(m)
+ r = ResumeMode.new(m)
+ BufferManager.spawn "Edit message", r
+ r.edit
else
b = BufferManager.spawn_unless_exists(:draft) do
mode = LabelSearchResultsMode.new [:draft]
end
end
end
- bm.kill_all_buffers
rescue Exception => e
$exception ||= e
ensure
Redwood::finish
stop_cursing
+ if $exception
+ Redwood::log "oh crap, an exception"
+ else
+ Redwood::log "good night, sweet prince!"
+ end
end
Index.save unless $exception # TODO: think about this