add <a-R> for rotating selections content

This commit is contained in:
Maxime Coste 2013-10-02 19:10:31 +01:00
parent 6331fb5a61
commit 6e5ff644f2
2 changed files with 18 additions and 1 deletions

View File

@ -80,10 +80,11 @@ Basic Movement
* _N_: add a new selection with next match
* _alt-n_: replace main selection with next match (preserving the others)
* _alt-c_: center main selection in current window
* _pageup_: scroll up
* _pagedown_: scroll down
* _alt-r_: rotate selections (the main selection becomes the next one)
Appending
---------
@ -141,6 +142,8 @@ Changes
* _~_: to upper case
* _alt-`_: swap case
* _alt-R_: rotate selections content
Goto Commands
-------------

View File

@ -658,6 +658,19 @@ void rotate_selections(Context& context)
context.editor().rotate_selections(count);
}
void rotate_selections_content(Context& context)
{
int count = context.numeric_param();
if (count == 0)
count = 1;
Editor& editor = context.editor();
auto strings = editor.selections_content();
count = count % strings.size();
std::rotate(strings.begin(), strings.end()-count, strings.end());
editor.insert(strings, InsertMode::Replace);
editor.rotate_selections(count);
}
enum class SelectFlags
{
None = 0,
@ -951,6 +964,7 @@ KeyMap keymap =
{ { Key::Modifiers::Control, 's' }, save_selections },
{ { Key::Modifiers::Alt, 'r' }, rotate_selections },
{ { Key::Modifiers::Alt, 'R' }, rotate_selections_content },
{ { Key::Modifiers::None, 'q' }, start_or_end_macro_recording },
{ { Key::Modifiers::None, 'Q' }, replay_macro },