-#define CON_MASK_LOADEDHISTORY 4
-
-void Con_AddLine(const char *line, int len, int mask);
-int Con_FindPrevLine(int mask_must, int mask_mustnot, int start);
-int Con_FindNextLine(int mask_must, int mask_mustnot, int start);
-const char *Con_GetLine(int i);
-int Con_GetLineID(int i);
-int Con_GetLineByID(int i);
+#define CON_MASK_DEVELOPER 4
+#define CON_MASK_PRINT 8
+
+typedef struct con_lineinfo_s
+{
+ char *start;
+ size_t len;
+ int mask;
+
+ /// used only by console.c
+ double addtime;
+ int height; ///< recalculated line height when needed (-1 to unset)
+}
+con_lineinfo_t;
+
+typedef struct conbuffer_s
+{
+ qbool active;
+ int textsize;
+ char *text;
+ int maxlines;
+ con_lineinfo_t *lines;
+ int lines_first;
+ int lines_count; ///< cyclic buffer
+}
+conbuffer_t;
+
+#define CONBUFFER_LINES(buf, i) (buf)->lines[((buf)->lines_first + (i)) % (buf)->maxlines]
+#define CONBUFFER_LINES_COUNT(buf) ((buf)->lines_count)
+#define CONBUFFER_LINES_LAST(buf) CONBUFFER_LINES(buf, CONBUFFER_LINES_COUNT(buf) - 1)
+
+void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool);
+void ConBuffer_Clear (conbuffer_t *buf);
+void ConBuffer_Shutdown(conbuffer_t *buf);
+
+/*! Notifies the console code about the current time
+ * (and shifts back times of other entries when the time
+ * went backwards)
+ */
+void ConBuffer_FixTimes(conbuffer_t *buf);
+
+/// Deletes the first line from the console history.
+void ConBuffer_DeleteLine(conbuffer_t *buf);
+
+/// Deletes the last line from the console history.
+void ConBuffer_DeleteLastLine(conbuffer_t *buf);
+
+/// Appends a given string as a new line to the console.
+void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, int mask);
+int ConBuffer_FindPrevLine(conbuffer_t *buf, int mask_must, int mask_mustnot, int start);
+int ConBuffer_FindNextLine(conbuffer_t *buf, int mask_must, int mask_mustnot, int start);
+const char *ConBuffer_GetLine(conbuffer_t *buf, int i);