From 2b8caca91c8f30f761ce71f104229c7b8783e633 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 4 Feb 2012 14:34:33 +0100 Subject: [PATCH] console: remove *_buffer_newline() This function is no longer needed as we now have proper scrolling functions. This also adjusts the buffer tests to be more appropriate. Signed-off-by: David Herrmann --- src/console.c | 4 ++-- src/console.h | 1 - src/console_cell.c | 27 --------------------------- tests/test_buffer.c | 5 +++-- 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/console.c b/src/console.c index f3a57e0..cbf60cc 100644 --- a/src/console.c +++ b/src/console.c @@ -241,7 +241,7 @@ void kmscon_console_write(struct kmscon_console *con, kmscon_symbol_t ch) con->cursor_y++; if (con->cursor_y >= con->cells_y) { con->cursor_y--; - kmscon_buffer_newline(con->cells); + kmscon_buffer_scroll_up(con->cells, 1); } } @@ -258,6 +258,6 @@ void kmscon_console_newline(struct kmscon_console *con) con->cursor_y++; if (con->cursor_y >= con->cells_y) { con->cursor_y--; - kmscon_buffer_newline(con->cells); + kmscon_buffer_scroll_up(con->cells, 1); } } diff --git a/src/console.h b/src/console.h index b9157ea..493d613 100644 --- a/src/console.h +++ b/src/console.h @@ -70,7 +70,6 @@ void kmscon_buffer_write(struct kmscon_buffer *buf, unsigned int x, unsigned int y, kmscon_symbol_t ch); kmscon_symbol_t kmscon_buffer_read(struct kmscon_buffer *buf, unsigned int x, unsigned int y); -void kmscon_buffer_newline(struct kmscon_buffer *buf); void kmscon_buffer_scroll_down(struct kmscon_buffer *buf, unsigned int num); void kmscon_buffer_scroll_up(struct kmscon_buffer *buf, unsigned int num); diff --git a/src/console_cell.c b/src/console_cell.c index a8d6e6a..8ef2898 100644 --- a/src/console_cell.c +++ b/src/console_cell.c @@ -840,33 +840,6 @@ kmscon_symbol_t kmscon_buffer_read(struct kmscon_buffer *buf, unsigned int x, return line->cells[x].ch; } -void kmscon_buffer_newline(struct kmscon_buffer *buf) -{ - struct line *nl; - int ret; - - if (!buf) - return; - - ret = new_line(&nl); - if (ret) { - log_warn("console: cannot allocate line (%d); " - "dropping input\n", ret); - return; - } - - if (buf->scroll_fill >= buf->scroll_y) { - link_to_scrollback(buf, buf->scroll_buf[0]); - memmove(buf->scroll_buf, &buf->scroll_buf[1], - (buf->scroll_y - 1) * sizeof(struct line*)); - buf->scroll_buf[buf->scroll_y - 1] = NULL; - buf->scroll_fill--; - } - - buf->scroll_buf[buf->scroll_fill] = nl; - buf->scroll_fill++; -} - void kmscon_buffer_scroll_down(struct kmscon_buffer *buf, unsigned int num) { unsigned int i; diff --git a/tests/test_buffer.c b/tests/test_buffer.c index a255775..d136d5c 100644 --- a/tests/test_buffer.c +++ b/tests/test_buffer.c @@ -87,15 +87,16 @@ static void test1(struct kmscon_buffer *buf) kmscon_buffer_write(buf, 1, 4, ch); kmscon_buffer_write(buf, 3, 4, ch); kmscon_buffer_write(buf, 5, 4, ch); + kmscon_buffer_write(buf, 9, 1, ch); kmscon_buffer_write(buf, 9, 2, ch); print_buf(buf); - kmscon_buffer_resize(buf, 5, 3); + kmscon_buffer_resize(buf, 20, 3); print_buf(buf); kmscon_buffer_resize(buf, 20, 5); print_buf(buf); kmscon_buffer_write(buf, 15, 1, ch); print_buf(buf); - kmscon_buffer_newline(buf); + kmscon_buffer_scroll_up(buf, 1); print_buf(buf); }