Vitezslav Samel <vitezslav(a)samel.cz> writes:
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/ifstats.c | 160 +++++++++++++++++++++++++++++++---------------------------
1 file changed, 85 insertions(+), 75 deletions(-)
diff --git a/src/ifstats.c b/src/ifstats.c
index 7c5df73..72df2d8 100644
--- a/src/ifstats.c
+++ b/src/ifstats.c
@@ -407,6 +407,87 @@ static void scrollgstatwin(struct iftab *table, int direction, int
lines)
showrates(table);
}
+static void ifstats_process_key(struct iftab *table, int ch)
+{
+ switch (ch) {
+ case KEY_UP:
+ scrollgstatwin(table, SCROLLDOWN, 1);
+ break;
+ case KEY_DOWN:
+ scrollgstatwin(table, SCROLLUP, 1);
+ break;
+ case KEY_PPAGE:
+ case '-':
+ scrollgstatwin(table, SCROLLDOWN, LINES - 5);
+ break;
+ case KEY_NPAGE:
+ case ' ':
+ scrollgstatwin(table, SCROLLUP, LINES - 5);
+ break;
+ case KEY_HOME:
+ scrollgstatwin(table, SCROLLDOWN, INT_MAX);
+ break;
+ case KEY_END:
+ scrollgstatwin(table, SCROLLUP, INT_MAX);
+ break;
+ case 12:
+ case 'l':
+ case 'L':
+ tx_refresh_screen();
+ break;
+ case 'Q':
+ case 'q':
+ case 'X':
+ case 'x':
+ case 27:
+ case 24:
+ exitloop = 1;
+ break;
+ case ERR:
+ default:
+ /* no key ready, do nothing */
+ break;
+ }
+}
I will modify this to return 1 if we exit loop, otherwise return 0 like
that.
if (ch != ERR)
exitloop = ifstats_process_key(&table, ch);
I think, it makes more sense instead of modify "somewhere" exitloop.
--
Nikola