mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-05 01:40:41 -05:00
mouse scrolling and selection
This commit is contained in:
parent
a163484f25
commit
5fc55b8fbd
7 changed files with 147 additions and 66 deletions
72
vimode.c
72
vimode.c
|
|
@ -460,6 +460,32 @@ void vimode_cancel(struct terminal *term)
|
|||
render_refresh(term);
|
||||
}
|
||||
|
||||
void vimode_view_up(struct terminal *term, int const delta)
|
||||
{
|
||||
if (!term->vimode.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
damage_cursor_cell(term);
|
||||
term->vimode.cursor.row += delta;
|
||||
clip_cursor_to_view(term);
|
||||
update_selection(term);
|
||||
update_highlights(term);
|
||||
}
|
||||
|
||||
void vimode_view_down(struct terminal *const term, int const delta)
|
||||
{
|
||||
if (!term->vimode.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
damage_cursor_cell(term);
|
||||
term->vimode.cursor.row -= delta;
|
||||
clip_cursor_to_view(term);
|
||||
update_selection(term);
|
||||
update_highlights(term);
|
||||
}
|
||||
|
||||
static ssize_t matches_cell(const struct terminal *term,
|
||||
const struct cell *cell, char32_t const *const buf,
|
||||
size_t const len, size_t search_ofs)
|
||||
|
|
@ -819,19 +845,6 @@ void vimode_search_add_chars(struct terminal *term, const char *src,
|
|||
on_search_string_updated(term);
|
||||
}
|
||||
|
||||
void vimode_view_down(struct terminal *const term, int const delta)
|
||||
{
|
||||
if (!term->vimode.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_DBG("VIMODE VIEW DOWN [delta=%d]", delta);
|
||||
damage_cursor_cell(term);
|
||||
term->vimode.cursor.row -= delta;
|
||||
clip_cursor_to_view(term);
|
||||
update_highlights(term);
|
||||
}
|
||||
|
||||
enum c32_class {
|
||||
CLASS_BLANK,
|
||||
CLASS_PUNCTUATION,
|
||||
|
|
@ -1738,3 +1751,36 @@ void vimode_input(struct seat *seat, struct terminal *term,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vimode_mouse_selection_begin(struct terminal *const term,
|
||||
struct coord const point,
|
||||
enum vi_mode const vmode)
|
||||
{
|
||||
if (term->vimode.active == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_mode_visual(vmode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
term->vimode.selection.mouse_button_pressed = true;
|
||||
term->vimode.selection.start = point;
|
||||
term->vimode.mode = vmode;
|
||||
damage_cursor_cell(term);
|
||||
term->vimode.cursor = cursor_from_view_relative(term, point);
|
||||
damage_cursor_cell(term);
|
||||
}
|
||||
|
||||
void vimode_mouse_selection_end(struct terminal *const term)
|
||||
{
|
||||
term->vimode.selection.mouse_button_pressed = false;
|
||||
}
|
||||
|
||||
void vimode_mouse_move(struct terminal *const term, struct coord const point)
|
||||
{
|
||||
damage_cursor_cell(term);
|
||||
term->vimode.cursor = cursor_from_view_relative(term, point);
|
||||
damage_cursor_cell(term);
|
||||
update_selection(term);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue