VladimirMarkelov / clui

Command Line User Interface (Console UI inspired by TurboVision)
MIT License
670 stars 50 forks source link

What is the correct way to redraw a control? #144

Open jlopezr opened 3 years ago

jlopezr commented 3 years ago

I am using a label for showing information that I receive from an asynchronous goroutine through a channel. When I receive new data, I modify the title of the label and then use the ui.RefreshScreen() function.

This is working for me but I am not sure if this redraws all the screen or only the modified control.

What is the expected way to ask the library to redraw a specific control?

VladimirMarkelov commented 3 years ago

Yes, it is the correct way. There are two ways: do not call anything and it redraws after the next key or mouse event or, if you need to do it immediately, you have to call ui.RefreshScreen somehow. On the one hand, it seems overkill to refresh the screen if you need to redraw a single element; on the other hand, internally it should optimize out redundant screen output and result in repainting only changed area in the screen