enum

Termisu::Input::Modifier

Inherits Enum / Comparable / Value / Object

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

Constants

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.

In mouse protocols, modifiers are encoded as:

  • Bit 2 (4) = Shift
  • Bit 3 (8) = Meta/Alt
  • Bit 4 (16) = Control
Source
from_xterm_code(code : Int32) : Modifier

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.

Source

Instance methods

alt?

Returns true if this enum value contains Alt

Source
ctrl?

Returns true if this enum value contains Ctrl

Source
meta?

Returns true if this enum value contains Meta

Source
none?

Returns true if this enum value contains None

Source
shift?

Returns true if this enum value contains Shift

Source