ed

[hare] The standard editor
Log | Files | Refs | README | LICENSE

commit 721dafa51156bc0e4004cce60c35707c131bec53
parent 7a91d68743d7c62f07e27af75e3883ea9a4ef959
Author: Byron Torres <b@torresjrjr.com>
Date:   Tue, 13 Dec 2022 22:47:54 +0000

progress

Diffstat:
Mcommand.ha | 18++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/command.ha b/command.ha @@ -152,7 +152,7 @@ fn cmd_edit(s: *session, cmd: *command) (void | error) = { assert_noaddrs(s, cmd.linenums)?; if (s.buf.modified && !s.warned) { - s.warned = true; + s.warned = true; // TODO: reset this every command somehow return buffermodified; }; @@ -255,7 +255,10 @@ fn cmd_mark(s: *session, cmd: *command) (void | error) = { const n = get_linenum(cmd.linenums, s.buf.cursor); assert_nonzero(s, n)?; - const mark = strings::runes(cmd.arg)[0]; // TODO: check len, etc... + // TODO: this should use ".suffix", not ".arg", and parse() should + // handle this + // TODO: check len, etc... + const mark = strings::runes(cmd.arg)[0]; debug("cmd_mark(): mark={}", mark); :search { @@ -300,12 +303,13 @@ fn cmd_move(s: *session, cmd: *command) (void | error) = { const iter = strings::iter(cmd.arg); const n = match (scan_addr(&iter)) { case let addr: address => - yield 1 + (match (exec_addr(s, addr)) { + const n = match (exec_addr(s, addr)) { case let n: size => yield n; case invalidaddress => return invaliddestination; - }); + }; + yield n + 1; // like insert case void => return invalidaddress; }; @@ -326,9 +330,6 @@ fn cmd_move(s: *session, cmd: *command) (void | error) = { }; const ls = alloc(s.buf.lines[a..b+1]...); defer free(ls); -// for (let i = 0z; i < len(ls); i += 1) { -// debug("cmd_move(): ls[{}].text='{}'", i, ls[i].text); -// }; buf_delete(&s.buf, a, b); buf_insert(&s.buf, dest, ls...); @@ -425,9 +426,6 @@ fn cmd_copy(s: *session, cmd: *command) (void | error) = { debug("cmd_copy(): dest={}", dest); const ls = alloc(s.buf.lines[a..b+1]...); defer free(ls); -// for (let i = 0z; i < len(ls); i += 1) { -// debug("cmd_copy(): ls[{}].text='{}'", i, ls[i].text); -// }; buf_insert(&s.buf, dest, ls...); s.buf.cursor = dest - 1 + len(ls);