diff options
author | Timo Sirainen <cras@irssi.org> | 2002-02-15 16:02:14 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-02-15 16:02:14 +0000 |
commit | eb31bb17129be11aeab2e592c42d4725b81bbdf2 (patch) | |
tree | 2cc7efb3427f44b8450110896832d1cbcced76f6 | |
parent | b18424f7cb85120855156f837cc291a71af970e7 (diff) | |
download | irssi-eb31bb17129be11aeab2e592c42d4725b81bbdf2.zip |
transpose_characters was broken
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2454 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/fe-text/gui-entry.c | 22 | ||||
-rw-r--r-- | src/fe-text/gui-entry.h | 2 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 19 |
3 files changed, 25 insertions, 18 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index 2824d4af..cce8ee00 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -414,6 +414,28 @@ void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space) gui_entry_erase(entry, size); } +void gui_entry_transpose_chars(GUI_ENTRY_REC *entry) +{ + unichar chr; + + if (entry->pos == 0 || entry->text_len < 2) + return; + + if (entry->pos == entry->text_len) + entry->pos--; + + /* swap chars */ + chr = entry->text[entry->pos]; + entry->text[entry->pos] = entry->text[entry->pos-1]; + entry->text[entry->pos-1] = chr; + + entry->pos++; + + gui_entry_redraw_from(entry, entry->pos-2); + gui_entry_fix_cursor(entry); + gui_entry_draw(entry); +} + int gui_entry_get_pos(GUI_ENTRY_REC *entry) { g_return_val_if_fail(entry != NULL, 0); diff --git a/src/fe-text/gui-entry.h b/src/fe-text/gui-entry.h index 347be476..b54ed075 100644 --- a/src/fe-text/gui-entry.h +++ b/src/fe-text/gui-entry.h @@ -43,6 +43,8 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size); 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); +void gui_entry_transpose_chars(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_move_pos(GUI_ENTRY_REC *entry, int pos); diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index c5602262..3eb527fe 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -309,24 +309,7 @@ static void key_yank_from_cutbuffer(void) static void key_transpose_characters(void) { -#if 0 /* FIXME: !!! */ - char *line, c; - int pos; - - pos = gui_entry_get_pos(active_entry); - line = gui_entry_get_text(active_entry); - if (pos == 0 || strlen(line) < 2) - return; - - if (line[pos] != '\0') - gui_entry_move_pos(active_entry, 1); - c = line[gui_entry_get_pos(active_entry)-1]; - gui_entry_erase(active_entry, 1); - gui_entry_move_pos(active_entry, -1); - gui_entry_insert_char(active_entry, c); - gui_entry_set_pos(active_entry, pos); - gui_entry_move_pos(active_entry, 1); -#endif + gui_entry_transpose_chars(active_entry); } static void key_delete_character(void) |