Honor suppress mode.

- Allow P command to create a new prompt string.
This commit is contained in:
2026-09-03 09:53:14 +01:00
parent 0104f96d51
commit cd9583ec34
+21 -11
View File
@@ -141,7 +141,8 @@ void Function::register_posix(BEd &ctx) {
vase::Shard::release(s); vase::Shard::release(s);
throw; throw;
} }
ctx.io.write_line(std::format("{}", buf.bytes())); if (!ctx.suppress_mode)
ctx.io.write_line(std::format("{}", buf.bytes()));
} }
} }
); );
@@ -186,7 +187,8 @@ void Function::register_posix(BEd &ctx) {
vase::Shard::release(s); vase::Shard::release(s);
throw; throw;
} }
ctx.io.write_line(std::format("{}", buf.bytes())); if (!ctx.suppress_mode)
ctx.io.write_line(std::format("{}", buf.bytes()));
} }
} }
); );
@@ -449,9 +451,9 @@ void Function::register_posix(BEd &ctx) {
"P", "P",
Function{ Function{
.address_kind = Function::AddressKind::None, .address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::None, .argument_kind = Function::ArgumentKind::Any,
.input_mode = Function::InputMode::None, .input_mode = Function::InputMode::None,
.desc = "Toggle prompt.", .desc = "Toggle/set prompt.",
.default_address = "", .default_address = "",
.accept_zero = false, .accept_zero = false,
.pre_text_mode = nullptr, .pre_text_mode = nullptr,
@@ -459,13 +461,18 @@ void Function::register_posix(BEd &ctx) {
BEd &ctx, BEd &ctx,
const buffer::Address &, const buffer::Address &,
vase::Shard *, vase::Shard *,
const Argument &, const Argument &arg_,
std::vector<buffer::Line> * std::vector<buffer::Line> *
) { ) {
ctx.prompt_mode = !ctx.prompt_mode; auto &arg = std::get<std::string>(arg_);
if (ctx.prompt_mode && !ctx.prompt) { if (arg.size()) {
ctx.prompt = [](BEd &) { return "*"; }; ctx.prompt_mode = true;
ctx.prompt = [arg](BEd &) { return arg; };
return;
} }
ctx.prompt_mode = !ctx.prompt_mode;
if (ctx.prompt_mode && !ctx.prompt)
ctx.prompt = [](BEd &) { return "*"; };
} }
} }
); );
@@ -558,12 +565,13 @@ void Function::register_posix(BEd &ctx) {
}; };
try { try {
buf.append(ctx, s, addr.number); buf.append(ctx, s, addr.number);
ctx.io.write_line(std::format("{}", s ? s->length + 1 : 0));
vase::Shard::release(s); vase::Shard::release(s);
} catch (...) { } catch (...) {
vase::Shard::release(s); vase::Shard::release(s);
throw; throw;
} }
if (!ctx.suppress_mode)
ctx.io.write_line(std::format("{}", s ? s->length + 1 : 0));
} }
} }
); );
@@ -705,12 +713,13 @@ void Function::register_posix(BEd &ctx) {
throw ed_error("Need filename."); throw ed_error("Need filename.");
vase::write_file(path, text); vase::write_file(path, text);
}; };
ctx.io.write(std::format("{}\n", text ? text->length + 1 : 0));
vase::Shard::release(text); vase::Shard::release(text);
} catch (...) { } catch (...) {
vase::Shard::release(text); vase::Shard::release(text);
throw; throw;
} }
if (!ctx.suppress_mode)
ctx.io.write(std::format("{}\n", text ? text->length + 1 : 0));
} }
} }
); );
@@ -767,7 +776,8 @@ void Function::register_posix(BEd &ctx) {
if (ctx.escape_command(cmd, filename.string())) if (ctx.escape_command(cmd, filename.string()))
ctx.io.write(cmd + "\n"); ctx.io.write(cmd + "\n");
ctx.io.run_pty(cmd); ctx.io.run_pty(cmd);
ctx.io.write("!\n"); if (!ctx.suppress_mode)
ctx.io.write("!\n");
}, },
} }
); );