]> git.xonotic.org Git - xonotic/darkplaces.git/blob - console.h
Doxygen: disable CALL_GRAPH and CALLER_GRAPH
[xonotic/darkplaces.git] / console.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3 Copyright (C) 2000-2020 DarkPlaces contributors
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 */
21
22 #ifndef CONSOLE_H
23 #define CONSOLE_H
24
25 #include <stddef.h>
26 #include "qtypes.h"
27 #include "cmd.h"
28 #include "lhnet.h"
29
30 //
31 // console
32 //
33 extern int con_totallines;
34 extern int con_backscroll;
35 extern qbool con_initialized;
36
37 void Con_Rcon_Redirect_Init(lhnetsocket_t *sock, lhnetaddress_t *dest, qbool proquakeprotocol);
38 void Con_Rcon_Redirect_End(void);
39 void Con_Rcon_Redirect_Abort(void);
40
41 /// If the line width has changed, reformat the buffer.
42 void Con_CheckResize (void);
43 void Con_Init (void);
44 void Con_Init_Commands (void);
45 void Con_Shutdown (void);
46 void Con_DrawConsole (int lines);
47
48 /// Prints to a chosen console target
49 void Con_MaskPrint(int mask, const char *msg);
50
51 // Prints to a chosen console target
52 void Con_MaskPrintf(int mask, const char *fmt, ...) DP_FUNC_PRINTF(2);
53
54 /// Prints to all appropriate console targets, and adds timestamps
55 void Con_Print(const char *txt);
56
57 /// Prints to all appropriate console targets.
58 void Con_Printf(const char *fmt, ...) DP_FUNC_PRINTF(1);
59
60 /// A Con_Print that only shows up if the "developer" cvar is set.
61 void Con_DPrint(const char *msg);
62
63 /// A Con_Printf that only shows up if the "developer" cvar is set
64 void Con_DPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
65 void Con_Clear_f(cmd_state_t *cmd);
66 void Con_DrawNotify (void);
67
68 /// Clear all notify lines.
69 void Con_ClearNotify (void);
70 void Con_ToggleConsole_f(cmd_state_t *cmd);
71
72 qbool GetMapList (const char *s, char *completedname, int completednamebufferlength);
73
74 /// wrapper function to attempt to either complete the command line
75 /// or to list possible matches grouped by type
76 /// (i.e. will display possible variables, aliases, commands
77 /// that match what they've typed so far)
78 int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console);
79
80 /// Generic libs/util/console.c function to display a list
81 /// formatted in columns on the console
82 void Con_DisplayList(const char **list);
83
84
85 /*! \name log
86  * @{
87  */
88 void Log_Init (void);
89 void Log_Close (void);
90 void Log_Start (void);
91 void Log_DestBuffer_Flush (void); ///< call this once per frame to send out replies to rcon streaming clients
92
93 void Log_Printf(const char *logfilename, const char *fmt, ...) DP_FUNC_PRINTF(2);
94 //@}
95
96 #define CON_WARN "^3"
97 #define CON_ERROR "^1"
98
99 // CON_MASK_PRINT is the default (Con_Print/Con_Printf)
100 // CON_MASK_DEVELOPER is used by Con_DPrint/Con_DPrintf
101 #define CON_MASK_HIDENOTIFY 128
102 #define CON_MASK_CHAT 1
103 #define CON_MASK_INPUT 2
104 #define CON_MASK_DEVELOPER 4
105 #define CON_MASK_PRINT 8
106
107 typedef struct con_lineinfo_s
108 {
109         char *start;
110         size_t len;
111         int mask;
112
113         /// used only by console.c
114         double addtime;
115         int height; ///< recalculated line height when needed (-1 to unset)
116 }
117 con_lineinfo_t;
118
119 typedef struct conbuffer_s
120 {
121         qbool active;
122         int textsize;
123         char *text;
124         int maxlines;
125         con_lineinfo_t *lines;
126         int lines_first;
127         int lines_count; ///< cyclic buffer
128 }
129 conbuffer_t;
130
131 #define CONBUFFER_LINES(buf, i) (buf)->lines[((buf)->lines_first + (i)) % (buf)->maxlines]
132 #define CONBUFFER_LINES_COUNT(buf) ((buf)->lines_count)
133 #define CONBUFFER_LINES_LAST(buf) CONBUFFER_LINES(buf, CONBUFFER_LINES_COUNT(buf) - 1)
134
135 void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool);
136 void ConBuffer_Clear (conbuffer_t *buf);
137 void ConBuffer_Shutdown(conbuffer_t *buf);
138
139 /*! Notifies the console code about the current time
140  * (and shifts back times of other entries when the time
141  * went backwards)
142  */
143 void ConBuffer_FixTimes(conbuffer_t *buf);
144
145 /// Deletes the first line from the console history.
146 void ConBuffer_DeleteLine(conbuffer_t *buf);
147
148 /// Deletes the last line from the console history.
149 void ConBuffer_DeleteLastLine(conbuffer_t *buf);
150
151 /// Appends a given string as a new line to the console.
152 void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, int mask);
153 int ConBuffer_FindPrevLine(conbuffer_t *buf, int mask_must, int mask_mustnot, int start);
154 int ConBuffer_FindNextLine(conbuffer_t *buf, int mask_must, int mask_mustnot, int start);
155 const char *ConBuffer_GetLine(conbuffer_t *buf, int i);
156
157 #endif
158