]> icculus.org git repositories - divverent/darkplaces.git/blob - console.h
improved persistent input history; now independent buffers are used again, by factori...
[divverent/darkplaces.git] / console.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #ifndef CONSOLE_H
22 #define CONSOLE_H
23
24 //
25 // console
26 //
27 extern int con_totallines;
28 extern int con_backscroll;
29 extern qboolean con_initialized;
30
31 void Con_Rcon_Redirect_Init(lhnetsocket_t *sock, lhnetaddress_t *dest);
32 void Con_Rcon_Redirect_End();
33 void Con_Rcon_Redirect_Abort();
34
35 void Con_CheckResize (void);
36 void Con_Init (void);
37 void Con_Init_Commands (void);
38 void Con_DrawConsole (int lines);
39 void Con_Print(const char *txt);
40 void Con_Printf(const char *fmt, ...) DP_FUNC_PRINTF(1);
41 void Con_DPrint(const char *msg);
42 void Con_DPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
43 void Con_Clear_f (void);
44 void Con_DrawNotify (void);
45 void Con_ClearNotify (void);
46 void Con_ToggleConsole_f (void);
47
48 qboolean GetMapList (const char *s, char *completedname, int completednamebufferlength);
49
50 // wrapper function to attempt to either complete the command line
51 // or to list possible matches grouped by type
52 // (i.e. will display possible variables, aliases, commands
53 // that match what they've typed so far)
54 void Con_CompleteCommandLine(void);
55
56 // Generic libs/util/console.c function to display a list
57 // formatted in columns on the console
58 void Con_DisplayList(const char **list);
59
60
61 //
62 // log
63 //
64 void Log_Init (void);
65 void Log_Close (void);
66 void Log_Start (void);
67 void Log_DestBuffer_Flush (void); // call this once per frame to send out replies to rcon streaming clients
68
69 void Log_Printf(const char *logfilename, const char *fmt, ...) DP_FUNC_PRINTF(2);
70
71 #define CON_MASK_HIDENOTIFY 128
72 #define CON_MASK_CHAT 1
73 #define CON_MASK_INPUT 2
74
75 typedef struct con_lineinfo_s
76 {
77         char *start;
78         size_t len;
79         int mask;
80
81         // used only by console.c
82         double addtime;
83         int height; // recalculated line height when needed (-1 to unset)
84 }
85 con_lineinfo_t;
86
87 typedef struct conbuffer_s
88 {
89         int textsize;
90         char *text;
91         int maxlines;
92         con_lineinfo_t *lines;
93         int lines_first;
94         int lines_count; // cyclic buffer
95 }
96 conbuffer_t;
97
98 #define CONBUF_LINES_IDX(buf, i) (((buf)->lines_first + (i)) % (buf)->maxlines)
99 #define CONBUF_LINES_UNIDX(buf, i) (((i) - (buf)->lines_first + (buf)->maxlines) % (buf)->maxlines)
100 #define CONBUF_LINES_LAST(buf) CONBUF_LINES_IDX(buf, (buf)->lines_count - 1)
101 #define CONBUF_LINES(buf, i) (buf)->lines[CONBUF_LINES_IDX(buf, i)]
102 #define CONBUF_LINES_PRED(buf, i) (((i) + (buf)->maxlines - 1) % (buf)->maxlines)
103 #define CONBUF_LINES_SUCC(buf, i) (((i) + 1) % (buf)->maxlines)
104
105 void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool);
106 void ConBuffer_Clear (conbuffer_t *buf);
107 void ConBuffer_Shutdown(conbuffer_t *buf);
108 void ConBuffer_FixTimes(conbuffer_t *buf);
109 void ConBuffer_DeleteLine(conbuffer_t *buf);
110 void ConBuffer_DeleteLastLine(conbuffer_t *buf);
111 void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, int mask);
112 int ConBuffer_FindPrevLine(conbuffer_t *buf, int mask_must, int mask_mustnot, int start);
113 int ConBuffer_FindNextLine(conbuffer_t *buf, int mask_must, int mask_mustnot, int start);
114 const char *ConBuffer_GetLine(conbuffer_t *buf, int i);
115
116 #endif
117