summaryrefslogtreecommitdiff
path: root/src/fe-text/gui-entry.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-10-14 11:32:06 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-10-14 11:32:06 +0000
commit8c7243f19cbce92c5d3ee5c706a0fceb0c2bf749 (patch)
treebadc16957bcf9b59d9c879b604c4f6ee709e3250 /src/fe-text/gui-entry.c
parent4e9ff3d6d82e9affdba88c14b59c956d7a8d1eef (diff)
downloadirssi-8c7243f19cbce92c5d3ee5c706a0fceb0c2bf749.zip
delete_previous_word and delete_next_word now deletes only until
non-alphanumeric character is found. added delete_to_next_space command. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1833 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/gui-entry.c')
-rw-r--r--src/fe-text/gui-entry.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c
index 3af35eba..0154902d 100644
--- a/src/fe-text/gui-entry.c
+++ b/src/fe-text/gui-entry.c
@@ -252,7 +252,7 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size)
gui_entry_draw(entry);
}
-void gui_entry_erase_word(GUI_ENTRY_REC *entry)
+void gui_entry_erase_word(GUI_ENTRY_REC *entry, int to_space)
{
int to;
@@ -262,14 +262,18 @@ void gui_entry_erase_word(GUI_ENTRY_REC *entry)
to = entry->pos - 1;
- while (entry->text->str[to] == ' ' && to > 0)
- to--;
-
- while (entry->text->str[to] != ' ' && to > 0)
- to--;
-
- if (entry->text->str[to] == ' ' && to > 0)
- to++;
+ if (to_space) {
+ while (entry->text->str[to] == ' ' && to > 0)
+ to--;
+ while (entry->text->str[to] != ' ' && to > 0)
+ to--;
+ } else {
+ while (!isalnum(entry->text->str[to]) && to > 0)
+ to--;
+ while (isalnum(entry->text->str[to]) && to > 0)
+ to--;
+ }
+ if (to > 0) to++;
g_string_erase(entry->text, to, entry->pos - to);
entry->pos = to;
@@ -278,7 +282,7 @@ void gui_entry_erase_word(GUI_ENTRY_REC *entry)
gui_entry_draw(entry);
}
-void gui_entry_erase_next_word(GUI_ENTRY_REC *entry)
+void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space)
{
int to;
@@ -287,11 +291,17 @@ void gui_entry_erase_next_word(GUI_ENTRY_REC *entry)
return;
to = entry->pos;
- while (entry->text->str[to] == ' ' && to < entry->text->len)
- to++;
-
- while (entry->text->str[to] != ' ' && to < entry->text->len)
- to++;
+ if (to_space) {
+ while (entry->text->str[to] == ' ' && to < entry->text->len)
+ to++;
+ while (entry->text->str[to] != ' ' && to < entry->text->len)
+ to++;
+ } else {
+ while (!isalnum(entry->text->str[to]) && to < entry->text->len)
+ to++;
+ while (isalnum(entry->text->str[to]) && to < entry->text->len)
+ to++;
+ }
g_string_erase(entry->text, entry->pos, to - entry->pos);