gj/gl/gg/G in select mode
This commit is contained in:
@@ -416,6 +416,10 @@ impl TryFrom<&str> for BufferAction {
|
|||||||
"find_till_null" => Ok(FindTillNull),
|
"find_till_null" => Ok(FindTillNull),
|
||||||
"find_till_ff" => Ok(FindTillFF),
|
"find_till_ff" => Ok(FindTillFF),
|
||||||
|
|
||||||
|
"extend_till_mark" => Ok(ExtendTillMark),
|
||||||
|
"extend_till_null" => Ok(ExtendTillNull),
|
||||||
|
"extend_till_ff" => Ok(ExtendTillFF),
|
||||||
|
|
||||||
"inspect_selection" => Ok(InspectSelection),
|
"inspect_selection" => Ok(InspectSelection),
|
||||||
"inspect_selection_color" => Ok(InspectSelectionColor),
|
"inspect_selection_color" => Ok(InspectSelectionColor),
|
||||||
|
|
||||||
@@ -443,6 +447,11 @@ pub enum CursorAction {
|
|||||||
GotoFileStart,
|
GotoFileStart,
|
||||||
GotoFileEnd,
|
GotoFileEnd,
|
||||||
|
|
||||||
|
ExtendLineStart,
|
||||||
|
ExtendLineEnd,
|
||||||
|
ExtendFileStart,
|
||||||
|
ExtendFileEnd,
|
||||||
|
|
||||||
MoveNextWordStart,
|
MoveNextWordStart,
|
||||||
MoveNextWordEnd,
|
MoveNextWordEnd,
|
||||||
MovePreviousWordStart,
|
MovePreviousWordStart,
|
||||||
@@ -476,6 +485,11 @@ impl CursorAction {
|
|||||||
GotoFileStart => true,
|
GotoFileStart => true,
|
||||||
GotoFileEnd => true,
|
GotoFileEnd => true,
|
||||||
|
|
||||||
|
ExtendLineStart => true,
|
||||||
|
ExtendLineEnd => true,
|
||||||
|
ExtendFileStart => true,
|
||||||
|
ExtendFileEnd => true,
|
||||||
|
|
||||||
MoveNextWordStart => true,
|
MoveNextWordStart => true,
|
||||||
MoveNextWordEnd => true,
|
MoveNextWordEnd => true,
|
||||||
MovePreviousWordStart => true,
|
MovePreviousWordStart => true,
|
||||||
@@ -510,6 +524,11 @@ impl From<CursorAction> for &str {
|
|||||||
GotoFileStart => "goto_file_start",
|
GotoFileStart => "goto_file_start",
|
||||||
GotoFileEnd => "goto_file_end",
|
GotoFileEnd => "goto_file_end",
|
||||||
|
|
||||||
|
ExtendLineStart => "extend_line_start",
|
||||||
|
ExtendLineEnd => "extend_line_end",
|
||||||
|
ExtendFileStart => "extend_file_start",
|
||||||
|
ExtendFileEnd => "extend_file_end",
|
||||||
|
|
||||||
MoveNextWordStart => "move_next_word_start",
|
MoveNextWordStart => "move_next_word_start",
|
||||||
MoveNextWordEnd => "move_next_word_end",
|
MoveNextWordEnd => "move_next_word_end",
|
||||||
MovePreviousWordStart => "move_previous_word_start",
|
MovePreviousWordStart => "move_previous_word_start",
|
||||||
@@ -552,6 +571,11 @@ impl TryFrom<&str> for CursorAction {
|
|||||||
"goto_file_start" => Ok(GotoFileStart),
|
"goto_file_start" => Ok(GotoFileStart),
|
||||||
"goto_file_end" => Ok(GotoFileEnd),
|
"goto_file_end" => Ok(GotoFileEnd),
|
||||||
|
|
||||||
|
"extend_line_start" => Ok(ExtendLineStart),
|
||||||
|
"extend_line_end" => Ok(ExtendLineEnd),
|
||||||
|
"extend_file_start" => Ok(ExtendFileStart),
|
||||||
|
"extend_file_end" => Ok(ExtendFileEnd),
|
||||||
|
|
||||||
"move_next_word_start" => Ok(MoveNextWordStart),
|
"move_next_word_start" => Ok(MoveNextWordStart),
|
||||||
"move_next_word_end" => Ok(MoveNextWordEnd),
|
"move_next_word_end" => Ok(MoveNextWordEnd),
|
||||||
"move_previous_word_start" => Ok(MovePreviousWordStart),
|
"move_previous_word_start" => Ok(MovePreviousWordStart),
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ impl Default for Config {
|
|||||||
(keypress("j"), ExtendByteLeft.into()),
|
(keypress("j"), ExtendByteLeft.into()),
|
||||||
(keypress("l"), ExtendByteRight.into()),
|
(keypress("l"), ExtendByteRight.into()),
|
||||||
|
|
||||||
|
(keypress("G"), ExtendFileEnd.into()),
|
||||||
|
|
||||||
(keypress("up"), ExtendByteUp.into()),
|
(keypress("up"), ExtendByteUp.into()),
|
||||||
(keypress("down"), ExtendByteDown.into()),
|
(keypress("down"), ExtendByteDown.into()),
|
||||||
(keypress("left"), ExtendByteLeft.into()),
|
(keypress("left"), ExtendByteLeft.into()),
|
||||||
@@ -220,6 +222,12 @@ impl Default for Config {
|
|||||||
(keypress("C- "), InspectSelection.into()),
|
(keypress("C- "), InspectSelection.into()),
|
||||||
(keypress("A- "), InspectSelectionColor.into()),
|
(keypress("A- "), InspectSelectionColor.into()),
|
||||||
].into()),
|
].into()),
|
||||||
|
(Some(PartialAction::Goto), [
|
||||||
|
(keypress("j"), ExtendLineStart.into()),
|
||||||
|
(keypress("l"), ExtendLineEnd.into()),
|
||||||
|
|
||||||
|
(keypress("g"), ExtendFileStart.into()),
|
||||||
|
].into()),
|
||||||
(Some(PartialAction::View), [
|
(Some(PartialAction::View), [
|
||||||
(keypress("z"), AlignViewCenter.into()),
|
(keypress("z"), AlignViewCenter.into()),
|
||||||
(keypress("b"), AlignViewBottom.into()),
|
(keypress("b"), AlignViewBottom.into()),
|
||||||
|
|||||||
+28
-7
@@ -23,6 +23,11 @@ impl Cursor {
|
|||||||
CursorAction::GotoFileStart => self.goto_file_start(),
|
CursorAction::GotoFileStart => self.goto_file_start(),
|
||||||
CursorAction::GotoFileEnd => self.goto_file_end(max_contents_index),
|
CursorAction::GotoFileEnd => self.goto_file_end(max_contents_index),
|
||||||
|
|
||||||
|
CursorAction::ExtendLineStart => self.extend_line_start(),
|
||||||
|
CursorAction::ExtendLineEnd => self.extend_line_end(max_contents_index),
|
||||||
|
CursorAction::ExtendFileStart => self.extend_file_start(),
|
||||||
|
CursorAction::ExtendFileEnd => self.extend_file_end(max_contents_index),
|
||||||
|
|
||||||
CursorAction::MoveNextWordStart => self.move_next_word_start(max_contents_index),
|
CursorAction::MoveNextWordStart => self.move_next_word_start(max_contents_index),
|
||||||
CursorAction::MoveNextWordEnd => self.move_next_word_end(max_contents_index),
|
CursorAction::MoveNextWordEnd => self.move_next_word_end(max_contents_index),
|
||||||
CursorAction::MovePreviousWordStart => self.move_previous_word_start(),
|
CursorAction::MovePreviousWordStart => self.move_previous_word_start(),
|
||||||
@@ -89,27 +94,43 @@ impl Cursor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const fn goto_line_start(&mut self) {
|
pub const fn goto_line_start(&mut self) {
|
||||||
self.head -= self.head % BYTES_PER_LINE;
|
self.extend_line_start();
|
||||||
self.collapse();
|
self.collapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn goto_line_end(&mut self, max: usize) {
|
pub fn goto_line_end(&mut self, max: usize) {
|
||||||
self.head = min(
|
self.extend_line_end(max);
|
||||||
self.head + BYTES_PER_LINE - 1 - (self.head % BYTES_PER_LINE),
|
|
||||||
max
|
|
||||||
);
|
|
||||||
self.collapse();
|
self.collapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn goto_file_start(&mut self) {
|
pub const fn goto_file_start(&mut self) {
|
||||||
self.head %= BYTES_PER_LINE;
|
self.extend_file_start();
|
||||||
self.collapse();
|
self.collapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn goto_file_end(&mut self, max: usize) {
|
pub const fn goto_file_end(&mut self, max: usize) {
|
||||||
|
self.extend_file_end(max);
|
||||||
|
self.collapse();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn extend_line_start(&mut self) {
|
||||||
|
self.head -= self.head % BYTES_PER_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extend_line_end(&mut self, max: usize) {
|
||||||
|
self.head = min(
|
||||||
|
self.head + BYTES_PER_LINE - 1 - (self.head % BYTES_PER_LINE),
|
||||||
|
max
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn extend_file_start(&mut self) {
|
||||||
|
self.head %= BYTES_PER_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn extend_file_end(&mut self, max: usize) {
|
||||||
self.head += previous_multiple_of(BYTES_PER_LINE, max + 1 - self.head);
|
self.head += previous_multiple_of(BYTES_PER_LINE, max + 1 - self.head);
|
||||||
|
|
||||||
self.collapse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_next_word_start(&mut self, max: usize) {
|
pub fn move_next_word_start(&mut self, max: usize) {
|
||||||
|
|||||||
+2
-1
@@ -43,7 +43,8 @@ const BYTES_OF_PADDING: usize = LINES_OF_PADDING * BYTES_PER_LINE;
|
|||||||
// - update showcase
|
// - update showcase
|
||||||
// - fix scroll clamping
|
// - fix scroll clamping
|
||||||
// - inspector translations for varint
|
// - inspector translations for varint
|
||||||
// - repeat in select mode doesnt work right
|
// - repeated actions may only be cursor actions
|
||||||
|
// - shouldn't crash
|
||||||
// - gg/G in select mode
|
// - gg/G in select mode
|
||||||
// - gl/gj in select mode
|
// - gl/gj in select mode
|
||||||
// - scrolling in select mode
|
// - scrolling in select mode
|
||||||
|
|||||||
Reference in New Issue
Block a user