commit 3d06a08091e0de7e3e156e0d359eb3cf7e0a695b
parent a950a2e08a1a2650976d41d43bdd185292da6bb1
Author: Byron Torres <b@torresjrjr.com>
Date: Sat, 6 Jan 2024 13:25:19 +0000
cmd_global_interactive() progress
Diffstat:
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/command.ha b/command.ha
@@ -269,6 +269,7 @@ fn cmd_global_interative(s: *Session, cmd: *Command) (void | Error) = {
addr_lastline(s.buf),
)?;
assert_nonzero(s, a)?;
+
const regex = regex::compile(cmd.arg1)?; defer regex::finish(®ex);
for (let i = a; i <= b; i += 1) {
@@ -289,24 +290,23 @@ fn cmd_global_interative(s: *Session, cmd: *Command) (void | Error) = {
break :lines;
};
};
- const line = s.buf.lines[n];
+ s.buf.cursor = n;
+ let line = s.buf.lines[n];
fmt::println(line.text)!;
- s.buf.cursor = n;
- let cmd = Command{ ... };
+ let cmd = parse(s.input)!;
- // const rawinput = match (bufio::read_line(os::stdin)?) {
- // case let bs: []u8 =>
- // yield bs;
- // case io::EOF =>
- // return UnexpectedEOF;
- // };
- // defer free(rawinput);
- // const input = strings::fromutf8(rawinput)?;
+ // write new parse_global_interactive() function instead
+ // as to avoid reading multiple lines in the case of
+ // 'a', 'c', 'i' ?
+ switch (cmd.cmdname) {
+ case 'a', 'c', 'i', 'g', 'G', 'v', 'V' =>
+ // return new type 'InvalidGlobalInteractiveSubcmd' ?
+ continue;
+ case => void;
+ };
- const input = scanline(s)?;
- let cmd = parse(s.input)!;
execute(s, &cmd)?;
// TODO: test if line was modified.