Add zero-indexed register

This commit is contained in:
xenia 2023-10-11 19:36:16 +02:00
parent f94e8e49ed
commit ad9a4b25d5
3 changed files with 13 additions and 0 deletions

View File

@ -198,6 +198,7 @@ constexpr StringView register_doc =
"%: buffer name\n" "%: buffer name\n"
".: selection contents\n" ".: selection contents\n"
"#: selection index\n" "#: selection index\n"
"$: selection index (zero-indexed)\n"
"_: null register\n" "_: null register\n"
"\": default yank/paste register\n" "\": default yank/paste register\n"
"@: default macro register\n" "@: default macro register\n"

View File

@ -436,6 +436,17 @@ void register_registers()
return res; return res;
})); }));
register_manager.add_register('$', make_dyn_reg(
"$",
[](const Context& context) {
const size_t count = context.selections().size();
StringList res;
res.reserve(count);
for (size_t i = 0; i < count; ++i)
res.push_back(to_string((int)i));
return res;
}));
for (size_t i = 0; i < 10; ++i) for (size_t i = 0; i < 10; ++i)
{ {
register_manager.add_register('0'+i, make_dyn_reg( register_manager.add_register('0'+i, make_dyn_reg(

View File

@ -67,6 +67,7 @@ static const HashMap<StringView, Codepoint> reg_names {
{ "percent", '%' }, { "percent", '%' },
{ "dot", '.' }, { "dot", '.' },
{ "hash", '#' }, { "hash", '#' },
{ "dollar", '$' },
{ "underscore", '_' }, { "underscore", '_' },
{ "colon", ':' } { "colon", ':' }
}; };