1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Add more keybinds for scrolling in pager(1)

b commonly corresponds to Page Up, and f is added to match.

j and k for lines, ^F and ^B for pages, and g and G for home/end are from vi.

C-n and C-p for lines and C-v and M-v for pages are from Emacs.

< and > for home/end allow using Emacs M-< and M->, tho they are from less(1).
This commit is contained in:
Juhani Krekelä 2021-04-19 01:06:31 +03:00
parent 5e666dce8a
commit 73e42780f4
2 changed files with 31 additions and 13 deletions

View file

@ -31,19 +31,19 @@ to show only selected escape codes.
.Nm
supports the following key commands:
.Bl -tag -width "12345678"
.It Enter or Down Arrow
.It Sy Enter , Down Arrow , j , ^N
Scroll the file one line down.
.It Up Arrow
.It Sy Up Arrow , k , ^P
Scroll the file one line up.
.It Space or Page Down
.It Sy Space , Page Down , f , ^F , ^V
Scroll the file one page down.
.It Page Up
.It Sy Page Up , b , ^B , ESC-v
Scroll the file one page up.
.It End
.It Sy End , G , >
Scroll all the way down to the end of the file.
.It Home
.It Sy Home , g , <
Scroll all the way up to the beginning of the file.
.It q or Q
.It Sy q , Q
Exit the pager.
.El
.Sh EXIT STATUS

View file

@ -162,14 +162,19 @@ static void prompt(bool at_end)
}
buffer[buffer_used] = '\0';
if ( !strcmp(buffer, "\n") || !strcmp(buffer, "\e[B") )
if ( !strcmp(buffer, "\n") ||
!strcmp(buffer, "j") ||
!strcmp(buffer, "\x0e") /* ^N */ ||
!strcmp(buffer, "\e[B") /* Down Arrow */ )
{
dprintf(1, "\r\e[J");
allowed_lines++;
return;
}
if ( !strcmp(buffer, "\e[A") )
if ( !strcmp(buffer, "k") ||
!strcmp(buffer, "\x10") /* ^P */ ||
!strcmp(buffer, "\e[A") /* Up Arrow */ )
{
if ( current_line <= possible_lines )
continue;
@ -180,14 +185,21 @@ static void prompt(bool at_end)
return;
}
if ( !strcmp(buffer, " ") || !strcmp(buffer, "\e[6~") )
if ( !strcmp(buffer, " ") ||
!strcmp(buffer, "f") ||
!strcmp(buffer, "\x06") /* ^F */ ||
!strcmp(buffer, "\x16") /* ^V */ ||
!strcmp(buffer, "\e[6~") /* Page Down */ )
{
dprintf(1, "\r\e[J");
allowed_lines = possible_lines;
return;
}
if ( !strcmp(buffer, "\e[5~") )
if ( !strcmp(buffer, "b") ||
!strcmp(buffer, "\x02") /* ^B */ ||
!strcmp(buffer, "\ev") /* ESC-v */ ||
!strcmp(buffer, "\e[5~") /* Page Up */)
{
if ( current_line <= possible_lines )
continue;
@ -201,7 +213,10 @@ static void prompt(bool at_end)
return;
}
if ( !strcmp(buffer, "\e[F") || !strcmp(buffer, "\e[4~") )
if ( !strcmp(buffer, ">") ||
!strcmp(buffer, "G") ||
!strcmp(buffer, "\e[F") /* End */ ||
!strcmp(buffer, "\e[4~") /* End (Linux console) */ )
{
dprintf(1, "\r\e[J");
skipping_to_end = true;
@ -209,7 +224,10 @@ static void prompt(bool at_end)
return;
}
if ( !strcmp(buffer, "\e[H") || !strcmp(buffer, "\e[1~") )
if ( !strcmp(buffer, "<") ||
!strcmp(buffer, "g") ||
!strcmp(buffer, "\e[H") /* Home */ ||
!strcmp(buffer, "\e[1~") /* Home (Linux console) */ )
{
if ( current_line <= possible_lines )
continue;