sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 34570f64c113bbb5ee57a47a30e9a467e4902a39
parent 4279bd4b40633eae6367df08db28ea467f708162
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Sun, 30 Dec 2007 11:03:23 -0800

added ThreadIndexMode#launch_next_thread_after to support dispatch-then-kill

Diffstat:
M lib/sup/modes/thread-index-mode.rb | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -75,7 +75,7 @@ EOS
   end
 
   ## open up a thread view window
-  def select t=nil
+  def select t=nil, when_done=nil
     t ||= cursor_thread or return
 
     Redwood::reporting_thread("load messages for thread-view-mode") do
@@ -98,12 +98,28 @@ EOS
 
       update_text_for_line curpos
       UpdateManager.relay self, :read, t.first
+      when_done.call if when_done
     end
   end
 
   def multi_select threads
     threads.each { |t| select t }
   end
+
+  ## this is called by thread-view-modes when the user wants to view
+  ## the next thread without going to index-mode. we update the cursor
+  ## as a convenience.
+  def launch_next_thread_after thread, &b
+    l = @lines[thread] or return
+    t = @mutex.synchronize do
+      if l < @threads.length - 1
+        set_cursor_pos l + 1 # move out of mutex?
+        @threads[l + 1]
+      end
+    end or return
+
+    select t, b
+  end
   
   def handle_single_message_labeled_update sender, m
     ## no need to do anything different here; we don't differentiate