Shellminator V3.0.1
Simple Terminal
|
Shellminator object. More...
#include <Shellminator.hpp>
Classes | |
struct | shellEvent_t |
Shell event structure. More... | |
Public Member Functions | |
Shellminator (Stream *stream_p) | |
Shell object constructor. More... | |
bool | enableBuffering (uint8_t *buffer, int bufferSize) |
Enable buffering to gain speed. More... | |
void | attachExecFunc (void(*execution_fn_p)(char *, Shellminator *)) |
Register a function callback for command execution. More... | |
void | attachNeofetchFunc (void(*neofetch_fn_p)(Shellminator *)) |
Register a function callback for neofetch command. More... | |
void | begin (const char *banner_p) |
Shellminator initialization function. More... | |
void | sendBackspace () |
Sends a backspace. More... | |
void | clear () |
Clear screen. More... | |
void | update () |
Update function. More... | |
void | logOut () |
void | format (Stream *stream_p, int firstArg) |
Basic text formatting. More... | |
void | format (Stream *stream_p, int firstArg, int secondArg) |
void | format (Stream *stream_p, int firstArg, int secondArg, int thirdArg) |
void | hideCursor () |
Hide the cursor. More... | |
void | showCursor () |
Show the cursor. More... | |
bool | getCursorPosition (int *x, int *y, uint32_t timeout=250) |
Get the position of the cursor. More... | |
void | setCursorPosition (int x, int y) |
Set the position of the cursor. More... | |
bool | getTerminalSize (int *width, int *height) |
void | drawLogo () |
Draws the startup logo. More... | |
void | printBanner () |
This function prints the banner text. More... | |
void | printHistory () |
Print command history. More... | |
void | printHelp () |
Print help text. More... | |
void | setBannerText (const char *banner_p) |
This function sets the banner text. More... | |
void | setBannerPathText (const char *bannerPath_p) |
This function sets the banner path text. More... | |
void | attachLogo (const char *logo_p) |
This function attaches a logo to the terminal. More... | |
void | attachLogo (__FlashStringHelper *progmemLogo_p) |
This function attaches a logo to the terminal. More... | |
void | overrideUpArrow (void(*func)(Shellminator *)) |
Override up arrow key behaviour. More... | |
void | overrideDownArrow (void(*func)(Shellminator *)) |
Override down arrow key behaviour. More... | |
void | overrideLeftArrow (void(*func)(Shellminator *)) |
Override left arrow key behaviour. More... | |
void | overrideRightArrow (void(*func)(Shellminator *)) |
Override right arrow key behaviour. More... | |
void | overrideAbortKey (void(*func)(Shellminator *)) |
Override abort key behaviour. More... | |
void | overridePageUpKey (void(*func)(Shellminator *)) |
Override Page-Up key behaviour. More... | |
void | overridePageDownKey (void(*func)(Shellminator *)) |
Override Page-Down key behaviour. More... | |
void | overrideHomeKey (void(*func)(Shellminator *)) |
Override Home key behaviour. More... | |
void | overrideEndKey (void(*func)(Shellminator *)) |
Override End key behaviour. More... | |
void | overrideLogoutKey (void(*func)(Shellminator *)) |
Override Logout key behaviour. More... | |
void | overrideSearchKey (void(*func)(Shellminator *)) |
Override Search key behaviour. More... | |
void | freeUpArrow () |
Reset up arrow key functionality to default. More... | |
void | freeDownArrow () |
Reset down arrow key functionality to default. More... | |
void | freeLeftArrow () |
Reset left arrow key functionality to default. More... | |
void | freeRightArrow () |
Reset right arrow key functionality to default. More... | |
void | freeAbortKey () |
Reset abort key functionality to default. More... | |
void | freePageUpKey () |
Reset Page-Up key functionality to default. More... | |
void | freePageDownKey () |
Reset Page-Down key functionality to default. More... | |
void | freeHomeKey () |
Reset Home key functionality to default. More... | |
void | freeEndKey () |
Reset End key functionality to default. More... | |
void | freeLogoutKey () |
Reset Logout key functionality to default. More... | |
void | freeSearchKey () |
Reset Search key functionality to default. More... | |
void | setPassword (uint8_t *hashData, int hashSize) |
Enable login password. More... | |
void | setPasswordHashFunction (void(*hashFunc_p)(uint8_t *, int, uint8_t *, int)) |
Replace the built-in CRC32 hash generator. More... | |
void | beginScreen (ShellminatorScreen *screen_p, int updatePeriod=250) |
Register Screen object to draw. More... | |
void | endScreen () |
Abort Screen session. More... | |
void | swapScreen (ShellminatorScreen *screen_p, int updatePeriod=250) |
void | swapScreenAndClear (ShellminatorScreen *screen_p, int updatePeriod=250) |
void | requestRedraw () |
Redraw request from a Screen object. More... | |
int | eventAvailable () |
Get the number of events available for reading from the eventBuffer. More... | |
shellEvent_t | readEvent () |
Read an event. More... | |
void | popEvent () |
Remove the current element from the buffer. More... | |
void | mouseBegin () |
Enable mouse reports. More... | |
void | mouseEnd () |
Disable mouse reports. More... | |
void | input (char *buffer, int bufferSize, const char *instruction, void(*callback)(char *, int, Shellminator *), bool secret=false) |
Input prompt. More... | |
void | beep () |
Select list. More... | |
void | printLoginScreen () |
ShellminatorBufferedPrinter * | getBufferedPrinter () |
Get the buffered printer object address. More... | |
void | attachColorizer (DefaultColorizer *colorizer_p) |
void | autoDetectTerminal () |
Static Public Member Functions | |
static void | setFormat (Stream *stream_p, int firstArg) |
Basic text formatting. More... | |
static void | setFormat (Stream *stream_p, int firstArg, int secondArg) |
static void | setFormat (Stream *stream_p, int firstArg, int secondArg, int thirdArg) |
static void | hideCursor (Stream *stream_p) |
Hide the cursor. More... | |
static void | showCursor (Stream *stream_p) |
Show the cursor. More... | |
static void | setCursorPosition (Stream *channel_p, int x, int y) |
Set the position of the cursor. More... | |
static Shellminator * | castVoidToShellminator (void *ptr) |
This is a helper function for pointer casting. More... | |
static bool | waitForKey (Stream *source, char key, uint32_t timeout=0) |
Wait for specific keypress. More... | |
static bool | waitForKey (Stream *source, char *keys, uint32_t timeout=0) |
Wait for specific keypress. More... | |
Public Attributes | |
shellEvent_t | eventBuffer [EVENT_BUFFER_SIZE] |
The events are stored in this buffer. More... | |
uint8_t | eventBufferWritePtr |
Write position for the eventBuffers circular structure. More... | |
uint8_t | eventBufferReadPtr |
Read position for the eventBuffers circular structure. More... | |
int | terminalWidth = 30 |
Stores the width of the terminal in characters. More... | |
int | terminalHeight = 12 |
Stores the height of the terminal in characters. More... | |
char | mouseEventBuffer [SHELLMINATOR_MOUSE_PARSER_BUFFER_SIZE] |
This buffer is used to parse the mouse coordinates form the host terminals answer. More... | |
uint8_t | mouseEventBufferCounter = 0 |
This variable traks the next free characters location in the mouseEventBuffer. More... | |
bool | enableFormatting = true |
This flag enables or disables character formatting. More... | |
bool | mute = false |
If set, the buzzer will be silent. More... | |
Stream * | channel = NULL |
Pointer to the communication class. More... | |
Static Public Attributes | |
static const char * | version = SHELLMINATOR_VERSION |
String, that holds the version information. More... | |
Protected Member Functions | |
virtual void | printCommandParserHelp (Stream *channel_p, bool formatting_p) |
Print command parser Help. More... | |
virtual void | checkCommandFraction () |
Check the command with the command parser to get some useful information. More... | |
virtual bool | hasCommandParser () |
virtual void | executeWithCommandParser () |
virtual void | autoCompleteWithCommandParser () |
void | redrawLine () |
Protected Attributes | |
char | cmd_buff [SHELLMINATOR_BUFF_DIM][SHELLMINATOR_BUFF_LEN+1] = {{0}} |
Text buffer. More... | |
uint32_t | cmd_buff_dim = 1 |
This variable tracks the index of the previous command while you browsing the command history. More... | |
uint32_t | cmd_buff_cntr = 0 |
This variable tracks the end of the input message. More... | |
uint32_t | cursor = 0 |
This variable tracks the location of the next character. More... | |
bool | commandFound = false |
This flag must be set true in checkCommandFraction function when the command parser contains the command. More... | |
Private Attributes | |
ShellminatorBufferedPrinter | bufferedPrinter |
It can be used to accelerate the data sending process. More... | |
bool | bufferMemoryAllocated = false |
If memory is allocated, this will be true;. More... | |
ShellminatorScreen * | screen = NULL |
Pointer to a ShellminatorScreen object. More... | |
unsigned long | screenTimerStart = 0 |
The screen is drawn within a pre-defined periods. More... | |
unsigned long | sizeTimerStart = 0 |
int | screenUpdatePeriod |
The time interval between two drawings. More... | |
bool | screenRedraw |
This flag shows if a request come from the Screen object to issue a draw function call. More... | |
DefaultColorizer | defaultColorizer |
DefaultColorizer * | colorizer = &this->defaultColorizer |
uint8_t * | passwordHash = NULL |
Stores the address of the password hash array. More... | |
int | passwordHashSize = 0 |
Stores the password hash array size. More... | |
bool | loggedIn = false |
If logging in is required this flag will be true. More... | |
void(* | passwordHashFunc )(uint8_t *, int, uint8_t *, int) = NULL |
Pointer to the hash function. More... | |
void(Shellminator::* | currentState )(char) = &Shellminator::ShellminatorDefaultState |
Function pointer to the current state of the main state-machine. More... | |
char * | logo = NULL |
Pointer to a string that holds the startup logo. More... | |
__FlashStringHelper * | progmemLogo = NULL |
On AVR there is an oprion to store the logo in the program memory. More... | |
void(* | execution_fn )(char *, Shellminator *) |
This function-pointer stores the execution function pointer. More... | |
void(* | neofetch_fn )(Shellminator *) |
This function-pointer stores the neofetch function pointer. More... | |
uint32_t | escape_state = 0 |
This variable tracks the state of the VT100 decoder state-machine. More... | |
char | banner [SHELLMINATOR_BANNER_LEN] = {'\0'} |
This character array stores the banner text. More... | |
char | bannerPath [SHELLMINATOR_BANNER_PATH_LEN] = "$" |
This character array stores the banner path text. More... | |
uint8_t | lastBannerSize = 0 |
Size of the last printed banner in characters. More... | |
void(* | upArrowOverrideFunc )(Shellminator *) = NULL |
Function pointer for up arrow behaviour override. More... | |
void(* | downArrowOverrideFunc )(Shellminator *) = NULL |
Function pointer for down arrow behaviour override. More... | |
void(* | leftArrowOverrideFunc )(Shellminator *) = NULL |
Function pointer for left arrow behaviour override. More... | |
void(* | rightArrowOverrideFunc )(Shellminator *) = NULL |
Function pointer for right arrow behaviour override. More... | |
void(* | abortKeyFunc )(Shellminator *) = NULL |
Function pointer for abort key behaviour override. More... | |
void(* | pageUpKeyFunc )(Shellminator *) = NULL |
Function pointer for Page-Up key behaviour override. More... | |
void(* | pageDownKeyFunc )(Shellminator *) = NULL |
Function pointer for Page-Down key behaviour override. More... | |
void(* | homeKeyFunc )(Shellminator *) = NULL |
Function pointer for Home key behaviour override. More... | |
void(* | endKeyFunc )(Shellminator *) = NULL |
Function pointer for End key behaviour override. More... | |
void(* | logoutKeyFunc )(Shellminator *) = NULL |
Function pointer for Logout key behaviour override. More... | |
void(* | searchKeyFunc )(Shellminator *) = NULL |
Function pointer for Search key behaviour override. More... | |
bool | inSearch = false |
If reverse search mode is active, this flag will be true. More... | |
int | searchMatch |
Used to parse reverse search. More... | |
bool | inputActive = false |
This flag will be true when an input prompt is active. More... | |
int | inputInstuctionSize = 0 |
This will store the length of the instruction text size in an input. More... | |
char * | inputDestinationBuffer |
Pointer to a buffer that will be used to store the text, that is typed to an input. More... | |
int | inputDestinationBufferSize |
Size of the buffer that is attached to an input. More... | |
bool | inputSecretMode |
If secret mode is activated on an input, this flag will be true. More... | |
void(* | inputCallback )(char *, int, Shellminator *) |
This function will be called when an input is finished. More... | |
uint32_t | lastKeyPressTime = 0 |
Last time in ms when a key was pressed. More... | |
Friends | |
class | ShellminatorProgress |
class | ShellminatorUT |
Shellminator object.
It can be used to interface with a VT100 compatible terminal like PuTTY, Terra Term or minicom. The module requires an Arduino-like Serial object.
Definition at line 105 of file Shellminator.hpp.
VT100 color codes.
This enum holds all of the VT100 compatible background color codes.
Definition at line 127 of file Shellminator.hpp.
Coded event enumeration.
Definition at line 697 of file Shellminator.hpp.
Shell Event enumeration.
Definition at line 687 of file Shellminator.hpp.
VT100 color codes.
This enum holds all of the VT100 compatible color codes.
Definition at line 112 of file Shellminator.hpp.
VT100 font sytles.
This enum holds all of the VT100 compatible font styles.
Definition at line 142 of file Shellminator.hpp.
Shellminator::Shellminator | ( | Stream * | stream_p | ) |
Shell object constructor.
This is a simple constructor for a Shellminator object.
stream_p | Pointer to a Stream object which will be used for communication. |
Definition at line 38 of file Shellminator.cpp.
void Shellminator::attachColorizer | ( | DefaultColorizer * | colorizer_p | ) |
Definition at line 1968 of file Shellminator.cpp.
void Shellminator::attachExecFunc | ( | void(*)(char *, Shellminator *) | execution_fn_p | ) |
Register a function callback for command execution.
With this function you can attach an external function to the object This function will be called when a command is typed and the return key is pressed.
execution_fn_p | Function pointer to the execution function. |
The execution function prototype must be like this:
You can use any name you like, but the arguments and the return type has to be the same. Practical example for impementation:
Definition at line 141 of file Shellminator.cpp.
void Shellminator::attachLogo | ( | __FlashStringHelper * | progmemLogo_p | ) |
This function attaches a logo to the terminal.
The logo is just a character array. To create custom startup logo: https://patorjk.com/software/taag/#p=display&f=Slant&t=Arduino To make it to a c-string: https://tomeko.net/online_tools/cpp_text_escape.php?lang=en Add '\r' to all line end.
logo_p | Pointer to the logo's address. |
Definition at line 126 of file Shellminator.cpp.
void Shellminator::attachLogo | ( | const char * | logo_p | ) |
This function attaches a logo to the terminal.
The logo is just a character array. To create costum startup logo: https://patorjk.com/software/taag/#p=display&f=Slant&t=Arduino To make it to a c-string: https://tomeko.net/online_tools/cpp_text_escape.php?lang=en Add '\r' to all line end.
logo_p | Pointer to the logo's address. |
Definition at line 134 of file Shellminator.cpp.
void Shellminator::attachNeofetchFunc | ( | void(*)(Shellminator *) | neofetch_fn_p | ) |
Register a function callback for neofetch command.
With this function you can attach an external function to the object This function will be called when a command is typed and the return key is pressed. You can find mor information about neofetch here.
neofetch_fn_p | Function pointer to the neofetch callback function. |
The neofetch callback function prototype must be like this:
You can use any name you like, but the arguments and the return type has to be the same. Practical example for impementation:
Definition at line 148 of file Shellminator.cpp.
|
protectedvirtual |
Reimplemented in ShellminatorCommanderInterface.
Definition at line 315 of file Shellminator.cpp.
void Shellminator::autoDetectTerminal | ( | ) |
Definition at line 1770 of file Shellminator.cpp.
void Shellminator::beep | ( | ) |
Select list.
It is a simple input prompt to select elements from a list. There are two working modes:
To abort this prompt the following keys can be used:
source | Pointer to a source stream. The function will wait for a key to arrive on this channel. |
lineText | Character array. You can specify the prompt instructions here. |
numberOfElements | The number of elements in the list. |
list | The list of the options( string array ) |
timeout | Timeout in ms. If it is 0, that means no timeout. |
selection | bool array to store the status of the selected elements. The size of this array should be equal to the size of the list. If an element is selected, the corresponding element in this array will be true. To enable multiple element selection mode, this pointer has to point to a valid array! [ optional, NULL by default( single element mode ) ] |
Definition at line 1014 of file Shellminator.cpp.
void Shellminator::begin | ( | const char * | banner_p | ) |
Shellminator initialization function.
This function initializes the object and prints the startup logo.
banner_p | this is equivalent to a user name in linux like terminals. It is just a visual thing. |
Definition at line 437 of file Shellminator.cpp.
void Shellminator::beginScreen | ( | ShellminatorScreen * | screen_p, |
int | updatePeriod = 250 |
||
) |
Register Screen object to draw.
This function can be used to register a Screen object to the terminal. After the Screen object is registered, it will take over the control against the terminal interface.
screen_p | Pointer to a screen object. |
updatePeriod | Optionally, you can specify the screen refresh time in milliseconds. |
Definition at line 1794 of file Shellminator.cpp.
|
static |
This is a helper function for pointer casting.
It is designed to be used with Commander-API, when you have to cast a void* to Shellminator*.
ptr | Pointer to a Shellminator object in void*. |
Definition at line 1766 of file Shellminator.cpp.
|
protectedvirtual |
Check the command with the command parser to get some useful information.
Reimplemented in ShellminatorCommanderInterface.
Definition at line 307 of file Shellminator.cpp.
|
private |
Check the password.
This function generates a hash from its argument string and compares it with the hash stored in the passwordHash array.
password | Input text to compare. |
Definition at line 352 of file Shellminator-Crypto.cpp.
void Shellminator::clear | ( | ) |
Clear screen.
This function clears the terminal screen.
Definition at line 68 of file Shellminator-Styles.cpp.
void Shellminator::drawLogo | ( | ) |
Draws the startup logo.
Draws the startup logo in the terminal
Definition at line 975 of file Shellminator.cpp.
bool Shellminator::enableBuffering | ( | uint8_t * | buffer, |
int | bufferSize | ||
) |
Enable buffering to gain speed.
With this function, a buffer can be attached to the object. It can be used to accelerate the printing process. Because this library meant to work on low power devices, with limited amount of dynamic memory, all rendering happens in place. It has one downside tough. The printing not happens in one time. Small independent printing actions renders the final result. The frontend on a PC can't handle this very well, if the data is coming fast. A much better solution is to collect the printed data into a buffer, and flush it, when we are finished. You can achieve this functionality with this function.
buffer | Pointer to a buffer. It has to be uint8_t type. |
bufferSize | The size of the buffer in elements. |
Definition at line 67 of file Shellminator.cpp.
void Shellminator::endScreen | ( | ) |
Abort Screen session.
With this function you can abort a registered Screen session.
Definition at line 1895 of file Shellminator.cpp.
int Shellminator::eventAvailable | ( | ) |
Get the number of events available for reading from the eventBuffer.
Definition at line 54 of file Shellminator-Events.cpp.
|
protectedvirtual |
Reimplemented in ShellminatorCommanderInterface.
Definition at line 311 of file Shellminator.cpp.
void Shellminator::format | ( | Stream * | stream_p, |
int | firstArg | ||
) |
Basic text formatting.
You can use this function to modify the style or color of the printed text. This function can only be accessed with an object.
stream_p | Pointer to a Stream object. |
firstArg | The first format specifier. |
... | All other format specifiers. The last argument must be a negative integer number! |
Definition at line 111 of file Shellminator-Styles.cpp.
void Shellminator::format | ( | Stream * | stream_p, |
int | firstArg, | ||
int | secondArg | ||
) |
void Shellminator::format | ( | Stream * | stream_p, |
int | firstArg, | ||
int | secondArg, | ||
int | thirdArg | ||
) |
void Shellminator::freeAbortKey | ( | ) |
Reset abort key functionality to default.
This function resets the abort key functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 96 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeDownArrow | ( | ) |
Reset down arrow key functionality to default.
This function resets the down arrow functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 84 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeEndKey | ( | ) |
Reset End key functionality to default.
This function resets the End key functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 112 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeHomeKey | ( | ) |
Reset Home key functionality to default.
This function resets the Home key functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 108 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeLeftArrow | ( | ) |
Reset left arrow key functionality to default.
This function resets the left arrow functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 88 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeLogoutKey | ( | ) |
Reset Logout key functionality to default.
This function resets the Logout key functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 116 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freePageDownKey | ( | ) |
Reset Page-Down key functionality to default.
This function resets the Page-Down key functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 104 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freePageUpKey | ( | ) |
Reset Page-Up key functionality to default.
This function resets the Page-Up key functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 100 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeRightArrow | ( | ) |
Reset right arrow key functionality to default.
This function resets the right arrow functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 92 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeSearchKey | ( | ) |
Reset Search key functionality to default.
This function resets the Search key functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 120 of file Shellminator-SpecialKeys.cpp.
void Shellminator::freeUpArrow | ( | ) |
Reset up arrow key functionality to default.
This function resets the up arrow functionality to default. If you want to detach the override function for the key, you have to call this function.
Definition at line 80 of file Shellminator-SpecialKeys.cpp.
ShellminatorBufferedPrinter * Shellminator::getBufferedPrinter | ( | ) |
Get the buffered printer object address.
With this function the bufferedPrinter object can be accessed from outside.
Definition at line 88 of file Shellminator.cpp.
bool Shellminator::getCursorPosition | ( | int * | x, |
int * | y, | ||
uint32_t | timeout = 250 |
||
) |
Get the position of the cursor.
This function can be used to query the current location of the cursor. The result will be passed back on the arguments.
x | Pointer to an integer. The horizontal coordinate will be written to the variable where this pointer points. |
y | Pointer to an integer. The horizontal coordinate will be written to the variable where this pointer points. |
timeout | You can specify a maximum time to wait for the answer in milliseconds. the default value is 100ms. |
The screen coordinate system works like this: The origin is on the top left and it's coordinate is 1;1. The screen size can vary.
Definition at line 748 of file Shellminator.cpp.
bool Shellminator::getTerminalSize | ( | int * | width, |
int * | height | ||
) |
Definition at line 946 of file Shellminator.cpp.
|
protectedvirtual |
Reimplemented in ShellminatorCommanderInterface.
Definition at line 319 of file Shellminator.cpp.
void Shellminator::hideCursor | ( | ) |
Hide the cursor.
This function disables the cursor on the host terminal. This function can only be accessed with an object.
Definition at line 36 of file Shellminator-Styles.cpp.
|
static |
Hide the cursor.
This function disables the cursor on the host terminal. This function can be accessed outside of the class.
stream_p | Pointer to a Stream object. |
Definition at line 42 of file Shellminator-Styles.cpp.
|
private |
This function is used to search the previous matching command in the history.
Definition at line 36 of file Shellminator-SearchModule.cpp.
|
private |
This function is used to search the next matching command in the history.
Definition at line 86 of file Shellminator-SearchModule.cpp.
void Shellminator::input | ( | char * | buffer, |
int | bufferSize, | ||
const char * | instruction, | ||
void(*)(char *, int, Shellminator *) | callback, | ||
bool | secret = false |
||
) |
Input prompt.
It is a simple prompt for user input. You can create simple queries with this function. This is a non-blocking function, and this means, that the it will take over the control from the terminal until the user finishes. It can be interrupted with the abort key( ctrl-c ).
buffer | Pointer to a buffer. The typed text will be copied to this buffer. The result will be always terminated to make it compatible with str functions. |
bufferSize | The size of the buffer. |
instruction | Instruction text for the prompt. It can be helpful to instruct the user about what information is needed in this prompt. |
callback | When the input typed the data and the return key is pressed, this function will be called. The typed text will be available on the arguments. |
secret | If you has to request some sensitive data, you can set this flag to true. This way, the prompt will echo back * characters instead of the actual ones. |
Example callback function:
Definition at line 36 of file Shellminator-Input.cpp.
void Shellminator::logOut | ( | ) |
void Shellminator::mouseBegin | ( | ) |
Enable mouse reports.
With this function you can enable X-term like mouse reporting on the host terminal.
Definition at line 36 of file Shellminator-MouseInterface.cpp.
void Shellminator::mouseEnd | ( | ) |
Disable mouse reports.
Definition at line 47 of file Shellminator-MouseInterface.cpp.
void Shellminator::overrideAbortKey | ( | void(*)(Shellminator *) | func | ) |
Override abort key behaviour.
With this function you can attach a function that will be called every time when the abort key is pressed. The default abort key is usually a Ctrl + C combo.
func | Pointer to the function that will be called on keypress. |
Definition at line 52 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideDownArrow | ( | void(*)(Shellminator *) | func | ) |
Override down arrow key behaviour.
With this function you can attach a function that will be called every time when the down arrow key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 40 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideEndKey | ( | void(*)(Shellminator *) | func | ) |
Override End key behaviour.
With this function you can attach a function that will be called every time when the End key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 68 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideHomeKey | ( | void(*)(Shellminator *) | func | ) |
Override Home key behaviour.
With this function you can attach a function that will be called every time when the Home key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 64 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideLeftArrow | ( | void(*)(Shellminator *) | func | ) |
Override left arrow key behaviour.
With this function you can attach a function that will be called every time when the left arrow key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 44 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideLogoutKey | ( | void(*)(Shellminator *) | func | ) |
Override Logout key behaviour.
With this function you can attach a function that will be called every time when the Logout key is pressed. The default Logout key is usually a Ctrl + D combo.
func | Pointer to the function that will be called on keypress. |
Definition at line 72 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overridePageDownKey | ( | void(*)(Shellminator *) | func | ) |
Override Page-Down key behaviour.
With this function you can attach a function that will be called every time when the Page-Down key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 60 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overridePageUpKey | ( | void(*)(Shellminator *) | func | ) |
Override Page-Up key behaviour.
With this function you can attach a function that will be called every time when the Page-Up key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 56 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideRightArrow | ( | void(*)(Shellminator *) | func | ) |
Override right arrow key behaviour.
With this function you can attach a function that will be called every time when the right arrow key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 48 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideSearchKey | ( | void(*)(Shellminator *) | func | ) |
Override Search key behaviour.
With this function you can attach a function that will be called every time when the Logout key is pressed. The default Search key is usually a Ctrl + R combo.
func | Pointer to the function that will be called on keypress. |
Definition at line 76 of file Shellminator-SpecialKeys.cpp.
void Shellminator::overrideUpArrow | ( | void(*)(Shellminator *) | func | ) |
Override up arrow key behaviour.
With this function you can attach a function that will be called every time when the up arrow key is pressed.
func | Pointer to the function that will be called on keypress. |
Definition at line 36 of file Shellminator-SpecialKeys.cpp.
|
private |
Parse mouse data.
It is used by the main state machine. Its main task is to parse the mouse string and if it is parsed successfully, generate a new event in the event buffer for it.
Definition at line 95 of file Shellminator-MouseInterface.cpp.
void Shellminator::popEvent | ( | ) |
Remove the current element from the buffer.
It has to be used after calling the update function of the attached Screen object. This way an event won't get parsed multiple times.
Definition at line 103 of file Shellminator-Events.cpp.
void Shellminator::printBanner | ( | ) |
This function prints the banner text.
Definition at line 155 of file Shellminator.cpp.
|
protectedvirtual |
Print command parser Help.
Reimplemented in ShellminatorCommanderInterface.
Definition at line 303 of file Shellminator.cpp.
void Shellminator::printHelp | ( | ) |
Print help text.
Definition at line 324 of file Shellminator.cpp.
void Shellminator::printHistory | ( | ) |
Print command history.
Definition at line 207 of file Shellminator.cpp.
void Shellminator::printLoginScreen | ( | ) |
|
private |
This function processes a new character.
This function handles every character that arrives from the terminal software. It called by the update function every time when the Serial buffer has some unprocessed characters.
new_char | This is the nex character that has to be processed. |
Definition at line 633 of file Shellminator.cpp.
|
private |
Push a new event to the event buffer.
Definition at line 36 of file Shellminator-Events.cpp.
Shellminator::shellEvent_t Shellminator::readEvent | ( | ) |
Read an event.
With this function, you can read an event from the event buffer. Unlike Arduino-like read methods, this won't pop the event from the buffer after reading. This way a complex Screen layout is much easier to make.
SHELL_EVENT_EMPTY
. Definition at line 76 of file Shellminator-Events.cpp.
|
private |
If reverse search mode is active, this function is used to print the text correctly.
Definition at line 117 of file Shellminator-SearchModule.cpp.
|
protected |
Definition at line 506 of file Shellminator.cpp.
void Shellminator::requestRedraw | ( | ) |
Redraw request from a Screen object.
This function is used by the attached Screen object. The Screen object can signal the terminal interface with this function, to call the draw function in the next drawing session. The drawing only happens, when an event triggers it, to save some CPU time. This way the Screen drawing is much efficient.
Definition at line 1960 of file Shellminator.cpp.
void Shellminator::sendBackspace | ( | ) |
Sends a backspace.
This function makes a backspace in the terminal application. Basically it deletes the last character in the terminal screen.
Definition at line 494 of file Shellminator.cpp.
void Shellminator::setBannerPathText | ( | const char * | bannerPath_p | ) |
This function sets the banner path text.
It can be used when you want to change the banner path text runtime.
banner_p | String that contains the new banner text. |
$
Definition at line 115 of file Shellminator.cpp.
void Shellminator::setBannerText | ( | const char * | banner_p | ) |
This function sets the banner text.
It can be used when you want to change the banner text runtime.
banner_p | String that contains the new banner text. |
Definition at line 103 of file Shellminator.cpp.
void Shellminator::setCursorPosition | ( | int | x, |
int | y | ||
) |
Set the position of the cursor.
This function can be used to set the cursor location to a specified coordinate. This function can only be accessed with an object.
x | New X-coordinate of the cursor. |
y | New Y-coordinate of the cursor. |
The screen coordinate system works like this: The origin is on the top left and it's coordinate is 1;1. The screen size can vary.
Definition at line 921 of file Shellminator.cpp.
|
static |
Set the position of the cursor.
This function can be used to set the cursor location to a specified coordinate. This function can be accessed outside of the class.
channel_p | Pointer to a Stream object. |
x | New X-coordinate of the cursor. |
y | New Y-coordinate of the cursor. |
The screen coordinate system works like this: The origin is on the top left and it's coordinate is 1;1. The screen size can vary.
Definition at line 927 of file Shellminator.cpp.
|
static |
Basic text formatting.
You can use this function to modify the style or color of the printed text. This function can be accessed from outside of an object.
stream_p | Pointer to a Stream object. |
firstArg | The first format specifier. |
... | All other format specifiers. The last argument must be a negative integer number! |
Definition at line 75 of file Shellminator-Styles.cpp.
|
static |
Definition at line 85 of file Shellminator-Styles.cpp.
|
static |
Definition at line 97 of file Shellminator-Styles.cpp.
void Shellminator::setPassword | ( | uint8_t * | hashData, |
int | hashSize | ||
) |
Enable login password.
With this function you can add a login password. There is a twist in the story tough. Instead of storing the password itself, we have to store a hash that is generated from the password. The reason for this is simple. If you store the password, it can be dumped from the compiled firmware and it is easily hackable. If you store a hash, that is generated from the password, it is much safer, because ideally, you can not generate the original password back from its hash.
The default implementation uses a crc32 hash generator. It is not the safest, and not the prettiest, but it can be run on low end hardware fairly well. You can replace this hash algorithm to a custom one with the setPasswordHashFunction.
Using this is fairly simple, you need to generate a hash from your password. You can find an online hash generator here. Set the input to ASCII and the output to HEX with CRC32 mode. For this demo I will use Password
as password. The online tool calculated the result which is 0xCCB42483. This is all the information what we need.
Example code:
Definition at line 342 of file Shellminator-Crypto.cpp.
void Shellminator::setPasswordHashFunction | ( | void(*)(uint8_t *, int, uint8_t *, int) | hashFunc_p | ) |
Replace the built-in CRC32 hash generator.
If you want some more modern solution instead of the good old CRC32, you can do this with this function. You need a hash function which looks like this:
The hash must be generated from the inputData, and it's must be generated to the outputData.
Definition at line 348 of file Shellminator-Crypto.cpp.
|
private |
Definition at line 1495 of file Shellminator.cpp.
|
private |
Definition at line 1485 of file Shellminator.cpp.
|
private |
Definition at line 1199 of file Shellminator.cpp.
|
private |
Definition at line 1416 of file Shellminator.cpp.
|
private |
Definition at line 1474 of file Shellminator.cpp.
|
private |
Definition at line 1030 of file Shellminator.cpp.
|
private |
Definition at line 391 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 425 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 180 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 359 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 379 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 1424 of file Shellminator.cpp.
|
private |
Definition at line 1253 of file Shellminator.cpp.
|
private |
Definition at line 1538 of file Shellminator.cpp.
|
private |
Definition at line 1526 of file Shellminator.cpp.
|
private |
Definition at line 1182 of file Shellminator.cpp.
|
private |
Definition at line 1187 of file Shellminator.cpp.
|
private |
Definition at line 1192 of file Shellminator.cpp.
|
private |
Definition at line 321 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 343 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 245 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 1432 of file Shellminator.cpp.
|
private |
Definition at line 56 of file Shellminator-MouseInterface.cpp.
|
private |
Definition at line 472 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 495 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 437 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 460 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 1598 of file Shellminator.cpp.
|
private |
Definition at line 1454 of file Shellminator.cpp.
|
private |
Definition at line 282 of file Shellminator-SpecialKeys.cpp.
|
private |
Definition at line 1170 of file Shellminator.cpp.
|
private |
Definition at line 1175 of file Shellminator.cpp.
|
private |
Definition at line 1163 of file Shellminator.cpp.
|
private |
Definition at line 124 of file Shellminator-SpecialKeys.cpp.
void Shellminator::showCursor | ( | ) |
Show the cursor.
This function enables the cursor on the host terminal. This function can only be accessed with an object.
Definition at line 52 of file Shellminator-Styles.cpp.
|
static |
Show the cursor.
This function enables the cursor on the host terminal. This function can be accessed outside of the class.
stream_p | Pointer to a Stream object. |
Definition at line 58 of file Shellminator-Styles.cpp.
|
private |
Basic substring function.
The original source can be found here
Definition at line 215 of file Shellminator-SearchModule.cpp.
void Shellminator::swapScreen | ( | ShellminatorScreen * | screen_p, |
int | updatePeriod = 250 |
||
) |
Definition at line 1857 of file Shellminator.cpp.
void Shellminator::swapScreenAndClear | ( | ShellminatorScreen * | screen_p, |
int | updatePeriod = 250 |
||
) |
void Shellminator::update | ( | ) |
Update function.
This function handles all of the communication related stuff between the code and the terminal application.
Definition at line 640 of file Shellminator.cpp.
|
static |
Wait for specific keypress.
It can be useful with a simple prompt like waiting for Y or N characters. It can be useful, for multiple key detection. For example upper and lower case detection as well.
source | Pointer to a source stream. The function will wait for a key to arrive on this channel. |
keys | Character array. Array of characters for match detection. |
timeout | Timeout in ms. If it is 0, that means no timeout. [ optional, 0 by default ] |
Definition at line 1725 of file Shellminator.cpp.
|
static |
Wait for specific keypress.
It can be useful with a simple prompt like waiting for Y or N characters.
source | Pointer to a source stream. The function will wait for a key to arrive on this channel. |
key | Expected key. For example in a Yes/No prompt you expect 'Y' or 'y' to arrive. |
timeout | Timeout in ms. If it is 0, that means no timeout. [ optional, 0 by default ] |
Definition at line 1693 of file Shellminator.cpp.
|
friend |
Definition at line 893 of file Shellminator.hpp.
|
friend |
Definition at line 1174 of file Shellminator.hpp.
|
private |
Function pointer for abort key behaviour override.
Definition at line 1090 of file Shellminator.hpp.
|
private |
This character array stores the banner text.
Definition at line 1067 of file Shellminator.hpp.
|
private |
This character array stores the banner path text.
default banner path text is $
.
Definition at line 1071 of file Shellminator.hpp.
|
private |
It can be used to accelerate the data sending process.
With this, the output will be rendered once without flickering.
Definition at line 940 of file Shellminator.hpp.
|
private |
If memory is allocated, this will be true;.
Definition at line 943 of file Shellminator.hpp.
Stream* Shellminator::channel = NULL |
Pointer to the communication class.
By default it points to the default response handler.
Definition at line 879 of file Shellminator.hpp.
|
protected |
Text buffer.
This array stores the incoming and the previous commands. The 0th element always reserved to hold the incoming data. All other elements are holds the previous commands. Every new command shifts the elements towards the higher index, and removes the highest index element. To navigate between the previous commands you can use the UP and DOWN arrows on the keyboard. To specify the 'memory' of the interface you have to configure the SHELLMINATOR_BUFF_DIM definition.
Definition at line 907 of file Shellminator.hpp.
|
protected |
This variable tracks the end of the input message.
Definition at line 913 of file Shellminator.hpp.
|
protected |
This variable tracks the index of the previous command while you browsing the command history.
Definition at line 910 of file Shellminator.hpp.
|
private |
Definition at line 964 of file Shellminator.hpp.
|
protected |
This flag must be set true in checkCommandFraction function when the command parser contains the command.
Definition at line 920 of file Shellminator.hpp.
|
private |
Function pointer to the current state of the main state-machine.
Definition at line 1027 of file Shellminator.hpp.
|
protected |
This variable tracks the location of the next character.
Definition at line 916 of file Shellminator.hpp.
|
private |
Definition at line 963 of file Shellminator.hpp.
|
private |
Function pointer for down arrow behaviour override.
Definition at line 1081 of file Shellminator.hpp.
bool Shellminator::enableFormatting = true |
This flag enables or disables character formatting.
It can be useful when VT100 format parser is not available on the host device.
Definition at line 872 of file Shellminator.hpp.
|
private |
Function pointer for End key behaviour override.
Definition at line 1102 of file Shellminator.hpp.
|
private |
This variable tracks the state of the VT100 decoder state-machine.
Definition at line 1064 of file Shellminator.hpp.
shellEvent_t Shellminator::eventBuffer[EVENT_BUFFER_SIZE] |
The events are stored in this buffer.
It uses a circular structure to store the events. Usually this buffer should not has to be big.
Definition at line 734 of file Shellminator.hpp.
uint8_t Shellminator::eventBufferReadPtr |
Read position for the eventBuffers circular structure.
Definition at line 740 of file Shellminator.hpp.
uint8_t Shellminator::eventBufferWritePtr |
Write position for the eventBuffers circular structure.
Definition at line 737 of file Shellminator.hpp.
|
private |
This function-pointer stores the execution function pointer.
This function will be called when a command receives.
Definition at line 1057 of file Shellminator.hpp.
|
private |
Function pointer for Home key behaviour override.
Definition at line 1099 of file Shellminator.hpp.
|
private |
This flag will be true when an input prompt is active.
Definition at line 1148 of file Shellminator.hpp.
|
private |
This function will be called when an input is finished.
Definition at line 1167 of file Shellminator.hpp.
|
private |
Pointer to a buffer that will be used to store the text, that is typed to an input.
Definition at line 1156 of file Shellminator.hpp.
|
private |
Size of the buffer that is attached to an input.
Definition at line 1159 of file Shellminator.hpp.
|
private |
This will store the length of the instruction text size in an input.
Definition at line 1152 of file Shellminator.hpp.
|
private |
If secret mode is activated on an input, this flag will be true.
Definition at line 1163 of file Shellminator.hpp.
|
private |
If reverse search mode is active, this flag will be true.
Definition at line 1142 of file Shellminator.hpp.
|
private |
Size of the last printed banner in characters.
It's used to accelerate the redrawing process.
Definition at line 1075 of file Shellminator.hpp.
|
private |
Last time in ms when a key was pressed.
Definition at line 1170 of file Shellminator.hpp.
|
private |
Function pointer for left arrow behaviour override.
Definition at line 1084 of file Shellminator.hpp.
|
private |
If logging in is required this flag will be true.
Definition at line 973 of file Shellminator.hpp.
|
private |
Pointer to a string that holds the startup logo.
Simple text that holds the startup logo. You can create custom logos with a text to ASCII converter.
Definition at line 1034 of file Shellminator.hpp.
|
private |
Function pointer for Logout key behaviour override.
Definition at line 1105 of file Shellminator.hpp.
char Shellminator::mouseEventBuffer[SHELLMINATOR_MOUSE_PARSER_BUFFER_SIZE] |
This buffer is used to parse the mouse coordinates form the host terminals answer.
Definition at line 771 of file Shellminator.hpp.
uint8_t Shellminator::mouseEventBufferCounter = 0 |
This variable traks the next free characters location in the mouseEventBuffer.
Definition at line 774 of file Shellminator.hpp.
bool Shellminator::mute = false |
If set, the buzzer will be silent.
Definition at line 875 of file Shellminator.hpp.
|
private |
This function-pointer stores the neofetch function pointer.
This function will be called when the neofetch command receives.
Definition at line 1061 of file Shellminator.hpp.
|
private |
Function pointer for Page-Down key behaviour override.
Definition at line 1096 of file Shellminator.hpp.
|
private |
Function pointer for Page-Up key behaviour override.
Definition at line 1093 of file Shellminator.hpp.
|
private |
Stores the address of the password hash array.
Definition at line 967 of file Shellminator.hpp.
|
private |
Pointer to the hash function.
Definition at line 976 of file Shellminator.hpp.
|
private |
Stores the password hash array size.
Definition at line 970 of file Shellminator.hpp.
|
private |
On AVR there is an oprion to store the logo in the program memory.
Definition at line 1052 of file Shellminator.hpp.
|
private |
Function pointer for right arrow behaviour override.
Definition at line 1087 of file Shellminator.hpp.
|
private |
Pointer to a ShellminatorScreen object.
It will be used when Screen drawing is enabled.
Definition at line 947 of file Shellminator.hpp.
|
private |
This flag shows if a request come from the Screen object to issue a draw function call.
Definition at line 961 of file Shellminator.hpp.
|
private |
The screen is drawn within a pre-defined periods.
This variable stores the last time when a drawing event occurred.
Definition at line 952 of file Shellminator.hpp.
|
private |
The time interval between two drawings.
Definition at line 957 of file Shellminator.hpp.
|
private |
Function pointer for Search key behaviour override.
Definition at line 1108 of file Shellminator.hpp.
|
private |
Used to parse reverse search.
Definition at line 1145 of file Shellminator.hpp.
|
private |
Definition at line 954 of file Shellminator.hpp.
int Shellminator::terminalHeight = 12 |
Stores the height of the terminal in characters.
Definition at line 767 of file Shellminator.hpp.
int Shellminator::terminalWidth = 30 |
Stores the width of the terminal in characters.
Definition at line 764 of file Shellminator.hpp.
|
private |
Function pointer for up arrow behaviour override.
Definition at line 1078 of file Shellminator.hpp.
|
static |
String, that holds the version information.
Definition at line 156 of file Shellminator.hpp.