bin/sup in sup-0.0.1 vs bin/sup in sup-0.0.2
- old
+ new
@@ -1,14 +1,25 @@
-#!/bin/env ruby
+#!/usr/bin/env ruby
require 'rubygems'
require 'ncurses'
require "sup"
module Redwood
$exception = nil
+def reporting_thread
+ ::Thread.new do
+ begin
+ yield
+ rescue Exception => e
+ $exception ||= e
+ raise
+ end
+ end
+end
+module_function :reporting_thread
global_keymap = Keymap.new do |k|
k.add :quit, "Quit Redwood", 'q'
k.add :help, "Show help", 'H', '?'
k.add :roll_buffers, "Switch to next buffer", 'b'
@@ -97,29 +108,22 @@
end
log "initializing buffer manager"
bm = BufferManager.new
- if Index.usual_sources.any? { |s| !s.done? }
- log "polling for new mail"
- pmode = PollMode.new
- pbuf = bm.spawn "load new messages", pmode
- pmode.poll
-# sleep 1
-# bm.kill_buffer pbuf
- end
-
log "initializing mail index buffer"
imode = InboxMode.new
ibuf = bm.spawn "inbox", imode
log "ready for (inter)action!"
Logger.make_buf
bm.draw_screen
imode.load_more_threads ibuf.content_height
+ reporting_thread { sleep 3; PollManager.poll }
+
until $exception
bm.draw_screen
c = Ncurses.nonblocking_getch
bm.erase_flash
@@ -137,11 +141,11 @@
when :roll_buffers
bm.roll_buffers
when :roll_buffers_backwards
bm.roll_buffers_backwards
when :kill_buffer
- bm.kill_buffer bm.focus_buf unless bm.focus_buf.mode.is_a? InboxMode
+ bm.kill_buffer bm.focus_buf if bm.focus_buf.mode.killable?
when :list_buffers
bm.spawn_unless_exists("Buffer List") { BufferListMode.new }
when :list_contacts
mode = ContactListMode.new
bm.spawn "compose to contacts", mode
@@ -166,14 +170,12 @@
when :compose
mode = ComposeMode.new
bm.spawn "new message", mode
mode.edit
when :poll
- b = BufferManager.spawn_unless_exists("load new messages") do
- PollMode.new
- end
- b.mode.poll
+ BufferManager.raise_to_front PollManager.buffer
+ PollManager.poll
when :nothing
when :redraw
bm.completely_redraw_screen
else
BufferManager.flash "Unknown key press '#{c.to_character}' for #{bm.focus_buf.mode.name}."
@@ -191,39 +193,41 @@
end
Index.save unless $exception # TODO: think about this
if $exception
- if $exception.is_a? IndexError
+ case $exception
+ when IndexError
$stderr.puts <<EOS
-An error occurred while loading a message from source "#{$exception.source}".
+An error occurred while parsing a message from source:
+ #{$exception.source}.
Typically, this means that the source has been modified in some
-way which has rendered the messages invalid.
+way which has rendered the messages invalid. For example, if it's
+an mbox file, you may have read or deleted messages using another
+mail client.
You must rebuild the index for this source. Please run:
sup-import --rebuild #{$exception.source}
to correct this error.
EOS
- raise $exception
+#' stupid ruby-mode
else
$stderr.puts <<EOS
------------------------------------------------------------------
-I'm very sorry, but it seems that an error occurred in Redwood.
+----------------------------------------------------------------
+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 user wmorgan-sup at site masanjin dot net so that I might
address this problem. Thank you!
Sincerely,
William
------------------------------------------------------------------
+----------------------------------------------------------------
The problem was: #{$exception.message} (error type #{$exception.class.name})
A backtrace follows:
EOS
- raise $exception
end
+ raise $exception
end
-
end
-