diff options
author | Nico Weber <thakis@chromium.org> | 2020-08-06 13:26:43 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-06 19:48:30 +0200 |
commit | 90efba95c1637b2c0a1b042aa59a6f604b1645bc (patch) | |
tree | 6eb79a7769b9ca9c9131a160ca9313703add614b /Libraries/LibLine | |
parent | 5d343e1c29b8b181b8744405d9b074566c6cbc13 (diff) | |
download | serenity-90efba95c1637b2c0a1b042aa59a6f604b1645bc.zip |
LibLine: Add bindings for Alt-u, Alt-l, Alt-c
Diffstat (limited to 'Libraries/LibLine')
-rw-r--r-- | Libraries/LibLine/Editor.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp index 3e37c8177f..138d97636c 100644 --- a/Libraries/LibLine/Editor.cpp +++ b/Libraries/LibLine/Editor.cpp @@ -571,7 +571,7 @@ void Editor::handle_read_event() do_cursor_left(Word); m_state = InputState::Free; continue; - case 'd': // ^[d: alt-d + case 'd': // ^[d: alt-d: forward delete word { bool has_seen_nonspace = false; while (m_cursor < m_buffer.size()) { @@ -590,6 +590,26 @@ void Editor::handle_read_event() do_cursor_right(Word); m_state = InputState::Free; continue; + case 'c': // ^[c: alt-c: capitalize word + case 'l': // ^[l: alt-l: lowercase word + case 'u': // ^[u: alt-u: uppercase word + { + while (m_cursor < m_buffer.size() && isspace(m_buffer[m_cursor])) + ++m_cursor; + size_t start = m_cursor; + while (m_cursor < m_buffer.size() && !isspace(m_buffer[m_cursor])) { + if (code_point == 'u' || (code_point == 'c' && m_cursor == start)) { + m_buffer[m_cursor] = toupper(m_buffer[m_cursor]); + } else { + ASSERT(code_point == 'l' || (code_point == 'c' && m_cursor > start)); + m_buffer[m_cursor] = tolower(m_buffer[m_cursor]); + } + ++m_cursor; + m_refresh_needed = true; + } + m_state = InputState::Free; + continue; + } default: m_state = InputState::Free; continue; |