Lines Matching defs:browser
2 #include "../browser.h"
40 static inline struct annotation *browser__annotation(struct ui_browser *browser)
42 struct map_symbol *ms = browser->priv;
46 static bool disasm_line__filter(struct ui_browser *browser, void *entry)
48 struct annotation *notes = browser__annotation(browser);
53 static int ui_browser__jumps_percent_color(struct ui_browser *browser, int nr, bool current)
55 struct annotation *notes = browser__annotation(browser);
57 if (current && (!browser->use_navkeypressed || browser->navkeypressed))
66 static int ui_browser__set_jumps_percent_color(void *browser, int nr, bool current)
68 int color = ui_browser__jumps_percent_color(browser, nr, current);
69 return ui_browser__set_color(browser, color);
72 static int annotate_browser__set_color(void *browser, int color)
74 return ui_browser__set_color(browser, color);
77 static void annotate_browser__write_graph(void *browser, int graph)
79 ui_browser__write_graph(browser, graph);
82 static void annotate_browser__set_percent_color(void *browser, double percent, bool current)
84 ui_browser__set_percent_color(browser, percent, current);
87 static void annotate_browser__printf(void *browser, const char *fmt, ...)
92 ui_browser__vprintf(browser, fmt, args);
96 static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
98 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
99 struct annotation *notes = browser__annotation(browser);
101 const bool is_current_entry = ui_browser__is_current_entry(browser, row);
107 (browser->use_navkeypressed &&
108 !browser->navkeypressed))),
109 .width = browser->width,
110 .obj = browser,
119 if (!browser->navkeypressed)
147 static void annotate_browser__draw_current_jump(struct ui_browser *browser)
149 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
203 ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS);
204 __ui_browser__line_arrow(browser,
209 ui_browser__mark_fused(browser,
216 static unsigned int annotate_browser__refresh(struct ui_browser *browser)
218 struct annotation *notes = browser__annotation(browser);
219 int ret = ui_browser__list_head_refresh(browser);
223 annotate_browser__draw_current_jump(browser);
225 ui_browser__set_color(browser, HE_COLORSET_NORMAL);
226 __ui_browser__vline(browser, pcnt_width, 0, browser->rows - 1);
244 static void disasm_rb_tree__insert(struct annotate_browser *browser,
247 struct rb_root *root = &browser->entries;
256 if (disasm__cmp(al, l, browser->opts->percent_type) < 0)
265 static void annotate_browser__set_top(struct annotate_browser *browser,
268 struct annotation *notes = browser__annotation(&browser->b);
271 ui_browser__refresh_dimensions(&browser->b);
272 back = browser->b.height / 2;
273 browser->b.top_idx = browser->b.index = idx;
275 while (browser->b.top_idx != 0 && back != 0) {
281 --browser->b.top_idx;
285 browser->b.top = pos;
286 browser->b.navkeypressed = true;
289 static void annotate_browser__set_rb_top(struct annotate_browser *browser,
292 struct annotation *notes = browser__annotation(&browser->b);
298 annotate_browser__set_top(browser, pos, idx);
299 browser->curr_hot = nd;
302 static void annotate_browser__calc_percent(struct annotate_browser *browser,
305 struct map_symbol *ms = browser->b.priv;
310 browser->entries = RB_ROOT;
329 browser->opts->percent_type);
339 disasm_rb_tree__insert(browser, &pos->al);
343 browser->curr_hot = rb_last(&browser->entries);
346 static bool annotate_browser__toggle_source(struct annotate_browser *browser)
348 struct annotation *notes = browser__annotation(&browser->b);
350 off_t offset = browser->b.index - browser->b.top_idx;
352 browser->b.seek(&browser->b, offset, SEEK_CUR);
353 al = list_entry(browser->b.top, struct annotation_line, node);
359 browser->b.nr_entries = notes->nr_entries;
361 browser->b.seek(&browser->b, -offset, SEEK_CUR);
362 browser->b.top_idx = al->idx - offset;
363 browser->b.index = al->idx;
367 browser->b.seek(&browser->b, -offset, SEEK_CUR);
374 browser->b.nr_entries = notes->nr_asm_entries;
376 browser->b.seek(&browser->b, -offset, SEEK_CUR);
377 browser->b.top_idx = al->idx_asm - offset;
378 browser->b.index = al->idx_asm;
384 static void ui_browser__init_asm_mode(struct ui_browser *browser)
386 struct annotation *notes = browser__annotation(browser);
387 ui_browser__reset_index(browser);
388 browser->nr_entries = notes->nr_asm_entries;
409 static bool annotate_browser__callq(struct annotate_browser *browser,
413 struct map_symbol *ms = browser->b.priv, target_ms;
414 struct disasm_line *dl = disasm_line(browser->selection);
437 symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts);
438 sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
439 ui_browser__show_title(&browser->b, title);
444 struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser,
447 struct annotation *notes = browser__annotation(&browser->b);
461 static bool annotate_browser__jump(struct annotate_browser *browser,
465 struct disasm_line *dl = disasm_line(browser->selection);
473 annotate_browser__callq(browser, evsel, hbt);
478 dl = annotate_browser__find_offset(browser, offset, &idx);
484 annotate_browser__set_top(browser, &dl->al, idx);
490 struct annotation_line *annotate_browser__find_string(struct annotate_browser *browser,
493 struct annotation *notes = browser__annotation(&browser->b);
494 struct annotation_line *al = browser->selection;
496 *idx = browser->b.index;
510 static bool __annotate_browser__search(struct annotate_browser *browser)
515 al = annotate_browser__find_string(browser, browser->search_bf, &idx);
521 annotate_browser__set_top(browser, al, idx);
522 browser->searching_backwards = false;
527 struct annotation_line *annotate_browser__find_string_reverse(struct annotate_browser *browser,
530 struct annotation *notes = browser__annotation(&browser->b);
531 struct annotation_line *al = browser->selection;
533 *idx = browser->b.index;
547 static bool __annotate_browser__search_reverse(struct annotate_browser *browser)
552 al = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx);
558 annotate_browser__set_top(browser, al, idx);
559 browser->searching_backwards = true;
563 static bool annotate_browser__search_window(struct annotate_browser *browser,
566 if (ui_browser__input_window("Search", "String: ", browser->search_bf,
569 !*browser->search_bf)
575 static bool annotate_browser__search(struct annotate_browser *browser, int delay_secs)
577 if (annotate_browser__search_window(browser, delay_secs))
578 return __annotate_browser__search(browser);
583 static bool annotate_browser__continue_search(struct annotate_browser *browser,
586 if (!*browser->search_bf)
587 return annotate_browser__search(browser, delay_secs);
589 return __annotate_browser__search(browser);
592 static bool annotate_browser__search_reverse(struct annotate_browser *browser,
595 if (annotate_browser__search_window(browser, delay_secs))
596 return __annotate_browser__search_reverse(browser);
602 bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
605 if (!*browser->search_bf)
606 return annotate_browser__search_reverse(browser, delay_secs);
608 return __annotate_browser__search_reverse(browser);
611 static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
613 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
614 struct map_symbol *ms = browser->priv;
618 if (ui_browser__show(browser, title, help) < 0)
623 ui_browser__gotorc_title(browser, 0, 0);
624 ui_browser__set_color(browser, HE_COLORSET_ROOT);
625 ui_browser__write_nstring(browser, symbol_dso, browser->width + 1);
662 static int annotate_browser__run(struct annotate_browser *browser,
668 struct map_symbol *ms = browser->b.priv;
677 if (annotate_browser__show(&browser->b, title, help) < 0)
680 annotate_browser__calc_percent(browser, evsel);
682 if (browser->curr_hot) {
683 annotate_browser__set_rb_top(browser, browser->curr_hot);
684 browser->b.navkeypressed = false;
687 nd = browser->curr_hot;
690 key = ui_browser__run(&browser->b, delay_secs);
693 annotate_browser__calc_percent(browser, evsel);
711 annotate_browser__show(&browser->b, title, help);
718 nd = rb_last(&browser->entries);
720 nd = browser->curr_hot;
726 nd = rb_first(&browser->entries);
728 nd = browser->curr_hot;
732 ui_browser__help_window(&browser->b,
758 annotate_browser__show(&browser->b, title, help);
764 nd = browser->curr_hot;
767 if (annotate_browser__toggle_source(browser))
786 if (annotate_browser__search(browser, delay_secs)) {
792 if (browser->searching_backwards ?
793 annotate_browser__continue_search_reverse(browser, delay_secs) :
794 annotate_browser__continue_search(browser, delay_secs))
798 if (annotate_browser__search_reverse(browser, delay_secs))
805 seq++, browser->b.nr_entries,
806 browser->b.height,
807 browser->b.index,
808 browser->b.top_idx,
815 struct disasm_line *dl = disasm_line(browser->selection);
817 if (browser->selection == NULL)
819 else if (browser->selection->offset == -1)
825 else if (!(annotate_browser__jump(browser, evsel, hbt) ||
826 annotate_browser__callq(browser, evsel, hbt))) {
833 map_symbol__annotation_dump(ms, evsel, browser->opts);
854 switch_percent_type(browser->opts, key == 'b');
856 annotate_browser__show(&browser->b, title, help);
868 annotate_browser__set_rb_top(browser, nd);
871 ui_browser__hide(&browser->b);
899 struct annotate_browser browser = {
919 err = symbol__annotate2(ms, evsel, opts, &browser.arch);
929 browser.b.width = notes->max_line_len;
930 browser.b.nr_entries = notes->nr_entries;
931 browser.b.entries = ¬es->src->source,
932 browser.b.width += 18; /* Percentage */
935 ui_browser__init_asm_mode(&browser.b);
937 ret = annotate_browser__run(&browser, evsel, hbt);