libghostty-vt 0.0.0
Loading...
Searching...
No Matches
Focus

Encode focus gained and lost events, for mode 1004. More...

Detailed Description

Encode focus gained and lost events, for mode 1004.

Encode focus gained and lost events into terminal escape sequences (CSI I / CSI O) for focus reporting mode (mode 1004).

Only send these to a program that turned that mode on. There's no encoder to create, and you don't need a terminal to encode one.

Example

int main() {
uint8_t buf[8];
size_t written = 0;
GHOSTTY_FOCUS_GAINED, buf, sizeof(buf), &written);
if (result == GHOSTTY_SUCCESS) {
printf("Encoded %zu bytes: ", written);
fwrite(buf, 1, written, stdout);
printf("\n");
}
return 0;
}

Full program: c-vt-encode-focus/src/main.c

See the Input guide.

Enumerations

enum  GhosttyFocusEvent { GHOSTTY_FOCUS_GAINED = 0 , GHOSTTY_FOCUS_LOST = 1 , GHOSTTY_FOCUS_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE }

Functions

GHOSTTY_API GhosttyResult ghostty_focus_encode (GhosttyFocusEvent event, uint8_t *buf, size_t buf_len, size_t *out_written)

Enumeration Type Documentation

◆ GhosttyFocusEvent

Focus event types for focus reporting mode (mode 1004).

Enumerator
GHOSTTY_FOCUS_GAINED 

Terminal window gained focus

GHOSTTY_FOCUS_LOST 

Terminal window lost focus

Definition at line 39 of file focus.h.

Function Documentation

◆ ghostty_focus_encode()

GHOSTTY_API GhosttyResult ghostty_focus_encode ( GhosttyFocusEvent event,
uint8_t * buf,
size_t buf_len,
size_t * out_written )

Encode a focus event into a terminal escape sequence.

Encodes a focus gained (CSI I) or focus lost (CSI O) report into the provided buffer.

If buf is too small, this returns GHOSTTY_OUT_OF_SPACE and sets out_written to the size needed. The buffer may then hold part of the sequence, which you should discard. To get the size without encoding anything, pass NULL for buf and 0 for buf_len.

Parameters
eventThe focus event to encode
bufBuffer to write the sequence into. May be NULL if buf_len is 0.
buf_lenSize of buf in bytes
[out]out_writtenThe number of bytes written, or the size needed if the result is GHOSTTY_OUT_OF_SPACE
Returns
GHOSTTY_SUCCESS on success, GHOSTTY_OUT_OF_SPACE if the buffer is too small
Examples
c-vt-encode-focus/src/main.c.