]> git.cworth.org Git - sup/blob - lib/sup/modes/inbox-mode.rb
'A' archives and kills buffer in thread-view-mode (required significant updatedes...
[sup] / lib / sup / modes / inbox-mode.rb
1 require 'thread'
2
3 module Redwood
4
5 class InboxMode < ThreadIndexMode
6   register_keymap do |k|
7     ## overwrite toggle_archived with archive
8     k.add :archive, "Archive thread (remove from inbox)", 'a'
9   end
10
11   def initialize
12     super [:inbox], [:inbox]
13   end
14
15   def killable?; false; end
16
17   def archive
18     cursor_thread.remove_label :inbox
19     hide_thread cursor_thread
20     regen_text
21   end
22
23   def multi_archive threads
24     threads.each { |t| remove_label_and_hide_thread t, :inbox }
25     regen_text
26   end
27
28   def handle_archived_update sender, t
29     hide_thread t if contains_thread? t
30   end
31
32   def handle_unarchived_update sender, t
33     ## XXX todo: fill me in
34   end
35
36   def status
37     super + "    #{Index.size} messages in index"
38   end
39
40   def is_relevant? m; m.has_label? :inbox; end
41
42   def load_threads opts={}
43     n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
44     load_n_threads_background n, :label => :inbox,
45                                  :when_done => (lambda do |num|
46       opts[:when_done].call if opts[:when_done]
47       BufferManager.flash "Added #{num} threads."
48     end)
49   end
50 end
51
52 end