Class: Minder::QuickAddFrame

Inherits:
Frame
  • Object
show all
Defined in:
lib/minder/cli/quick_add_frame.rb

Instance Attribute Summary collapse

Attributes inherited from Frame

#height, #left, #lines, #min_height, #pomodoro_runner, #task_manager, #top, #width, #window

Instance Method Summary collapse

Methods inherited from Frame

#build_window, #erase, #focus, #focused?, #handle_keypress, #has_cursor?, #hidden?, #hide, #listen, #move, #parse_template, #print_line, #refresh, #resize, #unfocus, #unhide, #window_refresh

Constructor Details

#initializeQuickAddFrame

Returns a new instance of QuickAddFrame.



7
8
9
10
# File 'lib/minder/cli/quick_add_frame.rb', line 7

def initialize(*)
  super
  self.input = ''
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



5
6
7
# File 'lib/minder/cli/quick_add_frame.rb', line 5

def input
  @input
end

Instance Method Details

#handle_char_keypress(key) ⇒ Object



27
28
29
30
# File 'lib/minder/cli/quick_add_frame.rb', line 27

def handle_char_keypress(key)
  self.input += key
  refresh
end

#handle_non_char_keypress(key) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/minder/cli/quick_add_frame.rb', line 32

def handle_non_char_keypress(key)
  case key
  when *Curses::Key::BACKSPACE, 127
    self.input.chop!
    refresh
  when 10
    changed
    notify_observers(:add_task, { task: input })
    self.input = ''
    refresh
  end
end

#set_cursor_positionObject



23
24
25
# File 'lib/minder/cli/quick_add_frame.rb', line 23

def set_cursor_position
  window.setpos(1, template.strip.length + 2 + input.length)
end

#set_textObject



18
19
20
21
# File 'lib/minder/cli/quick_add_frame.rb', line 18

def set_text
  self.lines[0] += ' ' + input
  super
end

#templateObject



12
13
14
15
16
# File 'lib/minder/cli/quick_add_frame.rb', line 12

def template
  <<-TEXT
Quick add task:
TEXT
end