mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +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);
|
insert(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::insert(const StringView& string_view)
|
||||||
|
{
|
||||||
|
for (auto ch : Utf8View { string_view })
|
||||||
|
insert(ch);
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::insert(const u32 cp)
|
void Editor::insert(const u32 cp)
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
@ -567,6 +573,16 @@ void Editor::handle_read_event()
|
||||||
case '[':
|
case '[':
|
||||||
m_state = InputState::GotEscapeFollowedByLeftBracket;
|
m_state = InputState::GotEscapeFollowedByLeftBracket;
|
||||||
continue;
|
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
|
case 'b': // ^[b: alt-b
|
||||||
do_cursor_left(Word);
|
do_cursor_left(Word);
|
||||||
m_state = InputState::Free;
|
m_state = InputState::Free;
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
|
|
||||||
void clear_line();
|
void clear_line();
|
||||||
void insert(const String&);
|
void insert(const String&);
|
||||||
|
void insert(const StringView&);
|
||||||
void insert(const Utf32View&);
|
void insert(const Utf32View&);
|
||||||
void insert(const u32);
|
void insert(const u32);
|
||||||
void stylize(const Span&, const Style&);
|
void stylize(const Span&, const Style&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue