From a168a780876c284b7cfd319d14e63ddb2793129d Mon Sep 17 00:00:00 2001 From: Piotr Kocia Date: Mon, 31 Mar 2025 18:19:08 +0200 Subject: [PATCH] resolve todos --- ime.c | 27 ++++++++++----------------- unicode-mode.c | 14 +++++--------- vimode.c | 6 ++++-- vimode.h | 3 ++- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/ime.c b/ime.c index 3d3160a9..56711254 100644 --- a/ime.c +++ b/ime.c @@ -11,9 +11,9 @@ #include "log.h" #include "char32.h" #include "render.h" -#include "search.h" #include "terminal.h" #include "util.h" +#include "vimode.h" #include "wayland.h" #include "xmalloc.h" @@ -177,10 +177,8 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, ime_reset_preedit(seat); if (term != NULL) { - if (term->vimode.active) - // TODO (kociap): refresh - // render_refresh_search(term); - (void)0; + if (term->vimode.searching) + render_refresh_vimode_search_box(term); else render_refresh(term); } @@ -200,11 +198,9 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, size_t len = strlen(text); if (term != NULL) { - if (term->vimode.active) { - // TODO (kociap): input and refresh - // search_add_chars(term, text, len); - // render_refresh_search(term); - (void)0; + if (term->vimode.searching) { + vimode_search_add_chars(term, text, len); + render_refresh_vimode_search_box(term); } else term_to_slave(term, text, len); } @@ -371,10 +367,8 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, ime_reset_pending_preedit(seat); if (term != NULL) { - if (term->vimode.active) - // TODO (kociap): refresh - // render_refresh_search(term); - (void)0; + if (term->vimode.searching) + render_refresh_vimode_search_box(term); else render_refresh(term); } @@ -480,9 +474,8 @@ ime_update_cursor_rect(struct seat *seat) goto update; /* Set in render_search_box() */ - // TODO (kociap): in vimode this most likely is not necessary. - // if (term->vimode.searching) - // goto update; + if (term->vimode.searching) + goto update; int x, y, width, height; int col = term->grid->cursor.point.col; diff --git a/unicode-mode.c b/unicode-mode.c index 35956f88..8fddb57b 100644 --- a/unicode-mode.c +++ b/unicode-mode.c @@ -4,7 +4,7 @@ #define LOG_ENABLE_DBG 0 #include "log.h" #include "render.h" -#include "search.h" +#include "vimode.h" void unicode_mode_activate(struct terminal *term) @@ -33,10 +33,8 @@ unicode_mode_updated(struct terminal *term) { if (term == NULL) return; - if (term->vimode.active) - // TODO (kociap): refresh - // render_refresh_search(term); - (void)0; + if (term->vimode.searching) + render_refresh_vimode_search_box(term); else render_refresh(term); } @@ -58,10 +56,8 @@ unicode_mode_input(struct seat *seat, struct terminal *term, term->unicode_mode.character, (int)chars, utf8); if (chars != (size_t)-1) { - if (term->vimode.active) - // TODO (kociap): input - // search_add_chars(term, utf8, chars); - (void)0; + if (term->vimode.searching) + vimode_search_add_chars(term, utf8, chars); else term_to_slave(term, utf8, chars); } diff --git a/vimode.c b/vimode.c index 7e8bb913..4c6f4ff7 100644 --- a/vimode.c +++ b/vimode.c @@ -19,6 +19,7 @@ // TODO (kociap): consider adding scrolloff. // TODO (kociap): consider not cancelling selection on scroll. // TODO (kociap): jump list? +// TODO (kociap): WORD motions. static bool is_mode_visual(enum vi_mode const mode) { return mode == VI_MODE_VISUAL || mode == VI_MODE_VLINE || @@ -724,7 +725,8 @@ static void add_wchars(struct terminal *term, char32_t *src, size_t count) { term->vimode.search.buf[term->vimode.search.len] = U'\0'; } -void search_add_chars(struct terminal *term, const char *src, size_t count) { +void vimode_search_add_chars(struct terminal *term, const char *src, + size_t count) { size_t chars = mbsntoc32(NULL, src, count, 0); if (chars == (size_t)-1) { LOG_ERRNO("failed to convert %.*s to Unicode", (int)count, src); @@ -1513,7 +1515,7 @@ void vimode_input(struct seat *seat, struct terminal *term, } if (count > 0) { - search_add_chars(term, (const char *)buf, count); + vimode_search_add_chars(term, (const char *)buf, count); render_refresh_vimode_search_box(term); search_string_updated = true; } diff --git a/vimode.h b/vimode.h index ff39b660..4523117e 100644 --- a/vimode.h +++ b/vimode.h @@ -20,7 +20,8 @@ void vimode_input(struct seat *seat, struct terminal *term, xkb_keysym_t sym, xkb_mod_mask_t mods, xkb_mod_mask_t consumed, const xkb_keysym_t *raw_syms, size_t raw_count, uint32_t serial); -// void search_add_chars(struct terminal *term, const char *text, size_t len); +void vimode_search_add_chars(struct terminal *term, const char *text, + size_t len); struct search_match_iterator { struct terminal *term;