aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Arora <amit.arora@linaro.org>2010-11-16 11:27:38 +0530
committerAmit Arora <amit.arora@linaro.org>2010-11-16 11:27:38 +0530
commit3bc8c920b5fb4438ffff9d08b63979c82b84fbe9 (patch)
tree4b91716e7584f6aa5d5fcb7fbc25462d0899793b
parentac4e865c0c3b260002d1bd9e0b1a1ba7aa8d7382 (diff)
Scroll when user selects clock beyond maxy
-rw-r--r--clocks.c25
-rw-r--r--clocks.h2
2 files changed, 22 insertions, 5 deletions
diff --git a/clocks.c b/clocks.c
index 25dcddb..80ff835 100644
--- a/clocks.c
+++ b/clocks.c
@@ -35,7 +35,7 @@ void init_clock_details(void)
exit(1);
}
sprintf(clk_dir_path, "%s/clock", clk_dir_path);
- //strcpy(clk_dir_path, "/debug/clock"); // Hardcoded for testing..
+ strcpy(clk_dir_path, "/debug/clock"); // Hardcoded for testing..
if (stat(clk_dir_path, &buf)) {
fprintf(stderr, "powerdebug: Unable to find clock tree"
" information at %s. Exiting..\n", clk_dir_path);
@@ -78,9 +78,17 @@ int read_and_print_clock_info(int verbose, int hrow, int selected)
return hrow;
}
+int calc_delta_screen_size(int hrow)
+{
+ if (hrow > (maxy - 3))
+ return hrow - (maxy - 3);
+
+ return 0;
+}
+
void print_clock_info(int verbose, int hrow, int selected)
{
- int i, count = 0;
+ int i, count = 0, delta;
(void)verbose;
@@ -90,9 +98,16 @@ void print_clock_info(int verbose, int hrow, int selected)
add_clock_details_recur(clocks_info->children[i],
hrow, selected);
- while (clock_lines[count] && strcmp(clock_lines[count], "")) {
- print_one_clock(count, clock_lines[count], bold[count],
- (hrow == count));
+ delta = calc_delta_screen_size(hrow);
+
+ while (clock_lines[count + delta] &&
+ strcmp(clock_lines[count + delta], "")) {
+ if (count < delta) {
+ count++;
+ continue;
+ }
+ print_one_clock(count - delta, clock_lines[count + delta],
+ bold[count + delta], (hrow == (count + delta)));
count++;
}
diff --git a/clocks.h b/clocks.h
index 9a945b7..e916e15 100644
--- a/clocks.h
+++ b/clocks.h
@@ -20,6 +20,8 @@
#include <sys/stat.h>
#include <linux/magic.h>
+extern int maxy;
+
#define MAX_LINES 80
struct clock_info {