diff options
-rw-r--r-- | src/fe-text/gui-entry.c | 24 | ||||
-rw-r--r-- | src/fe-text/gui-entry.h | 2 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 5 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index 62ea83fb..7bc8868d 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -149,6 +149,30 @@ void gui_entry_erase(int size) entry_update(); } +void gui_entry_erase_word(void) +{ + int to; + + if (pos == 0) return; + + to = pos - 1; + + while (entry->str[to] == ' ' && to > 0) + to--; + + while (entry->str[to] != ' ' && to > 0) + to--; + + if (entry->str[to] == ' ' && to > 0) + to++; + + g_string_erase(entry, to, pos - to); + pos = to; + + entry_screenpos(); + entry_update(); +} + int gui_entry_get_pos(void) { return pos; diff --git a/src/fe-text/gui-entry.h b/src/fe-text/gui-entry.h index 4fbf5c16..cb1251ad 100644 --- a/src/fe-text/gui-entry.h +++ b/src/fe-text/gui-entry.h @@ -12,7 +12,9 @@ char *gui_entry_get_text(void); void gui_entry_insert_text(const char *str); void gui_entry_insert_char(char chr); + void gui_entry_erase(int size); +void gui_entry_erase_word(void); int gui_entry_get_pos(void); void gui_entry_set_pos(int pos); diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 8aa7b0a7..b68ec01e 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -208,6 +208,11 @@ void handle_key(int key) gui_entry_erase(1); break; + case 23: + /* C-w - erase word to the left of marker */ + gui_entry_erase_word(); + break; + case 4: case KEY_DC: if (gui_entry_get_pos() < strlen(gui_entry_get_text())) { |