console: add function to clear scrollback buffer
The new function can be used by the UI to clear the current scrollback buffer to free resources or whatever. It will also be used by the CSI handler to reset the console. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
3560ae8eb1
commit
09e15d84e8
@ -58,6 +58,7 @@ int kmscon_buffer_resize(struct kmscon_buffer *buf, unsigned int x,
|
||||
unsigned int y);
|
||||
void kmscon_buffer_draw(struct kmscon_buffer *buf, struct kmscon_font *font);
|
||||
void kmscon_buffer_set_max_sb(struct kmscon_buffer *buf, unsigned int max);
|
||||
void kmscon_buffer_clear_sb(struct kmscon_buffer *buf);
|
||||
|
||||
unsigned int kmscon_buffer_get_width(struct kmscon_buffer *buf);
|
||||
unsigned int kmscon_buffer_get_height(struct kmscon_buffer *buf);
|
||||
|
@ -242,7 +242,6 @@ void kmscon_buffer_ref(struct kmscon_buffer *buf)
|
||||
|
||||
void kmscon_buffer_unref(struct kmscon_buffer *buf)
|
||||
{
|
||||
struct line *iter, *tmp;
|
||||
unsigned int i;
|
||||
|
||||
if (!buf || !buf->ref)
|
||||
@ -251,11 +250,7 @@ void kmscon_buffer_unref(struct kmscon_buffer *buf)
|
||||
if (--buf->ref)
|
||||
return;
|
||||
|
||||
for (iter = buf->sb_first; iter; ) {
|
||||
tmp = iter;
|
||||
iter = iter->next;
|
||||
free_line(tmp);
|
||||
}
|
||||
kmscon_buffer_clear_sb(buf);
|
||||
|
||||
for (i = 0; i < buf->size_y; ++i)
|
||||
free_line(buf->current[i]);
|
||||
@ -364,6 +359,26 @@ void kmscon_buffer_set_max_sb(struct kmscon_buffer *buf, unsigned int max)
|
||||
buf->sb_max = max;
|
||||
}
|
||||
|
||||
/* clear scrollback buffer */
|
||||
void kmscon_buffer_clear_sb(struct kmscon_buffer *buf)
|
||||
{
|
||||
struct line *iter, *tmp;
|
||||
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
for (iter = buf->sb_first; iter; ) {
|
||||
tmp = iter;
|
||||
iter = iter->next;
|
||||
free_line(tmp);
|
||||
}
|
||||
|
||||
buf->sb_first = NULL;
|
||||
buf->sb_last = NULL;
|
||||
buf->sb_count = 0;
|
||||
buf->position = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Resize the current console buffer
|
||||
* This resizes the current buffer. We do not resize the lines or modify them in
|
||||
|
Loading…
x
Reference in New Issue
Block a user