mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Get Fat Emacs working in Windows Console
This commit is contained in:
parent
bf835de612
commit
7100b1cf91
34 changed files with 479 additions and 168 deletions
|
@ -16,6 +16,7 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/dprintf.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
|
@ -62,15 +63,25 @@ int rawmode(void) {
|
|||
once = true;
|
||||
}
|
||||
memcpy(&t, &oldterm, sizeof(t));
|
||||
|
||||
t.c_cc[VMIN] = 1;
|
||||
t.c_cc[VTIME] = 1;
|
||||
|
||||
// emacs does the following to remap ctrl-c to ctrl-g in termios
|
||||
// t.c_cc[VINTR] = CTRL('G');
|
||||
// it can be restored using
|
||||
// (set-quit-char (logxor ?C 0100))
|
||||
// but we are able to polyfill the remapping on windows
|
||||
// please note this is a moot point b/c ISIG is cleared
|
||||
|
||||
t.c_iflag &= ~(INPCK | ISTRIP | PARMRK | INLCR | IGNCR | ICRNL | IXON |
|
||||
IGNBRK | BRKINT);
|
||||
t.c_lflag &= ~(IEXTEN | ICANON | ECHO | ECHONL | ISIG);
|
||||
t.c_cflag &= ~(CSIZE | PARENB);
|
||||
t.c_oflag &= ~OPOST;
|
||||
t.c_oflag |= OPOST | ONLCR;
|
||||
t.c_cflag |= CS8;
|
||||
t.c_iflag |= IUTF8;
|
||||
|
||||
tcsetattr(1, TCSANOW, &t);
|
||||
WRITE(1, ENABLE_SAFE_PASTE);
|
||||
WRITE(1, ENABLE_MOUSE_TRACKING);
|
||||
|
@ -125,8 +136,16 @@ const char *describemouseevent(int e) {
|
|||
return buf + 1;
|
||||
}
|
||||
|
||||
// change the code above to enable ISIG if you want to trigger this
|
||||
// then press ctrl-c or ctrl-\ in your pseudoteletypewriter console
|
||||
void OnSignalThatWontEintrRead(int sig) {
|
||||
dprintf(1, "got %s\n", strsignal(sig));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int e, c, y, x, n, yn, xn;
|
||||
signal(SIGINT, OnSignalThatWontEintrRead);
|
||||
signal(SIGQUIT, OnSignalThatWontEintrRead);
|
||||
xsigaction(SIGTERM, onkilled, 0, 0, NULL);
|
||||
xsigaction(SIGWINCH, onresize, 0, 0, NULL);
|
||||
xsigaction(SIGCONT, onresize, 0, 0, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue