diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2011-06-15 15:45:12 +0200 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2011-06-15 15:45:12 +0200 |
commit | 271fd90a182707f89a508c334df8c2df9b0fa113 (patch) | |
tree | aaecbcc838e8eb80c5f2828bc1d9d727cb4037e1 | |
parent | 40ba329c7b5a5e5ed5720fc5cc45e55d3992c463 (diff) | |
download | powerdebugV2-271fd90a182707f89a508c334df8c2df9b0fa113.tar.gz |
Encapsulate the display (9)
Remove unused parameter for the keystroke callback.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r-- | powerdebug.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/powerdebug.c b/powerdebug.c index 28b23b4..fccc08b 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -153,7 +153,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) return 0; } -int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) +int keystroke_callback(struct powerdebug_options *options) { char keychar; int keystroke = getch(); @@ -162,10 +162,10 @@ int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) exit(0); if (keystroke == KEY_RIGHT || keystroke == '\t') - options->selectedwindow = display_next_panel(); + display_next_panel(); if (keystroke == KEY_LEFT || keystroke == KEY_BTAB) - options->selectedwindow = display_prev_panel(); + display_prev_panel(); if (keystroke == KEY_DOWN) display_next_line(); @@ -176,13 +176,13 @@ int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) keychar = toupper(keystroke); if (keystroke == '\r') - *enter_hit = true; + display_select(); if (keychar == 'Q') return 1; if (keychar == 'R') { - /* TODO refresh window */ + display_refresh(); options->ticktime = 3; } @@ -191,23 +191,11 @@ int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) int mainloop(struct powerdebug_options *options) { - bool enter_hit = false; - while (1) { int key = 0; struct timeval tval; fd_set readfds; - - if (options->selectedwindow == CLOCK) { - if (enter_hit) - display_select(); - enter_hit = false; - } - - display_refresh(); - - FD_ZERO(&readfds); FD_SET(0, &readfds); tval.tv_sec = options->ticktime; @@ -224,9 +212,10 @@ int mainloop(struct powerdebug_options *options) break; } - if (keystroke_callback(&enter_hit, options)) + if (keystroke_callback(options)) break; + display_refresh(); } return 0; @@ -253,6 +242,9 @@ static int powerdebug_display(struct powerdebug_options *options) return -1; } + if (display_refresh()) + return -1; + if (mainloop(options)) return -1; |