| 1 | /** |
| 2 | * @file vt.h |
| 3 | * |
| 4 | * libghostty-vt - Virtual terminal emulator library |
| 5 | * |
| 6 | * This library provides functionality for parsing and handling terminal |
| 7 | * escape sequences as well as maintaining terminal state such as styles, |
| 8 | * cursor position, screen, scrollback, and more. |
| 9 | * |
| 10 | * WARNING: This is an incomplete, work-in-progress API. It is not yet |
| 11 | * stable and is definitely going to change. |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * @mainpage libghostty-vt - Virtual Terminal Emulator Library |
| 16 | * |
| 17 | * libghostty-vt is a C library which implements a modern terminal emulator, |
| 18 | * extracted from the [Ghostty](https://ghostty.org) terminal emulator. |
| 19 | * |
| 20 | * libghostty-vt contains the logic for handling the core parts of a terminal |
| 21 | * emulator: parsing terminal escape sequences, maintaining terminal state, |
| 22 | * encoding input events, etc. It can handle scrollback, line wrapping, |
| 23 | * reflow on resize, and more. |
| 24 | * |
| 25 | * @warning This library is currently in development and the API is not yet stable. |
| 26 | * Breaking changes are expected in future versions. Use with caution in production code. |
| 27 | * |
| 28 | * @section groups_sec API Reference |
| 29 | * |
| 30 | * The API is organized into the following groups: |
| 31 | * - @ref terminal "Terminal" - Complete terminal emulator state and rendering |
| 32 | * - @ref render "Render State" - Incremental render state updates for custom renderers |
| 33 | * - @ref formatter "Formatter" - Format terminal content as plain text, VT sequences, or HTML |
| 34 | * - @ref osc "OSC Parser" - Parse OSC (Operating System Command) sequences |
| 35 | * - @ref sgr "SGR Parser" - Parse SGR (Select Graphic Rendition) sequences |
| 36 | * - @ref paste "Paste Utilities" - Validate paste data safety |
| 37 | * - @ref build_info "Build Info" - Query compile-time build configuration |
| 38 | * - @ref allocator "Memory Management" - Memory management and custom allocators |
| 39 | * - @ref wasm "WebAssembly Utilities" - WebAssembly convenience functions |
| 40 | * |
| 41 | * Encoding related APIs: |
| 42 | * - @ref focus "Focus Encoding" - Encode focus in/out events into terminal sequences |
| 43 | * - @ref key "Key Encoding" - Encode key events into terminal sequences |
| 44 | * - @ref mouse "Mouse Encoding" - Encode mouse events into terminal sequences |
| 45 | * |
| 46 | * @section examples_sec Examples |
| 47 | * |
| 48 | * Complete working examples: |
| 49 | * - @ref c-vt-build-info/src/main.c - Build info query example |
| 50 | * - @ref c-vt/src/main.c - OSC parser example |
| 51 | * - @ref c-vt-encode-key/src/main.c - Key encoding example |
| 52 | * - @ref c-vt-encode-mouse/src/main.c - Mouse encoding example |
| 53 | * - @ref c-vt-paste/src/main.c - Paste safety check example |
| 54 | * - @ref c-vt-sgr/src/main.c - SGR parser example |
| 55 | * - @ref c-vt-formatter/src/main.c - Terminal formatter example |
| 56 | * - @ref c-vt-grid-traverse/src/main.c - Grid traversal example using grid refs |
| 57 | * - @ref c-vt-grid-ref-tracked/src/main.c - Tracked grid ref example |
| 58 | * |
| 59 | */ |
| 60 | |
| 61 | /** @example c-vt-build-info/src/main.c |
| 62 | * This example demonstrates how to query compile-time build configuration |
| 63 | * such as SIMD support, Kitty graphics, and tmux control mode availability. |
| 64 | */ |
| 65 | |
| 66 | /** @example c-vt/src/main.c |
| 67 | * This example demonstrates how to use the OSC parser to parse an OSC sequence, |
| 68 | * extract command information, and retrieve command-specific data like window titles. |
| 69 | */ |
| 70 | |
| 71 | /** @example c-vt-encode-key/src/main.c |
| 72 | * This example demonstrates how to use the key encoder to convert key events |
| 73 | * into terminal escape sequences using the Kitty keyboard protocol. |
| 74 | */ |
| 75 | |
| 76 | /** @example c-vt-encode-mouse/src/main.c |
| 77 | * This example demonstrates how to use the mouse encoder to convert mouse events |
| 78 | * into terminal escape sequences using the SGR mouse format. |
| 79 | */ |
| 80 | |
| 81 | /** @example c-vt-paste/src/main.c |
| 82 | * This example demonstrates how to use the paste utilities to check if |
| 83 | * paste data is safe before sending it to the terminal. |
| 84 | */ |
| 85 | |
| 86 | /** @example c-vt-sgr/src/main.c |
| 87 | * This example demonstrates how to use the SGR parser to parse terminal |
| 88 | * styling sequences and extract text attributes like colors and underline styles. |
| 89 | */ |
| 90 | |
| 91 | /** @example c-vt-formatter/src/main.c |
| 92 | * This example demonstrates how to use the terminal and formatter APIs to |
| 93 | * create a terminal, write VT-encoded content into it, and format the screen |
| 94 | * contents as plain text. |
| 95 | */ |
| 96 | |
| 97 | /** @example c-vt-grid-traverse/src/main.c |
| 98 | * This example demonstrates how to traverse the entire terminal grid using |
| 99 | * grid refs to inspect cell codepoints, row wrap state, and cell styles. |
| 100 | */ |
| 101 | |
| 102 | /** @example c-vt-grid-ref-tracked/src/main.c |
| 103 | * This example demonstrates how to track a grid ref as the terminal scrolls, |
| 104 | * detect when it loses its value, and move it to a new point. |
| 105 | */ |
| 106 | |
| 107 | /** @example c-vt-selection-gesture/src/main.c |
| 108 | * This example demonstrates how to use synthetic selection gesture events to |
| 109 | * derive drag and deep-press selection snapshots. |
| 110 | */ |
| 111 | |
| 112 | /** @example c-vt-kitty-graphics/src/main.c |
| 113 | * This example demonstrates how to use the system interface to install a |
| 114 | * PNG decoder callback and send a Kitty Graphics Protocol image. |
| 115 | */ |
| 116 | |
| 117 | #ifndef GHOSTTY_VT_H |
| 118 | #define GHOSTTY_VT_H |
| 119 | |
| 120 | #ifdef __cplusplus |
| 121 | extern "C" { |
| 122 | #endif |
| 123 | |
| 124 | #include <ghostty/vt/types.h> |
| 125 | #include <ghostty/vt/allocator.h> |
| 126 | #include <ghostty/vt/build_info.h> |
| 127 | #include <ghostty/vt/color.h> |
| 128 | #include <ghostty/vt/device.h> |
| 129 | #include <ghostty/vt/focus.h> |
| 130 | #include <ghostty/vt/formatter.h> |
| 131 | #include <ghostty/vt/render.h> |
| 132 | #include <ghostty/vt/terminal.h> |
| 133 | #include <ghostty/vt/grid_ref.h> |
| 134 | #include <ghostty/vt/grid_ref_tracked.h> |
| 135 | #include <ghostty/vt/osc.h> |
| 136 | #include <ghostty/vt/sgr.h> |
| 137 | #include <ghostty/vt/style.h> |
| 138 | #include <ghostty/vt/sys.h> |
| 139 | #include <ghostty/vt/key.h> |
| 140 | #include <ghostty/vt/kitty_graphics.h> |
| 141 | #include <ghostty/vt/modes.h> |
| 142 | #include <ghostty/vt/mouse.h> |
| 143 | #include <ghostty/vt/paste.h> |
| 144 | #include <ghostty/vt/point.h> |
| 145 | #include <ghostty/vt/screen.h> |
| 146 | #include <ghostty/vt/selection.h> |
| 147 | #include <ghostty/vt/size_report.h> |
| 148 | #include <ghostty/vt/wasm.h> |
| 149 | |
| 150 | #ifdef __cplusplus |
| 151 | } |
| 152 | #endif |
| 153 | |
| 154 | #endif /* GHOSTTY_VT_H */ |