Add all basic ed functions

- except global and history ones
This commit is contained in:
2026-08-31 08:14:12 +01:00
parent 010f916d35
commit a996beb4aa
15 changed files with 732 additions and 362 deletions
+13 -1
View File
@@ -192,7 +192,19 @@ std::optional<buffer::Range> AddressPromise::get_range(BEd &ctx, std::vector<Add
return buffer::Range(prev.resolve(ctx), curr.resolve(ctx));
}
} else if (std::holds_alternative<LastRange>(curr.base)) {
return ctx.prev();
auto previous = ctx.prev();
auto &buf = ctx.buffer(previous.buffername);
if (curr.offset < 0 && previous.start < (uint64_t)-curr.offset)
throw ed_error("Can't have negative addresses");
previous.start += curr.offset;
if (previous.start > buf.lines())
throw ed_error("Line number too high.");
if (curr.offset < 0 && previous.end < (uint64_t)-curr.offset)
throw ed_error("Can't have negative addresses");
previous.end += curr.offset;
if (previous.end > buf.lines())
throw ed_error("Line number too high.");
return previous;
}
if (prev_given)
return buffer::Range(prev.resolve(ctx), curr.resolve(ctx));