diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-08-07 12:56:04 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-08-10 15:08:33 -0400 |
commit | d247eb6b924bbc2f13748c89b6c72c7a3d46645c (patch) | |
tree | 88be5eaca242e18622517825b670995a266660f3 /tools/perf/util/ui | |
parent | ef8f34aabf2450a9fb36b2c87fe0ea0b86a38195 (diff) |
perf ui: Shorten ui_browser member names
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/ui')
-rw-r--r-- | tools/perf/util/ui/browser.c | 57 | ||||
-rw-r--r-- | tools/perf/util/ui/browser.h | 6 |
2 files changed, 31 insertions, 32 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c index 0b2b9306312d..edbb7dd9eb2e 100644 --- a/tools/perf/util/ui/browser.c +++ b/tools/perf/util/ui/browser.c | |||
@@ -49,7 +49,7 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc | |||
49 | pos = head->next; | 49 | pos = head->next; |
50 | break; | 50 | break; |
51 | case SEEK_CUR: | 51 | case SEEK_CUR: |
52 | pos = self->first_visible_entry; | 52 | pos = self->top; |
53 | break; | 53 | break; |
54 | case SEEK_END: | 54 | case SEEK_END: |
55 | pos = head->prev; | 55 | pos = head->prev; |
@@ -66,7 +66,7 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc | |||
66 | pos = pos->prev; | 66 | pos = pos->prev; |
67 | } | 67 | } |
68 | 68 | ||
69 | self->first_visible_entry = pos; | 69 | self->top = pos; |
70 | } | 70 | } |
71 | 71 | ||
72 | void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) | 72 | void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) |
@@ -79,7 +79,7 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) | |||
79 | nd = rb_first(root); | 79 | nd = rb_first(root); |
80 | break; | 80 | break; |
81 | case SEEK_CUR: | 81 | case SEEK_CUR: |
82 | nd = self->first_visible_entry; | 82 | nd = self->top; |
83 | break; | 83 | break; |
84 | case SEEK_END: | 84 | case SEEK_END: |
85 | nd = rb_last(root); | 85 | nd = rb_last(root); |
@@ -96,7 +96,7 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) | |||
96 | nd = rb_prev(nd); | 96 | nd = rb_prev(nd); |
97 | } | 97 | } |
98 | 98 | ||
99 | self->first_visible_entry = nd; | 99 | self->top = nd; |
100 | } | 100 | } |
101 | 101 | ||
102 | unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self) | 102 | unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self) |
@@ -104,13 +104,13 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self) | |||
104 | struct rb_node *nd; | 104 | struct rb_node *nd; |
105 | int row = 0; | 105 | int row = 0; |
106 | 106 | ||
107 | if (self->first_visible_entry == NULL) | 107 | if (self->top == NULL) |
108 | self->first_visible_entry = rb_first(self->entries); | 108 | self->top = rb_first(self->entries); |
109 | 109 | ||
110 | nd = self->first_visible_entry; | 110 | nd = self->top; |
111 | 111 | ||
112 | while (nd != NULL) { | 112 | while (nd != NULL) { |
113 | SLsmg_gotorc(self->top + row, self->left); | 113 | SLsmg_gotorc(self->y + row, self->x); |
114 | self->write(self, nd, row); | 114 | self->write(self, nd, row); |
115 | if (++row == self->height) | 115 | if (++row == self->height) |
116 | break; | 116 | break; |
@@ -122,7 +122,7 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self) | |||
122 | 122 | ||
123 | bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row) | 123 | bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row) |
124 | { | 124 | { |
125 | return (self->first_visible_entry_idx + row) == self->index; | 125 | return self->top_idx + row == self->index; |
126 | } | 126 | } |
127 | 127 | ||
128 | void ui_browser__refresh_dimensions(struct ui_browser *self) | 128 | void ui_browser__refresh_dimensions(struct ui_browser *self) |
@@ -135,13 +135,13 @@ void ui_browser__refresh_dimensions(struct ui_browser *self) | |||
135 | self->height = rows - 5; | 135 | self->height = rows - 5; |
136 | if (self->height > self->nr_entries) | 136 | if (self->height > self->nr_entries) |
137 | self->height = self->nr_entries; | 137 | self->height = self->nr_entries; |
138 | self->top = (rows - self->height) / 2; | 138 | self->y = (rows - self->height) / 2; |
139 | self->left = (cols - self->width) / 2; | 139 | self->x = (cols - self->width) / 2; |
140 | } | 140 | } |
141 | 141 | ||
142 | void ui_browser__reset_index(struct ui_browser *self) | 142 | void ui_browser__reset_index(struct ui_browser *self) |
143 | { | 143 | { |
144 | self->index = self->first_visible_entry_idx = 0; | 144 | self->index = self->top_idx = 0; |
145 | self->seek(self, 0, SEEK_SET); | 145 | self->seek(self, 0, SEEK_SET); |
146 | } | 146 | } |
147 | 147 | ||
@@ -180,7 +180,7 @@ int ui_browser__refresh(struct ui_browser *self) | |||
180 | newtScrollbarSet(self->sb, self->index, self->nr_entries - 1); | 180 | newtScrollbarSet(self->sb, self->index, self->nr_entries - 1); |
181 | row = self->refresh(self); | 181 | row = self->refresh(self); |
182 | SLsmg_set_color(HE_COLORSET_NORMAL); | 182 | SLsmg_set_color(HE_COLORSET_NORMAL); |
183 | SLsmg_fill_region(self->top + row, self->left, | 183 | SLsmg_fill_region(self->y + row, self->x, |
184 | self->height - row, self->width, ' '); | 184 | self->height - row, self->width, ' '); |
185 | 185 | ||
186 | return 0; | 186 | return 0; |
@@ -205,8 +205,8 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es) | |||
205 | if (self->index == self->nr_entries - 1) | 205 | if (self->index == self->nr_entries - 1) |
206 | break; | 206 | break; |
207 | ++self->index; | 207 | ++self->index; |
208 | if (self->index == self->first_visible_entry_idx + self->height) { | 208 | if (self->index == self->top_idx + self->height) { |
209 | ++self->first_visible_entry_idx; | 209 | ++self->top_idx; |
210 | self->seek(self, +1, SEEK_CUR); | 210 | self->seek(self, +1, SEEK_CUR); |
211 | } | 211 | } |
212 | break; | 212 | break; |
@@ -214,34 +214,34 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es) | |||
214 | if (self->index == 0) | 214 | if (self->index == 0) |
215 | break; | 215 | break; |
216 | --self->index; | 216 | --self->index; |
217 | if (self->index < self->first_visible_entry_idx) { | 217 | if (self->index < self->top_idx) { |
218 | --self->first_visible_entry_idx; | 218 | --self->top_idx; |
219 | self->seek(self, -1, SEEK_CUR); | 219 | self->seek(self, -1, SEEK_CUR); |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | case NEWT_KEY_PGDN: | 222 | case NEWT_KEY_PGDN: |
223 | case ' ': | 223 | case ' ': |
224 | if (self->first_visible_entry_idx + self->height > self->nr_entries - 1) | 224 | if (self->top_idx + self->height > self->nr_entries - 1) |
225 | break; | 225 | break; |
226 | 226 | ||
227 | offset = self->height; | 227 | offset = self->height; |
228 | if (self->index + offset > self->nr_entries - 1) | 228 | if (self->index + offset > self->nr_entries - 1) |
229 | offset = self->nr_entries - 1 - self->index; | 229 | offset = self->nr_entries - 1 - self->index; |
230 | self->index += offset; | 230 | self->index += offset; |
231 | self->first_visible_entry_idx += offset; | 231 | self->top_idx += offset; |
232 | self->seek(self, +offset, SEEK_CUR); | 232 | self->seek(self, +offset, SEEK_CUR); |
233 | break; | 233 | break; |
234 | case NEWT_KEY_PGUP: | 234 | case NEWT_KEY_PGUP: |
235 | if (self->first_visible_entry_idx == 0) | 235 | if (self->top_idx == 0) |
236 | break; | 236 | break; |
237 | 237 | ||
238 | if (self->first_visible_entry_idx < self->height) | 238 | if (self->top_idx < self->height) |
239 | offset = self->first_visible_entry_idx; | 239 | offset = self->top_idx; |
240 | else | 240 | else |
241 | offset = self->height; | 241 | offset = self->height; |
242 | 242 | ||
243 | self->index -= offset; | 243 | self->index -= offset; |
244 | self->first_visible_entry_idx -= offset; | 244 | self->top_idx -= offset; |
245 | self->seek(self, -offset, SEEK_CUR); | 245 | self->seek(self, -offset, SEEK_CUR); |
246 | break; | 246 | break; |
247 | case NEWT_KEY_HOME: | 247 | case NEWT_KEY_HOME: |
@@ -253,7 +253,7 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es) | |||
253 | offset = self->nr_entries - 1; | 253 | offset = self->nr_entries - 1; |
254 | 254 | ||
255 | self->index = self->nr_entries - 1; | 255 | self->index = self->nr_entries - 1; |
256 | self->first_visible_entry_idx = self->index - offset; | 256 | self->top_idx = self->index - offset; |
257 | self->seek(self, -offset, SEEK_END); | 257 | self->seek(self, -offset, SEEK_END); |
258 | break; | 258 | break; |
259 | default: | 259 | default: |
@@ -271,14 +271,13 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *self) | |||
271 | struct list_head *head = self->entries; | 271 | struct list_head *head = self->entries; |
272 | int row = 0; | 272 | int row = 0; |
273 | 273 | ||
274 | if (self->first_visible_entry == NULL || | 274 | if (self->top == NULL || self->top == self->entries) |
275 | self->first_visible_entry == self->entries) | 275 | self->top = head->next; |
276 | self->first_visible_entry = head->next; | ||
277 | 276 | ||
278 | pos = self->first_visible_entry; | 277 | pos = self->top; |
279 | 278 | ||
280 | list_for_each_from(pos, head) { | 279 | list_for_each_from(pos, head) { |
281 | SLsmg_gotorc(self->top + row, self->left); | 280 | SLsmg_gotorc(self->y + row, self->x); |
282 | self->write(self, pos, row); | 281 | self->write(self, pos, row); |
283 | if (++row == self->height) | 282 | if (++row == self->height) |
284 | break; | 283 | break; |
diff --git a/tools/perf/util/ui/browser.h b/tools/perf/util/ui/browser.h index bcc4391405bd..8eed24cf2854 100644 --- a/tools/perf/util/ui/browser.h +++ b/tools/perf/util/ui/browser.h | |||
@@ -13,9 +13,9 @@ | |||
13 | 13 | ||
14 | struct ui_browser { | 14 | struct ui_browser { |
15 | newtComponent form, sb; | 15 | newtComponent form, sb; |
16 | u64 index, first_visible_entry_idx; | 16 | u64 index, top_idx; |
17 | void *first_visible_entry, *entries; | 17 | void *top, *entries; |
18 | u16 top, left, width, height; | 18 | u16 y, x, width, height; |
19 | void *priv; | 19 | void *priv; |
20 | unsigned int (*refresh)(struct ui_browser *self); | 20 | unsigned int (*refresh)(struct ui_browser *self); |
21 | void (*write)(struct ui_browser *self, void *entry, int row); | 21 | void (*write)(struct ui_browser *self, void *entry, int row); |