Add all basic ed functions
- except global and history ones
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -103,6 +103,8 @@ void Parser::operation() {
|
||||
command->argument = functions::Function::GlobalArg(delim, std::move(val));
|
||||
} break;
|
||||
case functions::Function::ArgumentKind::File:
|
||||
if (!(peek() == '\t' || peek() == ' ' || peek() == '\0'))
|
||||
throw ed_error("Incorrect file input usage.");
|
||||
skip_ws();
|
||||
switch (peek()) {
|
||||
case '!':
|
||||
|
||||
Reference in New Issue
Block a user