8 /* maximum length of a typed in command */ |
8 /* maximum length of a typed in command */ |
9 #define ICON_CMDLN_SIZE 255 |
9 #define ICON_CMDLN_SIZE 255 |
10 /* maximum length of a totally expanded command */ |
10 /* maximum length of a totally expanded command */ |
11 #define ICON_MAX_STREAMSIZE 1024 |
11 #define ICON_MAX_STREAMSIZE 1024 |
12 |
12 |
13 typedef enum IConsoleVarTypes { |
13 enum IConsoleVarTypes { |
14 ICONSOLE_VAR_BOOLEAN, |
14 ICONSOLE_VAR_BOOLEAN, |
15 ICONSOLE_VAR_BYTE, |
15 ICONSOLE_VAR_BYTE, |
16 ICONSOLE_VAR_UINT16, |
16 ICONSOLE_VAR_UINT16, |
17 ICONSOLE_VAR_UINT32, |
17 ICONSOLE_VAR_UINT32, |
18 ICONSOLE_VAR_INT16, |
18 ICONSOLE_VAR_INT16, |
19 ICONSOLE_VAR_INT32, |
19 ICONSOLE_VAR_INT32, |
20 ICONSOLE_VAR_STRING |
20 ICONSOLE_VAR_STRING |
21 } IConsoleVarTypes; |
21 }; |
22 |
22 |
23 typedef enum IConsoleModes { |
23 enum IConsoleModes { |
24 ICONSOLE_FULL, |
24 ICONSOLE_FULL, |
25 ICONSOLE_OPENED, |
25 ICONSOLE_OPENED, |
26 ICONSOLE_CLOSED |
26 ICONSOLE_CLOSED |
27 } IConsoleModes; |
27 }; |
28 |
28 |
29 typedef enum IConsoleHookTypes { |
29 enum IConsoleHookTypes { |
30 ICONSOLE_HOOK_ACCESS, |
30 ICONSOLE_HOOK_ACCESS, |
31 ICONSOLE_HOOK_PRE_ACTION, |
31 ICONSOLE_HOOK_PRE_ACTION, |
32 ICONSOLE_HOOK_POST_ACTION |
32 ICONSOLE_HOOK_POST_ACTION |
33 } IConsoleHookTypes; |
33 }; |
34 |
34 |
35 /** --Hooks-- |
35 /** --Hooks-- |
36 * Hooks are certain triggers get get accessed/executed on either |
36 * Hooks are certain triggers get get accessed/executed on either |
37 * access, before execution/change or after execution/change. This allows |
37 * access, before execution/change or after execution/change. This allows |
38 * for general flow of permissions or special action needed in some cases |
38 * for general flow of permissions or special action needed in some cases |
39 */ |
39 */ |
40 typedef bool IConsoleHook(void); |
40 typedef bool IConsoleHook(); |
41 typedef struct IConsoleHooks{ |
41 struct IConsoleHooks{ |
42 IConsoleHook *access; ///< trigger when accessing the variable/command |
42 IConsoleHook *access; ///< trigger when accessing the variable/command |
43 IConsoleHook *pre; ///< trigger before the variable/command is changed/executed |
43 IConsoleHook *pre; ///< trigger before the variable/command is changed/executed |
44 IConsoleHook *post; ///< trigger after the variable/command is changed/executed |
44 IConsoleHook *post; ///< trigger after the variable/command is changed/executed |
45 } IConsoleHooks; |
45 }; |
46 |
46 |
47 /** --Commands-- |
47 /** --Commands-- |
48 * Commands are commands, or functions. They get executed once and any |
48 * Commands are commands, or functions. They get executed once and any |
49 * effect they produce are carried out. The arguments to the commands |
49 * effect they produce are carried out. The arguments to the commands |
50 * are given to them, each input word seperated by a double-quote (") is an argument |
50 * are given to them, each input word seperated by a double-quote (") is an argument |
51 * If you want to handle multiple words as one, enclose them in double-quotes |
51 * If you want to handle multiple words as one, enclose them in double-quotes |
52 * eg. 'say "hello sexy boy"' |
52 * eg. 'say "hello sexy boy"' |
53 */ |
53 */ |
54 typedef bool (IConsoleCmdProc)(byte argc, char *argv[]); |
54 typedef bool (IConsoleCmdProc)(byte argc, char *argv[]); |
55 |
55 |
56 struct IConsoleCmd; |
56 struct IConsoleCmd { |
57 typedef struct IConsoleCmd { |
|
58 char *name; ///< name of command |
57 char *name; ///< name of command |
59 struct IConsoleCmd *next; ///< next command in list |
58 IConsoleCmd *next; ///< next command in list |
60 |
59 |
61 IConsoleCmdProc *proc; ///< process executed when command is typed |
60 IConsoleCmdProc *proc; ///< process executed when command is typed |
62 IConsoleHooks hook; ///< any special trigger action that needs executing |
61 IConsoleHooks hook; ///< any special trigger action that needs executing |
63 } IConsoleCmd; |
62 }; |
64 |
63 |
65 /** --Variables-- |
64 /** --Variables-- |
66 * Variables are pointers to real ingame variables which allow for |
65 * Variables are pointers to real ingame variables which allow for |
67 * changing while ingame. After changing they keep their new value |
66 * changing while ingame. After changing they keep their new value |
68 * and can be used for debugging, gameplay, etc. It accepts: |
67 * and can be used for debugging, gameplay, etc. It accepts: |
69 * - no arguments; just print out current value |
68 * - no arguments; just print out current value |
70 * - '= <new value>' to assign a new value to the variable |
69 * - '= <new value>' to assign a new value to the variable |
71 * - '++' to increase value by one |
70 * - '++' to increase value by one |
72 * - '--' to decrease value by one |
71 * - '--' to decrease value by one |
73 */ |
72 */ |
74 struct IConsoleVar; |
73 struct IConsoleVar { |
75 typedef struct IConsoleVar { |
|
76 char *name; ///< name of the variable |
74 char *name; ///< name of the variable |
77 struct IConsoleVar *next; ///< next variable in list |
75 IConsoleVar *next; ///< next variable in list |
78 |
76 |
79 void *addr; ///< the address where the variable is pointing at |
77 void *addr; ///< the address where the variable is pointing at |
80 uint32 size; ///< size of the variable, used for strings |
78 uint32 size; ///< size of the variable, used for strings |
81 char *help; ///< the optional help string shown when requesting information |
79 char *help; ///< the optional help string shown when requesting information |
82 IConsoleVarTypes type; ///< type of variable (for correct assignment/output) |
80 IConsoleVarTypes type; ///< type of variable (for correct assignment/output) |
83 IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that |
81 IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that |
84 IConsoleHooks hook; ///< any special trigger action that needs executing |
82 IConsoleHooks hook; ///< any special trigger action that needs executing |
85 } IConsoleVar; |
83 }; |
86 |
84 |
87 /** --Aliases-- |
85 /** --Aliases-- |
88 * Aliases are like shortcuts for complex functions, variable assignments, |
86 * Aliases are like shortcuts for complex functions, variable assignments, |
89 * etc. You can use a simple alias to rename a longer command (eg 'lv' for |
87 * etc. You can use a simple alias to rename a longer command (eg 'lv' for |
90 * 'list_vars' for example), or concatenate more commands into one |
88 * 'list_vars' for example), or concatenate more commands into one |
93 * - "%A - %Z" substitute arguments 1 t/m 26 |
91 * - "%A - %Z" substitute arguments 1 t/m 26 |
94 * - "%+" lists all parameters keeping them seperated |
92 * - "%+" lists all parameters keeping them seperated |
95 * - "%!" also lists all parameters but presenting them to the aliased command as one argument |
93 * - "%!" also lists all parameters but presenting them to the aliased command as one argument |
96 * - ";" allows for combining commands (see example 'ng') |
94 * - ";" allows for combining commands (see example 'ng') |
97 */ |
95 */ |
98 struct IConsoleAlias; |
96 struct IConsoleAlias { |
99 typedef struct IConsoleAlias { |
|
100 char *name; ///< name of the alias |
97 char *name; ///< name of the alias |
101 struct IConsoleAlias *next; ///< next alias in list |
98 IConsoleAlias *next; ///< next alias in list |
102 |
99 |
103 char *cmdline; ///< command(s) that is/are being aliased |
100 char *cmdline; ///< command(s) that is/are being aliased |
104 } IConsoleAlias; |
101 }; |
105 |
102 |
106 /* console parser */ |
103 /* console parser */ |
107 VARDEF IConsoleCmd *_iconsole_cmds; ///< list of registred commands |
104 VARDEF IConsoleCmd *_iconsole_cmds; ///< list of registred commands |
108 VARDEF IConsoleVar *_iconsole_vars; ///< list of registred vars |
105 VARDEF IConsoleVar *_iconsole_vars; ///< list of registred vars |
109 VARDEF IConsoleAlias *_iconsole_aliases; ///< list of registred aliases |
106 VARDEF IConsoleAlias *_iconsole_aliases; ///< list of registred aliases |
115 VARDEF byte _icolour_dbg; |
112 VARDEF byte _icolour_dbg; |
116 VARDEF byte _icolour_cmd; |
113 VARDEF byte _icolour_cmd; |
117 VARDEF IConsoleModes _iconsole_mode; |
114 VARDEF IConsoleModes _iconsole_mode; |
118 |
115 |
119 /* console functions */ |
116 /* console functions */ |
120 void IConsoleInit(void); |
117 void IConsoleInit(); |
121 void IConsoleFree(void); |
118 void IConsoleFree(); |
122 void IConsoleClearBuffer(void); |
119 void IConsoleClearBuffer(); |
123 void IConsoleResize(Window *w); |
120 void IConsoleResize(Window *w); |
124 void IConsoleSwitch(void); |
121 void IConsoleSwitch(); |
125 void IConsoleClose(void); |
122 void IConsoleClose(); |
126 void IConsoleOpen(void); |
123 void IConsoleOpen(); |
127 |
124 |
128 /* console output */ |
125 /* console output */ |
129 void IConsolePrint(uint16 color_code, const char *string); |
126 void IConsolePrint(uint16 color_code, const char *string); |
130 void CDECL IConsolePrintF(uint16 color_code, const char *s, ...); |
127 void CDECL IConsolePrintF(uint16 color_code, const char *s, ...); |
131 void IConsoleDebug(const char *dbg, const char *string); |
128 void IConsoleDebug(const char *dbg, const char *string); |