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

feat: support commands from command mode to insert mode #7

Merged

Conversation

zhuweihao12138
Copy link
Contributor

实现从command模式到insert模式的按键,与vim相同
i:从光标前开始插入字符
I:从行首开始插入字符
a:从光标后开始插入字符
A:从行尾开始插入字符
o:在当前行之下另起一行,开始插入字符
O:在当前行之上另起一行,开始插入字符

原i|I进入插入模式被修改。
原a|A跳转到下一个锁定行被修改,需要商量另一个按键来使用


b"I" => {
// 切换Insert模式,从行首开始插入字符
ui.cursor.move_to_previous_line(0)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是当前行首还是前一行的行首?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是当前行首,没有直接对应的函数,但是用这个函数参数为0可以实现

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是否用移动到第0列的语义更加合适


b"a" => {
// 切换Insert模式,在光标后开始输入文本
ui.cursor.move_right(1)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有没有考虑如果光标后没有内容时行为是否正确

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move_right函数已经考虑了详尽的情况

@GnoCiYeH
Copy link
Member

原来那几个功能,可以讨论一下是否需要,不需要可以直接删掉

@GnoCiYeH GnoCiYeH merged commit 55c6e59 into DragonOS-Community:master Aug 29, 2024
3 checks passed
@zhuweihao12138 zhuweihao12138 deleted the zwh/support_insert_mode branch September 4, 2024 08:50
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