libghostty-vt 0.0.0
Loading...
Searching...
No Matches
c-vt-modes/src/main.c

Pack DEC and ANSI mode numbers into a GhosttyMode and encode a DECRPM report.

#include <stdio.h>
#include <ghostty/vt.h>
void modes_example() {
// Create a mode for DEC mode 25 (cursor visible)
GhosttyMode tag = ghostty_mode_new(25, false);
printf("value=%u ansi=%d packed=0x%04x\n",
ghostty_mode_value(tag),
ghostty_mode_ansi(tag),
tag);
// Create a mode for ANSI mode 4 (insert mode)
GhosttyMode ansi_tag = ghostty_mode_new(4, true);
printf("value=%u ansi=%d packed=0x%04x\n",
ghostty_mode_value(ansi_tag),
ghostty_mode_ansi(ansi_tag),
ansi_tag);
}
void decrpm_example() {
uint8_t buf[32];
size_t written = 0;
// Encode a report that DEC mode 25 (cursor visible) is set
buf, sizeof(buf), &written);
if (result == GHOSTTY_SUCCESS) {
printf("Encoded %zu bytes: ", written);
fwrite(buf, 1, written, stdout);
printf("\n"); // prints: ESC[?25;1$y
}
}
int main() {
modes_example();
decrpm_example();
return 0;
}
GhosttyResult
Definition types.h:143
@ GHOSTTY_SUCCESS
Definition types.h:145
uint16_t GhosttyMode
Definition modes.h:104
#define GHOSTTY_MODE_CURSOR_VISIBLE
Definition modes.h:65
GHOSTTY_API GhosttyResult ghostty_mode_report_encode(GhosttyMode mode, GhosttyModeReportState state, uint8_t *buf, size_t buf_len, size_t *out_written)
@ GHOSTTY_MODE_REPORT_SET
Definition modes.h:153