/* * Return appropriate space number for breakindent, taking influencing * parameters into account. Window must be specified, since it is not * necessarily always the current one. */ int get_breakindent_win(win_T *wp, char_u *line) { static int prev_indent = 0; /* cached indent value */ static int prev_ts = 0L; /* cached tabstop value */ static char_u *prev_line = NULL; /* cached pointer to line */ int bri = 0; /* window width minus window margin space, i.e. what rests for text */ const int eff_wwidth = wp->w_width - ((wp->w_p_nu || wp->w_p_rnu) && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) ? number_width(wp) + 1 : 0); /* used cached indent, unless pointer or 'tabstop' changed */ if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts) { prev_line = line; prev_ts = wp->w_buffer->b_p_ts; prev_indent = get_indent_str(line, (int)wp->w_buffer->b_p_ts, wp->w_p_list); } bri = prev_indent + wp->w_p_brishift; /* indent minus the length of the showbreak string */ if (wp->w_p_brisbr) bri -= vim_strsize(p_sbr); /* Add offset for number column, if 'n' is in 'cpoptions' */ bri += win_col_off2(wp); /* never indent past left window margin */ if (bri < 0) bri = 0; /* always leave at least bri_min characters on the left, * if text width is sufficient */ else if (bri > eff_wwidth - wp->w_p_brimin) bri = (eff_wwidth - wp->w_p_brimin < 0) ? 0 : eff_wwidth - wp->w_p_brimin; return bri; }
static int tab_title_width(int number, const char *filename) { return 3 + number_width(number) + u_str_width(filename); }