telnet towel.blinkenlights.nl
Typing the above command in a terminal on Linux produces a Star Wars animation.
What baffles me is how the writers were able to produce an animation in a terminal in the first place. Normally one cannot undelete previous lines in a terminal right? Even with ~Ctrl+L~ the terminal prompt remains. Same goes for the famous steam locomotive animation in linux produced via the command sl
/
How does the source code work for these commands in the first place, What terminal magic is required to produce individual frames of an animation and delete previous ones onto the screen?
I can imagine how one might doe this with Emacs, (for instance "M-x butterfly") but on a terminal it seems like magic!
telnet towel.blinkenlights.nl | head -c 400K > capture
(2) Wait. (3)less capture
(4) NoticeESC[H
andESC[J
. (5) Investigate:CUP
andED
here. (6) Notice frames starting withESC[H
. (7) Exitless
and replay in a constant rate:<capture pv -qL 10000
// Conclusion: the server clears your screen by sendingESC[J
and then sends single frames, each printed from the top thanks toESC[H
. The animation is "smooth" becauseESC[H
and the following frame is sent without delay. The server waits between frames.