Major updates/cleanup.
This commit is contained in:
@@ -60,7 +60,21 @@ void Function::register_posix(BEd &ctx) {
|
||||
.desc = "Change a range of lines",
|
||||
.default_address = ".,.",
|
||||
.accept_zero = false,
|
||||
.pre_text_mode = nullptr,
|
||||
.pre_text_mode = [](
|
||||
BEd &ctx,
|
||||
const buffer::Address &addr_,
|
||||
const Argument &
|
||||
) -> std::tuple<vase::Shard *, syntax::Language *, void *> {
|
||||
const auto &addr = std::get<buffer::Range>(addr_);
|
||||
auto &buf_ = ctx.buffer(addr.buffername);
|
||||
if (buf_.kind != buffer::Buffer::Kind::Generic)
|
||||
return {buf_.copy(addr.start, addr.end), nullptr, nullptr};
|
||||
auto &buf = *(buffer::GenericBuffer *)&buf_;
|
||||
if (!buf.parse.lang)
|
||||
return {buf.copy(addr.start, addr.end), nullptr, nullptr};
|
||||
void *state = nullptr; // TODO: buf.parse.root.get_at(addr.start);
|
||||
return {buf.copy(addr.start, addr.end), buf.parse.lang, state};
|
||||
},
|
||||
.handle = [](
|
||||
BEd &ctx,
|
||||
const buffer::Address &addr_,
|
||||
@@ -68,10 +82,9 @@ void Function::register_posix(BEd &ctx) {
|
||||
const Argument &,
|
||||
std::vector<buffer::Line> *
|
||||
) {
|
||||
auto addr = std::get<buffer::Range>(addr_);
|
||||
const auto &addr = std::get<buffer::Range>(addr_);
|
||||
ctx.buffer(addr.buffername).replace(ctx, text, addr.start, addr.end);
|
||||
vase::Shard::release(text);
|
||||
}
|
||||
vase::Shard::release(text); }
|
||||
}
|
||||
);
|
||||
ctx.functions.insert(
|
||||
|
||||
Reference in New Issue
Block a user