From d53a37794b162691692931411c151f89972425f5 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Wed, 24 Dec 2014 12:11:58 -0500 Subject: [PATCH] better compatibility with edge triggered eventloop --- terminal.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/terminal.d b/terminal.d index 40169c4..7a7e52b 100644 --- a/terminal.d +++ b/terminal.d @@ -1668,6 +1668,23 @@ struct RealTimeConsoleInput { InputEvent[] readNextEvents() { terminal.flush(); // make sure all output is sent out before we try to get input + // we want to starve the read, especially if we're called from an edge-triggered + // epoll (which might happen in version=with_eventloop.. impl detail there subject + // to change). + auto initial = readNextEventsHelper(); + + // lol this calls select() inside a function prolly called from epoll but meh, + // it is the simplest thing that can possibly work. The alternative would be + // doing non-blocking reads and buffering in the nextRaw function (not a bad idea + // btw, just a bit more of a hassle). + while(timedCheckForInput(0)) + initial ~= readNextEventsHelper(); + return initial; + } + + // The helper reads just one actual event from the pipe... + version(Posix) + InputEvent[] readNextEventsHelper() { InputEvent[] charPressAndRelease(dchar character) { if((flags & ConsoleInputFlags.releasedKeys)) return [