diff options
-rw-r--r-- | tools/perf/Makefile | 2 | ||||
-rw-r--r-- | tools/perf/util/newt.c | 38 | ||||
-rw-r--r-- | tools/perf/util/ui/helpline.c | 43 | ||||
-rw-r--r-- | tools/perf/util/ui/helpline.h | 9 |
4 files changed, 55 insertions, 37 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index d5bce768b4bf..d77a101ab7dd 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -569,7 +569,9 @@ else | |||
569 | EXTLIBS += -lnewt -lslang | 569 | EXTLIBS += -lnewt -lslang |
570 | LIB_OBJS += $(OUTPUT)util/newt.o | 570 | LIB_OBJS += $(OUTPUT)util/newt.o |
571 | LIB_OBJS += $(OUTPUT)util/ui/browser.o | 571 | LIB_OBJS += $(OUTPUT)util/ui/browser.o |
572 | LIB_OBJS += $(OUTPUT)util/ui/helpline.o | ||
572 | LIB_H += util/ui/browser.h | 573 | LIB_H += util/ui/browser.h |
574 | LIB_H += util/ui/helpline.h | ||
573 | endif | 575 | endif |
574 | endif | 576 | endif |
575 | 577 | ||
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index 9768be31f9c5..23f3b7d31bff 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "sort.h" | 24 | #include "sort.h" |
25 | #include "symbol.h" | 25 | #include "symbol.h" |
26 | #include "ui/browser.h" | 26 | #include "ui/browser.h" |
27 | #include "ui/helpline.h" | ||
27 | 28 | ||
28 | #if SLANG_VERSION < 20104 | 29 | #if SLANG_VERSION < 20104 |
29 | #define slsmg_printf(msg, args...) SLsmg_printf((char *)msg, ##args) | 30 | #define slsmg_printf(msg, args...) SLsmg_printf((char *)msg, ##args) |
@@ -94,43 +95,6 @@ void ui_progress__delete(struct ui_progress *self) | |||
94 | free(self); | 95 | free(self); |
95 | } | 96 | } |
96 | 97 | ||
97 | static void ui_helpline__pop(void) | ||
98 | { | ||
99 | newtPopHelpLine(); | ||
100 | } | ||
101 | |||
102 | static void ui_helpline__push(const char *msg) | ||
103 | { | ||
104 | newtPushHelpLine(msg); | ||
105 | } | ||
106 | |||
107 | static void ui_helpline__vpush(const char *fmt, va_list ap) | ||
108 | { | ||
109 | char *s; | ||
110 | |||
111 | if (vasprintf(&s, fmt, ap) < 0) | ||
112 | vfprintf(stderr, fmt, ap); | ||
113 | else { | ||
114 | ui_helpline__push(s); | ||
115 | free(s); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | static void ui_helpline__fpush(const char *fmt, ...) | ||
120 | { | ||
121 | va_list ap; | ||
122 | |||
123 | va_start(ap, fmt); | ||
124 | ui_helpline__vpush(fmt, ap); | ||
125 | va_end(ap); | ||
126 | } | ||
127 | |||
128 | static void ui_helpline__puts(const char *msg) | ||
129 | { | ||
130 | ui_helpline__pop(); | ||
131 | ui_helpline__push(msg); | ||
132 | } | ||
133 | |||
134 | static int ui_entry__read(const char *title, char *bf, size_t size, int width) | 98 | static int ui_entry__read(const char *title, char *bf, size_t size, int width) |
135 | { | 99 | { |
136 | struct newtExitStruct es; | 100 | struct newtExitStruct es; |
diff --git a/tools/perf/util/ui/helpline.c b/tools/perf/util/ui/helpline.c new file mode 100644 index 000000000000..6a11e1301559 --- /dev/null +++ b/tools/perf/util/ui/helpline.c | |||
@@ -0,0 +1,43 @@ | |||
1 | #define _GNU_SOURCE | ||
2 | #include <stdio.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <newt.h> | ||
5 | |||
6 | #include "helpline.h" | ||
7 | |||
8 | void ui_helpline__pop(void) | ||
9 | { | ||
10 | newtPopHelpLine(); | ||
11 | } | ||
12 | |||
13 | void ui_helpline__push(const char *msg) | ||
14 | { | ||
15 | newtPushHelpLine(msg); | ||
16 | } | ||
17 | |||
18 | static void ui_helpline__vpush(const char *fmt, va_list ap) | ||
19 | { | ||
20 | char *s; | ||
21 | |||
22 | if (vasprintf(&s, fmt, ap) < 0) | ||
23 | vfprintf(stderr, fmt, ap); | ||
24 | else { | ||
25 | ui_helpline__push(s); | ||
26 | free(s); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | void ui_helpline__fpush(const char *fmt, ...) | ||
31 | { | ||
32 | va_list ap; | ||
33 | |||
34 | va_start(ap, fmt); | ||
35 | ui_helpline__vpush(fmt, ap); | ||
36 | va_end(ap); | ||
37 | } | ||
38 | |||
39 | void ui_helpline__puts(const char *msg) | ||
40 | { | ||
41 | ui_helpline__pop(); | ||
42 | ui_helpline__push(msg); | ||
43 | } | ||
diff --git a/tools/perf/util/ui/helpline.h b/tools/perf/util/ui/helpline.h new file mode 100644 index 000000000000..56d8c1d8ffc8 --- /dev/null +++ b/tools/perf/util/ui/helpline.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _PERF_UI_HELPLINE_H_ | ||
2 | #define _PERF_UI_HELPLINE_H_ 1 | ||
3 | |||
4 | void ui_helpline__pop(void); | ||
5 | void ui_helpline__push(const char *msg); | ||
6 | void ui_helpline__fpush(const char *fmt, ...); | ||
7 | void ui_helpline__puts(const char *msg); | ||
8 | |||
9 | #endif /* _PERF_UI_HELPLINE_H_ */ | ||