diff options
Diffstat (limited to 'vui.c')
| -rw-r--r-- | vui.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -55,6 +55,10 @@ static VuiKey esc_key(u32 c); /* output */ +static VuiAttr attr_last = A_DEFAULT; +static unsigned cur_x = 0; +static unsigned cur_y = 0; + static void vui_out_fit(size_t n); static void vui_outf(const char *fmt, ...); static inline void vui_outc(char c); @@ -227,10 +231,15 @@ void vui_enable(void) { tcsetattr(STDIN_FILENO, TCSANOW, &vui_tos_raw); } +static inline void clear_and_reset(void) { + printf(CSI "H" CSI "2J" CSI "0m"); + fflush(stdout); + attr_last = A_DEFAULT; +} + void vui_disable(void) { tcsetattr(STDIN_FILENO, TCSANOW, &vui_tos_src); - printf("\x1b[H\x1b[2J\x1b[0m"); - fflush(stdout); + clear_and_reset(); } void vui_redraw(void) { @@ -239,6 +248,7 @@ void vui_redraw(void) { if (w != COLS || h != LINES) resize_win(w, h); win.redraw_all = 1; if (win.redraw_fn) win.redraw_fn(win.redraw_ctx); + clear_and_reset(); vui_blit(); } @@ -489,10 +499,6 @@ chg_colors:; void vui_scroll_buf(VuiBuffer *b, int dx, int dy); -static VuiAttr attr_last = A_DEFAULT; -static unsigned cur_x = 0; -static unsigned cur_y = 0; - static void emit_scroll_x(u32 y) { if (win.scroll_x < 0) { /* delete chars at start of line */ |
