console: add newline function
authorDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 26 Dec 2011 13:24:31 +0000 (14:24 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 26 Dec 2011 13:24:31 +0000 (14:24 +0100)
kmscon_console_newline() can be used to produce a newline. Writing \n doesn't
work as this would write \n as character into the cell and not produce a
newline.
The console does not perform any parsing so we provide a separate function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/console.c
src/console.h

index eaf8558..2ed88b6 100644 (file)
@@ -375,3 +375,16 @@ void kmscon_console_write(struct kmscon_console *con,
        kmscon_buffer_write(con->cells, con->cursor_x, con->cursor_y, ch);
        con->cursor_x++;
 }
+
+void kmscon_console_newline(struct kmscon_console *con)
+{
+       if (!con)
+               return;
+
+       con->cursor_x = 0;
+       con->cursor_y++;
+       if (con->cursor_y >= con->cells_y) {
+               con->cursor_y--;
+               kmscon_buffer_rotate(con->cells);
+       }
+}
index fe0e0b6..2b0cea4 100644 (file)
@@ -104,3 +104,4 @@ void kmscon_console_map(struct kmscon_console *con);
 
 void kmscon_console_write(struct kmscon_console *con,
                                                const struct kmscon_char *ch);
+void kmscon_console_newline(struct kmscon_console *con);