mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 03:41:27 +00:00
Add help screen on keybinds
This commit is contained in:
parent
418c9f2654
commit
4b66029762
1
LICENSE
1
LICENSE
|
@ -1,5 +1,6 @@
|
|||
Copyright (c) 2014-2016 Lazaros Koromilas <lostd@2f30.org>
|
||||
Copyright (c) 2014-2016 Dimitris Papastamos <sin@2f30.org>
|
||||
Copyright (c) 2016-2017 Arun Prakash Jana <engineerarun@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
47
README.md
47
README.md
|
@ -109,29 +109,30 @@ Start nnn (default: current directory):
|
|||
|
||||
| Key | Function |
|
||||
| --- | --- |
|
||||
| `Up`, `k`, `^P` | previous entry |
|
||||
| `Down`, `j`, `^N` | next entry |
|
||||
| `PgUp`, `^U` | scroll half page up |
|
||||
| `PgDn`, `^D` | scroll half page down |
|
||||
| `Home`, `^`, `^A` | jump to first dir entry |
|
||||
| `End`, `$`, `^E` | jump to last dir entry |
|
||||
| `Right`, `Enter`, `l`, `^M` | open file or enter dir |
|
||||
| `Left`, `Backspace`, `h`, `^H` | parent dir |
|
||||
| `~` | jump to home dir |
|
||||
| `/`, `&` | filter dir contents |
|
||||
| `c` | show change dir prompt |
|
||||
| `d` | toggle detail view |
|
||||
| `D` | show details of selected file |
|
||||
| `.` | toggle hide dot files |
|
||||
| `s` | toggle sort by file size |
|
||||
| `t` | toggle sort by modified time |
|
||||
| `!` | spawn `SHELL` in `PWD` (fallback sh) |
|
||||
| `z` | run `top` |
|
||||
| `e` | edit entry in `EDITOR` (fallback vi) |
|
||||
| `p` | open entry with `PAGER` (fallback less) |
|
||||
| `^K` | invoke file name copier |
|
||||
| `^L` | redraw window |
|
||||
| `q` | quit |
|
||||
| `Up`, `k`, `^P` | Previous entry |
|
||||
| `Down`, `j`, `^N` | Next entry |
|
||||
| `PgUp`, `^U` | Scroll half page up |
|
||||
| `PgDn`, `^D` | Scroll half page down |
|
||||
| `Home`, `^`, `^A` | Jump to first dir entry |
|
||||
| `End`, `$`, `^E` | Jump to last dir entry |
|
||||
| `Right`, `Enter`, `l`, `^M` | Open file or enter dir |
|
||||
| `Left`, `Backspace`, `h`, `^H` | Go to parent dir |
|
||||
| `~` | Jump to HOME dir |
|
||||
| `/`, `&` | Filter dir contents |
|
||||
| `c` | Show change dir prompt |
|
||||
| `d` | Toggle detail view |
|
||||
| `D` | Show details of selected file |
|
||||
| `.` | Toggle hide .dot files |
|
||||
| `s` | Toggle sort by file size |
|
||||
| `t` | Toggle sort by modified time |
|
||||
| `!` | Spawn `SHELL` in `PWD` (fallback sh) |
|
||||
| `z` | Run `top` |
|
||||
| `e` | Edit entry in `EDITOR` (fallback vi) |
|
||||
| `p` | Open entry in `PAGER` (fallback less) |
|
||||
| `^K` | Invoke file name copier |
|
||||
| `^L` | Force a redraw |
|
||||
| `?` | Show help |
|
||||
| `q` | Quit |
|
||||
|
||||
### Filters
|
||||
|
||||
|
|
76
config.def.h
76
config.def.h
|
@ -23,60 +23,62 @@ struct assoc assocs[] = {
|
|||
|
||||
struct key bindings[] = {
|
||||
/* Quit */
|
||||
{ 'q', SEL_QUIT, "\0", "\0" },
|
||||
{ 'q', SEL_QUIT, "", "" },
|
||||
/* Back */
|
||||
{ KEY_BACKSPACE, SEL_BACK, "\0", "\0" },
|
||||
{ KEY_LEFT, SEL_BACK, "\0", "\0" },
|
||||
{ 'h', SEL_BACK, "\0", "\0" },
|
||||
{ CONTROL('H'), SEL_BACK, "\0", "\0" },
|
||||
{ KEY_BACKSPACE, SEL_BACK, "", "" },
|
||||
{ KEY_LEFT, SEL_BACK, "", "" },
|
||||
{ 'h', SEL_BACK, "", "" },
|
||||
{ CONTROL('H'), SEL_BACK, "", "" },
|
||||
/* Inside */
|
||||
{ KEY_ENTER, SEL_GOIN, "\0", "\0" },
|
||||
{ '\r', SEL_GOIN, "\0", "\0" },
|
||||
{ KEY_RIGHT, SEL_GOIN, "\0", "\0" },
|
||||
{ 'l', SEL_GOIN, "\0", "\0" },
|
||||
{ KEY_ENTER, SEL_GOIN, "", "" },
|
||||
{ '\r', SEL_GOIN, "", "" },
|
||||
{ KEY_RIGHT, SEL_GOIN, "", "" },
|
||||
{ 'l', SEL_GOIN, "", "" },
|
||||
/* Filter */
|
||||
{ '/', SEL_FLTR, "\0", "\0" },
|
||||
{ '&', SEL_FLTR, "\0", "\0" },
|
||||
{ '/', SEL_FLTR, "", "" },
|
||||
{ '&', SEL_FLTR, "", "" },
|
||||
/* Next */
|
||||
{ 'j', SEL_NEXT, "\0", "\0" },
|
||||
{ KEY_DOWN, SEL_NEXT, "\0", "\0" },
|
||||
{ CONTROL('N'), SEL_NEXT, "\0", "\0" },
|
||||
{ 'j', SEL_NEXT, "", "" },
|
||||
{ KEY_DOWN, SEL_NEXT, "", "" },
|
||||
{ CONTROL('N'), SEL_NEXT, "", "" },
|
||||
/* Previous */
|
||||
{ 'k', SEL_PREV, "\0", "\0" },
|
||||
{ KEY_UP, SEL_PREV, "\0", "\0" },
|
||||
{ CONTROL('P'), SEL_PREV, "\0", "\0" },
|
||||
{ 'k', SEL_PREV, "", "" },
|
||||
{ KEY_UP, SEL_PREV, "", "" },
|
||||
{ CONTROL('P'), SEL_PREV, "", "" },
|
||||
/* Page down */
|
||||
{ KEY_NPAGE, SEL_PGDN, "\0", "\0" },
|
||||
{ CONTROL('D'), SEL_PGDN, "\0", "\0" },
|
||||
{ KEY_NPAGE, SEL_PGDN, "", "" },
|
||||
{ CONTROL('D'), SEL_PGDN, "", "" },
|
||||
/* Page up */
|
||||
{ KEY_PPAGE, SEL_PGUP, "\0", "\0" },
|
||||
{ CONTROL('U'), SEL_PGUP, "\0", "\0" },
|
||||
{ KEY_PPAGE, SEL_PGUP, "", "" },
|
||||
{ CONTROL('U'), SEL_PGUP, "", "" },
|
||||
/* Home */
|
||||
{ KEY_HOME, SEL_HOME, "\0", "\0" },
|
||||
{ CONTROL('A'), SEL_HOME, "\0", "\0" },
|
||||
{ '^', SEL_HOME, "\0", "\0" },
|
||||
{ KEY_HOME, SEL_HOME, "", "" },
|
||||
{ CONTROL('A'), SEL_HOME, "", "" },
|
||||
{ '^', SEL_HOME, "", "" },
|
||||
/* End */
|
||||
{ KEY_END, SEL_END, "\0", "\0" },
|
||||
{ CONTROL('E'), SEL_END, "\0", "\0" },
|
||||
{ '$', SEL_END, "\0", "\0" },
|
||||
{ KEY_END, SEL_END, "", "" },
|
||||
{ CONTROL('E'), SEL_END, "", "" },
|
||||
{ '$', SEL_END, "", "" },
|
||||
/* Change dir */
|
||||
{ 'c', SEL_CD, "\0", "\0" },
|
||||
{ '~', SEL_CDHOME, "\0", "\0" },
|
||||
{ 'c', SEL_CD, "", "" },
|
||||
{ '~', SEL_CDHOME, "", "" },
|
||||
/* Toggle hide .dot files */
|
||||
{ '.', SEL_TOGGLEDOT, "\0", "\0" },
|
||||
{ '.', SEL_TOGGLEDOT, "", "" },
|
||||
/* Detailed listing */
|
||||
{ 'd', SEL_DETAIL, "\0", "\0" },
|
||||
{ 'd', SEL_DETAIL, "", "" },
|
||||
/* File details */
|
||||
{ 'D', SEL_STATS, "\0", "\0" },
|
||||
{ 'D', SEL_STATS, "", "" },
|
||||
/* Toggle sort by size */
|
||||
{ 's', SEL_FSIZE, "\0", "\0" },
|
||||
{ 's', SEL_FSIZE, "", "" },
|
||||
/* Toggle sort by time */
|
||||
{ 't', SEL_MTIME, "\0", "\0" },
|
||||
{ CONTROL('L'), SEL_REDRAW, "\0", "\0" },
|
||||
{ 't', SEL_MTIME, "", "" },
|
||||
{ CONTROL('L'), SEL_REDRAW, "", "" },
|
||||
/* Copy currently selected file path */
|
||||
{ CONTROL('K'), SEL_COPY, "\0", "\0" },
|
||||
{ CONTROL('K'), SEL_COPY, "", "" },
|
||||
/* Show help */
|
||||
{ '?', SEL_HELP, "", "" },
|
||||
/* Run command */
|
||||
{ 'z', SEL_RUN, "top", "\0" },
|
||||
{ 'z', SEL_RUN, "top", "" },
|
||||
{ '!', SEL_RUN, "sh", "SHELL" },
|
||||
/* Run command with argument */
|
||||
{ 'e', SEL_RUNARG, "vi", "EDITOR" },
|
||||
|
|
24
nnn.1
24
nnn.1
|
@ -22,25 +22,25 @@ supports both vi-like and emacs-like key bindings in the default
|
|||
configuration. The default key bindings are listed below.
|
||||
.Pp
|
||||
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact
|
||||
.It Ic k, [Up] or C-p
|
||||
.It Ic [Up], k, ^P
|
||||
Move to previous entry
|
||||
.It Ic j, [Down] or C-n
|
||||
.It Ic [Down], j, ^N
|
||||
Move to next entry
|
||||
.It Ic [Pgup] or C-u
|
||||
.It Ic [PgUp], ^U
|
||||
Scroll up half a page
|
||||
.It Ic [Pgdown] or C-d
|
||||
.It Ic [PgDn], ^D
|
||||
Scroll down half a page
|
||||
.It Ic [Home], ^ or C-a
|
||||
.It Ic [Home], ^, ^A
|
||||
Move to the first entry
|
||||
.It Ic [End], $ or C-e
|
||||
.It Ic [End], $, ^E
|
||||
Move to the last entry
|
||||
.It Ic l, [Right], [Return] or C-m
|
||||
.It Ic [Right], [Enter], l, ^M
|
||||
Open file or enter directory
|
||||
.It Ic h, C-h, [Left] or [Backspace]
|
||||
.It Ic [Left], [Backspace], h, ^H
|
||||
Back up one directory level
|
||||
.It Ic ~
|
||||
Change to the HOME directory
|
||||
.It Ic / or &
|
||||
.It Ic /, &
|
||||
Change filter (more information below)
|
||||
.It Ic c
|
||||
Change into the given directory
|
||||
|
@ -62,10 +62,12 @@ Run the system top utility.
|
|||
Open current entry in EDITOR (fallback vi)
|
||||
.It Ic p
|
||||
Open current entry in PAGER (fallback less)
|
||||
.It Ic C-k
|
||||
.It Ic ^K
|
||||
Invoke file name copier
|
||||
.It Ic C-l
|
||||
.It Ic ^L
|
||||
Force a redraw
|
||||
.It Ic \&?
|
||||
Show help
|
||||
.It Ic q
|
||||
Quit
|
||||
.El
|
||||
|
|
49
nnn.c
49
nnn.c
|
@ -69,6 +69,7 @@ enum action {
|
|||
SEL_MTIME,
|
||||
SEL_REDRAW,
|
||||
SEL_COPY,
|
||||
SEL_HELP,
|
||||
SEL_RUN,
|
||||
SEL_RUNARG,
|
||||
};
|
||||
|
@ -815,6 +816,48 @@ show_stats(char* fpath, char* fname, struct stat *sb)
|
|||
return;
|
||||
}
|
||||
|
||||
void
|
||||
show_help(void)
|
||||
{
|
||||
char c;
|
||||
|
||||
clear();
|
||||
|
||||
printw("\n\
|
||||
<< Key >> << Function >>\n\n\
|
||||
[Up], k, ^P Previous entry\n\
|
||||
[Down], j, ^N Next entry\n\
|
||||
[PgUp], ^U Scroll half page up\n\
|
||||
[PgDn], ^D Scroll half page down\n\
|
||||
[Home], ^, ^A Jump to first dir entry\n\
|
||||
[End], $, ^E Jump to last dir entry\n\
|
||||
[Right], [Enter], l, ^M Open file or enter dir\n\
|
||||
[Left], [Backspace], h, ^H Go to parent dir\n\
|
||||
~ Jump to HOME dir\n\
|
||||
/, & Filter dir contents\n\
|
||||
c Show change dir prompt\n\
|
||||
d Toggle detail view\n\
|
||||
D Show details of selected file\n\
|
||||
. Toggle hide .dot files\n\
|
||||
s Toggle sort by file size\n\
|
||||
t Toggle sort by modified time\n\
|
||||
! Spawn SHELL in PWD (fallback sh)\n\
|
||||
z Run top\n\
|
||||
e Edit entry in EDITOR (fallback vi)\n\
|
||||
p Open entry in PAGER (fallback less)\n\
|
||||
^K Invoke file name copier\n\
|
||||
^L Force a redraw\n\
|
||||
? Show help\n\
|
||||
q Quit\n");
|
||||
|
||||
/* Show exit keys */
|
||||
printw("\n\n << (q/Esc)");
|
||||
|
||||
while (c = getch())
|
||||
if (c == 'q' || c == 27)
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
dentfill(char *path, struct entry **dents,
|
||||
int (*filter)(regex_t *, char *), regex_t *re)
|
||||
|
@ -1269,6 +1312,12 @@ nochange:
|
|||
} else if (!copier)
|
||||
printmsg("NNN_COPIER is not set");
|
||||
goto nochange;
|
||||
case SEL_HELP:
|
||||
show_help();
|
||||
/* Save current */
|
||||
if (ndents > 0)
|
||||
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
|
||||
goto begin;
|
||||
case SEL_RUN:
|
||||
run = xgetenv(env, run);
|
||||
exitcurses();
|
||||
|
|
Loading…
Reference in a new issue