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 <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-02-04 14:34:33 +01:00
parent bff87253a8
commit 2b8caca91c
4 changed files with 5 additions and 32 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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);
}