aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/browser.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-08-10 14:44:20 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-08-10 14:44:20 -0400
commit59e8fe32fc0cc9dff6b0c269d099a49e004dc45e (patch)
tree55133961ebcbf9ea5b5ab674360207876c189349 /tools/perf/util/ui/browser.c
parentf1e9214cc99644101d957c5c660946c6f2f86d7c (diff)
perf ui browser: Add ui_browser__show counterpart: __hide
So that the common tasks of providing a helpline at __run entry and destroying the window and releasing resourses at exit can be abstracted away, reducing a bit more the coupling with libnewt. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/ui/browser.c')
-rw-r--r--tools/perf/util/ui/browser.c18
1 files changed, 17 insertions, 1 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;