Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+17 -8
+15 -8
tools/perf/ui/tui/util.c
··· 162 162 return key; 163 163 } 164 164 165 - int ui__question_window(const char *title, const char *text, 166 - const char *exit_msg, int delay_secs) 165 + void __ui__info_window(const char *title, const char *text, const char *exit_msg) 167 166 { 168 167 int x, y; 169 168 int max_len = 0, nr_lines = 0; ··· 184 185 t = sep + 1; 185 186 } 186 187 187 - pthread_mutex_lock(&ui__lock); 188 - 189 188 max_len += 2; 190 189 nr_lines += 2; 191 190 if (exit_msg) ··· 203 206 max_len -= 2; 204 207 SLsmg_write_wrapped_string((unsigned char *)text, y, x, 205 208 nr_lines, max_len, 1); 206 - SLsmg_gotorc(y + nr_lines - 2, x); 207 - SLsmg_write_nstring((char *)" ", max_len); 208 - SLsmg_gotorc(y + nr_lines - 1, x); 209 209 if (exit_msg) { 210 210 SLsmg_gotorc(y + nr_lines - 2, x); 211 211 SLsmg_write_nstring((char *)" ", max_len); 212 212 SLsmg_gotorc(y + nr_lines - 1, x); 213 213 SLsmg_write_nstring((char *)exit_msg, max_len); 214 214 } 215 + } 216 + 217 + void ui__info_window(const char *title, const char *text) 218 + { 219 + pthread_mutex_lock(&ui__lock); 220 + __ui__info_window(title, text, NULL); 215 221 SLsmg_refresh(); 216 - 217 222 pthread_mutex_unlock(&ui__lock); 223 + } 218 224 225 + int ui__question_window(const char *title, const char *text, 226 + const char *exit_msg, int delay_secs) 227 + { 228 + pthread_mutex_lock(&ui__lock); 229 + __ui__info_window(title, text, exit_msg); 230 + SLsmg_refresh(); 231 + pthread_mutex_unlock(&ui__lock); 219 232 return ui__getch(delay_secs); 220 233 } 221 234
+2
tools/perf/ui/util.h
··· 8 8 int ui__popup_menu(int argc, char * const argv[]); 9 9 int ui__help_window(const char *text); 10 10 int ui__dialog_yesno(const char *msg); 11 + void __ui__info_window(const char *title, const char *text, const char *exit_msg); 12 + void ui__info_window(const char *title, const char *text); 11 13 int ui__question_window(const char *title, const char *text, 12 14 const char *exit_msg, int delay_secs); 13 15