mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
vim-patch:9.0.1300: 'statusline' only supports one "%=" item (#22218)
Problem: 'statusline' only supports one "%=" item.
Solution: Add support for multiple "%=" items. (TJ DeVries, Yegappan
Lakshmanan, closes vim/vim#11970, closes vim/vim#11965)
3ec78f973f
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
parent
414ff7742f
commit
374955bcc5
@ -6201,8 +6201,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
this label.
|
||||
< - Where to truncate line if too long. Default is at the start.
|
||||
No width fields allowed.
|
||||
= - Separation point between alignment sections. Each section will
|
||||
be separated by an equal number of spaces.
|
||||
= - Separation point between alignment sections. Each section will
|
||||
be separated by an equal number of spaces. With one %= what
|
||||
comes after it will be right-aligned. With two %= there is a
|
||||
middle part, with white space left and right of it.
|
||||
No width fields allowed.
|
||||
# - Set highlight group. The name must follow and then a # again.
|
||||
Thus use %#HLname# for highlight group HLname. The same
|
||||
|
@ -267,7 +267,6 @@ Options:
|
||||
'pumblend' pseudo-transparent popupmenu
|
||||
'scrollback'
|
||||
'signcolumn' supports up to 9 dynamic/fixed columns
|
||||
'statusline' supports unlimited alignment sections
|
||||
'tabline' %@Func@foo%X can call any function on mouse-click
|
||||
'winblend' pseudo-transparency in floating windows |api-floatwin|
|
||||
'winhighlight' window-local highlights
|
||||
@ -292,6 +291,7 @@ These Nvim features were later integrated into Vim.
|
||||
- |WinScrolled|
|
||||
- |:sign-define| "numhl" argument
|
||||
- |:source| works with anonymous (no file) scripts
|
||||
- 'statusline' supports unlimited alignment sections
|
||||
|
||||
==============================================================================
|
||||
5. Changed features *nvim-features-changed*
|
||||
|
@ -1094,7 +1094,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
|
||||
continue;
|
||||
}
|
||||
|
||||
// STL_SEPARATE: Separation place between left and right aligned items.
|
||||
// STL_SEPARATE: Separation between items, filled with white space.
|
||||
if (*fmt_p == STL_SEPARATE) {
|
||||
fmt_p++;
|
||||
// Ignored when we are inside of a grouping
|
||||
@ -2066,8 +2066,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
|
||||
int num_separators = 0;
|
||||
for (int i = 0; i < itemcnt; i++) {
|
||||
if (stl_items[i].type == Separate) {
|
||||
// Create an array of the start location for each
|
||||
// separator mark.
|
||||
// Create an array of the start location for each separator mark.
|
||||
stl_separator_locations[num_separators] = i;
|
||||
num_separators++;
|
||||
}
|
||||
@ -2079,17 +2078,17 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
|
||||
int final_spaces = (maxwidth - width) -
|
||||
standard_spaces * (num_separators - 1);
|
||||
|
||||
for (int i = 0; i < num_separators; i++) {
|
||||
int dislocation = (i == (num_separators - 1)) ? final_spaces : standard_spaces;
|
||||
for (int l = 0; l < num_separators; l++) {
|
||||
int dislocation = (l == (num_separators - 1)) ? final_spaces : standard_spaces;
|
||||
dislocation *= utf_char2len(fillchar);
|
||||
char *start = stl_items[stl_separator_locations[i]].start;
|
||||
char *start = stl_items[stl_separator_locations[l]].start;
|
||||
char *seploc = start + dislocation;
|
||||
STRMOVE(seploc, start);
|
||||
for (char *s = start; s < seploc;) {
|
||||
MB_CHAR2BYTES(fillchar, s);
|
||||
}
|
||||
|
||||
for (int item_idx = stl_separator_locations[i] + 1;
|
||||
for (int item_idx = stl_separator_locations[l] + 1;
|
||||
item_idx < itemcnt;
|
||||
item_idx++) {
|
||||
stl_items[item_idx].start += dislocation;
|
||||
|
@ -231,6 +231,10 @@ func Test_statusline()
|
||||
" %=: Separation point between left and right aligned items.
|
||||
set statusline=foo%=bar
|
||||
call assert_match('^foo\s\+bar\s*$', s:get_statusline())
|
||||
set statusline=foo%=bar%=baz
|
||||
call assert_match('^foo\s\+bar\s\+baz\s*$', s:get_statusline())
|
||||
set statusline=foo%=bar%=baz%=qux
|
||||
call assert_match('^foo\s\+bar\s\+baz\s\+qux\s*$', s:get_statusline())
|
||||
|
||||
" Test min/max width, leading zeroes, left/right justify.
|
||||
set statusline=%04B
|
||||
|
Loading…
Reference in New Issue
Block a user