From 72b32ff1755c9223294d6069fa00eaa039563e64 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 14 Jun 2000 18:02:13 +0000 Subject: =?UTF-8?q?Ctrl-W=20deletes=20word=20in=20left=20-=20patch=20from?= =?UTF-8?q?=20Kjetil=20=EF=BF=BDdegaard=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.irssi.org/repos/irssi/trunk@341 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-text/gui-entry.c | 24 ++++++++++++++++++++++++ src/fe-text/gui-entry.h | 2 ++ src/fe-text/gui-readline.c | 5 +++++ 3 files changed, 31 insertions(+) (limited to 'src/fe-text') 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())) { -- cgit v1.2.3