enum
Termisu::Input::Modifier
Overview
Keyboard modifier flags for input events.
Modifiers can be combined using bitwise OR (|). XTerm encodes modifiers as: code = 1 + (shift1 + alt2 + ctrl4 + meta8)
Example:
event = termisu.poll_event
if event.is_a?(Termisu::Event::Key)
if event.modifiers.ctrl? && event.key.lower_c?
puts "Ctrl+C pressed!"
end
end
Defined in:
termisu/input/modifier.crEnum Members
-
None =
0_u8 -
No modifiers
-
Shift =
1_u8 -
Shift key
-
Alt =
2_u8 -
Alt/Option key
-
Ctrl =
4_u8 -
Control key
-
Meta =
8_u8 -
Meta/Super/Windows key
-
All =
15_u8
Constructors
-
.from_mouse_cb(cb : Int32) : Modifier
Decodes mouse button modifiers from the Cb byte.
-
.from_xterm_code(code : Int32) : Modifier
Decodes an XTerm modifier code to Modifier flags.
Instance Method Summary
-
#alt?
Returns
trueif this enum value containsAlt -
#ctrl?
Returns
trueif this enum value containsCtrl -
#meta?
Returns
trueif this enum value containsMeta -
#none?
Returns
trueif this enum value containsNone -
#shift?
Returns
trueif this enum value containsShift
Constructor Detail
Decodes mouse button modifiers from the Cb byte.
In mouse protocols, modifiers are encoded as:
- Bit 2 (4) = Shift
- Bit 3 (8) = Meta/Alt
- Bit 4 (16) = Control
Decodes an XTerm modifier code to Modifier flags.
XTerm encoding: code = 1 + (shift1 + alt2 + ctrl4 + meta8) So we subtract 1 to get the raw flags.