1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

transpose_characters was broken

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2454 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-02-15 16:02:14 +00:00 committed by cras
parent b18424f7cb
commit eb31bb1712
3 changed files with 25 additions and 18 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)