perf ui browser: Return the exit key in all browsers
Commit-ID: b50e003db13848dd74572ffd221047683313981d Gitweb: http://git.kernel.org/tip/b50e003db13848dd74572ffd221047683313981d Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 11 Aug 2010 10:07:43 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 19 Aug 2010 19:39:52 -0300
perf ui browser: Return the exit key in all browsers
Make all browsers return the exit key uniformly and remove the newtExitStruct parameter, removing one more newt specific thing from the ui API.
Cc: Frederic Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
LKML-Reference: <new-submission>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-annotate.c | 17 ++-- tools/perf/util/ui/browser.c | 16 ++-- tools/perf/util/ui/browser.h | 2 +- tools/perf/util/ui/browsers/annotate.c | 18 ++--- tools/perf/util/ui/browsers/hists.c | 132 ++++++++++++++------------------ tools/perf/util/ui/browsers/map.c | 20 +++-- tools/perf/util/util.h | 13 --- 7 files changed, 93 insertions(+), 125 deletions(-)
tools/perf/builtin-annotate.c +8 -9
@@ -321,7 +321,7 @@ static int hist_entry__tty_annotate(struct hist_entry *he)static void hists__find_annotations (struct hists *self) { -struct rb_node *first =rb_first (&self->entries), *nd = first; +struct rb_node *nd =rb_first (&self->entries), *next;int key =KEY_RIGHT ;while (nd) {
@@ -343,20 +343,19 @@ find_next:if (use_browser >0 ) { key =hist_entry__tui_annotate (he); -if (is_exit_key (key)) -break ;switch (key) {case KEY_RIGHT : -case '\t' : - nd =rb_next (nd); + next =rb_next (nd);break ;case KEY_LEFT : -if (nd == first) -continue ; - nd =rb_prev (nd); -default : + next =rb_prev (nd);break ; +default : +return ; } + +if (next !=NULL ) + nd = next; }else {hist_entry__tty_annotate (he); nd =rb_next (nd);
tools/perf/util/ui/browser.c +8 -8
@@ -204,21 +204,21 @@ int ui_browser__refresh(struct ui_browser *self)return 0 ; } -int ui_browser__run (struct ui_browser *self,struct newtExitStruct *es) +int ui_browser__run (struct ui_browser *self) { +struct newtExitStruct es; +if (ui_browser__refresh (self) <0 )return -1 ;while (1 ) {off_t offset; -newtFormRun (self->form, es); +newtFormRun (self->form, &es); -if (es->reason !=NEWT_EXIT_HOTKEY ) +if (es.reason !=NEWT_EXIT_HOTKEY )break ; -if (is_exit_key (es->u.key)) -return es->u.key; -switch (es->u.key) { +switch (es.u.key) {case NEWT_KEY_DOWN :if (self->index == self->nr_entries -1 )break ;
@@ -275,12 +275,12 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es) self->seek (self, -offset,SEEK_END );break ;default : -return es->u.key; +return es.u.key; }if (ui_browser__refresh (self) <0 )return -1 ; } -return 0 ; +return -1 ; }unsigned int ui_browser__list_head_refresh (struct ui_browser *self)
tools/perf/util/ui/browser.h +1 -1
@@ -37,7 +37,7 @@ int ui_browser__show(struct ui_browser *self, const char *title, const char *helpline, ...);void ui_browser__hide (struct ui_browser *self);int ui_browser__refresh (struct ui_browser *self); -int ui_browser__run (struct ui_browser *self,struct newtExitStruct *es); +int ui_browser__run (struct ui_browser *self);void ui_browser__rb_tree_seek (struct ui_browser *self,off_t offset,int whence);unsigned int ui_browser__rb_tree_refresh (struct ui_browser *self);
tools/perf/util/ui/browsers/annotate.c +7 -11
@@ -133,14 +133,14 @@ static void annotate_browser__set_top(struct annotate_browser *self, self->curr_hot = nd; } -static int annotate_browser__run (struct annotate_browser *self, -struct newtExitStruct *es) +static int annotate_browser__run (struct annotate_browser *self) {struct rb_node *nd;struct hist_entry *he = self->b.priv; +int key;if (ui_browser__show (&self->b, he->ms.sym->name, -"<- or ESC: exit, TAB/shift+TAB: cycle thru samples" ) <0 ) +"<-, -> or ESC: exit, TAB/shift+TAB: cycle thru samples" ) <0 )return -1 ;newtFormAddHotKey (self->b.form,NEWT_KEY_LEFT );
@@ -153,12 +153,9 @@ static int annotate_browser__run(struct annotate_browser *self, }while (1 ) { -ui_browser__run (&self->b, es); + key =ui_browser__run (&self->b); -if (es->reason !=NEWT_EXIT_HOTKEY ) -break ; - -switch (es->u.key) { +switch (key) {case NEWT_KEY_TAB : nd =rb_prev (nd);if (nd ==NULL )
@@ -177,12 +174,11 @@ static int annotate_browser__run(struct annotate_browser *self, } out:ui_browser__hide (&self->b); -return es->u.key; +return key; }int hist_entry__tui_annotate (struct hist_entry *self) { -struct newtExitStruct es;struct objdump_line *pos, *n;struct objdump_line_rb_node *rbpos;LIST_HEAD (head);
@@ -230,7 +226,7 @@ int hist_entry__tui_annotate(struct hist_entry *self)annotate_browser__set_top (&browser, browser.curr_hot); browser.b.width +=18 ;/* Percentage */ - ret =annotate_browser__run (&browser, &es); + ret =annotate_browser__run (&browser);list_for_each_entry_safe (pos, n, &head, node) {list_del (&pos->node);objdump_line__free (pos);
tools/perf/util/ui/browsers/hists.c +58 -74
192 lines not on this page · raw message
tools/perf/util/ui/browsers/map.c +11 -9
@@ -97,31 +97,34 @@ static int map_browser__search(struct map_browser *self)return 0 ; } -static int map_browser__run (struct map_browser *self,struct newtExitStruct *es) +static int map_browser__run (struct map_browser *self) { +int key; +if (ui_browser__show (&self->b, self->map->dso->long_name,"Press <- or ESC to exit, %s / to search" , verbose ?"" :"restart with -v to use" ) <0 )return -1 ;newtFormAddHotKey (self->b.form,NEWT_KEY_LEFT ); -newtFormAddHotKey (self->b.form,NEWT_KEY_ENTER ); +newtFormAddHotKey (self->b.form,NEWT_KEY_ESCAPE ); +newtFormAddHotKey (self->b.form,'Q' ); +newtFormAddHotKey (self->b.form,'q' ); +newtFormAddHotKey (self->b.form,CTRL ('c' ));if (verbose)newtFormAddHotKey (self->b.form,'/' );while (1 ) { -ui_browser__run (&self->b, es); + key =ui_browser__run (&self->b); -if (es->reason !=NEWT_EXIT_HOTKEY ) -break ; -if (verbose && es->u.key =='/' ) +if (verbose && key =='/' )map_browser__search (self);else break ; }ui_browser__hide (&self->b); -return 0 ; +return key; }int map__browse (struct map *self)
@@ -135,7 +138,6 @@ int map__browse(struct map *self) }, .map = self, }; -struct newtExitStruct es;struct rb_node *nd;char tmp[BITS_PER_LONG /4 ];u64 maxaddr =0 ;
@@ -156,5 +158,5 @@ int map__browse(struct map *self) mb.addrlen =snprintf (tmp,sizeof (tmp),"%llx" , maxaddr); mb.b.width += mb.addrlen *2 +4 + mb.namelen; -return map_browser__run (&mb, &es); +return map_browser__run (&mb); }
tools/perf/util/util.h +0 -13
@@ -266,19 +266,6 @@ bool strglobmatch(const char *str, const char *pat);bool strlazymatch (const char *str,const char *pat);unsigned long convert_unit (unsigned long value,char *unit); -#ifndef ESC -#define ESC 27 -#endif - -static inline bool is_exit_key (int key) -{ -char up; -if (key ==CTRL ('c' ) || key ==ESC ) -return true; - up =toupper (key); -return up =='Q' ; -} -#define _STR (x) #x#define STR (x) _STR(x)