aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/include
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-04-06 22:05:00 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-04-06 22:56:01 +0300
commit6ccf156a3dd23f419c03892ddc1136e72957f66a (patch)
tree1d5465e61d03344a63683ad3b9bbdec9a4476a5c /vendor/libghostty-vt/include
parent62b751b2b551d866e2aebfdecf89f7a003d64ebc (diff)
refactor: use libghostty-native selection text reading
Diffstat (limited to 'vendor/libghostty-vt/include')
-rw-r--r--vendor/libghostty-vt/include/ghostty/vt/terminal.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/include/ghostty/vt/terminal.h b/vendor/libghostty-vt/include/ghostty/vt/terminal.h
index b43e37cf..b466bd84 100644
--- a/vendor/libghostty-vt/include/ghostty/vt/terminal.h
+++ b/vendor/libghostty-vt/include/ghostty/vt/terminal.h
@@ -254,6 +254,26 @@ typedef struct {
} GhosttyTerminalScrollbar;
/**
+ * Selection bounds for terminal text extraction.
+ *
+ * The start and end points may be in any supported point coordinate system
+ * (active, viewport, screen, or history). Text is always returned in reading
+ * order. Set `rectangle` to true for rectangular selection semantics.
+ *
+ * @ingroup terminal
+ */
+typedef struct {
+ /** Selection start point. */
+ GhosttyPoint start;
+
+ /** Selection end point. */
+ GhosttyPoint end;
+
+ /** Whether to treat the selection as a rectangle. */
+ bool rectangle;
+} GhosttyTerminalSelection;
+
+/**
* Callback function type for bell.
*
* Called when the terminal receives a BEL character (0x07).
@@ -974,6 +994,34 @@ GHOSTTY_API GhosttyResult ghostty_terminal_grid_ref(GhosttyTerminal terminal,
GhosttyPoint point,
GhosttyGridRef *out_ref);
+/**
+ * Read terminal text for an arbitrary selection.
+ *
+ * Formats the selected region as plain text using Ghostty's native selection
+ * semantics. Soft-wrapped lines are unwrapped and trailing whitespace is
+ * trimmed on non-blank lines.
+ *
+ * The returned buffer is allocated using the provided allocator, or the
+ * default allocator if NULL is passed. Free it with ghostty_free(), passing
+ * the same allocator pointer and returned length.
+ *
+ * @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)
+ * @param selection The selection bounds to read
+ * @param allocator Pointer to allocator, or NULL to use the default allocator
+ * @param[out] out_ptr On success, set to the allocated output buffer
+ * @param[out] out_len On success, set to the output length in bytes
+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if the terminal
+ * is NULL or the selection points are out of bounds,
+ * GHOSTTY_OUT_OF_MEMORY on allocation failure
+ *
+ * @ingroup terminal
+ */
+GHOSTTY_API GhosttyResult ghostty_terminal_read_text(GhosttyTerminal terminal,
+ GhosttyTerminalSelection selection,
+ const GhosttyAllocator* allocator,
+ uint8_t** out_ptr,
+ size_t* out_len);
+
/** @} */
#ifdef __cplusplus