1 #include "util/cache.h"
2 #include "util/debug.h"
3 #include "ui/browser.h"
4 #include "ui/keysyms.h"
7 #include "ui/libslang.h"
8 #include "util/header.h"
9 #include "util/session.h"
11 static void ui_browser__argv_write(struct ui_browser
*browser
,
17 bool current_entry
= ui_browser__is_current_entry(browser
, row
);
18 unsigned long offset
= (unsigned long)browser
->priv
;
20 if (offset
>= strlen(str
))
25 ui_browser__set_color(browser
, current_entry
? HE_COLORSET_SELECTED
:
28 slsmg_write_nstring(str
, browser
->width
);
31 static int list_menu__run(struct ui_browser
*menu
)
36 "h/?/F1 Show this window\n"
39 "LEFT/RIGHT Navigate\n"
40 "q/ESC/CTRL+C Exit browser";
42 if (ui_browser__show(menu
, "Header information", "Press 'q' to exit") < 0)
46 key
= ui_browser__run(menu
, 0);
50 offset
= (unsigned long)menu
->priv
;
52 menu
->priv
= (void *)offset
;
55 offset
= (unsigned long)menu
->priv
;
58 menu
->priv
= (void *)offset
;
63 ui_browser__help_window(menu
, help
);
77 ui_browser__hide(menu
);
81 static int ui__list_menu(int argc
, char * const argv
[])
83 struct ui_browser menu
= {
84 .entries
= (void *)argv
,
85 .refresh
= ui_browser__argv_refresh
,
86 .seek
= ui_browser__argv_seek
,
87 .write
= ui_browser__argv_write
,
91 return list_menu__run(&menu
);
94 int tui__header_window(struct perf_session_env
*env
)
98 struct perf_session
*session
;
101 FILE *fp
= open_memstream(&ptr
, &size
);
103 session
= container_of(env
, struct perf_session
, header
.env
);
104 perf_header__fprintf_info(session
, fp
, true);
107 for (pos
= ptr
, argc
= 0; (pos
= strchr(pos
, '\n')) != NULL
; pos
++)
110 argv
= calloc(argc
+ 1, sizeof(*argv
));
115 for (i
= 1; (pos
= strchr(pos
, '\n')) != NULL
; i
++) {
120 BUG_ON(i
!= argc
+ 1);
122 ui__list_menu(argc
, argv
);