adding mouse action line_from_begin see #9755
This commit is contained in:
parent
e8461b2a9f
commit
a7e5b949a6
7 changed files with 27 additions and 3 deletions
|
|
@ -51,6 +51,7 @@ MOUSE_SELECTION_EXTEND: int
|
|||
MOUSE_SELECTION_NORMAL: int
|
||||
MOUSE_SELECTION_WORD: int
|
||||
MOUSE_SELECTION_RECTANGLE: int
|
||||
MOUSE_SELECTION_LINE_FROM_BEGIN: int
|
||||
MOUSE_SELECTION_LINE_FROM_POINT: int
|
||||
MOUSE_SELECTION_UPTO_SURROUNDING_WHITESPACE: int
|
||||
MOUSE_SELECTION_WORD_AND_LINE_FROM_POINT: int
|
||||
|
|
|
|||
|
|
@ -1110,6 +1110,7 @@ typedef enum MouseSelectionType {
|
|||
MOUSE_SELECTION_RECTANGLE,
|
||||
MOUSE_SELECTION_WORD,
|
||||
MOUSE_SELECTION_LINE,
|
||||
MOUSE_SELECTION_LINE_FROM_BEGIN,
|
||||
MOUSE_SELECTION_LINE_FROM_POINT,
|
||||
MOUSE_SELECTION_WORD_AND_LINE_FROM_POINT,
|
||||
MOUSE_SELECTION_MOVE_END,
|
||||
|
|
@ -1141,6 +1142,9 @@ mouse_selection(Window *w, int code, int button) {
|
|||
case MOUSE_SELECTION_LINE:
|
||||
if (screen_selection_range_for_line(screen, w->mouse_pos.cell_y, &start, &end)) S(EXTEND_LINE);
|
||||
break;
|
||||
case MOUSE_SELECTION_LINE_FROM_BEGIN:
|
||||
if (screen_selection_range_for_line(screen, w->mouse_pos.cell_y, &start, &end)) S(EXTEND_LINE_FROM_BEGIN);
|
||||
break;
|
||||
case MOUSE_SELECTION_LINE_FROM_POINT:
|
||||
if (screen_selection_range_for_line(screen, w->mouse_pos.cell_y, &start, &end) && end > w->mouse_pos.cell_x) S(EXTEND_LINE_FROM_POINT);
|
||||
break;
|
||||
|
|
@ -1591,6 +1595,7 @@ init_mouse(PyObject *module) {
|
|||
PyModule_AddIntMacro(module, MOUSE_SELECTION_RECTANGLE);
|
||||
PyModule_AddIntMacro(module, MOUSE_SELECTION_WORD);
|
||||
PyModule_AddIntMacro(module, MOUSE_SELECTION_LINE);
|
||||
PyModule_AddIntMacro(module, MOUSE_SELECTION_LINE_FROM_BEGIN);
|
||||
PyModule_AddIntMacro(module, MOUSE_SELECTION_LINE_FROM_POINT);
|
||||
PyModule_AddIntMacro(module, MOUSE_SELECTION_WORD_AND_LINE_FROM_POINT);
|
||||
PyModule_AddIntMacro(module, MOUSE_SELECTION_MOVE_END);
|
||||
|
|
|
|||
|
|
@ -972,6 +972,10 @@
|
|||
'select_line left triplepress ungrabbed mouse_selection line',
|
||||
)
|
||||
|
||||
mma('Select line from beginning of line',
|
||||
'select_line_from_begin left triplepress ungrabbed mouse_selection line_from_begin',
|
||||
)
|
||||
|
||||
mma('Select line from point',
|
||||
'select_line_from_point ctrl+alt+left triplepress ungrabbed mouse_selection line_from_point',
|
||||
long_text='Select from the clicked point to the end of the line.'
|
||||
|
|
@ -1019,6 +1023,10 @@
|
|||
'select_line_grabbed shift+left triplepress ungrabbed,grabbed mouse_selection line',
|
||||
)
|
||||
|
||||
mma('Select line from begin even when grabbed',
|
||||
'select_line_from_begin_grabbed left triplepress ungrabbed,grabbed mouse_selection line_from_begin',
|
||||
)
|
||||
|
||||
mma('Select line from point even when grabbed',
|
||||
'select_line_from_point_grabbed ctrl+shift+alt+left triplepress ungrabbed,grabbed mouse_selection line_from_point',
|
||||
long_text='Select from the clicked point to the end of the line even when grabbed.'
|
||||
|
|
|
|||
6
kitty/options/types.py
generated
6
kitty/options/types.py
generated
|
|
@ -1086,6 +1086,8 @@ def __setattr__(self, key: str, val: typing.Any) -> typing.Any:
|
|||
MouseMapping(repeat_count=2, definition='mouse_selection word'),
|
||||
# select_line
|
||||
MouseMapping(repeat_count=3, definition='mouse_selection line'),
|
||||
# select_line_from_begin
|
||||
MouseMapping(mods=6, repeat_count=3, definition='mouse_selection line_from_begin'),
|
||||
# select_line_from_point
|
||||
MouseMapping(mods=6, repeat_count=3, definition='mouse_selection line_from_point'),
|
||||
# extend_selection
|
||||
|
|
@ -1116,6 +1118,10 @@ def __setattr__(self, key: str, val: typing.Any) -> typing.Any:
|
|||
MouseMapping(mods=7, repeat_count=3, grabbed=True, definition='mouse_selection line_from_point'),
|
||||
# select_line_from_point_grabbed
|
||||
MouseMapping(mods=7, repeat_count=3, definition='mouse_selection line_from_point'),
|
||||
# select_line_from_begin_grabbed
|
||||
MouseMapping(mods=7, repeat_count=3, grabbed=True, definition='mouse_selection line_from_begin'),
|
||||
# select_line_from_begin_grabbed
|
||||
MouseMapping(mods=7, repeat_count=3, definition='mouse_selection line_from_begin'),
|
||||
# extend_selection_grabbed
|
||||
MouseMapping(button=1, mods=1, grabbed=True, definition='mouse_selection extend'),
|
||||
# extend_selection_grabbed
|
||||
|
|
|
|||
|
|
@ -444,6 +444,7 @@ def mouse_selection(func: str, rest: str) -> FuncArgsType:
|
|||
'rectangle': defines.MOUSE_SELECTION_RECTANGLE,
|
||||
'word': defines.MOUSE_SELECTION_WORD,
|
||||
'line': defines.MOUSE_SELECTION_LINE,
|
||||
'line_from_begin': defines.MOUSE_SELECTION_LINE_FROM_BEGIN,
|
||||
'line_from_point': defines.MOUSE_SELECTION_LINE_FROM_POINT,
|
||||
'word_and_line_from_point': defines.MOUSE_SELECTION_WORD_AND_LINE_FROM_POINT,
|
||||
'upto_surrounding_whitespace': defines.MOUSE_SELECTION_UPTO_SURROUNDING_WHITESPACE,
|
||||
|
|
|
|||
|
|
@ -5353,7 +5353,7 @@ do_update_selection(Screen *self, Selection *s, index_type x, index_type y, bool
|
|||
if (upd.set_as_nearest_extend || self->selections.extension_in_progress) {
|
||||
self->selections.extension_in_progress = true;
|
||||
bool start_is_nearer = false;
|
||||
if (self->selections.extend_mode == EXTEND_LINE || self->selections.extend_mode == EXTEND_LINE_FROM_POINT || self->selections.extend_mode == EXTEND_WORD_AND_LINE_FROM_POINT) {
|
||||
if (self->selections.extend_mode == EXTEND_LINE || self->selections.extend_mode == EXTEND_LINE_FROM_BEGIN || self->selections.extend_mode == EXTEND_LINE_FROM_POINT || self->selections.extend_mode == EXTEND_WORD_AND_LINE_FROM_POINT) {
|
||||
if (abs_start.y == abs_end.y) {
|
||||
if (abs_current_input.y == abs_start.y) start_is_nearer = selection_boundary_less_than(&abs_start, &abs_end) ? (abs_current_input.x <= abs_start.x) : (abs_current_input.x <= abs_end.x);
|
||||
else start_is_nearer = selection_boundary_less_than(&abs_start, &abs_end) ? (abs_current_input.y > abs_start.y) : (abs_current_input.y < abs_end.y);
|
||||
|
|
@ -5418,6 +5418,7 @@ do_update_selection(Screen *self, Selection *s, index_type x, index_type y, bool
|
|||
}
|
||||
break;
|
||||
}
|
||||
case EXTEND_LINE_FROM_BEGIN:
|
||||
case EXTEND_LINE_FROM_POINT:
|
||||
case EXTEND_WORD_AND_LINE_FROM_POINT:
|
||||
case EXTEND_LINE: {
|
||||
|
|
@ -5436,7 +5437,9 @@ do_update_selection(Screen *self, Selection *s, index_type x, index_type y, bool
|
|||
s->start.x = up_start.x; s->end.x = bottom_line == top_line ? up_end.x : down_end.x;
|
||||
down_start = up_start; down_end = up_end;
|
||||
bottom_line = continue_line_downwards(self, bottom_line, &down_start, &down_end);
|
||||
if (self->selections.extend_mode == EXTEND_LINE_FROM_POINT) {
|
||||
if (self->selections.extend_mode == EXTEND_LINE_FROM_BEGIN) {
|
||||
S; s->start.x = 0;
|
||||
} else if (self->selections.extend_mode == EXTEND_LINE_FROM_POINT) {
|
||||
if (x <= up_end.x) {
|
||||
S; s->start.x = MAX(x, up_start.x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ typedef struct {
|
|||
bool in_left_half_of_cell;
|
||||
} SelectionBoundary;
|
||||
|
||||
typedef enum SelectionExtendModes { EXTEND_CELL, EXTEND_WORD, EXTEND_LINE, EXTEND_LINE_FROM_POINT, EXTEND_WORD_AND_LINE_FROM_POINT } SelectionExtendMode;
|
||||
typedef enum SelectionExtendModes { EXTEND_CELL, EXTEND_WORD, EXTEND_LINE, EXTEND_LINE_FROM_BEGIN, EXTEND_LINE_FROM_POINT, EXTEND_WORD_AND_LINE_FROM_POINT } SelectionExtendMode;
|
||||
|
||||
typedef struct {
|
||||
index_type x, x_limit;
|
||||
|
|
|
|||
Loading…
Reference in a new issue