Documentation
¶
Overview ¶
Package screenshot turns the contents of a tcell simulation screen into something that can be committed to the repository: plain text for tests to compare against, and SVG for the documentation.
The point is that both come from the same run. A picture in the README that is regenerated by the same command a test asserts on cannot quietly drift away from what the program does.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnimatedSVG ¶
AnimatedSVG draws a sequence of screens as one looping picture.
SVG rather than a GIF because it is the same renderer the still screenshots already use, so the animation cannot drift away from them; because it stays sharp at any size, where a GIF of a terminal is either huge or blurry; and because it needs no encoder - there is no ffmpeg or ImageMagick to depend on and nothing to install to regenerate it.
Frames are drawn on top of each other and shown one at a time by a discrete SMIL animation. Discrete rather than interpolated: a terminal does not fade between states, and interpolation would show two frames at once.
A viewer that ignores SMIL - some renderers do - shows the first frame, which is why the first frame is the one worth seeing on its own.
func Grab ¶
func Grab(s tcell.SimulationScreen) ([][]Cell, int, int)
Grab reads the whole screen. Trailing blanks on each line are kept, because a line that is blank to the right edge and one that is short are different screens, and a golden file should notice.
func SVG ¶
SVG renders the screen as an image for the documentation.
Cells are emitted in runs of identical style rather than one element each: a 120x36 screen is over four thousand cells, and one element per cell produces a file too large to review in a diff.
func Text ¶
Text renders the screen as plain text, one line per row, right-trimmed.
This is what the tests compare. Style is deliberately dropped: a golden file that encodes colour would fail on every palette tweak, and the thing worth catching is a pane that stopped being drawn, not a shade that changed.