diff options
| -rw-r--r-- | tools/perf/util/newt.c | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index 0ffc8281363c..9fa5b20d4090 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
| @@ -328,6 +328,32 @@ static void ui_browser__reset_index(struct ui_browser *self) | |||
| 328 | self->seek(self, 0, SEEK_SET); | 328 | self->seek(self, 0, SEEK_SET); |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | static int ui_browser__show(struct ui_browser *self, const char *title) | ||
| 332 | { | ||
| 333 | if (self->form != NULL) | ||
| 334 | return 0; | ||
| 335 | ui_browser__refresh_dimensions(self); | ||
| 336 | newtCenteredWindow(self->width + 2, self->height, title); | ||
| 337 | self->form = newt_form__new(); | ||
| 338 | if (self->form == NULL) | ||
| 339 | return -1; | ||
| 340 | |||
| 341 | self->sb = newtVerticalScrollbar(self->width + 1, 0, self->height, | ||
| 342 | HE_COLORSET_NORMAL, | ||
| 343 | HE_COLORSET_SELECTED); | ||
| 344 | if (self->sb == NULL) | ||
| 345 | return -1; | ||
| 346 | |||
| 347 | newtFormAddHotKey(self->form, NEWT_KEY_UP); | ||
| 348 | newtFormAddHotKey(self->form, NEWT_KEY_DOWN); | ||
| 349 | newtFormAddHotKey(self->form, NEWT_KEY_PGUP); | ||
| 350 | newtFormAddHotKey(self->form, NEWT_KEY_PGDN); | ||
| 351 | newtFormAddHotKey(self->form, NEWT_KEY_HOME); | ||
| 352 | newtFormAddHotKey(self->form, NEWT_KEY_END); | ||
| 353 | newtFormAddComponent(self->form, self->sb); | ||
| 354 | return 0; | ||
| 355 | } | ||
| 356 | |||
| 331 | static int objdump_line__show(struct objdump_line *self, struct list_head *head, | 357 | static int objdump_line__show(struct objdump_line *self, struct list_head *head, |
| 332 | int width, struct hist_entry *he, int len, | 358 | int width, struct hist_entry *he, int len, |
| 333 | bool current_entry) | 359 | bool current_entry) |
| @@ -406,39 +432,10 @@ static int ui_browser__refresh_entries(struct ui_browser *self) | |||
| 406 | return 0; | 432 | return 0; |
| 407 | } | 433 | } |
| 408 | 434 | ||
| 409 | static int ui_browser__run(struct ui_browser *self, const char *title, | 435 | static int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es) |
| 410 | struct newtExitStruct *es) | ||
| 411 | { | 436 | { |
| 412 | if (self->form) { | ||
| 413 | newtFormDestroy(self->form); | ||
| 414 | newtPopWindow(); | ||
| 415 | } | ||
| 416 | |||
| 417 | ui_browser__refresh_dimensions(self); | ||
| 418 | newtCenteredWindow(self->width + 2, self->height, title); | ||
| 419 | self->form = newt_form__new(); | ||
| 420 | if (self->form == NULL) | ||
| 421 | return -1; | ||
| 422 | |||
| 423 | self->sb = newtVerticalScrollbar(self->width + 1, 0, self->height, | ||
| 424 | HE_COLORSET_NORMAL, | ||
| 425 | HE_COLORSET_SELECTED); | ||
| 426 | if (self->sb == NULL) | ||
| 427 | return -1; | ||
| 428 | |||
| 429 | newtFormAddHotKey(self->form, NEWT_KEY_UP); | ||
| 430 | newtFormAddHotKey(self->form, NEWT_KEY_DOWN); | ||
| 431 | newtFormAddHotKey(self->form, NEWT_KEY_PGUP); | ||
| 432 | newtFormAddHotKey(self->form, NEWT_KEY_PGDN); | ||
| 433 | newtFormAddHotKey(self->form, ' '); | ||
| 434 | newtFormAddHotKey(self->form, NEWT_KEY_HOME); | ||
| 435 | newtFormAddHotKey(self->form, NEWT_KEY_END); | ||
| 436 | newtFormAddHotKey(self->form, NEWT_KEY_TAB); | ||
| 437 | newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); | ||
| 438 | |||
| 439 | if (ui_browser__refresh_entries(self) < 0) | 437 | if (ui_browser__refresh_entries(self) < 0) |
| 440 | return -1; | 438 | return -1; |
| 441 | newtFormAddComponent(self->form, self->sb); | ||
| 442 | 439 | ||
| 443 | while (1) { | 440 | while (1) { |
| 444 | off_t offset; | 441 | off_t offset; |
| @@ -733,7 +730,8 @@ int hist_entry__tui_annotate(struct hist_entry *self) | |||
| 733 | } | 730 | } |
| 734 | 731 | ||
| 735 | browser.width += 18; /* Percentage */ | 732 | browser.width += 18; /* Percentage */ |
| 736 | ret = ui_browser__run(&browser, self->ms.sym->name, &es); | 733 | ui_browser__show(&browser, self->ms.sym->name); |
| 734 | ui_browser__run(&browser, &es); | ||
| 737 | newtFormDestroy(browser.form); | 735 | newtFormDestroy(browser.form); |
| 738 | newtPopWindow(); | 736 | newtPopWindow(); |
| 739 | list_for_each_entry_safe(pos, n, &head, node) { | 737 | list_for_each_entry_safe(pos, n, &head, node) { |
