Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269091
b: refs/heads/master
c: 250611c
h: refs/heads/master
i:
  269089: f49324c
  269087: 90edcbd
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Oct 14, 2011
1 parent 48b2988 commit 5e865dd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 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: 7296d66aca60a71076a5f0ffab39730e7788590f
refs/heads/master: 250611cfb60ff0c50ca189da7ca727dcd78e8cee
51 changes: 42 additions & 9 deletions trunk/tools/perf/util/ui/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,62 @@ void ui_browser__gotorc(struct ui_browser *self, int y, int x)
SLsmg_gotorc(self->y + y, self->x + x);
}

static struct list_head *
ui_browser__list_head_filter_entries(struct ui_browser *browser,
struct list_head *pos)
{
do {
if (!browser->filter || !browser->filter(browser, pos))
return pos;
pos = pos->next;
} while (pos != browser->entries);

return NULL;
}

static struct list_head *
ui_browser__list_head_filter_prev_entries(struct ui_browser *browser,
struct list_head *pos)
{
do {
if (!browser->filter || !browser->filter(browser, pos))
return pos;
pos = pos->prev;
} while (pos != browser->entries);

return NULL;
}

void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence)
{
struct list_head *head = self->entries;
struct list_head *pos;

if (self->nr_entries == 0)
return;

switch (whence) {
case SEEK_SET:
pos = head->next;
pos = ui_browser__list_head_filter_entries(self, head->next);
break;
case SEEK_CUR:
pos = self->top;
break;
case SEEK_END:
pos = head->prev;
pos = ui_browser__list_head_filter_prev_entries(self, head->prev);
break;
default:
return;
}

assert(pos != NULL);

if (offset > 0) {
while (offset-- != 0)
pos = pos->next;
pos = ui_browser__list_head_filter_entries(self, pos->next);
} else {
while (offset++ != 0)
pos = pos->prev;
pos = ui_browser__list_head_filter_prev_entries(self, pos->prev);
}

self->top = pos;
Expand Down Expand Up @@ -365,15 +396,17 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *self)
int row = 0;

if (self->top == NULL || self->top == self->entries)
self->top = head->next;
self->top = ui_browser__list_head_filter_entries(self, head->next);

pos = self->top;

list_for_each_from(pos, head) {
ui_browser__gotorc(self, row, 0);
self->write(self, pos, row);
if (++row == self->height)
break;
if (!self->filter || !self->filter(self, pos)) {
ui_browser__gotorc(self, row, 0);
self->write(self, pos, row);
if (++row == self->height)
break;
}
}

return row;
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/ui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct ui_browser {
unsigned int (*refresh)(struct ui_browser *self);
void (*write)(struct ui_browser *self, void *entry, int row);
void (*seek)(struct ui_browser *self, off_t offset, int whence);
bool (*filter)(struct ui_browser *self, void *entry);
u32 nr_entries;
};

Expand Down

0 comments on commit 5e865dd

Please sign in to comment.