]> git.cworth.org Git - sup/blobdiff - bin/sup
Allow thread index view to sort oldest first
[sup] / bin / sup
diff --git a/bin/sup b/bin/sup
index 605c55342b11b1cdfd4e8fc9bfd64a98ba154129..43a26fca4127cdc227c1cc6ee356d74ac9d1e8c7 100755 (executable)
--- a/bin/sup
+++ b/bin/sup
@@ -58,6 +58,7 @@ if $opts[:list_hooks]
 end
 
 Thread.abort_on_exception = true # make debugging possible
+Thread.current.priority = 1 # keep ui responsive
 
 module Redwood
 
@@ -79,6 +80,7 @@ global_keymap = Keymap.new do |k|
   k.add :nothing, "Do nothing", :ctrl_g
   k.add :recall_draft, "Edit most recent draft message", 'R'
   k.add :show_inbox, "Show the Inbox buffer", 'I'
+  k.add :show_console, "Show the Console buffer", '~'
 end
 
 ## the following magic enables wide characters when used with a ruby
@@ -203,13 +205,13 @@ begin
   end
 
   if $opts[:search]
-    SearchResultsMode.spawn_from_query $opts[:search]
+    SearchResultsMode.spawn_from_query $opts[:search], true
   end
 
   until Redwood::exceptions.nonempty? || $die
     c = begin
       Ncurses.nonblocking_getch
-    rescue Interrupt => e
+    rescue Interrupt
       raise if BufferManager.ask_yes_or_no "Die ungracefully now?"
       BufferManager.draw_screen
       nil
@@ -231,15 +233,16 @@ begin
 
     bm.erase_flash
 
-    action = begin
-      if bm.handle_input c
+    action =
+      begin
+        if bm.handle_input c
+          :nothing
+        else
+          bm.resolve_input_with_keymap c, global_keymap
+        end
+      rescue InputSequenceAborted
         :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
@@ -264,9 +267,9 @@ begin
     when :search
       query = BufferManager.ask :search, "search all messages: "
       next unless query && query !~ /^\s*$/
-      SearchResultsMode.spawn_from_query query
+      SearchResultsMode.spawn_from_query query, true
     when :search_unread
-      SearchResultsMode.spawn_from_query "is:unread"
+      SearchResultsMode.spawn_from_query "is:unread", InboxMode.newest_first
     when :list_labels
       labels = LabelManager.all_labels.map { |l| LabelManager.string_for l }
       user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels
@@ -297,6 +300,9 @@ begin
       end
     when :show_inbox
       BufferManager.raise_to_front ibuf
+    when :show_console
+      b, new = bm.spawn_unless_exists("Console", :system => true) { ConsoleMode.new }
+      b.mode.run
     when :nothing, InputSequenceAborted
     when :redraw
       bm.completely_redraw_screen