Lines Matching defs:browser
2 #include "../browser.h"
35 static inline struct annotation *browser__annotation(struct ui_browser *browser)
37 struct map_symbol *ms = browser->priv;
41 static bool disasm_line__filter(struct ui_browser *browser, void *entry)
43 struct annotation *notes = browser__annotation(browser);
48 static int ui_browser__jumps_percent_color(struct ui_browser *browser, int nr, bool current)
50 struct annotation *notes = browser__annotation(browser);
52 if (current && (!browser->use_navkeypressed || browser->navkeypressed))
61 static int ui_browser__set_jumps_percent_color(void *browser, int nr, bool current)
63 int color = ui_browser__jumps_percent_color(browser, nr, current);
64 return ui_browser__set_color(browser, color);
67 static int annotate_browser__set_color(void *browser, int color)
69 return ui_browser__set_color(browser, color);
72 static void annotate_browser__write_graph(void *browser, int graph)
74 ui_browser__write_graph(browser, graph);
77 static void annotate_browser__set_percent_color(void *browser, double percent, bool current)
79 ui_browser__set_percent_color(browser, percent, current);
82 static void annotate_browser__printf(void *browser, const char *fmt, ...)
87 ui_browser__vprintf(browser, fmt, args);
91 static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
93 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
94 struct annotation *notes = browser__annotation(browser);
96 const bool is_current_entry = ui_browser__is_current_entry(browser, row);
102 (browser->use_navkeypressed &&
103 !browser->navkeypressed))),
104 .width = browser->width,
105 .obj = browser,
114 if (!browser->navkeypressed)
151 static void annotate_browser__draw_current_jump(struct ui_browser *browser)
153 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
208 ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS);
209 __ui_browser__line_arrow(browser,
215 ui_browser__mark_fused(browser,
221 static unsigned int annotate_browser__refresh(struct ui_browser *browser)
223 struct annotation *notes = browser__annotation(browser);
224 int ret = ui_browser__list_head_refresh(browser);
228 annotate_browser__draw_current_jump(browser);
230 ui_browser__set_color(browser, HE_COLORSET_NORMAL);
231 __ui_browser__vline(browser, pcnt_width, 0, browser->rows - 1);
249 static void disasm_rb_tree__insert(struct annotate_browser *browser,
252 struct rb_root *root = &browser->entries;
261 if (disasm__cmp(al, l, browser->opts->percent_type) < 0)
270 static void annotate_browser__set_top(struct annotate_browser *browser,
273 struct annotation *notes = browser__annotation(&browser->b);
276 ui_browser__refresh_dimensions(&browser->b);
277 back = browser->b.height / 2;
278 browser->b.top_idx = browser->b.index = idx;
280 while (browser->b.top_idx != 0 && back != 0) {
286 --browser->b.top_idx;
290 browser->b.top = pos;
291 browser->b.navkeypressed = true;
294 static void annotate_browser__set_rb_top(struct annotate_browser *browser,
297 struct annotation *notes = browser__annotation(&browser->b);
303 annotate_browser__set_top(browser, pos, idx);
304 browser->curr_hot = nd;
307 static void annotate_browser__calc_percent(struct annotate_browser *browser,
310 struct map_symbol *ms = browser->b.priv;
315 browser->entries = RB_ROOT;
334 browser->opts->percent_type);
344 disasm_rb_tree__insert(browser, &pos->al);
348 browser->curr_hot = rb_last(&browser->entries);
352 struct annotate_browser *browser,
358 list_for_each_entry_continue(it, browser->b.entries, node) {
365 list_for_each_entry_continue_reverse(it, browser->b.entries, node) {
374 static bool annotate_browser__toggle_source(struct annotate_browser *browser)
376 struct annotation *notes = browser__annotation(&browser->b);
378 off_t offset = browser->b.index - browser->b.top_idx;
380 browser->b.seek(&browser->b, offset, SEEK_CUR);
381 al = list_entry(browser->b.top, struct annotation_line, node);
387 browser->b.nr_entries = notes->nr_entries;
389 browser->b.seek(&browser->b, -offset, SEEK_CUR);
390 browser->b.top_idx = al->idx - offset;
391 browser->b.index = al->idx;
395 al = annotate_browser__find_next_asm_line(browser, al);
397 browser->b.seek(&browser->b, -offset, SEEK_CUR);
405 browser->b.nr_entries = notes->nr_asm_entries;
407 browser->b.seek(&browser->b, -offset, SEEK_CUR);
408 browser->b.top_idx = al->idx_asm - offset;
409 browser->b.index = al->idx_asm;
417 static void annotate_browser__show_full_location(struct ui_browser *browser)
419 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
434 static void ui_browser__init_asm_mode(struct ui_browser *browser)
436 struct annotation *notes = browser__annotation(browser);
437 ui_browser__reset_index(browser);
438 browser->nr_entries = notes->nr_asm_entries;
458 static bool annotate_browser__callq(struct annotate_browser *browser,
462 struct map_symbol *ms = browser->b.priv, target_ms;
463 struct disasm_line *dl = disasm_line(browser->selection);
486 symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts);
487 sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
488 ui_browser__show_title(&browser->b, title);
493 struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser,
496 struct annotation *notes = browser__annotation(&browser->b);
510 static bool annotate_browser__jump(struct annotate_browser *browser,
514 struct disasm_line *dl = disasm_line(browser->selection);
522 annotate_browser__callq(browser, evsel, hbt);
527 dl = annotate_browser__find_offset(browser, offset, &idx);
533 annotate_browser__set_top(browser, &dl->al, idx);
539 struct annotation_line *annotate_browser__find_string(struct annotate_browser *browser,
542 struct annotation *notes = browser__annotation(&browser->b);
543 struct annotation_line *al = browser->selection;
545 *idx = browser->b.index;
559 static bool __annotate_browser__search(struct annotate_browser *browser)
564 al = annotate_browser__find_string(browser, browser->search_bf, &idx);
570 annotate_browser__set_top(browser, al, idx);
571 browser->searching_backwards = false;
576 struct annotation_line *annotate_browser__find_string_reverse(struct annotate_browser *browser,
579 struct annotation *notes = browser__annotation(&browser->b);
580 struct annotation_line *al = browser->selection;
582 *idx = browser->b.index;
596 static bool __annotate_browser__search_reverse(struct annotate_browser *browser)
601 al = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx);
607 annotate_browser__set_top(browser, al, idx);
608 browser->searching_backwards = true;
612 static bool annotate_browser__search_window(struct annotate_browser *browser,
615 if (ui_browser__input_window("Search", "String: ", browser->search_bf,
618 !*browser->search_bf)
624 static bool annotate_browser__search(struct annotate_browser *browser, int delay_secs)
626 if (annotate_browser__search_window(browser, delay_secs))
627 return __annotate_browser__search(browser);
632 static bool annotate_browser__continue_search(struct annotate_browser *browser,
635 if (!*browser->search_bf)
636 return annotate_browser__search(browser, delay_secs);
638 return __annotate_browser__search(browser);
641 static bool annotate_browser__search_reverse(struct annotate_browser *browser,
644 if (annotate_browser__search_window(browser, delay_secs))
645 return __annotate_browser__search_reverse(browser);
651 bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
654 if (!*browser->search_bf)
655 return annotate_browser__search_reverse(browser, delay_secs);
657 return __annotate_browser__search_reverse(browser);
660 static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
662 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
663 struct map_symbol *ms = browser->priv;
667 if (ui_browser__show(browser, title, help) < 0)
672 ui_browser__gotorc_title(browser, 0, 0);
673 ui_browser__set_color(browser, HE_COLORSET_ROOT);
674 ui_browser__write_nstring(browser, symbol_dso, browser->width + 1);
711 static int annotate_browser__run(struct annotate_browser *browser,
717 struct map_symbol *ms = browser->b.priv;
726 if (annotate_browser__show(&browser->b, title, help) < 0)
729 annotate_browser__calc_percent(browser, evsel);
731 if (browser->curr_hot) {
732 annotate_browser__set_rb_top(browser, browser->curr_hot);
733 browser->b.navkeypressed = false;
736 nd = browser->curr_hot;
739 key = ui_browser__run(&browser->b, delay_secs);
742 annotate_browser__calc_percent(browser, evsel);
760 annotate_browser__show(&browser->b, title, help);
767 nd = rb_last(&browser->entries);
769 nd = browser->curr_hot;
775 nd = rb_first(&browser->entries);
777 nd = browser->curr_hot;
781 ui_browser__help_window(&browser->b,
809 annotate_browser__show(&browser->b, title, help);
815 annotate_browser__show_full_location (&browser->b);
818 nd = browser->curr_hot;
821 if (annotate_browser__toggle_source(browser))
840 if (annotate_browser__search(browser, delay_secs)) {
846 if (browser->searching_backwards ?
847 annotate_browser__continue_search_reverse(browser, delay_secs) :
848 annotate_browser__continue_search(browser, delay_secs))
852 if (annotate_browser__search_reverse(browser, delay_secs))
859 seq++, browser->b.nr_entries,
860 browser->b.height,
861 browser->b.index,
862 browser->b.top_idx,
869 struct disasm_line *dl = disasm_line(browser->selection);
871 if (browser->selection == NULL)
873 else if (browser->selection->offset == -1)
879 else if (!(annotate_browser__jump(browser, evsel, hbt) ||
880 annotate_browser__callq(browser, evsel, hbt))) {
887 map_symbol__annotation_dump(ms, evsel, browser->opts);
908 switch_percent_type(browser->opts, key == 'b');
910 annotate_browser__show(&browser->b, title, help);
927 annotate_browser__set_rb_top(browser, nd);
930 ui_browser__hide(&browser->b);
958 struct annotate_browser browser = {
982 err = symbol__annotate2(ms, evsel, opts, &browser.arch);
994 browser.b.width = notes->max_line_len;
995 browser.b.nr_entries = notes->nr_entries;
996 browser.b.entries = ¬es->src->source,
997 browser.b.width += 18; /* Percentage */
1000 ui_browser__init_asm_mode(&browser.b);
1002 ret = annotate_browser__run(&browser, evsel, hbt);