FTEQW
Documentation of the FTE engine source tree.
console.h
Go to the documentation of this file.
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20//
21// console
22//
23
24#define MAXCONCOLOURS 16
25typedef struct {
26 float fr, fg, fb;
28
29extern consolecolours_t consolecolours[MAXCONCOLOURS];
30
31#define MAXQ3COLOURS 10
32extern conchar_t q3codemasks[MAXQ3COLOURS];
33
34#define CON_LONGCHAR_MASK (CON_LONGCHAR|CON_RICHFORECOLOUR)
35
36#define CON_NONCLEARBG 0x00800000 //disabled if CON_RICHFORECOLOUR
37#define CON_HALFALPHA 0x00400000 //disabled if CON_RICHFORECOLOUR
38#define CON_LINKSPECIAL 0x00200000 //disabled if CON_RICHFORECOLOUR
39#define CON_LONGCHAR 0x00100000 //flags (other than hidden) are found in the following conchar. disabled if CON_RICHFORECOLOUR
40#define CON_HIDDEN 0x00080000
41#define CON_BLINKTEXT 0x00040000
42#define CON_2NDCHARSETTEXT 0x00020000
43#define CON_RICHFORECOLOUR 0x00010000 //if set, the upper 3 nibbles are r4g4b4. background is clear, halfalpha is ignored.
44//#define CON_HIGHCHARSMASK 0x00000080 // Quake's alternative mask
45
46#define CON_FLAGSMASK 0xFFFF0000
47#define CON_CHARMASK 0x0000FFFF
48
49#define CON_FGMASK 0x0F000000
50#define CON_BGMASK 0xF0000000
51#define CON_FGSHIFT 24 //second highest nibble
52#define CON_BGSHIFT 28 //high nibble
53#define CON_RICHFOREMASK 0xFFF00000
54#define CON_RICHBSHIFT 20 //
55#define CON_RICHGSHIFT 24
56#define CON_RICHRSHIFT 28 //high nibble
57
58#define CON_WHITEMASK 0x0F000000 // must be constant. things assume this
59
60#define CON_DEFAULTCHAR (CON_WHITEMASK | 32)
61
62#define CON_LINKSTART (CON_LINKSPECIAL | CON_HIDDEN | '[')
63#define CON_LINKEND (CON_LINKSPECIAL | CON_HIDDEN | ']')
64
65// RGBI standard colors
66#define COLOR_BLACK 0
67#define COLOR_DARKBLUE 1
68#define COLOR_DARKGREEN 2
69#define COLOR_DARKCYAN 3
70#define COLOR_DARKRED 4
71#define COLOR_DARKMAGENTA 5
72#define COLOR_BROWN 6
73#define COLOR_GREY 7
74#define COLOR_DARKGREY 8
75#define COLOR_BLUE 9
76#define COLOR_GREEN 10
77#define COLOR_CYAN 11
78#define COLOR_RED 12
79#define COLOR_MAGENTA 13
80#define COLOR_YELLOW 14
81#define COLOR_WHITE 15
82
83#define S_COLOR_BLACK "^0"
84#define S_COLOR_RED "^1"
85#define S_COLOR_GREEN "^2"
86#define S_COLOR_YELLOW "^3"
87#define S_COLOR_BLUE "^4"
88#define S_COLOR_CYAN "^5"
89#define S_COLOR_MAGENTA "^6"
90#define S_COLOR_WHITE "^7"
91#define S_COLOR_TRANS "^8"
92#define S_COLOR_GRAY "^9"
93
94#define CON_DEFAULT "^&--"
95#define CON_WARNING "^&E0"
96#define CON_ERROR "^&C0"
97#define CON_NOTICE "^&-1"
98
99#define isextendedcode(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || x == '-')
100#define ishexcode(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || (x >= 'a' && x <= 'f'))
101
102#define CONL_CENTERED (1u<<0)
103#define CONL_NONOTIFY (1u<<1)
104#define CONL_BREAKPOINT (1u<<2) //red
105#define CONL_EXECUTION (1u<<3) //yellow
106typedef struct conline_s {
109 unsigned short length;
110 unsigned short maxlength;
111 unsigned char numlines; //updated so we scroll properly
112 unsigned char flags;
113 unsigned short id;
114 float time;
116
117//majority of these are mututally exclusive. the bits allow multiple.
118enum
119{
127 CB_SELECTED = 7, //selection ended (deferred until drawing to ensure selections happen properly)
128 CB_TAPPED = 8, //quick-tap ended (deferred until drawing to ensure selections happen properly)
129
130 //the flags part
131 CB_STALE = (1u<<28), //WAS held last frame - to make sure we still do stuff when released on the same frame.
132 CB_SIZELEFT = (1u<<29),
133 CB_SIZERIGHT = (1u<<30),
134 CB_SIZEBOTTOM = (1u<<31),
135};
136enum
137{
138 CONF_HIDDEN = 1u<<0, /*do not show in the console list (unless active)*/
139 CONF_NOTIFY = 1u<<1, /*text printed to console also appears as notify lines*/
140 CONF_NOTIFY_BOTTOM = 1u<<2, /*align the bottom*/
142 //CONF_NOTIMES = 1u<<4,
145 CONF_NOWRAP = 1u<<7,
146 CONF_KEEPSELECTION = 1u<<8, //there's text selected, keep it selected.
147 CONF_BACKSELECTION = 1u<<9, //a hint that the text was selected from the end
148};
149typedef struct console_s
150{
151 int id;
152 int nextlineid; //the current line being written to. so we can rewrite links etc.
153 char name[128];
154 char title[128];
155 char prompt[128];
156 char icon[MAX_QPATH]; //should really dynamically allocate this stuff.
157 char backimage[MAX_QPATH];
159 float wnd_x;
160 float wnd_y;
161 float wnd_w;
162 float wnd_h;
164 unsigned int flags;
165 float notif_x;
166 float notif_y;
167 float notif_w;
169 float notif_fade; // will be transparent for this long when fading
170 float notif_t;
173 conline_t *current; // line where next message will be printed
174 int x; // offset in current line for next print
175 int cr; // last char printed was a carrage return so the next char printed will wipe the line.
176 conline_t *display; // bottom of console displays this line
177 float displayscroll; // to try to handle smoother scrolling.
178 int displayoffset; // horizontal offset
179 int vislines; // pixel lines
180 int linesprinted; // for notify times
182 unsigned parseflags;
184 int commandcompletion; //allows tab completion of quake console commands
185
186 //WARNING: note that links do NOT represent any sort of security. text can be inserted from anywhere. Its fine to use such things for context, but don't treat them as sescure.
187 int (*linebuffered) (struct console_s *con, const char *line); //if present, called on enter, causes the standard console input to appear. return 2 to not save the line in history.
188 qboolean (*redirect) (struct console_s *con, unsigned int unicode, int key); //if present, called every character.
189 qboolean (*mouseover)(struct console_s *con, char **out_tiptext, struct shader_s **out_shader);
190 qboolean (*close) (struct console_s *con, qboolean force);
191 void *userdata; //user context
192 conline_t *userline; //editor cursor line
193 unsigned int useroffset; //editor cursor offset
194
195 conline_t *highlightline; //used for highlights (this line gets flagged)
196 conline_t *completionline; //temp text at the bottom of the console
197 conline_t *footerline; //temp text at the bottom of the console
200 float mousedown[2]; //x,y position that the current buttons were clicked.
201 unsigned int buttonsdown;
202 float mousecursor[2]; //x,y
203 float mousedowntime; //time mouse1 last went down, to detect double-clicks
204
207
208extern console_t *con_head;
209extern console_t *con_curwindow; // refers to a windowed console
210extern console_t *con_current; // point to either con_main or con_chat
212
213extern console_t *con_chat;
214
215//shared between console and keys.
216//really the console input should be in console.c instead of keys.c I suppose.
217#define MAXCMDLINE 8192
218#define CON_EDIT_LINES_MASK ((1<<8)-1)
219extern unsigned char *key_lines[CON_EDIT_LINES_MASK+1];
220extern int edit_line;
221extern int key_linepos;
222extern int history_line;
223
224//extern int con_totallines;
226extern qbyte *con_chars;
227
228void Con_DrawCharacter (int cx, int line, int num);
229
230void Con_CheckResize (void);
231void Con_ForceActiveNow(void);
232void Con_Init (void);
233void Con_Shutdown (void);
234void Con_History_Save(void);
235void Con_History_Load(void);
236struct font_s;
237void Con_DrawOneConsole(console_t *con, qboolean focused, struct font_s *font, float fx, float fy, float fsx, float fsy, float lineagelimit);
238void Con_DrawConsole (int lines, qboolean noback);
240char *Con_CopyConsole(console_t *con, qboolean nomarkup, qboolean onlyiflink, qboolean forceutf8);
241void Con_Print (const char *txt);
242void Con_CenterPrint(const char *txt);
243void Con_PrintFlags(const char *text, unsigned int setflags, unsigned int clearflags);
244void VARGS Con_Printf (const char *fmt, ...) LIKEPRINTF(1);
245void VARGS Con_TPrintf (translation_t text, ...);
246void VARGS Con_DPrintf (const char *fmt, ...) LIKEPRINTF(1); //developer>=1, for stuff that's probably actually slightly useful
247void VARGS Con_DLPrintf (int level, const char *fmt, ...) LIKEPRINTF(2); //developer>=2, for spammy stuff
248void VARGS Con_ThrottlePrintf (float *timer, int developerlevel, const char *fmt, ...); //for spammed warnings, so they don't spam prints with every single frame/call. the timer arg should be a static local.
249void VARGS Con_SafePrintf (const char *fmt, ...) LIKEPRINTF(1);
250void Con_Footerf(console_t *con, qboolean append, const char *fmt, ...) LIKEPRINTF(3);
251void Con_Clear_f (void);
252void Con_DrawNotify (void);
253void Con_ClearNotify (void);
254void Con_ToggleConsole_f (void);//note: allows csqc to intercept the toggleconsole
255void Con_ToggleConsole_Force(void);
256
257int Con_ExecuteLine(console_t *con, const char *line); //takes normal console commands
258int Con_Navigate(console_t *con, const char *line); //special webbrowser hacks
259
260vfsfile_t *Con_POpen(const char *conname);
261void Con_CycleConsole (void);
262int Con_IsActive (console_t *con);
263void Con_Destroy (console_t *con);
264void Con_ClearCon(console_t *con);
265void Con_SetActive (console_t *con);
267console_t *Con_FindConsole(const char *name);
268console_t *Con_Create(const char *name, unsigned int flags);
269console_t *Con_GetMain(void); //retrieves the main console (creating it if needed)
270void Con_PrintCon (console_t *con, const char *txt, unsigned int parseflags);
273void Con_FlushBackgrounds(void);
274
275void Con_NotifyBox (char *text); // during startup for sound / cd warnings
276
277#ifdef CRAZYDEBUGGING
278#define TRACE(x) Sys_Printf x
279#else
280#define TRACE(x)
281#endif
282
qboolean
Definition: api_menu.h:34
dReal dReal fy
Definition: com_phys_ode.c:386
dReal fx
Definition: com_phys_ode.c:386
int num
Definition: com_phys_ode.c:314
unsigned int conchar_t
Definition: common.h:476
unsigned char qbyte
Definition: common.h:127
console_t * con_head
Definition: console.c:25
void Con_ExpandConsoleSelection(console_t *con)
Definition: console.c:3534
void Con_Init(void)
Definition: console.c:799
conchar_t q3codemasks[MAXQ3COLOURS]
Definition: common.c:3531
void Con_History_Save(void)
Definition: console.c:579
vfsfile_t * Con_POpen(const char *conname)
Definition: console.c:1110
void Con_PrintCon(console_t *con, const char *txt, unsigned int parseflags)
Definition: console.c:928
qbyte * con_chars
void Con_DrawCharacter(int cx, int line, int num)
void VARGS Con_ThrottlePrintf(float *timer, int developerlevel, const char *fmt,...)
Definition: console.c:1299
qboolean Con_InsertConChars(console_t *con, conline_t *line, int offset, conchar_t *c, int len)
Definition: console.c:909
@ CONF_NOTIFY_RIGHT
Definition: console.h:141
@ CONF_NOWRAP
Definition: console.h:145
@ CONF_ISWINDOW
Definition: console.h:144
@ CONF_KEEPSELECTION
Definition: console.h:146
@ CONF_HIDDEN
Definition: console.h:138
@ CONF_NOTIFY_BOTTOM
Definition: console.h:140
@ CONF_NOTIFY
Definition: console.h:139
@ CONF_BACKSELECTION
Definition: console.h:147
@ CONF_KEYFOCUSED
Definition: console.h:143
void Con_DrawNotify(void)
Definition: console.c:1799
qboolean Con_NameForNum(int num, char *buffer, int buffersize)
Definition: console.c:336
int Con_Navigate(console_t *con, const char *line)
Definition: keys.c:591
console_t * con_current
Definition: console.c:27
console_t * Con_FindConsole(const char *name)
Definition: console.c:216
void Con_Print(const char *txt)
Definition: console.c:1046
char * Con_CopyConsole(console_t *con, qboolean nomarkup, qboolean onlyiflink, qboolean forceutf8)
Definition: console.c:3620
void Con_ForceActiveNow(void)
Definition: console.c:786
void VARGS Con_DLPrintf(int level, const char *fmt,...) LIKEPRINTF(2)
Definition: console.c:1260
void Con_FlushBackgrounds(void)
Definition: console.c:203
int key_linepos
Definition: keys.c:35
void Con_CycleConsole(void)
Definition: console.c:1067
console_t * Con_GetMain(void)
Definition: console.c:275
int history_line
Definition: keys.c:39
void Con_PrintFlags(const char *text, unsigned int setflags, unsigned int clearflags)
Definition: console.c:1051
void Con_DrawOneConsole(console_t *con, qboolean focused, struct font_s *font, float fx, float fy, float fsx, float fsy, float lineagelimit)
Definition: console.c:3413
int Con_ExecuteLine(console_t *con, const char *line)
Definition: keys.c:608
console_t * Con_Create(const char *name, unsigned int flags)
Definition: console.c:231
console_t * con_chat
Definition: console.c:31
void Con_ClearNotify(void)
Definition: console.c:1789
consolecolours_t consolecolours[MAXCONCOLOURS]
=====================================
Definition: common.c:3510
void VARGS Con_DPrintf(const char *fmt,...) LIKEPRINTF(1)
Definition: console.c:1225
@ CB_NONE
Definition: console.h:120
@ CB_ACTIONBAR
Definition: console.h:125
@ CB_SIZEBOTTOM
Definition: console.h:134
@ CB_SIZELEFT
Definition: console.h:132
@ CB_SCROLL_R
Definition: console.h:122
@ CB_CLOSE
Definition: console.h:123
@ CB_SELECTED
Definition: console.h:127
@ CB_SELECT
Definition: console.h:126
@ CB_SCROLL
Definition: console.h:121
@ CB_TAPPED
Definition: console.h:128
@ CB_STALE
Definition: console.h:131
@ CB_SIZERIGHT
Definition: console.h:133
@ CB_MOVE
Definition: console.h:124
console_t * con_curwindow
Definition: console.c:26
qboolean con_initialized
Definition: console.c:112
void Con_Destroy(console_t *con)
Definition: console.c:141
void Con_Clear_f(void)
Definition: console.c:704
void VARGS Con_SafePrintf(const char *fmt,...) LIKEPRINTF(1)
Definition: console.c:1165
void Con_NotifyBox(char *text)
void Con_DrawConsole(int lines, qboolean noback)
Definition: console.c:3078
void Con_History_Load(void)
Definition: console.c:549
void Con_SetActive(console_t *con)
Definition: console.c:296
struct conline_s conline_t
conline_t * Con_ResizeLineBuffer(console_t *con, conline_t *old, unsigned int length)
Definition: console.c:876
struct console_s console_t
void VARGS Con_TPrintf(translation_t text,...)
Definition: console.c:1178
int Con_IsActive(console_t *con)
Definition: console.c:136
void Con_ClearCon(console_t *con)
Definition: console.c:682
void Con_ToggleConsole_Force(void)
Definition: console.c:614
void Con_ToggleConsole_f(void)
Definition: console.c:646
void Con_CheckResize(void)
void VARGS Con_Printf(const char *fmt,...) LIKEPRINTF(1)
Definition: console.c:1123
void Con_Shutdown(void)
Definition: console.c:849
void Con_Footerf(console_t *con, qboolean append, const char *fmt,...) LIKEPRINTF(3)
Definition: console.c:1379
void Con_CenterPrint(const char *txt)
Definition: console.c:1037
unsigned char * key_lines[CON_EDIT_LINES_MASK+1]
Definition: keys.c:34
console_t * con_mouseover
Definition: console.c:28
int edit_line
Definition: keys.c:38
char * text
Definition: decomp.c:375
void size_t buffersize
Definition: gl_model.c:912
GLint level
Definition: gl_vidcommon.c:42
float old
Definition: gl_vidlinuxglx.c:1365
static CONST PIXELFORMATDESCRIPTOR *static int
Definition: gl_vidnt.c:222
GLsizei const GLcharARB const GLint * length
Definition: glquake.h:149
GLuint GLcharARB * name
Definition: glquake.h:155
GLenum GLsizei len
Definition: glsupp.h:502
struct font_s * font[FONT_SIZES]
Definition: pr_menu.c:111
vec3_t offset
Definition: q2m_flash.c:28
uploadfmt_t fmt
Definition: r_2d.c:48
static ALC_API ALCvoid * buffer
Definition: snd_al.c:259
Definition: console.h:106
unsigned short length
Definition: console.h:109
struct conline_s * newer
Definition: console.h:108
unsigned short maxlength
Definition: console.h:110
float time
Definition: console.h:114
unsigned short id
Definition: console.h:113
struct conline_s * older
Definition: console.h:107
unsigned char numlines
Definition: console.h:111
unsigned char flags
Definition: console.h:112
Definition: console.h:150
int maxlines
Definition: console.h:171
int id
Definition: console.h:151
conline_t * selendline
Definition: console.h:198
conline_t * current
Definition: console.h:173
int cr
Definition: console.h:175
int notif_l
Definition: console.h:168
float mousecursor[2]
Definition: console.h:202
int linecount
Definition: console.h:163
float notif_y
Definition: console.h:166
conline_t * oldest
Definition: console.h:172
char icon[MAX_QPATH]
Definition: console.h:156
conline_t * display
Definition: console.h:176
conchar_t defaultcharbits
Definition: console.h:183
float mousedown[2]
Definition: console.h:200
float wnd_y
Definition: console.h:160
void * userdata
Definition: console.h:191
char prompt[128]
Definition: console.h:155
unsigned int flags
Definition: console.h:164
float mousedowntime
Definition: console.h:203
qboolean(* redirect)(struct console_s *con, unsigned int unicode, int key)
Definition: console.h:188
unsigned int selendoffset
Definition: console.h:199
int linesprinted
Definition: console.h:180
unsigned int useroffset
Definition: console.h:193
qboolean unseentext
Definition: console.h:181
float wnd_w
Definition: console.h:161
float wnd_h
Definition: console.h:162
qboolean(* mouseover)(struct console_s *con, char **out_tiptext, struct shader_s **out_shader)
Definition: console.h:189
struct shader_s * backshader
Definition: console.h:158
float notif_x
Definition: console.h:165
conline_t * selstartline
Definition: console.h:198
unsigned parseflags
Definition: console.h:182
float wnd_x
Definition: console.h:159
float displayscroll
Definition: console.h:177
float notif_w
Definition: console.h:167
int nextlineid
Definition: console.h:152
int x
Definition: console.h:174
int vislines
Definition: console.h:179
conline_t * completionline
Definition: console.h:196
char title[128]
Definition: console.h:154
conline_t * highlightline
Definition: console.h:195
int displayoffset
Definition: console.h:178
unsigned int buttonsdown
Definition: console.h:201
float notif_fade
Definition: console.h:169
conline_t * footerline
Definition: console.h:197
unsigned int selstartoffset
Definition: console.h:199
struct console_s * next
Definition: console.h:205
conline_t * userline
Definition: console.h:192
char backimage[MAX_QPATH]
Definition: console.h:157
qboolean(* close)(struct console_s *con, qboolean force)
Definition: console.h:190
int(* linebuffered)(struct console_s *con, const char *line)
Definition: console.h:187
int commandcompletion
Definition: console.h:184
float notif_t
Definition: console.h:170
Definition: console.h:25
float fb
Definition: console.h:26
Definition: shader.h:602
void * vfsfile_t
Definition: sys_plugfte.h:2
const char * translation_t
Definition: translate.h:3
unsigned int flags
Definition: valid.c:313