Skip to content

Commit

Permalink
Revert 04746ad; this lets iread
Browse files Browse the repository at this point in the history
inappropriately break up a multi-char input sequence.
Also make WIN32ungetch() push the char on the front of the queue
rather than the back.
  • Loading branch information
gwsw committed Sep 24, 2023
1 parent 5dcf7b5 commit ec906cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions os.c
Expand Up @@ -183,7 +183,7 @@ public int iread(int fd, unsigned char *buf, unsigned int len)
c = getch();
if (c == '\003')
return (READ_INTR);
ungetcc_back(c);
ungetch(c);
}
#endif
#endif
Expand Down Expand Up @@ -264,7 +264,7 @@ public int iread(int fd, unsigned char *buf, unsigned int len)
reading = 0;
return (READ_INTR);
}
ungetcc_back(c);
WIN32ungetch(c);
}
#endif
#endif
Expand Down
19 changes: 11 additions & 8 deletions screen.c
Expand Up @@ -2824,6 +2824,17 @@ static void win32_unget_queue(char ch)
}
}

/*
* Make the next call to WIN32getch return ch.
*/
public void WIN32ungetch(int ch)
{
WIN32_CHAR *wch = (WIN32_CHAR *) ecalloc(1, sizeof(WIN32_CHAR));
wch->wc_ch = ch;
wch->wc_next = win32_queue;
win32_queue = wch;
}

/*
* Get a char from the front of the win32_queue.
*/
Expand Down Expand Up @@ -3041,14 +3052,6 @@ public char WIN32getch(void)
return (win32_get_queue());
}

/*
* Make the next call to WIN32getch return ch.
*/
public void WIN32ungetch(int ch)
{
win32_unget_queue(ch);
}

public void win32_getch_clear(void)
{
while (win32_kbhit())
Expand Down

0 comments on commit ec906cb

Please sign in to comment.