Module: RETerm::ComponentInput

Included in:
RETerm::Components::Dial, RETerm::Components::Rocker, RETerm::Components::VSlider
Defined in:
lib/reterm/mixins/component_input.rb

Overview

Helper mixin defining standard input controls for custom components. ‘In House’ components included in the project may used this to standarding their usage.

Constant Summary collapse

QUIT_CONTROLS =

Key which if pressed cause the component to lose focus / become deactivated

[10, 27]
INC_CONTROLS =

Keys if pressed invoked the increment operation

['+'.ord, Ncurses::KEY_UP, Ncurses::KEY_RIGHT]
DEC_CONTROLS =

Keys if pressed invoked the decrement operation

['-'.ord, Ncurses::KEY_DOWN, Ncurses::KEY_LEFT]

Instance Method Summary collapse

Instance Method Details

#handle_inputObject

Helper to be internally invoked by component on activation



27
28
29
30
31
32
33
34
35
# File 'lib/reterm/mixins/component_input.rb', line 27

def handle_input
  while(!QUIT_CONTROLS.include?((ch = window.getch)))
    if INC_CONTROLS.include?(ch)
      on_inc
    elsif DEC_CONTROLS.include?(ch)
      on_dec
    end
  end
end

#on_decObject

May be overrideen in subclass, invoked when the user requests a decrement



23
24
# File 'lib/reterm/mixins/component_input.rb', line 23

def on_dec
end

#on_incObject

May be overrideen in subclass, invoked when the user requests an ‘increment’



18
19
# File 'lib/reterm/mixins/component_input.rb', line 18

def on_inc
end