From 1398641d22da7b313129dde7bad7134ac19589d4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 10 Apr 2013 19:02:28 +0200 Subject: [PATCH] Add gt, gb and gc to goto the first/last/middle displayed line --- README.asciidoc | 8 ++++++-- src/main.cc | 25 +++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 8836fb9c..96e6e2de 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -65,8 +65,12 @@ Basic Movement * _gh_, _alt-H_: select to line begin * _gl_, _alt-L_: select to line end - * _gg_, _gt_: go to the first line - * _gb_: go to the last line + * _gg_, _gk_: go to the first line + * _gj_: go to the last line + + * _gt_, _gk_: go to the first displayed line + * _gc_, _gk_: go to the middle displayed line + * _gb_: go to the last displayed line * _/_: search (select next match) * _?_: search (extend to next match) diff --git a/src/main.cc b/src/main.cc index a3e86a7e..97fc20b2 100644 --- a/src/main.cc +++ b/src/main.cc @@ -88,11 +88,32 @@ void do_go(Context& context) break; } case 'e': - { context.push_jump(); editor.select(editor.buffer().end()-1, mode); break; - } + case 't': + if (context.has_window()) + { + auto line = context.window().position().line; + editor.select(editor.buffer().iterator_at_line_begin(line), mode); + } + break; + case 'b': + if (context.has_window()) + { + auto& window = context.window(); + auto line = window.position().line + window.dimensions().line - 1; + editor.select(editor.buffer().iterator_at_line_begin(line), mode); + } + break; + case 'c': + if (context.has_window()) + { + auto& window = context.window(); + auto line = window.position().line + window.dimensions().line / 2; + editor.select(editor.buffer().iterator_at_line_begin(line), mode); + } + break; case 'a': { auto& buffer_manager = BufferManager::instance();