OpenTTD Source: src/console_internal.h Source File

OpenTTD Source 1.11.0-RC1

console_internal.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef CONSOLE_INTERNAL_H
11 #define CONSOLE_INTERNAL_H
12
13 #include "gfx_type.h"
14
15 static const uint ICON_CMDLN_SIZE = 1024;
16 static const uint ICON_MAX_STREAMSIZE = 2048;
17
19 enum ConsoleHookResult {
20 CHR_ALLOW,
21 CHR_DISALLOW,
22 CHR_HIDE,
23 };
24
33 typedef bool IConsoleCmdProc(byte argc, char *argv[]);
34 typedef ConsoleHookResult IConsoleHook(bool echo);
35 struct IConsoleCmd {
36 char *name;
37 IConsoleCmd *next;
38
39 IConsoleCmdProc *proc;
40 IConsoleHook *hook;
41 };
42
55 struct IConsoleAlias {
56 char *name;
57 IConsoleAlias *next;
58
59 char *cmdline;
60 };
61
62 /* console parser */
63 extern IConsoleCmd *_iconsole_cmds;
64 extern IConsoleAlias *_iconsole_aliases;
65
66 /* console functions */
67 void IConsoleClearBuffer();
68
69 /* Commands */
70 void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook = nullptr);
71 void IConsoleAliasRegister(const char *name, const char *cmd);
72 IConsoleCmd *IConsoleCmdGet(const char *name);
73 IConsoleAlias *IConsoleAliasGet(const char *name);
74
75 /* console std lib (register ingame commands/aliases) */
76 void IConsoleStdLibRegister();
77
78 /* Supporting functions */
79 bool GetArgumentInteger(uint32 *value, const char *arg);
80
81 void IConsoleGUIInit();
82 void IConsoleGUIFree();
83 void IConsoleGUIPrint(TextColour colour_code, char *string);
84 char *RemoveUnderscores(char *name);
85
86 #endif /* CONSOLE_INTERNAL_H */
_iconsole_cmds
IConsoleCmd * _iconsole_cmds
List of registered commands.
Definition: console.cpp:27
IConsoleCmd::proc
IConsoleCmdProc * proc
process executed when command is typed
Definition: console_internal.h:39
IConsoleCmdGet
IConsoleCmd * IConsoleCmdGet(const char *name)
Find the command pointed to by its string.
Definition: console.cpp:265
IConsoleAliasGet
IConsoleAlias * IConsoleAliasGet(const char *name)
Find the alias pointed to by its string.
Definition: console.cpp:303
ICON_CMDLN_SIZE
static const uint ICON_CMDLN_SIZE
maximum length of a typed in command
Definition: console_internal.h:15
GetArgumentInteger
bool GetArgumentInteger(uint32 *value, const char *arg)
Change a string into its number representation.
Definition: console.cpp:180
IConsoleAlias::cmdline
char * cmdline
command(s) that is/are being aliased
Definition: console_internal.h:59
IConsoleGUIPrint
void IConsoleGUIPrint(TextColour colour_code, char *string)
Handle the printing of text entered into the console or redirected there by any other means.
Definition: console_gui.cpp:511
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:250
IConsoleCmd::hook
IConsoleHook * hook
any special trigger action that needs executing
Definition: console_internal.h:40
ICON_MAX_STREAMSIZE
static const uint ICON_MAX_STREAMSIZE
maximum length of a totally expanded command
Definition: console_internal.h:16
IConsoleCmd
Definition: console_internal.h:35
CHR_ALLOW
@ CHR_ALLOW
Allow command execution.
Definition: console_internal.h:20
IConsoleAliasRegister
void IConsoleAliasRegister(const char *name, const char *cmd)
Register a an alias for an already existing command in the console.
Definition: console.cpp:280
IConsoleAlias::name
char * name
name of the alias
Definition: console_internal.h:56
IConsoleAlias::next
IConsoleAlias * next
next alias in list
Definition: console_internal.h:57
IConsoleAlias
–Aliases– Aliases are like shortcuts for complex functions, variable assignments, etc.
Definition: console_internal.h:55
IConsoleCmd::name
char * name
name of command
Definition: console_internal.h:36
IConsoleCmd::next
IConsoleCmd * next
next command in list
Definition: console_internal.h:37
_iconsole_aliases
IConsoleAlias * _iconsole_aliases
List of registered aliases.
Definition: console.cpp:28
IConsoleCmdRegister
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook=nullptr)
Register a new command to be used in the console.
Definition: console.cpp:249
CHR_DISALLOW
@ CHR_DISALLOW
Disallow command execution.
Definition: console_internal.h:21
CHR_HIDE
@ CHR_HIDE
Hide the existence of the command.
Definition: console_internal.h:22
IConsoleCmdProc
bool IConsoleCmdProc(byte argc, char *argv[])
–Commands– Commands are commands, or functions.
Definition: console_internal.h:33
RemoveUnderscores
char * RemoveUnderscores(char *name)
Remove underscores from a string; the string will be modified!
Definition: console.cpp:234
gfx_type.h
ConsoleHookResult
ConsoleHookResult
Return values of console hooks (#IConsoleHook).
Definition: console_internal.h:19