class TerminalNotes::SearchField

Constants

ALIGN
HEIGHT
POS_X
POS_Y
WIDTH

Public Class Methods

new(parent:) click to toggle source
Calls superclass method
# File lib/terminal-notes/search_field.rb, line 9
def initialize(parent:)
    super(parent: parent, title: "Search",
          width: WIDTH, height: HEIGHT,
          x: POS_X, y: POS_Y,
          align: ALIGN)

    @text_field = TextField.new(@parent,
        position: @position.dup.moveBy(2, 2),
        width:    @width - 4)

    @has_focus = false

    draw
end

Public Instance Methods

focus() click to toggle source
# File lib/terminal-notes/search_field.rb, line 28
def focus
    @has_focus = true
    @text_field.draw
end
on_key(key) click to toggle source
# File lib/terminal-notes/search_field.rb, line 41
def on_key key
    return unless @has_focus
    @text_field.on_key(key)
end
on_text_changed(&delegate) click to toggle source
# File lib/terminal-notes/search_field.rb, line 37
def on_text_changed &delegate
    @text_field.on_text_changed { |p| delegate.call(p) }
end
text() click to toggle source
# File lib/terminal-notes/search_field.rb, line 24
def text
    @text_field.text
end
unfocus() click to toggle source
# File lib/terminal-notes/search_field.rb, line 33
def unfocus
    @has_focus = false
end