sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 68f2413aa51fc3bcb72655a6444398186c32748b
parent 899412cc771ea86842d4018263155bdd7a48ca19
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Sat, 24 Nov 2007 20:43:33 +0000

- label-list-mode rekeyed tab to 'u' for showing only labels with unread messages
- label-list-mode now uses tab to jump between labels with unread messages, just like thread-index-mode
- if 'u' and no labels with unread messages, now flash a message.



git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@720 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M lib/sup/modes/label-list-mode.rb | 29 ++++++++++++++++-------------
M lib/sup/modes/thread-view-mode.rb | 2 +-
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/lib/sup/modes/label-list-mode.rb b/lib/sup/modes/label-list-mode.rb
@@ -4,15 +4,13 @@ class LabelListMode < LineCursorMode
   register_keymap do |k|
     k.add :select_label, "Search by label", :enter
     k.add :reload, "Discard label list and reload", '@'
-    k.add :toggle_show_unread_only, "Toggle between all labels and those with unread mail", :tab
+    k.add :jump_to_next_new, "Jump to next new thread", :tab
+    k.add :toggle_show_unread_only, "Toggle between showing all labels and those with unread mail", 'u'
   end
 
-  attr_reader :value
-
   def initialize
     @labels = []
     @text = []
-    @value = nil
     @unread_only = false
     super
     regen_text
@@ -21,15 +19,18 @@ class LabelListMode < LineCursorMode
   def lines; @text.length end
   def [] i; @text[i] end
 
-  def status
-    if true
-      "No labels with unread messages"
+  def jump_to_next_new
+    n = ((curpos + 1) ... lines).find { |i| @labels[i][1] > 0 } || (0 ... curpos).find { |i| @labels[i][1] > 0 }
+    if n
+      ## jump there if necessary
+      jump_to_line n unless n >= topline && n < botline
+      set_cursor_pos n
     else
-      super
+      BufferManager.flash "No labels messages with unread messages."
     end
   end
-
 protected
+
   def toggle_show_unread_only
     @unread_only = !@unread_only
     reload
@@ -67,15 +68,17 @@ protected
 
       @text << [[(unread == 0 ? :labellist_old_color : :labellist_new_color),
           sprintf("%#{width + 1}s %5d %s, %5d unread", string, total, total == 1 ? " message" : "messages", unread)]]
-      @labels << label
+      @labels << [label, unread]
       yield i if block_given?
     end.compact
+
+    BufferManager.flash "No labels with unread messages!" if counts.empty? && @unread_only
   end
 
   def select_label
-    @value, string = @labels[curpos]
-    return unless @value
-    LabelSearchResultsMode.spawn_nicely @value
+    label, num_unread = @labels[curpos]
+    return unless label
+    LabelSearchResultsMode.spawn_nicely label
   end
 end
 
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -25,7 +25,7 @@ class ThreadViewMode < LineCursorMode
     k.add :jump_to_prev_open, "Jump to previous open message", 'p'
     k.add :toggle_starred, "Star or unstar message", '*'
     k.add :toggle_new, "Toggle new/read status of message", 'N'
-#    k.add :collapse_non_new_messages, "Collapse all but new messages", 'N'
+#    k.add :collapse_non_new_messages, "Collapse all but unread messages", 'N'
     k.add :reply, "Reply to a message", 'r'
     k.add :forward, "Forward a message", 'f'
     k.add :alias, "Edit alias/nickname for a person", 'i'