feat: add command to add cursors to all matches
Also, move inspector view to Ctrl-Shift-i
This commit is contained in:
parent
779f6976e0
commit
8f8d4b6145
6 changed files with 38 additions and 12 deletions
9
help.md
9
help.md
|
@ -139,6 +139,9 @@ cycle style of editing.
|
||||||
- Alt-Shift-Down, Alt-Shift-Up =>
|
- Alt-Shift-Down, Alt-Shift-Up =>
|
||||||
Add cursor on the previous/next line
|
Add cursor on the previous/next line
|
||||||
|
|
||||||
|
- Ctrl-Shift-l =>
|
||||||
|
Add cursors to all matches
|
||||||
|
|
||||||
- Ctrl-MouseLeft =>
|
- Ctrl-MouseLeft =>
|
||||||
Add cursor at mouse click
|
Add cursor at mouse click
|
||||||
|
|
||||||
|
@ -237,7 +240,7 @@ cycle style of editing.
|
||||||
|
|
||||||
### Debugging Commands
|
### Debugging Commands
|
||||||
|
|
||||||
- F5 =>
|
- F5, Ctrl-Shift-i =>
|
||||||
Toggle inspector view
|
Toggle inspector view
|
||||||
|
|
||||||
- F6 =>
|
- F6 =>
|
||||||
|
@ -246,10 +249,10 @@ cycle style of editing.
|
||||||
- F7 =>
|
- F7 =>
|
||||||
Dump current line to log view
|
Dump current line to log view
|
||||||
|
|
||||||
- F11, Ctrl-J, Ctrl-Shift-l =>
|
- F11, Ctrl-J, Alt-l =>
|
||||||
Toggle log view
|
Toggle log view
|
||||||
|
|
||||||
- F12, Ctrl-Shift-i =>
|
- F12, Alt-i =>
|
||||||
Toggle input view
|
Toggle input view
|
||||||
|
|
||||||
- Ctrl-Shift-/ =>
|
- Ctrl-Shift-/ =>
|
||||||
|
|
|
@ -2083,6 +2083,21 @@ pub const Editor = struct {
|
||||||
try self.send_editor_jump_destination();
|
try self.send_editor_jump_destination();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_cursor_all_matches(self: *Self, _: command.Context) tp.result {
|
||||||
|
if (self.matches.items.len == 0) return;
|
||||||
|
try self.send_editor_jump_source();
|
||||||
|
while (self.get_next_match(self.get_primary().cursor)) |match| {
|
||||||
|
self.push_cursor() catch |e| return tp.exit_error(e);
|
||||||
|
const primary = self.get_primary();
|
||||||
|
const root = self.buf_root() catch return;
|
||||||
|
primary.selection = match.to_selection();
|
||||||
|
match.has_selection = true;
|
||||||
|
primary.cursor.move_to(root, match.end.row, match.end.col) catch return;
|
||||||
|
}
|
||||||
|
self.clamp();
|
||||||
|
try self.send_editor_jump_destination();
|
||||||
|
}
|
||||||
|
|
||||||
fn pull_cursel_up(self: *Self, root_: Buffer.Root, cursel: *CurSel, a: Allocator) error{Stop}!Buffer.Root {
|
fn pull_cursel_up(self: *Self, root_: Buffer.Root, cursel: *CurSel, a: Allocator) error{Stop}!Buffer.Root {
|
||||||
var root = root_;
|
var root = root_;
|
||||||
const saved = cursel.*;
|
const saved = cursel.*;
|
||||||
|
@ -2954,6 +2969,14 @@ pub const Editor = struct {
|
||||||
(self.matches.addOne() catch return).* = match;
|
(self.matches.addOne() catch return).* = match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn scan_first_match(self: *const Self) ?*Match {
|
||||||
|
for (self.matches.items) |*match_| if (match_.*) |*match| {
|
||||||
|
if (match.has_selection) continue;
|
||||||
|
return match;
|
||||||
|
};
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
fn scan_next_match(self: *const Self, cursor: Cursor) ?*Match {
|
fn scan_next_match(self: *const Self, cursor: Cursor) ?*Match {
|
||||||
const row = cursor.row;
|
const row = cursor.row;
|
||||||
const col = cursor.col;
|
const col = cursor.col;
|
||||||
|
@ -2968,7 +2991,7 @@ pub const Editor = struct {
|
||||||
if (self.scan_next_match(cursor)) |match| return match;
|
if (self.scan_next_match(cursor)) |match| return match;
|
||||||
var cursor_ = cursor;
|
var cursor_ = cursor;
|
||||||
cursor_.move_buffer_begin();
|
cursor_.move_buffer_begin();
|
||||||
return self.scan_next_match(cursor_);
|
return self.scan_first_match();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scan_prev_match(self: *const Self, cursor: Cursor) ?*Match {
|
fn scan_prev_match(self: *const Self, cursor: Cursor) ?*Match {
|
||||||
|
|
|
@ -116,8 +116,8 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result {
|
||||||
'Q' => self.cmd("quit_without_saving", .{}),
|
'Q' => self.cmd("quit_without_saving", .{}),
|
||||||
'R' => self.cmd("restart", .{}),
|
'R' => self.cmd("restart", .{}),
|
||||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||||
'L' => self.cmd_async("toggle_logview"),
|
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||||
'I' => self.cmd_async("toggle_inputview"),
|
'I' => self.cmd_async("toggle_inspector_view"),
|
||||||
'/' => self.cmd("log_widgets", .{}),
|
'/' => self.cmd("log_widgets", .{}),
|
||||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||||
key.END => self.cmd("select_buffer_end", .{}),
|
key.END => self.cmd("select_buffer_end", .{}),
|
||||||
|
|
|
@ -118,8 +118,8 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result {
|
||||||
'Q' => self.cmd("quit_without_saving", .{}),
|
'Q' => self.cmd("quit_without_saving", .{}),
|
||||||
'R' => self.cmd("restart", .{}),
|
'R' => self.cmd("restart", .{}),
|
||||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||||
'L' => self.cmd_async("toggle_logview"),
|
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||||
'I' => self.cmd_async("toggle_inputview"),
|
'I' => self.cmd_async("toggle_inspector_view"),
|
||||||
'/' => self.cmd("log_widgets", .{}),
|
'/' => self.cmd("log_widgets", .{}),
|
||||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||||
key.END => self.cmd("select_buffer_end", .{}),
|
key.END => self.cmd("select_buffer_end", .{}),
|
||||||
|
|
|
@ -121,8 +121,8 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result {
|
||||||
'Q' => self.cmd("quit_without_saving", .{}),
|
'Q' => self.cmd("quit_without_saving", .{}),
|
||||||
'R' => self.cmd("restart", .{}),
|
'R' => self.cmd("restart", .{}),
|
||||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||||
'L' => self.cmd_async("toggle_logview"),
|
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||||
'I' => self.cmd_async("toggle_inputview"),
|
'I' => self.cmd_async("toggle_inspector_view"),
|
||||||
'/' => self.cmd("log_widgets", .{}),
|
'/' => self.cmd("log_widgets", .{}),
|
||||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||||
key.END => self.cmd("select_buffer_end", .{}),
|
key.END => self.cmd("select_buffer_end", .{}),
|
||||||
|
|
|
@ -121,8 +121,8 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result {
|
||||||
'Q' => self.cmd("quit_without_saving", .{}),
|
'Q' => self.cmd("quit_without_saving", .{}),
|
||||||
'R' => self.cmd("restart", .{}),
|
'R' => self.cmd("restart", .{}),
|
||||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||||
'L' => self.cmd_async("toggle_logview"),
|
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||||
'I' => self.cmd_async("toggle_inputview"),
|
'I' => self.cmd_async("toggle_inspector_view"),
|
||||||
'/' => self.cmd("log_widgets", .{}),
|
'/' => self.cmd("log_widgets", .{}),
|
||||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||||
key.END => self.cmd("select_buffer_end", .{}),
|
key.END => self.cmd("select_buffer_end", .{}),
|
||||||
|
|
Loading…
Add table
Reference in a new issue