MenĂ¼position merken.
authorWintermute <wintermute@hannover.ccc.de>
Sun, 20 Oct 2013 19:43:58 +0000 (21:43 +0200)
committerWintermute <wintermute@hannover.ccc.de>
Sun, 20 Oct 2013 19:43:58 +0000 (21:43 +0200)
badge/ui/menu.c
badge/ui/menu.h
mock/Makefile
mock/badge_main_loop.c

index e4eaac7..0627a10 100644 (file)
@@ -65,12 +65,12 @@ static void badge_menu_show(char const *const *menu,
 }
 
 size_t badge_menu(char const *const *menu,
-                   size_t n,
-                   size_t first_visible,
-                   size_t selected)
+                   size_t  n,
+                   size_t *first_visible,
+                   size_t  selected)
 {
   for(;;) {
-    badge_menu_show(menu, n, first_visible, selected);
+    badge_menu_show(menu, n, *first_visible, selected);
 
     badge_event_t ev;
 
@@ -86,13 +86,13 @@ size_t badge_menu(char const *const *menu,
       return selected;
     } else if((new_buttons & BADGE_EVENT_KEY_UP  ) && selected != 0) {
       --selected;
-      if(first_visible != 0 && selected <= first_visible) {
-        first_visible = selected - 1;
+      if(*first_visible != 0 && selected <= *first_visible) {
+        *first_visible = selected - 1;
       }
     } else if(new_buttons & BADGE_EVENT_KEY_DOWN && selected + 1 < n) {
       ++selected;
-      if(first_visible + (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)) < selected) {
-        first_visible = selected - (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n));
+      if(*first_visible + (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)) < selected) {
+        *first_visible = selected - (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n));
       }
     }
   }
index 712618d..e2b9aec 100644 (file)
@@ -5,8 +5,8 @@
 #include <stdint.h>
 
 size_t badge_menu(char const *const * menu,
-                  size_t n,
-                  size_t first_visible,
-                  size_t preselected);
+                  size_t  n,
+                  size_t *first_visible,
+                  size_t  preselected);
 
 #endif
index de9d367..4414c13 100644 (file)
@@ -1,8 +1,8 @@
 #!/usr/bin/make -f
 
 CPPFLAGS      = $$(pkg-config --cflags gtkmm-3.0) -I. -I ../badge
-CFLAGS        = -Wall -Wextra -pedantic -std=c99   -Werror -O0 -g
-CXXFLAGS      = -Wall -Wextra -pedantic -std=c++0x -Werror -O0 -g
+CFLAGS        = -Wall -Wextra -pedantic -std=c99   -Werror -O0 -g -fstack-protector-all
+CXXFLAGS      = -Wall -Wextra -pedantic -std=c++0x -Werror -O0 -g -fstack-protector-all
 
 BADGE         = badge
 CONVERTER     = level-converter
index e893c18..86a72b1 100644 (file)
@@ -30,8 +30,11 @@ void badge_main_loop(void) {
     menu[j] = menu_buf[j];
   }
 
+  size_t choice = 0;
+  size_t first_visible = 0;
+
   for(;;) {
-    size_t choice = badge_menu(menu, ARRAY_SIZE(menu), 0, 0);
+    choice = badge_menu(menu, ARRAY_SIZE(menu), &first_visible, choice);
     char lvname[256];
     sprintf(lvname, "../badge/jumpnrun/%s.lvl", menu[choice]);
 
This page took 0.042397 seconds and 4 git commands to generate.