OpenTTD Source 20241224-master-gf74b0cf984
console_internal.h File Reference

Internally used functions for the console. More...

#include "gfx_type.h"

Go to the source code of this file.

Data Structures

struct  IConsoleCmd
 
struct  IConsoleAlias
 –Aliases– Aliases are like shortcuts for complex functions, variable assignments, etc. More...
 
struct  IConsole
 

Typedefs

typedef bool IConsoleCmdProc(uint8_t argc, char *argv[])
 –Commands– Commands are commands, or functions.
 
typedef ConsoleHookResult IConsoleHook(bool echo)
 

Enumerations

enum  ConsoleHookResult { CHR_ALLOW , CHR_DISALLOW , CHR_HIDE }
 Return values of console hooks (IConsoleHook). More...
 

Functions

void IConsoleClearBuffer ()
 
void IConsoleStdLibRegister ()
 
bool GetArgumentInteger (uint32_t *value, const char *arg)
 Change a string into its number representation.
 
void IConsoleGUIInit ()
 
void IConsoleGUIFree ()
 
void IConsoleGUIPrint (TextColour colour_code, const std::string &string)
 Handle the printing of text entered into the console or redirected there by any other means.
 

Variables

static const uint ICON_CMDLN_SIZE = 1024
 maximum length of a typed in command
 
static const uint ICON_MAX_STREAMSIZE = 2048
 maximum length of a totally expanded command
 

Detailed Description

Internally used functions for the console.

Definition in file console_internal.h.

Typedef Documentation

◆ IConsoleCmdProc

typedef bool IConsoleCmdProc(uint8_t argc, char *argv[])

–Commands– Commands are commands, or functions.

They get executed once and any effect they produce are carried out. The arguments to the commands are given to them, each input word separated by a double-quote (") is an argument If you want to handle multiple words as one, enclose them in double-quotes eg. 'say "hello everybody"'

Definition at line 33 of file console_internal.h.

◆ IConsoleHook

typedef ConsoleHookResult IConsoleHook(bool echo)

Definition at line 34 of file console_internal.h.

Enumeration Type Documentation

◆ ConsoleHookResult

Return values of console hooks (IConsoleHook).

Enumerator
CHR_ALLOW 

Allow command execution.

CHR_DISALLOW 

Disallow command execution.

CHR_HIDE 

Hide the existence of the command.

Definition at line 19 of file console_internal.h.

Function Documentation

◆ GetArgumentInteger()

bool GetArgumentInteger ( uint32_t *  value,
const char *  arg 
)

Change a string into its number representation.

Supports decimal and hexadecimal numbers as well as 'on'/'off' 'true'/'false'

Parameters
*valuethe variable a successful conversion will be put in
*argthe string to be converted
Returns
Return true on success or false on failure

Definition at line 127 of file console.cpp.

Referenced by DEF_CONSOLE_CMD(), and DEF_CONSOLE_CMD().

◆ IConsoleClearBuffer()

void IConsoleClearBuffer ( )

Definition at line 400 of file console_gui.cpp.

◆ IConsoleGUIFree()

void IConsoleGUIFree ( )

Definition at line 405 of file console_gui.cpp.

◆ IConsoleGUIInit()

void IConsoleGUIInit ( )

Definition at line 386 of file console_gui.cpp.

◆ IConsoleGUIPrint()

void IConsoleGUIPrint ( TextColour  colour_code,
const std::string &  str 
)

Handle the printing of text entered into the console or redirected there by any other means.

Text can be redirected to other clients in a network game as well as to a logfile. If the network server is a dedicated server, all activities are also logged. All lines to print are added to a temporary buffer which can be used as a history to print them onscreen

Parameters
colour_codethe colour of the command. Red in case of errors, etc.
strthe message entered or output on the console (notice, error, etc.)

Definition at line 501 of file console_gui.cpp.

References _iconsole_buffer, SetWindowDirty(), and WC_CONSOLE.

Referenced by IConsolePrint().

◆ IConsoleStdLibRegister()

void IConsoleStdLibRegister ( )

Definition at line 2773 of file console_cmds.cpp.

Variable Documentation

◆ ICON_CMDLN_SIZE

const uint ICON_CMDLN_SIZE = 1024
static

maximum length of a typed in command

Definition at line 15 of file console_internal.h.

◆ ICON_MAX_STREAMSIZE

const uint ICON_MAX_STREAMSIZE = 2048
static

maximum length of a totally expanded command

Definition at line 16 of file console_internal.h.

Referenced by IConsoleAliasExec(), and IConsoleCmdExec().