vte: add auto-wrap support
authorDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 29 May 2012 15:07:53 +0000 (17:07 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 29 May 2012 15:07:53 +0000 (17:07 +0200)
VT510 manual says auto-wrap is disabled by default but most applications
(including bash) expect it to be on, therefore we enable it by default.

The console layer already supported it but the vte layer wasn't hooked up.

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

index eefd572..d21f2ff 100644 (file)
@@ -98,7 +98,6 @@ struct kmscon_console {
        /* console cells */
        struct kmscon_buffer *cells;
        bool rel_addr;                  /* is relative addressing used? */
-       bool auto_wrap;                 /* auto wrap on end of line? */
 
        /* cursor */
        unsigned int cursor_x;
@@ -982,7 +981,6 @@ int kmscon_console_new(struct kmscon_console **out)
 
        memset(con, 0, sizeof(*con));
        con->ref = 1;
-       con->auto_wrap = true;
 
        ret = kmscon_buffer_new(&con->cells, 0, 0);
        if (ret)
@@ -1067,7 +1065,7 @@ void kmscon_console_write(struct kmscon_console *con, kmscon_symbol_t ch,
        last = con->cells->scroll_y + con->cells->mtop_y;
 
        if (con->cursor_x >= con->cells->size_x) {
-               if (con->auto_wrap) {
+               if (flags & KMSCON_CONSOLE_WRAP) {
                        con->cursor_x = 0;
                        con->cursor_y++;
                        if (con->cursor_y >= last) {
index 8528b8d..fe65eb9 100644 (file)
@@ -45,6 +45,7 @@ struct kmscon_console;
 /* console objects */
 
 #define KMSCON_CONSOLE_INSERT          0x01
+#define KMSCON_CONSOLE_WRAP            0x02
 
 int kmscon_console_new(struct kmscon_console **out);
 void kmscon_console_ref(struct kmscon_console *con);
index e132b46..314c8a4 100644 (file)
--- a/src/vte.c
+++ b/src/vte.c
@@ -269,6 +269,8 @@ static void write_console(struct kmscon_vte *vte, kmscon_symbol_t sym)
        flags = 0;
        if (vte->flags & FLAG_INSERT_REPLACE_MODE)
                flags |= KMSCON_CONSOLE_INSERT;
+       if (vte->flags & FLAG_AUTO_WRAP_MODE)
+               flags |= KMSCON_CONSOLE_WRAP;
 
        kmscon_console_write(vte->con, sym, &vte->cattr, flags);
 }
@@ -288,6 +290,7 @@ void kmscon_vte_reset(struct kmscon_vte *vte)
        vte->flags |= FLAG_TEXT_CURSOR_MODE;
        vte->flags |= FLAG_AUTO_REPEAT_MODE;
        vte->flags |= FLAG_SEND_RECEIVE_MODE;
+       vte->flags |= FLAG_AUTO_WRAP_MODE;
 
        kmscon_utf8_mach_reset(vte->mach);
        vte->state = STATE_GROUND;