diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-02 07:51:18 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-02 07:51:18 -0300 |
commit | 888511862bc7b0850e2695e3edd46212dc78cc47 (patch) | |
tree | 572598e6b335008a71d6bc76faf6c5be7185d91c /src/nvim/os/time.c | |
parent | 212cb13ca4526350ce761378505536fafb559eab (diff) | |
parent | 6436908ffe1906804a13073dd474e109e8be1d91 (diff) | |
download | rneovim-888511862bc7b0850e2695e3edd46212dc78cc47.tar.gz rneovim-888511862bc7b0850e2695e3edd46212dc78cc47.tar.bz2 rneovim-888511862bc7b0850e2695e3edd46212dc78cc47.zip |
Merge PR #1591 'Prepare to rewrite the terminal UI'
Diffstat (limited to 'src/nvim/os/time.c')
-rw-r--r-- | src/nvim/os/time.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index a4871ef499..3794e813d2 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -6,6 +6,7 @@ #include <uv.h> #include "nvim/os/time.h" +#include "nvim/os/event.h" #include "nvim/vim.h" #include "nvim/term.h" @@ -38,31 +39,22 @@ uint64_t os_hrtime(void) /// @param ignoreinput If true, allow a SIGINT to interrupt us void os_delay(uint64_t milliseconds, bool ignoreinput) { - os_microdelay(milliseconds * 1000, ignoreinput); + if (ignoreinput) { + if (milliseconds > INT_MAX) { + milliseconds = INT_MAX; + } + event_poll_until((int)milliseconds, got_int); + } else { + os_microdelay(milliseconds * 1000); + } } /// Sleeps for a certain amount of microseconds /// /// @param microseconds Number of microseconds to sleep -/// @param ignoreinput If true, allow a SIGINT to interrupt us -void os_microdelay(uint64_t microseconds, bool ignoreinput) +void os_microdelay(uint64_t microseconds) { - int old_tmode; - - if (ignoreinput) { - // Go to cooked mode without echo, to allow SIGINT interrupting us - // here - old_tmode = curr_tmode; - - if (curr_tmode == TMODE_RAW) - settmode(TMODE_SLEEP); - - microdelay(microseconds); - - settmode(old_tmode); - } else { - microdelay(microseconds); - } + microdelay(microseconds); } /// Portable version of POSIX localtime_r() |