1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _PERF_UI_BROWSER_H_
3 #define _PERF_UI_BROWSER_H_ 1
4 
5 #include <linux/types.h>
6 #include <stdarg.h>
7 #include <sys/types.h>
8 
9 #define HE_COLORSET_TOP		50
10 #define HE_COLORSET_MEDIUM	51
11 #define HE_COLORSET_NORMAL	52
12 #define HE_COLORSET_SELECTED	53
13 #define HE_COLORSET_JUMP_ARROWS	54
14 #define HE_COLORSET_ADDR	55
15 #define HE_COLORSET_ROOT	56
16 
17 struct ui_browser {
18 	u64	      index, top_idx;
19 	void	      *top, *entries;
20 	u16	      y, x, width, height, rows, columns, horiz_scroll;
21 	u8	      extra_title_lines;
22 	int	      current_color;
23 	void	      *priv;
24 	const char    *title;
25 	char	      *helpline;
26 	const char    *no_samples_msg;
27 	void 	      (*refresh_dimensions)(struct ui_browser *browser);
28 	unsigned int  (*refresh)(struct ui_browser *browser);
29 	void	      (*write)(struct ui_browser *browser, void *entry, int row);
30 	void	      (*seek)(struct ui_browser *browser, off_t offset, int whence);
31 	bool	      (*filter)(struct ui_browser *browser, void *entry);
32 	u32	      nr_entries;
33 	bool	      navkeypressed;
34 	bool	      use_navkeypressed;
35 };
36 
37 int  ui_browser__set_color(struct ui_browser *browser, int color);
38 void ui_browser__set_percent_color(struct ui_browser *browser,
39 				   double percent, bool current);
40 bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row);
41 void ui_browser__refresh_dimensions(struct ui_browser *browser);
42 void ui_browser__reset_index(struct ui_browser *browser);
43 
44 void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x);
45 void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
46 void ui_browser__write_nstring(struct ui_browser *browser, const char *msg,
47 			       unsigned int width);
48 void ui_browser__vprintf(struct ui_browser *browser, const char *fmt, va_list args);
49 void ui_browser__printf(struct ui_browser *browser, const char *fmt, ...);
50 void ui_browser__write_graph(struct ui_browser *browser, int graph);
51 void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
52 			      u64 start, u64 end);
53 void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column,
54 			    unsigned int row, int diff, bool arrow_down);
55 void __ui_browser__show_title(struct ui_browser *browser, const char *title);
56 void ui_browser__show_title(struct ui_browser *browser, const char *title);
57 int ui_browser__show(struct ui_browser *browser, const char *title,
58 		     const char *helpline, ...);
59 void ui_browser__hide(struct ui_browser *browser);
60 int ui_browser__refresh(struct ui_browser *browser);
61 int ui_browser__run(struct ui_browser *browser, int delay_secs);
62 void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries);
63 void ui_browser__handle_resize(struct ui_browser *browser);
64 void __ui_browser__vline(struct ui_browser *browser, unsigned int column,
65 			 u16 start, u16 end);
66 
67 int ui_browser__warning(struct ui_browser *browser, int timeout,
68 			const char *format, ...);
69 int ui_browser__help_window(struct ui_browser *browser, const char *text);
70 bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);
71 int ui_browser__input_window(const char *title, const char *text, char *input,
72 			     const char *exit_msg, int delay_sec);
73 struct perf_env;
74 int tui__header_window(struct perf_env *env);
75 
76 void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
77 unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
78 
79 void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence);
80 unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser);
81 
82 void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence);
83 unsigned int ui_browser__list_head_refresh(struct ui_browser *browser);
84 
85 void ui_browser__init(void);
86 #endif /* _PERF_UI_BROWSER_H_ */
87