Lines Matching refs:browser

2 #include "../browser.h"
34 static inline struct annotation *browser__annotation(struct ui_browser *browser)
36 struct map_symbol *ms = browser->priv;
40 static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, void *entry)
46 static int ui_browser__jumps_percent_color(struct ui_browser *browser, int nr, bool current)
48 struct annotation *notes = browser__annotation(browser);
50 if (current && (!browser->use_navkeypressed || browser->navkeypressed))
59 static int ui_browser__set_jumps_percent_color(void *browser, int nr, bool current)
61 int color = ui_browser__jumps_percent_color(browser, nr, current);
62 return ui_browser__set_color(browser, color);
65 static int annotate_browser__set_color(void *browser, int color)
67 return ui_browser__set_color(browser, color);
70 static void annotate_browser__write_graph(void *browser, int graph)
72 ui_browser__write_graph(browser, graph);
75 static void annotate_browser__set_percent_color(void *browser, double percent, bool current)
77 ui_browser__set_percent_color(browser, percent, current);
80 static void annotate_browser__printf(void *browser, const char *fmt, ...)
85 ui_browser__vprintf(browser, fmt, args);
89 static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
91 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
92 struct annotation *notes = browser__annotation(browser);
94 const bool is_current_entry = ui_browser__is_current_entry(browser, row);
100 (browser->use_navkeypressed &&
101 !browser->navkeypressed))),
102 .width = browser->width,
103 .obj = browser,
112 if (!browser->navkeypressed)
149 static void annotate_browser__draw_current_jump(struct ui_browser *browser)
151 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
207 ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS);
208 __ui_browser__line_arrow(browser,
214 ui_browser__mark_fused(browser,
220 static unsigned int annotate_browser__refresh(struct ui_browser *browser)
222 struct annotation *notes = browser__annotation(browser);
223 int ret = ui_browser__list_head_refresh(browser);
227 annotate_browser__draw_current_jump(browser);
229 ui_browser__set_color(browser, HE_COLORSET_NORMAL);
230 __ui_browser__vline(browser, pcnt_width, 0, browser->rows - 1);
248 static void disasm_rb_tree__insert(struct annotate_browser *browser,
251 struct rb_root *root = &browser->entries;
269 static void annotate_browser__set_top(struct annotate_browser *browser,
274 ui_browser__refresh_dimensions(&browser->b);
275 back = browser->b.height / 2;
276 browser->b.top_idx = browser->b.index = idx;
278 while (browser->b.top_idx != 0 && back != 0) {
284 --browser->b.top_idx;
288 browser->b.top = pos;
289 browser->b.navkeypressed = true;
292 static void annotate_browser__set_rb_top(struct annotate_browser *browser,
300 annotate_browser__set_top(browser, pos, idx);
301 browser->curr_hot = nd;
304 static void annotate_browser__calc_percent(struct annotate_browser *browser,
307 struct map_symbol *ms = browser->b.priv;
312 browser->entries = RB_ROOT;
341 disasm_rb_tree__insert(browser, &pos->al);
345 browser->curr_hot = rb_last(&browser->entries);
349 struct annotate_browser *browser,
355 list_for_each_entry_continue(it, browser->b.entries, node) {
362 list_for_each_entry_continue_reverse(it, browser->b.entries, node) {
371 static bool annotate_browser__toggle_source(struct annotate_browser *browser)
373 struct annotation *notes = browser__annotation(&browser->b);
375 off_t offset = browser->b.index - browser->b.top_idx;
377 browser->b.seek(&browser->b, offset, SEEK_CUR);
378 al = list_entry(browser->b.top, struct annotation_line, node);
384 browser->b.nr_entries = notes->src->nr_entries;
386 browser->b.seek(&browser->b, -offset, SEEK_CUR);
387 browser->b.top_idx = al->idx - offset;
388 browser->b.index = al->idx;
392 al = annotate_browser__find_next_asm_line(browser, al);
394 browser->b.seek(&browser->b, -offset, SEEK_CUR);
402 browser->b.nr_entries = notes->src->nr_asm_entries;
404 browser->b.seek(&browser->b, -offset, SEEK_CUR);
405 browser->b.top_idx = al->idx_asm - offset;
406 browser->b.index = al->idx_asm;
414 static void annotate_browser__show_full_location(struct ui_browser *browser)
416 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
431 static void ui_browser__init_asm_mode(struct ui_browser *browser)
433 struct annotation *notes = browser__annotation(browser);
434 ui_browser__reset_index(browser);
435 browser->nr_entries = notes->src->nr_asm_entries;
455 static bool annotate_browser__callq(struct annotate_browser *browser,
459 struct map_symbol *ms = browser->b.priv, target_ms;
460 struct disasm_line *dl = disasm_line(browser->selection);
485 ui_browser__show_title(&browser->b, title);
490 struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser,
493 struct annotation *notes = browser__annotation(&browser->b);
507 static bool annotate_browser__jump(struct annotate_browser *browser,
511 struct disasm_line *dl = disasm_line(browser->selection);
519 annotate_browser__callq(browser, evsel, hbt);
524 dl = annotate_browser__find_offset(browser, offset, &idx);
530 annotate_browser__set_top(browser, &dl->al, idx);
536 struct annotation_line *annotate_browser__find_string(struct annotate_browser *browser,
539 struct annotation *notes = browser__annotation(&browser->b);
540 struct annotation_line *al = browser->selection;
542 *idx = browser->b.index;
556 static bool __annotate_browser__search(struct annotate_browser *browser)
561 al = annotate_browser__find_string(browser, browser->search_bf, &idx);
567 annotate_browser__set_top(browser, al, idx);
568 browser->searching_backwards = false;
573 struct annotation_line *annotate_browser__find_string_reverse(struct annotate_browser *browser,
576 struct annotation *notes = browser__annotation(&browser->b);
577 struct annotation_line *al = browser->selection;
579 *idx = browser->b.index;
593 static bool __annotate_browser__search_reverse(struct annotate_browser *browser)
598 al = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx);
604 annotate_browser__set_top(browser, al, idx);
605 browser->searching_backwards = true;
609 static bool annotate_browser__search_window(struct annotate_browser *browser,
612 if (ui_browser__input_window("Search", "String: ", browser->search_bf,
615 !*browser->search_bf)
621 static bool annotate_browser__search(struct annotate_browser *browser, int delay_secs)
623 if (annotate_browser__search_window(browser, delay_secs))
624 return __annotate_browser__search(browser);
629 static bool annotate_browser__continue_search(struct annotate_browser *browser,
632 if (!*browser->search_bf)
633 return annotate_browser__search(browser, delay_secs);
635 return __annotate_browser__search(browser);
638 static bool annotate_browser__search_reverse(struct annotate_browser *browser,
641 if (annotate_browser__search_window(browser, delay_secs))
642 return __annotate_browser__search_reverse(browser);
648 bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
651 if (!*browser->search_bf)
652 return annotate_browser__search_reverse(browser, delay_secs);
654 return __annotate_browser__search_reverse(browser);
657 static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
659 struct map_symbol *ms = browser->priv;
663 if (ui_browser__show(browser, title, help) < 0)
668 ui_browser__gotorc_title(browser, 0, 0);
669 ui_browser__set_color(browser, HE_COLORSET_ROOT);
670 ui_browser__write_nstring(browser, symbol_dso, browser->width + 1);
707 static int annotate_browser__run(struct annotate_browser *browser,
713 struct map_symbol *ms = browser->b.priv;
723 if (annotate_browser__show(&browser->b, title, help) < 0)
726 annotate_browser__calc_percent(browser, evsel);
728 if (browser->curr_hot) {
729 annotate_browser__set_rb_top(browser, browser->curr_hot);
730 browser->b.navkeypressed = false;
733 nd = browser->curr_hot;
738 key = ui_browser__run(&browser->b, delay_secs);
741 annotate_browser__calc_percent(browser, evsel);
759 annotate_browser__show(&browser->b, title, help);
766 nd = rb_last(&browser->entries);
768 nd = browser->curr_hot;
774 nd = rb_first(&browser->entries);
776 nd = browser->curr_hot;
780 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))) {
910 annotate_browser__show(&browser->b, title, help);
914 ui_browser__help_window(&browser->b, br_cntr_text);
916 ui_browser__help_window(&browser->b,
935 annotate_browser__set_rb_top(browser, nd);
938 ui_browser__hide(&browser->b);
965 struct annotate_browser browser = {
988 err = symbol__annotate2(ms, evsel, &browser.arch);
1000 browser.b.width = notes->src->widths.max_line_len;
1001 browser.b.nr_entries = notes->src->nr_entries;
1002 browser.b.entries = &notes->src->source;
1003 browser.b.width += 18; /* Percentage */
1006 ui_browser__init_asm_mode(&browser.b);
1008 ret = annotate_browser__run(&browser, evsel, hbt);