This commit is contained in:
Piotr Kocia 2025-03-30 12:53:34 +02:00
parent 66a3e53b31
commit 2033b267d8
7 changed files with 28 additions and 27 deletions

8
ime.c
View file

@ -177,7 +177,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
ime_reset_preedit(seat); ime_reset_preedit(seat);
if (term != NULL) { if (term != NULL) {
if (term->is_vimming) if (term->vimode.active)
// TODO (kociap): refresh // TODO (kociap): refresh
// render_refresh_search(term); // render_refresh_search(term);
(void)0; (void)0;
@ -200,7 +200,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
size_t len = strlen(text); size_t len = strlen(text);
if (term != NULL) { if (term != NULL) {
if (term->is_vimming) { if (term->vimode.active) {
// TODO (kociap): input and refresh // TODO (kociap): input and refresh
// search_add_chars(term, text, len); // search_add_chars(term, text, len);
// render_refresh_search(term); // 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); ime_reset_pending_preedit(seat);
if (term != NULL) { if (term != NULL) {
if (term->is_vimming) if (term->vimode.active)
// TODO (kociap): refresh // TODO (kociap): refresh
// render_refresh_search(term); // render_refresh_search(term);
(void)0; (void)0;
@ -481,7 +481,7 @@ ime_update_cursor_rect(struct seat *seat)
/* Set in render_search_box() */ /* Set in render_search_box() */
// TODO (kociap): in vimode this most likely is not necessary. // TODO (kociap): in vimode this most likely is not necessary.
// if (term->is_searching) // if (term->vimode.searching)
// goto update; // goto update;
int x, y, width, height; int x, y, width, height;

View file

@ -1640,7 +1640,7 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
return; return;
} }
else if (term->is_vimming) { else if (term->vimode.active) {
printf("VIMODE INPUT\n"); printf("VIMODE INPUT\n");
if (should_repeat) if (should_repeat)
start_repeater(seat, key); start_repeater(seat, key);
@ -2749,7 +2749,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
selection_stop_scroll_timer(term); selection_stop_scroll_timer(term);
/* Update selection */ /* Update selection */
if (!term->is_vimming) { if (!term->vimode.active) {
if (auto_scroll_direction != SELECTION_SCROLL_NOT) { if (auto_scroll_direction != SELECTION_SCROLL_NOT) {
/* /*
* Start 'selection auto-scrolling' * Start 'selection auto-scrolling'

View file

@ -1770,7 +1770,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat,
if (likely(seat->ime.preedit.cells == NULL)) if (likely(seat->ime.preedit.cells == NULL))
return; return;
if (unlikely(term->is_vimming)) if (unlikely(term->vimode.active))
return; return;
const bool gamma_correct = wayl_do_linear_blending(term->wl, term->conf); 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 bool unicode_mode_active = term->unicode_mode.active;
const enum overlay_style style = const enum overlay_style style =
term->is_vimming ? OVERLAY_NONE : term->vimode.active ? OVERLAY_NONE :
term->flash.active ? OVERLAY_FLASH : term->flash.active ? OVERLAY_FLASH :
unicode_mode_active ? OVERLAY_UNICODE_MODE : unicode_mode_active ? OVERLAY_UNICODE_MODE :
OVERLAY_NONE; OVERLAY_NONE;
@ -2134,7 +2134,7 @@ render_worker_thread(void *_ctx)
* not dependent on the terminal state. * not dependent on the terminal state.
*/ */
struct coord cursor = {-1, -1}; struct coord cursor = {-1, -1};
if (term->is_vimming) { if (term->vimode.active) {
cursor = term->vimode.cursor; cursor = term->vimode.cursor;
cursor.row += term->grid->offset; cursor.row += term->grid->offset;
cursor.row -= term->grid->view; cursor.row -= term->grid->view;
@ -3024,7 +3024,7 @@ render_scrollback_position(struct terminal *term)
case SCROLLBACK_INDICATOR_POSITION_RELATIVE: { case SCROLLBACK_INDICATOR_POSITION_RELATIVE: {
int lines = term->rows - 2; /* Avoid using first and last rows */ int lines = term->rows - 2; /* Avoid using first and last rows */
// TODO (kociap): whatever this does // TODO (kociap): whatever this does
// if (term->is_searching) { // if (term->vimode.searching) {
// /* Make sure we don't collide with the scrollback search box */ // /* Make sure we don't collide with the scrollback search box */
// lines--; // lines--;
// } // }
@ -5233,7 +5233,7 @@ render_refresh_csd(struct terminal *term)
void void
render_refresh_vimode_search_box(struct terminal *term) 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; term->render.refresh.vimode_search_box = true;
} }

View file

@ -524,7 +524,7 @@ cursor_refresh(struct terminal *term)
if (!term->window->is_configured) if (!term->window->is_configured)
return; return;
if(term->is_vimming) { if(term->vimode.active) {
struct row *const row = struct row *const row =
grid_row_in_view(term->grid, term->vimode.cursor.row); grid_row_in_view(term->grid, term->vimode.cursor.row);
row->cells[term->vimode.cursor.col].attrs.clean = 0; row->cells[term->vimode.cursor.col].attrs.clean = 0;

View file

@ -626,12 +626,12 @@ struct terminal {
} auto_scroll; } auto_scroll;
} selection; } selection;
bool is_vimming;
struct { struct {
bool active;
bool searching;
enum vi_mode mode; enum vi_mode mode;
// The position of the cursor (offset relative). // The position of the cursor (offset relative).
struct coord cursor; struct coord cursor;
bool is_searching;
struct { struct {
struct coord start; struct coord start;

View file

@ -34,7 +34,7 @@ unicode_mode_updated(struct terminal *term)
if (term == NULL) if (term == NULL)
return; return;
printf("UNICODE UPDATE\n"); printf("UNICODE UPDATE\n");
if (term->is_vimming) if (term->vimode.active)
// TODO (kociap): refresh // TODO (kociap): refresh
// render_refresh_search(term); // render_refresh_search(term);
(void)0; (void)0;
@ -60,7 +60,7 @@ unicode_mode_input(struct seat *seat, struct terminal *term,
term->unicode_mode.character, (int)chars, utf8); term->unicode_mode.character, (int)chars, utf8);
if (chars != (size_t)-1) { if (chars != (size_t)-1) {
if (term->is_vimming) if (term->vimode.active)
// TODO (kociap): input // TODO (kociap): input
// search_add_chars(term, utf8, chars); // search_add_chars(term, utf8, chars);
(void)0; (void)0;

View file

@ -291,7 +291,7 @@ static bool search_ensure_size(struct terminal *term, size_t wanted_size) {
static void start_search(struct terminal *term, static void start_search(struct terminal *term,
enum search_direction const direction) { enum search_direction const direction) {
if (term->vimode.is_searching) { if (term->vimode.searching) {
return; return;
} }
@ -308,7 +308,7 @@ static void start_search(struct terminal *term,
term->vimode.search.direction = direction; term->vimode.search.direction = direction;
term->vimode.search.match = (struct coord){-1, -1}; term->vimode.search.match = (struct coord){-1, -1};
term->vimode.search.match_len = 0; term->vimode.search.match_len = 0;
term->vimode.is_searching = true; term->vimode.searching = true;
/* On-demand instantiate wayland surface */ /* On-demand instantiate wayland surface */
bool ret = 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); ensure_view_is_allocated(term, term->vimode.search.original_view);
term_damage_view(term); term_damage_view(term);
render_refresh(term); render_refresh(term);
update_selection(term);
} }
static void cancel_search(struct terminal *const term, static void cancel_search(struct terminal *const term,
bool const restore_original) { bool const restore_original) {
if (!term->vimode.is_searching) { if (!term->vimode.searching) {
return; return;
} }
wayl_win_subsurface_destroy(&term->window->search); wayl_win_subsurface_destroy(&term->window->search);
clear_highlights(term);
term->vimode.is_searching = false; term->vimode.searching = false;
struct vimode_search *const search = &term->vimode.search; struct vimode_search *const search = &term->vimode.search;
if (restore_original) { if (restore_original) {
restore_pre_search_state(term); restore_pre_search_state(term);
@ -389,14 +390,14 @@ void vimode_begin(struct terminal *term) {
term_ime_enable(term); term_ime_enable(term);
} }
term->is_vimming = true; term->vimode.active = true;
term_xcursor_update(term); term_xcursor_update(term);
} }
// TODO (kociap): vimode is being cancelled by cursor input. // TODO (kociap): vimode is being cancelled by cursor input.
void vimode_cancel(struct terminal *term) { void vimode_cancel(struct terminal *term) {
if (!term->is_vimming) { if (!term->vimode.active) {
return; return;
} }
@ -406,7 +407,7 @@ void vimode_cancel(struct terminal *term) {
clear_highlights(term); clear_highlights(term);
selection_cancel(term); selection_cancel(term);
term->is_vimming = false; term->vimode.active = false;
/* Reset IME state */ /* Reset IME state */
if (term_ime_is_enabled(term)) { 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) { void vimode_view_down(struct terminal *const term, int const delta) {
if (!term->is_vimming) { if (!term->vimode.active) {
return; 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_state_get_status(seat->kbd.xkb_compose_state)
: XKB_COMPOSE_NOTHING; : XKB_COMPOSE_NOTHING;
if (!term->vimode.is_searching) { if (!term->vimode.searching) {
struct key_binding const *const binding = match_binding( struct key_binding const *const binding = match_binding(
&bindings->vimode, key, sym, mods, consumed, raw_syms, raw_count); &bindings->vimode, key, sym, mods, consumed, raw_syms, raw_count);
if (binding != NULL) { 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); delta_cursor_to_abs_coord(term, term->vimode.search.match);
move_cursor_delta(term, delta); move_cursor_delta(term, delta);
center_view_on_cursor(term); center_view_on_cursor(term);
update_selection(term);
} else { } else {
restore_pre_search_state(term); restore_pre_search_state(term);
} }
update_selection(term);
update_highlights(term); update_highlights(term);
} }
} }