Mercurial > pidgin.yaz
changeset 21262:aee0d7fef769
transpose-chars action for the entry boxes.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 26 Oct 2007 07:27:00 +0000 |
parents | 7f1910f62246 |
children | 1812b8ccfd7a |
files | ChangeLog finch/libgnt/gntentry.c |
diffstat | 2 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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,