Commit Graph

1910 Commits

Author SHA1 Message Date
NRK a59a91c312 handle tilde more correctly
closes: https://github.com/jarun/nnn/issues/1596
2023-02-25 21:15:46 +06:00
Arun Prakash Jana b874da395c
Update copyright year 2023-02-19 08:28:20 +05:30
NRK 9cc4b66868 export NNN_PREFER_SELECTION to all plugins 2023-02-17 19:24:45 +06:00
NRK 8ad5c87107 nmv: prefer selection if -u is active
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.
2023-02-17 19:22:46 +06:00
Arun Prakash Jana 58b77411c8
Optimize listed selection size calculation 2023-01-31 18:36:26 +05:30
Arun Prakash Jana 33827109d5
Show total size of non-filtered selected files in a directory. 2023-01-30 00:14:54 +05:30
Arun Prakash Jana b80e047d50
Set defaults for some multiple choice prompts
Archive options: listing
Create new options: create file
Open with options: command type GUI
2023-01-28 09:50:58 +05:30
Arun Prakash Jana ad4ecb19cb
Simplify paged and GUI commands run as plugin 2023-01-28 09:16:06 +05:30
Arun 786ecf9fc2
Merge pull request #1571 from KlzXS/plugin_simplification
Simplify the command as plugin codepath
2023-01-28 08:23:24 +05:30
KlzXS 867726d870
Add debug message for bad call 2023-01-25 18:56:48 +01:00
KlzXS 7abfb77a13
Update signatures 2023-01-25 17:37:31 +01:00
KlzXS 827e84a56f
Simplify commands as plugins
Remove restrictions on $nnn

