How can I calculate the width of &statusline as seen on-screen?
I'm writing a plugin that attempts to take advantage of extra whitespace in the statusline by displaying information of arbitrary length. Depending on the status of the current buffer, I want to开发者_StackOverflow中文版 display a specific slice of this information.
I can grab the format string of
&statusline
, however this length can greatly differ from the actual on-screen length after all processing is done.%<
and friends won't help me here because I would possibly need to truncate from both ends of the string if the information I want to see is in the middle. I can determine what section of the string I want via the current status of the active buffer.
Is there any way for me to grab the processed statusline via vimscript so I can alter it and make smart decisions based on it's length?
You should ask your question on vim mailing list.
If there is a trick to grab the expanded statusline, it's more likely that someone there will know it. (BTW, don't forget that elements may be right justified.)
You may have to play with winwidth()
and to expand the official statusline by yourself to operate your alteration.
精彩评论