summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2012-02-04 15:49:14 +0100
committerDavid Herrmann <dh.herrmann@googlemail.com>2012-02-04 15:49:14 +0100
commit466fcc3b06129f95fd11b567c1cbb727cf30a8e4 (patch)
treecdad85cdaaa94426cabdda2a06e1ccbb6b93283a /src
parent497d3840dc370ac4938eea27f9aceeb589adb825 (diff)
console: add auto-wrap mode
If auto-wrap mode is enabled we automatically advance the cursor to the next line if we hit the end of line. Otherwise, we simply continue overwriting the last character in the line. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/console.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/console.c b/src/console.c
index 943d00b..d419f06 100644
--- a/src/console.c
+++ b/src/console.c
@@ -60,6 +60,7 @@ struct kmscon_console {
unsigned int margin_top; /* idx of first scroll line */
unsigned int margin_bottom; /* idx of last scroll line */
bool rel_addr; /* is relative addressing used? */
+ bool auto_wrap; /* auto wrap on end of line? */
/* cursor */
unsigned int cursor_x;
@@ -258,11 +259,15 @@ void kmscon_console_write(struct kmscon_console *con, kmscon_symbol_t ch)
return;
if (con->cursor_x >= con->cells_x) {
- con->cursor_x = 0;
- con->cursor_y++;
- if (con->cursor_y > con->margin_bottom) {
- con->cursor_y--;
- kmscon_buffer_scroll_up(con->cells, 1);
+ if (con->auto_wrap) {
+ con->cursor_x = 0;
+ con->cursor_y++;
+ if (con->cursor_y > con->margin_bottom) {
+ con->cursor_y--;
+ kmscon_buffer_scroll_up(con->cells, 1);
+ }
+ } else {
+ con->cursor_x = con->cells_x - 1;
}
}