mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -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:
parent
4e9ff3d6d8
commit
8c7243f19c
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user