class Redwood::ContactListMode
Constants
- LOAD_MORE_CONTACTS_NUM
Public Class Methods
new(mode=:regular)
click to toggle source
Calls superclass method
# File lib/sup/modes/contact_list_mode.rb, line 30 def initialize mode=:regular @mode = mode @tags = Tagger.new self, "contact" @num = nil @text = [] super() end
Public Instance Methods
[](i;)
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 46 def [] i; @text[i]; end
alias()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 39 def alias p = @contacts[curpos] or return alias_contact p update end
apply_to_tagged()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 60 def apply_to_tagged; @tags.apply_to_tagged; end
lines()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 45 def lines; @text.length; end
load()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 108 def load @num ||= (buffer.content_height * 2) @user_contacts = ContactManager.contacts_with_aliases @user_contacts += (HookManager.run("extra-contact-addresses") || []).map { |addr| Person.from_address addr } num = [@num - @user_contacts.length, 0].max BufferManager.say("Loading #{num} contacts from index...") do recentc = Index.load_contacts AccountManager.user_emails, :num => num @contacts = (@user_contacts + recentc).sort_by { |p| p.sort_by_me }.uniq end end
load_in_background()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 100 def load_in_background Redwood::reporting_thread("contact manager load in bg") do load update BufferManager.draw_screen end end
load_more(num=LOAD_MORE_CONTACTS_NUM)
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 62 def load_more num=LOAD_MORE_CONTACTS_NUM @num += num load update BufferManager.flash "Added #{num.pluralize 'contact'}." end
multi_search(people)
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 83 def multi_search people mode = PersonSearchResultsMode.new people BufferManager.spawn "search for #{people.map { |p| p.name }.join(', ')}", mode mode.load_threads :num => mode.buffer.content_height end
multi_select(people)
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 69 def multi_select people case @mode when :regular mode = ComposeMode.new :to => people BufferManager.spawn "new message", mode mode.default_edit_message end end
multi_toggle_tagged(threads)
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 55 def multi_toggle_tagged threads @tags.drop_all_tags update end
reload()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 94 def reload @tags.drop_all_tags @num = nil load end
search()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 89 def search p = @contacts[curpos] or return multi_search [p] end
select()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 78 def select p = @contacts[curpos] or return multi_select [p] end
toggle_tagged()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 48 def toggle_tagged p = @contacts[curpos] or return @tags.toggle_tag_for p update_text_for_line curpos cursor_down end
Protected Instance Methods
regen_text()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 137 def regen_text @awidth, @nwidth = 0, 0 @contacts.each do |p| aalias = ContactManager.alias_for(p) @awidth = aalias.length if aalias && aalias.length > @awidth @nwidth = p.name.length if p.name && p.name.length > @nwidth end @text = @contacts.map { |p| text_for_contact p } end
text_for_contact(p)
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 131 def text_for_contact p aalias = ContactManager.alias_for(p) || "" [[:tagged_color, @tags.tagged?(p) ? ">" : " "], [:text_color, sprintf("%-#{@awidth}s %-#{@nwidth}s %s", aalias, p.name, p.email)]] end
update()
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 121 def update regen_text buffer.mark_dirty if buffer end
update_text_for_line(line)
click to toggle source
# File lib/sup/modes/contact_list_mode.rb, line 126 def update_text_for_line line @text[line] = text_for_contact @contacts[line] buffer.mark_dirty if buffer end