blob: 2550277db9f9312e4e0181c840671bbc3ef4a680 [file] [log] [blame]
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -03001#ifndef _PERF_UI_BROWSER_H_
2#define _PERF_UI_BROWSER_H_ 1
3
4#include <stdbool.h>
Arnaldo Carvalho de Melo211ef122010-08-10 14:54:09 -03005#include <sys/types.h>
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -03006#include "../types.h"
7
8#define HE_COLORSET_TOP 50
9#define HE_COLORSET_MEDIUM 51
10#define HE_COLORSET_NORMAL 52
11#define HE_COLORSET_SELECTED 53
12#define HE_COLORSET_CODE 54
Arnaldo Carvalho de Melo058b4cc2012-04-02 12:59:01 -030013#define HE_COLORSET_ADDR 55
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030014
15struct ui_browser {
Arnaldo Carvalho de Melod247eb62010-08-07 13:56:04 -030016 u64 index, top_idx;
17 void *top, *entries;
18 u16 y, x, width, height;
Arnaldo Carvalho de Melo08709162012-04-02 12:48:56 -030019 int current_color;
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030020 void *priv;
Arnaldo Carvalho de Melo3af6e332011-10-13 08:52:46 -030021 const char *title;
22 char *helpline;
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030023 unsigned int (*refresh)(struct ui_browser *self);
24 void (*write)(struct ui_browser *self, void *entry, int row);
25 void (*seek)(struct ui_browser *self, off_t offset, int whence);
Arnaldo Carvalho de Melo250611c2011-10-14 12:27:54 -030026 bool (*filter)(struct ui_browser *self, void *entry);
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030027 u32 nr_entries;
Arnaldo Carvalho de Meloc172f742011-10-18 14:31:35 -020028 bool navkeypressed;
29 bool use_navkeypressed;
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030030};
31
Arnaldo Carvalho de Melo08709162012-04-02 12:48:56 -030032int ui_browser__set_color(struct ui_browser *browser, int color);
Arnaldo Carvalho de Melo8f9bbc42010-08-11 14:51:47 -030033void ui_browser__set_percent_color(struct ui_browser *self,
34 double percent, bool current);
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030035bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row);
36void ui_browser__refresh_dimensions(struct ui_browser *self);
37void ui_browser__reset_index(struct ui_browser *self);
38
Arnaldo Carvalho de Melo8f9bbc42010-08-11 14:51:47 -030039void ui_browser__gotorc(struct ui_browser *self, int y, int x);
Arnaldo Carvalho de Melob210b3b2011-02-25 11:33:31 -030040void __ui_browser__show_title(struct ui_browser *browser, const char *title);
41void ui_browser__show_title(struct ui_browser *browser, const char *title);
Arnaldo Carvalho de Melo59e8fe32010-08-10 15:44:20 -030042int ui_browser__show(struct ui_browser *self, const char *title,
43 const char *helpline, ...);
44void ui_browser__hide(struct ui_browser *self);
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030045int ui_browser__refresh(struct ui_browser *self);
Arnaldo Carvalho de Melo3af6e332011-10-13 08:52:46 -030046int ui_browser__run(struct ui_browser *browser, int delay_secs);
Arnaldo Carvalho de Melo900e14a2011-10-11 16:15:39 -030047void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries);
Arnaldo Carvalho de Melo4610e412011-10-26 12:04:37 -020048void ui_browser__handle_resize(struct ui_browser *browser);
49
Arnaldo Carvalho de Melo7b275092011-10-29 12:15:04 -020050int ui_browser__warning(struct ui_browser *browser, int timeout,
51 const char *format, ...);
Arnaldo Carvalho de Melo4610e412011-10-26 12:04:37 -020052int ui_browser__help_window(struct ui_browser *browser, const char *text);
53bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);
Namhyung Kimaa49f6e2012-03-16 17:50:52 +090054int ui_browser__input_window(const char *title, const char *text, char *input,
55 const char *exit_msg, int delay_sec);
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030056
Arnaldo Carvalho de Melo1056d3d2011-10-26 07:11:03 -020057void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
58unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
59
Arnaldo Carvalho de Meloef8f34a2010-08-06 17:35:02 -030060void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence);
61unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self);
62
63void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence);
64unsigned int ui_browser__list_head_refresh(struct ui_browser *self);
65
66void ui_browser__init(void);
67#endif /* _PERF_UI_BROWSER_H_ */