1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-29 10:02:57 +03:00

Default register is not handled by the Normal input mode.

Normal input mode will just pass 0 as the reg if it was not specified
by the user, its yank/paste functions that should determine 0 means
use '"' register.
This commit is contained in:
Maxime Coste 2015-08-19 13:41:16 +01:00
parent 3f493fa186
commit baf0203b9d
2 changed files with 14 additions and 9 deletions

View File

@ -246,7 +246,7 @@ public:
get_face("Information"), InfoStyle::Prompt);
it->func(context(), m_params);
}
m_params = { 0, '"' };
m_params = { 0, 0 };
}
context().hooks().run_hook("NormalKey", key_to_str(key), context());
@ -261,7 +261,7 @@ public:
atoms.push_back({ "; param=", Face(Color::Yellow) });
atoms.push_back({ to_string(m_params.count), Face(Color::Green) });
}
if (m_params.reg != '"')
if (m_params.reg)
{
atoms.push_back({ "; reg=", Face(Color::Yellow) });
atoms.push_back({ StringView(m_params.reg).str(), Face(Color::Green) });
@ -272,7 +272,7 @@ public:
KeymapMode keymap_mode() const override { return KeymapMode::Normal; }
private:
NormalParams m_params = { 0, '"' };
NormalParams m_params = { 0, 0 };
bool m_hooks_disabled = false;
bool m_waiting_for_reg = false;
Timer m_idle_timer;

View File

@ -460,15 +460,17 @@ void select_next_match(const Buffer& buffer, SelectionList& selections,
void yank(Context& context, NormalParams params)
{
RegisterManager::instance()[params.reg] = context.selections_content();
const char reg = params.reg ? params.reg : '"';
RegisterManager::instance()[reg] = context.selections_content();
context.print_status({ format("yanked {} selections to register {}",
context.selections().size(), params.reg),
context.selections().size(), reg),
get_face("Information") });
}
void erase_selections(Context& context, NormalParams params)
{
RegisterManager::instance()[params.reg] = context.selections_content();
const char reg = params.reg ? params.reg : '"';
RegisterManager::instance()[reg] = context.selections_content();
ScopedEdition edition(context);
context.selections().erase();
context.selections().avoid_eol();
@ -476,7 +478,8 @@ void erase_selections(Context& context, NormalParams params)
void change(Context& context, NormalParams params)
{
RegisterManager::instance()[params.reg] = context.selections_content();
const char reg = params.reg ? params.reg : '"';
RegisterManager::instance()[reg] = context.selections_content();
enter_insert_mode<InsertMode::Replace>(context, params);
}
@ -493,7 +496,8 @@ constexpr InsertMode adapt_for_linewise(InsertMode mode)
template<InsertMode mode>
void paste(Context& context, NormalParams params)
{
auto strings = RegisterManager::instance()[params.reg].values(context);
const char reg = params.reg ? params.reg : '"';
auto strings = RegisterManager::instance()[reg].values(context);
InsertMode effective_mode = mode;
for (auto& str : strings)
{
@ -510,7 +514,8 @@ void paste(Context& context, NormalParams params)
template<InsertMode mode>
void paste_all(Context& context, NormalParams params)
{
auto strings = RegisterManager::instance()[params.reg].values(context);
const char reg = params.reg ? params.reg : '"';
auto strings = RegisterManager::instance()[reg].values(context);
InsertMode effective_mode = mode;
String all;
Vector<ByteCount> offsets;