tDraw status line at the bottom - ve - a minimal text editor (work in progress)
 (HTM) git clone git://src.adamsgaard.dk/ve
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 87aab360fcdd4649b2d1f3349f589f51bc69976b
 (DIR) parent be10ead5325b9450f1a985058b8740a088424e3f
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Tue,  6 Aug 2019 10:14:40 +0200
       
       Draw status line at the bottom
       
       Diffstat:
         A byote.h                             |       7 +++++++
         M output.c                            |      21 ++++++++++++++++++++-
       
       2 files changed, 27 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/byote.h b/byote.h
       t@@ -0,0 +1,7 @@
       +#ifndef BYOTE_H_
       +#define BYOTE_H_
       +
       +#define PROGNAME "byote"
       +#define VERSION "0.0.1"
       +
       +#endif
 (DIR) diff --git a/output.c b/output.c
       t@@ -1,8 +1,10 @@
        #include <unistd.h>
        #include <string.h>
        #include <stdlib.h>
       +#include <stdio.h>
        #include "terminal.h"
        #include "output.h"
       +#include "byote.h"
        
        /* reallocate append buffer to hold string s */
        void
       t@@ -23,6 +25,18 @@ ab_free(struct abuf *ab) {
                free(ab->b);
        }
        
       +void
       +draw_status_string(struct abuf *ab)
       +{
       +        char status[80];
       +        int statuslen;
       +        statuslen = snprintf(status, sizeof(status),
       +                             "%s editor -- version %s", PROGNAME, VERSION);
       +        if (statuslen > E.screencols)
       +                statuslen = E.screencols;
       +        ab_append(ab, status, statuslen);
       +}
       +
        /* draw editor screen.
         * show tilde characters after EOF */
        void
       t@@ -30,7 +44,12 @@ editor_draw_rows(struct abuf *ab)
        {
                int y;
                for (y = -1; y < E.screenrows; ++y) {
       -                ab_append(ab, "~", 1);
       +
       +                if (y == E.screenrows-1)
       +                        draw_status_string(ab);
       +                else
       +                        ab_append(ab, "~", 1);
       +
                        ab_append(ab, "\x1b[K", 3); /* erase to end of line */
                        if (y < E.screenrows - 1)
                                ab_append(ab, "\r\n", 2);