Class: Redwood::ForwardMode
- Inherits:
-
EditMessageMode
- Object
- Mode
- ScrollMode
- LineCursorMode
- EditMessageMode
- Redwood::ForwardMode
- Defined in:
- lib/sup/modes/forward_mode.rb
Constant Summary
Constants inherited from EditMessageMode
EditMessageMode::DECORATION_LINES, EditMessageMode::FORCE_HEADERS, EditMessageMode::MULTI_HEADERS, EditMessageMode::NON_EDITABLE_HEADERS
Instance Attribute Summary
Attributes inherited from EditMessageMode
Attributes inherited from LineCursorMode
Attributes inherited from ScrollMode
#botline, #leftcol, #status, #topline
Attributes inherited from Mode
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ ForwardMode
constructor
TODO: share some of this with reply-mode.
Methods inherited from EditMessageMode
#[], #attach_file, #delete_attachment, #edit_cc, #edit_message, #edit_message_async, #edit_message_async_resume, #edit_message_or_field, #edit_subject, #edit_to, #handle_new_text, #killable?, #lines, #save_message_to_file, #set_sig_edit_flag, #unsaved?
Methods inherited from LineCursorMode
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, #killable?, load_all_modes, make_name, #name, #pipe_to_process, register_keymap, #resize, #resolve_input, #save_to_file, #status, #unsaved?
Constructor Details
#initialize(opts = {}) ⇒ ForwardMode
TODO: share some of this with reply-mode
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sup/modes/forward_mode.rb', line 5 def initialize opts={} header = { "From" => AccountManager.default_account.full_address, } header["Subject"] = if opts[:message] "Fwd: " + opts[:message].subj elsif opts[:attachments] "Fwd: " + opts[:attachments].keys.join(", ") end 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] body = if opts[:message] forward_body_lines(opts[:message]) elsif opts[:attachments] ["Note: #{opts[:attachments].size.pluralize 'attachment'}."] end super :header => header, :body => body, :attachments => opts[:attachments] end |
Class Method Details
.spawn_nicely(opts = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sup/modes/forward_mode.rb', line 31 def self.spawn_nicely opts={} to = opts[:to] || (BufferManager.ask_for_contacts(:people, "To: ") or return if ($config[:ask_for_to] != false)) 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]) = {} = opts[:attachments] || [] if(m = opts[:message]) m.load_from_source! # read the full message in. you know, maybe i should just make Message#chunks do this.... += m.chunks.select { |c| c.is_a?(Chunk::Attachment) && !c.quotable? } end .each do |c| mime_type = MIME::Types[c.content_type].first || MIME::Types["application/octet-stream"].first [c.filename] = RMail::Message. c.raw_content, mime_type.content_type, mime_type.encoding, c.filename end mode = ForwardMode.new :message => opts[:message], :to => to, :cc => cc, :bcc => bcc, :attachments => title = "Forwarding " + if opts[:message] opts[:message].subj elsif .keys.join(", ") else "something" end BufferManager.spawn title, mode mode. end |