apprt/embedded: improve text reading APIs (selection, random points)

This commit is contained in:
Mitchell Hashimoto
2025-06-09 15:48:03 -07:00
parent be437f5b64
commit c5f921bb06
5 changed files with 357 additions and 101 deletions

View File

@@ -355,6 +355,27 @@ typedef struct {
double tl_px_y;
uint32_t offset_start;
uint32_t offset_len;
const char* text;
uintptr_t text_len;
} ghostty_text_s;
typedef enum {
GHOSTTY_POINT_ACTIVE,
GHOSTTY_POINT_VIEWPORT,
GHOSTTY_POINT_SCREEN,
GHOSTTY_POINT_SURFACE,
} ghostty_point_tag_e;
typedef struct {
ghostty_point_tag_e tag;
uint32_t x;
uint32_t y;
} ghostty_point_s;
typedef struct {
ghostty_point_s top_left;
ghostty_point_s bottom_right;
bool rectangle;
} ghostty_selection_s;
typedef struct {
@@ -832,16 +853,16 @@ void ghostty_surface_complete_clipboard_request(ghostty_surface_t,
void*,
bool);
bool ghostty_surface_has_selection(ghostty_surface_t);
uintptr_t ghostty_surface_selection(ghostty_surface_t, char*, uintptr_t);
bool ghostty_surface_read_selection(ghostty_surface_t, ghostty_text_s*);
bool ghostty_surface_read_text(ghostty_surface_t,
ghostty_selection_s,
ghostty_text_s*);
void ghostty_surface_free_text(ghostty_surface_t, ghostty_text_s*);
#ifdef __APPLE__
void ghostty_surface_set_display_id(ghostty_surface_t, uint32_t);
void* ghostty_surface_quicklook_font(ghostty_surface_t);
uintptr_t ghostty_surface_quicklook_word(ghostty_surface_t,
char*,
uintptr_t,
ghostty_selection_s*);
bool ghostty_surface_selection_info(ghostty_surface_t, ghostty_selection_s*);
bool ghostty_surface_quicklook_word(ghostty_surface_t, ghostty_text_s*);
#endif
ghostty_inspector_t ghostty_surface_inspector(ghostty_surface_t);