Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf ui browser: Optional horizontal scrolling key binding

If the classes derived from ui_browser want to do some sort of
horizontal scrolling, they have just to set ui_browser->columns to
the number of columns available.

Those columns can be the number of characters on the screen, if what is
desired is to scroll character by character, or the number of columns in
a spreadsheet like table.

This is what the hist_browser will do, skipping ui_browser->horiz_scroll
columns when rendering each of its lines.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-q6a22bpmpgcr1awgzrmd4jrs@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+15 -1
+14
tools/perf/ui/browser.c
··· 393 393 394 394 if (browser->use_navkeypressed && !browser->navkeypressed) { 395 395 if (key == K_DOWN || key == K_UP || 396 + (browser->columns && (key == K_LEFT || key == K_RIGHT)) || 396 397 key == K_PGDN || key == K_PGUP || 397 398 key == K_HOME || key == K_END || 398 399 key == ' ') { ··· 421 420 --browser->top_idx; 422 421 browser->seek(browser, -1, SEEK_CUR); 423 422 } 423 + break; 424 + case K_RIGHT: 425 + if (!browser->columns) 426 + goto out; 427 + if (browser->horiz_scroll < browser->columns - 1) 428 + ++browser->horiz_scroll; 429 + break; 430 + case K_LEFT: 431 + if (!browser->columns) 432 + goto out; 433 + if (browser->horiz_scroll != 0) 434 + --browser->horiz_scroll; 424 435 break; 425 436 case K_PGDN: 426 437 case ' ': ··· 472 459 browser->seek(browser, -offset, SEEK_END); 473 460 break; 474 461 default: 462 + out: 475 463 return key; 476 464 } 477 465 }
+1 -1
tools/perf/ui/browser.h
··· 14 14 struct ui_browser { 15 15 u64 index, top_idx; 16 16 void *top, *entries; 17 - u16 y, x, width, height, rows; 17 + u16 y, x, width, height, rows, columns, horiz_scroll; 18 18 int current_color; 19 19 void *priv; 20 20 const char *title;