From 3e0b077ec236aa26bfeb290f3cd7973ec3fbcb7d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 21 Oct 2018 13:05:22 -0500 Subject: Move start_redraw() to lib/ and have ps.c (top) use it. --- lib/interestingtimes.c | 17 +++++++++++++++++ lib/lib.h | 1 + 2 files changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/interestingtimes.c b/lib/interestingtimes.c index c3ed9f9a..9cf84041 100644 --- a/lib/interestingtimes.c +++ b/lib/interestingtimes.c @@ -258,3 +258,20 @@ void tty_sigreset(int i) tty_reset(); _exit(i ? 128+i : 0); } + +void start_redraw(unsigned *width, unsigned *height) +{ + // If never signaled, do raw mode setup. + if (!toys.signal) { + *width = 80; + *height = 25; + set_terminal(0, 1, 0, 0); + sigatexit(tty_sigreset); + xsignal(SIGWINCH, generic_signal); + } + if (toys.signal != -1) { + toys.signal = -1; + terminal_probesize(width, height); + } + xprintf("\033[H\033[J"); +} diff --git a/lib/lib.h b/lib/lib.h index 136cdab5..98c042c7 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -293,6 +293,7 @@ void tty_esc(char *s); void tty_jump(int x, int y); void tty_reset(void); void tty_sigreset(int i); +void start_redraw(unsigned *width, unsigned *height); // net.c int xsocket(int domain, int type, int protocol); -- cgit v1.2.3