From beb4556dc0e8a3c8c6febfb5dc832895098c7e4f Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 27 Aug 2025 13:43:12 +0200 Subject: multi-cursor: wip: track cursor shapes and colors And erase all extra cursors on reset, resize and clear screen/scrollback (ED 2/3). --- terminal.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 62bcd7d9..8c008af2 100644 --- a/terminal.c +++ b/terminal.c @@ -1404,6 +1404,11 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper, .ime_enabled = true, #endif .active_notifications = tll_init(), + .multi_cursor = { + .shapes = NULL, + .cursor_color = MULTI_CURSOR_COLOR_PRIMARY, + .text_color = MULTI_CURSOR_COLOR_PRIMARY, + }, }; pixman_region32_init(&term->render.last_overlay_clip); @@ -1946,6 +1951,7 @@ term_destroy(struct terminal *term) free(term->color_stack.stack); pixman_region32_fini(&term->multi_cursor.active); + free(term->multi_cursor.shapes); int ret = EXIT_SUCCESS; @@ -2090,6 +2096,15 @@ term_theme_apply(struct terminal *term, const struct color_theme *theme) memcpy(term->colors.table, theme->table, sizeof(term->colors.table)); } +void +term_remove_all_multi_cursors(struct terminal *term) +{ + pixman_region32_fini(&term->multi_cursor.active); + pixman_region32_init(&term->multi_cursor.active); + free(term->multi_cursor.shapes); + term->multi_cursor.shapes = NULL; +} + void term_reset(struct terminal *term, bool hard) { @@ -2170,6 +2185,12 @@ term_reset(struct terminal *term, bool hard) term->bits_affecting_ascii_printer.value = 0; term_update_ascii_printer(term); + term_remove_all_multi_cursors(term); + term->multi_cursor.cursor_color_source = MULTI_CURSOR_COLOR_PRIMARY; + term->multi_cursor.text_color_source = MULTI_CURSOR_COLOR_PRIMARY; + term->multi_cursor.cursor_color = 0; + term->multi_cursor.text_color = 0; + if (!hard) return; -- cgit v1.3