From 2033b267d80c835cd106475f60738250f7063833 Mon Sep 17 00:00:00 2001 From: Piotr Kocia Date: Sun, 30 Mar 2025 12:53:34 +0200 Subject: [PATCH] rename --- ime.c | 8 ++++---- input.c | 4 ++-- render.c | 10 +++++----- terminal.c | 2 +- terminal.h | 4 ++-- unicode-mode.c | 4 ++-- vimode.c | 23 ++++++++++++----------- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/ime.c b/ime.c index e1a64d61..3d3160a9 100644 --- a/ime.c +++ b/ime.c @@ -177,7 +177,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, ime_reset_preedit(seat); if (term != NULL) { - if (term->is_vimming) + if (term->vimode.active) // TODO (kociap): refresh // render_refresh_search(term); (void)0; @@ -200,7 +200,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, size_t len = strlen(text); if (term != NULL) { - if (term->is_vimming) { + if (term->vimode.active) { // TODO (kociap): input and refresh // search_add_chars(term, text, len); // render_refresh_search(term); @@ -371,7 +371,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, ime_reset_pending_preedit(seat); if (term != NULL) { - if (term->is_vimming) + if (term->vimode.active) // TODO (kociap): refresh // render_refresh_search(term); (void)0; @@ -481,7 +481,7 @@ ime_update_cursor_rect(struct seat *seat) /* Set in render_search_box() */ // TODO (kociap): in vimode this most likely is not necessary. - // if (term->is_searching) + // if (term->vimode.searching) // goto update; int x, y, width, height; diff --git a/input.c b/input.c index f87ad665..45c39ed5 100644 --- a/input.c +++ b/input.c @@ -1640,7 +1640,7 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial, return; } - else if (term->is_vimming) { + else if (term->vimode.active) { printf("VIMODE INPUT\n"); if (should_repeat) start_repeater(seat, key); @@ -2749,7 +2749,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, selection_stop_scroll_timer(term); /* Update selection */ - if (!term->is_vimming) { + if (!term->vimode.active) { if (auto_scroll_direction != SELECTION_SCROLL_NOT) { /* * Start 'selection auto-scrolling' diff --git a/render.c b/render.c index f8f9ff3f..30024429 100644 --- a/render.c +++ b/render.c @@ -1770,7 +1770,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat, if (likely(seat->ime.preedit.cells == NULL)) return; - if (unlikely(term->is_vimming)) + if (unlikely(term->vimode.active)) return; const bool gamma_correct = wayl_do_linear_blending(term->wl, term->conf); @@ -2013,7 +2013,7 @@ render_overlay(struct terminal *term) const bool unicode_mode_active = term->unicode_mode.active; const enum overlay_style style = - term->is_vimming ? OVERLAY_NONE : + term->vimode.active ? OVERLAY_NONE : term->flash.active ? OVERLAY_FLASH : unicode_mode_active ? OVERLAY_UNICODE_MODE : OVERLAY_NONE; @@ -2134,7 +2134,7 @@ render_worker_thread(void *_ctx) * not dependent on the terminal state. */ struct coord cursor = {-1, -1}; - if (term->is_vimming) { + if (term->vimode.active) { cursor = term->vimode.cursor; cursor.row += term->grid->offset; cursor.row -= term->grid->view; @@ -3024,7 +3024,7 @@ render_scrollback_position(struct terminal *term) case SCROLLBACK_INDICATOR_POSITION_RELATIVE: { int lines = term->rows - 2; /* Avoid using first and last rows */ // TODO (kociap): whatever this does - // if (term->is_searching) { + // if (term->vimode.searching) { // /* Make sure we don't collide with the scrollback search box */ // lines--; // } @@ -5233,7 +5233,7 @@ render_refresh_csd(struct terminal *term) void render_refresh_vimode_search_box(struct terminal *term) { - if (term->is_vimming && term->vimode.is_searching) + if (term->vimode.active && term->vimode.searching) term->render.refresh.vimode_search_box = true; } diff --git a/terminal.c b/terminal.c index 085ad198..a1a310fc 100644 --- a/terminal.c +++ b/terminal.c @@ -524,7 +524,7 @@ cursor_refresh(struct terminal *term) if (!term->window->is_configured) return; - if(term->is_vimming) { + if(term->vimode.active) { struct row *const row = grid_row_in_view(term->grid, term->vimode.cursor.row); row->cells[term->vimode.cursor.col].attrs.clean = 0; diff --git a/terminal.h b/terminal.h index 1f352c8e..e583717a 100644 --- a/terminal.h +++ b/terminal.h @@ -626,12 +626,12 @@ struct terminal { } auto_scroll; } selection; - bool is_vimming; struct { + bool active; + bool searching; enum vi_mode mode; // The position of the cursor (offset relative). struct coord cursor; - bool is_searching; struct { struct coord start; diff --git a/unicode-mode.c b/unicode-mode.c index b7d23e36..e09a1c9f 100644 --- a/unicode-mode.c +++ b/unicode-mode.c @@ -34,7 +34,7 @@ unicode_mode_updated(struct terminal *term) if (term == NULL) return; printf("UNICODE UPDATE\n"); - if (term->is_vimming) + if (term->vimode.active) // TODO (kociap): refresh // render_refresh_search(term); (void)0; @@ -60,7 +60,7 @@ unicode_mode_input(struct seat *seat, struct terminal *term, term->unicode_mode.character, (int)chars, utf8); if (chars != (size_t)-1) { - if (term->is_vimming) + if (term->vimode.active) // TODO (kociap): input // search_add_chars(term, utf8, chars); (void)0; diff --git a/vimode.c b/vimode.c index d801f05f..7ac6132e 100644 --- a/vimode.c +++ b/vimode.c @@ -291,7 +291,7 @@ static bool search_ensure_size(struct terminal *term, size_t wanted_size) { static void start_search(struct terminal *term, enum search_direction const direction) { - if (term->vimode.is_searching) { + if (term->vimode.searching) { return; } @@ -308,7 +308,7 @@ static void start_search(struct terminal *term, term->vimode.search.direction = direction; term->vimode.search.match = (struct coord){-1, -1}; term->vimode.search.match_len = 0; - term->vimode.is_searching = true; + term->vimode.searching = true; /* On-demand instantiate wayland surface */ bool ret = @@ -327,17 +327,18 @@ static void restore_pre_search_state(struct terminal *const term) { ensure_view_is_allocated(term, term->vimode.search.original_view); term_damage_view(term); render_refresh(term); + update_selection(term); } static void cancel_search(struct terminal *const term, bool const restore_original) { - if (!term->vimode.is_searching) { + if (!term->vimode.searching) { return; } wayl_win_subsurface_destroy(&term->window->search); - - term->vimode.is_searching = false; + clear_highlights(term); + term->vimode.searching = false; struct vimode_search *const search = &term->vimode.search; if (restore_original) { restore_pre_search_state(term); @@ -389,14 +390,14 @@ void vimode_begin(struct terminal *term) { term_ime_enable(term); } - term->is_vimming = true; + term->vimode.active = true; term_xcursor_update(term); } // TODO (kociap): vimode is being cancelled by cursor input. void vimode_cancel(struct terminal *term) { - if (!term->is_vimming) { + if (!term->vimode.active) { return; } @@ -406,7 +407,7 @@ void vimode_cancel(struct terminal *term) { clear_highlights(term); selection_cancel(term); - term->is_vimming = false; + term->vimode.active = false; /* Reset IME state */ if (term_ime_is_enabled(term)) { @@ -793,7 +794,7 @@ void search_add_chars(struct terminal *term, const char *src, size_t count) { // } void vimode_view_down(struct terminal *const term, int const delta) { - if (!term->is_vimming) { + if (!term->vimode.active) { return; } @@ -1216,7 +1217,7 @@ void vimode_input(struct seat *seat, struct terminal *term, ? xkb_compose_state_get_status(seat->kbd.xkb_compose_state) : XKB_COMPOSE_NOTHING; - if (!term->vimode.is_searching) { + if (!term->vimode.searching) { struct key_binding const *const binding = match_binding( &bindings->vimode, key, sym, mods, consumed, raw_syms, raw_count); if (binding != NULL) { @@ -1266,10 +1267,10 @@ void vimode_input(struct seat *seat, struct terminal *term, delta_cursor_to_abs_coord(term, term->vimode.search.match); move_cursor_delta(term, delta); center_view_on_cursor(term); + update_selection(term); } else { restore_pre_search_state(term); } - update_selection(term); update_highlights(term); } }