mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
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:
parent
ececec4c94
commit
d6c2830850
27 changed files with 635 additions and 464 deletions
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/termios.h"
|
||||
#include "libc/calls/struct/termios.internal.h"
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
@ -119,8 +120,15 @@ const char *(DescribeTermios)(char buf[N], ssize_t rc,
|
|||
{IEXTEN, "IEXTEN"}, //
|
||||
{EXTPROC, "EXTPROC"}, //
|
||||
};
|
||||
append(", .c_lflag=%s",
|
||||
DescribeFlags(b128, 128, kLocal, ARRAYLEN(kLocal), "", tio->c_lflag));
|
||||
append(", "
|
||||
".c_lflag=%s, "
|
||||
".c_cc[VMIN]=%d, "
|
||||
".c_cc[VTIME]=%d, "
|
||||
".c_cc[VINTR]=CTRL(%#c), "
|
||||
".c_cc[VQUIT]=CTRL(%#c)",
|
||||
DescribeFlags(b128, 128, kLocal, ARRAYLEN(kLocal), "", tio->c_lflag),
|
||||
tio->c_cc[VMIN], tio->c_cc[VTIME], CTRL(tio->c_cc[VINTR]),
|
||||
CTRL(tio->c_cc[VQUIT]));
|
||||
|
||||
append("}");
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ textstartup void __init_fds(int argc, char **argv, char **envp) {
|
|||
}
|
||||
fds->p[1].flags = O_WRONLY | O_APPEND;
|
||||
fds->p[2].flags = O_WRONLY | O_APPEND;
|
||||
__veof = CTRL('D');
|
||||
__vintr = CTRL('C');
|
||||
__vquit = CTRL('\\');
|
||||
}
|
||||
|
|
|
@ -18,15 +18,10 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/nomultics.internal.h"
|
||||
|
||||
/**
|
||||
* Controls ANSI prefix for log emissions.
|
||||
*
|
||||
* This should be true in raw tty mode repls.
|
||||
*
|
||||
* @see kprintf(), vflogf(), linenoise()
|
||||
*/
|
||||
char __replmode;
|
||||
char __replstderr;
|
||||
char __ttymagic;
|
||||
char __vintr;
|
||||
char __vquit;
|
||||
unsigned char __replmode;
|
||||
unsigned char __replstderr;
|
||||
unsigned char __ttymagic;
|
||||
unsigned char __veof;
|
||||
unsigned char __vintr;
|
||||
unsigned char __vquit;
|
||||
unsigned char __vtime;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_NOMULTICS_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_NOMULTICS_INTERNAL_H_
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern char __replmode;
|
||||
extern char __replstderr;
|
||||
extern char __ttymagic;
|
||||
extern char __vintr;
|
||||
extern char __vquit;
|
||||
extern unsigned char __replmode;
|
||||
extern unsigned char __replstderr;
|
||||
extern unsigned char __ttymagic;
|
||||
extern unsigned char __veof;
|
||||
extern unsigned char __vintr;
|
||||
extern unsigned char __vquit;
|
||||
extern unsigned char __vtime;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue