1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-10-05 17:18:00 +03:00
This commit is contained in:
Willow 2024-07-02 00:30:25 +02:00 committed by GitHub
commit 86a671e35a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 5 deletions

View File

@ -442,6 +442,8 @@ See <<Appending>> below for instructions on extending (appending to) the current
* `pagedown, <c-f>`: scroll one page down
* `<c-u>`: scroll half a page up
* `<c-d>`: scroll half a page down
* `<c-y>`: scroll one line up
* `<c-e>`: scroll one line down
* `)`: rotate selections (the main selection becomes the next one)
* `(`: rotate selections backwards

View File

@ -193,6 +193,12 @@ the Shift modifier and moving will extend each selection instead.
*<c-d>*::
scroll half a page down
*<c-y>*::
scroll one line up
*<c-e>*::
scroll one line down
*;*, *<semicolon>*::
reduce selections to their cursor

View File

@ -20,6 +20,7 @@ class KeymapManager;
class AliasRegistry;
enum Direction { Backward = -1, Forward = 1 };
enum Distance { FullScreen = 0, HalfScreen = 1, Line = 2 };
struct JumpList
{

View File

@ -1422,12 +1422,24 @@ void select_object(Context& context, NormalParams params)
{{alt(';')}, "run command in object context"}}));
}
template<Direction direction, bool half = false>
template<Direction direction, Distance distance = FullScreen>
void scroll(Context& context, NormalParams params)
{
const Window& window = context.window();
const int count = params.count ? params.count : 1;
const LineCount offset = (window.dimensions().line - 2) / (half ? 2 : 1) * count;
LineCount offset = 0;
switch (distance) {
case FullScreen:
offset = (window.dimensions().line - 2) * count;
break;
case HalfScreen:
offset = (window.dimensions().line - 2) / 2 * count;
break;
case Line:
offset = count;
break;
}
scroll_window(context, offset * direction, OnHiddenCursor::MoveCursorAndAnchor);
}
@ -2444,10 +2456,12 @@ static constexpr HashMap<Key, NormalCmd, MemoryDomain::Undefined, KeymapBackend>
{ {Key::PageUp}, { "scroll one page up", scroll<Backward>} },
{ {Key::PageDown}, {"scroll one page down", scroll<Forward>} },
{ {ctrl('b')}, {"scroll one page up", scroll<Backward >} },
{ {ctrl('b')}, {"scroll one page up", scroll<Backward>} },
{ {ctrl('f')}, {"scroll one page down", scroll<Forward>} },
{ {ctrl('u')}, {"scroll half a page up", scroll<Backward, true>} },
{ {ctrl('d')}, {"scroll half a page down", scroll<Forward, true>} },
{ {ctrl('u')}, {"scroll half a page up", scroll<Backward, HalfScreen>} },
{ {ctrl('d')}, {"scroll half a page down", scroll<Forward, HalfScreen>} },
{ {ctrl('y')}, {"scroll one line up", scroll<Backward, Line>} },
{ {ctrl('e')}, {"scroll one line down", scroll<Forward, Line>} },
{ {'z'}, {"restore selections from register", restore_selections<false>} },
{ {alt('z')}, {"combine selections from register", restore_selections<true>} },