aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/ui/browser.c18
-rw-r--r--tools/perf/util/ui/browser.h4
-rw-r--r--tools/perf/util/ui/browsers/annotate.c8
-rw-r--r--tools/perf/util/ui/browsers/hists.c5
-rw-r--r--tools/perf/util/ui/browsers/map.c10
-rw-r--r--tools/perf/util/ui/helpline.c2
-rw-r--r--tools/perf/util/ui/helpline.h1
7 files changed, 33 insertions, 15 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index 83d57487f6e..66f2d583d8c 100644
--- a/tools/perf/util/ui/browser.c
+++ b/tools/perf/util/ui/browser.c
@@ -16,6 +16,7 @@
16#include <stdlib.h> 16#include <stdlib.h>
17#include <sys/ttydefaults.h> 17#include <sys/ttydefaults.h>
18#include "browser.h" 18#include "browser.h"
19#include "helpline.h"
19#include "../color.h" 20#include "../color.h"
20#include "../util.h" 21#include "../util.h"
21 22
@@ -145,8 +146,11 @@ void ui_browser__reset_index(struct ui_browser *self)
145 self->seek(self, 0, SEEK_SET); 146 self->seek(self, 0, SEEK_SET);
146} 147}
147 148
148int ui_browser__show(struct ui_browser *self, const char *title) 149int ui_browser__show(struct ui_browser *self, const char *title,
150 const char *helpline, ...)
149{ 151{
152 va_list ap;
153
150 if (self->form != NULL) { 154 if (self->form != NULL) {
151 newtFormDestroy(self->form); 155 newtFormDestroy(self->form);
152 newtPopWindow(); 156 newtPopWindow();
@@ -171,9 +175,21 @@ int ui_browser__show(struct ui_browser *self, const char *title)
171 newtFormAddHotKey(self->form, NEWT_KEY_END); 175 newtFormAddHotKey(self->form, NEWT_KEY_END);
172 newtFormAddHotKey(self->form, ' '); 176 newtFormAddHotKey(self->form, ' ');
173 newtFormAddComponent(self->form, self->sb); 177 newtFormAddComponent(self->form, self->sb);
178
179 va_start(ap, helpline);
180 ui_helpline__vpush(helpline, ap);
181 va_end(ap);
174 return 0; 182 return 0;
175} 183}
176 184
185void ui_browser__hide(struct ui_browser *self)
186{
187 newtFormDestroy(self->form);
188 newtPopWindow();
189 self->form = NULL;
190 ui_helpline__pop();
191}
192
177int ui_browser__refresh(struct ui_browser *self) 193int ui_browser__refresh(struct ui_browser *self)
178{ 194{
179 int row; 195 int row;
diff --git a/tools/perf/util/ui/browser.h b/tools/perf/util/ui/browser.h
index 856e3436172..0b9f829214f 100644
--- a/tools/perf/util/ui/browser.h
+++ b/tools/perf/util/ui/browser.h
@@ -30,7 +30,9 @@ bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row);
30void ui_browser__refresh_dimensions(struct ui_browser *self); 30void ui_browser__refresh_dimensions(struct ui_browser *self);
31void ui_browser__reset_index(struct ui_browser *self); 31void ui_browser__reset_index(struct ui_browser *self);
32 32
33int ui_browser__show(struct ui_browser *self, const char *title); 33int ui_browser__show(struct ui_browser *self, const char *title,
34 const char *helpline, ...);
35void ui_browser__hide(struct ui_browser *self);
34int ui_browser__refresh(struct ui_browser *self); 36int ui_browser__refresh(struct ui_browser *self);
35int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es); 37int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es);
36 38
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 73e78ef38a5..55ff792459a 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -141,10 +141,10 @@ static int annotate_browser__run(struct annotate_browser *self,
141 struct rb_node *nd; 141 struct rb_node *nd;
142 struct hist_entry *he = self->b.priv; 142 struct hist_entry *he = self->b.priv;
143 143
144 if (ui_browser__show(&self->b, he->ms.sym->name) < 0) 144 if (ui_browser__show(&self->b, he->ms.sym->name,
145 "<- or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0)
145 return -1; 146 return -1;
146 147
147 ui_helpline__fpush("<- or ESC: exit, TAB/shift+TAB: cycle thru samples");
148 newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT); 148 newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
149 149
150 nd = self->curr_hot; 150 nd = self->curr_hot;
@@ -177,9 +177,7 @@ static int annotate_browser__run(struct annotate_browser *self,
177 } 177 }
178 } 178 }
179out: 179out:
180 newtFormDestroy(self->b.form); 180 ui_browser__hide(&self->b);
181 newtPopWindow();
182 ui_helpline__pop();
183 return 0; 181 return 0;
184} 182}
185 183
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index cee7998f1c3..dd512b73b01 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -211,7 +211,8 @@ static int hist_browser__run(struct hist_browser *self, const char *title,
211 nr_events, unit); 211 nr_events, unit);
212 newtDrawRootText(0, 0, str); 212 newtDrawRootText(0, 0, str);
213 213
214 if (ui_browser__show(&self->b, title) < 0) 214 if (ui_browser__show(&self->b, title,
215 "Press '?' for help on key bindings") < 0)
215 return -1; 216 return -1;
216 217
217 newtFormAddHotKey(self->b.form, 'A'); 218 newtFormAddHotKey(self->b.form, 'A');
@@ -253,6 +254,8 @@ static int hist_browser__run(struct hist_browser *self, const char *title,
253 return 0; 254 return 0;
254 } 255 }
255 } 256 }
257
258 ui_browser__hide(&self->b);
256 return 0; 259 return 0;
257} 260}
258 261
diff --git a/tools/perf/util/ui/browsers/map.c b/tools/perf/util/ui/browsers/map.c
index b79f0c996ea..142b825b42b 100644
--- a/tools/perf/util/ui/browsers/map.c
+++ b/tools/perf/util/ui/browsers/map.c
@@ -100,11 +100,11 @@ static int map_browser__search(struct map_browser *self)
100 100
101static int map_browser__run(struct map_browser *self, struct newtExitStruct *es) 101static int map_browser__run(struct map_browser *self, struct newtExitStruct *es)
102{ 102{
103 if (ui_browser__show(&self->b, self->map->dso->long_name) < 0) 103 if (ui_browser__show(&self->b, self->map->dso->long_name,
104 "Press <- or ESC to exit, %s / to search",
105 verbose ? "" : "restart with -v to use") < 0)
104 return -1; 106 return -1;
105 107
106 ui_helpline__fpush("Press <- or ESC to exit, %s / to search",
107 verbose ? "" : "restart with -v to use");
108 newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT); 108 newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
109 newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER); 109 newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER);
110 if (verbose) 110 if (verbose)
@@ -121,9 +121,7 @@ static int map_browser__run(struct map_browser *self, struct newtExitStruct *es)
121 break; 121 break;
122 } 122 }
123 123
124 newtFormDestroy(self->b.form); 124 ui_browser__hide(&self->b);
125 newtPopWindow();
126 ui_helpline__pop();
127 return 0; 125 return 0;
128} 126}
129 127
diff --git a/tools/perf/util/ui/helpline.c b/tools/perf/util/ui/helpline.c
index ff584606a4d..8d79daa4458 100644
--- a/tools/perf/util/ui/helpline.c
+++ b/tools/perf/util/ui/helpline.c
@@ -16,7 +16,7 @@ void ui_helpline__push(const char *msg)
16 newtPushHelpLine(msg); 16 newtPushHelpLine(msg);
17} 17}
18 18
19static void ui_helpline__vpush(const char *fmt, va_list ap) 19void ui_helpline__vpush(const char *fmt, va_list ap)
20{ 20{
21 char *s; 21 char *s;
22 22
diff --git a/tools/perf/util/ui/helpline.h b/tools/perf/util/ui/helpline.h
index 5d1e5e72ffb..ab6028d0c40 100644
--- a/tools/perf/util/ui/helpline.h
+++ b/tools/perf/util/ui/helpline.h
@@ -4,6 +4,7 @@
4void ui_helpline__init(void); 4void ui_helpline__init(void);
5void ui_helpline__pop(void); 5void ui_helpline__pop(void);
6void ui_helpline__push(const char *msg); 6void ui_helpline__push(const char *msg);
7void ui_helpline__vpush(const char *fmt, va_list ap);
7void ui_helpline__fpush(const char *fmt, ...); 8void ui_helpline__fpush(const char *fmt, ...);
8void ui_helpline__puts(const char *msg); 9void ui_helpline__puts(const char *msg);
9 10