changeset 14216:e9dd2f76e61b

[gaim-migrate @ 16897] A couple more keybindings. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 20 Aug 2006 07:11:09 +0000
parents e9304dd00992
children 28b1cebaa328
files console/libgnt/gntentry.c console/libgnt/gntkeys.h console/libgnt/gntmain.c console/libgnt/gnttree.c
diffstat 4 files changed, 58 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/console/libgnt/gntentry.c	Sun Aug 20 02:24:15 2006 +0000
+++ b/console/libgnt/gntentry.c	Sun Aug 20 07:11:09 2006 +0000
@@ -255,6 +255,16 @@
 			move_forward(entry);
 			return TRUE;
 		}
+		else if (strcmp(text + 1, GNT_KEY_HOME) == 0)
+		{
+			move_start(entry);
+			return TRUE;
+		}
+		else if (strcmp(text + 1, GNT_KEY_END) == 0)
+		{
+			move_end(entry);
+			return TRUE;
+		}
 		else if (strcmp(text + 1, GNT_KEY_CTRL_DOWN) == 0 && entry->histlength)
 		{
 			if (entry->history->prev)
@@ -371,7 +381,14 @@
 				entry->end += len;
 
 				while (str < next)
-					*(entry->cursor++) = *str++;
+				{
+					if (*str == '\r' || *str == '\n')
+						*entry->cursor = ' ';
+					else
+						*entry->cursor = *str;
+					entry->cursor++;
+					str++;
+				}
 
 				while (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= widget->priv.width)
 					entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
--- a/console/libgnt/gntkeys.h	Sun Aug 20 02:24:15 2006 +0000
+++ b/console/libgnt/gntkeys.h	Sun Aug 20 07:11:09 2006 +0000
@@ -16,6 +16,8 @@
 
 #define GNT_KEY_PGUP   "[5~"
 #define GNT_KEY_PGDOWN "[6~"
+#define GNT_KEY_HOME   "[7~"
+#define GNT_KEY_END    "[8~"
 
 #define GNT_KEY_ENTER  "\r"
 
--- a/console/libgnt/gntmain.c	Sun Aug 20 02:24:15 2006 +0000
+++ b/console/libgnt/gntmain.c	Sun Aug 20 07:11:09 2006 +0000
@@ -681,7 +681,9 @@
 	
 	locale = setlocale(LC_ALL, "");
 
-	g_io_channel_unref(channel);
+#if 0
+	g_io_channel_unref(channel);  /* Apparently this causes crash for some people */
+#endif
 
 	if (locale && (strstr(locale, "UTF") || strstr(locale, "utf")))
 		ascii_only = FALSE;
--- a/console/libgnt/gnttree.c	Sun Aug 20 02:24:15 2006 +0000
+++ b/console/libgnt/gnttree.c	Sun Aug 20 07:11:09 2006 +0000
@@ -490,6 +490,41 @@
 			else
 				redraw_tree(tree);
 		}
+		else if (strcmp(text+1, GNT_KEY_PGDOWN) == 0)
+		{
+			row = get_next(tree->bottom);
+			if (row)
+			{
+				int dist = get_distance(tree->top, tree->current);
+				tree->top = tree->bottom;
+				tree->current = get_next_n_opt(tree->top, dist, NULL);
+				redraw_tree(tree);
+			}
+			else if (tree->current != tree->bottom)
+			{
+				tree->current = tree->bottom;
+				redraw_tree(tree);
+			}
+		}
+		else if (strcmp(text+1, GNT_KEY_PGUP) == 0)
+		{
+			if (tree->top != tree->root)
+			{
+				int dist = get_distance(tree->top, tree->current);
+				row = get_prev_n(tree->top, widget->priv.height - 1 -
+					tree->show_title * 2 - 2 * (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER) == 0));
+				if (row == NULL)
+					row = tree->root;
+				tree->top = row;
+				tree->current = get_next_n_opt(tree->top, dist, NULL);
+				redraw_tree(tree);
+			}
+			else if (tree->current != tree->top)
+			{
+				tree->current = tree->top;
+				redraw_tree(tree);
+			}
+		}
 	}
 	else if (iscntrl(text[0]))
 	{