im.pidgin.pidgin.next.minor: 771ebee2b730ca642cfc54d74967af56f5ee4589

sadrul at pidgin.im sadrul at pidgin.im
Fri Oct 26 05:00:44 EDT 2007


-----------------------------------------------------------------
Revision: 771ebee2b730ca642cfc54d74967af56f5ee4589
Ancestor: 08acda06a60a49c86dd22b679a931a22c62e3c13
Author: sadrul at pidgin.im
Date: 2007-10-26T07:27:00
Branch: im.pidgin.pidgin.next.minor

Modified files:
        ChangeLog finch/libgnt/gntentry.c

ChangeLog: 

transpose-chars action for the entry boxes.

-------------- next part --------------
============================================================
--- ChangeLog	9134b2057a1dfb42e9b6fea564694d43d7f8089b
+++ ChangeLog	65b10c2fc34dd5273a016ae78611482343dccf9a
@@ -22,6 +22,8 @@ version 2.3.0:
 	  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
============================================================
--- finch/libgnt/gntentry.c	e5767b93f57ae9817a6ce5a63873029e4be9749a
+++ finch/libgnt/gntentry.c	46a955aee57e3162256268b4b3bf5cfd6ca7a6d0
@@ -580,6 +580,33 @@ static gboolean
 }
 
 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 @@ gnt_entry_class_init(GntEntryClass *klas
 				"\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,


More information about the Commits mailing list