Skip to content

Commit

Permalink
change *, <count>c, <count>d
Browse files Browse the repository at this point in the history
  • Loading branch information
pcc committed Jun 13, 2022
1 parent a0ff377 commit d6d55b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions share/kak/kakrc
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ evaluate-commands %sh{
set -add global ui_options terminal_enable_mouse=false
add-highlighter global/ wrap
set global indentwidth 2
map global normal * "w _ b *"
23 changes: 20 additions & 3 deletions src/normal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,21 @@ void yank(Context& context, NormalParams params)
context.faces()["Information"] });
}

enum Direction { Backward = -1, Forward = 1 };

template<typename Type, Direction direction, SelectMode mode = SelectMode::Replace>
void move_cursor(Context& context, NormalParams params);

template<bool yank>
void erase_selections(Context& context, NormalParams params)
{
if (params.count > 1)
{
NormalParams new_params = params;
new_params.count--;
move_cursor<CharCount, Forward, SelectMode::Extend>(context, new_params);
}

if (yank)
{
const char reg = params.reg ? params.reg : '"';
Expand All @@ -641,6 +653,13 @@ void erase_selections(Context& context, NormalParams params)
template<bool yank>
void change(Context& context, NormalParams params)
{
if (params.count > 1)
{
NormalParams new_params = params;
new_params.count--;
move_cursor<CharCount, Forward, SelectMode::Extend>(context, new_params);
}

if (yank)
{
const char reg = params.reg ? params.reg : '"';
Expand Down Expand Up @@ -1396,8 +1415,6 @@ void select_object(Context& context, NormalParams params)
{{alt(';')}, "run command in object context"}}));
}

enum Direction { Backward = -1, Forward = 1 };

template<Direction direction, bool half = false>
void scroll(Context& context, NormalParams params)
{
Expand Down Expand Up @@ -2064,7 +2081,7 @@ void repeated(Context& context, NormalParams params)
do { func(context, {0, params.reg}); } while(--params.count > 0);
}

template<typename Type, Direction direction, SelectMode mode = SelectMode::Replace>
template<typename Type, Direction direction, SelectMode mode>
void move_cursor(Context& context, NormalParams params)
{
kak_assert(mode == SelectMode::Replace or mode == SelectMode::Extend);
Expand Down

0 comments on commit d6d55b2

Please sign in to comment.