Fix: Data races on cursor state in OpenGL backends
[openttd-github.git] / src / console_internal.h
blob630f69607b2974f208c5114e695e764f2edc3fc0
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 */
8 /** @file console_internal.h Internally used functions for the console. */
10 #ifndef CONSOLE_INTERNAL_H
11 #define CONSOLE_INTERNAL_H
13 #include "gfx_type.h"
15 static const uint ICON_CMDLN_SIZE = 1024; ///< maximum length of a typed in command
16 static const uint ICON_MAX_STREAMSIZE = 2048; ///< maximum length of a totally expanded command
18 /** Return values of console hooks (#IConsoleHook). */
19 enum ConsoleHookResult {
20 CHR_ALLOW, ///< Allow command execution.
21 CHR_DISALLOW, ///< Disallow command execution.
22 CHR_HIDE, ///< Hide the existence of the command.
25 /**
26 * --Commands--
27 * Commands are commands, or functions. They get executed once and any
28 * effect they produce are carried out. The arguments to the commands
29 * are given to them, each input word separated by a double-quote (") is an argument
30 * If you want to handle multiple words as one, enclose them in double-quotes
31 * eg. 'say "hello sexy boy"'
33 typedef bool IConsoleCmdProc(byte argc, char *argv[]);
34 typedef ConsoleHookResult IConsoleHook(bool echo);
35 struct IConsoleCmd {
36 char *name; ///< name of command
37 IConsoleCmd *next; ///< next command in list
39 IConsoleCmdProc *proc; ///< process executed when command is typed
40 IConsoleHook *hook; ///< any special trigger action that needs executing
43 /**
44 * --Aliases--
45 * Aliases are like shortcuts for complex functions, variable assignments,
46 * etc. You can use a simple alias to rename a longer command (eg 'set' for
47 * 'setting' for example), or concatenate more commands into one
48 * (eg. 'ng' for 'load %A; unpause; debug_level 5'). Aliases can parse the arguments
49 * given to them in the command line.
50 * - "%A - %Z" substitute arguments 1 t/m 26
51 * - "%+" lists all parameters keeping them separated
52 * - "%!" also lists all parameters but presenting them to the aliased command as one argument
53 * - ";" allows for combining commands (see example 'ng')
55 struct IConsoleAlias {
56 char *name; ///< name of the alias
57 IConsoleAlias *next; ///< next alias in list
59 char *cmdline; ///< command(s) that is/are being aliased
62 /* console parser */
63 extern IConsoleCmd *_iconsole_cmds; ///< List of registered commands.
64 extern IConsoleAlias *_iconsole_aliases; ///< List of registered aliases.
66 /* console functions */
67 void IConsoleClearBuffer();
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);
75 /* console std lib (register ingame commands/aliases) */
76 void IConsoleStdLibRegister();
78 /* Supporting functions */
79 bool GetArgumentInteger(uint32 *value, const char *arg);
81 void IConsoleGUIInit();
82 void IConsoleGUIFree();
83 void IConsoleGUIPrint(TextColour colour_code, char *string);
84 char *RemoveUnderscores(char *name);
86 #endif /* CONSOLE_INTERNAL_H */