File wsh_shell_io.h
FileList > src > wsh_shell_io.h
Go to the source code of this file
Terminal input/output definitions and interaction buffer API for WshShell. More...
#include "wsh_shell_cfg.h"#include "wsh_shell_str.h"
Classes
| Type | Name |
|---|---|
| struct | WshShellIO_CommandLine_t Structure representing the current user input interaction state. |
Public Types
| Type | Name |
|---|---|
| enum | WSH_SHELL_PRINT_t Shell print levels. |
Public Functions
| Type | Name |
|---|---|
| void | WshShellIO_ClearInterBuff (WshShellIO_CommandLine_t * pCommandLine) Clears the interaction buffer. |
| void | WshShellIO_InsertSymbol (WshShellIO_CommandLine_t * pCommandLine, WshShell_Char_t ch, WshShell_Bool_t starsOrChars) Inserts a symbol at the current cursor position in the input buffer. |
| void | WshShellIO_PrintInterBuff (WshShellIO_CommandLine_t * pCommandLine) Prints the current interaction buffer to the terminal. |
| void | WshShellIO_RefreshConsoleFromInterBuff (WshShellIO_CommandLine_t * pCommandLine) Refreshes the terminal display using the interaction buffer. |
| void | WshShellIO_RemoveLeftSymbol (WshShellIO_CommandLine_t * pCommandLine) Removes the symbol to the left of the cursor in the input buffer. |
| void | WshShellIO_WriteToInterBuff (WshShellIO_CommandLine_t * pCommandLine, WshShell_Char_t symbol) Writes a character into the interaction buffer at the cursor position. |
Macros
| Type | Name |
|---|---|
| define | WSH_SHELL_CHAR_CR '\r' |
| define | WSH_SHELL_CHAR_LF '\n' |
| define | WSH_SHELL_COLOR_BLACK [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[30m" |
| define | WSH_SHELL_COLOR_BLUE [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[34m" |
| define | WSH_SHELL_COLOR_CYAN [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[36m" |
| define | WSH_SHELL_COLOR_ERROR WSH\_SHELL\_COLOR\_RED |
| define | WSH_SHELL_COLOR_GREEN [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[32m" |
| define | WSH_SHELL_COLOR_INFO WSH\_SHELL\_COLOR\_WHITE |
| define | WSH_SHELL_COLOR_OK WSH\_SHELL\_COLOR\_GREEN |
| define | WSH_SHELL_COLOR_PURPLE [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[35m" |
| define | WSH_SHELL_COLOR_RED [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[31m" |
| define | WSH_SHELL_COLOR_SYS WSH\_SHELL\_COLOR\_CYAN |
| define | WSH_SHELL_COLOR_WARN WSH\_SHELL\_COLOR\_YELLOW |
| define | WSH_SHELL_COLOR_WHITE [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[37m" |
| define | WSH_SHELL_COLOR_YELLOW [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[33m" |
| define | WSH_SHELL_ECS_CLR_SCREEN [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[1;1H" WSH\_SHELL\_ESC\_SEQ\_START\_STR "[2J" |
| define | WSH_SHELL_ECS_RESET_MODE_BOLD [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[22m" |
| define | WSH_SHELL_ECS_RESET_MODE_ITALIC [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[23m" |
| define | WSH_SHELL_ECS_SET_MODE_BOLD [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[1m" |
| define | WSH_SHELL_ECS_SET_MODE_ITALIC [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[3m" |
| define | WSH_SHELL_END_LINE "\r\n" |
| define | WSH_SHELL_ESC_ARROW_DOWN [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[B" |
| define | WSH_SHELL_ESC_ARROW_LEFT [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[D" |
| define | WSH_SHELL_ESC_ARROW_RIGHT [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[C" |
| define | WSH_SHELL_ESC_ARROW_UP [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[A" |
| define | WSH_SHELL_ESC_CLEAR_RIGHT_FROM_CURS [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[0K" |
| define | WSH_SHELL_ESC_RESET_STYLE [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "[0m" |
| define | WSH_SHELL_ESC_RESTORE_CURSOR [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "8" |
| define | WSH_SHELL_ESC_SAVE_CURSOR [**WSH\_SHELL\_ESC\_SEQ\_START\_STR**](wsh__shell__io_8h.md#define-wsh_shell_esc_seq_start_str) "7" |
| define | WSH_SHELL_ESC_SEQ_START_CHAR '\033' |
| define | WSH_SHELL_ESC_SEQ_START_STR "\033" |
| define | WSH_SHELL_PRINT_ERR (_f_, ...) |
| define | WSH_SHELL_PRINT_INFO (_f_, ...) |
| define | WSH_SHELL_PRINT_LEVEL (_level_, _f_, ...) /* multi line expression */Generic macro for printing messages with a specific level. |
| define | WSH_SHELL_PRINT_SYS (_f_, ...) |
| define | WSH_SHELL_PRINT_WARN (_f_, ...) |
| define | WSH_SHELL_SYM_BACKSPACE '\b' |
| define | WSH_SHELL_SYM_DELETE 0x7f |
| define | WSH_SHELL_SYM_EXIT 0x04 |
| define | WSH_SHELL_SYM_SOUND 0x07 |
| define | WSH_SHELL_SYM_TAB '\t' |
Detailed Description
This header provides: * Common control characters (e.g. backspace, delete, tab). * ANSI escape sequences for terminal control (cursor movement, screen clearing, text style). * Colorized print macros for various log levels (system/info/warning/error). * PS1 and newline formatting helpers. * I/O buffer structure and utility functions for handling user input.
These utilities support consistent terminal behavior and shell interaction flow.
Author:
Whoosh Embedded Team
Copyright:
Copyright (c) 2024
Public Types Documentation
enum WSH_SHELL_PRINT_t
Shell print levels.
Defines the available message levels for shell output. Used to select which type of message (system, info, warning, error, ...) should be printed when calling WSH_SHELL_PRINT_LEVEL().
Public Functions Documentation
function WshShellIO_ClearInterBuff
Clears the interaction buffer.
Resets buffer contents, cursor position, and line length.
Parameters:
pCommandLinePointer to the interaction buffer.
function WshShellIO_InsertSymbol
Inserts a symbol at the current cursor position in the input buffer.
This function handles character insertion into the interaction buffer:
* If the cursor is in the middle of the line (not at the end), it shifts existing characters to the right to make space for the new symbol.
* The character is then written into the buffer at the cursor position using WshShellIO_WriteToInterBuff.
* The terminal is updated to reflect the insertion, printing either the actual symbol or an asterisk (*) if starsOrChars is true (used for password masking).
Cursor position and buffer length are updated internally. Asserts that pCommandLine is valid and that CursorPos >= 1 before printing.
Parameters:
pCommandLinePointer to the interaction buffer.chThe symbol to insert.starsOrCharsIf true, prints*instead of the actual character.
function WshShellIO_PrintInterBuff
Prints the current interaction buffer to the terminal.
Parameters:
pCommandLinePointer to the interaction buffer.
function WshShellIO_RefreshConsoleFromInterBuff
Refreshes the terminal display using the interaction buffer.
Clears the current line and reprints buffer contents.
Parameters:
pCommandLinePointer to the interaction buffer.
function WshShellIO_RemoveLeftSymbol
Removes the symbol to the left of the cursor in the input buffer.
This function handles backspace-like behavior: * If the cursor is not at the beginning of the line, it removes the symbol to the left of the cursor, shifts the rest of the line left, and updates both the buffer and terminal display. * If the cursor is beyond the line length (unexpected), only moves the cursor one position left.
Also updates the internal buffer length and uses ANSI escape sequences to visually update the terminal.
Parameters:
pCommandLinePointer to the interaction buffer.
function WshShellIO_WriteToInterBuff
Writes a character into the interaction buffer at the cursor position.
Increments cursor and line length accordingly.
Parameters:
pCommandLinePointer to the interaction buffer.symbolCharacter to write.
Macro Definition Documentation
define WSH_SHELL_CHAR_CR
Carriage return
define WSH_SHELL_CHAR_LF
Line feed
define WSH_SHELL_COLOR_BLACK
define WSH_SHELL_COLOR_BLUE
define WSH_SHELL_COLOR_CYAN
define WSH_SHELL_COLOR_ERROR
define WSH_SHELL_COLOR_GREEN
define WSH_SHELL_COLOR_INFO
define WSH_SHELL_COLOR_OK
define WSH_SHELL_COLOR_PURPLE
define WSH_SHELL_COLOR_RED
define WSH_SHELL_COLOR_SYS
define WSH_SHELL_COLOR_WARN
define WSH_SHELL_COLOR_WHITE
define WSH_SHELL_COLOR_YELLOW
define WSH_SHELL_ECS_CLR_SCREEN
define WSH_SHELL_ECS_RESET_MODE_BOLD
define WSH_SHELL_ECS_RESET_MODE_ITALIC
define WSH_SHELL_ECS_SET_MODE_BOLD
define WSH_SHELL_ECS_SET_MODE_ITALIC
define WSH_SHELL_END_LINE
End-of-line string
define WSH_SHELL_ESC_ARROW_DOWN
define WSH_SHELL_ESC_ARROW_LEFT
define WSH_SHELL_ESC_ARROW_RIGHT
define WSH_SHELL_ESC_ARROW_UP
define WSH_SHELL_ESC_CLEAR_RIGHT_FROM_CURS
define WSH_SHELL_ESC_RESET_STYLE
define WSH_SHELL_ESC_RESTORE_CURSOR
define WSH_SHELL_ESC_SAVE_CURSOR
define WSH_SHELL_ESC_SEQ_START_CHAR
Escape character (0x1B)
define WSH_SHELL_ESC_SEQ_START_STR
Escape character as string
define WSH_SHELL_PRINT_ERR
define WSH_SHELL_PRINT_INFO
define WSH_SHELL_PRINT_LEVEL
Generic macro for printing messages with a specific level.
Each specific print macro (e.g. WSH_SHELL_PRINT_ERR) can be disabled at compile time using corresponding flags (WSH_SHELL_PRINT_*_ENABLE).
Parameters:
<em>level</em>Print level (one of WSH_SHELL_PRINT_t).<em>f</em>Format string (compatible withprintf)....Additional arguments for the format string.
define WSH_SHELL_PRINT_SYS
define WSH_SHELL_PRINT_WARN
define WSH_SHELL_SYM_BACKSPACE
Backspace character
define WSH_SHELL_SYM_DELETE
Delete (DEL) character
define WSH_SHELL_SYM_EXIT
Ctrl + D (EOF signal)
define WSH_SHELL_SYM_SOUND
Bell character (alert)
define WSH_SHELL_SYM_TAB
Tab character
The documentation for this class was generated from the following file src/wsh_shell_io.h