summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-06-14 18:02:13 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-06-14 18:02:13 +0000
commit72b32ff1755c9223294d6069fa00eaa039563e64 (patch)
tree12084ba7040d976adda46380730b2ab397a357ee /src
parent22b12d85ee7112e404d4b6af1ac52878baef50e7 (diff)
downloadirssi-72b32ff1755c9223294d6069fa00eaa039563e64.zip
Ctrl-W deletes word in left - patch from
Kjetil �degaard <kjetilod@orakel.ntnu.no> git-svn-id: http://svn.irssi.org/repos/irssi/trunk@341 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-text/gui-entry.c24
-rw-r--r--src/fe-text/gui-entry.h2
-rw-r--r--src/fe-text/gui-readline.c5
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())) {