1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

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
This commit is contained in:
Timo Sirainen 2001-10-14 11:32:06 +00:00 committed by cras
parent 4e9ff3d6d8
commit 8c7243f19c
3 changed files with 36 additions and 20 deletions

View File

@ -252,7 +252,7 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size)
gui_entry_draw(entry); 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; int to;
@ -262,14 +262,18 @@ void gui_entry_erase_word(GUI_ENTRY_REC *entry)
to = entry->pos - 1; to = entry->pos - 1;
while (entry->text->str[to] == ' ' && to > 0) if (to_space) {
to--; while (entry->text->str[to] == ' ' && to > 0)
to--;
while (entry->text->str[to] != ' ' && to > 0) while (entry->text->str[to] != ' ' && to > 0)
to--; to--;
} else {
if (entry->text->str[to] == ' ' && to > 0) while (!isalnum(entry->text->str[to]) && to > 0)
to++; to--;
while (isalnum(entry->text->str[to]) && to > 0)
to--;
}
if (to > 0) to++;
g_string_erase(entry->text, to, entry->pos - to); g_string_erase(entry->text, to, entry->pos - to);
entry->pos = to; entry->pos = to;
@ -278,7 +282,7 @@ void gui_entry_erase_word(GUI_ENTRY_REC *entry)
gui_entry_draw(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; int to;
@ -287,11 +291,17 @@ void gui_entry_erase_next_word(GUI_ENTRY_REC *entry)
return; return;
to = entry->pos; to = entry->pos;
while (entry->text->str[to] == ' ' && to < entry->text->len) if (to_space) {
to++; while (entry->text->str[to] == ' ' && to < entry->text->len)
to++;
while (entry->text->str[to] != ' ' && to < entry->text->len) while (entry->text->str[to] != ' ' && to < entry->text->len)
to++; 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); g_string_erase(entry->text, entry->pos, to - entry->pos);

View File

@ -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_insert_char(GUI_ENTRY_REC *entry, char chr);
void gui_entry_erase(GUI_ENTRY_REC *entry, int size); void gui_entry_erase(GUI_ENTRY_REC *entry, int size);
void gui_entry_erase_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); void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space);
int gui_entry_get_pos(GUI_ENTRY_REC *entry); int gui_entry_get_pos(GUI_ENTRY_REC *entry);
void gui_entry_set_pos(GUI_ENTRY_REC *entry, int pos); void gui_entry_set_pos(GUI_ENTRY_REC *entry, int pos);

View File

@ -293,17 +293,22 @@ static void key_backspace(void)
static void key_delete_previous_word(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) 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) 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) 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_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_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_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_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_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); key_bind("erase_to_end_of_line", "", "^K", NULL, (SIGNAL_FUNC) key_erase_to_end_of_line);