Open kyu08 opened 10 months ago
Thank you for taking the time opening this issue!
There is a little bit of misunderstanding what is actually happening in the example, I will try to break it down:
The last bit should the the interesting part for you. Here the command is run once, but the ui is drawn many times. What makes this cheap is that the screen is an already parsed state that in this case does not change at all.
I suspect the flickering stems from drawing render_preview_block
in the ui
function many times, which should generally be a non issue.
But in this case you: create pty, select target, openpty, run_command, create_parser, parse in a separate thread and render the widget - every time the ui is redrawn.
Ideally you want to more or less only have code from here in render_preview_block
.
I adjusted the example slightly and vendored your makefile for demonstration purposes: https://github.com/a-kenji/tui-term/tree/bat-paging-example
On a related note: I have been thinking how to make this easier, maybe even in an experimental api, through #12. Though I think that particular design is too complicated at the moment.
I am always thinking how to make this easier. So I am happy about any feedback!
Thank you very much for your detailed answer and for writing the code for explanation! :)
I tried to move the process before this point as you suggested, but in my case, I want to redraw the preview window with bat according to the user's input, so it might be difficult to move the process before this point outside of the loop
. (the cmd
depends on model.key_input
and the value of model.key_input
represents the user's key input).
Anyway, it's good to know that fixing the flickering might be difficult. I really appreciate you replying to me!
Thanks for taking the time to reply to the other issue as well!
Thank you for creating great ratatui plugin!
Premise
0.24.0
0.1.5
rustc —version
:rustc 1.74.0 (79e9716c9 2023-11-13) (Homebrew)
Problem
Implementation
How to reproduce
gh repo clone kyu08/fzf-make
cd fzf-make
cargo run
Again, there may be parts I don't understand, so it would be helpful if you could point out if I'm wrong. Also, there is some missing information, please let me know. Thank you.