mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -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.
|
this label.
|
||||||
< - Where to truncate line if too long. Default is at the start.
|
< - Where to truncate line if too long. Default is at the start.
|
||||||
No width fields allowed.
|
No width fields allowed.
|
||||||
= - Separation point between alignment sections. Each section will
|
= - Separation point between alignment sections. Each section will
|
||||||
be separated by an equal number of spaces.
|
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.
|
No width fields allowed.
|
||||||
# - Set highlight group. The name must follow and then a # again.
|
# - Set highlight group. The name must follow and then a # again.
|
||||||
Thus use %#HLname# for highlight group HLname. The same
|
Thus use %#HLname# for highlight group HLname. The same
|
||||||
|
@ -267,7 +267,6 @@ Options:
|
|||||||
'pumblend' pseudo-transparent popupmenu
|
'pumblend' pseudo-transparent popupmenu
|
||||||
'scrollback'
|
'scrollback'
|
||||||
'signcolumn' supports up to 9 dynamic/fixed columns
|
'signcolumn' supports up to 9 dynamic/fixed columns
|
||||||
'statusline' supports unlimited alignment sections
|
|
||||||
'tabline' %@Func@foo%X can call any function on mouse-click
|
'tabline' %@Func@foo%X can call any function on mouse-click
|
||||||
'winblend' pseudo-transparency in floating windows |api-floatwin|
|
'winblend' pseudo-transparency in floating windows |api-floatwin|
|
||||||
'winhighlight' window-local highlights
|
'winhighlight' window-local highlights
|
||||||
@ -292,6 +291,7 @@ These Nvim features were later integrated into Vim.
|
|||||||
- |WinScrolled|
|
- |WinScrolled|
|
||||||
- |:sign-define| "numhl" argument
|
- |:sign-define| "numhl" argument
|
||||||
- |:source| works with anonymous (no file) scripts
|
- |:source| works with anonymous (no file) scripts
|
||||||
|
- 'statusline' supports unlimited alignment sections
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. Changed features *nvim-features-changed*
|
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;
|
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) {
|
if (*fmt_p == STL_SEPARATE) {
|
||||||
fmt_p++;
|
fmt_p++;
|
||||||
// Ignored when we are inside of a grouping
|
// 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;
|
int num_separators = 0;
|
||||||
for (int i = 0; i < itemcnt; i++) {
|
for (int i = 0; i < itemcnt; i++) {
|
||||||
if (stl_items[i].type == Separate) {
|
if (stl_items[i].type == Separate) {
|
||||||
// Create an array of the start location for each
|
// Create an array of the start location for each separator mark.
|
||||||
// separator mark.
|
|
||||||
stl_separator_locations[num_separators] = i;
|
stl_separator_locations[num_separators] = i;
|
||||||
num_separators++;
|
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) -
|
int final_spaces = (maxwidth - width) -
|
||||||
standard_spaces * (num_separators - 1);
|
standard_spaces * (num_separators - 1);
|
||||||
|
|
||||||
for (int i = 0; i < num_separators; i++) {
|
for (int l = 0; l < num_separators; l++) {
|
||||||
int dislocation = (i == (num_separators - 1)) ? final_spaces : standard_spaces;
|
int dislocation = (l == (num_separators - 1)) ? final_spaces : standard_spaces;
|
||||||
dislocation *= utf_char2len(fillchar);
|
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;
|
char *seploc = start + dislocation;
|
||||||
STRMOVE(seploc, start);
|
STRMOVE(seploc, start);
|
||||||
for (char *s = start; s < seploc;) {
|
for (char *s = start; s < seploc;) {
|
||||||
MB_CHAR2BYTES(fillchar, s);
|
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 < itemcnt;
|
||||||
item_idx++) {
|
item_idx++) {
|
||||||
stl_items[item_idx].start += dislocation;
|
stl_items[item_idx].start += dislocation;
|
||||||
|
@ -231,6 +231,10 @@ func Test_statusline()
|
|||||||
" %=: Separation point between left and right aligned items.
|
" %=: Separation point between left and right aligned items.
|
||||||
set statusline=foo%=bar
|
set statusline=foo%=bar
|
||||||
call assert_match('^foo\s\+bar\s*$', s:get_statusline())
|
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.
|
" Test min/max width, leading zeroes, left/right justify.
|
||||||
set statusline=%04B
|
set statusline=%04B
|
||||||
|
Loading…
Reference in New Issue
Block a user