36#define ColorIndex(c) (((c) - '0') & 0x07)
51#define CONSOLE_CHAR_ALIGN 4
52#define NUM_CON_TIMES 8
53#define CON_TEXTSIZE 32768
54#define CONSOLE_CURSOR_CHAR 11
55#define CONSOLE_HISTORY_FILENAME "history"
83 for (
unsigned int i = 0;
i <
size;
i++)
92static void Con_DrawText (
const short* text,
int x,
int y,
size_t width)
94 for (
unsigned int xPos = 0; xPos < width; xPos++) {
95 const int currentColor = (text[xPos] >> 8) & 7;
111 if (width >
size || strlen(txt) >
size)
117 while ((c = *txt) != 0) {
124 *pos = (color << 8) | c;
174 con.displayLine += scroll;
175 if (
con.displayLine >
con.currentLine)
176 con.displayLine =
con.currentLine;
177 else if (
con.displayLine < 0)
189 if (width < 1 || width ==
con.lineWidth)
192 int oldWidth =
con.lineWidth;
193 con.lineWidth = width;
194 int oldTotalLines =
con.totalLines;
196 int numLines = oldTotalLines;
198 if (
con.totalLines < numLines)
199 numLines =
con.totalLines;
201 int numChars = oldWidth;
203 if (
con.lineWidth < numChars)
204 numChars =
con.lineWidth;
206 memcpy(tbuf,
con.text,
sizeof(tbuf));
209 for (
int i = 0;
i < numLines;
i++) {
210 for (
int j = 0; j < numChars; j++) {
211 con.text[(
con.totalLines - 1 -
i) *
con.lineWidth + j] = tbuf[((
con.currentLine -
i + oldTotalLines) % oldTotalLines) * oldWidth + j];
215 con.currentLine =
con.totalLines - 1;
216 con.displayLine =
con.currentLine;
237 if (line[strlen(line) - 1] ==
'\n')
238 line[strlen(line) - 1] = 0;
263 const char* lastLine =
nullptr;
270 FS_Write(lastLine, strlen(lastLine), &
f);
278 Com_Printf(
"\n----- console initialization -------\n");
295 con.initialized =
true;
304 if (
con.displayLine ==
con.currentLine)
308 for (
int i = 0;
i <
con.lineWidth;
i++)
324 if (!
con.initialized)
329 while ((c = *txt) != 0) {
374 y =
con.currentLine %
con.totalLines;
375 con.text[y *
con.lineWidth +
con.pos] = (color << 8) | c;
377 if (
con.pos >=
con.lineWidth)
411 for (
unsigned int i = 0;
i <
size;
i++) {
417 short* text = editlinecopy;
427 for (
unsigned int i = y;
i <
size;
i++)
445 unsigned int lines =
viddef.context.height * frac;
449 if (lines >
viddef.context.height)
450 lines =
viddef.context.height;
456 char consoleMessage[128];
459 const int len = strlen(consoleMessage);
464 for (
int x = 0; x <
len; x++)
469 con.visLines = lines;
476 if (
con.displayLine !=
con.currentLine) {
479 for (
int x = 0; x <
con.lineWidth; x += 4)
489 if (
con.currentLine - row >=
con.totalLines)
492 short* text =
con.text + (row %
con.totalLines) *
con.lineWidth;
static void Con_ToggleChat_f(void)
void Con_LoadConsoleHistory(void)
Load the console history.
#define CONSOLE_CURSOR_CHAR
void Con_SaveConsoleHistory(void)
Stores the console history.
#define CONSOLE_HISTORY_FILENAME
static cvar_t * con_history
void Con_Print(const char *txt)
Handles cursor positioning, line wrapping, etc All console printing must go through this in order to ...
static void Key_ClearTyping(void)
static void Con_DrawText(const short *text, int x, int y, size_t width)
static void Con_Clear(void)
void Con_Close(void)
Hide the gameconsole if active.
static const uint32_t g_color_table[]
void Con_DrawConsole(float frac)
Draws the console with the solid background.
#define CONSOLE_CHAR_ALIGN
static cvar_t * con_background
void Con_Scroll(int scroll)
Scrolls the console.
void Con_ToggleConsole_f(void)
void Con_CheckResize(void)
If the line width has changed, reformat the buffer.
static void Con_Linefeed(void)
static void Con_Clear_f(void)
Clears the console buffer.
void Con_DrawString(const char *txt, int x, int y, unsigned int width)
static cvar_t * con_notifytime
static void Con_DrawInput(void)
The input line scrolls horizontally if typing goes beyond the right edge.
Shared game type headers.
char keyLines[MAXKEYLINES][MAXCMDLINE]
void Key_SetDest(keydest_t keyDest)
Sets the keyDest in cls.
Header file for keyboard handler.
int CL_Milliseconds(void)
Primary header for client.
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
void Com_Printf(const char *const fmt,...)
#define Q_IsColorString(p)
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
int FS_Write(const void *buffer, int len, qFILE *f)
Properly handles partial writes.
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
void Sys_Error(const char *error,...)
void R_DrawChar(int x, int y, int num, uint32_t color)
Draws one 8*8 graphics character with 0 being transparent. It can be clipped to the top of the screen...
void R_DrawStretchImage(float x, float y, int w, int h, const image_t *image)
QGL_EXTERN GLuint GLchar GLuint * len
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
int UTF8_char_len(unsigned char c)
length of UTF-8 character starting with this byte.