diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-text/gui-entry.c | 40 | ||||
-rw-r--r-- | src/fe-text/gui-entry.h | 4 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 12 |
3 files changed, 36 insertions, 20 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); diff --git a/src/fe-text/gui-entry.h b/src/fe-text/gui-entry.h index 2a35bc4c..9b862676 100644 --- a/src/fe-text/gui-entry.h +++ b/src/fe-text/gui-entry.h @@ -29,8 +29,8 @@ void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str); void gui_entry_insert_char(GUI_ENTRY_REC *entry, char chr); void gui_entry_erase(GUI_ENTRY_REC *entry, int size); -void gui_entry_erase_word(GUI_ENTRY_REC *entry); -void gui_entry_erase_next_word(GUI_ENTRY_REC *entry); +void gui_entry_erase_word(GUI_ENTRY_REC *entry, int to_space); +void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space); int gui_entry_get_pos(GUI_ENTRY_REC *entry); void gui_entry_set_pos(GUI_ENTRY_REC *entry, int pos); diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 84fba1a9..6f9822e4 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -293,17 +293,22 @@ static void key_backspace(void) static void key_delete_previous_word(void) { - gui_entry_erase_word(active_entry); + gui_entry_erase_word(active_entry, FALSE); } static void key_delete_next_word(void) { - gui_entry_erase_next_word(active_entry); + gui_entry_erase_next_word(active_entry, FALSE); } static void key_delete_to_previous_space(void) { - gui_entry_erase_word(active_entry); + gui_entry_erase_word(active_entry, TRUE); +} + +static void key_delete_to_next_space(void) +{ + gui_entry_erase_next_word(active_entry, TRUE); } void readline(void) @@ -557,6 +562,7 @@ void gui_readline_init(void) key_bind("delete_next_word", "", NULL, NULL, (SIGNAL_FUNC) key_delete_next_word); key_bind("delete_previous_word", "", NULL, NULL, (SIGNAL_FUNC) key_delete_previous_word); key_bind("delete_to_previous_space", "", "^W", NULL, (SIGNAL_FUNC) key_delete_to_previous_space); + key_bind("delete_to_next_space", "", "", NULL, (SIGNAL_FUNC) key_delete_to_next_space); key_bind("erase_line", "", "^U", NULL, (SIGNAL_FUNC) key_erase_line); key_bind("erase_to_beg_of_line", "", NULL, NULL, (SIGNAL_FUNC) key_erase_to_beg_of_line); key_bind("erase_to_end_of_line", "", "^K", NULL, (SIGNAL_FUNC) key_erase_to_end_of_line); |