Add 'showcmd' statusline item and 'showcmdloc' option#11684
Add 'showcmd' statusline item and 'showcmdloc' option#11684luukvbaal wants to merge 1 commit intovim:masterfrom
Conversation
|
|
Codecov Report
@@ Coverage Diff @@
## master #11684 +/- ##
==========================================
- Coverage 81.81% 81.80% -0.01%
==========================================
Files 164 164
Lines 190973 191298 +325
Branches 43370 43437 +67
==========================================
+ Hits 156242 156491 +249
- Misses 22046 22097 +51
- Partials 12685 12710 +25
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
Please first add documentation. Reverse engineering the code to guess what it's supposed to do isn't the right way to add a new feature. |
Right, completely forgot sorry.
True, should 'statusline' be parsed for this item? Is there precedent for this?
When 'showcmd' is off, we still fill the |
a500f6b to
27be343
Compare
I guess there's no reason not to, latest commit sets a global boolean when the 'showcmd' item is encountered. Status line will only be redrawn when TRUE, so reverted the terminal focus testdump change. |
|
> Please first add documentation.
Right, completely forgot sorry.
> One problem I can spot is that it's redrawing the status lines even when the showcmd item isn't in there.
True, should 'statusline' be parsed for this item? Is there precedent
for this?
I don't think so. Currently there is no item that changes on every key
stroke, AFAIK.
Parsing the option only works when when it doesn't start with "!%".
I think the only way would be to draw the status line, and set a flag if
the "showcmd" value is used. But then perhaps it isn't always called
(e.g. if there is not enough room), that makes it unreliable.
> Also, what happens when 'showcmd' is off is unclear.
When 'showcmd' is off, we still fill the `showcmd_buf`, because the
user might have the item in use. If we parse the status/tabline we
could set a global and avoid unnecessary work I guess.
If 'showcmd' would have been a number or string option we could have
done something, but since it's a boolean we can't change it.
We could tackle both problems with a 'showcmdwhere' option (better
name?), to tell Vim where the command will be displayed, thus knowing
when to update status lines. Since the user has to switch 'showcmd'
off, setting another option isn't really a problem.
…--
MAN: You don't frighten us, English pig-dog! Go and boil your bottoms,
son of a silly person. I blow my nose on you, so-called Arthur-king,
you and your silly English K...kaniggets.
He puts hands to his ears and blows a raspberry.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Yeah I realized, the latest commit does just that.
Right, let me know if that is a route you want to take to include this feature. I can update accordingly. Do we want to facilitate displaying this item in both the status line and tabline? Or even multiple(status/tab/cmdline) at the same time? In which case I suppose it should be a comma separated string option.
I guess in theory they don't have to but it would make the most sense yeah. |
|
> Parsing the option only works when when it doesn't start with "!%".
> I think the only way would be to draw the status line, and set a
> flag if the "showcmd" value is used.
Yeah I realized, the latest commit does just that.
> We could tackle both problems with a 'showcmdwhere' option (better
>name?), to tell Vim where the command will be displayed, thus knowing
>when to update status lines.
Right, let me know if that is a route you want to take to include this
feature. I can update accordingly. Do we want to facilitate displaying
this item in both the status line and tabline? Or even
multiple(status/tab/cmdline) at the same time? In which case I suppose
it should be a comma separated string option.
Would someone really want it in multiple places? That sounds unusual.
I would not implement that at first, but make the option value in a way
that it's possible in the future.
When you say "status line" it doesn't say where it shows up. Only the
status line for the most bottom-right window? Otherwise it's specified
by the 'statusline' option. But it could also be done when 'statusline'
is empty.
I find it hard to imagine showcmd showing up in the tabline. I suppose
some space would need to be reserved for it. Then the choice is on the
far left or the far right.
> Since the user has to switch 'showcmd' off, setting another option
> isn't really a problem.
I guess in theory they don't **have** to but it would make the most
sense yeah.
With the extra option, probably 'showcmdloc', then 'showcmd' would still
be on. If it is off then it won't show anywhere. That's simple.
'showcmdloc' would now be one word, such as "statusline",
"tablineright", etc. If we ever would want to show it in more than one
place the option can become a comma separated list of these words.
I still have the feeling that very few users are going to use this, thus
consider it low priority.
…--
ARTHUR: (as the MAN next to him is squashed by a sheep) Knights! Run away!
Midst echoing shouts of "run away" the KNIGHTS retreat to cover with the odd
cow or goose hitting them still. The KNIGHTS crouch down under cover.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Yes showing it in multiple places would be unusual. The way I implemented it currently and what seems to make the most sense to me is to redraw the status line for
Very possible, again I only made the PR here to avoid future naming conflicts with Neovim, and get a feel for what item-symbol you would choose. But if we are going to add the feature here we have to add it in a way that makes sense. I think we may not need the 'showcmdloc' option. Since we now pass the option name to |
|
Yes showing it in multiple places would be unusual. The way I
implemented it currently and what seems to make the most sense to me
is to redraw the status line for `curwin`. Whether it shows up is not
our concern I don't think. It would indeed be up to the user to
reserve space, if they find the item high enough priority.
It does make sense to show it in the current window. That's closest to
where the user is looking.
When 'statusline' is empty it should still show up. Left of the ruler
would be good.
Very possible, again I only made the PR here to avoid future naming
conflicts with Neovim, and get a feel for what item-symbol you would
choose. But if we are going to add the feature here we have to add it
in a way that makes sense. I think we may not need the 'showcmdloc'
option. Since we now pass the option name to `build_stl_str_hl()`, we
can simply set a flag for status/tabline and redraw accordingly in
`display_showcmd()`.
In my opinion we do need to add the 'showcmdloc' option. Without it,
the user would have to reset 'showcmd' and add the item to the
'statusline' option. This would black adding 'showcmdloc' later,
because then 'showcmd' would remain on, thus it can't be backwards
compatible.
…--
In his lifetime van Gogh painted 486 oil paintings. Oddly enough, 8975
of them are to be found in the United States.
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
|
I wrote:
> Yes showing it in multiple places would be unusual. The way I
> implemented it currently and what seems to make the most sense to me
> is to redraw the status line for `curwin`. Whether it shows up is not
> our concern I don't think. It would indeed be up to the user to
> reserve space, if they find the item high enough priority.
It does make sense to show it in the current window. That's closest to
where the user is looking.
When 'statusline' is empty it should still show up. Left of the ruler
would be good.
> Very possible, again I only made the PR here to avoid future naming
> conflicts with Neovim, and get a feel for what item-symbol you would
> choose. But if we are going to add the feature here we have to add it
> in a way that makes sense. I think we may not need the 'showcmdloc'
> option. Since we now pass the option name to `build_stl_str_hl()`, we
> can simply set a flag for status/tabline and redraw accordingly in
> `display_showcmd()`.
In my opinion we do need to add the 'showcmdloc' option. Without it,
the user would have to reset 'showcmd' and add the item to the
'statusline' option. This would black adding 'showcmdloc' later,
s/black/block/
… because then 'showcmd' would remain on, thus it can't be backwards
compatible.
--
press CTRL-ALT-DEL for more information
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
29c0e80 to
56879bd
Compare
56879bd to
933b7b3
Compare
Latest commit adds the 'showcmdloc' option. Will need to figure out how to add this to the default statusline if 'showcmdloc' == "statusline". |
933b7b3 to
e182aee
Compare
Done in the latest commit, as well as for the default tabline. (I don't see it being all that useful in the tabline, I just added it because I came across https://vi.stackexchange.com/questions/16857/showcmd-on-first-line-instead-of-last-line). I think the attributes for the showcmd text in the default tabline should be |
e182aee to
0c887fd
Compare
0c887fd to
2673ca4
Compare
I guess it doesn't make sense to forcefully remove the underline from a highlight group (didn't actually figure out how to do that). This is finished then as far as I'm concerned. Tests for the default status/tabline are still missing. If you are open to including this in it's current form I could add additional tests. |
|
I thought I had already mentioned this: when 'showcmd' is off then the command should not be displayed anywhere. The default value for 'showcmdloc' should be "last". Currently you could replace it with "statusline" or "tabline". Coding style: Please put the opening curly on the next line. |
2673ca4 to
f9e9691
Compare
f9e9691 to
e5dc80d
Compare
Done and additional tests added. |
e5dc80d to
1d5eacf
Compare
|
Should the tests be in |
|
Should the tests be in `test_normal.vim` instead? Existing `showcmd`
test is in there.
test_normal.vim is already very big. Perhaps we have enough testing for
this feature to justify a new test file? In the past we thought the
overhead of starting a new Vim instance would matter, but now it matters
more that if a test fails, e.g. there is a memory leak, it is limited in
what might cause it.
Otherwise, test_statusline.vim would also be related.
…--
E M A C S
s e l o h
c t t n i
a a t f
p r t
e o
l
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Yeah depends on whether you want to group these tests under 'showcmd', in which case a |
|
I wonder if adding a builtin |
|
I wonder if adding a builtin `showcmd()` function, analogous to e.g.
`mode()` and `searchcount()` will be more useful/idiomatic than adding
a statusline item?
It looks like it is hardly any code. We can just do both.
Let me include it now. Then we can have some users try it out and see
if we need some adjustments.
…--
You had connectors? Eeee, when I were a lad we 'ad to carry the
bits between the computer and the terminal with a spoon...
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes vim/vim#11684) vim/vim@ba936f6 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
This statusline item is mostly intended for use with
cmdheight == 0in Neovim. Nevertheless, users have expressed interest in displayingshowcmdin their statusline and even tabline.Just checking if you are open to including this to avoid future naming conflicts of the statusline item. The item name is still up for debate, @justinmk suggested dot
.instead.I assume potential users of this item would
set noshowcmd, therefore I decoupled the showcmd routines fromp_sc, except for the actual drawing in the cmdline.I tried adding a non-screendump test to
Test_statusline()but only the visual mode test passes. The pending operator test yields an empty statusline. Does thecall assert_match()clear the showcmd buffer? That's what it seems like atleast:Therefore I grouped them as 2 screendump tests instead. It works as intended in practice.
Redrawing the statusline upon command input caused a test failure in
Test_aa_terminal_focus_events(), updated the dump files to reflect the statusline update.