simplify and reduce a draw - sob - simple output bar
 (HTM) git clone git://git.codemadness.org/sob
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 5036846948d44ae0c3ba47da9d26d527ecaa0cfb
 (DIR) parent ea01e94bd58fb239ee51da4d6543c415e3841a49
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Fri, 10 Oct 2014 20:02:19 +0000
       
       simplify and reduce a draw
       
       Diffstat:
         M sob.c                               |      23 ++++++-----------------
       
       1 file changed, 6 insertions(+), 17 deletions(-)
       ---
 (DIR) diff --git a/sob.c b/sob.c
       @@ -209,25 +209,13 @@ line_inserttext(const char *s)
                line.utfpos += ulen;
                line.colpos += clen;
                line.collen = colw(line.line, line.bytesiz);
       -        line_draw();
        }
        
        static void
        line_set(const char *s)
        {
       -        char *p;
       -
       -        strlcpy(line.line, s, sizeof(line.line));
       -        /* remove linefeed and return from string */
       -        if((p = strpbrk(line.line, "\r\n")))
       -                *p = '\0';
       -
       -        line.bytesiz = strlen(line.line);
       -        line.bytepos = line.bytesiz;
       -        line.utflen = utf8len(line.line);
       -        line.utfpos = line.utflen;
       -        line.collen = colw(line.line, line.bytesiz);
       -        line.colpos = line.collen;
       +        memset(&line, 0, sizeof(line));
       +        line_inserttext(s);
        }
        
        /* like mksh, toggle counting of escape codes in prompt with "\x01" */
       @@ -359,8 +347,7 @@ line_cursor_end(void)
        static void
        line_clear(void)
        {
       -        line_cursor_begin();
       -        line_set("");
       +        memset(&line, 0, sizeof(line));
                line_draw();
        }
        
       @@ -479,7 +466,8 @@ static void
        line_newline(void)
        {
                line_out();
       -        line_clear();
       +        memset(&line, 0, sizeof(line));
       +        line_draw();
        }
        
        static void
       @@ -792,6 +780,7 @@ handleinput(const unsigned char *key, size_t len)
                        if(key[0] == '\x1b' || iscntrl(key[0]))
                                return;
                        line_inserttext((char*)key);
       +                line_draw();
                }
        }