Elius94 / console-gui-tools

A simple library to draw option menu or other popup inputs and layout on Node.js console.
MIT License
111 stars 17 forks source link

Elius94/issue13 #16

Closed Elius94 closed 2 years ago

Elius94 commented 2 years ago

NEW DRAWING ALGORYTM

Animation

Now there's no more flickering in the screen! all the page is prerendered before printing on the console.

Introduced new styling design pattern:

Each page need to be created with the new class

const p = new PageBuilder()

and to add a styled row it's neccessary to call:

p.addRow({ text: `  'm'`, color: 'gray', bold: true }, { text: `       - Select simulation mode`, color: 'white', italic: true })

The arguments of that function is an array of object (function arguments syntax, no []!), so in a row you can add different phrases with different styles.

The styles are converted to the Chalk modificator:

colors:

Background colors ('bg')

Formatters (Each is a prop):

eg:

p.addRow({ text: `TCP messages sent:`, color: 'green', bg: 'bgRed', bold: true, italic: true, underline: true }, { text: ` ${tcpCounter}`, color: 'white' })

And so, we can add the PageBuilder to the home page

GUI.setHomePage(p)

The new Screen class is used internally by the ConsoleManager.