From 096eadbcbb224e9d0febacfad571a9c25934f151 Mon Sep 17 00:00:00 2001 From: Pavel Platto Date: Wed, 16 Apr 2014 08:58:09 +0300 Subject: [PATCH] Added os_isatty --- src/os/input.c | 5 +++++ src/os/input.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/os/input.c b/src/os/input.c index e0a00e006a..5143729698 100644 --- a/src/os/input.c +++ b/src/os/input.c @@ -124,6 +124,11 @@ void os_breakcheck() fill_input_buf(false); } +bool os_isatty(int fd) +{ + return uv_guess_handle(fd) == UV_TTY; +} + // This is a replacement for the old `WaitForChar` function in os_unix.c static InbufPollResult inbuf_poll(int32_t ms) { diff --git a/src/os/input.h b/src/os/input.h index 5eed09d2ee..0d58a33392 100644 --- a/src/os/input.h +++ b/src/os/input.h @@ -13,5 +13,11 @@ int os_inchar(uint8_t *, int, int32_t, int); bool os_char_avail(void); void os_breakcheck(void); +/// Test whether a file descriptor refers to a terminal. +/// +/// @param fd File descriptor. +/// @return `true` if file descriptor refers to a terminal. +bool os_isatty(int fd); + #endif // NEOVIM_OS_INPUT_H