Update the plugin README
2023-01-25 17:33:15 +01:00
KlzXS 8d21e5e832
Revert using UTIL_SH_EXEC 2023-01-25 17:26:14 +01:00
Arun Prakash Jana 6b94911bc9 Revert "Simplify get_output()"
This reverts commit 6c23fdfd5f.
2023-01-16 00:19:03 +05:30
Arun Prakash Jana 653cab9dff Revert "Give better names to variables"
This reverts commit 1a2f783b75.
2023-01-16 00:18:52 +05:30
Arun Prakash Jana f9295780ef Revert "Make CI happy"
This reverts commit 8a1e32d9eb.
2023-01-16 00:18:41 +05:30
Arun Prakash Jana cac5b9ba33 Revert "Concatenate arguments to pass to `sh`"
This reverts commit 428c652d36.
2023-01-16 00:18:19 +05:30
Arun Prakash Jana df05f593de Revert "Paging is achieved through shell command now"
This reverts commit 243301603e.
2023-01-16 00:15:54 +05:30
Arun Prakash Jana 243301603e
Paging is achieved through shell command now 2023-01-15 11:46:03 +05:30
Arun 428c652d36
Concatenate arguments to pass to `sh`
Co-authored-by: KlzXS <klzx+github@klzx.cf>
Co-authored-by: Arun Prakash Jana <engineerarun@gmail.com>
2023-01-15 10:59:36 +05:30
KlzXS 8a1e32d9eb
Make CI happy 2023-01-14 23:18:22 +01:00
KlzXS 1a2f783b75
Give better names to variables 2023-01-14 22:31:16 +01:00
KlzXS 6c23fdfd5f
Simplify get_output() 2023-01-14 22:11:10 +01:00
NRK fb5b2e5e64 icons-hash: fix bitwise rotation
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
2023-01-03 02:20:21 +06:00
N-R-K 2000ed5080
icons-hash: misc improvements (#1553)
* 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
2023-01-02 22:23:18 +05:30
KlzXS 87627a6e08
Remove unnecessary parameter from `archive_selection()` 2022-12-12 16:13:35 +01:00
Arun Prakash Jana 17ed380b57
Optimize link creation 2022-12-12 18:03:11 +05:30
Arun Prakash Jana 38d7090e64
Clear selection if all links are generated 2022-12-12 16:15:06 +05:30
Arun Prakash Jana 824e7a2c18
Show errno on link creation failure 2022-12-12 15:57:20 +05:30
Arun Prakash Jana 2e84716e76
Restore check to prevent overwriting hovered file when archiving 2022-12-12 14:45:04 +05:30
Arun Prakash Jana e8bc59a816
Improve archive, rename, new workflows
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
2022-12-12 10:19:53 +05:30
Arun Prakash Jana 32a6a63f44
Improve archive creation handling 2022-12-12 02:43:23 +05:30
Arun Prakash Jana cf46da60d9
Fix memory leak 2022-12-12 00:17:28 +05:30
Arun Prakash Jana 02dec98bf8
Use built-in 2022-12-11 03:42:34 +05:30
Arun Prakash Jana 608fbb4ad7
Fix length calculation 2022-12-11 03:01:19 +05:30
Arun Prakash Jana d4c3e52f2f
Attmept to create PATH if PATH is non-existent 2022-12-11 00:03:24 +05:30
Arun Prakash Jana 93de728eab
Create files in less permissive mode 2022-12-10 22:02:22 +05:30
Arun Prakash Jana c9dbae0586
Fix build break 2022-12-10 21:43:42 +05:30
Arun Prakash Jana b6bfc740ce
Fix signed and unsigned comparison 2022-12-10 21:39:44 +05:30
Arun Prakash Jana 28ea6e0f36
Allow creating a new file on startup
An accessibe parent directory must exist to allow creation
2022-12-10 21:39:36 +05:30
Arun Prakash Jana 2a673b4eb1
Allow overwriting regular files on new empty file creation 2022-12-10 19:28:58 +05:30
Arun Prakash Jana 7330e6642b
Prepare for release v4.7 Cuba libre 2022-11-24 10:58:21 +05:30
NRK 985f6537ce add ksh, ttf and otf icons
Co-authored-by: Tanner Babcock <babkock@protonmail.com>
2022-10-26 15:08:27 +06:00
NRK 080a061969 icons.h: fix alignment 2022-10-26 14:55:20 +06:00
NRK ff27d9ee14 clarify the goal of the default icon set 2022-10-26 14:54:07 +06:00
NRK e5074ebc83 prefill the prompt when there's a single target
Fixes: #1505 #1282 #1345
2022-10-12 00:48:33 +06:00
Dean G 38b7282050
Add Rust icons (#1502) 2022-10-05 11:38:48 +00:00
Luuk van Baal bc4233767a
Fix git pathspec for gitstatus patch 2022-10-01 17:06:30 +02:00
Arun Prakash Jana 59eed597c2
Fix #1498: count broken when selection is updated outside nnn 2022-09-28 00:30:26 +05:30
Arun Prakash Jana de3ad1b146
Fix build break 2022-09-19 21:36:04 +05:30
pataquets 78019a758e Detect key collisions: make clear everywhere that it exits afterwards. 2022-09-12 23:04:54 +02:00
Luuk van Baal 4f57e0df37
Show selected items in rm msg
Close https://github.com/jarun/nnn/issues/1479
2022-09-08 20:07:34 +02:00
Arun Prakash Jana f56a8caf65
Use correct data type for key collision detection 2022-08-23 19:00:45 +05:30
NRK f8ee991254 xstrdup: use memcpy
the length is already known, so memcpy should be faster than xstrsncpy.
2022-08-16 19:31:18 +06:00
NRK 29a5992dee use standard C11 alignas
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
2022-08-11 11:31:35 +06:00
KlzXS 65dec55e23
Improved chunk allocation logic
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>
2022-08-03 17:38:19 +02:00
Arun Prakash Jana ab9d8bee89
Fix #1449: ^N not working 2022-08-01 23:41:04 +05:30
Arun Prakash Jana a7ebc7858a
Key 'J' to jump to entry number or relative offset 2022-07-31 18:54:47 +05:30
Arun Prakash Jana e8acae3274
Continue listing when max files/size is exceeded 2022-07-31 12:49:42 +05:30
Arun Prakash Jana 21eebbb003
File list mode changes
- 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'
2022-07-31 11:11:32 +05:30
Arun Prakash Jana e73b57c78a
Option -B to use bsdtar as archive tool 2022-07-29 22:35:43 +05:30
Arun Prakash Jana b76cea3a34 Revert "Patch #1386: make bsdtar the default archive handler"
This reverts commit e104b749be.
2022-07-29 22:14:00 +05:30
Arun Prakash Jana 83825a7d11
Fix rm prompt
Esc - cancels the search
y/Y - adds the force option
n/N/any other key - prompts for every file
2022-07-28 19:38:55 +05:30
N-R-K f618b78866
Makefile: more robust generated header tracking (#1439)
give each generated header it's own unique file so that it's not
possible to try and build `O_EMOJI=1` with the generated header for
`O_NERD=1`.
2022-07-26 20:26:49 +05:30
Arun Prakash Jana 0988268a61
Prepare for release v4.6 Absinthe 2022-07-26 19:28:44 +05:30
Tharindu Abeydeera 98287158aa
Add Elixir icon (#1437)
* 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>
2022-07-25 19:40:00 +05:30
NRK e6b6466c49 icons-hash: comments and cleanups
adds some comments, references and cleanups. no change in functionality.
2022-07-25 18:34:36 +06:00
Arun Prakash Jana f415924c7e
Remove redundant spaces 2022-07-24 20:07:27 +05:30
NRK fe9c1bbb3a icons: use a compact array
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.
2022-07-24 16:24:11 +06:00
NRK 63a254951d icons-hash: some minor cleanups 2022-07-24 16:24:11 +06:00
NRK 12f5faa10d icons: replace double-width icons 2022-07-24 16:06:14 +06:00
NRK f1932967e2 icons: use COLOR_C for go files 2022-07-24 16:06:14 +06:00
Arun Prakash Jana 197717ce68
Enable hidden when opening a hidden file 2022-07-23 09:33:11 +05:30
NRK e98d9288d2 some cleanups and comments 2022-07-22 21:33:35 +06:00
NRK c3a42f0d92 make clang-tidy happy 2022-07-22 17:31:55 +06:00
NRK 3b09fd1c75 Revise and optimize icons handling
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.
2022-07-22 17:08:42 +06:00
Arun Prakash Jana d95755cce1
Use unget_wch() 2022-07-21 17:51:20 +05:30
Arun Prakash Jana 12b5416b2c
Fix #1428: handle unicode keybinds 2022-07-20 20:09:34 +05:30
Arun Prakash Jana a937265833
Reduce get_wch() array length and initialization. 2022-07-20 18:49:24 +05:30
Arun Prakash Jana b75a22f72d
Minor improvements 2022-07-18 18:28:16 +05:30
Arun Prakash Jana b752744ca0
Show volume used information in help 2022-07-18 18:28:16 +05:30
Arun Prakash Jana db7cb4da1e
Fix double order chars on filter case match change 2022-07-18 18:28:15 +05:30
NRK 7121a6fe43
Fix build break 2022-06-30 22:26:17 +05:30
NRK 744e9aaf70 initialize to zero instead of using memset
reduces some unncessary code. and when initializing larger objects,
compilers (gcc and clang at least) typically tend to compile it down to
a memset anyways.
2022-06-30 00:27:00 +06:00
NRK 1d347b1ce9 cfg: use designated initializer
anything not explicitly initialized will be implicitly initialized to
zero. this makes things more robust since comments are not checked by
the compiler and can be incorrect.
2022-06-30 00:26:36 +06:00
NRK 2df0cbd08b fix incorrect comment
xextension() uses xmemrchr to find '.'
2022-06-30 00:25:44 +06:00
Arun Prakash Jana 52f4ee5aee
Fix build break 2022-06-28 23:17:23 +05:30
Arun Prakash Jana 89bd541562
Add new emoji for C files 2022-06-25 20:07:43 +05:30
Arun Prakash Jana 02d48a9144
New icons for audio and video 2022-06-25 19:59:13 +05:30
NRK eb66cb5d11 account for realpath failure
realpath may fail, in which case fallback to mkpath.
2022-06-20 21:49:41 +06:00
Arun Prakash Jana 2130e1b33a
Use the term auto-advance instead of auto-jump
There's no jump.
2022-06-15 20:04:56 +05:30
Arun Prakash Jana d898d174f5
Fix docs, allow `/` to enable filter inside bookmarks 2022-06-14 17:36:17 +05:30
Arun Prakash Jana 581e629c20
Enable automatic dir entry on unique filer match 2022-06-14 13:49:41 +05:30
Arun Prakash Jana 56f96c3d0a
Enable filtering in plugins/bookmarks dirs
Enable auto-dir entry on filter mode
2022-06-14 13:10:54 +05:30
Arun Prakash Jana 51f2fde0e6
Revert #1398: Go to prev dir on bookmark key repeat
Reasons:

1. `b` is not a special key and will be interpreted as a filter
2. with this change pressing the standard `-` inside a symlinked
   bookmark takes back to the bookmarks directory. This deviates
   from the regular bookmarks behaviour.
2022-06-14 12:51:42 +05:30
Luuk van Baal 5b5a62bb0d
Fix false positive selbm 2022-06-13 04:07:40 +02:00
Arun Prakash Jana 783ea754f7
Use a more visible color 2022-06-12 07:55:23 +05:30
Arun Prakash Jana 19b2ea324a
Skip redundant getutil() call 2022-06-11 21:32:16 +05:30
Arun Prakash Jana 03fc3b99c5
Add informative comment 2022-06-11 21:25:03 +05:30
Arun Prakash Jana e104b749be
Patch #1386: make bsdtar the default archive handler 2022-06-11 15:09:40 +05:30