Class: Redwood::InboxMode

Inherits:
ThreadIndexMode show all
Defined in:
lib/sup/modes/inbox-mode.rb

Constant Summary

Constant Summary

Constants inherited from ThreadIndexMode

ThreadIndexMode::DATE_WIDTH, ThreadIndexMode::LOAD_MORE_THREAD_NUM, ThreadIndexMode::MIN_FROM_WIDTH

Constants inherited from ScrollMode

ScrollMode::COL_JUMP

Instance Attribute Summary

Attributes inherited from LineCursorMode

#curpos

Attributes inherited from ScrollMode

#botline, #leftcol, #topline

Attributes inherited from Mode

#buffer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ThreadIndexMode

#[], #actually_save, #actually_toggle_archived, #actually_toggle_deleted, #actually_toggle_spammed, #actually_toggle_starred, #apply_to_tagged, #cancel_search, #cleanup, #contains_thread?, #edit_labels, #edit_message, #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, #resize, #save, #select, #tag_matching, #toggle_archived, #toggle_deleted, #toggle_new, #toggle_spam, #toggle_starred, #toggle_tagged, #toggle_tagged_all, #update

Methods inherited from LineCursorMode

#draw

Methods inherited from ScrollMode

#at_bottom?, #at_top?, #cancel_search!, #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?, load_all_modes, make_name, #name, #pipe_to_process, register_keymap, #resize, #resolve_input, #save_to_file

Constructor Details

#initializeInboxMode



12
13
14
15
16
# File 'lib/sup/modes/inbox-mode.rb', line 12

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

.instanceObject

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



24
# File 'lib/sup/modes/inbox-mode.rb', line 24

def self.instance; @@instance; end

Instance Method Details

#archiveObject



27
28
29
30
31
32
# File 'lib/sup/modes/inbox-mode.rb', line 27

def archive
  return unless cursor_thread
  cursor_thread.remove_label :inbox
  hide_thread cursor_thread
  regen_text
end

#handle_archived_update(sender, m) ⇒ Object



63
64
65
66
67
# File 'lib/sup/modes/inbox-mode.rb', line 63

def handle_archived_update sender, m
  t = thread_containing(m) or return
  hide_thread t
  regen_text
end

#handle_unarchived_update(sender, m) ⇒ Object



59
60
61
# File 'lib/sup/modes/inbox-mode.rb', line 59

def handle_unarchived_update sender, m
  add_or_unhide m
end

#is_relevant?(m) ⇒ Boolean



18
19
20
# File 'lib/sup/modes/inbox-mode.rb', line 18

def is_relevant? m
  m.has_label?(:inbox) && ([:spam, :deleted, :killed] & m.labels).empty?
end

#killable?Boolean



25
# File 'lib/sup/modes/inbox-mode.rb', line 25

def killable?; false; end

#multi_archive(threads) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/sup/modes/inbox-mode.rb', line 34

def multi_archive threads
  threads.each do |t|
    t.remove_label :inbox
    hide_thread t
  end
  regen_text
end

#multi_read_and_archive(threads) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/sup/modes/inbox-mode.rb', line 50

def multi_read_and_archive threads
  threads.each do |t|
    t.remove_label :unread
    t.remove_label :inbox
    hide_thread t
  end
  regen_text
end

#read_and_archiveObject



42
43
44
45
46
47
48
# File 'lib/sup/modes/inbox-mode.rb', line 42

def read_and_archive
  return unless cursor_thread
  cursor_thread.remove_label :unread
  cursor_thread.remove_label :inbox
  hide_thread cursor_thread
  regen_text
end

#statusObject



69
70
71
# File 'lib/sup/modes/inbox-mode.rb', line 69

def status
  super + "    #{Index.size} messages in index"
end