module

Termisu::FFI

C ABI bridge for non-Crystal integrations.

Exposes stable C symbols, opaque handles, flat structs, and explicit status/error handling for FFI callers.

Lives at ffi/ffi.cr (not termisu/ffi.cr) so the require "./termisu/*" glob in src/termisu.cr cannot reach it - plain require "termisu" consumers must not link the exported C symbols. Build src/termisu_ffi.cr to produce libtermisu.

Constants

ABI_VERSION = 1_u32
PREEDIT_TEXT_CAPACITY = 32

Inline capacity (bytes) for ABI::Event preedit text. Composing strings are short (a handful of codepoints); longer preedit is truncated on a boundary.

Class methods

bracketed_paste?(handle : UInt64) : UInt8
Source
clear(handle : UInt64) : Status
Source
clear_error_message
Source
close(handle : UInt64) : Status
Source
copy_last_error(buffer : Pointer(UInt8), buffer_len : UInt64) : UInt64
Source
create(sync_updates : Bool) : UInt64
Source
destroy(handle : UInt64) : Status
Source
disable_bracketed_paste(handle : UInt64) : Status
Source
disable_enhanced_keyboard(handle : UInt64) : Status
Source
disable_mouse(handle : UInt64) : Status
Source
disable_timer(handle : UInt64) : Status
Source
enable_bracketed_paste(handle : UInt64) : Status
Source
enable_enhanced_keyboard(handle : UInt64) : Status
Source
enable_mouse(handle : UInt64) : Status
Source
enable_system_timer_ms(handle : UInt64, interval_ms : Int32) : Status
Source
enable_timer_ms(handle : UInt64, interval_ms : Int32) : Status
Source
enhanced_keyboard?(handle : UInt64) : UInt8
Source
hide_cursor(handle : UInt64) : Status
Source
last_error_length
Source
mouse_enabled?(handle : UInt64) : UInt8

Query counterparts for the three input modes. Without these a C or JS caller can toggle a mode but never ask whether it is on, and has to shadow the state itself — which desynchronizes the moment with_mode suspends and restores.

Source
poll_event(handle : UInt64, timeout_ms : Int32, out_event : Pointer(ABI::Event)) : Status
Source
render(handle : UInt64) : Status
Source
set_cell(handle : UInt64, x : Int32, y : Int32, codepoint : UInt32, style : Pointer(ABI::CellStyle)) : Status
Source
set_cells(handle : UInt64, ops : Pointer(ABI::CellOp), count : UInt64) : Status

Applies count cell writes with a single guard + registry fetch.

Per-op semantics match set_cell: ops rejected by the buffer (out of bounds, unfittable wide char, zero-width char) are skipped and the call returns Rejected after processing every op; malformed ops (invalid codepoint, color mode, or attribute bits) raise and abort the batch with Error, leaving prior ops applied. ops may be null only when count is 0.

Source
set_cursor(handle : UInt64, x : Int32, y : Int32) : Status
Source
set_sync_updates(handle : UInt64, enabled : Bool) : Status
Source
show_cursor(handle : UInt64) : Status
Source
size(handle : UInt64, out_size : Pointer(ABI::Size)) : Status
Source
sync(handle : UInt64) : Status
Source
sync_updates?(handle : UInt64) : UInt8
Source

Nested types