···108108} GhosttyTerminalSelectWordOptions;
109109110110/**
111111+ * Options for deriving the nearest word selection between two grid references.
112112+ *
113113+ * This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.
114114+ * If boundary_codepoints is NULL and boundary_codepoints_len is 0, Ghostty's
115115+ * default word-boundary codepoints are used. If boundary_codepoints_len is
116116+ * non-zero, boundary_codepoints must not be NULL.
117117+ *
118118+ * @ingroup selection
119119+ */
120120+typedef struct {
121121+ /** Size of this struct in bytes. Must be set to sizeof(GhosttyTerminalSelectWordBetweenOptions). */
122122+ size_t size;
123123+124124+ /** Starting grid reference for the inclusive search range. */
125125+ GhosttyGridRef start;
126126+127127+ /** Ending grid reference for the inclusive search range. */
128128+ GhosttyGridRef end;
129129+130130+ /** Optional word-boundary codepoints as uint32_t scalar values. */
131131+ const uint32_t* boundary_codepoints;
132132+133133+ /** Number of entries in boundary_codepoints. */
134134+ size_t boundary_codepoints_len;
135135+} GhosttyTerminalSelectWordBetweenOptions;
136136+137137+/**
111138 * Options for deriving a line selection from a terminal grid reference.
112139 *
113140 * This is a sized struct. Use GHOSTTY_INIT_SIZED() to initialize it.
···233260GHOSTTY_API GhosttyResult ghostty_terminal_select_word(
234261 GhosttyTerminal terminal,
235262 const GhosttyTerminalSelectWordOptions* options,
263263+ GhosttySelection* out_selection);
264264+265265+/**
266266+ * Derive the nearest word selection snapshot between two terminal grid refs.
267267+ *
268268+ * Starting at options->start, this searches toward options->end (inclusive)
269269+ * and returns the first selectable word found using Ghostty's word-selection
270270+ * rules.
271271+ *
272272+ * This is useful for implementing double-click-and-drag selection in a UI. If
273273+ * a user double-clicks one word and drags across spaces or punctuation toward
274274+ * another word, selecting only the word directly under the current pointer can
275275+ * flicker or collapse when the pointer is between words. Instead, ask for the
276276+ * nearest word between the original click and the drag point, ask again in the
277277+ * reverse direction, and combine the two word bounds into the drag selection.
278278+ *
279279+ * @snippet c-vt-selection/src/main.c selection-word-between
280280+ *
281281+ * The returned selection is not installed as the terminal's current
282282+ * selection. It is a snapshot with the same lifetime rules as GhosttySelection.
283283+ *
284284+ * @param terminal The terminal handle (NULL returns GHOSTTY_INVALID_VALUE)
285285+ * @param options Word-between-selection options
286286+ * @param[out] out_selection On success, receives the derived selection
287287+ * @return GHOSTTY_SUCCESS on success, GHOSTTY_NO_VALUE if there is no
288288+ * selectable word content between the valid refs, or
289289+ * GHOSTTY_INVALID_VALUE if the terminal, options, refs, codepoint
290290+ * pointer, or output pointer are invalid.
291291+ *
292292+ * @ingroup selection
293293+ */
294294+GHOSTTY_API GhosttyResult ghostty_terminal_select_word_between(
295295+ GhosttyTerminal terminal,
296296+ const GhosttyTerminalSelectWordBetweenOptions* options,
236297 GhosttySelection* out_selection);
237298238299/**