Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vim Cursor #28

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Add Vim Cursor #28

wants to merge 17 commits into from

Conversation

coder3101
Copy link
Member

@coder3101 coder3101 commented Aug 30, 2020

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

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.
@pull-assistant
Copy link

pull-assistant bot commented Aug 30, 2020

@coder3101 coder3101 requested a review from ouuan August 30, 2020 08:53
@ouuan
Copy link
Member

ouuan commented Aug 30, 2020

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
Copy link
Member

ouuan commented Aug 30, 2020

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

@ouuan
Copy link
Member

ouuan commented Aug 30, 2020

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 ouuan marked this pull request as draft August 30, 2020 09:49
@coder3101
Copy link
Member Author

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.

@ouuan
Copy link
Member

ouuan commented Aug 30, 2020

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.

@coder3101
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

coder3101 commented Sep 15, 2020

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 coder3101 marked this pull request as ready for review October 14, 2020 18:24
@coder3101 coder3101 requested review from ouuan and removed request for ouuan October 14, 2020 18:25
@coder3101
Copy link
Member Author

@ouuan could you please review this PR?

@coder3101 coder3101 requested a review from ouuan January 12, 2021 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants