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);
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;

View file

@ -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'

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

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,
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);
}
}