perf ui: Introduce non-interactive ui__info_window() function

Sometimes we want just to print a message on the center of the screen,
like in 'perf top' while we wait for the minimum amount of samples to be
collected before sorting and showing them.

Also expose __ui__info_window() as an optimization for cases where such
message is to be printed while holding the ui lock.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-uat0f89vfwl2w52kv9wzwd8a@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9e79ff77
...@@ -162,8 +162,7 @@ int ui_browser__input_window(const char *title, const char *text, char *input, ...@@ -162,8 +162,7 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
return key; return key;
} }
int ui__question_window(const char *title, const char *text, void __ui__info_window(const char *title, const char *text, const char *exit_msg)
const char *exit_msg, int delay_secs)
{ {
int x, y; int x, y;
int max_len = 0, nr_lines = 0; int max_len = 0, nr_lines = 0;
...@@ -185,8 +184,6 @@ int ui__question_window(const char *title, const char *text, ...@@ -185,8 +184,6 @@ int ui__question_window(const char *title, const char *text,
t = sep + 1; t = sep + 1;
} }
pthread_mutex_lock(&ui__lock);
max_len += 2; max_len += 2;
nr_lines += 2; nr_lines += 2;
if (exit_msg) if (exit_msg)
...@@ -206,19 +203,29 @@ int ui__question_window(const char *title, const char *text, ...@@ -206,19 +203,29 @@ int ui__question_window(const char *title, const char *text,
max_len -= 2; max_len -= 2;
SLsmg_write_wrapped_string((unsigned char *)text, y, x, SLsmg_write_wrapped_string((unsigned char *)text, y, x,
nr_lines, max_len, 1); nr_lines, max_len, 1);
SLsmg_gotorc(y + nr_lines - 2, x);
SLsmg_write_nstring((char *)" ", max_len);
SLsmg_gotorc(y + nr_lines - 1, x);
if (exit_msg) { if (exit_msg) {
SLsmg_gotorc(y + nr_lines - 2, x); SLsmg_gotorc(y + nr_lines - 2, x);
SLsmg_write_nstring((char *)" ", max_len); SLsmg_write_nstring((char *)" ", max_len);
SLsmg_gotorc(y + nr_lines - 1, x); SLsmg_gotorc(y + nr_lines - 1, x);
SLsmg_write_nstring((char *)exit_msg, max_len); SLsmg_write_nstring((char *)exit_msg, max_len);
} }
SLsmg_refresh(); }
void ui__info_window(const char *title, const char *text)
{
pthread_mutex_lock(&ui__lock);
__ui__info_window(title, text, NULL);
SLsmg_refresh();
pthread_mutex_unlock(&ui__lock); pthread_mutex_unlock(&ui__lock);
}
int ui__question_window(const char *title, const char *text,
const char *exit_msg, int delay_secs)
{
pthread_mutex_lock(&ui__lock);
__ui__info_window(title, text, exit_msg);
SLsmg_refresh();
pthread_mutex_unlock(&ui__lock);
return ui__getch(delay_secs); return ui__getch(delay_secs);
} }
......
...@@ -8,6 +8,8 @@ int ui__getch(int delay_secs); ...@@ -8,6 +8,8 @@ int ui__getch(int delay_secs);
int ui__popup_menu(int argc, char * const argv[]); int ui__popup_menu(int argc, char * const argv[]);
int ui__help_window(const char *text); int ui__help_window(const char *text);
int ui__dialog_yesno(const char *msg); int ui__dialog_yesno(const char *msg);
void __ui__info_window(const char *title, const char *text, const char *exit_msg);
void ui__info_window(const char *title, const char *text);
int ui__question_window(const char *title, const char *text, int ui__question_window(const char *title, const char *text,
const char *exit_msg, int delay_secs); const char *exit_msg, int delay_secs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment