aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2011-05-24 15:27:49 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2011-05-24 15:27:49 +0200
commit2ef06e969eb9674b55d1b9704587505ed0e8198e (patch)
tree61b3e0a834821b7a2475f3d07abeb2cd6e1b0583
parent3b42b5e49b687837d4ffeabdd6fae207202afb1c (diff)
downloadpowerdebug-2ef06e969eb9674b55d1b9704587505ed0e8198e.tar.gz
compute next and previous window with modulo arithmetic
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--powerdebug.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/powerdebug.c b/powerdebug.c
index dd4fe91..5fe07de 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -15,6 +15,7 @@
#include <getopt.h>
#include <stdbool.h>
+#include <math.h>
#include "regulator.h"
#include "display.h"
#include "clocks.h"
@@ -164,17 +165,16 @@ int keystroke_callback(bool *enter_hit, bool *findparent_ncurses,
if (keystroke == EOF)
exit(0);
- if (keystroke == KEY_RIGHT || keystroke == '\t')
+ if (keystroke == KEY_RIGHT || keystroke == '\t') {
options->selectedwindow++;
+ options->selectedwindow %= TOTAL_FEATURE_WINS;
+ }
- if (keystroke == KEY_LEFT || keystroke == KEY_BTAB)
+ if (keystroke == KEY_LEFT || keystroke == KEY_BTAB) {
options->selectedwindow--;
-
- if (options->selectedwindow >= TOTAL_FEATURE_WINS)
- options->selectedwindow = 0;
-
- if (options->selectedwindow < 0)
- options->selectedwindow = TOTAL_FEATURE_WINS - 1;
+ if (options->selectedwindow < 0)
+ options->selectedwindow = TOTAL_FEATURE_WINS - 1;
+ }
if (options->selectedwindow == CLOCK) {
if (keystroke == KEY_DOWN)