Skip to content

File wsh_shell_io.c

FileList > src > wsh_shell_io.c

Go to the source code of this file

  • #include "wsh_shell_io.h"

Public Static Attributes

Type Name
const WshShell_Char_t * WshShellIO_InsertStringTemplate = /* multi line expression */

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.

Public Static Attributes Documentation

variable WshShellIO_InsertStringTemplate

const WshShell_Char_t* WshShellIO_InsertStringTemplate;

Public Functions Documentation

function WshShellIO_ClearInterBuff

Clears the interaction buffer.

1
2
3
void WshShellIO_ClearInterBuff (
    WshShellIO_CommandLine_t * pCommandLine
) 

Resets buffer contents, cursor position, and line length.

Parameters:

  • pCommandLine Pointer to the interaction buffer.

function WshShellIO_InsertSymbol

Inserts a symbol at the current cursor position in the input buffer.

1
2
3
4
5
void WshShellIO_InsertSymbol (
    WshShellIO_CommandLine_t * pCommandLine,
    WshShell_Char_t ch,
    WshShell_Bool_t starsOrChars
) 

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:

  • pCommandLine Pointer to the interaction buffer.
  • ch The symbol to insert.
  • starsOrChars If true, prints * instead of the actual character.

function WshShellIO_PrintInterBuff

Prints the current interaction buffer to the terminal.

1
2
3
void WshShellIO_PrintInterBuff (
    WshShellIO_CommandLine_t * pCommandLine
) 

Parameters:

  • pCommandLine Pointer to the interaction buffer.

function WshShellIO_RefreshConsoleFromInterBuff

Refreshes the terminal display using the interaction buffer.

1
2
3
void WshShellIO_RefreshConsoleFromInterBuff (
    WshShellIO_CommandLine_t * pCommandLine
) 

Clears the current line and reprints buffer contents.

Parameters:

  • pCommandLine Pointer to the interaction buffer.

function WshShellIO_RemoveLeftSymbol

Removes the symbol to the left of the cursor in the input buffer.

1
2
3
void WshShellIO_RemoveLeftSymbol (
    WshShellIO_CommandLine_t * pCommandLine
) 

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:

  • pCommandLine Pointer to the interaction buffer.

function WshShellIO_WriteToInterBuff

Writes a character into the interaction buffer at the cursor position.

1
2
3
4
void WshShellIO_WriteToInterBuff (
    WshShellIO_CommandLine_t * pCommandLine,
    WshShell_Char_t symbol
) 

Increments cursor and line length accordingly.

Parameters:

  • pCommandLine Pointer to the interaction buffer.
  • symbol Character to write.


The documentation for this class was generated from the following file src/wsh_shell_io.c