Class: Fatty::Curses::EventSource
- Inherits:
-
Object
- Object
- Fatty::Curses::EventSource
- Defined in:
- lib/fatty/curses/event_source.rb
Constant Summary collapse
- MOUSE_BSTATE_BUTTON_MAP =
{ ::Curses::BUTTON1_PRESSED => :left_pressed, ::Curses::BUTTON1_RELEASED => :left_released, ::Curses::BUTTON1_CLICKED => :left_clicked, ::Curses::BUTTON1_DOUBLE_CLICKED => :left_double_clicked, ::Curses::BUTTON1_TRIPLE_CLICKED => :left_triple_clicked, ::Curses::BUTTON2_PRESSED => :middle_pressed, ::Curses::BUTTON2_RELEASED => :middle_released, ::Curses::BUTTON2_CLICKED => :middle_clicked, ::Curses::BUTTON2_DOUBLE_CLICKED => :middle_double_clicked, ::Curses::BUTTON2_TRIPLE_CLICKED => :middle_triple_clicked, ::Curses::BUTTON3_PRESSED => :right_pressed, ::Curses::BUTTON3_RELEASED => :right_released, ::Curses::BUTTON3_CLICKED => :right_clicked, ::Curses::BUTTON3_DOUBLE_CLICKED => :right_double_clicked, ::Curses::BUTTON3_TRIPLE_CLICKED => :right_triple_clicked }.freeze
- SCROLL_UP_BSTATE =
::Curses::BUTTON4_PRESSED
- SCROLL_DOWN_BSTATE =
0x10000000- MOUSE_MODIFIER_MASK =
::Curses::BUTTON_CTRL | ::Curses::BUTTON_ALT | ::Curses::BUTTON_SHIFT
- ESCAPE_LOOKAHEAD_MS =
0- BRACKETED_PASTE_START =
"[200~"- BRACKETED_PASTE_END =
"\e[201~"
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#key_decoder ⇒ Object
readonly
Returns the value of attribute key_decoder.
Instance Method Summary collapse
-
#initialize(context: Context.new, key_decoder: nil, poll_ms: 200) ⇒ EventSource
constructor
A new instance of EventSource.
- #interrupt_pending? ⇒ Boolean
- #next_event ⇒ Object
Constructor Details
#initialize(context: Context.new, key_decoder: nil, poll_ms: 200) ⇒ EventSource
Returns a new instance of EventSource.
40 41 42 43 44 45 |
# File 'lib/fatty/curses/event_source.rb', line 40 def initialize(context: Context.new, key_decoder: nil, poll_ms: 200) @context = context @key_decoder = key_decoder || KeyDecoder.new @poll_ms = poll_ms.to_i configure_input_polling! end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
38 39 40 |
# File 'lib/fatty/curses/event_source.rb', line 38 def context @context end |
#key_decoder ⇒ Object (readonly)
Returns the value of attribute key_decoder.
38 39 40 |
# File 'lib/fatty/curses/event_source.rb', line 38 def key_decoder @key_decoder end |
Instance Method Details
#interrupt_pending? ⇒ Boolean
51 52 53 54 55 56 57 |
# File 'lib/fatty/curses/event_source.rb', line 51 def interrupt_pending? command = read_event(timeout_ms: 0) interrupted = interrupt_command?(command) pending_events << command if command && !interrupted interrupted end |
#next_event ⇒ Object
47 48 49 |
# File 'lib/fatty/curses/event_source.rb', line 47 def next_event pending_events.shift || read_event end |