From d6d45bf07cc6ca77821368ba4182dffa7c1a8dc0 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 20 Sep 2022 12:14:01 +0900 Subject: [PATCH] [console] Add a function to clear the scroll-back buffer Needed for when the console display is cleared. --- include/QF/console.h | 1 + libs/console/buffer.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/QF/console.h b/include/QF/console.h index 79aac8e69..8839f1b73 100644 --- a/include/QF/console.h +++ b/include/QF/console.h @@ -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_BufferAddText (con_buffer_t *buf, const char *text); #define Con_BufferLine(b,l) ((b)->lines + ((l) + (b)->max_lines) % (b)->max_lines) +void Con_ClearBuffer (con_buffer_t *buffer); // init/shutdown functions void Con_Init (const char *plugin_name); diff --git a/libs/console/buffer.c b/libs/console/buffer.c index 006a2c7bb..9f0b08c5e 100644 --- a/libs/console/buffer.c +++ b/libs/console/buffer.c @@ -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; +}