mirror of
https://github.com/mawww/kakoune.git
synced 2024-10-05 17:18:00 +03:00
Merge 6717aac455
into e0bbd1e7ca
This commit is contained in:
commit
86a671e35a
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -20,6 +20,7 @@ class KeymapManager;
|
||||
class AliasRegistry;
|
||||
|
||||
enum Direction { Backward = -1, Forward = 1 };
|
||||
enum Distance { FullScreen = 0, HalfScreen = 1, Line = 2 };
|
||||
|
||||
struct JumpList
|
||||
{
|
||||
|
@ -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>} },
|
||||
|
Loading…
Reference in New Issue
Block a user