QCodeEditor icon indicating copy to clipboard operation
QCodeEditor copied to clipboard

Add Vim Cursor

Open coder3101 opened this issue 5 years ago • 10 comments

Vim Cursor is a rectangle with the character inside of it. This commit adds a member function called setVimCursor() and vimCursor() that sets and retrieves the cursor type the QCodeEditor is presenting. This cursor is only visible when FakeVim is attached to the Editor. The Rectangle is visible when in Normal/Visual mode and a zero width line is visible when in insert mode.

image

coder3101 avatar Aug 30 '20 08:08 coder3101

The cursor color on my machine is different from your screenshot:

CP Editor:

image

Vim:

image

image

The color of the cursor should be the color of the text.

And, why is it a "I" in insert mode? In my real vim, it is a block (the same as the normal mode) in the insert mode.

ouuan avatar Aug 30 '20 09:08 ouuan

BTW, you can update the submodule without merging this into master. You can merge this when the FakeVim in CP Editor is finished.

ouuan avatar Aug 30 '20 09:08 ouuan

You can work on FakeVim of CP Editor first. There are too many bugs/problems now, sometimes I can't tell whether it's a problem of the text cursor or a problem of FakeVim itself.

ouuan avatar Aug 30 '20 09:08 ouuan

You can work on FakeVim of CP Editor first. There are too many bugs/problems now, sometimes I can't tell whether it's a problem of the text cursor or a problem of FakeVim itself.

It will be helpful if you could list them (maybe here, or by opening a PR from fakevim and in that thread).

As for bugs, I have found some highlighting issues when selecting block in visual mode. Save, Quit are not implemented correctly. I am thinking of how to behave for :w when untitled, :r, :q :q! other functions are not implemented correctly.

coder3101 avatar Aug 30 '20 10:08 coder3101

It will be helpful if you could list them (maybe here, or by opening a PR from fakevim and in that thread).

There are too many. Can't you find any? I can list them when you think everything is OK.

ouuan avatar Aug 30 '20 10:08 ouuan

It will be helpful if you could list them (maybe here, or by opening a PR from fakevim and in that thread).

There are too many. Can't you find any? I can list them when you think everything is OK.

I have already mentioned some issues that I have found. I am just implementing things haven't tested much. But there are limitations of fakevim, it doesn't supports all vim commands. As for how I added support for fakevim, most of code comes from fakevim example.

coder3101 avatar Aug 30 '20 11:08 coder3101

And, why is it a "I" in insert mode? In my real vim, it is a block (the same as the normal mode) in the insert mode.

It is "I" in my neovim and all other vim emulation tools that I use, like IdeaVim, VSCode Vim Emulation, Visual Studio Vim Emulation. The block represents the "Replace" mode. So If you press "Ins" it toggles from Insert mode to Replace mode and vice versa. Just as expected, in Replace mode it becomes a block.

coder3101 avatar Sep 15 '20 14:09 coder3101

The color of the cursor should be the color of the text.

This is from Kate (KDE Notepad++ like an editor). It does not changes the cursor colour to text colour. Rather it generates contrast between the cursor and the text using a Difference Composition mode.

image

auto cp = /* cursor painter */;
cp.setPen(Qt::NoPen);
cp.setBrush(m_syntaxStyle->name() == "Default" ? Qt::white : cursorColor);
cp.setCompositionMode(QPainer::CompositionMode_Difference);

coder3101 avatar Sep 15 '20 14:09 coder3101

@ouuan could you please review this PR?

coder3101 avatar Nov 05 '20 10:11 coder3101