From 4610e4137b5fb93042a248928a2c0049ef7d4190 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 26 Oct 2011 12:04:37 -0200 Subject: perf ui browser: Handle K_RESIZE in dialog windows Just provide wrappers for things like ui__warning, ui__dialog_yesno and if they return K_RESIZE, refresh dimensions, redraw the entries, etc. Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-3ih7hyk9weryxaxb501sfq4u@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/ui/util.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'tools/perf/util/ui/util.c') diff --git a/tools/perf/util/ui/util.c b/tools/perf/util/ui/util.c index ef9b79332fe8..45daa7c41dad 100644 --- a/tools/perf/util/ui/util.c +++ b/tools/perf/util/ui/util.c @@ -121,43 +121,48 @@ int ui__help_window(const char *text) return ui__question_window("Help", text, "Press any key...", 0); } -bool ui__dialog_yesno(const char *msg) +int ui__dialog_yesno(const char *msg) { - int answer = ui__question_window(NULL, msg, "Enter: Yes, ESC: No", 0); - - return answer == K_ENTER; + return ui__question_window(NULL, msg, "Enter: Yes, ESC: No", 0); } -static void __ui__warning(const char *title, const char *format, va_list args) +int __ui__warning(const char *title, const char *format, va_list args) { char *s; if (use_browser > 0 && vasprintf(&s, format, args) > 0) { + int key; + pthread_mutex_lock(&ui__lock); - ui__question_window(title, s, "Press any key...", 0); + key = ui__question_window(title, s, "Press any key...", 0); pthread_mutex_unlock(&ui__lock); free(s); - return; + return key; } fprintf(stderr, "%s:\n", title); vfprintf(stderr, format, args); + return K_ESC; } -void ui__warning(const char *format, ...) +int ui__warning(const char *format, ...) { + int key; va_list args; va_start(args, format); - __ui__warning("Warning", format, args); + key = __ui__warning("Warning", format, args); va_end(args); + return key; } -void ui__error(const char *format, ...) +int ui__error(const char *format, ...) { + int key; va_list args; va_start(args, format); - __ui__warning("Error", format, args); + key = __ui__warning("Error", format, args); va_end(args); + return key; } -- cgit v1.2.3-59-g8ed1b