FTXUI: Window doesn't update on adding a element to Elements
I am adding data to Elements output
from a separate thread, data is added correctly, but the screen isn’t updated on adding a new element, i need to move the focus area with arrow keys for the UI to update, how can i make it update everytime a new element is added to Elements output
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (17 by maintainers)
scoped_lock
is always better thanlock_guard
and should be used.However, when locking only one mutex, its behavior is equivalent here.
Hi Thinkty, my memory is a bit rusty, but I don’t think using scoped_lock will be any better here, as lock guard does the job and I am using only one mutex not multiple.
Regards Vedant
You are modifying and reading your data from two thread. You need to use a mutex to ensure you don’t do this at the same time. https://en.cppreference.com/w/cpp/thread/lock_guard
If you don’t want to use mutex, you could also use the Receiver class below as a thread-safe queue to request updates from one thread, but execute them on the UI thread. https://github.com/ArthurSonzogni/FTXUI/blob/master/include/ftxui/component/receiver.hpp
No, this is currently not possible. This is simpler this way. I could try to print only the required difference, but this would require printing many “displace the cursor to position (x,y)”. This wouldn’t be better.
What OS are you using? (Windows support is quite limited now)
Then, use screen.PostEvent(Event::Custom) only when you need a refresh.