mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-27 09:31:39 +00:00
lib-vt: move scrollback limits to terminal_set
Terminal construction previously accepted GhosttyTerminalOptions with dimensions and one scrollback byte limit. Remove the options struct from the ABI and make ghostty_terminal_new accept columns and rows directly. Add byte and line limit options to ghostty_terminal_set and forward them to the runtime Terminal setters. NULL removes a limit, while zero bytes disables scrollback. Update type metadata, tests, and all API examples.
This commit is contained in:
@@ -42,8 +42,7 @@
|
||||
* @code{.c}
|
||||
* // Create a terminal and feed it some VT data that changes modes
|
||||
* GhosttyTerminal terminal;
|
||||
* ghostty_terminal_new(NULL, &terminal,
|
||||
* (GhosttyTerminalOptions){.cols = 80, .rows = 24, .max_scrollback = 0});
|
||||
* ghostty_terminal_new(NULL, &terminal, 80, 24);
|
||||
*
|
||||
* // Application might write data that enables Kitty keyboard protocol, etc.
|
||||
* ghostty_terminal_vt_write(terminal, vt_data, vt_len);
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
* @code{.c}
|
||||
* // Create a terminal and feed it some VT data that enables mouse tracking
|
||||
* GhosttyTerminal terminal;
|
||||
* ghostty_terminal_new(NULL, &terminal,
|
||||
* (GhosttyTerminalOptions){.cols = 80, .rows = 24, .max_scrollback = 0});
|
||||
* ghostty_terminal_new(NULL, &terminal, 80, 24);
|
||||
*
|
||||
* // Application might write data that enables mouse reporting, etc.
|
||||
* ghostty_terminal_vt_write(terminal, vt_data, vt_len);
|
||||
|
||||
@@ -172,26 +172,6 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Terminal initialization options.
|
||||
*
|
||||
* @ingroup terminal
|
||||
*/
|
||||
typedef struct {
|
||||
/** Terminal width in cells. Must be greater than zero. */
|
||||
uint16_t cols;
|
||||
|
||||
/** Terminal height in cells. Must be greater than zero. */
|
||||
uint16_t rows;
|
||||
|
||||
/** Maximum number of lines to keep in scrollback history. */
|
||||
size_t max_scrollback;
|
||||
|
||||
// TODO: Consider ABI compatibility implications of this struct.
|
||||
// We may want to artificially pad it significantly to support
|
||||
// future options.
|
||||
} GhosttyTerminalOptions;
|
||||
|
||||
/**
|
||||
* Amount of compression work to perform before returning.
|
||||
*
|
||||
@@ -888,6 +868,28 @@ typedef enum GHOSTTY_ENUM_TYPED {
|
||||
* Input type: GhosttyTerminalClipboardWriteFn
|
||||
*/
|
||||
GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE = 26,
|
||||
|
||||
/**
|
||||
* Set the maximum scrollback allocation in bytes.
|
||||
*
|
||||
* Lowering the limit immediately removes eligible complete historical
|
||||
* pages. A value of zero disables scrollback and erases retained history.
|
||||
* A NULL value pointer removes the byte limit.
|
||||
*
|
||||
* Input type: size_t*
|
||||
*/
|
||||
GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES = 27,
|
||||
|
||||
/**
|
||||
* Set the maximum number of physical lines retained in scrollback.
|
||||
*
|
||||
* Lowering the limit immediately removes eligible complete historical
|
||||
* pages. The effective limit retains the active-area and page-granularity
|
||||
* minimums. A NULL value pointer removes the line limit.
|
||||
*
|
||||
* Input type: size_t*
|
||||
*/
|
||||
GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_LINES = 28,
|
||||
GHOSTTY_TERMINAL_OPT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
|
||||
} GhosttyTerminalOption;
|
||||
|
||||
@@ -1221,16 +1223,22 @@ typedef enum GHOSTTY_ENUM_TYPED {
|
||||
/**
|
||||
* Create a new terminal instance.
|
||||
*
|
||||
* The terminal starts with various reasonable defaults e.g. around
|
||||
* scrollback limits. Use ghostty_terminal_set() to change any options
|
||||
* prior to using the terminal.
|
||||
*
|
||||
* @param allocator Pointer to allocator, or NULL to use the default allocator
|
||||
* @param terminal Pointer to store the created terminal handle
|
||||
* @param options Terminal initialization options
|
||||
* @param cols Terminal width in cells (must be greater than zero)
|
||||
* @param rows Terminal height in cells (must be greater than zero)
|
||||
* @return GHOSTTY_SUCCESS on success, or an error code on failure
|
||||
*
|
||||
* @ingroup terminal
|
||||
*/
|
||||
GHOSTTY_API GhosttyResult ghostty_terminal_new(const GhosttyAllocator* allocator,
|
||||
GhosttyTerminal* terminal,
|
||||
GhosttyTerminalOptions options);
|
||||
GhosttyTerminal* terminal,
|
||||
uint16_t cols,
|
||||
uint16_t rows);
|
||||
|
||||
/**
|
||||
* Free a terminal instance.
|
||||
@@ -1291,7 +1299,8 @@ GHOSTTY_API GhosttyResult ghostty_terminal_resize(GhosttyTerminal terminal,
|
||||
* write_pty callback and userdata pointer. The value is passed
|
||||
* directly for pointer types (callbacks, userdata) or as a pointer
|
||||
* to the value for non-pointer types (e.g. GhosttyString*).
|
||||
* NULL clears the option to its default.
|
||||
* The behavior of a NULL value is specific to each option and is
|
||||
* documented by the corresponding GhosttyTerminalOption value.
|
||||
*
|
||||
* Callbacks are invoked synchronously during ghostty_terminal_vt_write().
|
||||
* Callbacks must not call ghostty_terminal_vt_write() on the same
|
||||
|
||||
Reference in New Issue
Block a user