1// Ghostty embedding API. The documentation for the embedding API is
2// only within the Zig source files that define the implementations. This
3// isn't meant to be a general purpose embedding API (yet) so there hasn't
4// been documentation or example work beyond that.
5//
6// The only consumer of this API is the macOS app, but the API is built to
7// be more general purpose.
8#ifndef GHOSTTY_H
9#define GHOSTTY_H
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include <stdbool.h>
16#include <stddef.h>
17#include <stdint.h>
18
19#ifdef _MSC_VER
20#include <BaseTsd.h>
21typedef SSIZE_T ssize_t;
22#else
23#include <sys/types.h>
24#endif
25
26//-------------------------------------------------------------------
27// Macros
28
29#define GHOSTTY_SUCCESS 0
30
31// Symbol visibility for shared library builds. On Windows, functions
32// are exported from the DLL when building and imported when consuming.
33// On other platforms with GCC/Clang, functions are marked with default
34// visibility so they remain accessible when the library is built with
35// -fvisibility=hidden. For static library builds, define GHOSTTY_STATIC
36// before including this header to make this a no-op.
37#ifndef GHOSTTY_API
38#if defined(GHOSTTY_STATIC)
39 #define GHOSTTY_API
40#elif defined(_WIN32) || defined(_WIN64)
41 #ifdef GHOSTTY_BUILD_SHARED
42 #define GHOSTTY_API __declspec(dllexport)
43 #else
44 #define GHOSTTY_API __declspec(dllimport)
45 #endif
46#elif defined(__GNUC__) && __GNUC__ >= 4
47 #define GHOSTTY_API __attribute__((visibility("default")))
48#else
49 #define GHOSTTY_API
50#endif
51#endif
52
53//-------------------------------------------------------------------
54// Types
55
56// Opaque types
57typedef void* ghostty_app_t;
58typedef void* ghostty_config_t;
59typedef void* ghostty_surface_t;
60typedef void* ghostty_inspector_t;
61
62// All the types below are fully defined and must be kept in sync with
63// their Zig counterparts. Any changes to these types MUST have an associated
64// Zig change.
65typedef enum {
66 GHOSTTY_PLATFORM_INVALID,
67 GHOSTTY_PLATFORM_MACOS,
68 GHOSTTY_PLATFORM_IOS,
69} ghostty_platform_e;
70
71typedef enum {
72 GHOSTTY_CLIPBOARD_STANDARD,
73 GHOSTTY_CLIPBOARD_SELECTION,
74} ghostty_clipboard_e;
75
76typedef struct {
77 const char *mime;
78 const char *data;
79} ghostty_clipboard_content_s;
80
81typedef enum {
82 GHOSTTY_CLIPBOARD_REQUEST_PASTE,
83 GHOSTTY_CLIPBOARD_REQUEST_OSC_52_READ,
84 GHOSTTY_CLIPBOARD_REQUEST_OSC_52_WRITE,
85} ghostty_clipboard_request_e;
86
87typedef enum {
88 GHOSTTY_MOUSE_RELEASE,
89 GHOSTTY_MOUSE_PRESS,
90} ghostty_input_mouse_state_e;
91
92typedef enum {
93 GHOSTTY_MOUSE_UNKNOWN,
94 GHOSTTY_MOUSE_LEFT,
95 GHOSTTY_MOUSE_RIGHT,
96 GHOSTTY_MOUSE_MIDDLE,
97 GHOSTTY_MOUSE_FOUR,
98 GHOSTTY_MOUSE_FIVE,
99 GHOSTTY_MOUSE_SIX,
100 GHOSTTY_MOUSE_SEVEN,
101 GHOSTTY_MOUSE_EIGHT,
102 GHOSTTY_MOUSE_NINE,
103 GHOSTTY_MOUSE_TEN,
104 GHOSTTY_MOUSE_ELEVEN,
105} ghostty_input_mouse_button_e;
106
107typedef enum {
108 GHOSTTY_MOUSE_MOMENTUM_NONE,
109 GHOSTTY_MOUSE_MOMENTUM_BEGAN,
110 GHOSTTY_MOUSE_MOMENTUM_STATIONARY,
111 GHOSTTY_MOUSE_MOMENTUM_CHANGED,
112 GHOSTTY_MOUSE_MOMENTUM_ENDED,
113 GHOSTTY_MOUSE_MOMENTUM_CANCELLED,
114 GHOSTTY_MOUSE_MOMENTUM_MAY_BEGIN,
115} ghostty_input_mouse_momentum_e;
116
117typedef enum {
118 GHOSTTY_COLOR_SCHEME_LIGHT = 0,
119 GHOSTTY_COLOR_SCHEME_DARK = 1,
120} ghostty_color_scheme_e;
121
122// This is a packed struct (see src/input/mouse.zig) but the C standard
123// afaik doesn't let us reliably define packed structs so we build it up
124// from scratch.
125typedef int ghostty_input_scroll_mods_t;
126
127typedef enum {
128 GHOSTTY_MODS_NONE = 0,
129 GHOSTTY_MODS_SHIFT = 1 << 0,
130 GHOSTTY_MODS_CTRL = 1 << 1,
131 GHOSTTY_MODS_ALT = 1 << 2,
132 GHOSTTY_MODS_SUPER = 1 << 3,
133 GHOSTTY_MODS_CAPS = 1 << 4,
134 GHOSTTY_MODS_NUM = 1 << 5,
135 GHOSTTY_MODS_SHIFT_RIGHT = 1 << 6,
136 GHOSTTY_MODS_CTRL_RIGHT = 1 << 7,
137 GHOSTTY_MODS_ALT_RIGHT = 1 << 8,
138 GHOSTTY_MODS_SUPER_RIGHT = 1 << 9,
139} ghostty_input_mods_e;
140
141typedef enum {
142 GHOSTTY_BINDING_FLAGS_CONSUMED = 1 << 0,
143 GHOSTTY_BINDING_FLAGS_ALL = 1 << 1,
144 GHOSTTY_BINDING_FLAGS_GLOBAL = 1 << 2,
145 GHOSTTY_BINDING_FLAGS_PERFORMABLE = 1 << 3,
146} ghostty_binding_flags_e;
147
148typedef enum {
149 GHOSTTY_ACTION_RELEASE,
150 GHOSTTY_ACTION_PRESS,
151 GHOSTTY_ACTION_REPEAT,
152} ghostty_input_action_e;
153
154// Based on: https://www.w3.org/TR/uievents-code/
155typedef enum {
156 GHOSTTY_KEY_UNIDENTIFIED,
157
158 // "Writing System Keys" § 3.1.1
159 GHOSTTY_KEY_BACKQUOTE,
160 GHOSTTY_KEY_BACKSLASH,
161 GHOSTTY_KEY_BRACKET_LEFT,
162 GHOSTTY_KEY_BRACKET_RIGHT,
163 GHOSTTY_KEY_COMMA,
164 GHOSTTY_KEY_DIGIT_0,
165 GHOSTTY_KEY_DIGIT_1,
166 GHOSTTY_KEY_DIGIT_2,
167 GHOSTTY_KEY_DIGIT_3,
168 GHOSTTY_KEY_DIGIT_4,
169 GHOSTTY_KEY_DIGIT_5,
170 GHOSTTY_KEY_DIGIT_6,
171 GHOSTTY_KEY_DIGIT_7,
172 GHOSTTY_KEY_DIGIT_8,
173 GHOSTTY_KEY_DIGIT_9,
174 GHOSTTY_KEY_EQUAL,
175 GHOSTTY_KEY_INTL_BACKSLASH,
176 GHOSTTY_KEY_INTL_RO,
177 GHOSTTY_KEY_INTL_YEN,
178 GHOSTTY_KEY_A,
179 GHOSTTY_KEY_B,
180 GHOSTTY_KEY_C,
181 GHOSTTY_KEY_D,
182 GHOSTTY_KEY_E,
183 GHOSTTY_KEY_F,
184 GHOSTTY_KEY_G,
185 GHOSTTY_KEY_H,
186 GHOSTTY_KEY_I,
187 GHOSTTY_KEY_J,
188 GHOSTTY_KEY_K,
189 GHOSTTY_KEY_L,
190 GHOSTTY_KEY_M,
191 GHOSTTY_KEY_N,
192 GHOSTTY_KEY_O,
193 GHOSTTY_KEY_P,
194 GHOSTTY_KEY_Q,
195 GHOSTTY_KEY_R,
196 GHOSTTY_KEY_S,
197 GHOSTTY_KEY_T,
198 GHOSTTY_KEY_U,
199 GHOSTTY_KEY_V,
200 GHOSTTY_KEY_W,
201 GHOSTTY_KEY_X,
202 GHOSTTY_KEY_Y,
203 GHOSTTY_KEY_Z,
204 GHOSTTY_KEY_MINUS,
205 GHOSTTY_KEY_PERIOD,
206 GHOSTTY_KEY_QUOTE,
207 GHOSTTY_KEY_SEMICOLON,
208 GHOSTTY_KEY_SLASH,
209
210 // "Functional Keys" § 3.1.2
211 GHOSTTY_KEY_ALT_LEFT,
212 GHOSTTY_KEY_ALT_RIGHT,
213 GHOSTTY_KEY_BACKSPACE,
214 GHOSTTY_KEY_CAPS_LOCK,
215 GHOSTTY_KEY_CONTEXT_MENU,
216 GHOSTTY_KEY_CONTROL_LEFT,
217 GHOSTTY_KEY_CONTROL_RIGHT,
218 GHOSTTY_KEY_ENTER,
219 GHOSTTY_KEY_META_LEFT,
220 GHOSTTY_KEY_META_RIGHT,
221 GHOSTTY_KEY_SHIFT_LEFT,
222 GHOSTTY_KEY_SHIFT_RIGHT,
223 GHOSTTY_KEY_SPACE,
224 GHOSTTY_KEY_TAB,
225 GHOSTTY_KEY_CONVERT,
226 GHOSTTY_KEY_KANA_MODE,
227 GHOSTTY_KEY_NON_CONVERT,
228
229 // "Control Pad Section" § 3.2
230 GHOSTTY_KEY_DELETE,
231 GHOSTTY_KEY_END,
232 GHOSTTY_KEY_HELP,
233 GHOSTTY_KEY_HOME,
234 GHOSTTY_KEY_INSERT,
235 GHOSTTY_KEY_PAGE_DOWN,
236 GHOSTTY_KEY_PAGE_UP,
237
238 // "Arrow Pad Section" § 3.3
239 GHOSTTY_KEY_ARROW_DOWN,
240 GHOSTTY_KEY_ARROW_LEFT,
241 GHOSTTY_KEY_ARROW_RIGHT,
242 GHOSTTY_KEY_ARROW_UP,
243
244 // "Numpad Section" § 3.4
245 GHOSTTY_KEY_NUM_LOCK,
246 GHOSTTY_KEY_NUMPAD_0,
247 GHOSTTY_KEY_NUMPAD_1,
248 GHOSTTY_KEY_NUMPAD_2,
249 GHOSTTY_KEY_NUMPAD_3,
250 GHOSTTY_KEY_NUMPAD_4,
251 GHOSTTY_KEY_NUMPAD_5,
252 GHOSTTY_KEY_NUMPAD_6,
253 GHOSTTY_KEY_NUMPAD_7,
254 GHOSTTY_KEY_NUMPAD_8,
255 GHOSTTY_KEY_NUMPAD_9,
256 GHOSTTY_KEY_NUMPAD_ADD,
257 GHOSTTY_KEY_NUMPAD_BACKSPACE,
258 GHOSTTY_KEY_NUMPAD_CLEAR,
259 GHOSTTY_KEY_NUMPAD_CLEAR_ENTRY,
260 GHOSTTY_KEY_NUMPAD_COMMA,
261 GHOSTTY_KEY_NUMPAD_DECIMAL,
262 GHOSTTY_KEY_NUMPAD_DIVIDE,
263 GHOSTTY_KEY_NUMPAD_ENTER,
264 GHOSTTY_KEY_NUMPAD_EQUAL,
265 GHOSTTY_KEY_NUMPAD_MEMORY_ADD,
266 GHOSTTY_KEY_NUMPAD_MEMORY_CLEAR,
267 GHOSTTY_KEY_NUMPAD_MEMORY_RECALL,
268 GHOSTTY_KEY_NUMPAD_MEMORY_STORE,
269 GHOSTTY_KEY_NUMPAD_MEMORY_SUBTRACT,
270 GHOSTTY_KEY_NUMPAD_MULTIPLY,
271 GHOSTTY_KEY_NUMPAD_PAREN_LEFT,
272 GHOSTTY_KEY_NUMPAD_PAREN_RIGHT,
273 GHOSTTY_KEY_NUMPAD_SUBTRACT,
274 GHOSTTY_KEY_NUMPAD_SEPARATOR,
275 GHOSTTY_KEY_NUMPAD_UP,
276 GHOSTTY_KEY_NUMPAD_DOWN,
277 GHOSTTY_KEY_NUMPAD_RIGHT,
278 GHOSTTY_KEY_NUMPAD_LEFT,
279 GHOSTTY_KEY_NUMPAD_BEGIN,
280 GHOSTTY_KEY_NUMPAD_HOME,
281 GHOSTTY_KEY_NUMPAD_END,
282 GHOSTTY_KEY_NUMPAD_INSERT,
283 GHOSTTY_KEY_NUMPAD_DELETE,
284 GHOSTTY_KEY_NUMPAD_PAGE_UP,
285 GHOSTTY_KEY_NUMPAD_PAGE_DOWN,
286
287 // "Function Section" § 3.5
288 GHOSTTY_KEY_ESCAPE,
289 GHOSTTY_KEY_F1,
290 GHOSTTY_KEY_F2,
291 GHOSTTY_KEY_F3,
292 GHOSTTY_KEY_F4,
293 GHOSTTY_KEY_F5,
294 GHOSTTY_KEY_F6,
295 GHOSTTY_KEY_F7,
296 GHOSTTY_KEY_F8,
297 GHOSTTY_KEY_F9,
298 GHOSTTY_KEY_F10,
299 GHOSTTY_KEY_F11,
300 GHOSTTY_KEY_F12,
301 GHOSTTY_KEY_F13,
302 GHOSTTY_KEY_F14,
303 GHOSTTY_KEY_F15,
304 GHOSTTY_KEY_F16,
305 GHOSTTY_KEY_F17,
306 GHOSTTY_KEY_F18,
307 GHOSTTY_KEY_F19,
308 GHOSTTY_KEY_F20,
309 GHOSTTY_KEY_F21,
310 GHOSTTY_KEY_F22,
311 GHOSTTY_KEY_F23,
312 GHOSTTY_KEY_F24,
313 GHOSTTY_KEY_F25,
314 GHOSTTY_KEY_FN,
315 GHOSTTY_KEY_FN_LOCK,
316 GHOSTTY_KEY_PRINT_SCREEN,
317 GHOSTTY_KEY_SCROLL_LOCK,
318 GHOSTTY_KEY_PAUSE,
319
320 // "Media Keys" § 3.6
321 GHOSTTY_KEY_BROWSER_BACK,
322 GHOSTTY_KEY_BROWSER_FAVORITES,
323 GHOSTTY_KEY_BROWSER_FORWARD,
324 GHOSTTY_KEY_BROWSER_HOME,
325 GHOSTTY_KEY_BROWSER_REFRESH,
326 GHOSTTY_KEY_BROWSER_SEARCH,
327 GHOSTTY_KEY_BROWSER_STOP,
328 GHOSTTY_KEY_EJECT,
329 GHOSTTY_KEY_LAUNCH_APP_1,
330 GHOSTTY_KEY_LAUNCH_APP_2,
331 GHOSTTY_KEY_LAUNCH_MAIL,
332 GHOSTTY_KEY_MEDIA_PLAY_PAUSE,
333 GHOSTTY_KEY_MEDIA_SELECT,
334 GHOSTTY_KEY_MEDIA_STOP,
335 GHOSTTY_KEY_MEDIA_TRACK_NEXT,
336 GHOSTTY_KEY_MEDIA_TRACK_PREVIOUS,
337 GHOSTTY_KEY_POWER,
338 GHOSTTY_KEY_SLEEP,
339 GHOSTTY_KEY_AUDIO_VOLUME_DOWN,
340 GHOSTTY_KEY_AUDIO_VOLUME_MUTE,
341 GHOSTTY_KEY_AUDIO_VOLUME_UP,
342 GHOSTTY_KEY_WAKE_UP,
343
344 // "Legacy, Non-standard, and Special Keys" § 3.7
345 GHOSTTY_KEY_COPY,
346 GHOSTTY_KEY_CUT,
347 GHOSTTY_KEY_PASTE,
348} ghostty_input_key_e;
349
350typedef struct {
351 ghostty_input_action_e action;
352 ghostty_input_mods_e mods;
353 ghostty_input_mods_e consumed_mods;
354 uint32_t keycode;
355 const char* text;
356 uint32_t unshifted_codepoint;
357 bool composing;
358} ghostty_input_key_s;
359
360typedef enum {
361 GHOSTTY_TRIGGER_PHYSICAL,
362 GHOSTTY_TRIGGER_UNICODE,
363 GHOSTTY_TRIGGER_CATCH_ALL,
364} ghostty_input_trigger_tag_e;
365
366typedef union {
367 ghostty_input_key_e physical;
368 uint32_t unicode;
369 // catch_all has no payload
370} ghostty_input_trigger_key_u;
371
372typedef struct {
373 ghostty_input_trigger_tag_e tag;
374 ghostty_input_trigger_key_u key;
375 ghostty_input_mods_e mods;
376} ghostty_input_trigger_s;
377
378typedef struct {
379 const char* action_key;
380 const char* action;
381 const char* title;
382 const char* description;
383} ghostty_command_s;
384
385typedef enum {
386 GHOSTTY_BUILD_MODE_DEBUG,
387 GHOSTTY_BUILD_MODE_RELEASE_SAFE,
388 GHOSTTY_BUILD_MODE_RELEASE_FAST,
389 GHOSTTY_BUILD_MODE_RELEASE_SMALL,
390} ghostty_build_mode_e;
391
392typedef struct {
393 ghostty_build_mode_e build_mode;
394 const char* version;
395 uintptr_t version_len;
396} ghostty_info_s;
397
398typedef struct {
399 const char* message;
400} ghostty_diagnostic_s;
401
402typedef struct {
403 const char* ptr;
404 uintptr_t len;
405 bool sentinel;
406} ghostty_string_s;
407
408typedef struct {
409 double tl_px_x;
410 double tl_px_y;
411 uint32_t offset_start;
412 uint32_t offset_len;
413 const char* text;
414 uintptr_t text_len;
415} ghostty_text_s;
416
417typedef enum {
418 GHOSTTY_POINT_ACTIVE,
419 GHOSTTY_POINT_VIEWPORT,
420 GHOSTTY_POINT_SCREEN,
421 GHOSTTY_POINT_SURFACE,
422} ghostty_point_tag_e;
423
424typedef enum {
425 GHOSTTY_POINT_COORD_EXACT,
426 GHOSTTY_POINT_COORD_TOP_LEFT,
427 GHOSTTY_POINT_COORD_BOTTOM_RIGHT,
428} ghostty_point_coord_e;
429
430typedef struct {
431 ghostty_point_tag_e tag;
432 ghostty_point_coord_e coord;
433 uint32_t x;
434 uint32_t y;
435} ghostty_point_s;
436
437typedef struct {
438 ghostty_point_s top_left;
439 ghostty_point_s bottom_right;
440 bool rectangle;
441} ghostty_selection_s;
442
443typedef struct {
444 const char* key;
445 const char* value;
446} ghostty_env_var_s;
447
448typedef struct {
449 void* nsview;
450} ghostty_platform_macos_s;
451
452typedef struct {
453 void* uiview;
454} ghostty_platform_ios_s;
455
456typedef union {
457 ghostty_platform_macos_s macos;
458 ghostty_platform_ios_s ios;
459} ghostty_platform_u;
460
461typedef enum {
462 GHOSTTY_SURFACE_CONTEXT_WINDOW = 0,
463 GHOSTTY_SURFACE_CONTEXT_TAB = 1,
464 GHOSTTY_SURFACE_CONTEXT_SPLIT = 2,
465} ghostty_surface_context_e;
466
467typedef struct {
468 ghostty_platform_e platform_tag;
469 ghostty_platform_u platform;
470 void* userdata;
471 double scale_factor;
472 float font_size;
473 const char* working_directory;
474 const char* command;
475 ghostty_env_var_s* env_vars;
476 size_t env_var_count;
477 const char* initial_input;
478 bool wait_after_command;
479 ghostty_surface_context_e context;
480} ghostty_surface_config_s;
481
482typedef struct {
483 uint16_t columns;
484 uint16_t rows;
485 uint32_t width_px;
486 uint32_t height_px;
487 uint32_t cell_width_px;
488 uint32_t cell_height_px;
489} ghostty_surface_size_s;
490
491// Config types
492
493// config.Path
494typedef struct {
495 const char* path;
496 bool optional;
497} ghostty_config_path_s;
498
499// config.Color
500typedef struct {
501 uint8_t r;
502 uint8_t g;
503 uint8_t b;
504} ghostty_config_color_s;
505
506// config.ColorList
507typedef struct {
508 const ghostty_config_color_s* colors;
509 size_t len;
510} ghostty_config_color_list_s;
511
512// config.RepeatableCommand
513typedef struct {
514 const ghostty_command_s* commands;
515 size_t len;
516} ghostty_config_command_list_s;
517
518// config.Palette
519typedef struct {
520 ghostty_config_color_s colors[256];
521} ghostty_config_palette_s;
522
523// config.QuickTerminalSize
524typedef enum {
525 GHOSTTY_QUICK_TERMINAL_SIZE_NONE,
526 GHOSTTY_QUICK_TERMINAL_SIZE_PERCENTAGE,
527 GHOSTTY_QUICK_TERMINAL_SIZE_PIXELS,
528} ghostty_quick_terminal_size_tag_e;
529
530typedef union {
531 float percentage;
532 uint32_t pixels;
533} ghostty_quick_terminal_size_value_u;
534
535typedef struct {
536 ghostty_quick_terminal_size_tag_e tag;
537 ghostty_quick_terminal_size_value_u value;
538} ghostty_quick_terminal_size_s;
539
540typedef struct {
541 ghostty_quick_terminal_size_s primary;
542 ghostty_quick_terminal_size_s secondary;
543} ghostty_config_quick_terminal_size_s;
544
545// config.Fullscreen
546typedef enum {
547 GHOSTTY_CONFIG_FULLSCREEN_FALSE,
548 GHOSTTY_CONFIG_FULLSCREEN_TRUE,
549 GHOSTTY_CONFIG_FULLSCREEN_NON_NATIVE,
550 GHOSTTY_CONFIG_FULLSCREEN_NON_NATIVE_VISIBLE_MENU,
551 GHOSTTY_CONFIG_FULLSCREEN_NON_NATIVE_PADDED_NOTCH,
552} ghostty_config_fullscreen_e;
553
554// apprt.Target.Key
555typedef enum {
556 GHOSTTY_TARGET_APP,
557 GHOSTTY_TARGET_SURFACE,
558} ghostty_target_tag_e;
559
560typedef union {
561 ghostty_surface_t surface;
562} ghostty_target_u;
563
564typedef struct {
565 ghostty_target_tag_e tag;
566 ghostty_target_u target;
567} ghostty_target_s;
568
569// apprt.action.SplitDirection
570typedef enum {
571 GHOSTTY_SPLIT_DIRECTION_RIGHT,
572 GHOSTTY_SPLIT_DIRECTION_DOWN,
573 GHOSTTY_SPLIT_DIRECTION_LEFT,
574 GHOSTTY_SPLIT_DIRECTION_UP,
575} ghostty_action_split_direction_e;
576
577// apprt.action.GotoSplit
578typedef enum {
579 GHOSTTY_GOTO_SPLIT_PREVIOUS,
580 GHOSTTY_GOTO_SPLIT_NEXT,
581 GHOSTTY_GOTO_SPLIT_UP,
582 GHOSTTY_GOTO_SPLIT_LEFT,
583 GHOSTTY_GOTO_SPLIT_DOWN,
584 GHOSTTY_GOTO_SPLIT_RIGHT,
585} ghostty_action_goto_split_e;
586
587// apprt.action.GotoWindow
588typedef enum {
589 GHOSTTY_GOTO_WINDOW_PREVIOUS,
590 GHOSTTY_GOTO_WINDOW_NEXT,
591} ghostty_action_goto_window_e;
592
593// apprt.action.ResizeSplit.Direction
594typedef enum {
595 GHOSTTY_RESIZE_SPLIT_UP,
596 GHOSTTY_RESIZE_SPLIT_DOWN,
597 GHOSTTY_RESIZE_SPLIT_LEFT,
598 GHOSTTY_RESIZE_SPLIT_RIGHT,
599} ghostty_action_resize_split_direction_e;
600
601// apprt.action.ResizeSplit
602typedef struct {
603 uint16_t amount;
604 ghostty_action_resize_split_direction_e direction;
605} ghostty_action_resize_split_s;
606
607// apprt.action.MoveTab
608typedef struct {
609 ssize_t amount;
610} ghostty_action_move_tab_s;
611
612// apprt.action.GotoTab
613typedef enum {
614 GHOSTTY_GOTO_TAB_PREVIOUS = -1,
615 GHOSTTY_GOTO_TAB_NEXT = -2,
616 GHOSTTY_GOTO_TAB_LAST = -3,
617} ghostty_action_goto_tab_e;
618
619// apprt.action.Fullscreen
620typedef enum {
621 GHOSTTY_FULLSCREEN_NATIVE,
622 GHOSTTY_FULLSCREEN_MACOS_NON_NATIVE,
623 GHOSTTY_FULLSCREEN_MACOS_NON_NATIVE_VISIBLE_MENU,
624 GHOSTTY_FULLSCREEN_MACOS_NON_NATIVE_PADDED_NOTCH,
625} ghostty_action_fullscreen_e;
626
627// apprt.action.FloatWindow
628typedef enum {
629 GHOSTTY_FLOAT_WINDOW_ON,
630 GHOSTTY_FLOAT_WINDOW_OFF,
631 GHOSTTY_FLOAT_WINDOW_TOGGLE,
632} ghostty_action_float_window_e;
633
634// apprt.action.SecureInput
635typedef enum {
636 GHOSTTY_SECURE_INPUT_ON,
637 GHOSTTY_SECURE_INPUT_OFF,
638 GHOSTTY_SECURE_INPUT_TOGGLE,
639} ghostty_action_secure_input_e;
640
641// apprt.action.Inspector
642typedef enum {
643 GHOSTTY_INSPECTOR_TOGGLE,
644 GHOSTTY_INSPECTOR_SHOW,
645 GHOSTTY_INSPECTOR_HIDE,
646} ghostty_action_inspector_e;
647
648// apprt.action.QuitTimer
649typedef enum {
650 GHOSTTY_QUIT_TIMER_START,
651 GHOSTTY_QUIT_TIMER_STOP,
652} ghostty_action_quit_timer_e;
653
654// apprt.action.Readonly
655typedef enum {
656 GHOSTTY_READONLY_OFF,
657 GHOSTTY_READONLY_ON,
658} ghostty_action_readonly_e;
659
660// apprt.action.DesktopNotification.C
661typedef struct {
662 const char* title;
663 const char* body;
664} ghostty_action_desktop_notification_s;
665
666// apprt.action.SetTitle.C
667typedef struct {
668 const char* title;
669} ghostty_action_set_title_s;
670
671// apprt.action.PromptTitle
672typedef enum {
673 GHOSTTY_PROMPT_TITLE_SURFACE,
674 GHOSTTY_PROMPT_TITLE_TAB,
675} ghostty_action_prompt_title_e;
676
677// apprt.action.Pwd.C
678typedef struct {
679 const char* pwd;
680} ghostty_action_pwd_s;
681
682// terminal.MouseShape
683typedef enum {
684 GHOSTTY_MOUSE_SHAPE_DEFAULT,
685 GHOSTTY_MOUSE_SHAPE_CONTEXT_MENU,
686 GHOSTTY_MOUSE_SHAPE_HELP,
687 GHOSTTY_MOUSE_SHAPE_POINTER,
688 GHOSTTY_MOUSE_SHAPE_PROGRESS,
689 GHOSTTY_MOUSE_SHAPE_WAIT,
690 GHOSTTY_MOUSE_SHAPE_CELL,
691 GHOSTTY_MOUSE_SHAPE_CROSSHAIR,
692 GHOSTTY_MOUSE_SHAPE_TEXT,
693 GHOSTTY_MOUSE_SHAPE_VERTICAL_TEXT,
694 GHOSTTY_MOUSE_SHAPE_ALIAS,
695 GHOSTTY_MOUSE_SHAPE_COPY,
696 GHOSTTY_MOUSE_SHAPE_MOVE,
697 GHOSTTY_MOUSE_SHAPE_NO_DROP,
698 GHOSTTY_MOUSE_SHAPE_NOT_ALLOWED,
699 GHOSTTY_MOUSE_SHAPE_GRAB,
700 GHOSTTY_MOUSE_SHAPE_GRABBING,
701 GHOSTTY_MOUSE_SHAPE_ALL_SCROLL,
702 GHOSTTY_MOUSE_SHAPE_COL_RESIZE,
703 GHOSTTY_MOUSE_SHAPE_ROW_RESIZE,
704 GHOSTTY_MOUSE_SHAPE_N_RESIZE,
705 GHOSTTY_MOUSE_SHAPE_E_RESIZE,
706 GHOSTTY_MOUSE_SHAPE_S_RESIZE,
707 GHOSTTY_MOUSE_SHAPE_W_RESIZE,
708 GHOSTTY_MOUSE_SHAPE_NE_RESIZE,
709 GHOSTTY_MOUSE_SHAPE_NW_RESIZE,
710 GHOSTTY_MOUSE_SHAPE_SE_RESIZE,
711 GHOSTTY_MOUSE_SHAPE_SW_RESIZE,
712 GHOSTTY_MOUSE_SHAPE_EW_RESIZE,
713 GHOSTTY_MOUSE_SHAPE_NS_RESIZE,
714 GHOSTTY_MOUSE_SHAPE_NESW_RESIZE,
715 GHOSTTY_MOUSE_SHAPE_NWSE_RESIZE,
716 GHOSTTY_MOUSE_SHAPE_ZOOM_IN,
717 GHOSTTY_MOUSE_SHAPE_ZOOM_OUT,
718} ghostty_action_mouse_shape_e;
719
720// apprt.action.MouseVisibility
721typedef enum {
722 GHOSTTY_MOUSE_VISIBLE,
723 GHOSTTY_MOUSE_HIDDEN,
724} ghostty_action_mouse_visibility_e;
725
726// apprt.action.MouseOverLink
727typedef struct {
728 const char* url;
729 size_t len;
730} ghostty_action_mouse_over_link_s;
731
732// apprt.action.SizeLimit
733typedef struct {
734 uint32_t min_width;
735 uint32_t min_height;
736 uint32_t max_width;
737 uint32_t max_height;
738} ghostty_action_size_limit_s;
739
740// apprt.action.InitialSize
741typedef struct {
742 uint32_t width;
743 uint32_t height;
744} ghostty_action_initial_size_s;
745
746// apprt.action.CellSize
747typedef struct {
748 uint32_t width;
749 uint32_t height;
750} ghostty_action_cell_size_s;
751
752// renderer.Health
753typedef enum {
754 GHOSTTY_RENDERER_HEALTH_HEALTHY,
755 GHOSTTY_RENDERER_HEALTH_UNHEALTHY,
756} ghostty_action_renderer_health_e;
757
758// apprt.action.KeySequence
759typedef struct {
760 bool active;
761 ghostty_input_trigger_s trigger;
762} ghostty_action_key_sequence_s;
763
764// apprt.action.KeyTable.Tag
765typedef enum {
766 GHOSTTY_KEY_TABLE_ACTIVATE,
767 GHOSTTY_KEY_TABLE_DEACTIVATE,
768 GHOSTTY_KEY_TABLE_DEACTIVATE_ALL,
769} ghostty_action_key_table_tag_e;
770
771// apprt.action.KeyTable.CValue
772typedef union {
773 struct {
774 const char *name;
775 size_t len;
776 } activate;
777} ghostty_action_key_table_u;
778
779// apprt.action.KeyTable.C
780typedef struct {
781 ghostty_action_key_table_tag_e tag;
782 ghostty_action_key_table_u value;
783} ghostty_action_key_table_s;
784
785// apprt.action.ColorKind
786typedef enum {
787 GHOSTTY_ACTION_COLOR_KIND_FOREGROUND = -1,
788 GHOSTTY_ACTION_COLOR_KIND_BACKGROUND = -2,
789 GHOSTTY_ACTION_COLOR_KIND_CURSOR = -3,
790} ghostty_action_color_kind_e;
791
792// apprt.action.ColorChange
793typedef struct {
794 ghostty_action_color_kind_e kind;
795 uint8_t r;
796 uint8_t g;
797 uint8_t b;
798} ghostty_action_color_change_s;
799
800// apprt.action.ConfigChange
801typedef struct {
802 ghostty_config_t config;
803} ghostty_action_config_change_s;
804
805// apprt.action.ReloadConfig
806typedef struct {
807 bool soft;
808} ghostty_action_reload_config_s;
809
810// apprt.action.OpenUrlKind
811typedef enum {
812 GHOSTTY_ACTION_OPEN_URL_KIND_UNKNOWN,
813 GHOSTTY_ACTION_OPEN_URL_KIND_TEXT,
814 GHOSTTY_ACTION_OPEN_URL_KIND_HTML,
815} ghostty_action_open_url_kind_e;
816
817// apprt.action.OpenUrl.C
818typedef struct {
819 ghostty_action_open_url_kind_e kind;
820 const char* url;
821 uintptr_t len;
822} ghostty_action_open_url_s;
823
824// apprt.action.CloseTabMode
825typedef enum {
826 GHOSTTY_ACTION_CLOSE_TAB_MODE_THIS,
827 GHOSTTY_ACTION_CLOSE_TAB_MODE_OTHER,
828 GHOSTTY_ACTION_CLOSE_TAB_MODE_RIGHT,
829} ghostty_action_close_tab_mode_e;
830
831// apprt.surface.Message.ChildExited
832typedef struct {
833 uint32_t exit_code;
834 uint64_t timetime_ms;
835} ghostty_surface_message_childexited_s;
836
837// terminal.osc.Command.ProgressReport.State
838typedef enum {
839 GHOSTTY_PROGRESS_STATE_REMOVE,
840 GHOSTTY_PROGRESS_STATE_SET,
841 GHOSTTY_PROGRESS_STATE_ERROR,
842 GHOSTTY_PROGRESS_STATE_INDETERMINATE,
843 GHOSTTY_PROGRESS_STATE_PAUSE,
844} ghostty_action_progress_report_state_e;
845
846// terminal.osc.Command.ProgressReport.C
847typedef struct {
848 ghostty_action_progress_report_state_e state;
849 // -1 if no progress was reported, otherwise 0-100 indicating percent
850 // completeness.
851 int8_t progress;
852} ghostty_action_progress_report_s;
853
854// apprt.action.CommandFinished.C
855typedef struct {
856 // -1 if no exit code was reported, otherwise 0-255
857 int16_t exit_code;
858 // number of nanoseconds that command was running for
859 uint64_t duration;
860} ghostty_action_command_finished_s;
861
862// apprt.action.StartSearch.C
863typedef struct {
864 const char* needle;
865} ghostty_action_start_search_s;
866
867// apprt.action.SearchTotal
868typedef struct {
869 ssize_t total;
870} ghostty_action_search_total_s;
871
872// apprt.action.SearchSelected
873typedef struct {
874 ssize_t selected;
875} ghostty_action_search_selected_s;
876
877// terminal.Scrollbar
878typedef struct {
879 uint64_t total;
880 uint64_t offset;
881 uint64_t len;
882} ghostty_action_scrollbar_s;
883
884// apprt.Action.Key
885typedef enum {
886 GHOSTTY_ACTION_QUIT,
887 GHOSTTY_ACTION_NEW_WINDOW,
888 GHOSTTY_ACTION_NEW_TAB,
889 GHOSTTY_ACTION_CLOSE_TAB,
890 GHOSTTY_ACTION_NEW_SPLIT,
891 GHOSTTY_ACTION_CLOSE_ALL_WINDOWS,
892 GHOSTTY_ACTION_TOGGLE_MAXIMIZE,
893 GHOSTTY_ACTION_TOGGLE_FULLSCREEN,
894 GHOSTTY_ACTION_TOGGLE_TAB_OVERVIEW,
895 GHOSTTY_ACTION_TOGGLE_WINDOW_DECORATIONS,
896 GHOSTTY_ACTION_TOGGLE_QUICK_TERMINAL,
897 GHOSTTY_ACTION_TOGGLE_COMMAND_PALETTE,
898 GHOSTTY_ACTION_TOGGLE_VISIBILITY,
899 GHOSTTY_ACTION_TOGGLE_BACKGROUND_OPACITY,
900 GHOSTTY_ACTION_MOVE_TAB,
901 GHOSTTY_ACTION_GOTO_TAB,
902 GHOSTTY_ACTION_GOTO_SPLIT,
903 GHOSTTY_ACTION_GOTO_WINDOW,
904 GHOSTTY_ACTION_RESIZE_SPLIT,
905 GHOSTTY_ACTION_EQUALIZE_SPLITS,
906 GHOSTTY_ACTION_TOGGLE_SPLIT_ZOOM,
907 GHOSTTY_ACTION_PRESENT_TERMINAL,
908 GHOSTTY_ACTION_SIZE_LIMIT,
909 GHOSTTY_ACTION_RESET_WINDOW_SIZE,
910 GHOSTTY_ACTION_INITIAL_SIZE,
911 GHOSTTY_ACTION_CELL_SIZE,
912 GHOSTTY_ACTION_SCROLLBAR,
913 GHOSTTY_ACTION_RENDER,
914 GHOSTTY_ACTION_INSPECTOR,
915 GHOSTTY_ACTION_SHOW_GTK_INSPECTOR,
916 GHOSTTY_ACTION_RENDER_INSPECTOR,
917 GHOSTTY_ACTION_DESKTOP_NOTIFICATION,
918 GHOSTTY_ACTION_SET_TITLE,
919 GHOSTTY_ACTION_SET_TAB_TITLE,
920 GHOSTTY_ACTION_PROMPT_TITLE,
921 GHOSTTY_ACTION_PWD,
922 GHOSTTY_ACTION_MOUSE_SHAPE,
923 GHOSTTY_ACTION_MOUSE_VISIBILITY,
924 GHOSTTY_ACTION_MOUSE_OVER_LINK,
925 GHOSTTY_ACTION_RENDERER_HEALTH,
926 GHOSTTY_ACTION_OPEN_CONFIG,
927 GHOSTTY_ACTION_QUIT_TIMER,
928 GHOSTTY_ACTION_FLOAT_WINDOW,
929 GHOSTTY_ACTION_SECURE_INPUT,
930 GHOSTTY_ACTION_KEY_SEQUENCE,
931 GHOSTTY_ACTION_KEY_TABLE,
932 GHOSTTY_ACTION_COLOR_CHANGE,
933 GHOSTTY_ACTION_RELOAD_CONFIG,
934 GHOSTTY_ACTION_CONFIG_CHANGE,
935 GHOSTTY_ACTION_CLOSE_WINDOW,
936 GHOSTTY_ACTION_RING_BELL,
937 GHOSTTY_ACTION_SELECTION_CHANGED,
938 GHOSTTY_ACTION_UNDO,
939 GHOSTTY_ACTION_REDO,
940 GHOSTTY_ACTION_CHECK_FOR_UPDATES,
941 GHOSTTY_ACTION_OPEN_URL,
942 GHOSTTY_ACTION_SHOW_CHILD_EXITED,
943 GHOSTTY_ACTION_PROGRESS_REPORT,
944 GHOSTTY_ACTION_SHOW_ON_SCREEN_KEYBOARD,
945 GHOSTTY_ACTION_COMMAND_FINISHED,
946 GHOSTTY_ACTION_START_SEARCH,
947 GHOSTTY_ACTION_END_SEARCH,
948 GHOSTTY_ACTION_SEARCH_TOTAL,
949 GHOSTTY_ACTION_SEARCH_SELECTED,
950 GHOSTTY_ACTION_READONLY,
951 GHOSTTY_ACTION_COPY_TITLE_TO_CLIPBOARD,
952} ghostty_action_tag_e;
953
954typedef union {
955 ghostty_action_split_direction_e new_split;
956 ghostty_action_fullscreen_e toggle_fullscreen;
957 ghostty_action_move_tab_s move_tab;
958 ghostty_action_goto_tab_e goto_tab;
959 ghostty_action_goto_split_e goto_split;
960 ghostty_action_goto_window_e goto_window;
961 ghostty_action_resize_split_s resize_split;
962 ghostty_action_size_limit_s size_limit;
963 ghostty_action_initial_size_s initial_size;
964 ghostty_action_cell_size_s cell_size;
965 ghostty_action_scrollbar_s scrollbar;
966 ghostty_action_inspector_e inspector;
967 ghostty_action_desktop_notification_s desktop_notification;
968 ghostty_action_set_title_s set_title;
969 ghostty_action_set_title_s set_tab_title;
970 ghostty_action_prompt_title_e prompt_title;
971 ghostty_action_pwd_s pwd;
972 ghostty_action_mouse_shape_e mouse_shape;
973 ghostty_action_mouse_visibility_e mouse_visibility;
974 ghostty_action_mouse_over_link_s mouse_over_link;
975 ghostty_action_renderer_health_e renderer_health;
976 ghostty_action_quit_timer_e quit_timer;
977 ghostty_action_float_window_e float_window;
978 ghostty_action_secure_input_e secure_input;
979 ghostty_action_key_sequence_s key_sequence;
980 ghostty_action_key_table_s key_table;
981 ghostty_action_color_change_s color_change;
982 ghostty_action_reload_config_s reload_config;
983 ghostty_action_config_change_s config_change;
984 ghostty_action_open_url_s open_url;
985 ghostty_action_close_tab_mode_e close_tab_mode;
986 ghostty_surface_message_childexited_s child_exited;
987 ghostty_action_progress_report_s progress_report;
988 ghostty_action_command_finished_s command_finished;
989 ghostty_action_start_search_s start_search;
990 ghostty_action_search_total_s search_total;
991 ghostty_action_search_selected_s search_selected;
992 ghostty_action_readonly_e readonly;
993} ghostty_action_u;
994
995typedef struct {
996 ghostty_action_tag_e tag;
997 ghostty_action_u action;
998} ghostty_action_s;
999
1000typedef void (*ghostty_runtime_wakeup_cb)(void*);
1001typedef bool (*ghostty_runtime_read_clipboard_cb)(void*,
1002 ghostty_clipboard_e,
1003 void*);
1004typedef void (*ghostty_runtime_confirm_read_clipboard_cb)(
1005 void*,
1006 const char*,
1007 void*,
1008 ghostty_clipboard_request_e);
1009typedef void (*ghostty_runtime_write_clipboard_cb)(void*,
1010 ghostty_clipboard_e,
1011 const ghostty_clipboard_content_s*,
1012 size_t,
1013 bool);
1014typedef void (*ghostty_runtime_close_surface_cb)(void*, bool);
1015typedef bool (*ghostty_runtime_action_cb)(ghostty_app_t,
1016 ghostty_target_s,
1017 ghostty_action_s);
1018
1019typedef struct {
1020 void* userdata;
1021 bool supports_selection_clipboard;
1022 ghostty_runtime_wakeup_cb wakeup_cb;
1023 ghostty_runtime_action_cb action_cb;
1024 ghostty_runtime_read_clipboard_cb read_clipboard_cb;
1025 ghostty_runtime_confirm_read_clipboard_cb confirm_read_clipboard_cb;
1026 ghostty_runtime_write_clipboard_cb write_clipboard_cb;
1027 ghostty_runtime_close_surface_cb close_surface_cb;
1028} ghostty_runtime_config_s;
1029
1030// apprt.ipc.Target.Key
1031typedef enum {
1032 GHOSTTY_IPC_TARGET_CLASS,
1033 GHOSTTY_IPC_TARGET_DETECT,
1034} ghostty_ipc_target_tag_e;
1035
1036typedef union {
1037 char *klass;
1038} ghostty_ipc_target_u;
1039
1040typedef struct {
1041 ghostty_ipc_target_tag_e tag;
1042 ghostty_ipc_target_u target;
1043} chostty_ipc_target_s;
1044
1045// apprt.ipc.Action.NewWindow
1046typedef struct {
1047 // This should be a null terminated list of strings.
1048 const char **arguments;
1049} ghostty_ipc_action_new_window_s;
1050
1051typedef union {
1052 ghostty_ipc_action_new_window_s new_window;
1053} ghostty_ipc_action_u;
1054
1055// apprt.ipc.Action.Key
1056typedef enum {
1057 GHOSTTY_IPC_ACTION_NEW_WINDOW,
1058 GHOSTTY_IPC_ACTION_TOGGLE_QUICK_TERMINAL,
1059} ghostty_ipc_action_tag_e;
1060
1061//-------------------------------------------------------------------
1062// Published API
1063
1064GHOSTTY_API int ghostty_init(uintptr_t, char**);
1065GHOSTTY_API void ghostty_cli_try_action(void);
1066GHOSTTY_API ghostty_info_s ghostty_info(void);
1067GHOSTTY_API const char* ghostty_translate(const char*);
1068GHOSTTY_API void ghostty_string_free(ghostty_string_s);
1069
1070GHOSTTY_API ghostty_config_t ghostty_config_new();
1071GHOSTTY_API void ghostty_config_free(ghostty_config_t);
1072GHOSTTY_API ghostty_config_t ghostty_config_clone(ghostty_config_t);
1073GHOSTTY_API void ghostty_config_load_cli_args(ghostty_config_t);
1074GHOSTTY_API void ghostty_config_load_file(ghostty_config_t, const char*);
1075GHOSTTY_API void ghostty_config_load_default_files(ghostty_config_t);
1076GHOSTTY_API void ghostty_config_load_recursive_files(ghostty_config_t);
1077GHOSTTY_API void ghostty_config_finalize(ghostty_config_t);
1078GHOSTTY_API bool ghostty_config_get(ghostty_config_t, void*, const char*, uintptr_t);
1079GHOSTTY_API ghostty_input_trigger_s ghostty_config_trigger(ghostty_config_t,
1080 const char*,
1081 uintptr_t);
1082GHOSTTY_API bool ghostty_config_key_is_binding(ghostty_config_t, ghostty_input_key_s);
1083GHOSTTY_API uint32_t ghostty_config_diagnostics_count(ghostty_config_t);
1084GHOSTTY_API ghostty_diagnostic_s ghostty_config_get_diagnostic(ghostty_config_t, uint32_t);
1085GHOSTTY_API ghostty_string_s ghostty_config_open_path(void);
1086
1087GHOSTTY_API ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s*,
1088 ghostty_config_t);
1089GHOSTTY_API void ghostty_app_free(ghostty_app_t);
1090GHOSTTY_API void ghostty_app_tick(ghostty_app_t);
1091GHOSTTY_API void* ghostty_app_userdata(ghostty_app_t);
1092GHOSTTY_API void ghostty_app_set_focus(ghostty_app_t, bool);
1093GHOSTTY_API bool ghostty_app_key(ghostty_app_t, ghostty_input_key_s);
1094GHOSTTY_API void ghostty_app_keyboard_changed(ghostty_app_t);
1095GHOSTTY_API void ghostty_app_open_config(ghostty_app_t);
1096GHOSTTY_API void ghostty_app_update_config(ghostty_app_t, ghostty_config_t);
1097GHOSTTY_API bool ghostty_app_needs_confirm_quit(ghostty_app_t);
1098GHOSTTY_API bool ghostty_app_has_global_keybinds(ghostty_app_t);
1099GHOSTTY_API void ghostty_app_set_color_scheme(ghostty_app_t, ghostty_color_scheme_e);
1100
1101GHOSTTY_API ghostty_surface_config_s ghostty_surface_config_new();
1102
1103GHOSTTY_API ghostty_surface_t ghostty_surface_new(ghostty_app_t,
1104 const ghostty_surface_config_s*);
1105GHOSTTY_API void ghostty_surface_free(ghostty_surface_t);
1106GHOSTTY_API void* ghostty_surface_userdata(ghostty_surface_t);
1107GHOSTTY_API ghostty_app_t ghostty_surface_app(ghostty_surface_t);
1108GHOSTTY_API ghostty_surface_config_s ghostty_surface_inherited_config(ghostty_surface_t, ghostty_surface_context_e);
1109GHOSTTY_API void ghostty_surface_update_config(ghostty_surface_t, ghostty_config_t);
1110GHOSTTY_API bool ghostty_surface_needs_confirm_quit(ghostty_surface_t);
1111GHOSTTY_API bool ghostty_surface_process_exited(ghostty_surface_t);
1112GHOSTTY_API void ghostty_surface_refresh(ghostty_surface_t);
1113GHOSTTY_API void ghostty_surface_draw(ghostty_surface_t);
1114GHOSTTY_API void ghostty_surface_set_content_scale(ghostty_surface_t, double, double);
1115GHOSTTY_API void ghostty_surface_set_focus(ghostty_surface_t, bool);
1116GHOSTTY_API void ghostty_surface_set_occlusion(ghostty_surface_t, bool);
1117GHOSTTY_API void ghostty_surface_set_size(ghostty_surface_t, uint32_t, uint32_t);
1118GHOSTTY_API ghostty_surface_size_s ghostty_surface_size(ghostty_surface_t);
1119GHOSTTY_API uint64_t ghostty_surface_foreground_pid(ghostty_surface_t);
1120GHOSTTY_API ghostty_string_s ghostty_surface_tty_name(ghostty_surface_t);
1121GHOSTTY_API void ghostty_surface_set_color_scheme(ghostty_surface_t,
1122 ghostty_color_scheme_e);
1123GHOSTTY_API ghostty_input_mods_e ghostty_surface_key_translation_mods(ghostty_surface_t,
1124 ghostty_input_mods_e);
1125GHOSTTY_API bool ghostty_surface_key(ghostty_surface_t, ghostty_input_key_s);
1126GHOSTTY_API bool ghostty_surface_key_is_binding(ghostty_surface_t,
1127 ghostty_input_key_s,
1128 ghostty_binding_flags_e*);
1129GHOSTTY_API void ghostty_surface_text(ghostty_surface_t, const char*, uintptr_t);
1130GHOSTTY_API void ghostty_surface_preedit(ghostty_surface_t, const char*, uintptr_t);
1131GHOSTTY_API bool ghostty_surface_mouse_captured(ghostty_surface_t);
1132GHOSTTY_API bool ghostty_surface_mouse_button(ghostty_surface_t,
1133 ghostty_input_mouse_state_e,
1134 ghostty_input_mouse_button_e,
1135 ghostty_input_mods_e);
1136GHOSTTY_API void ghostty_surface_mouse_pos(ghostty_surface_t,
1137 double,
1138 double,
1139 ghostty_input_mods_e);
1140GHOSTTY_API void ghostty_surface_mouse_scroll(ghostty_surface_t,
1141 double,
1142 double,
1143 ghostty_input_scroll_mods_t);
1144GHOSTTY_API void ghostty_surface_mouse_pressure(ghostty_surface_t, uint32_t, double);
1145GHOSTTY_API void ghostty_surface_ime_point(ghostty_surface_t, double*, double*, double*, double*);
1146GHOSTTY_API void ghostty_surface_request_close(ghostty_surface_t);
1147GHOSTTY_API void ghostty_surface_split(ghostty_surface_t, ghostty_action_split_direction_e);
1148GHOSTTY_API void ghostty_surface_split_focus(ghostty_surface_t,
1149 ghostty_action_goto_split_e);
1150GHOSTTY_API void ghostty_surface_split_resize(ghostty_surface_t,
1151 ghostty_action_resize_split_direction_e,
1152 uint16_t);
1153GHOSTTY_API void ghostty_surface_split_equalize(ghostty_surface_t);
1154GHOSTTY_API bool ghostty_surface_binding_action(ghostty_surface_t, const char*, uintptr_t);
1155GHOSTTY_API void ghostty_surface_complete_clipboard_request(ghostty_surface_t,
1156 const char*,
1157 void*,
1158 bool);
1159GHOSTTY_API bool ghostty_surface_has_selection(ghostty_surface_t);
1160GHOSTTY_API bool ghostty_surface_read_selection(ghostty_surface_t, ghostty_text_s*);
1161GHOSTTY_API bool ghostty_surface_read_text(ghostty_surface_t,
1162 ghostty_selection_s,
1163 ghostty_text_s*);
1164GHOSTTY_API void ghostty_surface_free_text(ghostty_surface_t, ghostty_text_s*);
1165
1166#ifdef __APPLE__
1167GHOSTTY_API void ghostty_surface_set_display_id(ghostty_surface_t, uint32_t);
1168GHOSTTY_API void* ghostty_surface_quicklook_font(ghostty_surface_t);
1169GHOSTTY_API bool ghostty_surface_quicklook_word(ghostty_surface_t, ghostty_text_s*);
1170#endif
1171
1172GHOSTTY_API ghostty_inspector_t ghostty_surface_inspector(ghostty_surface_t);
1173GHOSTTY_API void ghostty_inspector_free(ghostty_surface_t);
1174GHOSTTY_API void ghostty_inspector_set_focus(ghostty_inspector_t, bool);
1175GHOSTTY_API void ghostty_inspector_set_content_scale(ghostty_inspector_t, double, double);
1176GHOSTTY_API void ghostty_inspector_set_size(ghostty_inspector_t, uint32_t, uint32_t);
1177GHOSTTY_API void ghostty_inspector_mouse_button(ghostty_inspector_t,
1178 ghostty_input_mouse_state_e,
1179 ghostty_input_mouse_button_e,
1180 ghostty_input_mods_e);
1181GHOSTTY_API void ghostty_inspector_mouse_pos(ghostty_inspector_t, double, double);
1182GHOSTTY_API void ghostty_inspector_mouse_scroll(ghostty_inspector_t,
1183 double,
1184 double,
1185 ghostty_input_scroll_mods_t);
1186GHOSTTY_API void ghostty_inspector_key(ghostty_inspector_t,
1187 ghostty_input_action_e,
1188 ghostty_input_key_e,
1189 ghostty_input_mods_e);
1190GHOSTTY_API void ghostty_inspector_text(ghostty_inspector_t, const char*);
1191
1192#ifdef __APPLE__
1193GHOSTTY_API bool ghostty_inspector_metal_init(ghostty_inspector_t, void*);
1194GHOSTTY_API void ghostty_inspector_metal_render(ghostty_inspector_t, void*, void*);
1195GHOSTTY_API bool ghostty_inspector_metal_shutdown(ghostty_inspector_t);
1196#endif
1197
1198// APIs I'd like to get rid of eventually but are still needed for now.
1199// Don't use these unless you know what you're doing.
1200GHOSTTY_API void ghostty_set_window_background_blur(ghostty_app_t, void*);
1201
1202// Benchmark API, if available.
1203GHOSTTY_API bool ghostty_benchmark_cli(const char*, const char*);
1204
1205#ifdef __cplusplus
1206}
1207#endif
1208
1209#endif /* GHOSTTY_H */