Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cli] Reimplement the interactive renderer
The display pipleline looks like this: โญโโโโโโโฎ โEngineโ โฐโโโโโโโฏ โฌ engine events โญโโโโโโโโโโโโโโโโโฎ โProgress Displayโ โฐโโโโโโโโโโโโโโโโโฏ โฌ display events: ticks, resource updates, system messages โญโโโโโโโโโโโโโโโโโโฎ โProgress Rendererโ โฐโโโโโโโโโโโโโโโโโโฏ โฌ text โญโโโโโโโโโฎ โTerminalโ โฐโโโโโโโโโฏ The existing implementation of the interactive Progress Renderer is broken into two parts, the display renderer and the message renderer. The display renderer converts display events into progress messages, each of which generally represents a single line of text at a particular position in the output. The message renderer converts progress messages into screen updates by identifying whether or not the contents of a particular message have changed and if so, re-rendering its output line. In somewhat greater detail: โญโโโโโโโโโโโโโโโโโฎ โDisplay Rendererโ โฐโโโโโโโโโโโโโโโโโฏ โฌ convert resource rows into a tree table โฌ convert the tree table and system messages into lines โฌ convert each line into a progress message with an index โญโโโโโโโโโโโโโโโโโฎ โMessage Rendererโ โฐโโโโโโโโโโโโโโโโโฏ โฌ if the line identified in a progress message has changed, โฌ go to that line on the terminal, clear it, and update it โญโโโโโโโโโฎ โTerminalโ โฐโโโโโโโโโฏ This separation of concerns is unnecessary and makes it difficult to understand where and when the terminal is updated. This approach also makes it somewhat challenging to change the way in which the display interacts with the terminal, as both the display renderer and the message renderer need to e.g. understand terminal dimensions, movement, etc. These changes reimplement the interactive Progress Renderer using a frame-oriented approach. The display is updated at 60 frame per second. If nothing has happened to invalidate the display's contents (i.e. no changes to the terminal geometry or the displayable contents have occurred), then the frame is not redrawn. Otherwise, the contents of the display are re-rendered and redrawn. An advantage of this approach is that it made it relatively simple to fix a long-standing issue with the interactive display: when the number of rows in the output exceed the height of the terminal, the new renderer clamps the output and allows the user to scroll the tree table using the up and down arrow keys.
- Loading branch information