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;
}
void ghostty_key_event_set_mods(GhosttyKeyEvent event, GhosttyMods mods)
struct GhosttyKeyEncoder * GhosttyKeyEncoder
void ghostty_key_event_set_action(GhosttyKeyEvent event, GhosttyKeyAction action)
GhosttyResult ghostty_key_encoder_new(const GhosttyAllocator *allocator, GhosttyKeyEncoder *encoder)
GhosttyResult ghostty_key_event_new(const GhosttyAllocator *allocator, GhosttyKeyEvent *event)
void ghostty_key_encoder_setopt(GhosttyKeyEncoder encoder, GhosttyKeyEncoderOption option, const void *value)
struct GhosttyKeyEvent * GhosttyKeyEvent
GhosttyResult ghostty_key_encoder_encode(GhosttyKeyEncoder encoder, GhosttyKeyEvent event, char *out_buf, size_t out_buf_size, size_t *out_len)
void ghostty_key_encoder_free(GhosttyKeyEncoder encoder)
void ghostty_key_event_free(GhosttyKeyEvent event)
void ghostty_key_event_set_key(GhosttyKeyEvent event, GhosttyKey key)
@ GHOSTTY_KEY_ENCODER_OPT_KITTY_FLAGS
@ GHOSTTY_KEY_ACTION_PRESS
#define GHOSTTY_KITTY_KEY_ALL
#define GHOSTTY_MODS_CTRL