mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 01:18:12 +00:00
LibLine: Add binding for Alt-backspace
It backward-deletes a word like Ctrl-W, but it has a slightly different definition of what a word is. For example, with the caret behind `gcc -fsanitize=address`, Ctrl-W would delete '-fsanitize=address' but Alt-backspace would only delete 'address'.
This commit is contained in:
parent
2051d690d5
commit
c1fb5263a5
1 changed files with 21 additions and 5 deletions
|
@ -42,7 +42,7 @@
|
||||||
// #define SUGGESTIONS_DEBUG
|
// #define SUGGESTIONS_DEBUG
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
u32 ctrl(char c) { return c & 0x3f; }
|
constexpr u32 ctrl(char c) { return c & 0x3f; }
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Line {
|
namespace Line {
|
||||||
|
@ -587,6 +587,26 @@ void Editor::handle_read_event()
|
||||||
do_cursor_left(Word);
|
do_cursor_left(Word);
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
|
case 'f': // ^[f: alt-f
|
||||||
|
do_cursor_right(Word);
|
||||||
|
m_state = InputState::Free;
|
||||||
|
continue;
|
||||||
|
case ctrl('H'): // ^[^H: alt-backspace: backward delete word
|
||||||
|
{
|
||||||
|
// A word here is contiguous alnums. `foo=bar baz` is three words.
|
||||||
|
bool has_seen_alnum = false;
|
||||||
|
while (m_cursor > 0) {
|
||||||
|
if (!isalnum(m_buffer[m_cursor - 1])) {
|
||||||
|
if (has_seen_alnum)
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
has_seen_alnum = true;
|
||||||
|
}
|
||||||
|
do_backspace();
|
||||||
|
}
|
||||||
|
m_state = InputState::Free;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
case 'd': // ^[d: alt-d: forward delete word
|
case 'd': // ^[d: alt-d: forward delete word
|
||||||
{
|
{
|
||||||
// A word here is contiguous alnums. `foo=bar baz` is three words.
|
// A word here is contiguous alnums. `foo=bar baz` is three words.
|
||||||
|
@ -603,10 +623,6 @@ void Editor::handle_read_event()
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case 'f': // ^[f: alt-f
|
|
||||||
do_cursor_right(Word);
|
|
||||||
m_state = InputState::Free;
|
|
||||||
continue;
|
|
||||||
case 'c': // ^[c: alt-c: capitalize word
|
case 'c': // ^[c: alt-c: capitalize word
|
||||||
case 'l': // ^[l: alt-l: lowercase word
|
case 'l': // ^[l: alt-l: lowercase word
|
||||||
case 'u': // ^[u: alt-u: uppercase word
|
case 'u': // ^[u: alt-u: uppercase word
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue