/* Picks window to use for suggestion box and prepares it for displaying data. * Sets *height to number of suggestions to display. Returns picked window. */ static WINDOW * prepare_suggestion_box(int *height) { WINDOW *win; const col_attr_t col = cfg.cs.color[SUGGEST_BOX_COLOR]; const int count = vle_compl_get_count(); if((cfg.sug.flags & SF_OTHERPANE) && curr_stats.number_of_windows == 2) { win = other_view->win; *height = MIN(count, getmaxy(win)); } else { const int max_height = getmaxy(stdscr) - getmaxy(status_bar) - ui_stat_job_bar_height() - 2; *height = MIN(count, max_height); wresize(stat_win, *height, getmaxx(stdscr)); ui_stat_reposition(getmaxy(status_bar), 1); win = stat_win; } /* Clear preview before displaying suggestion for the first time for specific * input if active preview needs special cleanup. */ if(!suggestions_are_visible && curr_stats.preview.on && curr_stats.preview.cleanup_cmd != NULL) { qv_cleanup(other_view, curr_stats.preview.cleanup_cmd); } ui_set_bg(win, &col, -1); werase(win); return win; }
/* Picks window to use for suggestion box and prepares it for displaying data. * Sets *height to number of suggestions to display. Returns picked window. */ static WINDOW * prepare_suggestion_box(int *height) { WINDOW *win; const col_attr_t col = cfg.cs.color[SUGGEST_BOX_COLOR]; const int count = vle_compl_get_count(); if((cfg.sug.flags & SF_OTHERPANE) && curr_stats.number_of_windows == 2) { win = other_view->win; *height = MIN(count, getmaxy(win)); } else { const int max_height = getmaxy(stdscr) - getmaxy(status_bar) - ui_stat_job_bar_height() - 2; *height = MIN(count, max_height); wresize(stat_win, *height, getmaxx(stdscr)); ui_stat_reposition(getmaxy(status_bar), 1); win = stat_win; } wbkgdset(win, COLOR_PAIR(colmgr_get_pair(col.fg, col.bg)) | col.attr); werase(win); return win; }
void clean_status_bar(void) { (void)ui_stat_reposition(1); werase(status_bar); wresize(status_bar, 1, getmaxx(stdscr) - FIELDS_WIDTH()); mvwin(status_bar, getmaxy(stdscr) - 1, 0); wnoutrefresh(status_bar); if(curr_stats.load_stage <= 2) { multiline_status_bar = 0; curr_stats.need_update = UT_FULL; return; } if(multiline_status_bar) { multiline_status_bar = 0; update_screen(UT_FULL); } multiline_status_bar = 0; }
static void status_bar_message_i(const char message[], int error) { /* TODO: Refactor this function status_bar_message_i() */ static char *msg; static int err; int len; const char *p, *q; int lines; int status_bar_lines; size_t screen_length; const char *out_msg; char truncated_msg[2048]; if(curr_stats.load_stage == 0) { return; } if(message != NULL) { if(replace_string(&msg, message)) { return; } err = error; save_status_bar_msg(msg); } if(msg == NULL || vle_mode_is(CMDLINE_MODE)) { return; } p = msg; q = msg - 1; status_bar_lines = 0; len = getmaxx(stdscr); while((q = strchr(q + 1, '\n')) != NULL) { status_bar_lines += DIV_ROUND_UP(q - p, len ); if(q == p) { ++status_bar_lines; } p = q + 1; } if(*p == '\0') { ++status_bar_lines; } screen_length = utf8_strsw(p); status_bar_lines += DIV_ROUND_UP(screen_length, len); if(status_bar_lines == 0) { status_bar_lines = 1; } lines = status_bar_lines; if(status_bar_lines > 1 || screen_length > (size_t)getmaxx(status_bar)) { ++lines; } out_msg = msg; if(lines > 1) { if(cfg.trunc_normal_sb_msgs && !err && curr_stats.allow_sb_msg_truncation) { truncate_with_ellipsis(msg, getmaxx(stdscr) - FIELDS_WIDTH(), truncated_msg); out_msg = truncated_msg; lines = 1; } else { const int extra = DIV_ROUND_UP(ARRAY_LEN(PRESS_ENTER_MSG) - 1, len) - 1; lines += extra; } } if(lines > getmaxy(stdscr)) { lines = getmaxy(stdscr); } (void)ui_stat_reposition(lines); mvwin(status_bar, getmaxy(stdscr) - lines, 0); if(lines == 1) { wresize(status_bar, lines, getmaxx(stdscr) - FIELDS_WIDTH()); } else { wresize(status_bar, lines, getmaxx(stdscr)); } checked_wmove(status_bar, 0, 0); if(err) { col_attr_t col = cfg.cs.color[CMD_LINE_COLOR]; mix_colors(&col, &cfg.cs.color[ERROR_MSG_COLOR]); wattron(status_bar, COLOR_PAIR(colmgr_get_pair(col.fg, col.bg)) | col.attr); } else { int attr = cfg.cs.color[CMD_LINE_COLOR].attr; wattron(status_bar, COLOR_PAIR(cfg.cs.pair[CMD_LINE_COLOR]) | attr); } werase(status_bar); wprint(status_bar, out_msg); multiline_status_bar = lines > 1; if(multiline_status_bar) { checked_wmove(status_bar, lines - DIV_ROUND_UP(ARRAY_LEN(PRESS_ENTER_MSG), len), 0); wclrtoeol(status_bar); if(lines < status_bar_lines) wprintw(status_bar, "%d of %d lines. ", lines, status_bar_lines); wprintw(status_bar, "%s", PRESS_ENTER_MSG); } wattrset(status_bar, 0); update_all_windows(); /* This is needed because update_all_windows() doesn't call doupdate() if * curr_stats.load_stage == 1. */ doupdate(); }