diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-06-11 21:05:55 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-06-11 21:05:55 +0200 |
commit | 30ed61fdd2c9335d123f3cb16cc0b3d4ba826616 (patch) | |
tree | 3b9579b62af97c7d75ce1c938b29d419f6c8ee95 /sdn.cpp | |
parent | 2df916c9b3aaf6219eaa35732eb88e4899472c39 (diff) | |
download | sdn-30ed61fdd2c9335d123f3cb16cc0b3d4ba826616.tar.gz sdn-30ed61fdd2c9335d123f3cb16cc0b3d4ba826616.tar.xz sdn-30ed61fdd2c9335d123f3cb16cc0b3d4ba826616.zip |
Implement ^W in the editor
Diffstat (limited to 'sdn.cpp')
-rw-r--r-- | sdn.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -416,7 +416,8 @@ enum { ALT = 1 << 24, SYM = 1 << 25 }; // Outside the range of Unicode XX(SEARCH) XX(RENAME) XX(RENAME_PREFILL) XX(MKDIR) \ XX(TOGGLE_FULL) XX(REVERSE_SORT) XX(SHOW_HIDDEN) XX(REDRAW) XX(RELOAD) \ XX(INPUT_ABORT) XX(INPUT_CONFIRM) XX(INPUT_B_DELETE) XX(INPUT_DELETE) \ - XX(INPUT_B_KILL_LINE) XX(INPUT_KILL_LINE) XX(INPUT_QUOTED_INSERT) \ + XX(INPUT_B_KILL_WORD) XX(INPUT_B_KILL_LINE) XX(INPUT_KILL_LINE) \ + XX(INPUT_QUOTED_INSERT) \ XX(INPUT_BACKWARD) XX(INPUT_FORWARD) XX(INPUT_BEGINNING) XX(INPUT_END) #define XX(name) ACTION_ ## name, @@ -459,7 +460,8 @@ static map<wint_t, action> g_input_actions { // Sometimes terminfo is wrong, we need to accept both of these {L'\b', ACTION_INPUT_B_DELETE}, {CTRL ('?'), ACTION_INPUT_B_DELETE}, {KEY (BACKSPACE), ACTION_INPUT_B_DELETE}, {KEY (DC), ACTION_INPUT_DELETE}, - {CTRL ('D'), ACTION_INPUT_DELETE}, {CTRL ('U'), ACTION_INPUT_B_KILL_LINE}, + {CTRL ('W'), ACTION_INPUT_B_KILL_WORD}, {CTRL ('D'), ACTION_INPUT_DELETE}, + {CTRL ('U'), ACTION_INPUT_B_KILL_LINE}, {CTRL ('K'), ACTION_INPUT_KILL_LINE}, {CTRL ('V'), ACTION_INPUT_QUOTED_INSERT}, {CTRL ('B'), ACTION_INPUT_BACKWARD}, {KEY (LEFT), ACTION_INPUT_BACKWARD}, @@ -1322,6 +1324,17 @@ fun handle_editor (wint_t c) { break; } break; + case ACTION_INPUT_B_KILL_WORD: + { + int i = g.editor_cursor; + while (i && g.editor_line[--i] == L' '); + while (i-- && g.editor_line[i] != L' '); + i++; + + g.editor_line.erase (i, g.editor_cursor - i); + g.editor_cursor = i; + break; + } case ACTION_INPUT_B_KILL_LINE: g.editor_line.erase (0, g.editor_cursor); g.editor_cursor = 0; |