Skip to content

Latest commit

 

History

History
9 lines (5 loc) · 1.5 KB

File metadata and controls

9 lines (5 loc) · 1.5 KB

Rendering

Opal's rendering relies on ANSI escape sequences. These are special sequences that the console interprets and uses to modify its state, for example to change the colors it is writing in.

Note: Windows Terminal has sequence processing enabled by default, however that is not the case for Windows Console. In the case of the latter, the console mode needs to be changed to enable the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag, which necessitates P/Invoke to Win32's SetConsoleMode function. For implementation details, refer to the WindowsConsoleHandler class, as well as Kernel32 class

ConsoleRenderer

The ConsoleRenderer class is responsible for rendering a ConsoleGrid to the console. It does so by going through the grid, line by line, and appends the necessary character and styling for each ConsoleChar to a StringBuilder. It will not apply styling to characters if the character before it has the same styling, in order to reduce the amount of data being appended to the StringBuilder. Finally, it passed the StringBuilder to a platform dependent IConsoleHandler which then writes to the console.