diff options
Diffstat (limited to 'test/functional/fixtures/tty-test.c')
-rw-r--r-- | test/functional/fixtures/tty-test.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 2b22352cda..9373e2d7ed 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -49,6 +49,7 @@ static void walk_cb(uv_handle_t *handle, void *arg) } } +#ifndef WIN32 static void sig_handler(int signum) { switch (signum) { @@ -65,6 +66,17 @@ static void sig_handler(int signum) return; } } +#else +static void sigwinch_cb(uv_signal_t *handle, int signum) +{ + int width, height; + uv_tty_t out; + uv_tty_init(uv_default_loop(), &out, fileno(stdout), 0); + uv_tty_get_winsize(&out, &width, &height); + fprintf(stderr, "rows: %d, cols: %d\n", height, width); + uv_close((uv_handle_t *)&out, NULL); +} +#endif static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) { @@ -101,26 +113,26 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) uv_tty_t out; uv_tty_init(&write_loop, &out, fileno(stdout), 0); -#ifdef _WIN32 - if (invoke_sigwinch_handler) { - int width, height; - uv_tty_get_winsize(&out, &width, &height); - if (screen_rect.width != width || screen_rect.height != height) { - screen_rect.width = width; - screen_rect.height = height; - // HACK: Invoke directly. See note at Screen:try_resize(). - sig_handler(SIGWINCH); - uv_run(&write_loop, UV_RUN_NOWAIT); - } - } else { -#endif +// #ifdef _WIN32 +// if (invoke_sigwinch_handler) { +// int width, height; +// uv_tty_get_winsize(&out, &width, &height); +// if (screen_rect.width != width || screen_rect.height != height) { +// screen_rect.width = width; +// screen_rect.height = height; +// // HACK: Invoke directly. See note at Screen:try_resize(). +// sig_handler(SIGWINCH); +// uv_run(&write_loop, UV_RUN_NOWAIT); +// } +// } else { +// #endif uv_write_t req; uv_buf_t b = {.base = buf->base, .len = (size_t)cnt}; uv_write(&req, STRUCT_CAST(uv_stream_t, &out), &b, 1, NULL); uv_run(&write_loop, UV_RUN_DEFAULT); -#ifdef _WIN32 - } -#endif +// #ifdef _WIN32 +// } +// #endif uv_close(STRUCT_CAST(uv_handle_t, &out), NULL); uv_run(&write_loop, UV_RUN_DEFAULT); @@ -202,9 +214,9 @@ int main(int argc, char **argv) sigaction(SIGHUP, &sa, NULL); sigaction(SIGWINCH, &sa, NULL); #else - // uv_signal_t sigwinch_watcher; - // uv_signal_init(uv_default_loop(), &sigwinch_watcher); - // uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH); + uv_signal_t sigwinch_watcher; + uv_signal_init(uv_default_loop(), &sigwinch_watcher); + uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH); #endif uv_run(uv_default_loop(), UV_RUN_DEFAULT); |