Skip to content

File wsh_shell_interact.h

FileList > src > wsh_shell_interact.h

Go to the source code of this file

Interactive command registration and line editing utilities for WshShell. More...

  • #include "wsh_shell_cfg.h"
  • #include "wsh_shell_io.h"

Classes

Type Name
struct WshShell_Interact_t
Interactive command registration structure.

Public Types

Type Name
typedef void(* WshShellInteractive_CmdHandler_t
Function pointer type for an interactive shell command.

Public Functions

Type Name
void WshShellInteract_AppendLineBreak (WshShellIO_CommandLine_t * pCommandLine)
Appends a CRLF ( \r\n ) sequence to the interaction buffer.
void WshShellInteract_Attach (WshShell_Interact_t * pInteract, const WshShell_Char_t * pcName, WshShellInteractive_CmdHandler_t handler)
Registers an interactive command.
void WshShellInteract_Flush (WshShell_Interact_t * pInteract)
Clears the contents of an interactive command slot.

Detailed Description

This module provides an interface for attaching interactive commands and for modifying the user input buffer, such as appending carriage return and line feed sequences (\r\n) at the end of the command line.

It is used internally by the shell to register interactive commands and manage the formatting of user-entered command lines.

Author:

Whoosh Embedded Team

Copyright:

Copyright (c) 2024

Public Types Documentation

typedef WshShellInteractive_CmdHandler_t

Function pointer type for an interactive shell command.

typedef void(* WshShellInteractive_CmdHandler_t) (WshShellIO_CommandLine_t *pCommandLine);

This type defines the prototype for interactive command callbacks, which are invoked with a pointer to the current command line buffer.


Public Functions Documentation

function WshShellInteract_AppendLineBreak

Appends a CRLF ( \r\n ) sequence to the interaction buffer.

1
2
3
void WshShellInteract_AppendLineBreak (
    WshShellIO_CommandLine_t * pCommandLine
) 

Adds a carriage return and line feed to the end of the current input buffer, if there is enough space. This is typically used to terminate user input lines.

If the buffer is too full to append both characters, an error is printed.

Parameters:

  • pCommandLine Pointer to the interaction buffer (command line).

function WshShellInteract_Attach

Registers an interactive command.

1
2
3
4
5
void WshShellInteract_Attach (
    WshShell_Interact_t * pInteract,
    const WshShell_Char_t * pcName,
    WshShellInteractive_CmdHandler_t handler
) 

Attaches a named command and its execution function to the given interact structure. The command name is truncated if it exceeds the internal buffer size.

Parameters:

  • pInteract Pointer to the interact object to initialize.
  • pcName Null-terminated name of the interactive command.
  • handler Function pointer to be called when the command is executed.

function WshShellInteract_Flush

Clears the contents of an interactive command slot.

1
2
3
void WshShellInteract_Flush (
    WshShell_Interact_t * pInteract
) 

Resets the execution function pointer to NULL and clears the command name buffer. This effectively "removes" the interactive command from the shell registry.

Parameters:

  • pInteract Pointer to the interact structure to flush.


The documentation for this class was generated from the following file src/wsh_shell_interact.h