changeset 14215:e9304dd00992

[gaim-migrate @ 16896] Bind ^n and ^p for gnttree navigation committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Sun, 20 Aug 2006 02:24:15 +0000
parents a3f9ebb0babd
children e9dd2f76e61b
files console/libgnt/gnttree.c
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/console/libgnt/gnttree.c	Sun Aug 20 02:13:05 2006 +0000
+++ b/console/libgnt/gnttree.c	Sun Aug 20 02:24:15 2006 +0000
@@ -2,6 +2,7 @@
 #include "gntmarshal.h"
 
 #include <string.h>
+#include <ctype.h>
 
 enum
 {
@@ -468,10 +469,10 @@
 	GntTree *tree = GNT_TREE(widget);
 	GntTreeRow *old = tree->current;
 	GntTreeRow *row;
+	int dist;
 
 	if (text[0] == 27)
 	{
-		int dist;
 		if (strcmp(text+1, GNT_KEY_DOWN) == 0 && (row = get_next(tree->current)) != NULL)
 		{
 			tree->current = row;
@@ -490,9 +491,29 @@
 				redraw_tree(tree);
 		}
 	}
-	else if (text[0] == '\r')
+	else if (iscntrl(text[0]))
 	{
-		gnt_widget_activate(widget);
+		if (strcmp(text, GNT_KEY_CTRL_N) == 0 && (row = get_next(tree->current)) != NULL)
+		{
+			tree->current = row;
+			if ((dist = get_distance(tree->current, tree->bottom)) < 0)
+				gnt_tree_scroll(tree, -dist);
+			else
+				redraw_tree(tree);
+		}
+		else if (strcmp(text, GNT_KEY_CTRL_P) == 0 && (row = get_prev(tree->current)) != NULL)
+		{
+			tree->current = row;
+
+			if ((dist = get_distance(tree->current, tree->top)) > 0)
+				gnt_tree_scroll(tree, -dist);
+			else
+				redraw_tree(tree);
+		}
+		else if (text[0] == '\r')
+		{
+			gnt_widget_activate(widget);
+		}
 	}
 	else if (text[0] == ' ' && text[1] == 0)
 	{