Skip to content

File wsh_shell_promptwait.h

FileList > src > wsh_shell_promptwait.h

Go to the source code of this file

One-time user input waiting mechanism for WshShell. More...

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

Classes

Type Name
struct WshShellPromptWait
Prompt-wait control structure.

Public Types

Type Name
typedef WshShell_Bool_t(* WshShellPromptWait_Handler_t
Function pointer type for prompt-wait callbacks.
typedef struct WshShellPromptWait WshShellPromptWait_t
Prompt-wait control structure.

Public Functions

Type Name
void WshShellPromptWait_Attach (WshShellPromptWait_t * pWait, WshShellPromptWait_Handler_t handler, void * pCtx)
Attach a one-time input handler.
WshShell_Bool_t WshShellPromptWait_Enter (WshShell_Char_t symbol, WshShellPromptWait_t * pWait)
User input handler for prompt-wait mode.
void WshShellPromptWait_Flush (WshShellPromptWait_t * pWait)
Flush the current prompt-wait mode.
WSH_SHELL_RET_STATE_t WshShellPromptWait_Handle (WshShellPromptWait_t * pWait, WshShell_Char_t symbol)
Handle a symbol when in prompt-wait mode.
WshShell_Bool_t WshShellPromptWait_YesNo (WshShell_Char_t symbol, WshShellPromptWait_t * pWait)

Detailed Description

This module allows the shell to temporarily override normal input handling to wait for a specific key press (e.g., <Enter>, Y/N confirmation, etc.).

Once the input is received, the registered callback is executed, and normal shell behavior resumes.

Author:

Whoosh Embedded Team

Copyright:

Copyright (c) 2025

Public Types Documentation

typedef WshShellPromptWait_Handler_t

Function pointer type for prompt-wait callbacks.

typedef WshShell_Bool_t(* WshShellPromptWait_Handler_t) (WshShell_Char_t symbol, struct WshShellPromptWait *pWait);

Parameters:

  • symbol The character that was entered by the user.
  • pCtx Optional user context passed to the handler.

typedef WshShellPromptWait_t

Prompt-wait control structure.

typedef struct WshShellPromptWait WshShellPromptWait_t;

Holds the active handler and optional context pointer. If Handler is NULL, no prompt-wait is active.


Public Functions Documentation

function WshShellPromptWait_Attach

Attach a one-time input handler.

1
2
3
4
5
void WshShellPromptWait_Attach (
    WshShellPromptWait_t * pWait,
    WshShellPromptWait_Handler_t handler,
    void * pCtx
) 

Replaces normal shell input handling with a temporary callback. The callback will receive the first character entered by the user, after which it should typically disable itself by calling WshShellPromptWait_Flush().

Parameters:

  • pWait Pointer to prompt-wait control object.
  • handler Callback function to invoke on user input.
  • pCtx Optional pointer to user context.

function WshShellPromptWait_Enter

User input handler for prompt-wait mode.

1
2
3
4
WshShell_Bool_t WshShellPromptWait_Enter (
    WshShell_Char_t symbol,
    WshShellPromptWait_t * pWait
) 

Processes a character entered by the user while waiting for specific input (e.g., Enter key, Y/N confirmation, etc.).

Parameters:

  • symbol The character entered by the user.
  • pWait Pointer to the prompt-wait control structure.

Returns:

WshShell_Bool_t * true if the input was handled and waiting can end; * false if waiting should continue.


function WshShellPromptWait_Flush

Flush the current prompt-wait mode.

1
2
3
void WshShellPromptWait_Flush (
    WshShellPromptWait_t * pWait
) 

Resets the handler to NULL so that normal shell input is processed.

Parameters:

  • pWait Pointer to prompt-wait control object.

function WshShellPromptWait_Handle

Handle a symbol when in prompt-wait mode.

1
2
3
4
WSH_SHELL_RET_STATE_t WshShellPromptWait_Handle (
    WshShellPromptWait_t * pWait,
    WshShell_Char_t symbol
) 

If a handler is set, it is called with the given symbol and context.

Parameters:

  • pWait Pointer to prompt-wait control object.
  • symbol Character entered by the user.

Returns:

WSH_SHELL_RET_STATE_ERR_PARAM if some problems with input params WSH_SHELL_RET_STATE_ERR_EMPTY if there are no handler attached WSH_SHELL_RET_STATE_ERR_BUSY if normal shell processing should continue WSH_SHELL_RET_STATE_SUCCESS if the symbol was handled by the prompt-wait mechanism


function WshShellPromptWait_YesNo

1
2
3
4
WshShell_Bool_t WshShellPromptWait_YesNo (
    WshShell_Char_t symbol,
    WshShellPromptWait_t * pWait
) 


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