Compare commits

...

4 Commits
r3 ... master

Author SHA1 Message Date
Kelvin Sherlock 4da75367c1 (re)set the controlling terminal.
This is necessary to read input from the console (via the Event Manager) since opening a pseudo terminal screws up the controlling terminal (and there is no O_NOCTTY flag).
2019-10-03 00:05:21 -04:00
Kelvin Sherlock d77291a0c0 default tabstops were off by 1. 2019-01-08 20:33:38 -05:00
Kelvin Sherlock d3addc3050 esc [ 3 g is clear all tabs. was esc [ 5 g . 2019-01-08 19:31:39 -05:00
Kelvin Sherlock 2079d4b442 ADB extended keycodes (from OS X Events) 2019-01-04 21:15:08 -05:00
3 changed files with 54 additions and 11 deletions

View File

@ -19,7 +19,7 @@ marlene: $(MARLENE_OBJS) $(COMMON_OBJS)
darlene: $(DARLENE_OBJS) $(COMMON_OBJS)
$(CC) -lutil -o $@ $^
iix chtyp -a 0xdc00 $@
# iix chtyp -a 0xdc00 $@

View File

@ -192,6 +192,11 @@ int main(int argc, char **argv) {
return 1;
}
if (!isatty(STDIN_FILENO)) {
ErrWriteCString("stdin required.\r\n");
return 1;
}
term_var.value = "\x05\x00vt100";
child_argv = NULL;
for (i = 1; i < argc; ++i) {
@ -260,6 +265,11 @@ int main(int argc, char **argv) {
goto _exit;
}
/* reset the controlling terminal, which was clobbered by opening a pty */
/* standard TIOCSCTTY causes ORCA/C shift errors */
#undef TIOCSCTTY
#define TIOCSCTTY (0x20000000ul | ('t' << 8) | 97)
ioctl(STDIN_FILENO, TIOCSCTTY, (void *)0);
for(;;) {

53
vt100.c
View File

@ -100,11 +100,11 @@ void vt100_init(unsigned flags)
LNM = flags & vtLNM;
}
tabs[0] = 0x8080;
tabs[1] = 0x8080;
tabs[2] = 0x8080;
tabs[3] = 0x8080;
tabs[4] = 0x0080;
tabs[0] = 0x0100;
tabs[1] = 0x0101;
tabs[2] = 0x0101;
tabs[3] = 0x0101;
tabs[4] = 0x0101;
parms[0] = 0;
parm_count = 0;
@ -355,7 +355,7 @@ static void clear_tabs(void) {
tabs[chunk] &= ~mask;
}
break;
case 5:
case 3:
tabs[0] = 0;
tabs[1] = 0;
tabs[2] = 0;
@ -649,6 +649,39 @@ void vt100_process(const unsigned char *buffer, unsigned buffer_size) {
ShowCursor(__x, __y);
}
/* adb codes for extended keys. passed as-is with keypad bit set */
/* nb - kegs gobbles up fkeys for his own use */
enum {
kVK_F17 = 0x40,
kVK_VolumeUp = 0x48,
kVK_VolumeDown = 0x49,
kVK_Mute = 0x4A,
kVK_F18 = 0x4F,
kVK_F19 = 0x50,
kVK_F20 = 0x5A,
kVK_F5 = 0x60,
kVK_F6 = 0x61,
kVK_F7 = 0x62,
kVK_F3 = 0x63,
kVK_F8 = 0x64,
kVK_F9 = 0x65,
kVK_F11 = 0x67,
kVK_F13 = 0x69,
kVK_F16 = 0x6A,
kVK_F14 = 0x6B,
kVK_F10 = 0x6D,
kVK_F12 = 0x6F,
kVK_F15 = 0x71,
kVK_Help = 0x72,
kVK_Home = 0x73,
kVK_PageUp = 0x74,
kVK_ForwardDelete = 0x75,
kVK_F4 = 0x76,
kVK_End = 0x77,
kVK_F2 = 0x78,
kVK_PageDown = 0x79,
kVK_F1 = 0x7A
};
//
// remap the iigs key to a vt100 code (if necessary) and send it out.
@ -724,22 +757,22 @@ void vt100_event(EventRecord *event) {
break;
case 0x7a: // f1
case kVK_F1: // f1
if (DECANM) { cp = ESC "OP"; len = 3; }
else { cp = ESC "P"; len = 2; }
break;
case 0x78: // f2
case kVK_F2: // f2
if (DECANM) { cp = ESC "OQ"; len = 3; }
else { cp = ESC "Q"; len = 2; }
break;
case 0x63: // f3
case kVK_F3: // f3
if (DECANM) { cp = ESC "OR"; len = 3; }
else { cp = ESC "R"; len = 2; }
break;
case 0x76: // f4
case kVK_F4: // f4
if (DECANM) { cp = ESC "OS"; len = 3; }
else { cp = ESC "S"; len = 2; }
break;