Fix memzoom on Windows

Right now we can't call poll() on file and fifos on Windows. So we work
around that by simply blocking on keyboard input. This is OK because on
Windows we can't use /proc/*/mem for realtime monitoring, so there's no
reason not to block.

See #65
This commit is contained in:
Justine Tunney 2021-02-27 14:59:26 -08:00
parent f3baa05195
commit cc56038b05
2 changed files with 7 additions and 2 deletions

View file

@ -97,6 +97,7 @@ static noasan textwindows wontreturn void WinMainNew(void) {
SetConsoleCP(kNtCpUtf8);
SetConsoleOutputCP(kNtCpUtf8);
inhand = GetStdHandle(pushpop(kNtStdInputHandle));
SetEnvironmentVariable(u"TERM", u"xterm-truecolor");
GetConsoleMode(inhand, &__ntconsolemode);
SetConsoleMode(inhand, kNtEnableProcessedInput | kNtEnableLineInput |
kNtEnableEchoInput | kNtEnableMouseInput |

View file

@ -318,6 +318,7 @@ static void PreventBufferbloat(void) {
static bool HasPendingInput(void) {
struct pollfd fds[1];
if (IsWindows()) return true; /* XXX */
fds[0].fd = 0;
fds[0].events = POLLIN;
fds[0].revents = 0;
@ -841,16 +842,19 @@ static void RangesZoom(void) {
}
static void MemZoom(void) {
bool ok;
ok = false;
do {
if (action & RESIZED) {
GetTtySize();
SetupCanvas();
action &= ~RESIZED;
}
if (HasPendingInput()) {
if (ok && HasPendingInput()) {
ReadKeyboard();
continue;
if (!IsWindows()) continue; /* XXX */
}
ok = true;
if (pid) {
RangesZoom();
} else {