Shellminator V3.0.1
Simple Terminal
|
Most modern terminal emulators support VT100 escape sequences. These sequences are special commands that allow you to manipulate various terminal elements, such as color, style, and cursor position. If you're interested in this topic, you can find a detailed explanation here.
The demo below isn’t interactive—it simply showcases how you can format the Serial output.
Formatting text with this library is very simple. Much like a modern word processor, you can set different attributes for the text. Once you've set the attributes, anything you print to the console will be formatted accordingly until you change the formatting attributes again.
Let's take a look at the available formatting options. We'll start with the styles, as it's usually best to define these first:
Style | Description |
---|---|
Regular | This is the most important formatting option. If you want to reset the console formatting to default, this is what you need. Typically, it is used before specifying a color. |
Bold | This allows you to set the text to bold. |
Low Intensity | This allows you to set the text to bold. In this case, the text appears slightly lighter than normal. |
Italic | This allows you to set the text to italic. |
Underline | This allows you to make the text underlined. |
Blinking | If your terminal emulator supports this feature, your text will blink. Unfortunately, I've encountered few emulators that support it, but examples include Linux shell and Windows cmd. However, Xterm.js does not support it, so it won't work in browser-based examples or in VS Code. |
Reverse | We're not quite sure what this does since we haven't come across an emulator that supports it yet. We implemented it to comply with the standard, but we'd be thrilled if someone could demonstrate its usefulness to us! |
Background | This is a very useful formatting option that swaps the foreground and background colors. If you want to highlight text, this can be a great choice. |
Invisible | You can create invisible text with this, where the text color matches the terminal background. The text will still be there, you just won't see it, but you can select it with the mouse, for example. |
Here's a simple example code for you:
The first thing we need is the address of a Stream object. This could be, for example, the default Serial object. The library will use this to generate the requested VT100 sequence needed to achieve the desired format. After this, you need to specify the formatting settings.