mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 15:01:16 -03:00
Add kill-selection function and visual binds for 'y' and 'd'
This commit is contained in:
15
reader.cpp
15
reader.cpp
@@ -2436,7 +2436,7 @@ size_t reader_get_cursor_pos()
|
||||
return data->buff_pos;
|
||||
}
|
||||
|
||||
bool reader_get_selection_pos(size_t &start, size_t &stop)
|
||||
bool reader_get_selection(size_t &start, size_t &len)
|
||||
{
|
||||
if (!data)
|
||||
{
|
||||
@@ -2449,7 +2449,7 @@ bool reader_get_selection_pos(size_t &start, size_t &stop)
|
||||
else
|
||||
{
|
||||
start = data->sel_start_pos;
|
||||
stop = data->sel_stop_pos;
|
||||
len = std::min(data->sel_stop_pos - data->sel_start_pos + 1, data->command_length());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3850,6 +3850,17 @@ const wchar_t *reader_readline(void)
|
||||
break;
|
||||
}
|
||||
|
||||
case R_KILL_SELECTION:
|
||||
{
|
||||
bool newv = (last_char != R_KILL_SELECTION);
|
||||
size_t start, len;
|
||||
if(reader_get_selection(start, len))
|
||||
{
|
||||
reader_kill(start, len, KILL_APPEND, newv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Other, if a normal character, we add it to the command */
|
||||
default:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user