aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/progress.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-10-25 11:29:11 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-26 11:04:42 -0400
commitca59bcbceeb7fd412faa35871ec0bd21bdd69229 (patch)
tree0d83b6f0b28492a978eb7a5ecde93ec9a2e18258 /tools/perf/util/ui/progress.c
parent727ab04edbc4767711a7aeff5e00249b267ed4c1 (diff)
perf ui progress: Reimplement using slang
Just another step in stopping the use of libnewt in perf. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-vkb9jh5kkzl5ep3puoatd6an@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/ui/progress.c')
-rw-r--r--tools/perf/util/ui/progress.c64
1 files changed, 16 insertions, 48 deletions
diff --git a/tools/perf/util/ui/progress.c b/tools/perf/util/ui/progress.c
index d7fc399d36b3..68d2c548abe3 100644
--- a/tools/perf/util/ui/progress.c
+++ b/tools/perf/util/ui/progress.c
@@ -1,60 +1,28 @@
1#include <stdlib.h>
2#include <newt.h>
3#include "../cache.h" 1#include "../cache.h"
4#include "progress.h" 2#include "progress.h"
3#include "libslang.h"
4#include "ui.h"
5#include "browser.h"
5 6
6struct ui_progress { 7void ui_progress__update(u64 curr, u64 total, const char *title)
7 newtComponent form, scale;
8};
9
10struct ui_progress *ui_progress__new(const char *title, u64 total)
11{
12 struct ui_progress *self = malloc(sizeof(*self));
13
14 if (self != NULL) {
15 int cols;
16
17 if (use_browser <= 0)
18 return self;
19 newtGetScreenSize(&cols, NULL);
20 cols -= 4;
21 newtCenteredWindow(cols, 1, title);
22 self->form = newtForm(NULL, NULL, 0);
23 if (self->form == NULL)
24 goto out_free_self;
25 self->scale = newtScale(0, 0, cols, total);
26 if (self->scale == NULL)
27 goto out_free_form;
28 newtFormAddComponent(self->form, self->scale);
29 newtRefresh();
30 }
31
32 return self;
33
34out_free_form:
35 newtFormDestroy(self->form);
36out_free_self:
37 free(self);
38 return NULL;
39}
40
41void ui_progress__update(struct ui_progress *self, u64 curr)
42{ 8{
9 int bar, y;
43 /* 10 /*
44 * FIXME: We should have a per UI backend way of showing progress, 11 * FIXME: We should have a per UI backend way of showing progress,
45 * stdio will just show a percentage as NN%, etc. 12 * stdio will just show a percentage as NN%, etc.
46 */ 13 */
47 if (use_browser <= 0) 14 if (use_browser <= 0)
48 return; 15 return;
49 newtScaleSet(self->scale, curr);
50 newtRefresh();
51}
52 16
53void ui_progress__delete(struct ui_progress *self) 17 pthread_mutex_lock(&ui__lock);
54{ 18 y = SLtt_Screen_Rows / 2 - 2;
55 if (use_browser > 0) { 19 SLsmg_set_color(0);
56 newtFormDestroy(self->form); 20 SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols);
57 newtPopWindow(); 21 SLsmg_gotorc(y++, 1);
58 } 22 SLsmg_write_string((char *)title);
59 free(self); 23 SLsmg_set_color(HE_COLORSET_SELECTED);
24 bar = ((SLtt_Screen_Cols - 2) * curr) / total;
25 SLsmg_fill_region(y, 1, 1, bar, ' ');
26 SLsmg_refresh();
27 pthread_mutex_unlock(&ui__lock);
60} 28}