Class: Redwood::ResumeMode

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

Constant Summary

Constant Summary

Constants inherited from EditMessageMode

EditMessageMode::DECORATION_LINES, 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

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, #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, #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, #status

Constructor Details

#initialize(m) ⇒ ResumeMode

Returns a new instance of ResumeMode



4
5
6
7
8
9
10
11
12
# File 'lib/sup/modes/resume-mode.rb', line 4

def initialize m
  @m = m
  @safe = false

  header, body = parse_file m.draft_filename
  header.delete "Date"

  super :header => header, :body => body, :have_signature => true
end

Instance Method Details

#killable?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sup/modes/resume-mode.rb', line 14

def killable?
  return true if @safe

  case BufferManager.ask_yes_or_no "Discard draft?"
  when true
    DraftManager.discard @m
    BufferManager.flash "Draft discarded."
    true
  when false
    if edited?
      DraftManager.write_draft { |f| write_message f, false }
      DraftManager.discard @m
      BufferManager.flash "Draft saved."
    end
    true
  else
    false
  end
end

#save_as_draftObject



41
42
43
44
# File 'lib/sup/modes/resume-mode.rb', line 41

def save_as_draft
  @safe = true
  DraftManager.discard @m if super
end

#send_messageObject



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

def send_message
  if super
    DraftManager.discard @m 
    @safe = true
  end
end