aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/browser.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/ui/browser.c')
-rw-r--r--tools/perf/util/ui/browser.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index 66f2d583d8c4..d237410c973b 100644
--- a/tools/perf/util/ui/browser.c
+++ b/tools/perf/util/ui/browser.c
@@ -1,16 +1,6 @@
1#define _GNU_SOURCE
2#include <stdio.h>
3#undef _GNU_SOURCE
4/*
5 * slang versions <= 2.0.6 have a "#if HAVE_LONG_LONG" that breaks
6 * the build if it isn't defined. Use the equivalent one that glibc
7 * has on features.h.
8 */
9#include <features.h>
10#ifndef HAVE_LONG_LONG
11#define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG
12#endif
13#include <slang.h> 1#include <slang.h>
2#include "libslang.h"
3#include <linux/compiler.h>
14#include <linux/list.h> 4#include <linux/list.h>
15#include <linux/rbtree.h> 5#include <linux/rbtree.h>
16#include <stdlib.h> 6#include <stdlib.h>
@@ -19,17 +9,11 @@
19#include "helpline.h" 9#include "helpline.h"
20#include "../color.h" 10#include "../color.h"
21#include "../util.h" 11#include "../util.h"
22 12#include <stdio.h>
23#if SLANG_VERSION < 20104
24#define sltt_set_color(obj, name, fg, bg) \
25 SLtt_set_color(obj,(char *)name, (char *)fg, (char *)bg)
26#else
27#define sltt_set_color SLtt_set_color
28#endif
29 13
30newtComponent newt_form__new(void); 14newtComponent newt_form__new(void);
31 15
32int ui_browser__percent_color(double percent, bool current) 16static int ui_browser__percent_color(double percent, bool current)
33{ 17{
34 if (current) 18 if (current)
35 return HE_COLORSET_SELECTED; 19 return HE_COLORSET_SELECTED;
@@ -40,6 +24,23 @@ int ui_browser__percent_color(double percent, bool current)
40 return HE_COLORSET_NORMAL; 24 return HE_COLORSET_NORMAL;
41} 25}
42 26
27void ui_browser__set_color(struct ui_browser *self __used, int color)
28{
29 SLsmg_set_color(color);
30}
31
32void ui_browser__set_percent_color(struct ui_browser *self,
33 double percent, bool current)
34{
35 int color = ui_browser__percent_color(percent, current);
36 ui_browser__set_color(self, color);
37}
38
39void ui_browser__gotorc(struct ui_browser *self, int y, int x)
40{
41 SLsmg_gotorc(self->y + y, self->x + x);
42}
43
43void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence) 44void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence)
44{ 45{
45 struct list_head *head = self->entries; 46 struct list_head *head = self->entries;
@@ -111,7 +112,7 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self)
111 nd = self->top; 112 nd = self->top;
112 113
113 while (nd != NULL) { 114 while (nd != NULL) {
114 SLsmg_gotorc(self->y + row, self->x); 115 ui_browser__gotorc(self, row, 0);
115 self->write(self, nd, row); 116 self->write(self, nd, row);
116 if (++row == self->height) 117 if (++row == self->height)
117 break; 118 break;
@@ -196,7 +197,7 @@ int ui_browser__refresh(struct ui_browser *self)
196 197
197 newtScrollbarSet(self->sb, self->index, self->nr_entries - 1); 198 newtScrollbarSet(self->sb, self->index, self->nr_entries - 1);
198 row = self->refresh(self); 199 row = self->refresh(self);
199 SLsmg_set_color(HE_COLORSET_NORMAL); 200 ui_browser__set_color(self, HE_COLORSET_NORMAL);
200 SLsmg_fill_region(self->y + row, self->x, 201 SLsmg_fill_region(self->y + row, self->x,
201 self->height - row, self->width, ' '); 202 self->height - row, self->width, ' ');
202 203
@@ -294,7 +295,7 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *self)
294 pos = self->top; 295 pos = self->top;
295 296
296 list_for_each_from(pos, head) { 297 list_for_each_from(pos, head) {
297 SLsmg_gotorc(self->y + row, self->x); 298 ui_browser__gotorc(self, row, 0);
298 self->write(self, pos, row); 299 self->write(self, pos, row);
299 if (++row == self->height) 300 if (++row == self->height)
300 break; 301 break;