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 | 73b400238f53a18c4d35b7ba9a7de7dd26755035 (patch) | |
tree | 58a078f05554a33a9fd8e5e1c5aa61bc228c7a17 | |
parent | a12163dafb3c38d08b85b4389de68369d69edf93 (diff) |
add a select callback on a clock from the search result
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r-- | clocks.c | 28 | ||||
-rw-r--r-- | display.c | 11 | ||||
-rw-r--r-- | display.h | 1 |
3 files changed, 30 insertions, 10 deletions
@@ -243,6 +243,10 @@ static int _clock_print_info_cb(struct tree *t, void *data) int *line = data; char *buffer; + /* we skip the root node of the tree */ + if (!t->parent) + return 0; + buffer = clock_line(t); if (!buffer) return -1; @@ -258,10 +262,6 @@ static int _clock_print_info_cb(struct tree *t, void *data) static int clock_print_info_cb(struct tree *t, void *data) { - /* we skip the root node of the tree */ - if (!t->parent) - return 0; - /* show the clock when *all* its parent is expanded */ if (tree_for_each_parent(t->parent, is_collapsed, NULL)) return 0; @@ -300,7 +300,7 @@ static int clock_print_info(struct tree *tree) return ret; } -static int clock_toggle_expanded(void) +static int clock_select(void) { struct tree *t = display_get_row_data(CLOCK); struct clock_info *clk = t->private; @@ -323,7 +323,7 @@ static int clock_display(void) return clock_print_info(clock_tree); } -int clock_find(const char *name) +static int clock_find(const char *name) { struct tree **ptree = NULL; int i, nr, line = 0, ret = 0; @@ -350,6 +350,19 @@ int clock_find(const char *name) return ret; } +static int clock_selectf(void) +{ + struct tree *t = display_get_row_data(CLOCK); + int line = 0; + + display_reset_cursor(CLOCK); + + if (tree_for_each_parent(t, _clock_print_info_cb, &line)) + return -1; + + return display_refresh_pad(CLOCK); +} + /* * Read the clock information and fill the tree with the information * found in the files. Then dump to stdout a formatted result. @@ -379,8 +392,9 @@ int clock_dump(char *clk) static struct display_ops clock_ops = { .display = clock_display, - .select = clock_toggle_expanded, + .select = clock_select, .find = clock_find, + .selectf = clock_selectf, }; /* @@ -447,9 +447,14 @@ static int display_find_keystroke(int fd, void *data) string[strlen(string) - 1] = '\0'; break; - case KEY_ENTER: - /* next patch */ - break; + case '\r': + if (!windata[current_win].ops || !windata[current_win].ops->selectf) + return 0; + + if (windata[current_win].ops->selectf()) + return -1; + + return 0; default: @@ -19,6 +19,7 @@ struct display_ops { int (*display)(void); int (*select)(void); int (*find)(const char *); + int (*selectf)(void); }; extern int display_print_line(int window, int line, char *str, |