diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-11-02 19:49:58 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-11-02 19:51:59 +0000 |
| commit | c8d24176469124dd74567caccc45560ea7ad23d7 (patch) | |
| tree | 0584ac07760625406c67eac93bd23a7ae3d2da89 /src/normal.cc | |
| parent | 17eef4a7dc3883b725069616d90db3a519837638 (diff) | |
Support horizontal centering in view commands (using m)
Fixes #442
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/normal.cc b/src/normal.cc index 2ec36d10..28a8c322 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -239,19 +239,23 @@ void view_commands(Context& context, NormalParams params) if (not cp or not context.has_window()) return; - LineCount cursor_line = context.selections().main().cursor().line; + const ByteCoord cursor = context.selections().main().cursor(); Window& window = context.window(); switch (tolower(*cp)) { case 'v': case 'c': - context.window().center_line(cursor_line); + context.window().center_line(cursor.line); + break; + case 'm': + context.window().center_column( + context.buffer()[cursor.line].char_count_to(cursor.column)); break; case 't': - context.window().display_line_at(cursor_line, 0); + context.window().display_line_at(cursor.line, 0); break; case 'b': - context.window().display_line_at(cursor_line, window.dimensions().line-1); + context.window().display_line_at(cursor.line, window.dimensions().line-1); break; case 'h': context.window().scroll(-std::max<CharCount>(1, params.count)); @@ -267,7 +271,8 @@ void view_commands(Context& context, NormalParams params) break; } }, "view", - "v,c: center cursor \n" + "v,c: center cursor (vertically)\n" + "m: center cursor (horzontally)\n" "t: cursor on top \n" "b: cursor on bottom\n" "h: scroll left \n" |
