Leo draws a vim-like box cursor in command mode

25 views
Skip to first unread message

Edward K. Ream

unread,
Dec 5, 2020, 6:51:14 AM12/5/20
to leo-editor
I have just completed #1768: Change the text cursor in command mode. The code appears in the ekr-vim branch, which is still under development. I plan to complete #1757: (vim bindings) later today.

Emulating how vim draws the cursor is crucial, because the cursor clearly distinguishes between command and insert modes.

The new code cost me a full day of difficult coding. Googling, googling, and more googling convinces me that it is virtually impossible in Qt to draw the cursor exactly as vim does. Indeed, the Qt draws the cursor in a private class.

Happily, the workaround is plenty good enough. Vim:

- command mode: block cursor.
- insert mode: underline cursor.

Leo:

- command mode: A box surrounds the cursor.
The width of the cursor (and box) is the font's average character width.

- insert mode: Show a thin (vertical) cursor, as always.
As before, @bool qt-cursor-width = 1 determines the width of the vertical cursor.

Summary

Leo now draws a vim-like box cursor in command mode.

This is a surprisingly important milestone in Leo's support for vim.

The new code is in the ekr-vim branch.

Edward

Edward K. Ream

unread,
Dec 5, 2020, 10:34:27 AM12/5/20
to leo-editor
On Saturday, December 5, 2020 at 5:51:14 AM UTC-6 Edward K. Ream wrote:

> Leo now draws a vim-like box cursor in command mode...The new code is in the ekr-vim branch.

New code is now in devel now draws a box cursor in command mode for:

- vim mode (@bool vim-mode = True).
- vim emulation (the bindings in @keys Vim bindings).

Please report any problems, but only for devel. The ekr-vim branch still needs work.

Edward

Edward K. Ream

unread,
Dec 5, 2020, 11:05:30 AM12/5/20
to leo-editor
On Saturday, December 5, 2020 at 5:51:14 AM UTC-6 Edward K. Ream wrote:

> I plan to complete #1757: (vim bindings) later today.

Problems remain with both vim mode (@bool vim-mode=True) and vim emulation (@keys Vim bindings).

I'll fix these problems first, but that might not be soon ;-) The devel branch is in a good place, so there is no urgency.

Edward

Edward K. Ream

unread,
Dec 6, 2020, 10:23:47 AM12/6/20
to leo-editor
On Saturday, December 5, 2020 at 10:05:30 AM UTC-6 Edward K. Ream wrote:

Problems remain with both vim mode (@bool vim-mode=True) and vim emulation (@keys Vim bindings).

I'll fix these problems first, but that might not be soon...

These problems have been fixed. Pull the ekr-vim branch.

I considered creating a Leo 6.3.1 release, but I rejected that idea. Those that want improved vim emulation can pull the latest code with git.

Edward
Reply all
Reply to author
Forward
0 new messages