mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
LibLine: Add binding for Alt-.
This commit is contained in:
parent
6be3f914f0
commit
7f7dd3cf9c
2 changed files with 17 additions and 0 deletions
|
@ -106,6 +106,12 @@ void Editor::insert(const String& string)
|
|||
insert(ch);
|
||||
}
|
||||
|
||||
void Editor::insert(const StringView& string_view)
|
||||
{
|
||||
for (auto ch : Utf8View { string_view })
|
||||
insert(ch);
|
||||
}
|
||||
|
||||
void Editor::insert(const u32 cp)
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
@ -567,6 +573,16 @@ void Editor::handle_read_event()
|
|||
case '[':
|
||||
m_state = InputState::GotEscapeFollowedByLeftBracket;
|
||||
continue;
|
||||
case '.': // ^[.: alt-.: insert last arg of previous command (similar to `!$`)
|
||||
{
|
||||
if (!m_history.is_empty()) {
|
||||
// FIXME: This isn't quite right: if the last arg was `"foo bar"` or `foo\ bar` (but not `foo\\ bar`), we should insert that whole arg as last token.
|
||||
if (auto last_words = m_history.last().split_view(' '); !last_words.is_empty())
|
||||
insert(last_words.last());
|
||||
}
|
||||
m_state = InputState::Free;
|
||||
continue;
|
||||
}
|
||||
case 'b': // ^[b: alt-b
|
||||
do_cursor_left(Word);
|
||||
m_state = InputState::Free;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue