From 4b1f21de75f9981007d80aca8355239e8615d6bd Mon Sep 17 00:00:00 2001 From: erw7 Date: Tue, 28 Mar 2017 18:07:58 +0900 Subject: win: support :terminal --- test/functional/fixtures/tty-test.c | 44 +++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'test/functional/fixtures/tty-test.c') diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 7ba21d652a..dd94d1a256 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -15,10 +15,12 @@ uv_tty_t tty; #include bool owns_tty(void) { - HWND consoleWnd = GetConsoleWindow(); - DWORD dwProcessId; - GetWindowThreadProcessId(consoleWnd, &dwProcessId); - return GetCurrentProcessId() == dwProcessId; + /* XXX: We need to make proper detect owns tty */ + /* HWND consoleWnd = GetConsoleWindow(); */ + /* DWORD dwProcessId; */ + /* GetWindowThreadProcessId(consoleWnd, &dwProcessId); */ + /* return GetCurrentProcessId() == dwProcessId; */ + return true; } #else #include @@ -54,16 +56,18 @@ 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 sigwinch_cb(uv_signal_t *handle, int signum) -// { -// int width, height; -// uv_tty_t *tty = handle->data; -// uv_tty_get_winsize(tty, &width, &height); -// fprintf(stderr, "rows: %d, cols: %d\n", height, width); -// } - static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) { buf->len = BUF_SIZE; @@ -88,7 +92,7 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) uv_loop_t write_loop; uv_loop_init(&write_loop); uv_tty_t out; - uv_tty_init(&write_loop, &out, 1, 0); + uv_tty_init(&write_loop, &out, fileno(stdout), 0); 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); @@ -149,7 +153,11 @@ int main(int argc, char **argv) uv_prepare_init(uv_default_loop(), &prepare); uv_prepare_start(&prepare, prepare_cb); // uv_tty_t tty; +#ifndef WIN32 uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1); +#else + uv_tty_init(uv_default_loop(), &tty, fileno(stdin), 1); +#endif uv_tty_set_mode(&tty, UV_TTY_MODE_RAW); tty.data = &interrupted; uv_read_start(STRUCT_CAST(uv_stream_t, &tty), alloc_cb, read_cb); @@ -160,15 +168,17 @@ int main(int argc, char **argv) sa.sa_handler = sig_handler; sigaction(SIGHUP, &sa, NULL); sigaction(SIGWINCH, &sa, NULL); - // uv_signal_t sigwinch_watcher; - // uv_signal_init(uv_default_loop(), &sigwinch_watcher); - // sigwinch_watcher.data = &tty; - // uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH); +#else + 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); +#ifndef WIN32 // XXX: Without this the SIGHUP handler is skipped on some systems. sleep(100); +#endif return 0; } -- cgit From 1614e805b33bf159a7af06ed54a0fb5823d8e407 Mon Sep 17 00:00:00 2001 From: erw7 Date: Fri, 31 Mar 2017 05:40:37 +0900 Subject: win/test: tty-test: print screen size explicitly with CTRL-Q tty-test.exe causes abnormal termination with low repeatability, try changing it so as not to use SIGWINCH. --- test/functional/fixtures/tty-test.c | 53 ++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'test/functional/fixtures/tty-test.c') diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index dd94d1a256..3e71ca209b 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -15,11 +15,11 @@ uv_tty_t tty; #include bool owns_tty(void) { - /* XXX: We need to make proper detect owns tty */ - /* HWND consoleWnd = GetConsoleWindow(); */ - /* DWORD dwProcessId; */ - /* GetWindowThreadProcessId(consoleWnd, &dwProcessId); */ - /* return GetCurrentProcessId() == dwProcessId; */ + // XXX: We need to make proper detect owns tty + // HWND consoleWnd = GetConsoleWindow(); + // DWORD dwProcessId; + // GetWindowThreadProcessId(consoleWnd, &dwProcessId); + // return GetCurrentProcessId() == dwProcessId; return true; } #else @@ -57,15 +57,15 @@ static void sig_handler(int signum) } } #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); -} +// 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) @@ -82,10 +82,14 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) } int *interrupted = stream->data; + bool prsz = false; + int width, height; for (int i = 0; i < cnt; i++) { if (buf->base[i] == 3) { (*interrupted)++; + } else if (buf->base[i] == 17) { + prsz = true; } } @@ -93,10 +97,17 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) uv_loop_init(&write_loop); uv_tty_t out; uv_tty_init(&write_loop, &out, fileno(stdout), 0); - 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); + + if (prsz) { + uv_tty_get_winsize(&out, &width, &height); + fprintf(stderr, "rows: %d, cols: %d\n", height, width); + } else { + 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); + } + uv_close(STRUCT_CAST(uv_handle_t, &out), NULL); uv_run(&write_loop, UV_RUN_DEFAULT); if (uv_loop_close(&write_loop)) { @@ -169,9 +180,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); -- cgit From d3a8c4f99289f7b65a68bf9ed5eeab34aa688e0e Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 2 Apr 2017 18:32:23 +0900 Subject: win/pty: log errors --- test/functional/fixtures/tty-test.c | 60 ++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 11 deletions(-) (limited to 'test/functional/fixtures/tty-test.c') diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 3e71ca209b..60d6f5485b 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -4,15 +4,34 @@ #include #include #include + #include +#ifdef _WIN32 +#include +#endif // -V:STRUCT_CAST:641 #define STRUCT_CAST(Type, obj) ((Type *)(obj)) +#define is_terminal(stream) (uv_guess_handle(fileno(stream)) == UV_TTY) +#define BUF_SIZE 0xfff +#define CTRL_C 0x03 +#ifdef _WIN32 +#define CTRL_Q 0x11 +#endif + +#ifdef _WIN32 +typedef struct screen_size { + int width; + int height; +} ScreenSize; +#endif uv_tty_t tty; +#ifdef _WIN32 +ScreenSize screen_rect; +#endif #ifdef _WIN32 -#include bool owns_tty(void) { // XXX: We need to make proper detect owns tty @@ -30,10 +49,8 @@ bool owns_tty(void) } #endif -#define is_terminal(stream) (uv_guess_handle(fileno(stream)) == UV_TTY) -#define BUF_SIZE 0xfff - -static void walk_cb(uv_handle_t *handle, void *arg) { +static void walk_cb(uv_handle_t *handle, void *arg) +{ if (!uv_is_closing(handle)) { uv_close(handle, NULL); } @@ -42,7 +59,7 @@ static void walk_cb(uv_handle_t *handle, void *arg) { #ifndef WIN32 static void sig_handler(int signum) { - switch(signum) { + switch (signum) { case SIGWINCH: { int width, height; uv_tty_get_winsize(&tty, &width, &height); @@ -82,14 +99,19 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) } int *interrupted = stream->data; +#ifdef _WIN32 bool prsz = false; - int width, height; + int width; + int height; +#endif for (int i = 0; i < cnt; i++) { - if (buf->base[i] == 3) { + if (buf->base[i] == CTRL_C) { (*interrupted)++; - } else if (buf->base[i] == 17) { +#ifdef _WIN32 + } else if (buf->base[i] == CTRL_Q) { prsz = true; +#endif } } @@ -98,15 +120,23 @@ 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 (prsz) { uv_tty_get_winsize(&out, &width, &height); - fprintf(stderr, "rows: %d, cols: %d\n", height, width); + if (screen_rect.width != width || screen_rect.height != height) { + screen_rect.width = width; + screen_rect.height = height; + fprintf(stderr, "rows: %d, cols: %d\n", height, width); + } } 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 uv_close(STRUCT_CAST(uv_handle_t, &out), NULL); uv_run(&write_loop, UV_RUN_DEFAULT); @@ -152,7 +182,7 @@ int main(int argc, char **argv) if (argc > 1) { int count = atoi(argv[1]); - for (int i = 0; i < count; ++i) { + for (int i = 0; i < count; i++) { printf("line%d\n", i); } fflush(stdout); @@ -168,6 +198,14 @@ int main(int argc, char **argv) uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1); #else uv_tty_init(uv_default_loop(), &tty, fileno(stdin), 1); + uv_tty_t out; + uv_tty_init(uv_default_loop(), &out, fileno(stdout), 0); + int width; + int height; + uv_tty_get_winsize(&out, &width, &height); + screen_rect.width = width; + screen_rect.height = height; + uv_close((uv_handle_t *)&out, NULL); #endif uv_tty_set_mode(&tty, UV_TTY_MODE_RAW); tty.data = &interrupted; -- cgit From 6a90f53862d9f75f7aeea350944c466aa85f11a2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 6 Aug 2017 14:26:17 +0200 Subject: test: cleanup --- test/functional/fixtures/tty-test.c | 48 +++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'test/functional/fixtures/tty-test.c') diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 60d6f5485b..2b22352cda 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -4,10 +4,11 @@ #include #include #include - #include #ifdef _WIN32 -#include +# include +#else +# include #endif // -V:STRUCT_CAST:641 @@ -15,39 +16,31 @@ #define is_terminal(stream) (uv_guess_handle(fileno(stream)) == UV_TTY) #define BUF_SIZE 0xfff #define CTRL_C 0x03 -#ifdef _WIN32 #define CTRL_Q 0x11 -#endif + +uv_tty_t tty; #ifdef _WIN32 typedef struct screen_size { int width; int height; } ScreenSize; -#endif - -uv_tty_t tty; -#ifdef _WIN32 ScreenSize screen_rect; #endif -#ifdef _WIN32 bool owns_tty(void) { +#ifdef _WIN32 // XXX: We need to make proper detect owns tty // HWND consoleWnd = GetConsoleWindow(); // DWORD dwProcessId; // GetWindowThreadProcessId(consoleWnd, &dwProcessId); // return GetCurrentProcessId() == dwProcessId; return true; -} #else -#include -bool owns_tty(void) -{ return getsid(0) == getpid(); -} #endif +} static void walk_cb(uv_handle_t *handle, void *arg) { @@ -56,7 +49,6 @@ static void walk_cb(uv_handle_t *handle, void *arg) } } -#ifndef WIN32 static void sig_handler(int signum) { switch (signum) { @@ -73,17 +65,6 @@ 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) { @@ -100,9 +81,9 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) int *interrupted = stream->data; #ifdef _WIN32 - bool prsz = false; - int width; - int height; + // HACK: Special-case to avoid relying on SIGWINCH on Windows. + // See note at Screen:try_resize(). + bool invoke_sigwinch_handler = false; #endif for (int i = 0; i < cnt; i++) { @@ -110,7 +91,7 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) (*interrupted)++; #ifdef _WIN32 } else if (buf->base[i] == CTRL_Q) { - prsz = true; + invoke_sigwinch_handler = true; #endif } } @@ -121,12 +102,15 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) uv_tty_init(&write_loop, &out, fileno(stdout), 0); #ifdef _WIN32 - if (prsz) { + 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; - fprintf(stderr, "rows: %d, cols: %d\n", height, width); + // HACK: Invoke directly. See note at Screen:try_resize(). + sig_handler(SIGWINCH); + uv_run(&write_loop, UV_RUN_NOWAIT); } } else { #endif -- cgit From e0763e94ade67c99f9d9f46cd51299b174969927 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 7 Aug 2017 00:26:43 +0200 Subject: test: tty-test.c: restore win32 SIGWINCH handler --- test/functional/fixtures/tty-test.c | 50 +++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'test/functional/fixtures/tty-test.c') 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); -- cgit From 91c85a6378e93b6ef0415c47ca7cb03bf1d57e2d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 13 Aug 2017 15:24:25 +0200 Subject: test: tty-test.c: keep `tty_out` handle around Now the window_split_tab_spec.lua test seems to work. Also do some cleanup. --- test/functional/fixtures/tty-test.c | 64 +++++++------------------------------ 1 file changed, 11 insertions(+), 53 deletions(-) (limited to 'test/functional/fixtures/tty-test.c') diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 9373e2d7ed..edcbe23f86 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -16,17 +16,9 @@ #define is_terminal(stream) (uv_guess_handle(fileno(stream)) == UV_TTY) #define BUF_SIZE 0xfff #define CTRL_C 0x03 -#define CTRL_Q 0x11 uv_tty_t tty; - -#ifdef _WIN32 -typedef struct screen_size { - int width; - int height; -} ScreenSize; -ScreenSize screen_rect; -#endif +uv_tty_t tty_out; bool owns_tty(void) { @@ -49,7 +41,6 @@ static void walk_cb(uv_handle_t *handle, void *arg) } } -#ifndef WIN32 static void sig_handler(int signum) { switch (signum) { @@ -66,15 +57,13 @@ static void sig_handler(int signum) return; } } -#else + +#ifdef WIN32 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); + uv_tty_get_winsize(&tty_out, &width, &height); fprintf(stderr, "rows: %d, cols: %d\n", height, width); - uv_close((uv_handle_t *)&out, NULL); } #endif @@ -92,19 +81,10 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) } int *interrupted = stream->data; -#ifdef _WIN32 - // HACK: Special-case to avoid relying on SIGWINCH on Windows. - // See note at Screen:try_resize(). - bool invoke_sigwinch_handler = false; -#endif for (int i = 0; i < cnt; i++) { if (buf->base[i] == CTRL_C) { (*interrupted)++; -#ifdef _WIN32 - } else if (buf->base[i] == CTRL_Q) { - invoke_sigwinch_handler = true; -#endif } } @@ -113,26 +93,10 @@ 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 - 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 + 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); uv_close(STRUCT_CAST(uv_handle_t, &out), NULL); uv_run(&write_loop, UV_RUN_DEFAULT); @@ -189,19 +153,13 @@ int main(int argc, char **argv) uv_prepare_t prepare; uv_prepare_init(uv_default_loop(), &prepare); uv_prepare_start(&prepare, prepare_cb); - // uv_tty_t tty; #ifndef WIN32 uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1); #else uv_tty_init(uv_default_loop(), &tty, fileno(stdin), 1); - uv_tty_t out; - uv_tty_init(uv_default_loop(), &out, fileno(stdout), 0); - int width; - int height; - uv_tty_get_winsize(&out, &width, &height); - screen_rect.width = width; - screen_rect.height = height; - uv_close((uv_handle_t *)&out, NULL); + uv_tty_init(uv_default_loop(), &tty_out, fileno(stdout), 0); + int width, height; + uv_tty_get_winsize(&tty_out, &width, &height); #endif uv_tty_set_mode(&tty, UV_TTY_MODE_RAW); tty.data = &interrupted; -- cgit