Ver Fonte

LibLine: Add ctrl-t shortcut for transposing characters

Nico Weber há 5 anos atrás
pai
commit
6105f063cb
1 ficheiros alterados com 11 adições e 0 exclusões
  1. 11 0
      Libraries/LibLine/Editor.cpp

+ 11 - 0
Libraries/LibLine/Editor.cpp

@@ -921,6 +921,17 @@ void Editor::handle_read_event()
             }
             continue;
         }
+        // ^T
+        if (codepoint == ctrl('T')) {
+            if (m_cursor > 0 && m_buffer.size() >= 2) {
+                if (m_cursor < m_buffer.size())
+                    ++m_cursor;
+                swap(m_buffer[m_cursor - 1], m_buffer[m_cursor - 2]);
+                // FIXME: Update anchored styles too.
+                m_refresh_needed = true;
+            }
+            continue;
+        }
         if (codepoint == '\n') {
             finish();
             continue;