-
Notifications
You must be signed in to change notification settings - Fork 643
refactor: quit command
#484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: aserowy <[email protected]>
Signed-off-by: aserowy <[email protected]>
|
Awesome! I'll review it ASAP. |
|
It seems meaningless to write the file list to AFAIK, fzf writes the TUI to |
|
it enables using stdout after the tui closes to enable further editor support without using temp files e.g. |
How big of a change would this be in yazi? Seems overall like a good idea. This would enable pipes and a more linux like behavior. |
Sorry I didn't understand this, how should I use |
|
In nvim i am using the following function to read directly from buffer without a tmpfile to open a selected file: function M.close()
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
if #lines == 0 then
return 1
end
local path = lines[1]
if not file_exists(path) then
return 1
end
vim.cmd("e " .. path)
vim.cmd("bd#")
vim.cmd("filetype detect")
return 0
endLike i wrote initially, the change enables my current workflows. This is one example. |
I quickly checked the ratatui and crossterm libraries used by Yazi, but couldn't find any relevant information. I'm not sure how to change it and how much effort it would involve. Also I don't think writing TUI to |
How do you select files in Yazi without the UI? Does nvim separate escape sequences from the selected file list in |
|
FYI: https://ratatui.rs/faq/#should-i-use-stdout-or-stderr Seems like a one place edit. |
|
I found this ratatui/ratatui-website#274; it seems that |
|
Ok, how should we proceed? Adding niche functionallity, and a refactoring to handle all quit actions at the same stage? |
|
Due to the performance issues mentioned above, I've decided not to switch Yazi from This would require more efforts in terms of performance optimization, and I still question whether it's suitable for a TUI application - afaik, it's an unconventional approach, a bit tricky, and I've only seen it in Therefore, I would like to remove |
|
feel free. Thus, no switch for me from lf sadly. Btw. i meant to add the flag without switching to stderr. |
|
I'm sorry that Yazi couldn't match your workflow. In fact, I never really understood what your X issue was, why only Anyway, feel free to close this PR if it's no longer valuable to you. Sorry again for any inconvenience it may have caused you. |
|
Everything is cool! Please take the refactoring. I hope it helps! Was a cool finger practice :D The link is interesting, maybe i can switch regardless (didnt even knew this is an option) edit: i removed the flag and left the refactoring intact |
Signed-off-by: aserowy <[email protected]>
|
For what it's worth, you might want to take a look at orhun/personal-blog#24 to know more about stdout/stderr performance. You can make stderr as fast as stdout by buffering it (code in the article) by wrapping stderr in a BufWriter. |
Funny. Thus, a buffered stderr should lead to better perf than the normal stdout in crossterm :D Something like this (untested!) would do the trick? Terminal::new(CrosstermBackend::new(BufWriter::new(stderr())))?; |
In theory yes, I won't explain what the article did better than me but the tldr is
|
|
The article is cool! I think it will clear up all my doubts about |
|
let me know if i should convert the removal of the flag commit. Otherwise the pr should only contain the refactoring. |
|
Let me make some changes and merge it first. I'll try to add |
|
Thank you for the PR, let me merge it now. |
quit command
Hi, long time no see! Yazi switched to yazi --cwd-file /dev/stdout | catto get the CWD when exiting. stdout.mp4 |
Hi,
i added a flag to be able to write the selected file for opening to stdout. To enable multiple flags at the same time i refactored these actions into an enum for quit actions which gets handled on app.quit. Thus, all actions on quit are now treated at the same stage of the app lifecycle.
My motivation was to ensure my workflow stays intact when switching from lf to yazi and i thought maybe others find the option usefull as well.
Kind regards
Alexander