aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2011-06-21 00:57:08 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2011-06-21 00:57:08 +0200
commite64c48e66407a9b502934569edf6e2f9636c490b (patch)
treeb9c1871b010678be7fc4674502bc7af15aec2ccb
parent75bd395071358fbbb4e4118c79e35375f811bdac (diff)
downloadpowerdebugV2-e64c48e66407a9b502934569edf6e2f9636c490b.tar.gz
Add the find callback
Switch the keyboard callback when we switch to the find mode. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--display.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/display.c b/display.c
index d32783f..758d17e 100644
--- a/display.c
+++ b/display.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <stdlib.h>
#include <ncurses.h>
+#include <form.h>
#include "powerdebug.h"
#include "mainloop.h"
#include "regulator.h"
@@ -266,6 +267,19 @@ int display_print_line(int win, int line, char *str, int bold, void *data)
return 0;
}
+static int display_find_keystroke(int fd, void *data);
+
+static int display_switch_to_find(int fd)
+{
+ if (mainloop_del(fd))
+ return -1;
+
+ if (mainloop_add(fd, display_find_keystroke, NULL))
+ return -1;
+
+ return 0;
+}
+
static int display_keystroke(int fd, void *data)
{
int keystroke = getch();
@@ -299,6 +313,9 @@ static int display_keystroke(int fd, void *data)
case 'Q':
return 1;
+ case '/':
+ return display_switch_to_find(fd);
+
case 'r':
case 'R':
/* refresh will be done after */
@@ -312,6 +329,35 @@ static int display_keystroke(int fd, void *data)
return 0;
}
+static int display_switch_to_main(int fd)
+{
+ if (mainloop_del(fd))
+ return -1;
+
+ if (mainloop_add(fd, display_keystroke, NULL))
+ return -1;
+
+ display_refresh(current_win);
+
+ return 0;
+}
+
+
+static int display_find_keystroke(int fd, void *data)
+{
+ int keystroke = getch();
+
+ switch (keystroke) {
+
+ case '\e':
+ return display_switch_to_main(fd);
+ default:
+ break;
+ }
+
+ return 0;
+}
+
int display_init(int wdefault)
{
int i, maxx, maxy;