UCON is a Node.js super framework for I/O in terminals.
It is designed to make I/O in terminals Visualize, Componentize and Standardize.
As a framework, UCON also provides useful standard components, such as ProgressBar and Table etc.
It is also convenient to create a component on your own, because the design of UCON and the features of terminals. The implementation of a component generally does not need to exceed 50 lines.
Developed by UniCoder Group. DESIGNED IN CHINA.
Converts plain text output into a graphic of characters.
Each output can be composed of components.
This borrows from the designs of front-end frameworks.
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. 1
In UCON, components are divided into three categories: BlockComponent, InlineComponent and ContainerComponent
BlockComponents occupy one or more lines without listening for input.
- Create an instance through
new - Call
mountto mount it to the newest line - You can call other methods to modify the content of it
let pb = new ucon.ProgressBar({
name: "test"
})......- Call
mountfor more than one time may cause undefined behaviors
InlineComponents render part of a line according to the arguments.
Call Name([Params][,...Contents]), which returns an instance.
ucon.ucon.log("This book is ", ucon.Italitic("Harry Potter"), ".");- The instance returned by this call is a derivative of
InlineComponent, so it cannot be added directly to the string or passed to the methods of standardconsole. Please call itsrendermethod to get the pure rendered string - The functions named as the component name are just a grammar sugar. These functions process the parameters and then construct and return the component instance
- This categorie of components can have no content parameters, such as the
Iconcomponent - Content arguments are separated by '
,', but Spaces are not added between arguments, for the same reason as theucon.logmethod, to allow another inline component to be part of content
ContainerComponents process all the outputs while they are registered.
- Create an instance through
new - Call
beginto output the beginning and register it - Output things that should be processed by it through
ucon.log - Call
endto unregister it and output the ending
let group = new ucon.Group();
......- Only the outputs through
ucon.logmethod will be processed byContainerComponents - The
register/unregistermethods can be called midway to turn processing on/off - If the program logic jumps due to exceptions or something else, the stack will be unbalanced, then the output will be confused, so be sure to clear/repair the stack at that time
[TODO]
Footnotes
-
https://reactjs.org/docs/components-and-props.html, Introduction ↩
