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

Statically link libghostty-vt from a Zig build with the ghostty-vt-static artifact. The program is the same as c-vt-osc.

#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <ghostty/vt.h>
int main() {
if (ghostty_osc_new(NULL, &parser) != GHOSTTY_SUCCESS) {
return 1;
}
// Setup change window title command to change the title to "hello"
ghostty_osc_next(parser, '0');
ghostty_osc_next(parser, ';');
const char *title = "hello";
for (size_t i = 0; i < strlen(title); i++) {
ghostty_osc_next(parser, title[i]);
}
// End parsing and get command
GhosttyOscCommand command = ghostty_osc_end(parser, 0);
// Get and print command type
printf("Command type: %d\n", type);
// Extract and print the title
GhosttyString extracted;
printf("Extracted title: %.*s\n", (int)extracted.len, (const char *)extracted.ptr);
} else {
printf("Failed to extract title\n");
}
return 0;
}
@ GHOSTTY_SUCCESS
Definition types.h:145
GHOSTTY_API GhosttyOscCommandType ghostty_osc_command_type(GhosttyOscCommand command)
GHOSTTY_API GhosttyOscCommand ghostty_osc_end(GhosttyOscParser parser, uint8_t terminator)
GhosttyOscCommandType
Definition osc.h:61
GHOSTTY_API void ghostty_osc_next(GhosttyOscParser parser, uint8_t byte)
struct GhosttyOscParserImpl * GhosttyOscParser
Definition types.h:314
GHOSTTY_API GhosttyResult ghostty_osc_new(const GhosttyAllocator *allocator, GhosttyOscParser *parser)
struct GhosttyOscCommandImpl * GhosttyOscCommand
Definition types.h:324
GHOSTTY_API GhosttyResult ghostty_osc_command_data(GhosttyOscCommand command, GhosttyOscCommandData data, void *out)
GHOSTTY_API void ghostty_osc_free(GhosttyOscParser parser)
@ GHOSTTY_OSC_DATA_CHANGE_WINDOW_TITLE_STR
Definition osc.h:224
size_t len
Definition types.h:444
const uint8_t * ptr
Definition types.h:441