README.md | 5 +++-- nnn.1 | 2 ++ src/nnn.c | 35 +++++++++++++++++++++++++---------- src/nnn.h | 4 +++- diff --git a/README.md b/README.md index b448af5ffb0203f6ffb47d95dab60029a2a8400e..d526e2482b0d1fb183d24e1b4a23dbaeb50440d5 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ - Detailed stat-like file information - Media information (needs mediainfo/exiftool) - Convenience - Create, rename files and directories - - Select files across directories, range selection + - Select files across dirs; all/range selection - Copy, move, delete selection - Create sym/hard link(s) to selection - Transfer files using lftp @@ -231,7 +231,8 @@ FILES ^O Open with... n Create new/link D File details ^R Rename entry ⎵, ^K Copy entry path r Open dir in vidir - Y, ^Y Toggle selection y List selection + ^Y Toggle selection y List selection + Y Select all P Copy selection X Delete selection V Move selection ^X Delete entry f Archive entry F List archive diff --git a/nnn.1 b/nnn.1 index 2659852f47870d53df9533086da9bc22fa9feb1e..8f239296e236535d64ec342648274c8746b8cd89 100644 --- a/nnn.1 +++ b/nnn.1 @@ -98,6 +98,8 @@ .It Ic r Open directory in vidir .It Ic Y, ^Y Toggle selection mode +.It Ic Y +Select all entries in dir .It Ic Space, ^K Copy entry absolute path .It Ic y diff --git a/src/nnn.c b/src/nnn.c index 9bf8e6c86218620bea12b601c253c6298f6941e5..309d7ef71b6efb1377e1933c4e1fa9ba75c81eb1 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -2286,7 +2286,8 @@ "1FILES\n" "b^O Open with... n Create new/link\n" "cD File details ^R Rename entry\n" "8⎵, ^K Copy entry path r Open dir in vidir\n" - "8Y, ^Y Toggle selection y List selection\n" + "b^Y Toggle selection y List selection\n" + "cY Select all\n" "cP Copy selection X Delete selection\n" "cV Move selection ^X Delete entry\n" "cf Archive entry F List archive\n" @@ -2743,7 +2744,7 @@ unescape(dents[cur].name, NAME_MAX), get_file_sym(dents[cur].mode)); } } else - printmsg("0 items"); + printmsg("0/0"); } if (mode_changed) { @@ -3360,11 +3361,23 @@ ncp = 0; printmsg("selection on"); DPRINTF_S("selection on"); goto nochange; + } // fallthrough + case SEL_COPYALL: + if (sel == SEL_COPYALL) { + if (!ndents) { + printmsg("0 entries"); + goto nochange; + } + + cfg.copymode = 0; + copybufpos = 0; + ncp = 0; + copystartid = 0; + copyendid = ndents - 1; } - if (!ncp) { /* Handle range selection */ #ifndef DIR_LIMITED_COPY - if (g_crc != crc8fast((uchar *)dents, + if ((sel != SEL_COPYALL) && g_crc != crc8fast((uchar *)dents, ndents * sizeof(struct entry))) { cfg.copymode = 0; printmsg("range error: dir/content changed"); @@ -3372,13 +3385,15 @@ DPRINTF_S("range error: dir/content changed"); goto nochange; } #endif - if (cur < copystartid) { - copyendid = copystartid; - copystartid = cur; - } else - copyendid = cur; + if (sel != SEL_COPYALL) { + if (cur < copystartid) { + copyendid = copystartid; + copystartid = cur; + } else + copyendid = cur; + } - if (copystartid < copyendid) { + if (copystartid < copyendid || sel == SEL_COPYALL) { for (r = copystartid; r <= copyendid; ++r) if (!appendfpath(newpath, mkpath(path, dents[r].name, newpath))) diff --git a/src/nnn.h b/src/nnn.h index e105a25735feba81a72bb7ab232b09e45b63a3f7..8517578a0054874dfa3a597b06691d90cae8740c 100644 --- a/src/nnn.h +++ b/src/nnn.h @@ -73,6 +73,7 @@ SEL_MTIME, SEL_REDRAW, SEL_COPY, SEL_COPYMUL, + SEL_COPYALL, SEL_COPYLIST, SEL_CP, SEL_MV, @@ -189,7 +190,8 @@ { CONTROL('K'), SEL_COPY }, { ' ', SEL_COPY }, /* Toggle copy multiple file paths */ { CONTROL('Y'), SEL_COPYMUL }, - { 'Y', SEL_COPYMUL }, + /* Select all files in current dir */ + { 'Y', SEL_COPYALL }, /* Show list of copied files */ { 'y', SEL_COPYLIST }, /* Copy from copy buffer */