]> Sergey Matveev's repositories - nnn.git/commitdiff
Jump to the next young file
authorANtlord <antlord@tutanota.com>
Sat, 22 Jul 2023 18:41:14 +0000 (19:41 +0100)
committerNRK <nrk@disroot.org>
Tue, 25 Jul 2023 02:17:21 +0000 (08:17 +0600)
Forward jumping to the next young file is implemented. The starting
position from which the next young file is searched is the next
position. If no young file has been found, the search starts from the
beginning. It stops at the initial position where the search has
started.

src/nnn.c
src/nnn.h

index 653919f302b5102329441860d3c657aa3ff2b291..9d05ed83736e9f4bfb141bb725a16e058581e085 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5107,6 +5107,7 @@ static void show_help(const char *path)
                "a1-4  Context%11(Sh)Tab  Cycle/new context\n"
            "62Esc ^Q  Quit%20q  Quit context\n"
                 "b^G  QuitCD%18Q  Pick/err, quit\n"
+                "b^y  Next young file\n"
        "0\n"
        "1FILTER & PROMPT\n"
                  "c/  Filter%17^N  Toggle type-to-nav\n"
@@ -6115,6 +6116,20 @@ static void handle_screen_move(enum action sel)
        case SEL_END:
                move_cursor(ndents - 1, 1);
                break;
+       case SEL_YOUNG:
+       {
+               for (int r = cur;;) {
+                       if (++r >= ndents)
+                               r = 0;
+                       if (r == cur)
+                               break;
+                       if (pdents[r].flags & FILE_YOUNG) {
+                               move_cursor(r, 0);
+                               break;
+                       }
+               }
+               break;
+       }
        default: /* case SEL_FIRST */
        {
                int c = get_input(messages[MSG_FIRST]);
@@ -7196,7 +7211,8 @@ nochange:
                case SEL_HOME: // fallthrough
                case SEL_END: // fallthrough
                case SEL_FIRST: // fallthrough
-               case SEL_JUMP:
+               case SEL_JUMP: // fallthrough
+               case SEL_YOUNG:
                        if (ndents) {
                                g_state.move = 1;
                                handle_screen_move(sel);
index d476ddd23683251f108525a6679c1d4144c51eb7..3cf132ba91c8893badb11b427acac28d7bbc7860 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -58,6 +58,7 @@ enum action {
        SEL_END,
        SEL_FIRST,
        SEL_JUMP,
+       SEL_YOUNG,
        SEL_CDHOME,
        SEL_CDBEGIN,
        SEL_CDLAST,
@@ -164,6 +165,7 @@ static struct key bindings[] = {
        { '\'',           SEL_FIRST },
        /* Jump to an entry number/offset */
        { 'J',            SEL_JUMP },
+       { CONTROL('Y'),   SEL_YOUNG },
        /* HOME */
        { '~',            SEL_CDHOME },
        /* Initial directory */