]> Sergey Matveev's repositories - nnn.git/commitdiff
F3 view
authorSergey Matveev <stargrave@stargrave.org>
Thu, 26 Oct 2023 13:53:23 +0000 (16:53 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 4 Dec 2023 12:58:01 +0000 (15:58 +0300)
src/nnn.c
src/nnn.h

index dbc64197fd50e5bfa15e0313492f6dc1a865ca73..566d12c6a84512456cdf1e4287c31b934c008173 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -7454,13 +7454,14 @@ nochange:
                case SEL_HELP: // fallthrough
                case SEL_AUTONEXT: // fallthrough
                case SEL_EDIT: // fallthrough
+               case SEL_VIEW: // fallthrough
                case SEL_LOCK:
                {
                        bool refresh = FALSE;
 
                        if (ndents)
                                mkpath(path, pdents[cur].name, newpath);
-                       else if (sel == SEL_EDIT) /* Avoid trying to edit a non-existing file */
+                       else if ((sel == SEL_EDIT) || (sel == SEL_VIEW)) /* Avoid trying to edit a non-existing file */
                                goto nochange;
 
                        switch (sel) {
@@ -7498,6 +7499,10 @@ nochange:
                                if (!(g_state.picker || g_state.fifomode))
                                        spawn(editor, newpath, NULL, NULL, F_CLI);
                                continue;
+                       case SEL_VIEW:
+                               if (!(g_state.picker || g_state.fifomode))
+                                       spawn(pager, newpath, NULL, NULL, F_CLI);
+                               continue;
                        default: /* SEL_LOCK */
                                lock_terminal();
                                break;
index cdba884de711ea4f25bed0cdb820f0c4514535c1..adfb83b40393c26da59cdf729651bfd5a778525f 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -118,6 +118,7 @@ enum action {
        SEL_QUITCD,
        SEL_QUIT,
        SEL_QUITERR,
+       SEL_VIEW,
 #ifndef NOMOUSE
        SEL_CLICK,
 #endif
@@ -259,6 +260,8 @@ static struct key bindings[] = {
        /* Edit in EDITOR */
        { 'e',            SEL_EDIT },
        { KEY_F(4),       SEL_EDIT },
+       /* View in PAGER */
+       { KEY_F(3),       SEL_VIEW },
        /* Run a plugin */
        { ';',            SEL_PLUGIN },
        /* Show total size of listed selection */