From 90efba95c1637b2c0a1b042aa59a6f604b1645bc Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 6 Aug 2020 13:26:43 -0400 Subject: [PATCH] LibLine: Add bindings for Alt-u, Alt-l, Alt-c --- Libraries/LibLine/Editor.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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;