MCPcopy Create free account
hub / github.com/NetHack/NetHack / gettty

Function gettty

sys/vms/vmstty.c:407–455  ·  view source on GitHub ↗

* Get initial state of terminal, set ospeed (for termcap routines) * and switch off tab expansion if necessary. * Called by init_nhwindows() and resume_nhwindows() in wintty.c * (for initial startup and for returning from '!' or ^Z). */

Source from the content-addressed store, hash-verified

405 * (for initial startup and for returning from '!' or ^Z).
406 */
407void
408gettty(void)
409{
410 static char dev_tty[] = "TT:";
411 static $DESCRIPTOR(tty_dsc, dev_tty);
412 int err = 0;
413 unsigned long status, zero = 0;
414
415 if (tt_chan == 0) { /* do this stuff once only */
416 iflags.cbreak = OFF, iflags.echo = ON; /* until setup is complete */
417 status = sys$assign(&tty_dsc, &tt_chan, 0, 0);
418 if (!vms_ok(status)) {
419 raw_print(""), err++;
420 errno = EVMSERR, vaxc$errno = status;
421 perror("NetHack(gettty: $assign)");
422 }
423 atexit(resettty); /* register an exit handler to reset things */
424 }
425 status = sys$qiow(0, tt_chan, IO$_SENSEMODE, &sg.io, (void (*) ()) 0, 0,
426 &sg.sm, sizeof sg.sm, 0, 0, 0, 0);
427 if (vms_ok(status))
428 status = sg.io.status;
429 if (!vms_ok(status)) {
430 raw_print(""), err++;
431 errno = EVMSERR, vaxc$errno = status;
432 perror("NetHack(gettty: sensemode)");
433 }
434 ospeed = sg.io.xmt_speed;
435 erase_char = '\177'; /* <rubout>, aka <delete> */
436 kill_char = CTRL('U');
437 intr_char = CTRL('C');
438 (void) lib$enable_ctrl(&zero, &ctrl_mask);
439 /* Use the systems's values for lines and columns if it has any idea. */
440 if (sg.sm.page_length)
441 LI = sg.sm.page_length;
442 if (sg.sm.page_width)
443 CO = sg.sm.page_width;
444 /* suppress tab and form-feed expansion, in case termcap uses them */
445 tt_char_restore = sg.sm.tt_char;
446 tt_char_active = sg.sm.tt_char |= TT_SPECIAL_HANDLING;
447 tt2_char_restore = sg.sm.tt2_char;
448 tt2_char_active = sg.sm.tt2_char |= TT2_SPECIAL_HANDLING;
449#if 0 /*[ defer until setftty() ]*/
450 setctty();
451#endif
452
453 if (err)
454 wait_synch();
455}
456
457/* reset terminal to original state */
458void

Callers 2

tty_init_nhwindowsFunction · 0.50
tty_resume_nhwindowsFunction · 0.50

Calls 4

raw_printFunction · 0.85
atexitFunction · 0.85
wait_synchFunction · 0.85
setcttyFunction · 0.70

Tested by

no test coverage detected