This works:
```lua
xplr.fn.custom.ping = function(app)
print("What's your name?")
local name = io.read()
os.execute('read -p "Hello ' .. name .. ', you are in ' .. app.pwd .. '"')
return {
{ LogSuccess = "pong" },
}
end
```
Then it can be called via `CallLua: custom.ping`.
The initial idea was to enable other tools to control `xplr` via the
input pipe. However, so far I didn't feel the need to use this feature.
And even if there is any need, it's much better to implement ad-hoc
services instead of wasting cpu resources.
This PR aims to fully migrate `config.yml` to `init.lua`
Also, use `builtin.foo_func` instead of `xplr.fn.builtin.foo_func`.
Similarly, use `custom.foo_func` instead of `xplr.fn.custom.foo_func`.
Closes: https://github.com/sayanarijit/xplr/issues/160
This commit begins porting of `config.yml` to `init.lua`.
As of now, it's not be possible to do the complete migration
because of how lua and yaml handles `null`/`nil` value.
So, we will need to completely deprecate `config.yml` in order to do the
complete migration.
Use `remaps: {key: null}` to un-map a key.
Also,
- `gx` will now open only the file under focus.
- `:sx` will open the selected files.
And other minor improvements.
Discussion: https://github.com/sayanarijit/xplr/discussions/146
The input poll timeout needs to stay low, else xplr will panic when you
spawn a subshell and start typing immediately.
From the `top` command, it didn't show any noticeable overhead.
Stay in the current mode when key input is not recognised. It's better
to do nothing than doing something wrong, at least when dealing with
important files and folders.
- Optimize by avoiding cloning the whole app in each iteration of the main
loop.
- Increase the input poll timeout from 1 to 200. This works because the
poll will not apply to key hold.
- Do not read input pipe if it hasn't been modified.
```
Benchmarking focus next item: Collecting 100 samples in estimated 5.1972 s (126k itera focus next item time: [41.216 us 41.346 us 41.494 us]
change: [-28.669% -28.110% -27.551%] (p = 0.00 < 0.05)
Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
4 (4.00%) high mild
5 (5.00%) high severe
Benchmarking focus previous item: Collecting 100 samples in estimated 5.0576 s (116k i focus previous item time: [43.589 us 43.754 us 43.927 us]
change: [-29.506% -28.748% -28.039%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) high mild
2 (2.00%) high severe
Benchmarking focus first item: Collecting 100 samples in estimated 5.1765 s (116k iter focus first item time: [44.071 us 44.340 us 44.634 us]
change: [-26.739% -26.314% -25.885%] (p = 0.00 < 0.05)
Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
8 (8.00%) high mild
4 (4.00%) high severe
Benchmarking focus last item: Collecting 100 samples in estimated 5.1522 s (116k itera focus last item time: [43.950 us 44.214 us 44.541 us]
change: [-27.571% -26.953% -26.337%] (p = 0.00 < 0.05)
Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
5 (5.00%) high mild
6 (6.00%) high severe
Benchmarking leave and enter directory: Collecting 100 samples in estimated 5.4863 s ( leave and enter directory
time: [96.645 us 96.915 us 97.234 us]
change: [-28.720% -27.224% -25.666%] (p = 0.00 < 0.05)
Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
6 (6.00%) high mild
3 (3.00%) high severe
```