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 <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-3ih7hyk9weryxaxb501sfq4u@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2011-10-26 12:04:37 -02:00
parent 0458122db0
commit 4610e4137b
9 changed files with 94 additions and 26 deletions

View file

@ -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;
}