The main reason to do this is to start watching the current dir for changes. In
any case, this does not harm; if there are dir entries shown on redraw that's
better than showing nothing.
Design overview:
We are introducing multiple file path copy as a mode which can be toggled using
the keybind `^Y`. `^K` works as the individual entry selector. If the user wants
to select a range, (s)he can press `^Y` on the first entry and `^Y` on the last
entry.
We subscribe to notifications, so we need a fail-proof way to detect changes in
the directory contents. For example, if a file is deleted, it becomes difficult
to get the names of all the files in a range containing that file. If the file
is on a range boundary it would lead to wrong calculations. To handle this the
right way we use CRC8 checksum of all the visible entries in the directory. The
checksum is calculated based on the file information buffer. If the CRC changes
on a redraw(), we reset the multi-select mode.
New line (`\n`) works as the delimiter between file paths. Note that you may have
to disable IFS in the `NNN_COPIER` script to show file paths separated by spaces.
The replacement keys are:
^J - toggle du mode
^Y - quit
The change is done because ^S, ^Q keybinds are lost in the following case:
- start nnn
- navigate to a different directory
- spawn a shell
- exit the shell
The issue happens only with the 'special' keybinds like ^S, ^Q, ^Z... which get
their original shell interpretation back.
So we are replacing these 2 keybinds with 2 'non-special' combinations.
New keys:
- bookmark prompt (^B)
- pin directory (B)
The intention of the change is to facilitate opening the bookmark prompt in
navigate-as-you-type mode. The bookmark prompt is used more than the pin
current directory option.
- For standard view, use ISO 8601 date format.
- For detailed view (i.e. stat), use default Linux date
format. Also, remove GMT offset to avoid confusion in
determining source of offset when reading alongside
the local time zone.
1. File name comparison method:
- initially ignore white space and punctuation characters
- run test for numeric values
- if the remaining substrings match in case-insensitive compare, compare case
- if they still match, see which one has more prefix symbols
- if they still match, run a case-sensitive compare on complete strings
2. Fixed xstrcmp() to return diff instead of 0 and -1.
Results in even less memory usage. The names are appended one after another.
The offsets are reset when the location of the memory changes die to realloc().
Other changes:
1. Use a debug mode print to measure time.
2. Remove redundant prefix when printing pointers in debug mode.
nnn has been using `struct entry` to hold both file name as well as file info.
The design forces file names to be copied in the following cases:
- swaps during file sort (nnn uses quicksort) applied after all the matching
files are read (in no particular order; good old readdir()) into memory.
- swaps during manual filtering. nnn moves non-matching entries below so they
are not encountered twice resulting in fast filtering.
There were scopes for _massive_ improvements in this area. So I did what had to
be done - decouple the file names from `struct entry` and use a separate struct
to hold the names with the indices set when the files are added by opendir().
There was a hidden problem to this approach - nnn uses realloc() to allocate
memory for file information and realloc() may move the original pointer in mem
when it can't fit the new memory to the earlier pointer. To handle that the new
algorithm tracks the change in memory location and re-adjusts the existing dir
entry names when that happens; this too, without any copying!
Though the results seem pretty clean from a theoretical point of view and early
tests, we may uncover some bugs. However, the speed is just mind-blowing!
And the binary size remains the same too!!!
* Prevent nnn from waiting on open file process
* Add env var flag to not wait for child process when opening file
* Set nowait flag once to skip bit-or every time we open a file
* Add documentation for NNN_NOWAIT