commands: add "registers" subcommand to :debug
This prints all non-empty registers and their value(s) to the `*debug*` buffer.
This commit is contained in:
parent
16547a1d46
commit
266e388c6b
|
@ -1392,7 +1392,7 @@ const CommandDesc debug_cmd = {
|
||||||
[](const Context& context, CompletionFlags flags,
|
[](const Context& context, CompletionFlags flags,
|
||||||
const String& prefix, ByteCount cursor_pos) -> Completions {
|
const String& prefix, ByteCount cursor_pos) -> Completions {
|
||||||
auto c = {"info", "buffers", "options", "memory", "shared-strings",
|
auto c = {"info", "buffers", "options", "memory", "shared-strings",
|
||||||
"profile-hash-maps", "faces", "mappings", "regex"};
|
"profile-hash-maps", "faces", "mappings", "regex", "registers"};
|
||||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) };
|
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) };
|
||||||
}),
|
}),
|
||||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
|
@ -1485,6 +1485,20 @@ const CommandDesc debug_cmd = {
|
||||||
write_to_debug_buffer(format(" * {}:\n{}",
|
write_to_debug_buffer(format(" * {}:\n{}",
|
||||||
parser[1], dump_regex(compile_regex(parser[1], RegexCompileFlags::Optimize))));
|
parser[1], dump_regex(compile_regex(parser[1], RegexCompileFlags::Optimize))));
|
||||||
}
|
}
|
||||||
|
else if (parser[0] == "registers")
|
||||||
|
{
|
||||||
|
write_to_debug_buffer("Register info:");
|
||||||
|
for (auto&& [name, reg] : RegisterManager::instance())
|
||||||
|
{
|
||||||
|
auto content = reg->get(context);
|
||||||
|
|
||||||
|
if (content.size() == 1 and content[0] == "")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
write_to_debug_buffer(format(" * {} = {}\n", name,
|
||||||
|
join(content | transform(quote), "\n = ")));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw runtime_error(format("no such debug command: '{}'", parser[0]));
|
throw runtime_error(format("no such debug command: '{}'", parser[0]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,9 @@ public:
|
||||||
void add_register(Codepoint c, std::unique_ptr<Register> reg);
|
void add_register(Codepoint c, std::unique_ptr<Register> reg);
|
||||||
CandidateList complete_register_name(StringView prefix, ByteCount cursor_pos) const;
|
CandidateList complete_register_name(StringView prefix, ByteCount cursor_pos) const;
|
||||||
|
|
||||||
|
auto begin() const { return m_registers.begin(); }
|
||||||
|
auto end() const { return m_registers.end(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HashMap<Codepoint, std::unique_ptr<Register>, MemoryDomain::Registers> m_registers;
|
HashMap<Codepoint, std::unique_ptr<Register>, MemoryDomain::Registers> m_registers;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user