Class: Redwood::ForwardMode

Inherits:
EditMessageMode show all
Defined in:
lib/sup/modes/forward-mode.rb

Constant Summary

Constants inherited from EditMessageMode

EditMessageMode::FORCE_HEADERS, EditMessageMode::MULTI_HEADERS, EditMessageMode::NON_EDITABLE_HEADERS

Constants inherited from ScrollMode

ScrollMode::COL_JUMP

Instance Attribute Summary

Attributes inherited from EditMessageMode

#body, #header, #status

Attributes inherited from LineCursorMode

#curpos

Attributes inherited from ScrollMode

#botline, #leftcol, #status, #topline

Attributes inherited from Mode

#buffer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from EditMessageMode

#[], #attach_file, #delete_attachment, #edit_cc, #edit_message, #edit_message_or_field, #edit_subject, #edit_to, #handle_new_text, #killable?, #lines

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, #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_in_buffer, #search_start_line

Methods inherited from Mode

#blur, #cancel_search!, #cleanup, #draw, #focus, #handle_input, #help_text, #in_search?, #killable?, load_all_modes, make_name, #name, register_keymap, #resize, #resolve_input, #save_to_file, #status

Constructor Details

#initialize(m, opts = {}) ⇒ ForwardMode

todo: share some of this with reply-mode



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sup/modes/forward-mode.rb', line 6

def initialize m, opts={}
  header = {
    "From" => AccountManager..full_address,
    "Subject" => "Fwd: #{m.subj}",
  }

  header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to]
  header["Cc"] = opts[:cc].map { |p| p.full_address }.join(", ") if opts[:cc]
  header["Bcc"] = opts[:bcc].map { |p| p.full_address }.join(", ") if opts[:bcc]

  super :header => header, :body => forward_body_lines(m)
end

Class Method Details

.spawn_nicely(m, opts = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/sup/modes/forward-mode.rb', line 19

def self.spawn_nicely m, opts={}
  to = opts[:to] || BufferManager.ask_for_contacts(:people, "To: ") or return
  cc = opts[:cc] || BufferManager.ask_for_contacts(:people, "Cc: ") or return if $config[:ask_for_cc]
  bcc = opts[:bcc] || BufferManager.ask_for_contacts(:people, "Bcc: ") or return if $config[:ask_for_bcc]
  
  mode = ForwardMode.new m, :to => to, :cc => cc, :bcc => bcc
  BufferManager.spawn "Forwarding #{m.subj}", mode
  mode.edit_message
end