From 6331fb5a61a7631fa217edde277e6e091762ec3f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 2 Oct 2013 18:48:50 +0100 Subject: [PATCH] Add for saving current selection in the jump list --- README.asciidoc | 11 +++++++++++ src/context.cc | 6 ++++++ src/normal.cc | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/README.asciidoc b/README.asciidoc index ad575682..b6783067 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -173,6 +173,17 @@ view. * _vk_: scroll the window count line upward * _vl_: scroll the window count columns right +Jump list +--------- + +Some commands, like the goto commands, buffer switch or search commands, +push the previous selections to the client's jump list. It is possible +to forward or backward in the jump list using: + + * _control-i_: Jump forward + * _control-o_: Jump backward + * _control-s_: save current selections + Multi Selection --------------- diff --git a/src/context.cc b/src/context.cc index f81d2b9e..c36984e6 100644 --- a/src/context.cc +++ b/src/context.cc @@ -108,6 +108,12 @@ const DynamicSelectionList& Context::jump_forward() const DynamicSelectionList& Context::jump_backward() { + if (m_current_jump != m_jump_list.end() and + *m_current_jump != editor().selections()) + { + push_jump(); + return *--m_current_jump; + } if (m_current_jump != m_jump_list.begin()) { if (m_current_jump == m_jump_list.end()) diff --git a/src/normal.cc b/src/normal.cc index 5cb99648..768801c4 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -746,6 +746,13 @@ void jump(Context& context) context.editor().select(SelectionList{ jump }); } +void save_selections(Context& context) +{ + context.push_jump(); + context.print_status({ "saved " + to_string(context.editor().selections().size()) + + " selections", get_color("Information") }); +} + template void align(Context& context) { @@ -941,6 +948,7 @@ KeyMap keymap = { { Key::Modifiers::Control, 'i' }, jump }, { { Key::Modifiers::Control, 'o' }, jump }, + { { Key::Modifiers::Control, 's' }, save_selections }, { { Key::Modifiers::Alt, 'r' }, rotate_selections },