class Minder::MessageFrame
Attributes
current_line[R]
task_editor[R]
Public Class Methods
new(*)
click to toggle source
Calls superclass method
Minder::Frame::new
# File lib/minder/cli/message_frame.rb, line 9 def initialize(*) super self.height = desired_height @minimized = false @editing = false end
Public Instance Methods
allocated_tasks_height()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 91 def allocated_tasks_height height - header_text_lines.length - 3 end
desired_height()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 84 def desired_height return 3 if minimized? # TODO: figure out what this magic 3 number is header_text_lines.length + tasks_text_lines.length + 3 end
doing_message()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 103 def doing_message header_text + offset_tasks_text end
editing?()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 29 def editing? @editing end
handle_char_keypress(key)
click to toggle source
# File lib/minder/cli/message_frame.rb, line 154 def handle_char_keypress(key) event = case key when 'j' then :select_next_task when 'k' then :select_previous_task when 'd' then :complete_task when 'x' then :delete_task when 's' then :start_task when 'u' then :unstart_task when 'G' then :select_last_task when 'e' @editing = true @task_editor = TaskEditor.new(task_manager.selected_task, self) @task_editor.add_observer(self, :handle_task_editor_event) :edit_task when '?' then :help when '/' then :search when 'm' minimize :redraw when 'n' then :next_search when 'N' then :previous_search when 'f' then :open_filter when 'g' @keypress_memory ||= [] @keypress_memory << 'g' if @keypress_memory == ['g', 'g'] @keypress_memory = [] :select_first_task end when ' ' if minimized? unminimize :redraw end end changed notify_observers(event) end
handle_keypress(key)
click to toggle source
Calls superclass method
Minder::Frame#handle_keypress
# File lib/minder/cli/message_frame.rb, line 132 def handle_keypress(key) if editing? task_editor.handle_keypress(key) else super end end
handle_task_editor_event(event, data = {})
click to toggle source
# File lib/minder/cli/message_frame.rb, line 140 def handle_task_editor_event(event, data = {}) if event == :stop_editing @editing = false @task_editor = nil elsif event == :update_task task_manager.update_task(task_manager.selected_task, data) @editing = false @task_editor = nil end changed notify_observers(event) end
header_text()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 57 def header_text <<-TEXT Tasks ? to see commands TEXT end
header_text_lines()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 80 def header_text_lines header_text.split("\n") end
minimize()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 16 def minimize @minimized = true end
minimized?()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 25 def minimized? @minimized end
minimized_message()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 43 def minimized_message <<-TEXT Space to see tasks TEXT end
offset_tasks_text()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 95 def offset_tasks_text tasks_text_lines[visible_tasks_range].join("\n") end
prompt_message()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 49 def prompt_message <<-TEXT What are you working on? Press (e) to open editor. TEXT end
scroll_offset()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 123 def scroll_offset position = task_manager.selected_task_index + 1 if position > allocated_tasks_height position - allocated_tasks_height else 0 end end
set_cursor_position()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 108 def set_cursor_position if minimized? window.setpos(1, 20) elsif editing? window.setpos(3 + task_manager.selected_task_index - scroll_offset, task_editor.cursor_position + 6) else window.setpos(3 + task_manager.selected_task_index - scroll_offset, 3) end end
tasks_text()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 64 def tasks_text text = '' task_manager.tasks.each do |task| if task.started? text += "-[*] #{task}\n" else text += "-[ ] #{task}\n" end end text end
tasks_text_lines()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 76 def tasks_text_lines tasks_text.split("\n") end
template()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 33 def template if minimized? minimized_message elsif task_manager.tasks? doing_message else prompt_message end end
total_tasks_height()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 119 def total_tasks_height task_manager.tasks.length end
unminimize()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 20 def unminimize @minimized = false self.height = desired_height end
visible_tasks_range()
click to toggle source
# File lib/minder/cli/message_frame.rb, line 99 def visible_tasks_range (scroll_offset..(allocated_tasks_height + scroll_offset - 1)) end