[console] Add a function to clear the scroll-back buffer

Needed for when the console display is cleared.
This commit is contained in:
Bill Currie 2022-09-20 12:14:01 +09:00
parent 11e978b4db
commit d6d45bf07c
2 changed files with 10 additions and 0 deletions

View file

@ -98,6 +98,7 @@ con_buffer_t *Con_CreateBuffer (size_t buffer_size, int max_lines);
void Con_DestroyBuffer (con_buffer_t *buffer); void Con_DestroyBuffer (con_buffer_t *buffer);
void Con_BufferAddText (con_buffer_t *buf, const char *text); void Con_BufferAddText (con_buffer_t *buf, const char *text);
#define Con_BufferLine(b,l) ((b)->lines + ((l) + (b)->max_lines) % (b)->max_lines) #define Con_BufferLine(b,l) ((b)->lines + ((l) + (b)->max_lines) % (b)->max_lines)
void Con_ClearBuffer (con_buffer_t *buffer);
// init/shutdown functions // init/shutdown functions
void Con_Init (const char *plugin_name); void Con_Init (const char *plugin_name);

View file

@ -125,3 +125,12 @@ Con_BufferAddText (con_buffer_t *buf, const char *text)
} }
} }
} }
VISIBLE void
Con_ClearBuffer (con_buffer_t *buffer)
{
buffer->line_head = 1;
buffer->line_tail = 0;
buffer->lines[0].text = 0;
buffer->lines[0].len = 0;
}