>From e42299ce17ed7c12989d0c8a6dea2ed100921e4a Mon Sep 17 00:00:00 2001
From: Mike Stipicevic <[email protected]>
Date: Mon, 16 Feb 2009 00:03:57 -0500
Subject: [PATCH] Added undo for starring
---
lib/sup/modes/thread-index-mode.rb | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/lib/sup/modes/thread-index-mode.rb
b/lib/sup/modes/thread-index-mode.rb
index 120acad..62fdb85 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -237,24 +237,41 @@ EOS
end
def actually_toggle_starred t
+ thread = t # cargo cult programming
+ pos = curpos
if t.has_label? :starred # if ANY message has a star
+ undo = lambda {
+ thread.first.add_label :starred
+ update_text_for_line pos
+ UpdateManager.relay self, :starred, thread.first
+ }
t.remove_label :starred # remove from all
UpdateManager.relay self, :unstarred, t.first
else
+ undo = lambda {
+ thread.remove_label :starred
+ update_text_for_line pos
+ UpdateManager.relay self, :unstarred, thread.first
+ }
t.first.add_label :starred # add only to first
UpdateManager.relay self, :starred, t.first
end
+
+ return undo
end
def toggle_starred
t = cursor_thread or return
- actually_toggle_starred t
+ undo = actually_toggle_starred t
+ UndoManager.register("starring/unstarring thread #{t.first.id}",undo)
update_text_for_line curpos
cursor_down
end
def multi_toggle_starred threads
- threads.each { |t| actually_toggle_starred t }
+ undo = threads.map { |t| actually_toggle_starred t }
+ UndoManager.register("starring/unstarring #{threads.size}
#{threads.size.pluralize 'thread'}",
+ undo)
regen_text
end
--
1.5.3
_______________________________________________
sup-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/sup-talk