commit bf56170ec27ec0f4877c419a921fcdea61951750
parent 68d687a913ca150afed7877b26343356b1dc87dc
Author: Byron Torres <b@torresjrjr.com>
Date: Sat, 6 Jan 2024 16:42:57 +0000
progress, global
Diffstat:
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/buffer.ha b/buffer.ha
@@ -49,6 +49,10 @@ fn buf_delete(buf: *Buffer, a: size, b: size) void = {
debug("buf_delete(a={}, b={})", a, b);
// buf_wipetrash(buf);
+ //for (let i = 0z; i < len(buf.lines); i += 1) {
+ // buf.lines[i].globalmark = false;
+ //};
+
insert(buf.trash[0], buf.lines[a..b+1]...);
delete(buf.lines[a..b+1]);
if (buf.written)
diff --git a/command.ha b/command.ha
@@ -274,12 +274,13 @@ fn cmd_global_interative(s: *Session, cmd: *Command) (void | Error) = {
for (let i = a; i <= b; i += 1) {
const line = s.buf.lines[i];
+ line.globalmark = false; // TODO: is this necessary?
if (regex::test(®ex, line.text)) {
line.globalmark = true;
};
};
- let prevcmd: (void | Command) = void;
+ let prevsubcmd: (void | Command) = void;
for :marks (true) {
// find next global-marked line
@@ -297,32 +298,39 @@ fn cmd_global_interative(s: *Session, cmd: *Command) (void | Error) = {
fmt::println(line.text)!;
- let cmd = parse(s.input)!;
+ let subcmd = parse(s.input)!;
// write new parse_global_interactive() function instead
// as to avoid reading multiple lines in the case of
// 'a', 'c', 'i' ?
- switch (cmd.cmdname) {
+ switch (subcmd.cmdname) {
case 'a', 'c', 'i', 'g', 'G', 'v', 'V' =>
// TODO: how to handle?
// return !InvalidGlobalInteractiveSubcmd; ?
+ fmt::printfln(
+ "Error: Invalid interactive global subcommand '{}'",
+ subcmd.cmdname,
+ )!;
continue;
case NUL =>
line.globalmark = false;
continue;
case '&' =>
- match (prevcmd) {
+ match (prevsubcmd) {
case void =>
- // TODO: return NoPrevGlobalCmd;
+ // TODO: return NoPrevGlobalSubCmd;
abort("global interactive: &: no previous command");
- case let prevcmd: Command =>
- cmd = prevcmd;
+ case let prevsubcmd: Command =>
+ subcmd = prevsubcmd;
};
+ case 'u' =>
+ // TODO: undo behaviour
+ continue;
case =>
- prevcmd = cmd;
+ prevsubcmd = subcmd;
};
- execute(s, &cmd)?;
+ execute(s, &subcmd)?;
// TODO: test if line was modified.
// TODO: make cmd_ functions save to session whether line was