Skip to content

Commit 25cc4eb

Browse files
olsajiriacmel
authored andcommitted
perf ui progress: Add ui specific init function
Adding ui specific init function allowing to setup the progress bar width based on current screen scales. Adding TUI init function to get more grained update of the progress bar. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20170908120510.22515-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 80f8735 commit 25cc4eb

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎tools/perf/ui/progress.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ void ui_progress__init(struct ui_progress *p, u64 total, const char *title)
3434
p->total = total;
3535
p->title = title;
3636

37+
if (ui_progress__ops->init)
38+
ui_progress__ops->init(p);
3739
}
3840

3941
void ui_progress__finish(void)

‎tools/perf/ui/progress.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ void ui_progress__init(struct ui_progress *p, u64 total, const char *title);
1414
void ui_progress__update(struct ui_progress *p, u64 adv);
1515

1616
struct ui_progress_ops {
17+
void (*init)(struct ui_progress *p);
1718
void (*update)(struct ui_progress *p);
1819
void (*finish)(void);
1920
};

‎tools/perf/ui/tui/progress.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
#include "tui.h"
66
#include "../browser.h"
77

8+
static void __tui_progress__init(struct ui_progress *p)
9+
{
10+
p->next = p->step = p->total / (SLtt_Screen_Cols - 2) ?: 1;
11+
}
12+
813
static void tui_progress__update(struct ui_progress *p)
914
{
1015
int bar, y;
@@ -49,8 +54,8 @@ static void tui_progress__finish(void)
4954
pthread_mutex_unlock(&ui__lock);
5055
}
5156

52-
static struct ui_progress_ops tui_progress__ops =
53-
{
57+
static struct ui_progress_ops tui_progress__ops = {
58+
.init = __tui_progress__init,
5459
.update = tui_progress__update,
5560
.finish = tui_progress__finish,
5661
};

0 commit comments

Comments
 (0)