* 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). */
| 405 | * (for initial startup and for returning from '!' or ^Z). |
| 406 | */ |
| 407 | void |
| 408 | gettty(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 */ |
| 458 | void |
no test coverage detected