34 #include "../shared/utf8.h"
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++)
92 static 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;
196 int numLines = oldTotalLines;
201 int numChars = oldWidth;
206 memcpy(tbuf, con.
text,
sizeof(tbuf));
209 for (
int i = 0;
i < numLines;
i++) {
210 for (
int j = 0; j < numChars; j++) {
237 if (line[strlen(line) - 1] ==
'\n')
238 line[strlen(line) - 1] = 0;
253 if (!con_history || !con_history->
integer)
263 const char* lastLine =
nullptr;
270 FS_Write(lastLine, strlen(lastLine), &f);
278 Com_Printf(
"\n----- console initialization -------\n");
281 con_notifytime =
Cvar_Get(
"con_notifytime",
"10",
CVAR_ARCHIVE,
"How many seconds console messages should be shown before they fade away");
283 con_background =
Cvar_Get(
"con_background",
"1",
CVAR_ARCHIVE,
"Console is rendered with background image");
329 while ((c = *txt) != 0) {
339 for (len = 0; len < con.
lineWidth; len++)
411 for (
unsigned int i = 0;
i <
size;
i++) {
417 short* text = editlinecopy;
427 for (
unsigned int i = y;
i <
size;
i++)
456 char consoleMessage[128];
459 const int len = strlen(consoleMessage);
464 for (
int x = 0; x <
len; x++)
479 for (
int x = 0; x < con.
lineWidth; x += 4)
486 for (
int i = 0, row = con.
displayLine;
i < rows;
i++, y -= con_fontHeight, row--) {
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
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 Con_DrawString(const char *txt, int x, int y, unsigned int width)
void Sys_Error(const char *error,...)
static cvar_t * con_notifytime
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
#define Q_IsColorString(p)
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
static void Con_Clear(void)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
int UTF8_char_len(unsigned char c)
length of UTF-8 character starting with this byte.
Shared game type headers.
static cvar_t * con_history
void R_DrawStretchImage(float x, float y, int w, int h, const image_t *image)
void Com_Printf(const char *const fmt,...)
void Con_Close(void)
Hide the gameconsole if active.
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Header file for keyboard handler.
static void Key_ClearTyping(void)
void Key_SetDest(keydest_t keyDest)
Sets the keyDest in cls.
static cvar_t * con_background
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
void Con_Print(const char *txt)
Handles cursor positioning, line wrapping, etc All console printing must go through this in order to ...
void Con_Scroll(int scroll)
Scrolls the console.
void Con_SaveConsoleHistory(void)
Stores the console history.
char keyLines[MAXKEYLINES][MAXCMDLINE]
void Con_LoadConsoleHistory(void)
Load the console history.
static void Con_DrawText(const short *text, int x, int y, size_t width)
static void Con_DrawInput(void)
The input line scrolls horizontally if typing goes beyond the right edge.
static void Con_ToggleChat_f(void)
#define CONSOLE_CURSOR_CHAR
void Con_DrawConsole(float frac)
Draws the console with the solid background.
QGL_EXTERN GLuint GLchar GLuint * len
static void Con_Clear_f(void)
Clears the console buffer.
Primary header for client.
static const uint32_t g_color_table[]
void Con_ToggleConsole_f(void)
#define CONSOLE_CHAR_ALIGN
void Con_CheckResize(void)
If the line width has changed, reformat the buffer.
int CL_Milliseconds(void)
static void Con_Linefeed(void)
int FS_Write(const void *buffer, int len, qFILE *f)
Properly handles partial writes.
#define CONSOLE_HISTORY_FILENAME