]> git.neil.brown.name Git - edlib.git/commitdiff
ncurses: use redrawwin() to force a window refresh.
authorNeilBrown <neil@brown.name>
Wed, 27 May 2020 11:11:56 +0000 (21:11 +1000)
committerNeilBrown <neil@brown.name>
Mon, 1 Jun 2020 11:10:40 +0000 (21:10 +1000)
I didn't use this before because it is buggy.
In ncurses it fails to redraw the first line if the cursor
is on the first line.
So add a work-around and use it.

I really don't want to have various pane have to redraw everything
because ncurses is busted.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
display-ncurses.c

index 1e78de9c42904b514f176fd60963949afa0e9de4..95b1959d79fdd55ef3d499d31919763df9f16067 100644 (file)
@@ -267,6 +267,8 @@ Module features
 
 ### completion
 
+- [ ] When 'delete' and there is only the original
+      entry of the prefix stack, just delete one character.
 - [ ] mouse selection should work in completion pane
 - [ ] filename completion should work for earlier component of path.
 - [ ] The “complete” popup should be positioned above/below the file name,
@@ -337,6 +339,7 @@ Module features
       stay there.
 - [ ] extend enough that make/grep can use shell mode for running the
       the command, and they just do ui and highlighting
+- [ ] always track time for a run and report it - or at least make it available
 
 ###  edlibclient
 - [ ] run edlib directly if no socket
index 0d23dc08ae171f76ae1284d7bc1ac5f3175175c5..87fbb95976fef868c5b93ae4849e4b01d1d3d3b0 100644 (file)
@@ -805,11 +805,33 @@ REDEF_CMD(handle_winch)
        set_screen(p);
        resize_term(size.ws_row, size.ws_col);
 
-       clear();
        pane_resize(p, 0, 0, size.ws_row, size.ws_col);
        return 1;
 }
 
+DEF_CMD(force_redraw)
+{
+       struct pane *p = ci->home;
+       struct display_data *dd = p->data;
+
+       set_screen(p);
+       if (dd->cursor.y == 0) {
+
+               /* There seems to be an ncurses bug where redrawwin()
+                * doesn't refresh the first line when cursor is on that
+                * line, so move it down temporarily.
+                */
+               move(1, 1);
+               refresh();
+       }
+       redrawwin(curscr);
+       if (dd->cursor.y == 0 && dd->cursor.x >= 0)
+               /* Move cursor back */
+               move(dd->cursor.y, dd->cursor.x);
+       refresh();
+       return 1;
+}
+
 static void ncurses_clear(struct pane *p safe, struct pane *display safe,
                          int attr, short x, short y, short w, short h)
 {
@@ -1117,7 +1139,7 @@ void edlib_init(struct pane *ed safe)
                  "attach-display-ncurses");
 
        nc_map = key_alloc();
-       key_add(nc_map, "Display:refresh", &handle_winch);
+       key_add(nc_map, "Display:refresh", &force_redraw);
        key_add(nc_map, "Display:close", &nc_close_display);
        key_add(nc_map, "Display:set-noclose", &nc_set_noclose);
        key_add(nc_map, "Close", &nc_close);