Lines Matching refs:browser
20 static int ui_browser__percent_color(struct ui_browser *browser, in ui_browser__percent_color() argument
23 if (current && (!browser->use_navkeypressed || browser->navkeypressed)) in ui_browser__percent_color()
32 int ui_browser__set_color(struct ui_browser *browser, int color) in ui_browser__set_color() argument
34 int ret = browser->current_color; in ui_browser__set_color()
35 browser->current_color = color; in ui_browser__set_color()
40 void ui_browser__set_percent_color(struct ui_browser *browser, in ui_browser__set_percent_color() argument
43 int color = ui_browser__percent_color(browser, percent, current); in ui_browser__set_percent_color()
44 ui_browser__set_color(browser, color); in ui_browser__set_percent_color()
47 void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x) in ui_browser__gotorc_title() argument
49 SLsmg_gotorc(browser->y + y, browser->x + x); in ui_browser__gotorc_title()
52 void ui_browser__gotorc(struct ui_browser *browser, int y, int x) in ui_browser__gotorc() argument
54 SLsmg_gotorc(browser->y + y + browser->extra_title_lines, browser->x + x); in ui_browser__gotorc()
57 void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, const char *msg, in ui_browser__write_nstring()
63 void ui_browser__vprintf(struct ui_browser *browser __maybe_unused, const char *fmt, va_list args) in ui_browser__vprintf()
68 void ui_browser__printf(struct ui_browser *browser __maybe_unused, const char *fmt, ...) in ui_browser__printf()
73 ui_browser__vprintf(browser, fmt, args); in ui_browser__printf()
78 ui_browser__list_head_filter_entries(struct ui_browser *browser, in ui_browser__list_head_filter_entries() argument
82 if (!browser->filter || !browser->filter(browser, pos)) in ui_browser__list_head_filter_entries()
85 } while (pos != browser->entries); in ui_browser__list_head_filter_entries()
91 ui_browser__list_head_filter_prev_entries(struct ui_browser *browser, in ui_browser__list_head_filter_prev_entries() argument
95 if (!browser->filter || !browser->filter(browser, pos)) in ui_browser__list_head_filter_prev_entries()
98 } while (pos != browser->entries); in ui_browser__list_head_filter_prev_entries()
103 void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence) in ui_browser__list_head_seek() argument
105 struct list_head *head = browser->entries; in ui_browser__list_head_seek()
108 if (browser->nr_entries == 0) in ui_browser__list_head_seek()
113 pos = ui_browser__list_head_filter_entries(browser, head->next); in ui_browser__list_head_seek()
116 pos = browser->top; in ui_browser__list_head_seek()
119 pos = ui_browser__list_head_filter_prev_entries(browser, head->prev); in ui_browser__list_head_seek()
129 pos = ui_browser__list_head_filter_entries(browser, pos->next); in ui_browser__list_head_seek()
132 pos = ui_browser__list_head_filter_prev_entries(browser, pos->prev); in ui_browser__list_head_seek()
135 browser->top = pos; in ui_browser__list_head_seek()
138 void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence) in ui_browser__rb_tree_seek() argument
140 struct rb_root *root = browser->entries; in ui_browser__rb_tree_seek()
148 nd = browser->top; in ui_browser__rb_tree_seek()
165 browser->top = nd; in ui_browser__rb_tree_seek()
168 unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser) in ui_browser__rb_tree_refresh() argument
173 if (browser->top == NULL) in ui_browser__rb_tree_refresh()
174 browser->top = rb_first(browser->entries); in ui_browser__rb_tree_refresh()
176 nd = browser->top; in ui_browser__rb_tree_refresh()
179 ui_browser__gotorc(browser, row, 0); in ui_browser__rb_tree_refresh()
180 browser->write(browser, nd, row); in ui_browser__rb_tree_refresh()
181 if (++row == browser->rows) in ui_browser__rb_tree_refresh()
189 bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row) in ui_browser__is_current_entry() argument
191 return browser->top_idx + row == browser->index; in ui_browser__is_current_entry()
194 void ui_browser__refresh_dimensions(struct ui_browser *browser) in ui_browser__refresh_dimensions() argument
196 browser->width = SLtt_Screen_Cols - 1; in ui_browser__refresh_dimensions()
197 browser->height = browser->rows = SLtt_Screen_Rows - 2; in ui_browser__refresh_dimensions()
198 browser->rows -= browser->extra_title_lines; in ui_browser__refresh_dimensions()
199 browser->y = 1; in ui_browser__refresh_dimensions()
200 browser->x = 0; in ui_browser__refresh_dimensions()
203 void ui_browser__handle_resize(struct ui_browser *browser) in ui_browser__handle_resize() argument
206 ui_browser__show(browser, browser->title, ui_helpline__current); in ui_browser__handle_resize()
207 ui_browser__refresh(browser); in ui_browser__handle_resize()
210 int ui_browser__warning(struct ui_browser *browser, int timeout, in ui_browser__warning() argument
229 ui_browser__handle_resize(browser); in ui_browser__warning()
236 int ui_browser__help_window(struct ui_browser *browser, const char *text) in ui_browser__help_window() argument
241 ui_browser__handle_resize(browser); in ui_browser__help_window()
246 bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text) in ui_browser__dialog_yesno() argument
251 ui_browser__handle_resize(browser); in ui_browser__dialog_yesno()
256 void ui_browser__reset_index(struct ui_browser *browser) in ui_browser__reset_index() argument
258 browser->index = browser->top_idx = 0; in ui_browser__reset_index()
259 browser->seek(browser, 0, SEEK_SET); in ui_browser__reset_index()
262 void __ui_browser__show_title(struct ui_browser *browser, const char *title) in __ui_browser__show_title() argument
265 ui_browser__set_color(browser, HE_COLORSET_ROOT); in __ui_browser__show_title()
266 ui_browser__write_nstring(browser, title, browser->width + 1); in __ui_browser__show_title()
269 void ui_browser__show_title(struct ui_browser *browser, const char *title) in ui_browser__show_title() argument
272 __ui_browser__show_title(browser, title); in ui_browser__show_title()
276 int ui_browser__show(struct ui_browser *browser, const char *title, in ui_browser__show() argument
282 if (browser->refresh_dimensions == NULL) in ui_browser__show()
283 browser->refresh_dimensions = ui_browser__refresh_dimensions; in ui_browser__show()
285 browser->refresh_dimensions(browser); in ui_browser__show()
288 __ui_browser__show_title(browser, title); in ui_browser__show()
290 browser->title = title; in ui_browser__show()
291 zfree(&browser->helpline); in ui_browser__show()
294 err = vasprintf(&browser->helpline, helpline, ap); in ui_browser__show()
297 ui_helpline__push(browser->helpline); in ui_browser__show()
302 void ui_browser__hide(struct ui_browser *browser) in ui_browser__hide() argument
306 zfree(&browser->helpline); in ui_browser__hide()
310 static void ui_browser__scrollbar_set(struct ui_browser *browser) in ui_browser__scrollbar_set() argument
312 int height = browser->height, h = 0, pct = 0, in ui_browser__scrollbar_set()
313 col = browser->width, in ui_browser__scrollbar_set()
316 if (browser->nr_entries > 1) { in ui_browser__scrollbar_set()
317 pct = ((browser->index * (browser->height - 1)) / in ui_browser__scrollbar_set()
318 (browser->nr_entries - 1)); in ui_browser__scrollbar_set()
324 ui_browser__gotorc(browser, row++, col); in ui_browser__scrollbar_set()
332 static int __ui_browser__refresh(struct ui_browser *browser) in __ui_browser__refresh() argument
335 int width = browser->width; in __ui_browser__refresh()
337 row = browser->refresh(browser); in __ui_browser__refresh()
338 ui_browser__set_color(browser, HE_COLORSET_NORMAL); in __ui_browser__refresh()
340 if (!browser->use_navkeypressed || browser->navkeypressed) in __ui_browser__refresh()
341 ui_browser__scrollbar_set(browser); in __ui_browser__refresh()
345 SLsmg_fill_region(browser->y + row + browser->extra_title_lines, browser->x, in __ui_browser__refresh()
346 browser->rows - row, width, ' '); in __ui_browser__refresh()
348 if (browser->nr_entries == 0 && browser->no_samples_msg) in __ui_browser__refresh()
349 __ui__info_window(NULL, browser->no_samples_msg, NULL); in __ui_browser__refresh()
353 int ui_browser__refresh(struct ui_browser *browser) in ui_browser__refresh() argument
356 __ui_browser__refresh(browser); in ui_browser__refresh()
368 void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries) in ui_browser__update_nr_entries() argument
370 off_t offset = nr_entries - browser->nr_entries; in ui_browser__update_nr_entries()
372 browser->nr_entries = nr_entries; in ui_browser__update_nr_entries()
375 if (browser->top_idx < (u64)-offset) in ui_browser__update_nr_entries()
376 offset = -browser->top_idx; in ui_browser__update_nr_entries()
378 browser->index += offset; in ui_browser__update_nr_entries()
379 browser->top_idx += offset; in ui_browser__update_nr_entries()
382 browser->top = NULL; in ui_browser__update_nr_entries()
383 browser->seek(browser, browser->top_idx, SEEK_SET); in ui_browser__update_nr_entries()
386 int ui_browser__run(struct ui_browser *browser, int delay_secs) in ui_browser__run() argument
394 err = __ui_browser__refresh(browser); in ui_browser__run()
404 browser->refresh_dimensions(browser); in ui_browser__run()
405 __ui_browser__show_title(browser, browser->title); in ui_browser__run()
406 ui_helpline__puts(browser->helpline); in ui_browser__run()
410 if (browser->use_navkeypressed && !browser->navkeypressed) { in ui_browser__run()
412 (browser->columns && (key == K_LEFT || key == K_RIGHT)) || in ui_browser__run()
416 browser->navkeypressed = true; in ui_browser__run()
424 if (browser->index == browser->nr_entries - 1) in ui_browser__run()
426 ++browser->index; in ui_browser__run()
427 if (browser->index == browser->top_idx + browser->rows) { in ui_browser__run()
428 ++browser->top_idx; in ui_browser__run()
429 browser->seek(browser, +1, SEEK_CUR); in ui_browser__run()
433 if (browser->index == 0) in ui_browser__run()
435 --browser->index; in ui_browser__run()
436 if (browser->index < browser->top_idx) { in ui_browser__run()
437 --browser->top_idx; in ui_browser__run()
438 browser->seek(browser, -1, SEEK_CUR); in ui_browser__run()
442 if (!browser->columns) in ui_browser__run()
444 if (browser->horiz_scroll < browser->columns - 1) in ui_browser__run()
445 ++browser->horiz_scroll; in ui_browser__run()
448 if (!browser->columns) in ui_browser__run()
450 if (browser->horiz_scroll != 0) in ui_browser__run()
451 --browser->horiz_scroll; in ui_browser__run()
455 if (browser->top_idx + browser->rows > browser->nr_entries - 1) in ui_browser__run()
458 offset = browser->rows; in ui_browser__run()
459 if (browser->index + offset > browser->nr_entries - 1) in ui_browser__run()
460 offset = browser->nr_entries - 1 - browser->index; in ui_browser__run()
461 browser->index += offset; in ui_browser__run()
462 browser->top_idx += offset; in ui_browser__run()
463 browser->seek(browser, +offset, SEEK_CUR); in ui_browser__run()
466 if (browser->top_idx == 0) in ui_browser__run()
469 if (browser->top_idx < browser->rows) in ui_browser__run()
470 offset = browser->top_idx; in ui_browser__run()
472 offset = browser->rows; in ui_browser__run()
474 browser->index -= offset; in ui_browser__run()
475 browser->top_idx -= offset; in ui_browser__run()
476 browser->seek(browser, -offset, SEEK_CUR); in ui_browser__run()
479 ui_browser__reset_index(browser); in ui_browser__run()
482 offset = browser->rows - 1; in ui_browser__run()
483 if (offset >= browser->nr_entries) in ui_browser__run()
484 offset = browser->nr_entries - 1; in ui_browser__run()
486 browser->index = browser->nr_entries - 1; in ui_browser__run()
487 browser->top_idx = browser->index - offset; in ui_browser__run()
488 browser->seek(browser, -offset, SEEK_END); in ui_browser__run()
498 unsigned int ui_browser__list_head_refresh(struct ui_browser *browser) in ui_browser__list_head_refresh() argument
501 struct list_head *head = browser->entries; in ui_browser__list_head_refresh()
504 if (browser->top == NULL || browser->top == browser->entries) in ui_browser__list_head_refresh()
505 browser->top = ui_browser__list_head_filter_entries(browser, head->next); in ui_browser__list_head_refresh()
507 pos = browser->top; in ui_browser__list_head_refresh()
510 if (!browser->filter || !browser->filter(browser, pos)) { in ui_browser__list_head_refresh()
511 ui_browser__gotorc(browser, row, 0); in ui_browser__list_head_refresh()
512 browser->write(browser, pos, row); in ui_browser__list_head_refresh()
513 if (++row == browser->rows) in ui_browser__list_head_refresh()
608 void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence) in ui_browser__argv_seek() argument
612 browser->top = browser->entries; in ui_browser__argv_seek()
615 browser->top = (char **)browser->top + offset; in ui_browser__argv_seek()
618 browser->top = (char **)browser->entries + browser->nr_entries - 1 + offset; in ui_browser__argv_seek()
623 assert((char **)browser->top < (char **)browser->entries + browser->nr_entries); in ui_browser__argv_seek()
624 assert((char **)browser->top >= (char **)browser->entries); in ui_browser__argv_seek()
627 unsigned int ui_browser__argv_refresh(struct ui_browser *browser) in ui_browser__argv_refresh() argument
629 unsigned int row = 0, idx = browser->top_idx; in ui_browser__argv_refresh()
632 if (browser->top == NULL) in ui_browser__argv_refresh()
633 browser->top = browser->entries; in ui_browser__argv_refresh()
635 pos = (char **)browser->top; in ui_browser__argv_refresh()
636 while (idx < browser->nr_entries && in ui_browser__argv_refresh()
638 assert(pos < (char **)browser->entries + browser->nr_entries); in ui_browser__argv_refresh()
639 if (!browser->filter || !browser->filter(browser, *pos)) { in ui_browser__argv_refresh()
640 ui_browser__gotorc(browser, row, 0); in ui_browser__argv_refresh()
641 browser->write(browser, pos, row); in ui_browser__argv_refresh()
642 if (++row == browser->rows) in ui_browser__argv_refresh()
653 void __ui_browser__vline(struct ui_browser *browser, unsigned int column, in __ui_browser__vline() argument
657 ui_browser__gotorc(browser, start, column); in __ui_browser__vline()
662 void ui_browser__write_graph(struct ui_browser *browser __maybe_unused, in ui_browser__write_graph()
670 static void __ui_browser__line_arrow_up(struct ui_browser *browser, in __ui_browser__line_arrow_up() argument
678 if (start < browser->top_idx + browser->rows) { in __ui_browser__line_arrow_up()
679 row = start - browser->top_idx; in __ui_browser__line_arrow_up()
680 ui_browser__gotorc(browser, row, column); in __ui_browser__line_arrow_up()
682 ui_browser__gotorc(browser, row, column + 1); in __ui_browser__line_arrow_up()
688 row = browser->rows - 1; in __ui_browser__line_arrow_up()
690 if (end > browser->top_idx) in __ui_browser__line_arrow_up()
691 end_row = end - browser->top_idx; in __ui_browser__line_arrow_up()
695 ui_browser__gotorc(browser, end_row, column); in __ui_browser__line_arrow_up()
698 ui_browser__gotorc(browser, end_row, column); in __ui_browser__line_arrow_up()
699 if (end >= browser->top_idx) { in __ui_browser__line_arrow_up()
701 ui_browser__gotorc(browser, end_row, column + 1); in __ui_browser__line_arrow_up()
703 ui_browser__gotorc(browser, end_row, column + 2); in __ui_browser__line_arrow_up()
710 static void __ui_browser__line_arrow_down(struct ui_browser *browser, in __ui_browser__line_arrow_down() argument
718 if (start >= browser->top_idx) { in __ui_browser__line_arrow_down()
719 row = start - browser->top_idx; in __ui_browser__line_arrow_down()
720 ui_browser__gotorc(browser, row, column); in __ui_browser__line_arrow_down()
722 ui_browser__gotorc(browser, row, column + 1); in __ui_browser__line_arrow_down()
730 if (end >= browser->top_idx + browser->rows) in __ui_browser__line_arrow_down()
731 end_row = browser->rows - 1; in __ui_browser__line_arrow_down()
733 end_row = end - browser->top_idx; in __ui_browser__line_arrow_down()
735 ui_browser__gotorc(browser, row, column); in __ui_browser__line_arrow_down()
738 ui_browser__gotorc(browser, end_row, column); in __ui_browser__line_arrow_down()
739 if (end < browser->top_idx + browser->rows) { in __ui_browser__line_arrow_down()
741 ui_browser__gotorc(browser, end_row, column + 1); in __ui_browser__line_arrow_down()
743 ui_browser__gotorc(browser, end_row, column + 2); in __ui_browser__line_arrow_down()
750 void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, in __ui_browser__line_arrow() argument
754 __ui_browser__line_arrow_up(browser, column, start, end); in __ui_browser__line_arrow()
756 __ui_browser__line_arrow_down(browser, column, start, end); in __ui_browser__line_arrow()
759 void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column, in ui_browser__mark_fused() argument
770 if (row + diff <= browser->top_idx) in ui_browser__mark_fused()
773 end_row = row + diff - browser->top_idx; in ui_browser__mark_fused()
774 ui_browser__gotorc(browser, end_row, column - 1); in ui_browser__mark_fused()
777 while (--end_row >= 0 && end_row > (int)(row - browser->top_idx)) { in ui_browser__mark_fused()
778 ui_browser__gotorc(browser, end_row, column - 1); in ui_browser__mark_fused()
782 end_row = (int)(row - browser->top_idx); in ui_browser__mark_fused()
784 ui_browser__gotorc(browser, end_row, column - 1); in ui_browser__mark_fused()
786 ui_browser__gotorc(browser, end_row, column); in ui_browser__mark_fused()
790 if (row < browser->top_idx) in ui_browser__mark_fused()
793 end_row = row - browser->top_idx; in ui_browser__mark_fused()
794 ui_browser__gotorc(browser, end_row, column - 1); in ui_browser__mark_fused()
796 ui_browser__gotorc(browser, end_row, column); in ui_browser__mark_fused()