Ejemplo n.º 1
0
/* Recalculates virtual lines of a view with line wrapping. */
static void
calc_vlines_wrapped(void)
{
    const char *p;
    char *q;

    int i;
    const int nlines = count_lines(text, INT_MAX);

    data = reallocarray(NULL, nlines, sizeof(*data));

    nvlines = 0;

    p = text;
    q = text - 1;

    for(i = 0; i < nlines; ++i)
    {
        char saved_char;
        q = until_first(q + 1, '\n');
        saved_char = *q;
        *q = '\0';

        data[i][0] = nvlines++;
        data[i][1] = utf8_strsw_with_tabs(p, cfg.tab_stop);
        data[i][2] = p - text;
        nvlines += data[i][1]/viewport_width;

        *q = saved_char;
        p = q + 1;
    }
}
Ejemplo n.º 2
0
/* Recalculates virtual lines of a view with line wrapping. */
static void
calc_vlines_wrapped(view_info_t *vi)
{
	int i;
	vi->nlinesv = 0;
	for(i = 0; i < vi->nlines; i++)
	{
		vi->widths[i][0] = vi->nlinesv++;
		vi->widths[i][1] = utf8_strsw_with_tabs(vi->lines[i], cfg.tab_stop) -
			esc_str_overhead(vi->lines[i]);
		vi->nlinesv += vi->widths[i][1]/vi->width;
	}
}