Class: Redwood::InboxMode
Constant Summary
ThreadIndexMode::DATE_WIDTH, ThreadIndexMode::LOAD_MORE_THREAD_NUM, ThreadIndexMode::MIN_FROM_WIDTH
Instance Attribute Summary
#curpos
Attributes inherited from ScrollMode
#botline, #leftcol, #topline
Attributes inherited from Mode
#buffer
Class Method Summary
collapse
-
.instance ⇒ Object
label-list-mode wants to be able to raise us if the user selects the “inbox” label, so we need to keep our singletonness around.
Instance Method Summary
collapse
#[], #actually_toggle_archived, #actually_toggle_deleted, #actually_toggle_spammed, #actually_toggle_starred, #apply_to_tagged, #cancel_search, #cleanup, #contains_thread?, #edit_labels, #edit_message, #flush_index, #forward, #handle_added_update, #handle_deleted_update, #handle_labeled_update, #handle_simple_update, #handle_single_message_deleted_update, #handle_single_message_labeled_update, #handle_spammed_update, #handle_undeleted_update, #join_threads, #jump_to_next_new, #kill, #launch_another_thread, #launch_next_thread_after, #launch_prev_thread_before, #lines, #load_all_threads, #load_n_threads, #load_n_threads_background, #load_threads, #multi_edit_labels, #multi_join_threads, #multi_kill, #multi_select, #multi_toggle_archived, #multi_toggle_deleted, #multi_toggle_new, #multi_toggle_spam, #multi_toggle_starred, #multi_toggle_tagged, #reload, #reply, #reply_all, #resize, #select, #tag_matching, #toggle_archived, #toggle_deleted, #toggle_new, #toggle_spam, #toggle_starred, #toggle_tagged, #toggle_tagged_all, #undo, #unsaved?, #update
#cleanup, #draw
Methods inherited from ScrollMode
#at_bottom?, #at_top?, #cancel_search!, #col_jump, #col_left, #col_right, #continue_search_in_buffer, #draw, #ensure_mode_validity, #half_page_down, #half_page_up, #in_search?, #jump_to_col, #jump_to_end, #jump_to_left, #jump_to_line, #jump_to_start, #line_down, #line_up, #page_down, #page_up, #resize, #rightcol, #search_goto_line, #search_goto_pos, #search_in_buffer, #search_start_line
Methods inherited from Mode
#blur, #cancel_search!, #cleanup, #draw, #focus, #handle_input, #help_text, #in_search?, keymap, keymaps, load_all_modes, make_name, #name, #pipe_to_process, register_keymap, #resize, #resolve_input, #save_to_file, #unsaved?
Constructor Details
Returns a new instance of InboxMode.
13
14
15
16
17
|
# File 'lib/sup/modes/inbox_mode.rb', line 13
def initialize
super [:inbox, :sent, :draft], { :label => :inbox, :skip_killed => true }
raise "can't have more than one!" if defined? @@instance
@@instance = self
end
|
Class Method Details
label-list-mode wants to be able to raise us if the user selects the “inbox” label, so we need to keep our singletonness around
30
|
# File 'lib/sup/modes/inbox_mode.rb', line 30
def self.instance; @@instance; end
|
Instance Method Details
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/sup/modes/inbox_mode.rb', line 33
def archive
return unless cursor_thread
thread = cursor_thread
UndoManager.register "archiving thread" do
thread.apply_label :inbox
add_or_unhide thread.first
Index.save_thread thread
end
cursor_thread.remove_label :inbox
hide_thread cursor_thread
regen_text
Index.save_thread thread
end
|
#handle_archived_update(sender, m) ⇒ Object
112
113
114
115
116
|
# File 'lib/sup/modes/inbox_mode.rb', line 112
def handle_archived_update sender, m
t = thread_containing(m) or return
hide_thread t
regen_text
end
|
#handle_idle_update(sender, idle_since) ⇒ Object
118
119
120
|
# File 'lib/sup/modes/inbox_mode.rb', line 118
def handle_idle_update sender, idle_since
flush_index
end
|
#handle_unarchived_update(sender, m) ⇒ Object
108
109
110
|
# File 'lib/sup/modes/inbox_mode.rb', line 108
def handle_unarchived_update sender, m
add_or_unhide m
end
|
#is_relevant?(m) ⇒ Boolean
19
|
# File 'lib/sup/modes/inbox_mode.rb', line 19
def is_relevant? m; (m.labels & [:spam, :deleted, :killed, :inbox]) == Set.new([:inbox]) end
|
#killable? ⇒ Boolean
31
|
# File 'lib/sup/modes/inbox_mode.rb', line 31
def killable?; false; end
|
#multi_archive(threads) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/sup/modes/inbox_mode.rb', line 49
def multi_archive threads
UndoManager.register "archiving #{threads.size.pluralize 'thread'}" do
threads.map do |t|
t.apply_label :inbox
add_or_unhide t.first
Index.save_thread t
end
regen_text
end
threads.each do |t|
t.remove_label :inbox
hide_thread t
end
regen_text
threads.each { |t| Index.save_thread t }
end
|
#multi_read_and_archive(threads) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/sup/modes/inbox_mode.rb', line 86
def multi_read_and_archive threads
old_labels = threads.map { |t| t.labels.dup }
threads.each do |t|
t.remove_label :unread
t.remove_label :inbox
hide_thread t
end
regen_text
UndoManager.register "reading and archiving #{threads.size.pluralize 'thread'}" do
threads.zip(old_labels).each do |t, l|
t.labels = l
add_or_unhide t.first
Index.save_thread t
end
regen_text
end
threads.each { |t| Index.save_thread t }
end
|
#read_and_archive ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/sup/modes/inbox_mode.rb', line 67
def read_and_archive
return unless cursor_thread
thread = cursor_thread
was_unread = thread.labels.member? :unread
UndoManager.register "reading and archiving thread" do
thread.apply_label :inbox
thread.apply_label :unread if was_unread
add_or_unhide thread.first
Index.save_thread thread
end
cursor_thread.remove_label :unread
cursor_thread.remove_label :inbox
hide_thread cursor_thread
regen_text
Index.save_thread thread
end
|
#refine_search ⇒ Object
21
22
23
24
25
26
|
# File 'lib/sup/modes/inbox_mode.rb', line 21
def refine_search
text = BufferManager.ask :search, "refine inbox with query: "
return unless text && text !~ /^\s*$/
text = "label:inbox -label:spam -label:deleted " + text
SearchResultsMode.spawn_from_query text
end
|
122
123
124
|
# File 'lib/sup/modes/inbox_mode.rb', line 122
def status
super + " #{Index.size} messages in index"
end
|