commit cebc7b7382d7b2faf94d07199c3a9931546b0df1
parent 9a0188e4299b904e28a412e804e59a318835d7eb
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Tue, 5 Feb 2008 09:21:03 -0800
add ] as a dispatch-and-previous prefix in thread-view-mode
Diffstat:
2 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -113,19 +113,28 @@ EOS
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.
+ ## these two methods are called by thread-view-modes when the user
+ ## wants to view the previous/next thread without going back to
+ ## index-mode. we update the cursor as a convenience.
def launch_next_thread_after thread, &b
+ launch_another_thread thread, 1, &b
+ end
+
+ def launch_prev_thread_before thread, &b
+ launch_another_thread thread, -1, &b
+ end
+
+ def launch_another_thread thread, direction, &b
l = @lines[thread] or return
+ target_l = l + direction
t = @mutex.synchronize do
- if l < @threads.length - 1
- set_cursor_pos l + 1 # move out of mutex?
- @threads[l + 1]
+ if target_l >= 0 && target_l < @threads.length
+ @threads[target_l]
end
end
if t # there's a next thread
+ set_cursor_pos target_l # move out of mutex?
select t, b
elsif b # no next thread. call the block anyways
b.call
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -63,6 +63,14 @@ EOS
kk.add :unread_and_next, "Mark this thread as unread, kill buffer, and view next", 'N'
kk.add :do_nothing_and_next, "Kill buffer, and view next", 'n'
end
+
+ k.add_multi "(a)rchive/(d)elete/mark as (s)pam/mark as u(N)read/do (n)othing:", ']' do |kk|
+ kk.add :archive_and_prev, "Archive this thread, kill buffer, and view previous", 'a'
+ kk.add :delete_and_prev, "Delete this thread, kill buffer, and view previous", 'd'
+ kk.add :spam_and_prev, "Mark this thread as spam, kill buffer, and view previous", 's'
+ kk.add :unread_and_prev, "Mark this thread as unread, kill buffer, and view previous", 'N'
+ kk.add :do_nothing_and_prev, "Kill buffer, and view previous", 'n'
+ end
end
## there are a couple important instance variables we hold to format
@@ -383,6 +391,12 @@ EOS
def unread_and_next; unread_and_then :next end
def do_nothing_and_next; do_nothing_and_then :next end
+ def archive_and_prev; archive_and_then :prev end
+ def spam_and_prev; spam_and_then :prev end
+ def delete_and_prev; delete_and_then :prev end
+ def unread_and_prev; unread_and_then :prev end
+ def do_nothing_and_prev; do_nothing_and_then :prev end
+
def archive_and_then op
dispatch op do
@thread.remove_label :inbox
@@ -419,15 +433,18 @@ EOS
return if @dying
@dying = true
+ l = lambda do
+ yield if block_given?
+ BufferManager.kill_buffer_safely buffer
+ end
+
case op
when :next
- @index_mode.launch_next_thread_after(@thread) do
- yield if block_given?
- BufferManager.kill_buffer_safely buffer
- end
+ @index_mode.launch_next_thread_after @thread, &l
+ when :prev
+ @index_mode.launch_prev_thread_before @thread, &l
when :kill
- yield if block_given?
- BufferManager.kill_buffer_safely buffer
+ l.call
else
raise ArgumentError, "unknown thread dispatch operation #{op.inspect}"
end