summaryrefslogtreecommitdiff
path: root/src/modal.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-22 09:50:43 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:24 -0300
commita8b457a306a4442975210bcac3f04b56513c61c3 (patch)
tree6e2026ecb15da2fb919a0202f5d8b38e3b36a595 /src/modal.zig
parenta8a1499bdffffc5b6919e24ec957e92fabaf003b (diff)
parent7e9d2c4169245072265b483ffaa6aa05f23f08d3 (diff)
downloadpardes-a8b457a306a4442975210bcac3f04b56513c61c3.tar.gz
pardes-a8b457a306a4442975210bcac3f04b56513c61c3.zip
Merge: Def/Refs, the diff viewer, Helix n/N, Callstack, Zig 0.17, Window mode and the terminal cwd fix onto 0.24
The docs keep both sides: 0.24's Ctrl-i fallbacks and typed ls with this line's Window mode, raw Esc and Helix n/N wording. The CHANGELOG's unreleased entries go above 0.24, Def/Refs and the context rows among them. cheatsheet-a4.pdf rendered again; .scratch/ ignored. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/modal.zig')
-rw-r--r--src/modal.zig29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/modal.zig b/src/modal.zig
index 316a66fa..82f1a3a0 100644
--- a/src/modal.zig
+++ b/src/modal.zig
@@ -36,6 +36,7 @@ pub const Normal = struct {
goto_type_definition,
goto_implementation,
goto_references,
+ goto_callstack,
view_top,
view_center,
@@ -157,10 +158,12 @@ pub const Normal = struct {
search,
search_next,
search_prev,
+ search_selection,
+ search_selection_word,
};
pub const Input = struct {
- roles: std.EnumSet(Role) = .initEmpty(),
+ roles: std.EnumSet(Role) = .empty,
cp: u21,
ctrl: bool = false,
alt: bool = false,
@@ -318,7 +321,7 @@ pub const Normal = struct {
undo,
redo,
};
- pub const Lsp = enum { definition, declaration, type_definition, implementation, references, format };
+ pub const Lsp = enum { definition, declaration, type_definition, implementation, references, callstack, format };
pub const Counted = struct {
count: u32,
@@ -355,7 +358,8 @@ pub const Normal = struct {
command_line,
pipe_selection: PipeBehavior,
search,
- search_step: Direction,
+ search_step: struct { direction: Direction, count: u32 },
+ search_selection: bool,
goto_word,
macro_record,
macro_replay: u32,
@@ -373,6 +377,7 @@ pub const Normal = struct {
.pipe_selection,
.search,
.search_step,
+ .search_selection,
.macro_record,
.macro_replay,
.node,
@@ -467,6 +472,7 @@ pub const Normal = struct {
if (key.has(.goto_type_definition)) return resultAction(.{ .lsp = .type_definition });
if (key.has(.goto_implementation)) return resultAction(.{ .lsp = .implementation });
if (key.has(.goto_references)) return resultAction(.{ .lsp = .references });
+ if (key.has(.goto_callstack)) return resultAction(.{ .lsp = .callstack });
return .ignored;
},
.view => {
@@ -676,8 +682,10 @@ pub const Normal = struct {
if (key.has(.macro_replay)) return resultAction(.{ .macro_replay = count });
if (key.has(.repeat_insert)) return resultAction(.{ .repeat_insert = count });
if (key.has(.search)) return resultAction(.search);
- if (key.has(.search_next)) return resultAction(.{ .search_step = .forward });
- if (key.has(.search_prev)) return resultAction(.{ .search_step = .backward });
+ if (key.has(.search_selection)) return resultAction(.{ .search_selection = false });
+ if (key.has(.search_selection_word)) return resultAction(.{ .search_selection = true });
+ if (key.has(.search_next)) return resultAction(.{ .search_step = .{ .direction = .forward, .count = count } });
+ if (key.has(.search_prev)) return resultAction(.{ .search_step = .{ .direction = .backward, .count = count } });
return .unbound;
}
@@ -1420,6 +1428,17 @@ fn wordClassAt(text: []const u8, off: usize) WordClass {
};
}
+pub fn searchWordAt(text: []const u8, off: usize) bool {
+ return off < text.len and wordClassAt(text, off) == .word;
+}
+
+pub fn searchWordBefore(text: []const u8, off: usize) bool {
+ if (off == 0) return false;
+ var previous = off - 1;
+ while (previous > 0 and text[previous] & 0xc0 == 0x80) previous -= 1;
+ return searchWordAt(text, previous);
+}
+
fn isWordWhitespace(c: WordClass) bool { // Rust char::is_whitespace (includes line endings)
return c == .ws or c == .eol;
}