macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.47k stars 680 forks source link

Allow pinning the cmdline to be aligned to the bottom of window #1280

Closed ychin closed 1 year ago

ychin commented 1 year ago

Add a setting that could pin the command-line portion of Vim to the bottom of the MacVim window. This is useful when smooth resizing is set, guioption+=k, or in full screen. In those situations, the MacVim window size is usually not direct multiples of the Vim text sizes. Previously the command-line would be drawn like other texts, and hence not aligned to the bottom and hence looking aesthetically a little off.

When this setting is set, the command-line portion would be aligned to the bottom of the window. This essentially moves the gap (due to the extra height of the window) from the bottom to be between cmdline and the rest of Vim. When cmdheight is changed, or other situations (e.g. typing too much cmdline height to be increased), the gap will be adjusted as well.

Implementation-wise, this was done by passing the commandline_row var from Vim to MacVim, which serves as a good estimate of where the command-line is. This works better than just using the cmdheight option as it is closer to the current state of the cmdline. One issue is that in hit-enter prompts, the row is set to the 2nd to last row to anticipate more messages, and we just add a big hack by incrementing the row by 1 in hit-enter state so only the "Press Enter..." part is aligned to bottom. We also have to do something similar to when it's showing "--more--" for similar reasons.

Close #833

ychin commented 1 year ago

Just to illustrate what it looks like.

This is what looks like without the setting (and what MacVim looked like before the change):

without-pin-bottom

This is what looks like with the setting:

with-pin-bottom

If you do a long message or something like :version, only the "Press Enter" prompt is pinned:

press-enter-pin-bottom

Just a video to illustrate the pinning in motion when you resize the window (with smooth resizing from the previously implemented feature in #1276):

https://user-images.githubusercontent.com/1217449/189526098-c9e3de6a-bc85-4988-a6d3-8b06b615f342.mov