Rewrite Windows console input handling

This change removes our use of ENABLE_VIRTUAL_TERMINAL_INPUT (which
isn't very good) in favor of having read() translate Windows Console
input events to ANSI/XTERM sequences by hand. This makes it possible to
capture important keystrokes (e.g. ctrl-space) that weren't possible
before. Most importantly this change also removes the stdin/sigwinch
worker threads, which never really worked that well. Interactive TTY
sessions will now work reliably when a Cosmo process spawns or forks
another Cosmo process, e.g. unbourne.com launching emacs.com.
This commit is contained in:
Justine Tunney 2023-09-19 11:42:38 -07:00
parent ececec4c94
commit d6c2830850
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
27 changed files with 635 additions and 464 deletions

View file

@ -9,17 +9,35 @@ struct NtKeyEventRecord {
uint16_t wVirtualKeyCode;
uint16_t wVirtualScanCode;
union {
int16_t UnicodeChar;
uint16_t UnicodeChar;
char AsciiChar;
} uChar;
unsigned int dwControlKeyState;
#define kNtRightAltPressed 0x0001
#define kNtLeftAltPressed 0x0002
#define kNtRightCtrlPressed 0x0004
#define kNtLeftCtrlPressed 0x0008
#define kNtShiftPressed 0x0010
#define kNtNumlockOn 0x0020
#define kNtScrolllockOn 0x0040
#define kNtCapslockOn 0x0080
#define kNtEnhancedKey 0x0100
};
struct NtMouseEventRecord {
struct NtCoord dwMousePosition;
uint32_t dwButtonState;
#define kNtFromLeft1stButtonPressed 0x0001
#define kNtRightmostButtonPressed 0x0002
#define kNtFromLeft2ndButtonPressed 0x0004
#define kNtFromLeft3rdButtonPressed 0x0008
#define kNtFromLeft4thButtonPressed 0x0010
uint32_t dwControlKeyState;
uint32_t dwEventFlags;
#define kNtMouseMoved 0x0001
#define kNtDoubleClick 0x0002
#define kNtMouseWheeled 0x0004
#define kNtMouseHwheeled 0x0008
};
struct NtWindowBufferSizeRecord {
@ -36,6 +54,11 @@ struct NtFocusEventRecord {
struct NtInputRecord {
uint16_t EventType;
#define kNtKeyEvent 0x0001
#define kNtMouseEvent 0x0002
#define kNtWindowBufferSizeEvent 0x0004
#define kNtMenuEvent 0x0008
#define kNtFocusEvent 0x0010
union {
struct NtKeyEventRecord KeyEvent;
struct NtMouseEventRecord MouseEvent;