diff options
author | Timo Sirainen <cras@irssi.org> | 2002-02-20 12:46:45 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-02-20 12:46:45 +0000 |
commit | bcc5174e4ada5c987b190b264fd1e3ffc046fd43 (patch) | |
tree | 754267b34697ced04725c7b39c162c280ed2db35 | |
parent | ec0270811e29dab261bc70183ef3f7d66ccf612b (diff) | |
download | irssi-bcc5174e4ada5c987b190b264fd1e3ffc046fd43.zip |
Backspace/delete shouldn't modify cutbuffer.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2520 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/fe-text/gui-entry.c | 26 | ||||
-rw-r--r-- | src/fe-text/gui-entry.h | 2 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 10 |
3 files changed, 20 insertions, 18 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index 42695917..01058355 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -334,23 +334,25 @@ char *gui_entry_get_cutbuffer(GUI_ENTRY_REC *entry) return buf; } -void gui_entry_erase(GUI_ENTRY_REC *entry, int size) +void gui_entry_erase(GUI_ENTRY_REC *entry, int size, int update_cutbuffer) { g_return_if_fail(entry != NULL); if (entry->pos < size) return; - /* put erased text to cutbuffer */ - if (entry->cutbuffer == NULL || entry->cutbuffer_len < size) { - g_free(entry->cutbuffer); - entry->cutbuffer = g_new(unichar, size+1); - } + if (update_cutbuffer) { + /* put erased text to cutbuffer */ + if (entry->cutbuffer == NULL || entry->cutbuffer_len < size) { + g_free(entry->cutbuffer); + entry->cutbuffer = g_new(unichar, size+1); + } - entry->cutbuffer_len = size; - entry->cutbuffer[size] = '\0'; - memcpy(entry->cutbuffer, entry->text + entry->pos - size, - size * sizeof(unichar)); + entry->cutbuffer_len = size; + entry->cutbuffer[size] = '\0'; + memcpy(entry->cutbuffer, entry->text + entry->pos - size, + size * sizeof(unichar)); + } if (size == 0) { /* we just wanted to clear the cutbuffer */ @@ -391,7 +393,7 @@ void gui_entry_erase_word(GUI_ENTRY_REC *entry, int to_space) } if (to > 0) to++; - gui_entry_erase(entry, entry->pos-to); + gui_entry_erase(entry, entry->pos-to, TRUE); } void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space) @@ -417,7 +419,7 @@ void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space) size = to-entry->pos; entry->pos = to; - gui_entry_erase(entry, size); + gui_entry_erase(entry, size, TRUE); } void gui_entry_transpose_chars(GUI_ENTRY_REC *entry) diff --git a/src/fe-text/gui-entry.h b/src/fe-text/gui-entry.h index b54ed075..2ad38041 100644 --- a/src/fe-text/gui-entry.h +++ b/src/fe-text/gui-entry.h @@ -39,7 +39,7 @@ void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str); void gui_entry_insert_char(GUI_ENTRY_REC *entry, unichar chr); char *gui_entry_get_cutbuffer(GUI_ENTRY_REC *entry); -void gui_entry_erase(GUI_ENTRY_REC *entry, int size); +void gui_entry_erase(GUI_ENTRY_REC *entry, int size, int update_cutbuffer); 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); diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 956f7a52..32ae7abe 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -280,7 +280,7 @@ static void key_forward_to_space(void) static void key_erase_line(void) { gui_entry_set_pos(active_entry, active_entry->text_len); - gui_entry_erase(active_entry, active_entry->text_len); + gui_entry_erase(active_entry, active_entry->text_len, TRUE); } static void key_erase_to_beg_of_line(void) @@ -288,7 +288,7 @@ static void key_erase_to_beg_of_line(void) int pos; pos = gui_entry_get_pos(active_entry); - gui_entry_erase(active_entry, pos); + gui_entry_erase(active_entry, pos, TRUE); } static void key_erase_to_end_of_line(void) @@ -297,7 +297,7 @@ static void key_erase_to_end_of_line(void) pos = gui_entry_get_pos(active_entry); gui_entry_set_pos(active_entry, active_entry->text_len); - gui_entry_erase(active_entry, active_entry->text_len - pos); + gui_entry_erase(active_entry, active_entry->text_len - pos, TRUE); } static void key_yank_from_cutbuffer(void) @@ -318,13 +318,13 @@ static void key_delete_character(void) { if (gui_entry_get_pos(active_entry) < active_entry->text_len) { gui_entry_move_pos(active_entry, 1); - gui_entry_erase(active_entry, 1); + gui_entry_erase(active_entry, 1, FALSE); } } static void key_backspace(void) { - gui_entry_erase(active_entry, 1); + gui_entry_erase(active_entry, 1, FALSE); } static void key_delete_previous_word(void) |