This example demonstrates how to use the key encoder to convert key events into terminal escape sequences using the Kitty keyboard protocol.
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
int main() {
char buf[128];
size_t written = 0;
fwrite(buf, 1, written, stdout);
return 0;
}
GHOSTTY_API void ghostty_key_event_set_action(GhosttyKeyEvent event, GhosttyKeyAction action)
struct GhosttyKeyEncoderImpl * GhosttyKeyEncoder
GHOSTTY_API GhosttyResult ghostty_key_encoder_encode(GhosttyKeyEncoder encoder, GhosttyKeyEvent event, char *out_buf, size_t out_buf_size, size_t *out_len)
GHOSTTY_API GhosttyResult ghostty_key_event_new(const GhosttyAllocator *allocator, GhosttyKeyEvent *event)
GHOSTTY_API void ghostty_key_event_set_key(GhosttyKeyEvent event, GhosttyKey key)
GHOSTTY_API void ghostty_key_event_set_mods(GhosttyKeyEvent event, GhosttyMods mods)
GHOSTTY_API void ghostty_key_encoder_setopt(GhosttyKeyEncoder encoder, GhosttyKeyEncoderOption option, const void *value)
struct GhosttyKeyEventImpl * GhosttyKeyEvent
GHOSTTY_API GhosttyResult ghostty_key_encoder_new(const GhosttyAllocator *allocator, GhosttyKeyEncoder *encoder)
GHOSTTY_API void ghostty_key_encoder_free(GhosttyKeyEncoder encoder)
GHOSTTY_API void ghostty_key_event_free(GhosttyKeyEvent event)
@ GHOSTTY_KEY_ENCODER_OPT_KITTY_FLAGS
@ GHOSTTY_KEY_ACTION_PRESS
#define GHOSTTY_KITTY_KEY_ALL
#define GHOSTTY_MODS_CTRL