Merge remote-tracking branch 'Delapouite/debug-mappings'
This commit is contained in:
commit
3cfd3a3276
|
@ -685,7 +685,7 @@ Some commands take an exclamation mark (`!`), which can be used to force
|
||||||
the execution of the command (i.e. to quit a modified buffer, the
|
the execution of the command (i.e. to quit a modified buffer, the
|
||||||
command `q!` has to be used).
|
command `q!` has to be used).
|
||||||
|
|
||||||
* `cd [<directory>]`: change the current directory to `<directory>`, or the home directory is unspecified
|
* `cd [<directory>]`: change the current directory to `<directory>`, or the home directory if unspecified
|
||||||
* `doc <topic>`: display documentation about a topic. The completion list
|
* `doc <topic>`: display documentation about a topic. The completion list
|
||||||
displays the available topics.
|
displays the available topics.
|
||||||
* `e[dit][!] <filename> [<line> [<column>]]`: open buffer on file, go to given
|
* `e[dit][!] <filename> [<line> [<column>]]`: open buffer on file, go to given
|
||||||
|
@ -1597,7 +1597,7 @@ Some helper commands can be used to define composite commands:
|
||||||
* `reg <name> <content>`: set register <name> to <content>
|
* `reg <name> <content>`: set register <name> to <content>
|
||||||
* `select <anchor_line>.<anchor_column>,<cursor_line>.<cursor_column>:...`:
|
* `select <anchor_line>.<anchor_column>,<cursor_line>.<cursor_column>:...`:
|
||||||
replace the current selections with the one described in the argument
|
replace the current selections with the one described in the argument
|
||||||
* `debug {info,buffers,options,memory,shared-strings,profile-hash-maps,faces}`:
|
* `debug {info,buffers,options,memory,shared-strings,profile-hash-maps,faces,mappings}`:
|
||||||
print some debug information in the `*debug*` buffer
|
print some debug information in the `*debug*` buffer
|
||||||
|
|
||||||
Note that these commands are available in interactive command mode, but are
|
Note that these commands are available in interactive command mode, but are
|
||||||
|
|
|
@ -221,7 +221,7 @@ commands:
|
||||||
*select* <anchor_line>.<anchor_column>,<cursor_line>.<cursor_column>:...::
|
*select* <anchor_line>.<anchor_column>,<cursor_line>.<cursor_column>:...::
|
||||||
replace the current selections with the one described in the argument
|
replace the current selections with the one described in the argument
|
||||||
|
|
||||||
*debug* {info,buffers,options,memory,shared-strings,profile-hash-maps,faces}::
|
*debug* {info,buffers,options,memory,shared-strings,profile-hash-maps,faces,mappings}::
|
||||||
print some debug information in the *\*debug** buffer
|
print some debug information in the *\*debug** buffer
|
||||||
|
|
||||||
Note that those commands are also available in the interactive mode, but
|
Note that those commands are also available in the interactive mode, but
|
||||||
|
|
|
@ -1111,6 +1111,19 @@ const CommandDesc echo_cmd = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
KeymapMode parse_keymap_mode(const String& str)
|
||||||
|
{
|
||||||
|
if (prefix_match("normal", str)) return KeymapMode::Normal;
|
||||||
|
if (prefix_match("insert", str)) return KeymapMode::Insert;
|
||||||
|
if (prefix_match("menu", str)) return KeymapMode::Menu;
|
||||||
|
if (prefix_match("prompt", str)) return KeymapMode::Prompt;
|
||||||
|
if (prefix_match("goto", str)) return KeymapMode::Goto;
|
||||||
|
if (prefix_match("view", str)) return KeymapMode::View;
|
||||||
|
if (prefix_match("user", str)) return KeymapMode::User;
|
||||||
|
if (prefix_match("object", str)) return KeymapMode::Object;
|
||||||
|
|
||||||
|
throw runtime_error(format("unknown keymap mode '{}'", str));
|
||||||
|
}
|
||||||
|
|
||||||
const CommandDesc debug_cmd = {
|
const CommandDesc debug_cmd = {
|
||||||
"debug",
|
"debug",
|
||||||
|
@ -1124,7 +1137,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"};
|
"profile-hash-maps", "faces", "mappings"};
|
||||||
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&)
|
||||||
|
@ -1180,6 +1193,21 @@ const CommandDesc debug_cmd = {
|
||||||
for (auto& face : FaceRegistry::instance().aliases())
|
for (auto& face : FaceRegistry::instance().aliases())
|
||||||
write_to_debug_buffer(format(" * {}: {}", face.key, face.value.face));
|
write_to_debug_buffer(format(" * {}: {}", face.key, face.value.face));
|
||||||
}
|
}
|
||||||
|
else if (parser[0] == "mappings")
|
||||||
|
{
|
||||||
|
auto& keymaps = context.keymaps();
|
||||||
|
auto modes = {"normal", "insert", "prompt", "menu",
|
||||||
|
"goto", "view", "user", "object"};
|
||||||
|
write_to_debug_buffer("Mappings:");
|
||||||
|
for (auto& mode : modes)
|
||||||
|
{
|
||||||
|
KeymapMode m = parse_keymap_mode(mode);
|
||||||
|
for (auto& key : keymaps.get_mapped_keys(m))
|
||||||
|
write_to_debug_buffer(format(" * {} {}: {}",
|
||||||
|
mode, key_to_str(key),
|
||||||
|
keymaps.get_mapping(key, m).docstring));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw runtime_error(format("unknown debug command '{}'", parser[0]));
|
throw runtime_error(format("unknown debug command '{}'", parser[0]));
|
||||||
}
|
}
|
||||||
|
@ -1394,20 +1422,6 @@ const CommandDesc declare_option_cmd = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
KeymapMode parse_keymap_mode(const String& str)
|
|
||||||
{
|
|
||||||
if (prefix_match("normal", str)) return KeymapMode::Normal;
|
|
||||||
if (prefix_match("insert", str)) return KeymapMode::Insert;
|
|
||||||
if (prefix_match("menu", str)) return KeymapMode::Menu;
|
|
||||||
if (prefix_match("prompt", str)) return KeymapMode::Prompt;
|
|
||||||
if (prefix_match("goto", str)) return KeymapMode::Goto;
|
|
||||||
if (prefix_match("view", str)) return KeymapMode::View;
|
|
||||||
if (prefix_match("user", str)) return KeymapMode::User;
|
|
||||||
if (prefix_match("object", str)) return KeymapMode::Object;
|
|
||||||
|
|
||||||
throw runtime_error(format("unknown keymap mode '{}'", str));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto map_key_completer =
|
auto map_key_completer =
|
||||||
[](const Context& context, CompletionFlags flags,
|
[](const Context& context, CompletionFlags flags,
|
||||||
CommandParameters params, size_t token_to_complete,
|
CommandParameters params, size_t token_to_complete,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user