1 #include "util/cache.h"
2 #include "util/debug.h"
3 #include "ui/browser.h"
6 #include "ui/libslang.h"
7 #include "util/header.h"
8 #include "util/session.h"
10 static void ui_browser__argv_write(struct ui_browser
*browser
,
16 bool current_entry
= ui_browser__is_current_entry(browser
, row
);
17 unsigned long offset
= (unsigned long)browser
->priv
;
19 if (offset
>= strlen(str
))
24 ui_browser__set_color(browser
, current_entry
? HE_COLORSET_SELECTED
:
27 slsmg_write_nstring(str
, browser
->width
);
30 static int list_menu__run(struct ui_browser
*menu
)
35 "h/?/F1 Show this window\n"
38 "LEFT/RIGHT Navigate\n"
39 "q/ESC/CTRL+C Exit browser";
41 if (ui_browser__show(menu
, "Header information", "Press 'q' to exit") < 0)
45 key
= ui_browser__run(menu
, 0);
49 offset
= (unsigned long)menu
->priv
;
51 menu
->priv
= (void *)offset
;
54 offset
= (unsigned long)menu
->priv
;
57 menu
->priv
= (void *)offset
;
62 ui_browser__help_window(menu
, help
);
76 ui_browser__hide(menu
);
80 static int ui__list_menu(int argc
, char * const argv
[])
82 struct ui_browser menu
= {
83 .entries
= (void *)argv
,
84 .refresh
= ui_browser__argv_refresh
,
85 .seek
= ui_browser__argv_seek
,
86 .write
= ui_browser__argv_write
,
90 return list_menu__run(&menu
);
93 int tui__header_window(struct perf_session_env
*env
)
97 struct perf_session
*session
;
100 FILE *fp
= open_memstream(&ptr
, &size
);
102 session
= container_of(env
, struct perf_session
, header
.env
);
103 perf_header__fprintf_info(session
, fp
, true);
106 for (pos
= ptr
, argc
= 0; (pos
= strchr(pos
, '\n')) != NULL
; pos
++)
109 argv
= calloc(argc
+ 1, sizeof(*argv
));
114 for (i
= 1; (pos
= strchr(pos
, '\n')) != NULL
; i
++) {
119 BUG_ON(i
!= argc
+ 1);
121 ui__list_menu(argc
, argv
);