module Termisu::FFI::Conversions

Defined in:

termisu/ffi/conversions.cr

Constant Summary

ATTRIBUTE_MASK = (((((((Attribute::Bold.value | Attribute::Underline.value) | Attribute::Reverse.value) | Attribute::Blink.value) | Attribute::Dim.value) | Attribute::Cursive.value) | Attribute::Hidden.value) | Attribute::Strikethrough.value).to_u16

Class Method Summary

Class Method Detail

def self.attr_from_bits(bits : UInt16) : Attribute #

[View source]
def self.blank_event : Termisu::FFI::ABI::Event #

Fully zeroed None event, deterministic across every field. The FFI poll hot path uses write_blank_event instead, which skips the memset.


[View source]
def self.codepoint_to_char(codepoint : UInt32) : Char #

[View source]
def self.color_from_abi(color : Termisu::FFI::ABI::Color) : Color #

[View source]
def self.style_from_abi(style : Termisu::FFI::ABI::CellStyle) : Tuple(Color, Color, Attribute) #

[View source]
def self.style_from_ptr(style : Pointer(Termisu::FFI::ABI::CellStyle)) : Tuple(Color, Color, Attribute) #

[View source]
def self.to_abi_event(event : Event::Any) : Termisu::FFI::ABI::Event #

[View source]
def self.write_abi_event(event : Event::Any, out_event : Pointer(Termisu::FFI::ABI::Event)) : Nil #

Writes event into the caller's struct in place, without zeroing it first. ABI readers dispatch on event_type and only touch that type's fields (see readEvent in javascript/core/src/structs.ts): event_type and modifiers are always read; key_, mouse_, resize_, tick_, mode_* and preedit_* only for their own type, with resize_old_/mode_previous gated behind their has_ flags. Each writer below sets exactly that read-set (writing explicit zeros for absent optional fields), so any other byte in the caller's buffer may keep stale content.


[View source]
def self.write_blank_event(out_event : Pointer(Termisu::FFI::ABI::Event)) : Nil #

No-event marker (poll timeout): readers only touch event_type and modifiers for a None event; key_char = -1 is kept as the "no char" sentinel blank_event has always guaranteed.


[View source]