]> git.cworth.org Git - sup/blob - lib/sup/modes/inbox-mode.rb
abort message composition if the file is unedited
[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, :sent], { :label => :inbox }
13     raise "can't have more than one!" if defined? @@instance
14     @@instance = self
15   end
16
17   def is_relevant? m; m.has_label? :inbox; end
18
19   ## label-list-mode wants to be able to raise us if the user selects
20   ## the "inbox" label, so we need to keep our singletonness around
21   def self.instance; @@instance; end
22   def killable?; false; end
23
24   def archive
25     return unless cursor_thread
26     cursor_thread.remove_label :inbox
27     hide_thread cursor_thread
28     regen_text
29   end
30
31   def multi_archive threads
32     threads.each do |t|
33       t.remove_label :inbox
34       hide_thread t
35     end
36     regen_text
37   end
38
39   def handle_archived_update sender, t
40     if contains_thread? t
41       hide_thread t
42       regen_text
43     end
44   end
45
46 # not quite working, and not sure if i like it anyways
47 #   def handle_unarchived_update sender, t
48 #     Redwood::log "unarchived #{t.subj}"
49 #     show_thread t
50 #   end
51
52   def status
53     super + "    #{Index.size} messages in index"
54   end
55 end
56
57 end