|
@@ -373,6 +373,23 @@ impl Command {
|
|
|
ui.cursor.move_to(prev_word_pos as u16, y)?;
|
|
|
return Ok(WarpUiCallBackType::None);
|
|
|
}
|
|
|
+
|
|
|
+ pub fn move_to_nlines_of_screen(
|
|
|
+ &self,
|
|
|
+ ui: &mut MutexGuard<UiCore>,
|
|
|
+ n: usize,
|
|
|
+ ) -> io::Result<()> {
|
|
|
+ let y = ui.cursor.y() as usize;
|
|
|
+
|
|
|
+ let offset = ui.buffer.offset();
|
|
|
+
|
|
|
+ let new_y = ui.buffer.goto_line(offset + n);
|
|
|
+ ui.render_content(0, CONTENT_WINSIZE.read().unwrap().rows as usize)?;
|
|
|
+ ui.cursor.move_to_row(new_y)?;
|
|
|
+ ui.cursor.highlight(Some(y as u16))?;
|
|
|
+
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl KeyEventCallback for Command {
|
|
@@ -455,19 +472,10 @@ impl KeyEventCallback for Command {
|
|
|
// 向右
|
|
|
b"l" => self.right(ui),
|
|
|
|
|
|
+ // 移动到当前屏幕最后一行
|
|
|
b"L" => {
|
|
|
- // 设置当前行lock
|
|
|
- let flag = ui.buffer.line_flags(ui.cursor.y());
|
|
|
- let offset = ui.buffer.offset();
|
|
|
- if flag.contains(LineState::LOCKED) {
|
|
|
- ui.buffer
|
|
|
- .remove_line_flags(offset + ui.cursor.y() as usize, LineState::LOCKED);
|
|
|
- } else {
|
|
|
- ui.buffer
|
|
|
- .add_line_flags(offset + ui.cursor.y() as usize, LineState::LOCKED);
|
|
|
- }
|
|
|
- let y = ui.cursor.y();
|
|
|
- ui.render_content(y, 1)?;
|
|
|
+ let win_size = CONTENT_WINSIZE.read().unwrap().rows as usize;
|
|
|
+ self.move_to_nlines_of_screen(ui, win_size - 1)?;
|
|
|
return Ok(WarpUiCallBackType::None);
|
|
|
}
|
|
|
|
|
@@ -549,6 +557,17 @@ impl KeyEventCallback for Command {
|
|
|
return Ok(WarpUiCallBackType::None);
|
|
|
}
|
|
|
|
|
|
+ b"H" => {
|
|
|
+ self.move_to_nlines_of_screen(ui, 0)?;
|
|
|
+ return Ok(WarpUiCallBackType::None);
|
|
|
+ }
|
|
|
+
|
|
|
+ b"M" => {
|
|
|
+ let win_size = CONTENT_WINSIZE.read().unwrap().rows as usize;
|
|
|
+ self.move_to_nlines_of_screen(ui, win_size / 2)?;
|
|
|
+ return Ok(WarpUiCallBackType::None);
|
|
|
+ }
|
|
|
+
|
|
|
_ => {
|
|
|
return Ok(WarpUiCallBackType::None);
|
|
|
}
|