]> git.cworth.org Git - sup/commitdiff
make enter collapse current message in thread-view-mode
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 5 Jun 2009 03:32:28 +0000 (23:32 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 5 Jun 2009 03:34:53 +0000 (23:34 -0400)
Pressing enter while over a text region in thread-view-mode will now
collapse the current message and move the cursor to the next open
message. (Behavior on quoted regions, sigs, attachments, etc. is
unchanged.)

This means that you can scan through a thread pretty rapidly by pressing
enter if you want to collapse the current message, or 'n' if you want
to keep it open.

lib/sup/modes/thread-view-mode.rb

index 42c62809fa8f80cb10c4730948de7fa4a208eff6..2b6c58b2933e123aa5d3a060ec7d986f540e5e68 100644 (file)
@@ -234,12 +234,16 @@ EOS
   ## view.
   def activate_chunk
     chunk = @chunk_lines[curpos] or return
-    layout = 
-      if chunk.is_a?(Message)
-        @layout[chunk]
-      elsif chunk.expandable?
-        @chunk_layout[chunk]
-      end
+    if chunk.is_a? Chunk::Text
+      ## if the cursor is over a text region, expand/collapse the
+      ## entire message
+      chunk = @message_lines[curpos]
+    end
+    layout = if chunk.is_a?(Message)
+      @layout[chunk]
+    elsif chunk.expandable?
+      @chunk_layout[chunk]
+    end
     if layout
       layout.state = (layout.state != :closed ? :closed : :open)
       #cursor_down if layout.state == :closed # too annoying
@@ -247,6 +251,10 @@ EOS
     elsif chunk.viewable?
       view chunk
     end
+    if chunk.is_a?(Message)
+      jump_to_message chunk
+      jump_to_next_open
+    end
   end
 
   def edit_as_new