OpenTTD

console_internal.h
Go to the documentation of this file.
1 /* $Id: console_internal.h 24900 2013-01-08 22:46:42Z planetmaker $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef CONSOLE_INTERNAL_H
13 #define CONSOLE_INTERNAL_H
14
15 #include "gfx_type.h"
16
17 static const uint ICON_CMDLN_SIZE = 1024;
18 static const uint ICON_MAX_STREAMSIZE = 2048;
19
21 enum ConsoleHookResult {
22 CHR_ALLOW,
23 CHR_DISALLOW,
24 CHR_HIDE,
25 };
26
35 typedef bool IConsoleCmdProc(byte argc, char *argv[]);
36 typedef ConsoleHookResult IConsoleHook(bool echo);
37 struct IConsoleCmd {
38 char *name;
39 IConsoleCmd *next;
40
41 IConsoleCmdProc *proc;
42 IConsoleHook *hook;
43 };
44
57 struct IConsoleAlias {
58 char *name;
59 IConsoleAlias *next;
60
61 char *cmdline;
62 };
63
64 /* console parser */
65 extern IConsoleCmd *_iconsole_cmds;
66 extern IConsoleAlias *_iconsole_aliases;
67
68 /* console functions */
69 void IConsoleClearBuffer();
70
71 /* Commands */
72 void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook = NULL);
73 void IConsoleAliasRegister(const char *name, const char *cmd);
74 IConsoleCmd *IConsoleCmdGet(const char *name);
75 IConsoleAlias *IConsoleAliasGet(const char *name);
76
77 /* console std lib (register ingame commands/aliases) */
78 void IConsoleStdLibRegister();
79
80 /* Supporting functions */
81 bool GetArgumentInteger(uint32 *value, const char *arg);
82
83 void IConsoleGUIInit();
84 void IConsoleGUIFree();
85 void IConsoleGUIPrint(TextColour colour_code, char *string);
86 char *RemoveUnderscores(char *name);
87
88 #endif /* CONSOLE_INTERNAL_H */
IConsoleCmd::next
IConsoleCmd * next
next command in list
Definition: console_internal.h:39
IConsoleAlias::name
char * name
name of the alias
Definition: console_internal.h:58
_iconsole_aliases
IConsoleAlias * _iconsole_aliases
List of registered aliases.
Definition: console.cpp:29
IConsoleCmd::proc
IConsoleCmdProc * proc
process executed when command is typed
Definition: console_internal.h:41
IConsoleCmd::name
char * name
name of command
Definition: console_internal.h:38
IConsoleCmdGet
IConsoleCmd * IConsoleCmdGet(const char *name)
Find the command pointed to by its string.
Definition: console.cpp:272
IConsoleCmdRegister
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook=NULL)
Register a new command to be used in the console.
Definition: console.cpp:256
CHR_HIDE
Hide the existence of the command.
Definition: console_internal.h:24
IConsoleCmdProc
bool IConsoleCmdProc(byte argc, char *argv[])
–Commands– Commands are commands, or functions.
Definition: console_internal.h:35
GetArgumentInteger
bool GetArgumentInteger(uint32 *value, const char *arg)
Change a string into its number representation.
Definition: console.cpp:187
RemoveUnderscores
char * RemoveUnderscores(char *name)
Remove underscores from a string; the string will be modified!
Definition: console.cpp:241
IConsoleAlias::next
IConsoleAlias * next
next alias in list
Definition: console_internal.h:59
ICON_MAX_STREAMSIZE
static const uint ICON_MAX_STREAMSIZE
maximum length of a totally expanded command
Definition: console_internal.h:18
CHR_ALLOW
Allow command execution.
Definition: console_internal.h:22
IConsoleAliasRegister
void IConsoleAliasRegister(const char *name, const char *cmd)
Register a an alias for an already existing command in the console.
Definition: console.cpp:287
ConsoleHookResult
ConsoleHookResult
Return values of console hooks (#IConsoleHook).
Definition: console_internal.h:21
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:247
_iconsole_cmds
IConsoleCmd * _iconsole_cmds
List of registered commands.
Definition: console.cpp:28
IConsoleAlias
–Aliases– Aliases are like shortcuts for complex functions, variable assignments, etc.
Definition: console_internal.h:57
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:503
IConsoleAlias::cmdline
char * cmdline
command(s) that is/are being aliased
Definition: console_internal.h:61
IConsoleCmd::hook
IConsoleHook * hook
any special trigger action that needs executing
Definition: console_internal.h:42
ICON_CMDLN_SIZE
static const uint ICON_CMDLN_SIZE
maximum length of a typed in command
Definition: console_internal.h:17
CHR_DISALLOW
Disallow command execution.
Definition: console_internal.h:23
IConsoleCmd
Definition: console_internal.h:37
IConsoleAliasGet
IConsoleAlias * IConsoleAliasGet(const char *name)
Find the alias pointed to by its string.
Definition: console.cpp:310
gfx_type.h
Types related to the graphics and/or input devices.