perf ui: Complete the breakdown of util/newt.c
Commit-ID: 1e6dd077a880ba5570beb690523b7a78a91a7615 Gitweb: http://git.kernel.org/tip/1e6dd077a880ba5570beb690523b7a78a91a7615 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Tue, 10 Aug 2010 15:58:50 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 10 Aug 2010 16:11:38 -0300
perf ui: Complete the breakdown of util/newt.c
LKML-Reference: <new-submission>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Makefile | 7 +--
tools/perf/util/debug.c | 2 +-
tools/perf/util/debug.h | 6 +-
tools/perf/util/ui/browsers/annotate.c | 2 +-
tools/perf/util/ui/browsers/hists.c | 8 +---
tools/perf/util/ui/helpline.c | 26 ++++++++++++
tools/perf/util/ui/helpline.h | 1 +
tools/perf/util/ui/setup.c | 42 +++++++++++++++++++
tools/perf/util/{newt.c => ui/util.c} | 70 +++----------------------------
tools/perf/util/ui/util.h | 10 +++++
10 files changed, 96 insertions(+), 78 deletions(-)tools/perf/Makefile +3 -4
@@ -567,18 +567,20 @@ else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h BASIC_CFLAGS += -I/usr/include/slang EXTLIBS += -lnewt -lslang - LIB_OBJS += $(OUTPUT)util/newt.o + LIB_OBJS += $(OUTPUT)util/ui/setup.o LIB_OBJS += $(OUTPUT)util/ui/browser.o LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o LIB_OBJS += $(OUTPUT)util/ui/helpline.o LIB_OBJS += $(OUTPUT)util/ui/progress.o + LIB_OBJS += $(OUTPUT)util/ui/util.o LIB_H += util/ui/browser.h LIB_H += util/ui/browsers/map.h LIB_H += util/ui/helpline.h LIB_H += util/ui/libslang.h LIB_H += util/ui/progress.h + LIB_H += util/ui/util.h endif endif
@@ -976,9 +978,6 @@ $(OUTPUT)builtin-init-db.o: builtin-init-db.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< -$(OUTPUT)util/newt.o: util/newt.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< - $(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
tools/perf/util/debug.c +1 -1
@@ -23,7 +23,7 @@ int eprintf(int level, const char *fmt, ...)if (verbose >= level) {va_start (args, fmt);if (use_browser >0 ) - ret =browser__show_help (fmt, args); + ret =ui_helpline__show_help (fmt, args);else ret =vfprintf (stderr, fmt, args);va_end (args);
tools/perf/util/debug.h +3 -3
@@ -14,7 +14,7 @@ void trace_event(event_t *event);struct ui_progress ;#ifdef NO_NEWT_SUPPORT -static inline int browser__show_help (const char *format__used ,va_list ap__used ) +static inline int ui_helpline__show_help (const char *format__used ,va_list ap__used ) {return 0 ; }
@@ -30,8 +30,8 @@ static inline void ui_progress__update(struct ui_progress *self __used,static inline void ui_progress__delete (struct ui_progress *self__used ) {}#else -extern char browser__last_msg[]; -int browser__show_help (const char *format,va_list ap); +extern char ui_helpline__last_msg[]; +int ui_helpline__show_help (const char *format,va_list ap);#include "ui/progress.h" #endif
tools/perf/util/ui/browsers/annotate.c +1 -1
@@ -86,7 +86,7 @@ int hist_entry__tui_annotate(struct hist_entry *self)return -1 ;if (hist_entry__annotate (self, &head) <0 ) { -ui__error_window (browser__last_msg); +ui__error_window (ui_helpline__last_msg);return -1 ; }
tools/perf/util/ui/browsers/hists.c +2 -6
@@ -17,10 +17,6 @@#include "../util.h" #include "map.h" -int ui__help_window (const char *text); -bool dialog_yesno (const char *msg); -int popup_menu (int argc,char *const argv[]); -struct hist_browser {struct ui_browser b;struct hists *hists;
@@ -798,7 +794,7 @@ do_help: }if (is_exit_key (key)) {if (key ==NEWT_KEY_ESCAPE && - !dialog_yesno ("Do you really want to exit?" )) + !ui__dialog_yesno ("Do you really want to exit?" ))continue ;break ; }
@@ -842,7 +838,7 @@ do_help: options[nr_options++] = (char *)"Exit" ; - choice =popup_menu (nr_options, options); + choice =ui__popup_menu (nr_options, options);for (i =0 ; i < nr_options -1 ; ++i)free (options[i]);
tools/perf/util/ui/helpline.c +26 -0
@@ -3,6 +3,7 @@#include <stdlib.h> #include <newt.h> +#include "../debug.h" #include "helpline.h" void ui_helpline__pop (void )
@@ -41,3 +42,28 @@ void ui_helpline__puts(const char *msg)ui_helpline__pop ();ui_helpline__push (msg); } + +void ui_helpline__init (void ) +{ +ui_helpline__puts (" " ); +} + +char ui_helpline__last_msg[1024 ]; + +int ui_helpline__show_help (const char *format,va_list ap) +{ +int ret; +static int backlog; + + ret =vsnprintf (ui_helpline__last_msg + backlog, +sizeof (ui_helpline__last_msg) - backlog, format, ap); + backlog += ret; + +if (ui_helpline__last_msg[backlog -1 ] =='\n' ) { +ui_helpline__puts (ui_helpline__last_msg); +newtRefresh (); + backlog =0 ; + } + +return ret; +}
tools/perf/util/ui/helpline.h +1 -0
@@ -1,6 +1,7 @@#ifndef _PERF_UI_HELPLINE_H_#define _PERF_UI_HELPLINE_H_ 1 +void ui_helpline__init (void );void ui_helpline__pop (void );void ui_helpline__push (const char *msg);void ui_helpline__fpush (const char *fmt, ...);
tools/perf/util/ui/setup.c new file +42 -0
42 lines not on this page · raw message
tools/perf/util/ui/util.c renamed from tools/perf/util/newt.c +7 -63
92 lines not on this page · raw message
tools/perf/util/ui/util.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _PERF_UI_UTIL_H_ +#define _PERF_UI_UTIL_H_ 1 + +#include <stdbool.h> + +int ui__popup_menu (int argc,char *const argv[]); +int ui__help_window (const char *text); +bool ui__dialog_yesno (const char *msg); + +#endif /* _PERF_UI_UTIL_H_ */