Class: Typr::Mouse
- Inherits:
-
Struct
- Object
- Struct
- Typr::Mouse
- Defined in:
- lib/terminal.rb
Overview
A mouse event decoded from the input stream. x / y are 1-based
terminal coordinates; button is 0=left, 1=middle, 2=right, or 4-7 for
the wheel (up/down/left/right); modifiers holds the SGR shift/alt/ctrl
bits. Non-widget code can test key.is_a?(Typr::Mouse).
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#button ⇒ Object
Returns the value of attribute button.
-
#modifiers ⇒ Object
Returns the value of attribute modifiers.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #left? ⇒ Boolean
- #middle? ⇒ Boolean
- #press? ⇒ Boolean
- #release? ⇒ Boolean
- #right? ⇒ Boolean
- #to_s ⇒ Object
- #wheel? ⇒ Boolean
- #wheel_down? ⇒ Boolean
- #wheel_up? ⇒ Boolean
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
64 65 66 |
# File 'lib/terminal.rb', line 64 def action @action end |
#button ⇒ Object
Returns the value of attribute button
64 65 66 |
# File 'lib/terminal.rb', line 64 def @button end |
#modifiers ⇒ Object
Returns the value of attribute modifiers
64 65 66 |
# File 'lib/terminal.rb', line 64 def modifiers @modifiers end |
#x ⇒ Object
Returns the value of attribute x
64 65 66 |
# File 'lib/terminal.rb', line 64 def x @x end |
#y ⇒ Object
Returns the value of attribute y
64 65 66 |
# File 'lib/terminal.rb', line 64 def y @y end |
Instance Method Details
#left? ⇒ Boolean
70 |
# File 'lib/terminal.rb', line 70 def left?; == 0 end |
#middle? ⇒ Boolean
71 |
# File 'lib/terminal.rb', line 71 def middle?; == 1 end |
#press? ⇒ Boolean
65 |
# File 'lib/terminal.rb', line 65 def press?; action == :press end |
#release? ⇒ Boolean
66 |
# File 'lib/terminal.rb', line 66 def release?; action == :release end |
#right? ⇒ Boolean
72 |
# File 'lib/terminal.rb', line 72 def right?; == 2 end |
#to_s ⇒ Object
73 74 |
# File 'lib/terminal.rb', line 73 def to_s; "%s button=%i x=%i y=%i%s" % [ action, , x, y, ( modifiers > 0 ? " modifiers=#{modifiers}" : "" ) ] end |
#wheel? ⇒ Boolean
67 |
# File 'lib/terminal.rb', line 67 def wheel?; .between?(4, 7) end |
#wheel_down? ⇒ Boolean
69 |
# File 'lib/terminal.rb', line 69 def wheel_down?; == 5 end |
#wheel_up? ⇒ Boolean
68 |
# File 'lib/terminal.rb', line 68 def wheel_up?; == 4 end |