mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
Implement basic canonical mode for Windows
The `cat` command now works properly, when run by itself on the bash command prompt. It's working beautifully so far, and is only missing a few keystrokes for clearing words and lines. Definitely works more well than the one that ships with WIN32 :-)
This commit is contained in:
parent
4825737509
commit
f26a280cda
36 changed files with 320 additions and 231 deletions
|
@ -123,9 +123,6 @@ textstartup void __init_fds(int argc, char **argv, char **envp) {
|
|||
SetupWinStd(fds, 0, kNtStdInputHandle, sockset);
|
||||
SetupWinStd(fds, 1, kNtStdOutputHandle, sockset);
|
||||
SetupWinStd(fds, 2, kNtStdErrorHandle, sockset);
|
||||
__veof = CTRL('D');
|
||||
__vintr = CTRL('C');
|
||||
__vquit = CTRL('\\');
|
||||
}
|
||||
fds->p[1].flags = O_WRONLY | O_APPEND;
|
||||
fds->p[2].flags = O_WRONLY | O_APPEND;
|
||||
|
|
|
@ -800,7 +800,7 @@ privileged static size_t kformat(char *b, size_t n, const char *fmt,
|
|||
// undocumented %r specifier
|
||||
// used for good carriage return
|
||||
// helps integrate loggers with repls
|
||||
if (!__replstderr || __nocolor) {
|
||||
if (!__ttyconf.replstderr || __nocolor) {
|
||||
break;
|
||||
} else {
|
||||
s = "\r\e[K";
|
||||
|
|
|
@ -16,13 +16,17 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/intrin/nomultics.internal.h"
|
||||
|
||||
unsigned char __replmode;
|
||||
unsigned char __replstderr;
|
||||
unsigned char __ttymagic;
|
||||
unsigned char __veof;
|
||||
unsigned char __vintr;
|
||||
unsigned char __vquit;
|
||||
unsigned char __vtime;
|
||||
unsigned char __mousebuttons;
|
||||
struct TtyConf __ttyconf = {
|
||||
.vmin = 1,
|
||||
.veof = CTRL('D'),
|
||||
.vintr = CTRL('C'),
|
||||
.vquit = CTRL('\\'),
|
||||
.verase = CTRL('?'),
|
||||
.vwerase = CTRL('W'),
|
||||
.vkill = CTRL('U'),
|
||||
.vreprint = CTRL('R'),
|
||||
.vlnext = CTRL('V'),
|
||||
};
|
||||
|
|
|
@ -1,18 +1,48 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_NOMULTICS_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_NOMULTICS_INTERNAL_H_
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#ifndef COSMOPOLITAN_NOMULTICS_H_
|
||||
#define COSMOPOLITAN_NOMULTICS_H_
|
||||
|
||||
#define kTtySilence 1 /* do not relay read() into write() */
|
||||
#define kTtyEchoRaw 2 /* don't ^X visualize control codes */
|
||||
#define kTtyUncanon 4 /* enables non-canonical (raw) mode */
|
||||
#define kTtyNoCr2Nl 8 /* don't map \r → \n (a.k.a !ICRNL) */
|
||||
#define kTtyNoIsigs 16 /* don't auto-raise signals on keys */
|
||||
#define kTtyXtMouse 32 /* enables eXtreme Xterm mouse mode */
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
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;
|
||||
extern unsigned char __mousebuttons;
|
||||
struct TtyConf {
|
||||
unsigned char magic;
|
||||
unsigned char mousebs;
|
||||
unsigned char replmode;
|
||||
unsigned char replstderr;
|
||||
union {
|
||||
unsigned char c_cc[20];
|
||||
struct {
|
||||
unsigned char vline;
|
||||
unsigned char vintr; /* SIGINT keystroke (isigs) */
|
||||
unsigned char vquit; /* SIGQUIT keystroke (isigs) */
|
||||
unsigned char verase; /* backspace keystroke (canon) */
|
||||
unsigned char vkill; /* kill line back keystroke (canon) */
|
||||
unsigned char veof; /* EOF keystroke (canon) */
|
||||
unsigned char vtime; /* vtime*100ms can control read delay */
|
||||
unsigned char vmin; /* use 0 for special non-blocking mode */
|
||||
unsigned char vswtc;
|
||||
unsigned char vstart;
|
||||
unsigned char vstop;
|
||||
unsigned char vsusp; /* keystroke for SIGTSTP (isigs) */
|
||||
unsigned char veol;
|
||||
unsigned char vreprint; /* keystroke to print unread line (canon) */
|
||||
unsigned char vdiscard;
|
||||
unsigned char vwerase; /* keystroke for kill word back (canon) */
|
||||
unsigned char vlnext; /* print next keystroke as ascii (canon) */
|
||||
unsigned char veol2;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
extern struct TtyConf __ttyconf;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_NOMULTICS_INTERNAL_H_ */
|
||||
#endif /* COSMOPOLITAN_NOMULTICS_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue