Esempio n. 1
0
void
ui_stat_update(view_t *view, int lazy_redraw)
{
	if(!cfg.display_statusline || view != curr_view)
	{
		return;
	}

	/* Don't redraw anything until :restart command is finished. */
	if(curr_stats.restart_in_progress)
	{
		return;
	}

	ui_stat_job_bar_check_for_updates();

	if(cfg.status_line[0] == '\0')
	{
		update_stat_window_old(view, lazy_redraw);
		return;
	}

	const int width = getmaxx(stdscr);

	wresize(stat_win, 1, width);
	ui_set_bg(stat_win, &cfg.cs.color[STATUS_LINE_COLOR],
			cfg.cs.pair[STATUS_LINE_COLOR]);
	werase(stat_win);
	checked_wmove(stat_win, 0, 0);

	cchar_t default_attr;
	setcchar(&default_attr, L" ", cfg.cs.color[STATUS_LINE_COLOR].attr,
			cfg.cs.pair[STATUS_LINE_COLOR], NULL);

	LineWithAttrs result = expand_status_line_macros(view, cfg.status_line);
	assert(strlen(result.attrs) == utf8_strsw(result.line) && "Broken attrs!");
	result.line = break_in_two(result.line, width, "%=");
	result.attrs = break_in_two(result.attrs, width, "=");
	print_with_attrs(stat_win, result.line, result.attrs, &default_attr);
	free(result.line);
	free(result.attrs);

	refresh_window(stat_win, lazy_redraw);
}
Esempio n. 2
0
void
update_stat_window(FileView *view, int lazy_redraw)
{
	int x;
	char *buf;

	if(!cfg.display_statusline)
	{
		return;
	}

	/* Don't redraw anything until :restart command is finished. */
	if(curr_stats.restart_in_progress)
	{
		return;
	}

	ui_stat_job_bar_check_for_updates();

	if(cfg.status_line[0] == '\0')
	{
		update_stat_window_old(view, lazy_redraw);
		return;
	}

	x = getmaxx(stdscr);
	wresize(stat_win, 1, x);
	wbkgdset(stat_win, COLOR_PAIR(cfg.cs.pair[STATUS_LINE_COLOR]) |
			cfg.cs.color[STATUS_LINE_COLOR].attr);

	buf = expand_status_line_macros(view, cfg.status_line);
	buf = break_in_two(buf, getmaxx(stdscr));

	werase(stat_win);
	checked_wmove(stat_win, 0, 0);
	wprint(stat_win, buf);

	if(lazy_redraw)
	{
		wnoutrefresh(stat_win);
	}
	else
	{
		wrefresh(stat_win);
	}

	free(buf);
}