* [sup-devel] [PATCH] [issue44] cursor sticks to thread
@ 2010-01-12 20:12 Eric Sherman
0 siblings, 0 replies; only message in thread
From: Eric Sherman @ 2010-01-12 20:12 UTC (permalink / raw)
To: sup-devel
The cursor will track the thread it is on when that thread is moved up
or down on the screen as threads are added or removed from the view.
---
lib/sup/modes/thread-index-mode.rb | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index a5bd344..9e70ec8 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -219,6 +219,10 @@ EOS
end
def update
+ ## remember the thread we are on and where the cursor is before we update
+ old_cursor_thread = cursor_thread
+ old_cursor_position = curpos
+
@mutex.synchronize do
## let's see you do THIS in python
@threads = @ts.threads.select { |t| !@hidden_threads[t] }.sort_by { |t| [t.date, t.first.id] }.reverse
@@ -226,6 +230,11 @@ EOS
@size_widget_width = @size_widgets.max_of { |w| w.display_length }
end
+ ## if the thread moved on screen, move the cursor to its new position
+ new_cursor_position = @threads.index(old_cursor_thread)||0
+ (old_cursor_position..(new_cursor_position-1)).each { |x| cursor_down }
+ (new_cursor_position..(old_cursor_position-1)).each { |x| cursor_up }
+
regen_text
end
--
1.6.6
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-01-12 20:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-12 20:12 [sup-devel] [PATCH] [issue44] cursor sticks to thread Eric Sherman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox