tRefresh screen size before every redraw - 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 dc3d4c4dbb62543b349bd8a6f47e6a8f734efea3
 (DIR) parent b9155f5bf8853830af6771cf86f226856a46c75e
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Sun, 11 Aug 2019 11:17:17 +0200
       
       Refresh screen size before every redraw
       
       Diffstat:
         M TODO                                |       1 +
         M ve.c                                |      18 +++++++++++++-----
       
       2 files changed, 14 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/TODO b/TODO
       t@@ -1,4 +1,5 @@
        Core functionality:
       +        - Set keypress timeout before redraw
                - Proper handling of command-line arguments
                - Implement procedural keybinds
                - Implementing most Vi binds
 (DIR) diff --git a/ve.c b/ve.c
       t@@ -148,7 +148,7 @@ get_cursor_position(int *rows, int *cols) {
        
                if (buf[0] != '\x1b' || buf[1] != '[')
                        return -1;
       -        if (scanf(&buf[2], "%d;%d", rows, cols) != 2)
       +        if (sscanf(&buf[2], "%d;%d", rows, cols) != 2)
                        return -1;
                return 0;
        }
       t@@ -586,6 +586,16 @@ editor_find(int direction)
        
        /** OUTPUT **/
        
       +void
       +editor_update_screen_size()
       +{
       +        if (get_window_size(&E.screen_rows, &E.screen_columns) == -1)
       +                die("get_window_size in main()");
       +        E.screen_rows--;
       +        if (E.show_status)
       +                E.screen_rows--;
       +}
       +
        /* reallocate append buffer to hold string s */
        void
        ab_append(struct abuf *ab, const char *s, int len)
       t@@ -824,6 +834,7 @@ editor_prompt(char *prompt)
                buf[0] = '\0';
        
                while (1) {
       +                editor_update_screen_size();
                        editor_set_status_message(prompt, buf);
                        editor_refresh_screen();
                        editor_place_cursor(strlen(prompt) - 1 + strlen(buf),
       t@@ -1088,10 +1099,6 @@ init_editor() {
                E.show_status = 0;
                E.file_changed = 0;
                E.find_query = NULL;
       -
       -        if (get_window_size(&E.screen_rows, &E.screen_columns) == -1)
       -                die("get_window_size");
       -        E.screen_rows -= 1;
        }
        
        
       t@@ -1110,6 +1117,7 @@ main(int argc, char* argv[])
                editor_set_status_message("%s %s", PROGNAME, VERSION);
        
                while (1) {
       +                editor_update_screen_size();
                        editor_refresh_screen();
                        editor_process_keypress();
                }