Allow extending word selections to non-word chars
This commit is contained in:
parent
5f33d907aa
commit
9849a69afd
@ -136,9 +136,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
- X11: use the window manager's native full-screen implementation when
|
||||
making windows full-screen (:iss:`1605`)
|
||||
|
||||
- Mouse selection: When extending by word, fix selection encompassing one or
|
||||
two non-word characters after a word when the mouse is over that character
|
||||
(:iss:`1616`)
|
||||
- Mouse selection: When extending by word, fix extending selection to non-word
|
||||
characters not working well (:iss:`1616`)
|
||||
|
||||
0.13.3 [2019-01-19]
|
||||
------------------------------
|
||||
|
||||
@ -309,7 +309,7 @@ multi_click(Window *w, unsigned int count) {
|
||||
unsigned int y1 = w->mouse_pos.cell_y, y2 = w->mouse_pos.cell_y;
|
||||
switch(count) {
|
||||
case 2:
|
||||
found_selection = screen_selection_range_for_word(screen, w->mouse_pos.cell_x, &y1, &y2, &start, &end);
|
||||
found_selection = screen_selection_range_for_word(screen, w->mouse_pos.cell_x, &y1, &y2, &start, &end, true);
|
||||
mode = EXTEND_WORD;
|
||||
break;
|
||||
case 3:
|
||||
|
||||
@ -2007,13 +2007,17 @@ is_opt_word_char(char_type ch) {
|
||||
}
|
||||
|
||||
bool
|
||||
screen_selection_range_for_word(Screen *self, index_type x, index_type *y1, index_type *y2, index_type *s, index_type *e) {
|
||||
screen_selection_range_for_word(Screen *self, index_type x, index_type *y1, index_type *y2, index_type *s, index_type *e, bool initial_selection) {
|
||||
if (*y1 >= self->lines || x >= self->columns) return false;
|
||||
index_type start, end;
|
||||
Line *line = visual_line_(self, *y1);
|
||||
*y2 = *y1;
|
||||
#define is_ok(x) (is_word_char((line->cpu_cells[x].ch)) || is_opt_word_char(line->cpu_cells[x].ch))
|
||||
if (!is_ok(x)) return false;
|
||||
if (!is_ok(x)) {
|
||||
if (initial_selection) return false;
|
||||
*s = x; *e = x;
|
||||
return true;
|
||||
}
|
||||
start = x; end = x;
|
||||
while(true) {
|
||||
while(start > 0 && is_ok(start - 1)) start--;
|
||||
@ -2109,19 +2113,19 @@ screen_update_selection(Screen *self, index_type x, index_type y, bool ended) {
|
||||
switch(self->selection.extend_mode) {
|
||||
case EXTEND_WORD: {
|
||||
index_type y1 = y, y2;
|
||||
found = screen_selection_range_for_word(self, x, &y1, &y2, &start, &end);
|
||||
found = screen_selection_range_for_word(self, x, &y1, &y2, &start, &end, false);
|
||||
if (found) {
|
||||
if (extending_leftwards) {
|
||||
self->selection.end_x = start; self->selection.end_y = y1;
|
||||
y1 = self->selection.start_y;
|
||||
found = screen_selection_range_for_word(self, self->selection.start_x, &y1, &y2, &start, &end);
|
||||
found = screen_selection_range_for_word(self, self->selection.start_x, &y1, &y2, &start, &end, false);
|
||||
if (found) {
|
||||
self->selection.start_x = end; self->selection.start_y = y2;
|
||||
}
|
||||
} else {
|
||||
self->selection.end_x = end; self->selection.end_y = y2;
|
||||
y1 = self->selection.start_y;
|
||||
found = screen_selection_range_for_word(self, self->selection.start_x, &y1, &y2, &start, &end);
|
||||
found = screen_selection_range_for_word(self, self->selection.start_x, &y1, &y2, &start, &end, false);
|
||||
if (found) {
|
||||
self->selection.start_x = start; self->selection.start_y = y1;
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ bool screen_invert_colors(Screen *self);
|
||||
void screen_update_cell_data(Screen *self, void *address, FONTS_DATA_HANDLE, bool cursor_has_moved);
|
||||
bool screen_is_cursor_visible(Screen *self);
|
||||
bool screen_selection_range_for_line(Screen *self, index_type y, index_type *start, index_type *end);
|
||||
bool screen_selection_range_for_word(Screen *self, index_type x, index_type *, index_type *, index_type *start, index_type *end);
|
||||
bool screen_selection_range_for_word(Screen *self, index_type x, index_type *, index_type *, index_type *start, index_type *end, bool);
|
||||
void screen_start_selection(Screen *self, index_type x, index_type y, bool, SelectionExtendMode);
|
||||
void screen_update_selection(Screen *self, index_type x, index_type y, bool ended);
|
||||
bool screen_history_scroll(Screen *self, int amt, bool upwards);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user