Redwood::start
Index.load
- if(s = Index.source_for DraftManager.source_name)
+ trap("TERM") { |x| SuicideManager.please_die! }
+ trap("WINCH") { |x| BufferManager.sigwinch_happened! }
+
+ if(s = Redwood::SourceManager.source_for DraftManager.source_name)
DraftManager.source = s
else
Redwood::log "no draft source, auto-adding..."
- Index.add_source DraftManager.new_source
+ Redwood::SourceManager.add_source DraftManager.new_source
end
- if(s = Index.source_for SentManager.source_name)
+ if(s = Redwood::SourceManager.source_for SentManager.source_uri)
SentManager.source = s
else
- Redwood::log "no sent mail source, auto-adding..."
- Index.add_source SentManager.new_source
+ Redwood::SourceManager.add_source SentManager.default_source
end
HookManager.run "startup"
bm.draw_screen
- Index.usual_sources.each do |s|
+ Redwood::SourceManager.usual_sources.each do |s|
next unless s.respond_to? :connect
reporting_thread("call #connect on #{s}") do
begin
end
until Redwood::exceptions.nonempty? || SuicideManager.die?
- c =
- begin
- Ncurses.nonblocking_getch
- rescue Exception => e
- if e.is_a?(Interrupt)
- raise if BufferManager.ask_yes_or_no("Die ungracefully now?")
- bm.draw_screen
- nil
- end
- end
- next unless c
+ c = begin
+ Ncurses.nonblocking_getch
+ rescue Interrupt => e
+ raise if BufferManager.ask_yes_or_no "Die ungracefully now?"
+ BufferManager.draw_screen
+ nil
+ end
+
+ if c.nil?
+ if BufferManager.sigwinch_happened?
+ Redwood::log "redrawing screen on sigwinch"
+ BufferManager.completely_redraw_screen
+ end
+ next
+ end
+
+ if c == 410
+ ## this is ncurses's way of telling us it's detected a refresh.
+ ## since we have our own sigwinch handler, we don't do anything.
+ next
+ end
+
bm.erase_flash
- action =
- begin
- if bm.handle_input c
- :nothing
- else
- bm.resolve_input_with_keymap c, global_keymap
- end
- rescue InputSequenceAborted
+ action = begin
+ if bm.handle_input c
:nothing
+ else
+ bm.resolve_input_with_keymap c, global_keymap
end
+ rescue InputSequenceAborted
+ :nothing
+ end
case action
when :quit_now
break if bm.kill_all_buffers_safely