3 #include "../string2.h" 5 #include "../../perf.h" 9 #include <linux/compiler.h> 10 #include <linux/list.h> 11 #include <linux/rbtree.h> 12 #include <linux/string.h> 14 #include <sys/ttydefaults.h> 37 SLsmg_set_color(color);
50 SLsmg_gotorc(browser->
y + y, browser->
x + x);
78 static struct list_head *
80 struct list_head *pos)
86 }
while (pos != browser->
entries);
91 static struct list_head *
93 struct list_head *pos)
99 }
while (pos != browser->
entries);
106 struct list_head *head = browser->
entries;
107 struct list_head *pos;
129 while (offset-- != 0)
132 while (offset++ != 0)
159 while (offset-- != 0)
162 while (offset++ != 0)
174 if (browser->
top == NULL)
181 browser->
write(browser, nd, row);
182 if (++row == browser->
rows)
197 browser->
width = SLtt_Screen_Cols - 1;
198 browser->
height = browser->
rows = SLtt_Screen_Rows - 2;
212 const char *format, ...)
218 va_start(args, format);
219 err = vasprintf(&text, format, args);
223 va_start(args, format);
260 browser->
seek(browser, 0, SEEK_SET);
278 const char *helpline, ...)
291 browser->
title = title;
294 va_start(ap, helpline);
295 err = vasprintf(&browser->
helpline, helpline, ap);
313 int height = browser->
height, h = 0, pct = 0,
314 col = browser->
width,
322 SLsmg_set_char_set(1);
326 SLsmg_write_char(h == pct ? SLSMG_DIAMOND_CHAR : SLSMG_CKBRD_CHAR);
330 SLsmg_set_char_set(0);
336 int width = browser->
width;
338 row = browser->
refresh(browser);
347 browser->
rows - row, width,
' ');
369 off_t offset = nr_entries - browser->
nr_entries;
374 if (browser->
top_idx < (u64)-offset)
377 browser->
index += offset;
382 browser->
seek(browser, browser->
top_idx, SEEK_SET);
428 browser->
seek(browser, +1, SEEK_CUR);
432 if (browser->
index == 0)
437 browser->
seek(browser, -1, SEEK_CUR);
457 offset = browser->
rows;
460 browser->
index += offset;
462 browser->
seek(browser, +offset, SEEK_CUR);
471 offset = browser->
rows;
473 browser->
index -= offset;
475 browser->
seek(browser, -offset, SEEK_CUR);
481 offset = browser->
rows - 1;
487 browser->
seek(browser, -offset, SEEK_END);
499 struct list_head *pos;
500 struct list_head *head = browser->
entries;
503 if (browser->
top == NULL || browser->
top == browser->
entries)
508 list_for_each_from(pos, head) {
509 if (!browser->
filter || !browser->
filter(browser, pos)) {
511 browser->
write(browser, pos, row);
512 if (++row == browser->
rows)
550 .name =
"jump_arrows",
573 void *
data __maybe_unused)
575 char *
fg = NULL, *
bg;
579 if (!strstarts(var,
"colors.") != 0)
583 const char *
name = var + 7;
592 bg = strchr(fg,
',');
626 unsigned int row = 0, idx = browser->
top_idx;
629 if (browser->
top == NULL)
632 pos = (
char **)browser->
top;
633 while (idx < browser->nr_entries) {
634 if (!browser->
filter || !browser->
filter(browser, *pos)) {
636 browser->
write(browser, pos, row);
637 if (++row == browser->
rows)
651 SLsmg_set_char_set(1);
653 SLsmg_draw_vline(end - start + 1);
654 SLsmg_set_char_set(0);
660 SLsmg_set_char_set(1);
661 SLsmg_write_char(graph);
662 SLsmg_set_char_set(0);
669 unsigned int row, end_row;
671 SLsmg_set_char_set(1);
673 if (start < browser->top_idx + browser->
rows) {
674 row = start - browser->
top_idx;
676 SLsmg_write_char(SLSMG_LLCORN_CHAR);
683 row = browser->
rows - 1;
686 end_row = end - browser->
top_idx;
691 SLsmg_draw_vline(row - end_row + 1);
695 SLsmg_write_char(SLSMG_ULCORN_CHAR);
697 SLsmg_write_char(SLSMG_HLINE_CHAR);
699 SLsmg_write_char(SLSMG_RARROW_CHAR);
702 SLsmg_set_char_set(0);
709 unsigned int row, end_row;
711 SLsmg_set_char_set(1);
713 if (start >= browser->
top_idx) {
714 row = start - browser->
top_idx;
716 SLsmg_write_char(SLSMG_ULCORN_CHAR);
726 end_row = browser->
rows - 1;
728 end_row = end - browser->
top_idx;
731 SLsmg_draw_vline(end_row - row + 1);
734 if (end < browser->top_idx + browser->
rows) {
735 SLsmg_write_char(SLSMG_LLCORN_CHAR);
737 SLsmg_write_char(SLSMG_HLINE_CHAR);
739 SLsmg_write_char(SLSMG_RARROW_CHAR);
742 SLsmg_set_char_set(0);
755 unsigned int row,
bool arrow_down)
757 unsigned int end_row;
760 end_row = row - browser->
top_idx;
764 SLsmg_set_char_set(1);
768 SLsmg_write_char(SLSMG_ULCORN_CHAR);
772 SLsmg_write_char(SLSMG_LTEE_CHAR);
775 SLsmg_write_char(SLSMG_LTEE_CHAR);
780 SLsmg_set_char_set(0);
void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries)
int ui__help_window(const char *text)
unsigned int ui_browser__argv_refresh(struct ui_browser *browser)
void ui_browser__reset_index(struct ui_browser *browser)
void ui__refresh_dimensions(bool force)
#define HE_COLORSET_NORMAL
#define slsmg_write_nstring(msg, len)
int ui__getch(int delay_secs)
int ui_browser__show(struct ui_browser *browser, const char *title, const char *helpline,...)
char ui_helpline__current[512]
void ui_browser__show_title(struct ui_browser *browser, const char *title)
#define slsmg_vprintf(msg, vargs)
void ui_helpline__push(const char *msg)
void ui_browser__refresh_dimensions(struct ui_browser *browser)
int ui_browser__help_window(struct ui_browser *browser, const char *text)
void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x)
bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row)
#define HE_COLORSET_JUMP_ARROWS
unsigned int ui_browser__list_head_refresh(struct ui_browser *browser)
void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence)
bool(* filter)(struct ui_browser *browser, void *entry)
void __ui_browser__show_title(struct ui_browser *browser, const char *title)
static void __ui_browser__line_arrow_up(struct ui_browser *browser, unsigned int column, u64 start, u64 end)
void ui_browser__write_graph(struct ui_browser *browser __maybe_unused, int graph)
void ui_helpline__puts(const char *msg)
#define HE_COLORSET_MEDIUM
void ui_browser__handle_resize(struct ui_browser *browser)
static struct ui_browser_colorset ui_browser__colorsets[]
void(* write)(struct ui_browser *browser, void *entry, int row)
int ui_browser__refresh(struct ui_browser *browser)
void ui_browser__printf(struct ui_browser *browser __maybe_unused, const char *fmt,...)
unsigned int(* refresh)(struct ui_browser *browser)
static void __ui_browser__line_arrow_down(struct ui_browser *browser, unsigned int column, u64 start, u64 end)
#define sltt_set_color(obj, name, fg, bg)
static struct list_head * ui_browser__list_head_filter_prev_entries(struct ui_browser *browser, struct list_head *pos)
void ui_helpline__vpush(const char *fmt, va_list ap)
void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, const char *msg, unsigned int width)
int perf_config(config_fn_t fn, void *data)
void __ui_browser__vline(struct ui_browser *browser, unsigned int column, u16 start, u16 end)
void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
void ui_helpline__pop(void)
static double percent(int st, int tot)
void ui_browser__vprintf(struct ui_browser *browser __maybe_unused, const char *fmt, va_list args)
#define HE_COLORSET_SELECTED
int ui_browser__run(struct ui_browser *browser, int delay_secs)
void(* seek)(struct ui_browser *browser, off_t offset, int whence)
int ui__dialog_yesno(const char *msg)
static void ui_browser__scrollbar_set(struct ui_browser *browser)
void ui_browser__hide(struct ui_browser *browser)
int ui__question_window(const char *title, const char *text, const char *exit_msg, int delay_secs)
static int ui_browser__color_config(const char *var, const char *value, void *data __maybe_unused)
int ui_browser__set_color(struct ui_browser *browser, int color)
void ui_browser__set_percent_color(struct ui_browser *browser, double percent, bool current)
static int __ui_browser__refresh(struct ui_browser *browser)
void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence)
static int ui_browser__percent_color(struct ui_browser *browser, double percent, bool current)
void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column, unsigned int row, bool arrow_down)
void ui_browser__init(void)
static struct list_head * ui_browser__list_head_filter_entries(struct ui_browser *browser, struct list_head *pos)
unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser)
int ui_browser__warning(struct ui_browser *browser, int timeout, const char *format,...)
void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, u64 start, u64 end)
bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text)
void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence)
void(* refresh_dimensions)(struct ui_browser *browser)