Move rotate selection and rotate selection contents to ) and <a-)>
Backward rotation are supported with (. Fixes #1210
This commit is contained in:
parent
683ce8e83b
commit
ec7f3738ee
|
@ -1,5 +1,5 @@
|
||||||
┌───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┲━━━━━━━━━━━━━━┓
|
┌───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┲━━━━━━━━━━━━━━┓
|
||||||
│ upper│ cmdout│convtab│ │selpipe│sel all│ │ align│pattern│ │ │ trim│ ┃ ⇤ ┃
|
│ upper│ cmdout│convtab│ │selpipe│sel all│ │ align│pattern│ rotate│ rotate│ trim│ ┃ ⇤ ┃
|
||||||
├┄┄CASE┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┨ ┃
|
├┄┄CASE┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┨ ┃
|
||||||
│ lower│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ │ ┃ ┃
|
│ lower│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ │ ┃ ┃
|
||||||
┢━━━━━━━┷━━━┱───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┺━━━┳━━━━━━━━━━┫
|
┢━━━━━━━┷━━━┱───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┺━━━┳━━━━━━━━━━┫
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
┣━━━━━━━━━━━┻━┱─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┺━┓ ┃
|
┣━━━━━━━━━━━┻━┱─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┺━┓ ┃
|
||||||
┃ ⇬ ┃ APPEND│ split│ │ ᵐʳ│ ᵐᵍ│ ᵐˡ│ ᵐ│ ᵐ│ ᵐˡ│cmdline│use reg│ pipe┃ ┃
|
┃ ⇬ ┃ APPEND│ split│ │ ᵐʳ│ ᵐᵍ│ ᵐˡ│ ᵐ│ ᵐ│ ᵐˡ│cmdline│use reg│ pipe┃ ┃
|
||||||
┃ ┠┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ find│ goto │ │ │ │ ├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┨ ┃
|
┃ ┠┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ find│ goto │ │ │ │ ├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┨ ┃
|
||||||
┃ ┃ append│ select│ delete│ char│ │ ← │ ↓ │ ↑ │ → │ cursor│ rotate│eschook┃ ┃
|
┃ ┃ append│ select│ delete│ char│ │ ← │ ↓ │ ↑ │ → │ cursor│ │eschook┃ ┃
|
||||||
┣━━━━━━━━━┳━━━┹───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┲━━━┷━━━━━━━┻━━━━━━━━┫
|
┣━━━━━━━━━┳━━━┹───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┲━━━┷━━━━━━━┻━━━━━━━━┫
|
||||||
┃ ┃ indent│ save│ ᵐ│copysel│ ᵛ│ ᵐʷ│ ᵐʳ│ │ dedent│ indent│ ᵐʳ┃ ┃
|
┃ ┃ indent│ save│ ᵐ│copysel│ ᵛ│ ᵐʷ│ ᵐʳ│ │ dedent│ indent│ ᵐʳ┃ ┃
|
||||||
┃ ┠┄┄┄┄┄┄┄┼┄MARKS┄┤ select├┄┄┄┄┄┄┄┤ view│ prev│ search│ match├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ search┃ ┃
|
┃ ┠┄┄┄┄┄┄┄┼┄MARKS┄┤ select├┄┄┄┄┄┄┄┤ view│ prev│ search│ match├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ search┃ ┃
|
||||||
|
|
|
@ -196,11 +196,11 @@ is a sequence of non whitespace characters
|
||||||
*<c-d>*::
|
*<c-d>*::
|
||||||
scroll half a page down
|
scroll half a page down
|
||||||
|
|
||||||
*'*::
|
*)*::
|
||||||
rotate selections (the main selection becomes the next one)
|
rotate main selection (the main selection becomes the next one)
|
||||||
|
|
||||||
*<a-'>*::
|
*(*::
|
||||||
rotate selections backwards
|
rotate main selection backward (the main selection becomes the previous one)
|
||||||
|
|
||||||
*;*::
|
*;*::
|
||||||
reduce selections to their cursor
|
reduce selections to their cursor
|
||||||
|
@ -362,7 +362,7 @@ is a sequence of non whitespace characters
|
||||||
*_*::
|
*_*::
|
||||||
trim selections
|
trim selections
|
||||||
|
|
||||||
*<a-">*::
|
*<a-)>*::
|
||||||
rotate selections content, if specified, the count groups selections,
|
rotate selections content, if specified, the count groups selections,
|
||||||
so the following command
|
so the following command
|
||||||
|
|
||||||
|
@ -372,6 +372,9 @@ is a sequence of non whitespace characters
|
||||||
|
|
||||||
rotate (1, 2, 3) and (3, 4, 6) independently
|
rotate (1, 2, 3) and (3, 4, 6) independently
|
||||||
|
|
||||||
|
*<a-(>*::
|
||||||
|
rotate selections content backward
|
||||||
|
|
||||||
== Goto commands
|
== Goto commands
|
||||||
|
|
||||||
*g*, *G*::
|
*g*, *G*::
|
||||||
|
|
|
@ -1365,10 +1365,11 @@ void rotate_selections(Context& context, NormalParams params)
|
||||||
: (index + (num - count % num)) % num);
|
: (index + (num - count % num)) % num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<Direction direction>
|
||||||
void rotate_selections_content(Context& context, NormalParams params)
|
void rotate_selections_content(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
int group = params.count;
|
size_t group = params.count;
|
||||||
int count = 1;
|
size_t count = 1;
|
||||||
auto strings = context.selections_content();
|
auto strings = context.selections_content();
|
||||||
if (group == 0 or group > (int)strings.size())
|
if (group == 0 or group > (int)strings.size())
|
||||||
group = (int)strings.size();
|
group = (int)strings.size();
|
||||||
|
@ -1376,13 +1377,20 @@ void rotate_selections_content(Context& context, NormalParams params)
|
||||||
for (auto it = strings.begin(); it != strings.end(); )
|
for (auto it = strings.begin(); it != strings.end(); )
|
||||||
{
|
{
|
||||||
auto end = std::min(strings.end(), it + group);
|
auto end = std::min(strings.end(), it + group);
|
||||||
std::rotate(it, end-count, end);
|
if (direction == Direction::Forward)
|
||||||
|
std::rotate(it, end-count, end);
|
||||||
|
else
|
||||||
|
std::rotate(it, it+count, end);
|
||||||
it = end;
|
it = end;
|
||||||
}
|
}
|
||||||
auto& selections = context.selections();
|
auto& selections = context.selections();
|
||||||
selections.insert(strings, InsertMode::Replace);
|
selections.insert(strings, InsertMode::Replace);
|
||||||
selections.set_main_index((selections.main_index() + count) %
|
const size_t index = selections.main_index();
|
||||||
selections.size());
|
const size_t index_in_group = index % group;
|
||||||
|
selections.set_main_index(index - index_in_group +
|
||||||
|
(direction == Forward) ?
|
||||||
|
(index_in_group + count) % group
|
||||||
|
: (index_in_group + group - count % group) % group);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class SelectFlags
|
enum class SelectFlags
|
||||||
|
@ -2182,9 +2190,10 @@ static const HashMap<Key, NormalCmd, MemoryDomain::Undefined, KeymapBackend> key
|
||||||
{ {ctrl('o')}, {"jump backward in jump list", jump<Backward>} },
|
{ {ctrl('o')}, {"jump backward in jump list", jump<Backward>} },
|
||||||
{ {ctrl('s')}, {"push current selections in jump list", push_selections} },
|
{ {ctrl('s')}, {"push current selections in jump list", push_selections} },
|
||||||
|
|
||||||
{ {'\''}, {"rotate main selection forward", rotate_selections<Forward>} },
|
{ {')'}, {"rotate main selection forward", rotate_selections<Forward>} },
|
||||||
{ {alt('\'')}, {"rotate main selection backward", rotate_selections<Backward>} },
|
{ {'('}, {"rotate main selection backward", rotate_selections<Backward>} },
|
||||||
{ {alt('"')}, {"rotate selections content", rotate_selections_content} },
|
{ {alt(')')}, {"rotate selections content forward", rotate_selections_content<Forward>} },
|
||||||
|
{ {alt('(')}, {"rotate selections content backward", rotate_selections_content<Backward>} },
|
||||||
|
|
||||||
{ {'q'}, {"replay recorded macro", replay_macro} },
|
{ {'q'}, {"replay recorded macro", replay_macro} },
|
||||||
{ {'Q'}, {"start or end macro recording", start_or_end_macro_recording} },
|
{ {'Q'}, {"start or end macro recording", start_or_end_macro_recording} },
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<a-">
|
<a-)>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
'<a-space>
|
)<a-space>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
%<a-s>_<a-">
|
%<a-s>_<a-)>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user