struct Tput::InputEvent

Overview

One unit of terminal input, as yielded by Tput::Input#listen. Exactly one kind is meaningful per event — mouse report, paste, in-band resize, or key transition — told apart with the predicates below; remaining fields are nil.

Defined in:

tput/input.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(char : Char, key : Tput::Key | Nil = nil, sequence : Array(Char) | Nil = nil, mouse : Tput::Mouse::Event | Nil = nil, key_event : Tput::KeyEvent | Nil = nil, paste : Nil | String = nil, resize : Tput::Resize | Nil = nil, color_scheme : Tput::ColorScheme | Nil = nil, clipboard : Nil | String = nil) #

[View source]

Instance Method Detail

def char : Char #

[View source]
def clipboard : String | Nil #

Decoded text of an OSC 52 clipboard read reply (request_clipboard). Distinct from #paste: this is the answer to a programmatic clipboard query, not user-pasted input.


[View source]
def clipboard? : Bool #

Whether this event is an OSC 52 clipboard read reply.


[View source]
def color_scheme : ColorScheme | Nil #

[View source]
def color_scheme? : Bool #

Whether this event is a color-scheme (light/dark) change report.


[View source]
def key : Key | Nil #

[View source]
def key_event : KeyEvent | Nil #

[View source]
def key_transition? : Bool #

Whether this event is a key transition (not mouse/paste/resize/scheme/clipboard).


[View source]
def mouse : Mouse::Event | Nil #

[View source]
def mouse? : Bool #

Whether this event is a mouse/focus report.


[View source]
def paste : String | Nil #

[View source]
def paste? : Bool #

Whether this event is a bracketed paste.


[View source]
def release? : Bool #

Whether this is a key release (only when enhanced event reporting is on).


[View source]
def repeat? : Bool #

Whether this is an auto-repeat key event.


[View source]
def resize : Resize | Nil #

[View source]
def resize? : Bool #

Whether this event is an in-band resize report.


[View source]
def sequence : Array(Char) #

Raw input bytes for this event. A single-character event carries no array — #listen passes nil and the byte is reconstructed here on demand, so plain typing allocates nothing unless a consumer reads the sequence.


[View source]
def sequence? : Array(Char) | Nil #

The raw input sequence as storednil for a single-character event (plain typing). Unlike #sequence, this never materializes a one-element [@char] array, so a consumer that can carry the nilable form through avoids the per-keypress allocation.


[View source]