diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2011-06-21 00:57:08 +0200 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2011-06-21 00:57:08 +0200 |
commit | e64c48e66407a9b502934569edf6e2f9636c490b (patch) | |
tree | b9c1871b010678be7fc4674502bc7af15aec2ccb | |
parent | 75bd395071358fbbb4e4118c79e35375f811bdac (diff) | |
download | powerdebugV2-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.c | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -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; |