This commit is contained in:
Wayne Rowcliffe
2015-09-16 00:51:41 -05:00
parent 12e53ca95c
commit 7c32d86f7d

View File

@@ -2850,11 +2850,11 @@ build_stl_str_hl (
} type;
} item[STL_MAX_ITEM];
enum number_base {
typedef enum {
DECIMAL = 10,
OCTAL = 8,
HEXIDECIMAL = 16
};
} number_base;
#define TMPLEN 70
char_u tmp[TMPLEN];
@@ -2952,7 +2952,8 @@ build_stl_str_hl (
continue;
}
// STL_MIDDLEMARK denotes the separation place between left and right aligned items.
// STL_MIDDLEMARK denotes the separation place between
// left and right aligned items.
if (*fmt_p == STL_MIDDLEMARK) {
fmt_p++;
// Ignored when we are inside of a grouping
@@ -2964,7 +2965,8 @@ build_stl_str_hl (
continue;
}
// STL_TRUNCMARK denotes where to begin truncating if the statusline is too long.
// STL_TRUNCMARK denotes where to begin truncating if the
// statusline is too long.
if (*fmt_p == STL_TRUNCMARK) {
fmt_p++;
item[curitem].type = Trunc;
@@ -2982,16 +2984,18 @@ build_stl_str_hl (
groupdepth--;
// { Determine how long the group is.
// Note: We set the current output position to null so `vim_strsize` will work.
// Note: We set the current output position to null
// so `vim_strsize` will work.
char_u *t = item[groupitem[groupdepth]].start;
*out_p = NUL;
long l = vim_strsize(t);
// }
// If the group contained internal items and the group did not have a minimum width,
// If the group contained internal items
// and the group did not have a minimum width,
// and if there were no normal items in the group,
// move the output pointer back to where the group started (erase the group).
// Note: This also erases any plaintext characters that were in the group.
// move the output pointer back to where the group started.
// Note: This erases any non-item characters that were in the group.
// Otherwise there would be no reason to do this step.
if (curitem > groupitem[groupdepth] + 1
&& item[groupitem[groupdepth]].minwid == 0) {
@@ -3021,8 +3025,9 @@ build_stl_str_hl (
l -= ptr2cells(t + n);
n += (*mb_ptr2len)(t + n);
}
} else
} else {
n = (long)(out_p - t) - item[groupitem[groupdepth]].maxwid + 1;
}
// }
// Prepend the `<` to indicate that the output was truncated.
@@ -3173,7 +3178,7 @@ build_stl_str_hl (
char_u opt = *fmt_p++;
/* OK - now for the real work */
enum number_base base = DECIMAL;
number_base base = DECIMAL;
bool itemisflag = false;
bool fillable = true;
long num = -1;
@@ -3212,7 +3217,8 @@ build_stl_str_hl (
fmt_p++;
*out_p = 0;
// Move our position in the output buffer to the beginning of the expression
// Move our position in the output buffer
// to the beginning of the expression
out_p = t;
// { Evaluate the expression
@@ -3221,8 +3227,8 @@ build_stl_str_hl (
vim_snprintf((char *)tmp, sizeof(tmp), "%d", curbuf->b_fnum);
set_internal_string_var((char_u *)"actual_curbuf", tmp);
// Switch the curbuf and curwin to the buffer and window we are evaluating the
// statusline for.
// Switch the curbuf and curwin to the buffer and window we are
// evaluating the statusline for.
buf_T *o_curbuf = curbuf;
win_T *o_curwin = curwin;
curwin = wp;
@@ -3236,7 +3242,7 @@ build_stl_str_hl (
curbuf = o_curbuf;
// Remove the variable we just stored
do_unlet((char_u *)"g:actual_curbuf", TRUE);
do_unlet((char_u *)"g:actual_curbuf", true);
// }
@@ -3310,7 +3316,7 @@ build_stl_str_hl (
// Note: The call will only return true if it actually
// appended data to the `tmp` buffer.
if (append_arg_number(wp, tmp, (int)sizeof(tmp), FALSE)) {
if (append_arg_number(wp, tmp, (int)sizeof(tmp), false)) {
str = tmp;
}
break;
@@ -3365,7 +3371,8 @@ build_stl_str_hl (
case STL_FILETYPE:
// Copy the filetype if it is not null and the formatted string will fit
// in the temporary buffer (including the brackets and null terminating character)
// in the temporary buffer
// (including the brackets and null terminating character)
if (*wp->w_buffer->b_p_ft != NUL
&& STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 3) {
vim_snprintf((char *)tmp, sizeof(tmp), "[%s]",
@@ -3378,7 +3385,8 @@ build_stl_str_hl (
{
itemisflag = true;
// Copy the filetype if it is not null and the formatted string will fit
// in the temporary buffer (including the comma and null terminating character)
// in the temporary buffer
// (including the comma and null terminating character)
if (*wp->w_buffer->b_p_ft != NUL
&& STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 2) {
vim_snprintf((char *)tmp, sizeof(tmp), ",%s",
@@ -3488,7 +3496,8 @@ build_stl_str_hl (
*out_p++ = '<';
}
// If the item is right aligned and not wide enough, pad with fill characters.
// If the item is right aligned and not wide enough,
// pad with fill characters.
if (minwid > 0) {
for (; l < minwid && out_p < out_end_p; l++) {
/* Don't put a "-" in front of a digit. */
@@ -3552,7 +3561,8 @@ build_stl_str_hl (
num_chars++;
}
// VIRTCOL_ALT takes up an extra character because of the `-` we added above.
// VIRTCOL_ALT takes up an extra character because
// of the `-` we added above.
if (opt == STL_VIRTCOL_ALT) {
num_chars++;
}
@@ -3564,7 +3574,8 @@ build_stl_str_hl (
// Figure out the approximate number in "scientific" type notation.
// Ex: 14532 with maxwid of 4 -> '14>3'
if (num_chars > maxwid) {
// Add two to the width because the power piece will take two extra characters
// Add two to the width because the power piece will take
// two extra characters
num_chars += 2;
// How many extra characters there are
@@ -3591,7 +3602,8 @@ build_stl_str_hl (
minwid, num);
}
// Advance the output buffer position to the end of the number we just printed
// Advance the output buffer position to the end of the
// number we just printed
out_p += STRLEN(out_p);
// Otherwise, there was nothing to print so mark the item as empty
@@ -3733,7 +3745,8 @@ build_stl_str_hl (
// to be moved backwards.
if (item[i].start >= trunc_end_p) {
item[i].start -= item_offset;
// Anything inside the truncated area is set to start at the `<` truncation character.
// Anything inside the truncated area is set to start
// at the `<` truncation character.
} else {
item[i].start = trunc_p;
}
@@ -3743,7 +3756,8 @@ build_stl_str_hl (
width = maxwidth;
// If there is room left in our statusline, and room left in our buffer,
// add characters at the middle marker (if there is one) to fill up the available space.
// add characters at the middle marker (if there is one) to
// fill up the available space.
} else if (width < maxwidth
&& STRLEN(out) + maxwidth - width + 1 < outlen) {
for (int item_idx = 0; item_idx < itemcnt; item_idx++) {