Mon, 15 Dec 2014 21:00:57 +0200
- added readline shortcuts: ^B, ^F, ^A, ^E, ^D (aliases to keyboard presses), ^U, ^K (new functionality)
sources/interface.cpp | file | annotate | diff | comparison | revisions |
--- a/sources/interface.cpp Mon Dec 15 09:12:50 2014 +0200 +++ b/sources/interface.cpp Mon Dec 15 21:00:57 2014 +0200 @@ -657,6 +657,7 @@ break; case KEY_LEFT: + case 'B' - 'A' + 1: // readline ^B if (g_cursor > 0) { g_cursor--; @@ -665,6 +666,7 @@ break; case KEY_RIGHT: + case 'F' - 'A' + 1: // readline ^F if (g_cursor < current_input().length()) { g_cursor++; @@ -678,6 +680,7 @@ break; case KEY_HOME: + case 'A' - 'A' + 1: // readline ^A if (g_cursor != 0) { g_cursor = 0; @@ -686,6 +689,7 @@ break; case KEY_END: + case 'E' - 'A' + 1: // readline ^E if (g_cursor != current_input().length()) { g_cursor = current_input().length(); @@ -702,6 +706,7 @@ break; case KEY_DC: + case 'D' - 'A' + 1: // readline ^D if (g_cursor < current_input().length()) { mutable_current_input().remove_at (g_cursor); @@ -719,6 +724,24 @@ g_needOutputRender = true; break; + case 'U' - 'A' + 1: // readline ^U - delete from start to cursor + if (g_cursor > 0) + { + mutable_current_input().remove (0, g_cursor); + g_cursor = 0; + g_needInputRender = true; + } + break; + + case 'K' - 'A' + 1: // readline ^K - delete from cursor to end + if (g_cursor < current_input().length()) + { + String& input = mutable_current_input(); + input.remove (g_cursor, input.length() - g_cursor); + g_needInputRender = true; + } + break; + case '\n': case KEY_ENTER: switch (g_inputState)