giulianopz / newscanoe

a simple TUI to read RSS/Atom/JSON feeds
GNU General Public License v3.0
2 stars 0 forks source link

Implement smooth scrolling #37

Open giulianopz opened 9 months ago

giulianopz commented 9 months ago

https://flak.tedunangst.com/post/terminal-smooth-scrolling

giulianopz commented 2 months ago

read here:

The first trick is "overwrite, don't clear". If you clear the "screen" and then add new content, you risk seeing a blank or partially blank frame for a brief moment. It's far better to overwrite the content in the terminal entirely so that there is no intermediate blank frame.

The second trick would be to write new content in a single write to standard output. It may be convenient to make multiple file.write calls to display an update, but as with the blank frame you risk a partial update becoming visible.

The third trick would be to use the Synchronized Output protocol; a relatively new addition to the terminal protocol, but already supported by many terminals. Details in the link, but the gist is that you tell the terminal when you begin and end a frame. It can then use this information to deliver flicker free updates.

With these three tricks in place you can create very smooth animation as long as you can deliver updates at regular intervals. Textual uses 60fps as a baseline. Any more than that probably isn't going to be noticeable.