Loading...
Searching...
No Matches
shell.h
Go to the documentation of this file.
#ifndef ARC_CONSOLE_SHELL_H_
#define ARC_CONSOLE_SHELL_H_
#ifdef __cplusplus
extern "C" {
#endif
//TODO: fix up this file
#include "view.h"
#include "buffer.h"
#include "arc/std/string.h"
#include "arc/std/vector.h"
#include <stdint.h>
/**
* @brief
*/
typedef struct ARC_ConsoleShell ARC_ConsoleShell;
/**
* @brief
*/
typedef void (* ARC_ConsoleShell_UpdateFn)(ARC_ConsoleShell *shell);
/**
* @brief
*/
struct ARC_ConsoleShell {
ARC_ConsoleView *view;
ARC_ConsoleBuffer *buffer;
uint32_t bufferLineIndex;
ARC_Vector *history;
uint32_t historyIndex;
ARC_ConsoleShell_UpdateFn updateFn;
ARC_String *currentLine;
ARC_String *userInput;
};
/**
* @brief creates ARC_ConsoleShell type
*
* @param shell ARC_ConsoleShell to create
* @param view ARC_ConsoleView to attach the shell to
* @param updateFn ARC_ConsoleShell_UpdateFn provided that will run the console
*/
void ARC_ConsoleShell_Create(ARC_ConsoleShell **shell, ARC_ConsoleView *view, ARC_ConsoleShell_UpdateFn updateFn);
/**
* @brief destroys ARC_ConsoleShell type
*
* @param shell ARC_ConsoleShell to destroy
*/
void ARC_ConsoleShell_Destroy(ARC_ConsoleShell *shell);
/**
* @brief updates the ARC_ConsoleShell type
*
* @param shell the ARC_ConsoleShell to update
*/
void ARC_ConsoleShell_Update(ARC_ConsoleShell *shell);
/**
* @brief renders the ARC_ConsoleShell type
*
* @param shell the ARC_ConsoleShell to render
*/
void ARC_ConsoleShell_Render(ARC_ConsoleShell *shell);
/**
* @brief adds history ARC_String to ARC_ConsoleShell
*
* @param shell the ARC_ConsoleShell to add history to
* @param string the history string to add to ARC_ConsoleShell
*/
void ARC_ConsoleShell_AddHistory(ARC_ConsoleShell *shell, ARC_String *string);
/**
* @brief gets history from ARC_ConsoleShell
*
* @note the index 0 will start from the last added history
*
* @param shell the ARC_ConsoleShell to get history from
* @param index the location to get history at
*
* @return the history as an ARC_String
*/
ARC_String *ARC_ConsoleShell_GetHistoryAt(ARC_ConsoleShell *shell, uint32_t index);
#ifdef __cplusplus
}
#endif
#endif //!ARC_CONSOLE_SHELL_H_
buffer.h
ARC_ConsoleBuffer
struct ARC_ConsoleBuffer ARC_ConsoleBuffer
Definition buffer.h:15
view.h
ARC_ConsoleView
struct ARC_ConsoleView ARC_ConsoleView
Definition view.h:18
ARC_Vector
struct ARC_Vector ARC_Vector
a dynamic array type
Definition vector.h:26
ARC_ConsoleShell_Render
void ARC_ConsoleShell_Render(ARC_ConsoleShell *shell)
renders the ARC_ConsoleShell type
ARC_ConsoleShell_Destroy
void ARC_ConsoleShell_Destroy(ARC_ConsoleShell *shell)
destroys ARC_ConsoleShell type
ARC_ConsoleShell_UpdateFn
void(* ARC_ConsoleShell_UpdateFn)(ARC_ConsoleShell *shell)
Definition shell.h:24
ARC_ConsoleShell_GetHistoryAt
ARC_String * ARC_ConsoleShell_GetHistoryAt(ARC_ConsoleShell *shell, uint32_t index)
gets history from ARC_ConsoleShell
ARC_ConsoleShell_Create
void ARC_ConsoleShell_Create(ARC_ConsoleShell **shell, ARC_ConsoleView *view, ARC_ConsoleShell_UpdateFn updateFn)
creates ARC_ConsoleShell type
ARC_ConsoleShell_AddHistory
void ARC_ConsoleShell_AddHistory(ARC_ConsoleShell *shell, ARC_String *string)
adds history ARC_String to ARC_ConsoleShell
ARC_ConsoleShell_Update
void ARC_ConsoleShell_Update(ARC_ConsoleShell *shell)
updates the ARC_ConsoleShell type
string.h
ARC_ConsoleShell
Definition shell.h:29
ARC_ConsoleShell::bufferLineIndex
uint32_t bufferLineIndex
Definition shell.h:32
ARC_ConsoleShell::view
ARC_ConsoleView * view
Definition shell.h:30
ARC_ConsoleShell::buffer
ARC_ConsoleBuffer * buffer
Definition shell.h:31
ARC_ConsoleShell::history
ARC_Vector * history
Definition shell.h:34
ARC_ConsoleShell::updateFn
ARC_ConsoleShell_UpdateFn updateFn
Definition shell.h:37
ARC_ConsoleShell::currentLine
ARC_String * currentLine
Definition shell.h:39
ARC_ConsoleShell::userInput
ARC_String * userInput
Definition shell.h:40
ARC_ConsoleShell::historyIndex
uint32_t historyIndex
Definition shell.h:35
ARC_String
substring position within a string
Definition string.h:14
vector.h
creates and outlines a dynamic array type and its functions