-
Notifications
You must be signed in to change notification settings - Fork 6
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
增加按键功能 #6
增加按键功能 #6
Conversation
添加'b'跳转至前一单词,'dw'删除单词的功能 |
src/utils/buffer.rs
Outdated
|
||
/// 返回下一个单词的起始位置 | ||
/// 如果为该行最后一单词,返回该行长度 | ||
pub fn search_nextw_beg(&self, x: u16, y: u16) -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名写全会更好,这里的beg最好写全begin
src/utils/buffer.rs
Outdated
} | ||
|
||
/// 返回前一单词首字母位置,如果是当前行首单词,返回 None | ||
pub fn search_prevw_beg(&self, x: u16, y: u16) -> Option<usize> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同理
src/utils/ui/mode/mode.rs
Outdated
let linesize = ui.buffer.get_linesize(y) as usize; | ||
|
||
// 如果光标已经在当前行的末尾,则尝试移动到下一行的末尾或单词末尾 | ||
if x as usize == linesize - 1 { | ||
if x as usize >= linesize - 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种减2的操作,这个2代表什么,应该尽量避免这种魔数
实现了一系列与Vim类似的功能: