diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-01 10:07:54 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-07 11:36:54 -0400 |
commit | 62c95ae33f64ecf398f490886f026a6132fb1520 (patch) | |
tree | 701435d99b2a87faf900325902dbaa38ee03f0c6 /tools/perf/ui/browser.c | |
parent | 8b5b584daf3b92fc5cdc83919e64231817d2f5a7 (diff) |
perf ui browser: Add ->rows to disambiguate from ->height
The ui_browser->height is about the whole browser "window", including
any header, status lines or any other space needed for some "Yes", "No",
etc buttons a descendent browser, like hist_browser, may have.
Since the navigation is done mostly on the ui_browser methods, it needs
to know how many rows are on the screen, while details about what other
components are, say, if a header (that may be composed of multiple
lines, etc) is present.
Besides this we'll need to add a ui_browser->refresh_dimensions() hook
so that browsers like hist_browser can update ->rows in response to
screen resizes, this will come in a follow up patch.
This patch just adds ->rows and updates it when updating ->height, keeps
using ->height for the only other widget that can come with ui_browser,
the scrollbar, that goes on using all the height on the rightmost column
in the screen, using ->rows for the keyboard navigation needs.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-xexmwg1mv7u03j5imn66jdak@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browser.c')
-rw-r--r-- | tools/perf/ui/browser.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index 9d2294efc00c..adb294a3ec08 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c | |||
@@ -150,7 +150,7 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser) | |||
150 | while (nd != NULL) { | 150 | while (nd != NULL) { |
151 | ui_browser__gotorc(browser, row, 0); | 151 | ui_browser__gotorc(browser, row, 0); |
152 | browser->write(browser, nd, row); | 152 | browser->write(browser, nd, row); |
153 | if (++row == browser->height) | 153 | if (++row == browser->rows) |
154 | break; | 154 | break; |
155 | nd = rb_next(nd); | 155 | nd = rb_next(nd); |
156 | } | 156 | } |
@@ -166,7 +166,7 @@ bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row) | |||
166 | void ui_browser__refresh_dimensions(struct ui_browser *browser) | 166 | void ui_browser__refresh_dimensions(struct ui_browser *browser) |
167 | { | 167 | { |
168 | browser->width = SLtt_Screen_Cols - 1; | 168 | browser->width = SLtt_Screen_Cols - 1; |
169 | browser->height = SLtt_Screen_Rows - 2; | 169 | browser->height = browser->rows = SLtt_Screen_Rows - 2; |
170 | browser->y = 1; | 170 | browser->y = 1; |
171 | browser->x = 0; | 171 | browser->x = 0; |
172 | } | 172 | } |
@@ -389,7 +389,7 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs) | |||
389 | if (browser->index == browser->nr_entries - 1) | 389 | if (browser->index == browser->nr_entries - 1) |
390 | break; | 390 | break; |
391 | ++browser->index; | 391 | ++browser->index; |
392 | if (browser->index == browser->top_idx + browser->height) { | 392 | if (browser->index == browser->top_idx + browser->rows) { |
393 | ++browser->top_idx; | 393 | ++browser->top_idx; |
394 | browser->seek(browser, +1, SEEK_CUR); | 394 | browser->seek(browser, +1, SEEK_CUR); |
395 | } | 395 | } |
@@ -405,10 +405,10 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs) | |||
405 | break; | 405 | break; |
406 | case K_PGDN: | 406 | case K_PGDN: |
407 | case ' ': | 407 | case ' ': |
408 | if (browser->top_idx + browser->height > browser->nr_entries - 1) | 408 | if (browser->top_idx + browser->rows > browser->nr_entries - 1) |
409 | break; | 409 | break; |
410 | 410 | ||
411 | offset = browser->height; | 411 | offset = browser->rows; |
412 | if (browser->index + offset > browser->nr_entries - 1) | 412 | if (browser->index + offset > browser->nr_entries - 1) |
413 | offset = browser->nr_entries - 1 - browser->index; | 413 | offset = browser->nr_entries - 1 - browser->index; |
414 | browser->index += offset; | 414 | browser->index += offset; |
@@ -419,10 +419,10 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs) | |||
419 | if (browser->top_idx == 0) | 419 | if (browser->top_idx == 0) |
420 | break; | 420 | break; |
421 | 421 | ||
422 | if (browser->top_idx < browser->height) | 422 | if (browser->top_idx < browser->rows) |
423 | offset = browser->top_idx; | 423 | offset = browser->top_idx; |
424 | else | 424 | else |
425 | offset = browser->height; | 425 | offset = browser->rows; |
426 | 426 | ||
427 | browser->index -= offset; | 427 | browser->index -= offset; |
428 | browser->top_idx -= offset; | 428 | browser->top_idx -= offset; |
@@ -432,7 +432,7 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs) | |||
432 | ui_browser__reset_index(browser); | 432 | ui_browser__reset_index(browser); |
433 | break; | 433 | break; |
434 | case K_END: | 434 | case K_END: |
435 | offset = browser->height - 1; | 435 | offset = browser->rows - 1; |
436 | if (offset >= browser->nr_entries) | 436 | if (offset >= browser->nr_entries) |
437 | offset = browser->nr_entries - 1; | 437 | offset = browser->nr_entries - 1; |
438 | 438 | ||
@@ -462,7 +462,7 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *browser) | |||
462 | if (!browser->filter || !browser->filter(browser, pos)) { | 462 | if (!browser->filter || !browser->filter(browser, pos)) { |
463 | ui_browser__gotorc(browser, row, 0); | 463 | ui_browser__gotorc(browser, row, 0); |
464 | browser->write(browser, pos, row); | 464 | browser->write(browser, pos, row); |
465 | if (++row == browser->height) | 465 | if (++row == browser->rows) |
466 | break; | 466 | break; |
467 | } | 467 | } |
468 | } | 468 | } |
@@ -587,7 +587,7 @@ unsigned int ui_browser__argv_refresh(struct ui_browser *browser) | |||
587 | if (!browser->filter || !browser->filter(browser, *pos)) { | 587 | if (!browser->filter || !browser->filter(browser, *pos)) { |
588 | ui_browser__gotorc(browser, row, 0); | 588 | ui_browser__gotorc(browser, row, 0); |
589 | browser->write(browser, pos, row); | 589 | browser->write(browser, pos, row); |
590 | if (++row == browser->height) | 590 | if (++row == browser->rows) |
591 | break; | 591 | break; |
592 | } | 592 | } |
593 | 593 | ||
@@ -623,7 +623,7 @@ static void __ui_browser__line_arrow_up(struct ui_browser *browser, | |||
623 | 623 | ||
624 | SLsmg_set_char_set(1); | 624 | SLsmg_set_char_set(1); |
625 | 625 | ||
626 | if (start < browser->top_idx + browser->height) { | 626 | if (start < browser->top_idx + browser->rows) { |
627 | row = start - browser->top_idx; | 627 | row = start - browser->top_idx; |
628 | ui_browser__gotorc(browser, row, column); | 628 | ui_browser__gotorc(browser, row, column); |
629 | SLsmg_write_char(SLSMG_LLCORN_CHAR); | 629 | SLsmg_write_char(SLSMG_LLCORN_CHAR); |
@@ -633,7 +633,7 @@ static void __ui_browser__line_arrow_up(struct ui_browser *browser, | |||
633 | if (row-- == 0) | 633 | if (row-- == 0) |
634 | goto out; | 634 | goto out; |
635 | } else | 635 | } else |
636 | row = browser->height - 1; | 636 | row = browser->rows - 1; |
637 | 637 | ||
638 | if (end > browser->top_idx) | 638 | if (end > browser->top_idx) |
639 | end_row = end - browser->top_idx; | 639 | end_row = end - browser->top_idx; |
@@ -675,8 +675,8 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser, | |||
675 | } else | 675 | } else |
676 | row = 0; | 676 | row = 0; |
677 | 677 | ||
678 | if (end >= browser->top_idx + browser->height) | 678 | if (end >= browser->top_idx + browser->rows) |
679 | end_row = browser->height - 1; | 679 | end_row = browser->rows - 1; |
680 | else | 680 | else |
681 | end_row = end - browser->top_idx; | 681 | end_row = end - browser->top_idx; |
682 | 682 | ||
@@ -684,7 +684,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser, | |||
684 | SLsmg_draw_vline(end_row - row + 1); | 684 | SLsmg_draw_vline(end_row - row + 1); |
685 | 685 | ||
686 | ui_browser__gotorc(browser, end_row, column); | 686 | ui_browser__gotorc(browser, end_row, column); |
687 | if (end < browser->top_idx + browser->height) { | 687 | if (end < browser->top_idx + browser->rows) { |
688 | SLsmg_write_char(SLSMG_LLCORN_CHAR); | 688 | SLsmg_write_char(SLSMG_LLCORN_CHAR); |
689 | ui_browser__gotorc(browser, end_row, column + 1); | 689 | ui_browser__gotorc(browser, end_row, column + 1); |
690 | SLsmg_write_char(SLSMG_HLINE_CHAR); | 690 | SLsmg_write_char(SLSMG_HLINE_CHAR); |