Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269107
b: refs/heads/master
c: c172f74
h: refs/heads/master
i:
  269105: d980caa
  269103: 149a271
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Oct 18, 2011
1 parent 5967561 commit 1a18239
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3f7247e0725de9643ce5a02b082c81c617476fd5
refs/heads/master: c172f7422c03463a7177e268ffe625c41c42c179
28 changes: 23 additions & 5 deletions trunk/tools/perf/util/ui/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

int newtGetKey(void);

static int ui_browser__percent_color(double percent, bool current)
static int ui_browser__percent_color(struct ui_browser *browser,
double percent, bool current)
{
if (current)
if (current && (!browser->use_navkeypressed || browser->navkeypressed))
return HE_COLORSET_SELECTED;
if (percent >= MIN_RED)
return HE_COLORSET_TOP;
Expand All @@ -33,7 +34,7 @@ void ui_browser__set_color(struct ui_browser *self __used, int color)
void ui_browser__set_percent_color(struct ui_browser *self,
double percent, bool current)
{
int color = ui_browser__percent_color(percent, current);
int color = ui_browser__percent_color(self, percent, current);
ui_browser__set_color(self, color);
}

Expand Down Expand Up @@ -241,12 +242,18 @@ static void ui_browser__scrollbar_set(struct ui_browser *browser)
static int __ui_browser__refresh(struct ui_browser *browser)
{
int row;
int width = browser->width;

row = browser->refresh(browser);
ui_browser__set_color(browser, HE_COLORSET_NORMAL);

if (!browser->use_navkeypressed || browser->navkeypressed)
ui_browser__scrollbar_set(browser);
else
width += 1;

SLsmg_fill_region(browser->y + row, browser->x,
browser->height - row, browser->width, ' ');
ui_browser__scrollbar_set(browser);
browser->height - row, width, ' ');

return 0;
}
Expand Down Expand Up @@ -326,6 +333,17 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
continue;
}

if (self->use_navkeypressed && !self->navkeypressed) {
if (key == NEWT_KEY_DOWN || key == NEWT_KEY_UP ||
key == NEWT_KEY_PGDN || key == NEWT_KEY_PGUP ||
key == NEWT_KEY_HOME || key == NEWT_KEY_END ||
key == ' ') {
self->navkeypressed = true;
continue;
} else
return key;
}

switch (key) {
case NEWT_KEY_DOWN:
if (self->index == self->nr_entries - 1)
Expand Down
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/ui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct ui_browser {
void (*seek)(struct ui_browser *self, off_t offset, int whence);
bool (*filter)(struct ui_browser *self, void *entry);
u32 nr_entries;
bool navkeypressed;
bool use_navkeypressed;
};

void ui_browser__set_color(struct ui_browser *self, int color);
Expand Down
6 changes: 6 additions & 0 deletions trunk/tools/perf/util/ui/browsers/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro

SLsmg_write_char(':');
slsmg_write_nstring(" ", 8);

/* The scroll bar isn't being used */
if (!self->navkeypressed)
width += 1;

if (!*ol->line)
slsmg_write_nstring(" ", width - 18);
else
Expand Down Expand Up @@ -386,6 +391,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
.write = annotate_browser__write,
.filter = objdump_line__filter,
.priv = &ms,
.use_navkeypressed = true,
},
};
int ret;
Expand Down
20 changes: 8 additions & 12 deletions trunk/tools/perf/util/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ static int hist_browser__show_entry(struct hist_browser *self,
char s[256];
double percent;
int printed = 0;
int color, width = self->b.width;
int width = self->b.width;
char folded_sign = ' ';
bool current_entry = ui_browser__is_current_entry(&self->b, row);
off_t row_offset = entry->row_offset;
Expand All @@ -567,22 +567,17 @@ static int hist_browser__show_entry(struct hist_browser *self,
0, false, self->hists->stats.total_period);
percent = (entry->period * 100.0) / self->hists->stats.total_period;

color = HE_COLORSET_SELECTED;
if (!current_entry) {
if (percent >= MIN_RED)
color = HE_COLORSET_TOP;
else if (percent >= MIN_GREEN)
color = HE_COLORSET_MEDIUM;
else
color = HE_COLORSET_NORMAL;
}

ui_browser__set_color(&self->b, color);
ui_browser__set_percent_color(&self->b, percent, current_entry);
ui_browser__gotorc(&self->b, row, 0);
if (symbol_conf.use_callchain) {
slsmg_printf("%c ", folded_sign);
width -= 2;
}

/* The scroll bar isn't being used */
if (!self->b.navkeypressed)
width += 1;

slsmg_write_nstring(s, width);
++row;
++printed;
Expand Down Expand Up @@ -787,6 +782,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists)
self->hists = hists;
self->b.refresh = hist_browser__refresh;
self->b.seek = ui_browser__hists_seek;
self->b.use_navkeypressed = true,
self->has_symbols = sort_sym.list.next != NULL;
}

Expand Down

0 comments on commit 1a18239

Please sign in to comment.