[svn-commits] seanbright: trunk r926 - /trunk/menuselect_newt.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 28 06:26:20 CDT 2011


Author: seanbright
Date: Thu Jul 28 06:26:17 2011
New Revision: 926

URL: http://svnview.digium.com/svn/menuselect?view=rev&rev=926
Log:
After toggling the currently selected item, move down to the next item in the list.

Modified:
    trunk/menuselect_newt.c

Modified: trunk/menuselect_newt.c
URL: http://svnview.digium.com/svn/menuselect/trunk/menuselect_newt.c?view=diff&rev=926&r1=925&r2=926
==============================================================================
--- trunk/menuselect_newt.c (original)
+++ trunk/menuselect_newt.c Thu Jul 28 06:26:17 2011
@@ -34,6 +34,9 @@
 #define MIN_X 80
 #define MIN_Y 21
 
+#define MIN(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); ((__a > __b) ? __b : __a);})
+#define MAX(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); ((__a < __b) ? __b : __a);})
+
 extern int changes_made;
 
 static newtComponent rootOptions;
@@ -69,12 +72,27 @@
 
 static void toggle_selected_option()
 {
+	int i;
 	struct member *mem = newtListboxGetCurrent(subOptions);
 
 	toggle_enabled(mem);
 
 	/* Redraw */
 	build_members_menu(1);
+
+	/* Select the next item in the list */
+	for (i = 0; i < newtListboxItemCount(subOptions); i++) {
+		struct member *cur;
+
+		newtListboxGetEntry(subOptions, i, NULL, &cur);
+
+		if (cur == mem) {
+			i = MIN(i + 1, newtListboxItemCount(subOptions) - 1);
+			break;
+		}
+	}
+
+	newtListboxSetCurrent(subOptions, i);
 
 	return;
 }




More information about the svn-commits mailing list