Console
Logging to the Console for text based applications
If your application is purely text-based, you can use the familiar
console
global to write textual data to the screen of the application
in the terminal-like interface that libnx
provides.
The canvas rendering mode is the default rendering mode for nx.js applications. To draw more intricate graphics, you should use the Canvas API.
Example
ANSI Escape Codes
Listed below are a few (non-exhaustive) npm modules known to work well with nx.js when using the Console renderer:
kluer
- Output colored text with ANSI escape codessisteransi
- ANSI escape sequences for moving the cursor
Limitations
It is worth noting that the terminal interface that libnx
provides
has dimensions of 80 x 45 characters, supports a limited set of unicode characters,
and provides no customization options for the appearance of the text.
If you would like more control over the visual appearance of your application,
consider using the @nx.js/terminal
package, which provides a more
full-featured terminal interface powered by xterm.js
.