Select a word, a line, a command's output or the whole screen, then format each selection as text. The line and output selections use OSC 133 prompt markers.
#include <assert.h>
#include <stdio.h>
#include <string.h>
}
.value = { .coordinate = { .x = x, .y = y } },
};
return ref;
}
static void print_selection(
const char *label,
NULL, &formatter, terminal);
bool trim = true;
uint8_t *buf = NULL;
size_t len = 0;
printf("%s: ", label);
fwrite(buf, 1, len, stdout);
printf("\n");
}
int main() {
vt_write(terminal,
"\033]133;A\007$ "
"\033]133;B\007git status"
"\033]133;C\007\r\n"
"On branch main\r\n"
"nothing to commit, working tree clean");
word.
ref = ref_at(terminal, 6, 0);
print_selection(terminal, "word", &selection);
start_word_opts.
start = click_ref;
start_word_opts.
end = drag_ref;
terminal, &start_word_opts, &start_word);
end_word_opts.
start = drag_ref;
end_word_opts.
end = click_ref;
terminal, &end_word_opts, &end_word);
drag_selection.
end = end_word.
end;
print_selection(terminal, "double-click drag", &drag_selection);
line.
ref = ref_at(terminal, 2, 0);
print_selection(terminal, "line", &selection);
terminal, ref_at(terminal, 0, 1), &selection);
print_selection(terminal, "output", &selection);
print_selection(terminal, "all", &selection);
return 0;
}
GHOSTTY_API void ghostty_free(const GhosttyAllocator *allocator, uint8_t *ptr, size_t len)
#define GHOSTTY_INIT_SIZED(type)
@ GHOSTTY_POINT_TAG_ACTIVE
GHOSTTY_API GhosttyResult ghostty_terminal_select_all(GhosttyTerminal terminal, GhosttySelection *out_selection)
GHOSTTY_API GhosttyResult ghostty_terminal_select_output(GhosttyTerminal terminal, GhosttyGridRef ref, GhosttySelection *out_selection)
GHOSTTY_API GhosttyResult ghostty_terminal_select_word_between(GhosttyTerminal terminal, const GhosttyTerminalSelectWordBetweenOptions *options, GhosttySelection *out_selection)
GHOSTTY_API GhosttyResult ghostty_terminal_select_line(GhosttyTerminal terminal, const GhosttyTerminalSelectLineOptions *options, GhosttySelection *out_selection)
GHOSTTY_API GhosttyResult ghostty_terminal_select_word(GhosttyTerminal terminal, const GhosttyTerminalSelectWordOptions *options, GhosttySelection *out_selection)
struct GhosttyTerminalImpl * GhosttyTerminal
GHOSTTY_API void ghostty_terminal_free(GhosttyTerminal terminal)
GHOSTTY_API void ghostty_terminal_vt_write(GhosttyTerminal terminal, const uint8_t *data, size_t len)
GHOSTTY_API GhosttyResult ghostty_terminal_grid_ref(GhosttyTerminal terminal, GhosttyPoint point, GhosttyGridRef *out_ref)
GHOSTTY_API GhosttyResult ghostty_terminal_new(const GhosttyAllocator *allocator, GhosttyTerminal *terminal, uint16_t cols, uint16_t rows)
bool semantic_prompt_boundary