# HG changeset patch # User Sadrul Habib Chowdhury # Date 1193383620 0 # Node ID aee0d7fef769c2859348112c538ddc3746cd6d07 # Parent 7f1910f62246d8af3e5c1547dff79e3f667e6505 transpose-chars action for the entry boxes. diff -r 7f1910f62246 -r aee0d7fef769 ChangeLog --- a/ChangeLog Wed Oct 24 10:14:58 2007 +0000 +++ b/ChangeLog Fri Oct 26 07:27:00 2007 +0000 @@ -22,6 +22,8 @@ could lead to crashes. * It's possible to bind key-strokes to specific menuitems in the windows. Read the 'Menus' section in the man-page for details. + * 'transpose-chars' operation for the entry boxes. The default key-binding + is ctrl+t. version 2.2.2: http://developer.pidgin.im/query?status=closed&milestone=2.2.2 diff -r 7f1910f62246 -r aee0d7fef769 finch/libgnt/gntentry.c --- a/finch/libgnt/gntentry.c Wed Oct 24 10:14:58 2007 +0000 +++ b/finch/libgnt/gntentry.c Fri Oct 26 07:27:00 2007 +0000 @@ -580,6 +580,33 @@ } static gboolean +transpose_chars(GntBindable *bind, GList *null) +{ + GntEntry *entry = GNT_ENTRY(bind); + char *current, *prev; + char hold[8]; /* that's right */ + + if (entry->cursor <= entry->start) + return FALSE; + + if (!*entry->cursor) + entry->cursor = g_utf8_find_prev_char(entry->start, entry->cursor); + + current = entry->cursor; + prev = g_utf8_find_prev_char(entry->start, entry->cursor); + move_forward(bind, null); + + /* Let's do this dance! */ + memcpy(hold, prev, current - prev); + memmove(prev, current, entry->cursor - current); + memcpy(prev + (entry->cursor - current), hold, current - prev); + + entry_redraw(GNT_WIDGET(entry)); + entry_text_changed(entry); + return TRUE; +} + +static gboolean gnt_entry_key_pressed(GntWidget *widget, const char *text) { GntEntry *entry = GNT_ENTRY(widget); @@ -762,6 +789,8 @@ "\033" "f", NULL); gnt_bindable_class_register_action(bindable, "delete-next-word", delete_forward_word, "\033" "d", NULL); + gnt_bindable_class_register_action(bindable, "transpose-chars", transpose_chars, + GNT_KEY_CTRL_T, NULL); gnt_bindable_class_register_action(bindable, "suggest-show", suggest_show, "\t", NULL); gnt_bindable_class_register_action(bindable, "suggest-next", suggest_next,