commit 00ddb2607c771b70156e784beb370ecfa5f0a88c
parent 10468bc5652dfe6ea2470ef20a8cf96efb55bdda
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Fri, 5 Jan 2007 01:54:40 +0000
renamed load_more_threads to load_threads and moved to thread-index-mode.
also made "saving thread" message actually accurate
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@178 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
8 files changed, 25 insertions(+), 36 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -100,7 +100,7 @@ begin
Logger.make_buf
bm.draw_screen
- imode.load_more_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } }
+ imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } }
PollManager.start_thread
@@ -140,7 +140,7 @@ begin
log "built query from #{text.inspect}: #{qobj}"
mode = SearchResultsMode.new qobj
bm.spawn "search: \"#{short_text}\"", mode
- mode.load_more_threads :num => mode.buffer.content_height
+ mode.load_threads :num => mode.buffer.content_height
rescue Ferret::QueryParser::QueryParseException => e
bm.flash "Couldn't parse query."
end
@@ -167,7 +167,7 @@ begin
b = BufferManager.spawn_unless_exists(:draft) do
mode = LabelSearchResultsMode.new [:draft]
end
- b.mode.load_more_threads :num => b.content_height
+ b.mode.load_threads :num => b.content_height
end
when :nothing
when :redraw
diff --git a/lib/sup/modes/contact-list-mode.rb b/lib/sup/modes/contact-list-mode.rb
@@ -60,7 +60,7 @@ class ContactListMode < LineCursorMode
def multi_search people
mode = PersonSearchResultsMode.new people
BufferManager.spawn "personal search results", mode
- mode.load_more_threads :num => mode.buffer.content_height
+ mode.load_threads :num => mode.buffer.content_height
end
def search
diff --git a/lib/sup/modes/inbox-mode.rb b/lib/sup/modes/inbox-mode.rb
@@ -6,8 +6,6 @@ class InboxMode < ThreadIndexMode
register_keymap do |k|
## overwrite toggle_archived with archive
k.add :archive, "Archive thread (remove from inbox)", 'a'
- k.add :load_more_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
- k.add :reload, "Discard threads and reload", 'D'
end
def initialize
@@ -28,7 +26,7 @@ class InboxMode < ThreadIndexMode
def is_relevant? m; m.has_label? :inbox; end
- def load_more_threads opts={}
+ def load_threads opts={}
n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
load_n_threads_background n, :label => :inbox,
:load_killed => false,
@@ -38,12 +36,6 @@ class InboxMode < ThreadIndexMode
BufferManager.flash "Added #{num} threads."
end)
end
-
- def reload
- drop_all_threads
- BufferManager.draw_screen
- load_more_threads :num => buffer.content_height
- end
end
end
diff --git a/lib/sup/modes/label-list-mode.rb b/lib/sup/modes/label-list-mode.rb
@@ -81,7 +81,7 @@ protected
b = BufferManager.spawn_unless_exists(label) do
mode = LabelSearchResultsMode.new [label]
end
- b.mode.load_more_threads :num => b.content_height
+ b.mode.load_threads :num => b.content_height
end
end
end
diff --git a/lib/sup/modes/label-search-results-mode.rb b/lib/sup/modes/label-search-results-mode.rb
@@ -1,10 +1,6 @@
module Redwood
class LabelSearchResultsMode < ThreadIndexMode
- register_keymap do |k|
- k.add :load_more_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
- end
-
def initialize labels
@labels = labels
super
@@ -12,7 +8,7 @@ class LabelSearchResultsMode < ThreadIndexMode
def is_relevant? m; @labels.all? { |l| m.has_label? l }; end
- def load_more_threads opts={}
+ def load_threads opts={}
n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
load_n_threads_background n, :labels => @labels,
:load_killed => true,
diff --git a/lib/sup/modes/person-search-results-mode.rb b/lib/sup/modes/person-search-results-mode.rb
@@ -1,10 +1,6 @@
module Redwood
class PersonSearchResultsMode < ThreadIndexMode
- register_keymap do |k|
- k.add :load_more_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
- end
-
def initialize people
@people = people
super
@@ -12,7 +8,7 @@ class PersonSearchResultsMode < ThreadIndexMode
def is_relevant? m; @people.any? { |p| m.from == p }; end
- def load_more_threads opts={}
+ def load_threads opts={}
n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
load_n_threads_background n, :participants => @people,
:load_killed => true,
diff --git a/lib/sup/modes/search-results-mode.rb b/lib/sup/modes/search-results-mode.rb
@@ -1,10 +1,6 @@
module Redwood
class SearchResultsMode < ThreadIndexMode
- register_keymap do |k|
- k.add :load_more_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
- end
-
def initialize qobj
@qobj = qobj
super
@@ -13,7 +9,7 @@ class SearchResultsMode < ThreadIndexMode
## TODO: think about this
def is_relevant? m; super; end
- def load_more_threads opts={}
+ def load_threads opts={}
n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
load_n_threads_background n, :qobj => @qobj,
:load_killed => true,
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -1,11 +1,15 @@
module Redwood
+## subclasses should implement load_threads
+
class ThreadIndexMode < LineCursorMode
DATE_WIDTH = Time::TO_NICE_S_MAX_LEN
FROM_WIDTH = 15
LOAD_MORE_THREAD_NUM = 20
register_keymap do |k|
+ k.add :load_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
+ k.add :reload, "Discard threads and reload", 'D'
k.add :toggle_archived, "Toggle archived status", 'a'
k.add :toggle_starred, "Star or unstar all messages in thread", '*'
k.add :toggle_new, "Toggle new/read status of all messages in thread", 'N'
@@ -41,6 +45,12 @@ class ThreadIndexMode < LineCursorMode
def lines; @text.length; end
def [] i; @text[i]; end
+ def reload
+ drop_all_threads
+ BufferManager.draw_screen
+ load_threads :num => buffer.content_height
+ end
+
## open up a thread view window
def select t=nil
t ||= @threads[curpos]
@@ -185,15 +195,14 @@ class ThreadIndexMode < LineCursorMode
def save
threads = @threads + @hidden_threads.keys
- mbid = BufferManager.say "Saving threads..."
- threads.each_with_index do |t, i|
- if i % 5 == 0
- BufferManager.say "Saving thread #{i + 1} of #{threads.length}...",
- mbid
+
+ BufferManager.say("Saving threads...") do |say_id|
+ threads.each_with_index do |t, i|
+ next unless t.dirty?
+ BufferManager.say "Saving thread #{i +1} of #{threads.length}...", say_id
+ t.save Index
end
- t.save Index
end
- BufferManager.clear mbid
end
def cleanup