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.cr

Enum 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

Instance Method Summary

Constructor Detail

def self.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

[View source]
def self.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.


[View source]

Instance Method Detail

def alt? #

Returns true if this enum value contains Alt


[View source]
def ctrl? #

Returns true if this enum value contains Ctrl


[View source]
def meta? #

Returns true if this enum value contains Meta


[View source]
def none? #

Returns true if this enum value contains None


[View source]
def shift? #

Returns true if this enum value contains Shift


[View source]