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
- #alt? ⇒ Boolean
- #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
70 71 72 |
# File 'lib/terminal.rb', line 70 def action @action end |
#button ⇒ Object
Returns the value of attribute button
70 71 72 |
# File 'lib/terminal.rb', line 70 def end |
#modifiers ⇒ Object
Returns the value of attribute modifiers
70 71 72 |
# File 'lib/terminal.rb', line 70 def modifiers @modifiers end |
#x ⇒ Object
Returns the value of attribute x
70 71 72 |
# File 'lib/terminal.rb', line 70 def x @x end |
#y ⇒ Object
Returns the value of attribute y
70 71 72 |
# File 'lib/terminal.rb', line 70 def y @y end |
Instance Method Details
#alt? ⇒ Boolean
79 |
# File 'lib/terminal.rb', line 79 def alt?; ( modifiers & 8 ) != 0 end |
#left? ⇒ Boolean
76 |
# File 'lib/terminal.rb', line 76 def left?; == 0 end |
#middle? ⇒ Boolean
77 |
# File 'lib/terminal.rb', line 77 def middle?; == 1 end |
#press? ⇒ Boolean
71 |
# File 'lib/terminal.rb', line 71 def press?; action == :press end |
#release? ⇒ Boolean
72 |
# File 'lib/terminal.rb', line 72 def release?; action == :release end |
#right? ⇒ Boolean
78 |
# File 'lib/terminal.rb', line 78 def right?; == 2 end |
#to_s ⇒ Object
80 81 |
# File 'lib/terminal.rb', line 80 def to_s; "%s button=%i x=%i y=%i%s" % [ action, , x, y, ( modifiers > 0 ? " modifiers=#{modifiers}" : "" ) ] end |
#wheel? ⇒ Boolean
73 |
# File 'lib/terminal.rb', line 73 def wheel?; .between?(4, 7) end |
#wheel_down? ⇒ Boolean
75 |
# File 'lib/terminal.rb', line 75 def wheel_down?; == 5 end |
#wheel_up? ⇒ Boolean
74 |
# File 'lib/terminal.rb', line 74 def wheel_up?; == 4 end |