this makes it so that if the cp/mv commands are changed the in the
future, it will continue to work reliably instead of having hardcoded
indexes to modify the array.
the `#ifdef __linux__` is also removed, compilers should be smart enough
to see that PROGRESS_{CP,MV} are unused (on non-linux systems) and
optimize it out.
- Clear filter only when a plugin is selected manually.
Plugin dir should be unfiltered when opened.
- Plugins invoked by keys don't require clearing filter
of original context. If a new context is opened using
the plugin, it will be unfiltered by default. If the
same context is re-used (when all the contexts are in
use) the filter should be cleared so the the new path
is opened unfiltered.
the rename plugin always asks for "selection vs current" even when -u
flag is active. pass it to the plugin via `NNN_PREFER_SELECTION` so that
there's less distracting prompts.
in case the rotation is 0, `v >> (32 - r)` would end up doing a 32 right
shift which is equal to the width of `v` and thus undefined behavior.
ref: https://blog.regehr.org/archives/1063
* icons-hash: take total probe count into account as well
* icons-hash: use a better PRNG
the older method was using a multiplicative congruential generator (MCG)
which doesn't work too well especially with just 32 bits of state.
change it to a PCG instead with 64 bits of state (and 32 bits of output)
which should give better results.
and since we should get better rng - the search iteration has been
halved as well to save some build time.
* icons-hash: use an xor-rotate hash function
* icons-hash: fix some compiler warnings
1. hover on entry created in cwd
2. check user input doesn't end with /
3. check user input len < PATH_MAX
4. support creation in ~ directory
5. handle filter mode after creation
6. ensure absolute path len < PATH_MAX
nnn source code already uses C11, which introduced `_Alignas` [^0] as a
standardized alternative to __attribute__((aligned)).
there are no other usage of `__attribute__` in the nnn source code, so
in theory this should make things more portable across compilers.
also removes an unnecessary usage of `alloca()` with an aligned constant
sized buffer instead.
[^0]: https://en.cppreference.com/w/c/language/_Alignas
Found memory deallocation edge case
Update and move chunk limit check
Generalize maximum size of input
Remove hard-coded values
Remove superfluous check before free
Let the kernel deal with extra data
Handle signals while reading
Conform to the manpage
Make CI happy
use `size_t` instead of `ssize_t`
`ssize_t` was used just so `--i` when `i` was zero would become -1
instead of SIZE_MAX. for looping through something in reverse order, the
"goes-to" operator (`-->`) can be used instead which doesn't require `i`
to be signed anymore.
remove useless blank line
use a normal loop
don't see any reason why freeing in reverse order would've been needed.
Co-authored-by: N-R-K <nrk@disroot.org>
- support listing maximum 16K files
- check if target directory exists before directory tree creation
in most of the cases many files will be under the same directory
- make frequently used function 'inline'
* Added icons for erlang, elixir and lockfile
* Lockfile icon updated
* Added colors for Erlang and elixir
* Added few more color variations and configured colors and file
extensions
* remove erlang and lock, use 1 color for elixir
Co-authored-by: Tharindu Abeydeera <tharindu.a@vizuamatix.com>
Co-authored-by: NRK <nrk@disroot.org>
a lot of the extension use the same icon. this can be exploited via
having an array with all the unique icons and then storing a single byte
index into the unique array.
when using `O_EMOJI` this results in around ~1.7KiB drop in the total
table size. `O_NERD` and `O_ICONS` get roughly ~0.5KiB savings.
This pretty much reworks the entire icon system. Some notable changes:
* The extensions are put into a statically generated hash-table instead
of a sorted array. We use Robin-Hood insertion to reduce the max probe
length. Currently we need to probe only 2 slots for `O_EMOJI` and only
3 for `O_NERD`/`O_ICONS`.
* I've opted not to use a perfect-hash since the perfect hashes
generated by [`gperf`](https://www.gnu.org/software/gperf) used some
huge lookup table. The hash function also wasn't as minimal as I'd
like.
* Colors are now using X-Macros. This should speed up startup since we
don't have to search `icons_ext` linearly to find unique colors.
* The hash-table generator outputs a more space optimized `struct
icon_pair` using a char array instead of char pointer. This brings
down the binary size from `145KiB` when using `O_NERD` down to
`137KiB`.
* Some unnecessary duplication and indirection has been reduced by using
the `ICON_STR()` macro.