| 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 |
| 12 | extern "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> |
| 21 | typedef 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 |
| 57 | typedef void* ghostty_app_t; |
| 58 | typedef void* ghostty_config_t; |
| 59 | typedef void* ghostty_surface_t; |
| 60 | typedef 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. |
| 65 | typedef enum { |
| 66 | GHOSTTY_PLATFORM_INVALID, |
| 67 | GHOSTTY_PLATFORM_MACOS, |
| 68 | GHOSTTY_PLATFORM_IOS, |
| 69 | } ghostty_platform_e; |
| 70 | |
| 71 | typedef enum { |
| 72 | GHOSTTY_CLIPBOARD_STANDARD, |
| 73 | GHOSTTY_CLIPBOARD_SELECTION, |
| 74 | } ghostty_clipboard_e; |
| 75 | |
| 76 | typedef struct { |
| 77 | const char *mime; |
| 78 | const char *data; |
| 79 | } ghostty_clipboard_content_s; |
| 80 | |
| 81 | typedef 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 | |
| 87 | typedef enum { |
| 88 | GHOSTTY_MOUSE_RELEASE, |
| 89 | GHOSTTY_MOUSE_PRESS, |
| 90 | } ghostty_input_mouse_state_e; |
| 91 | |
| 92 | typedef 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 | |
| 107 | typedef 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 | |
| 117 | typedef 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. |
| 125 | typedef int ghostty_input_scroll_mods_t; |
| 126 | |
| 127 | typedef 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 | |
| 141 | typedef 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 | |
| 148 | typedef 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/ |
| 155 | typedef 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 | |
| 350 | typedef 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 | |
| 360 | typedef enum { |
| 361 | GHOSTTY_TRIGGER_PHYSICAL, |
| 362 | GHOSTTY_TRIGGER_UNICODE, |
| 363 | GHOSTTY_TRIGGER_CATCH_ALL, |
| 364 | } ghostty_input_trigger_tag_e; |
| 365 | |
| 366 | typedef union { |
| 367 | ghostty_input_key_e physical; |
| 368 | uint32_t unicode; |
| 369 | // catch_all has no payload |
| 370 | } ghostty_input_trigger_key_u; |
| 371 | |
| 372 | typedef 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 | |
| 378 | typedef struct { |
| 379 | const char* action_key; |
| 380 | const char* action; |
| 381 | const char* title; |
| 382 | const char* description; |
| 383 | } ghostty_command_s; |
| 384 | |
| 385 | typedef 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 | |
| 392 | typedef struct { |
| 393 | ghostty_build_mode_e build_mode; |
| 394 | const char* version; |
| 395 | uintptr_t version_len; |
| 396 | } ghostty_info_s; |
| 397 | |
| 398 | typedef struct { |
| 399 | const char* message; |
| 400 | } ghostty_diagnostic_s; |
| 401 | |
| 402 | typedef struct { |
| 403 | const char* ptr; |
| 404 | uintptr_t len; |
| 405 | bool sentinel; |
| 406 | } ghostty_string_s; |
| 407 | |
| 408 | typedef 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 | |
| 417 | typedef enum { |
| 418 | GHOSTTY_POINT_ACTIVE, |
| 419 | GHOSTTY_POINT_VIEWPORT, |
| 420 | GHOSTTY_POINT_SCREEN, |
| 421 | GHOSTTY_POINT_SURFACE, |
| 422 | } ghostty_point_tag_e; |
| 423 | |
| 424 | typedef enum { |
| 425 | GHOSTTY_POINT_COORD_EXACT, |
| 426 | GHOSTTY_POINT_COORD_TOP_LEFT, |
| 427 | GHOSTTY_POINT_COORD_BOTTOM_RIGHT, |
| 428 | } ghostty_point_coord_e; |
| 429 | |
| 430 | typedef 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 | |
| 437 | typedef struct { |
| 438 | ghostty_point_s top_left; |
| 439 | ghostty_point_s bottom_right; |
| 440 | bool rectangle; |
| 441 | } ghostty_selection_s; |
| 442 | |
| 443 | typedef struct { |
| 444 | const char* key; |
| 445 | const char* value; |
| 446 | } ghostty_env_var_s; |
| 447 | |
| 448 | typedef struct { |
| 449 | void* nsview; |
| 450 | } ghostty_platform_macos_s; |
| 451 | |
| 452 | typedef struct { |
| 453 | void* uiview; |
| 454 | } ghostty_platform_ios_s; |
| 455 | |
| 456 | typedef union { |
| 457 | ghostty_platform_macos_s macos; |
| 458 | ghostty_platform_ios_s ios; |
| 459 | } ghostty_platform_u; |
| 460 | |
| 461 | typedef 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 | |
| 467 | typedef 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 | |
| 482 | typedef 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 |
| 494 | typedef struct { |
| 495 | const char* path; |
| 496 | bool optional; |
| 497 | } ghostty_config_path_s; |
| 498 | |
| 499 | // config.Color |
| 500 | typedef struct { |
| 501 | uint8_t r; |
| 502 | uint8_t g; |
| 503 | uint8_t b; |
| 504 | } ghostty_config_color_s; |
| 505 | |
| 506 | // config.ColorList |
| 507 | typedef struct { |
| 508 | const ghostty_config_color_s* colors; |
| 509 | size_t len; |
| 510 | } ghostty_config_color_list_s; |
| 511 | |
| 512 | // config.RepeatableCommand |
| 513 | typedef struct { |
| 514 | const ghostty_command_s* commands; |
| 515 | size_t len; |
| 516 | } ghostty_config_command_list_s; |
| 517 | |
| 518 | // config.Palette |
| 519 | typedef struct { |
| 520 | ghostty_config_color_s colors[256]; |
| 521 | } ghostty_config_palette_s; |
| 522 | |
| 523 | // config.QuickTerminalSize |
| 524 | typedef 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 | |
| 530 | typedef union { |
| 531 | float percentage; |
| 532 | uint32_t pixels; |
| 533 | } ghostty_quick_terminal_size_value_u; |
| 534 | |
| 535 | typedef struct { |
| 536 | ghostty_quick_terminal_size_tag_e tag; |
| 537 | ghostty_quick_terminal_size_value_u value; |
| 538 | } ghostty_quick_terminal_size_s; |
| 539 | |
| 540 | typedef 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 |
| 546 | typedef 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 |
| 555 | typedef enum { |
| 556 | GHOSTTY_TARGET_APP, |
| 557 | GHOSTTY_TARGET_SURFACE, |
| 558 | } ghostty_target_tag_e; |
| 559 | |
| 560 | typedef union { |
| 561 | ghostty_surface_t surface; |
| 562 | } ghostty_target_u; |
| 563 | |
| 564 | typedef struct { |
| 565 | ghostty_target_tag_e tag; |
| 566 | ghostty_target_u target; |
| 567 | } ghostty_target_s; |
| 568 | |
| 569 | // apprt.action.SplitDirection |
| 570 | typedef 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 |
| 578 | typedef 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 |
| 588 | typedef enum { |
| 589 | GHOSTTY_GOTO_WINDOW_PREVIOUS, |
| 590 | GHOSTTY_GOTO_WINDOW_NEXT, |
| 591 | } ghostty_action_goto_window_e; |
| 592 | |
| 593 | // apprt.action.ResizeSplit.Direction |
| 594 | typedef 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 |
| 602 | typedef struct { |
| 603 | uint16_t amount; |
| 604 | ghostty_action_resize_split_direction_e direction; |
| 605 | } ghostty_action_resize_split_s; |
| 606 | |
| 607 | // apprt.action.MoveTab |
| 608 | typedef struct { |
| 609 | ssize_t amount; |
| 610 | } ghostty_action_move_tab_s; |
| 611 | |
| 612 | // apprt.action.GotoTab |
| 613 | typedef 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 |
| 620 | typedef 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 |
| 628 | typedef 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 |
| 635 | typedef 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 |
| 642 | typedef enum { |
| 643 | GHOSTTY_INSPECTOR_TOGGLE, |
| 644 | GHOSTTY_INSPECTOR_SHOW, |
| 645 | GHOSTTY_INSPECTOR_HIDE, |
| 646 | } ghostty_action_inspector_e; |
| 647 | |
| 648 | // apprt.action.QuitTimer |
| 649 | typedef enum { |
| 650 | GHOSTTY_QUIT_TIMER_START, |
| 651 | GHOSTTY_QUIT_TIMER_STOP, |
| 652 | } ghostty_action_quit_timer_e; |
| 653 | |
| 654 | // apprt.action.Readonly |
| 655 | typedef enum { |
| 656 | GHOSTTY_READONLY_OFF, |
| 657 | GHOSTTY_READONLY_ON, |
| 658 | } ghostty_action_readonly_e; |
| 659 | |
| 660 | // apprt.action.DesktopNotification.C |
| 661 | typedef struct { |
| 662 | const char* title; |
| 663 | const char* body; |
| 664 | } ghostty_action_desktop_notification_s; |
| 665 | |
| 666 | // apprt.action.SetTitle.C |
| 667 | typedef struct { |
| 668 | const char* title; |
| 669 | } ghostty_action_set_title_s; |
| 670 | |
| 671 | // apprt.action.PromptTitle |
| 672 | typedef enum { |
| 673 | GHOSTTY_PROMPT_TITLE_SURFACE, |
| 674 | GHOSTTY_PROMPT_TITLE_TAB, |
| 675 | } ghostty_action_prompt_title_e; |
| 676 | |
| 677 | // apprt.action.Pwd.C |
| 678 | typedef struct { |
| 679 | const char* pwd; |
| 680 | } ghostty_action_pwd_s; |
| 681 | |
| 682 | // terminal.MouseShape |
| 683 | typedef 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 |
| 721 | typedef enum { |
| 722 | GHOSTTY_MOUSE_VISIBLE, |
| 723 | GHOSTTY_MOUSE_HIDDEN, |
| 724 | } ghostty_action_mouse_visibility_e; |
| 725 | |
| 726 | // apprt.action.MouseOverLink |
| 727 | typedef struct { |
| 728 | const char* url; |
| 729 | size_t len; |
| 730 | } ghostty_action_mouse_over_link_s; |
| 731 | |
| 732 | // apprt.action.SizeLimit |
| 733 | typedef 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 |
| 741 | typedef struct { |
| 742 | uint32_t width; |
| 743 | uint32_t height; |
| 744 | } ghostty_action_initial_size_s; |
| 745 | |
| 746 | // apprt.action.CellSize |
| 747 | typedef struct { |
| 748 | uint32_t width; |
| 749 | uint32_t height; |
| 750 | } ghostty_action_cell_size_s; |
| 751 | |
| 752 | // renderer.Health |
| 753 | typedef enum { |
| 754 | GHOSTTY_RENDERER_HEALTH_HEALTHY, |
| 755 | GHOSTTY_RENDERER_HEALTH_UNHEALTHY, |
| 756 | } ghostty_action_renderer_health_e; |
| 757 | |
| 758 | // apprt.action.KeySequence |
| 759 | typedef struct { |
| 760 | bool active; |
| 761 | ghostty_input_trigger_s trigger; |
| 762 | } ghostty_action_key_sequence_s; |
| 763 | |
| 764 | // apprt.action.KeyTable.Tag |
| 765 | typedef 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 |
| 772 | typedef 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 |
| 780 | typedef 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 |
| 786 | typedef 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 |
| 793 | typedef 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 |
| 801 | typedef struct { |
| 802 | ghostty_config_t config; |
| 803 | } ghostty_action_config_change_s; |
| 804 | |
| 805 | // apprt.action.ReloadConfig |
| 806 | typedef struct { |
| 807 | bool soft; |
| 808 | } ghostty_action_reload_config_s; |
| 809 | |
| 810 | // apprt.action.OpenUrlKind |
| 811 | typedef 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 |
| 818 | typedef 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 |
| 825 | typedef 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 |
| 832 | typedef struct { |
| 833 | uint32_t exit_code; |
| 834 | uint64_t timetime_ms; |
| 835 | } ghostty_surface_message_childexited_s; |
| 836 | |
| 837 | // terminal.osc.Command.ProgressReport.State |
| 838 | typedef 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 |
| 847 | typedef 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 |
| 855 | typedef 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 |
| 863 | typedef struct { |
| 864 | const char* needle; |
| 865 | } ghostty_action_start_search_s; |
| 866 | |
| 867 | // apprt.action.SearchTotal |
| 868 | typedef struct { |
| 869 | ssize_t total; |
| 870 | } ghostty_action_search_total_s; |
| 871 | |
| 872 | // apprt.action.SearchSelected |
| 873 | typedef struct { |
| 874 | ssize_t selected; |
| 875 | } ghostty_action_search_selected_s; |
| 876 | |
| 877 | // terminal.Scrollbar |
| 878 | typedef struct { |
| 879 | uint64_t total; |
| 880 | uint64_t offset; |
| 881 | uint64_t len; |
| 882 | } ghostty_action_scrollbar_s; |
| 883 | |
| 884 | // apprt.Action.Key |
| 885 | typedef 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 | |
| 954 | typedef 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 | |
| 995 | typedef struct { |
| 996 | ghostty_action_tag_e tag; |
| 997 | ghostty_action_u action; |
| 998 | } ghostty_action_s; |
| 999 | |
| 1000 | typedef void (*ghostty_runtime_wakeup_cb)(void*); |
| 1001 | typedef bool (*ghostty_runtime_read_clipboard_cb)(void*, |
| 1002 | ghostty_clipboard_e, |
| 1003 | void*); |
| 1004 | typedef void (*ghostty_runtime_confirm_read_clipboard_cb)( |
| 1005 | void*, |
| 1006 | const char*, |
| 1007 | void*, |
| 1008 | ghostty_clipboard_request_e); |
| 1009 | typedef void (*ghostty_runtime_write_clipboard_cb)(void*, |
| 1010 | ghostty_clipboard_e, |
| 1011 | const ghostty_clipboard_content_s*, |
| 1012 | size_t, |
| 1013 | bool); |
| 1014 | typedef void (*ghostty_runtime_close_surface_cb)(void*, bool); |
| 1015 | typedef bool (*ghostty_runtime_action_cb)(ghostty_app_t, |
| 1016 | ghostty_target_s, |
| 1017 | ghostty_action_s); |
| 1018 | |
| 1019 | typedef 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 |
| 1031 | typedef enum { |
| 1032 | GHOSTTY_IPC_TARGET_CLASS, |
| 1033 | GHOSTTY_IPC_TARGET_DETECT, |
| 1034 | } ghostty_ipc_target_tag_e; |
| 1035 | |
| 1036 | typedef union { |
| 1037 | char *klass; |
| 1038 | } ghostty_ipc_target_u; |
| 1039 | |
| 1040 | typedef 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 |
| 1046 | typedef struct { |
| 1047 | // This should be a null terminated list of strings. |
| 1048 | const char **arguments; |
| 1049 | } ghostty_ipc_action_new_window_s; |
| 1050 | |
| 1051 | typedef union { |
| 1052 | ghostty_ipc_action_new_window_s new_window; |
| 1053 | } ghostty_ipc_action_u; |
| 1054 | |
| 1055 | // apprt.ipc.Action.Key |
| 1056 | typedef 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 | |
| 1064 | GHOSTTY_API int ghostty_init(uintptr_t, char**); |
| 1065 | GHOSTTY_API void ghostty_cli_try_action(void); |
| 1066 | GHOSTTY_API ghostty_info_s ghostty_info(void); |
| 1067 | GHOSTTY_API const char* ghostty_translate(const char*); |
| 1068 | GHOSTTY_API void ghostty_string_free(ghostty_string_s); |
| 1069 | |
| 1070 | GHOSTTY_API ghostty_config_t ghostty_config_new(); |
| 1071 | GHOSTTY_API void ghostty_config_free(ghostty_config_t); |
| 1072 | GHOSTTY_API ghostty_config_t ghostty_config_clone(ghostty_config_t); |
| 1073 | GHOSTTY_API void ghostty_config_load_cli_args(ghostty_config_t); |
| 1074 | GHOSTTY_API void ghostty_config_load_file(ghostty_config_t, const char*); |
| 1075 | GHOSTTY_API void ghostty_config_load_default_files(ghostty_config_t); |
| 1076 | GHOSTTY_API void ghostty_config_load_recursive_files(ghostty_config_t); |
| 1077 | GHOSTTY_API void ghostty_config_finalize(ghostty_config_t); |
| 1078 | GHOSTTY_API bool ghostty_config_get(ghostty_config_t, void*, const char*, uintptr_t); |
| 1079 | GHOSTTY_API ghostty_input_trigger_s ghostty_config_trigger(ghostty_config_t, |
| 1080 | const char*, |
| 1081 | uintptr_t); |
| 1082 | GHOSTTY_API bool ghostty_config_key_is_binding(ghostty_config_t, ghostty_input_key_s); |
| 1083 | GHOSTTY_API uint32_t ghostty_config_diagnostics_count(ghostty_config_t); |
| 1084 | GHOSTTY_API ghostty_diagnostic_s ghostty_config_get_diagnostic(ghostty_config_t, uint32_t); |
| 1085 | GHOSTTY_API ghostty_string_s ghostty_config_open_path(void); |
| 1086 | |
| 1087 | GHOSTTY_API ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s*, |
| 1088 | ghostty_config_t); |
| 1089 | GHOSTTY_API void ghostty_app_free(ghostty_app_t); |
| 1090 | GHOSTTY_API void ghostty_app_tick(ghostty_app_t); |
| 1091 | GHOSTTY_API void* ghostty_app_userdata(ghostty_app_t); |
| 1092 | GHOSTTY_API void ghostty_app_set_focus(ghostty_app_t, bool); |
| 1093 | GHOSTTY_API bool ghostty_app_key(ghostty_app_t, ghostty_input_key_s); |
| 1094 | GHOSTTY_API void ghostty_app_keyboard_changed(ghostty_app_t); |
| 1095 | GHOSTTY_API void ghostty_app_open_config(ghostty_app_t); |
| 1096 | GHOSTTY_API void ghostty_app_update_config(ghostty_app_t, ghostty_config_t); |
| 1097 | GHOSTTY_API bool ghostty_app_needs_confirm_quit(ghostty_app_t); |
| 1098 | GHOSTTY_API bool ghostty_app_has_global_keybinds(ghostty_app_t); |
| 1099 | GHOSTTY_API void ghostty_app_set_color_scheme(ghostty_app_t, ghostty_color_scheme_e); |
| 1100 | |
| 1101 | GHOSTTY_API ghostty_surface_config_s ghostty_surface_config_new(); |
| 1102 | |
| 1103 | GHOSTTY_API ghostty_surface_t ghostty_surface_new(ghostty_app_t, |
| 1104 | const ghostty_surface_config_s*); |
| 1105 | GHOSTTY_API void ghostty_surface_free(ghostty_surface_t); |
| 1106 | GHOSTTY_API void* ghostty_surface_userdata(ghostty_surface_t); |
| 1107 | GHOSTTY_API ghostty_app_t ghostty_surface_app(ghostty_surface_t); |
| 1108 | GHOSTTY_API ghostty_surface_config_s ghostty_surface_inherited_config(ghostty_surface_t, ghostty_surface_context_e); |
| 1109 | GHOSTTY_API void ghostty_surface_update_config(ghostty_surface_t, ghostty_config_t); |
| 1110 | GHOSTTY_API bool ghostty_surface_needs_confirm_quit(ghostty_surface_t); |
| 1111 | GHOSTTY_API bool ghostty_surface_process_exited(ghostty_surface_t); |
| 1112 | GHOSTTY_API void ghostty_surface_refresh(ghostty_surface_t); |
| 1113 | GHOSTTY_API void ghostty_surface_draw(ghostty_surface_t); |
| 1114 | GHOSTTY_API void ghostty_surface_set_content_scale(ghostty_surface_t, double, double); |
| 1115 | GHOSTTY_API void ghostty_surface_set_focus(ghostty_surface_t, bool); |
| 1116 | GHOSTTY_API void ghostty_surface_set_occlusion(ghostty_surface_t, bool); |
| 1117 | GHOSTTY_API void ghostty_surface_set_size(ghostty_surface_t, uint32_t, uint32_t); |
| 1118 | GHOSTTY_API ghostty_surface_size_s ghostty_surface_size(ghostty_surface_t); |
| 1119 | GHOSTTY_API uint64_t ghostty_surface_foreground_pid(ghostty_surface_t); |
| 1120 | GHOSTTY_API ghostty_string_s ghostty_surface_tty_name(ghostty_surface_t); |
| 1121 | GHOSTTY_API void ghostty_surface_set_color_scheme(ghostty_surface_t, |
| 1122 | ghostty_color_scheme_e); |
| 1123 | GHOSTTY_API ghostty_input_mods_e ghostty_surface_key_translation_mods(ghostty_surface_t, |
| 1124 | ghostty_input_mods_e); |
| 1125 | GHOSTTY_API bool ghostty_surface_key(ghostty_surface_t, ghostty_input_key_s); |
| 1126 | GHOSTTY_API bool ghostty_surface_key_is_binding(ghostty_surface_t, |
| 1127 | ghostty_input_key_s, |
| 1128 | ghostty_binding_flags_e*); |
| 1129 | GHOSTTY_API void ghostty_surface_text(ghostty_surface_t, const char*, uintptr_t); |
| 1130 | GHOSTTY_API void ghostty_surface_preedit(ghostty_surface_t, const char*, uintptr_t); |
| 1131 | GHOSTTY_API bool ghostty_surface_mouse_captured(ghostty_surface_t); |
| 1132 | GHOSTTY_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); |
| 1136 | GHOSTTY_API void ghostty_surface_mouse_pos(ghostty_surface_t, |
| 1137 | double, |
| 1138 | double, |
| 1139 | ghostty_input_mods_e); |
| 1140 | GHOSTTY_API void ghostty_surface_mouse_scroll(ghostty_surface_t, |
| 1141 | double, |
| 1142 | double, |
| 1143 | ghostty_input_scroll_mods_t); |
| 1144 | GHOSTTY_API void ghostty_surface_mouse_pressure(ghostty_surface_t, uint32_t, double); |
| 1145 | GHOSTTY_API void ghostty_surface_ime_point(ghostty_surface_t, double*, double*, double*, double*); |
| 1146 | GHOSTTY_API void ghostty_surface_request_close(ghostty_surface_t); |
| 1147 | GHOSTTY_API void ghostty_surface_split(ghostty_surface_t, ghostty_action_split_direction_e); |
| 1148 | GHOSTTY_API void ghostty_surface_split_focus(ghostty_surface_t, |
| 1149 | ghostty_action_goto_split_e); |
| 1150 | GHOSTTY_API void ghostty_surface_split_resize(ghostty_surface_t, |
| 1151 | ghostty_action_resize_split_direction_e, |
| 1152 | uint16_t); |
| 1153 | GHOSTTY_API void ghostty_surface_split_equalize(ghostty_surface_t); |
| 1154 | GHOSTTY_API bool ghostty_surface_binding_action(ghostty_surface_t, const char*, uintptr_t); |
| 1155 | GHOSTTY_API void ghostty_surface_complete_clipboard_request(ghostty_surface_t, |
| 1156 | const char*, |
| 1157 | void*, |
| 1158 | bool); |
| 1159 | GHOSTTY_API bool ghostty_surface_has_selection(ghostty_surface_t); |
| 1160 | GHOSTTY_API bool ghostty_surface_read_selection(ghostty_surface_t, ghostty_text_s*); |
| 1161 | GHOSTTY_API bool ghostty_surface_read_text(ghostty_surface_t, |
| 1162 | ghostty_selection_s, |
| 1163 | ghostty_text_s*); |
| 1164 | GHOSTTY_API void ghostty_surface_free_text(ghostty_surface_t, ghostty_text_s*); |
| 1165 | |
| 1166 | #ifdef __APPLE__ |
| 1167 | GHOSTTY_API void ghostty_surface_set_display_id(ghostty_surface_t, uint32_t); |
| 1168 | GHOSTTY_API void* ghostty_surface_quicklook_font(ghostty_surface_t); |
| 1169 | GHOSTTY_API bool ghostty_surface_quicklook_word(ghostty_surface_t, ghostty_text_s*); |
| 1170 | #endif |
| 1171 | |
| 1172 | GHOSTTY_API ghostty_inspector_t ghostty_surface_inspector(ghostty_surface_t); |
| 1173 | GHOSTTY_API void ghostty_inspector_free(ghostty_surface_t); |
| 1174 | GHOSTTY_API void ghostty_inspector_set_focus(ghostty_inspector_t, bool); |
| 1175 | GHOSTTY_API void ghostty_inspector_set_content_scale(ghostty_inspector_t, double, double); |
| 1176 | GHOSTTY_API void ghostty_inspector_set_size(ghostty_inspector_t, uint32_t, uint32_t); |
| 1177 | GHOSTTY_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); |
| 1181 | GHOSTTY_API void ghostty_inspector_mouse_pos(ghostty_inspector_t, double, double); |
| 1182 | GHOSTTY_API void ghostty_inspector_mouse_scroll(ghostty_inspector_t, |
| 1183 | double, |
| 1184 | double, |
| 1185 | ghostty_input_scroll_mods_t); |
| 1186 | GHOSTTY_API void ghostty_inspector_key(ghostty_inspector_t, |
| 1187 | ghostty_input_action_e, |
| 1188 | ghostty_input_key_e, |
| 1189 | ghostty_input_mods_e); |
| 1190 | GHOSTTY_API void ghostty_inspector_text(ghostty_inspector_t, const char*); |
| 1191 | |
| 1192 | #ifdef __APPLE__ |
| 1193 | GHOSTTY_API bool ghostty_inspector_metal_init(ghostty_inspector_t, void*); |
| 1194 | GHOSTTY_API void ghostty_inspector_metal_render(ghostty_inspector_t, void*, void*); |
| 1195 | GHOSTTY_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. |
| 1200 | GHOSTTY_API void ghostty_set_window_background_blur(ghostty_app_t, void*); |
| 1201 | |
| 1202 | // Benchmark API, if available. |
| 1203 | GHOSTTY_API bool ghostty_benchmark_cli(const char*, const char*); |
| 1204 | |
| 1205 | #ifdef __cplusplus |
| 1206 | } |
| 1207 | #endif |
| 1208 | |
| 1209 | #endif /* GHOSTTY_H */ |