Skip to content

RetroShellAPI ​

cpp
#include <VirtualC64.h>
cpp
class RetroShellAPI

Defined in VirtualC64.h:1426

RetroShell Public API

Public Methods ​

ReturnNameDescription
const RetroShellInfo &getInfo constReturns the component's current state.
const RetroShellInfo &getCachedInfo constReturns the most recent state snapshot recorded by the emulator thread (see getInfo()).
stringtext constReturns a copy of the text buffer. The text buffer contains the complete contents of the console. It will be expanded when new output is generated. When the buffer grows too large, old contents is cropped.
voidpressInforms RetroShell that a key has been typed.
voidpressInforms RetroShell that a key has been typed.
voidpressInforms RetroShell that multiple keys have been typed.
voidsetStreamAssign an additional output stream. In addition to writing the RetroShell output into the text buffer, RetroShell will write the output into the provides stream.
voidexecScriptAsyncExecutes a script. The script is executed asynchronously. However, RetroShell will send messages back to the GUI thread to inform about the execution state. After the last pending command has been executed, Msg::RSH_DONE is sent. If a command fails, the remaining commands are dropped and Msg::RSH_ERROR is sent instead. A 'wait' command postpones the rest of the script and sends Msg::RSH_WAIT.
voidexecScriptAsyncExecutes a script that is read from a string stream.
voidexecScriptAsyncExecutes a script that is read from a file stream.
voidexecScriptAsyncExecutes a script that is given as a string.

getInfo ​

const

cpp
const RetroShellInfo & getInfo() const

Defined in VirtualC64.h:1446

Returns the component's current state.

getInfo() reads the live state on the calling thread. The result is only consistent if the emulator is paused or suspended. getCachedInfo() returns the snapshot the emulator thread has recorded most recently, which is the one to use while the emulator runs. Both return references that can be overwritten by a later call or by the emulator thread, so copy the data if you need to keep it.


getCachedInfo ​

const

cpp
const RetroShellInfo & getCachedInfo() const

Defined in VirtualC64.h:1448

Returns the most recent state snapshot recorded by the emulator thread (see getInfo()).


text ​

const

cpp
string text() const

Defined in VirtualC64.h:1455

Returns a copy of the text buffer. The text buffer contains the complete contents of the console. It will be expanded when new output is generated. When the buffer grows too large, old contents is cropped.


press ​

cpp
void press(RSKey key, bool shift = false)

Defined in VirtualC64.h:1474

Informs RetroShell that a key has been typed.

Parameters ​

ParameterTypeDescription
keyRSKeyThe pressed key
shiftboolStatus of the shift key

press ​

cpp
void press(char c)

Defined in VirtualC64.h:1479

Informs RetroShell that a key has been typed.

Parameters ​

ParameterTypeDescription
ccharThe pressed key

press ​

cpp
void press(const string & s)

Defined in VirtualC64.h:1484

Informs RetroShell that multiple keys have been typed.

Parameters ​

ParameterTypeDescription
sconst string &The typed text

setStream ​

cpp
void setStream(std::ostream & os)

Defined in VirtualC64.h:1494

Assign an additional output stream. In addition to writing the RetroShell output into the text buffer, RetroShell will write the output into the provides stream.


execScriptAsync ​

cpp
void execScriptAsync(const std::filesystem::path & path)

Defined in VirtualC64.h:1510

Executes a script. The script is executed asynchronously. However, RetroShell will send messages back to the GUI thread to inform about the execution state. After the last pending command has been executed, Msg::RSH_DONE is sent. If a command fails, the remaining commands are dropped and Msg::RSH_ERROR is sent instead. A 'wait' command postpones the rest of the script and sends Msg::RSH_WAIT.

Exceptions ​

ExceptionDescription
Errorif the file cannot be opened.

execScriptAsync ​

cpp
void execScriptAsync(std::stringstream & ss)

Defined in VirtualC64.h:1512

Executes a script that is read from a string stream.


execScriptAsync ​

cpp
void execScriptAsync(const std::ifstream & fs)

Defined in VirtualC64.h:1514

Executes a script that is read from a file stream.


execScriptAsync ​

cpp
void execScriptAsync(const string & contents)

Defined in VirtualC64.h:1516

Executes a script that is given as a string.