comparison src/term.c @ 53226:dd3018b4785b

Implemented multiple tty support. README.multi-tty: New file. src/termchar.h (struct terminal): Renamed to struct tty_output. Added name, type, input, output, termscript, old_tty, term_initted, old_tty_valid, background_pixel, foreground_pixel, next fields. (TERMINAL_*): Renamed to TTY_* for brevity. (CURRENT_TERMINAL): Renamed to CURTTY for brevity. (tty_list): New variable. (TERMINAL_PTR): Removed. (FRAME_TTY): New function. (TTY_NAME, TTY_TYPE): New macros. src/term.c (current_terminal): Removed. (_current_terminal): Removed. (tty_list): New variable. (OUTPUT, OUTPUT1, OUTPUTL, OUTPUT_IF, OUTPUT1_IF): Added tty parameter. (set_terminal_modes): Added tty parameter. (reset_terminal_modes): Added tty parameter. (cursor_to, raw_cursor_to): Updated cmgoto() calls. (clear_end_of_line, write_glyphs): Add indirection to terminal output, updated cmcheckmagic() calls. (get_named_tty): New function. (term_dummy_init): New function. (term_init): Added name parameter, added tty_output return value. Changed algorithm to update tty_list. Call init_sys_modes() to set up tty mode on the newly opened terminal device. (get_current_tty): New function, intended for debugging. src/termhooks.h (termscript): Removed. src/w32term.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Removed redundant definition. src/macterm.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Ditto. src/window.c (init_window_once): Call make_terminal_frame with two zero parameters. src/cm.h (emacs_tputs): New macro to set current_tty, and then call tputs(). (current_tty): New variable, for cmputc(). (cmcheckmagic, cmputc, cmgoto): Added prototypes. src/cm.c (current_tty): New variable, for cmputc(). (cmputc): Use it. (cmcheckmagic): Added tty parameter, look up terminal streams there. (calccost): Added tty parameter. Use emacs_tputs() instead of tputs(). (cmgoto): Added tty parameter. Pass it on to calccost(). Use emacs_tputs() instead of tputs(). src/dispextern.h (set_terminal_modes, reset_terminal_modes): Added tty parameter. (term_init): Added name parameter (the filename of the terminal device). Added return value (struct tty_output). src/dispnew.c: Replace CURTTY() with local variables throughout the file (where applicable). (termscript): Moved to struct tty_output. (terminal_type): Removed. src/emacs.c (main): Don't call init_sys_modes(), the new term_init() already does that during init_display(). (shut_down_emacs): Call reset_all_sys_modes() instead of reset_sys_modes(). src/frame.c (Qtty, Qtty_type): New variables. (syms_of_frame): Initialize them. (tty_display): Removed. (make_terminal_frame): New parameters (tty filename and type). Initialize output_data.tty field instead of output_data.x. Use term_init() to find the right tty_output. (Use term_dummy_init() during bootstrap.) (Fmake_terminal_frame): Get device filename and type from frame parameters. src/frame.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Do the right thing if the frame is a tty. (struct frame): New member in output_data: tty. (make_terminal_frame): Updated of prototype. src/keyboard.c (Fset_input_mode): Call reset_all_sys_modes(), not reset_sys_modes(). Ditto with init_sys_modes(). src/lisp.h (tty_output): Added forward declaration. (init_sys_modes, reset_sys_modes): Updated prototype. (init_all_sys_modes, reset_all_sys_modes): New prototypes. src/scroll.c: Replace CURTTY() with local variables throughout the file (where applicable). src/sysdep.c (old_tty, term_initted, old_tty_valid): Moved to struct tty_output.( (init_all_sys_modes): New function. (init_sys_modes): Added tty_output parameter. Use it. (reset_all_sys_modes): New function. (reset_sys_modes): Added tty_output parameter. Use it. src/Makefile.in: Update dependencies. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-2
author Karoly Lorentey <lorentey@elte.hu>
date Thu, 25 Dec 2003 06:59:31 +0000
parents 4250e7e26247
children 1595c5e1e9bb
comparison
equal deleted inserted replaced
53225:4250e7e26247 53226:dd3018b4785b
24 #include <config.h> 24 #include <config.h>
25 #include <stdio.h> 25 #include <stdio.h>
26 #include <ctype.h> 26 #include <ctype.h>
27 #include <string.h> 27 #include <string.h>
28 28
29 #include <sys/file.h>
30
31 #include "systty.h" /* For emacs_tty in termchar.h */
29 #include "termchar.h" 32 #include "termchar.h"
30 #include "termopts.h" 33 #include "termopts.h"
31 #include "lisp.h" 34 #include "lisp.h"
32 #include "charset.h" 35 #include "charset.h"
33 #include "coding.h" 36 #include "coding.h"
58 #endif 61 #endif
59 #ifdef MAC_OS 62 #ifdef MAC_OS
60 #include "macterm.h" 63 #include "macterm.h"
61 #endif 64 #endif
62 65
66 #ifndef O_RDWR
67 #define O_RDWR 2
68 #endif
69
63 static void turn_on_face P_ ((struct frame *, int face_id)); 70 static void turn_on_face P_ ((struct frame *, int face_id));
64 static void turn_off_face P_ ((struct frame *, int face_id)); 71 static void turn_off_face P_ ((struct frame *, int face_id));
65 static void tty_show_cursor P_ ((void)); 72 static void tty_show_cursor P_ ((void));
66 static void tty_hide_cursor P_ ((void)); 73 static void tty_hide_cursor P_ ((void));
67 74
68 #define OUTPUT(a) \ 75 #define OUTPUT(tty, a) \
69 tputs (a, (int) (FRAME_LINES (XFRAME (selected_frame)) - curY), cmputc) 76 emacs_tputs ((tty), a, (int) (FRAME_LINES (XFRAME (selected_frame)) - curY), cmputc)
70 #define OUTPUT1(a) tputs (a, 1, cmputc) 77 #define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc)
71 #define OUTPUTL(a, lines) tputs (a, lines, cmputc) 78 #define OUTPUTL(tty, a, lines) emacs_tputs ((tty), a, lines, cmputc)
72 79
73 #define OUTPUT_IF(a) \ 80 #define OUTPUT_IF(tty, a) \
74 do { \ 81 do { \
75 if (a) \ 82 if (a) \
76 tputs (a, (int) (FRAME_LINES (XFRAME (selected_frame)) \ 83 emacs_tputs ((tty), a, (int) (FRAME_LINES (XFRAME (selected_frame)) \
77 - curY), cmputc); \ 84 - curY), cmputc); \
78 } while (0) 85 } while (0)
79 86
80 #define OUTPUT1_IF(a) do { if (a) tputs (a, 1, cmputc); } while (0) 87 #define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0)
81 88
82 /* Function to use to ring the bell. */ 89 /* Function to use to ring the bell. */
83 90
84 Lisp_Object Vring_bell_function; 91 Lisp_Object Vring_bell_function;
85 92
86 /* Terminal characteristics that higher levels want to look at. */ 93 /* Terminal characteristics that higher levels want to look at. */
87 static struct terminal _current_terminal; 94
88 TERMINAL_PTR current_terminal = &_current_terminal; 95 struct tty_output *tty_list;
89 96
90 /* Nonzero means no need to redraw the entire frame on resuming 97 /* Nonzero means no need to redraw the entire frame on resuming
91 a suspended Emacs. This is useful on terminals with multiple pages, 98 a suspended Emacs. This is useful on terminals with multiple pages,
92 where one page is used for Emacs and another for all else. */ 99 where one page is used for Emacs and another for all else. */
93 int no_redraw_on_reenter; 100 int no_redraw_on_reenter;
419 426
420 Vring_bell_function = function; 427 Vring_bell_function = function;
421 } 428 }
422 else if (!FRAME_TERMCAP_P (XFRAME (selected_frame))) 429 else if (!FRAME_TERMCAP_P (XFRAME (selected_frame)))
423 (*ring_bell_hook) (); 430 (*ring_bell_hook) ();
424 else 431 else {
425 OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell); 432 OUTPUT (CURTTY (), TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell);
433 }
426 } 434 }
427 435
428 void 436 void
429 set_terminal_modes () 437 set_terminal_modes (struct tty_output *tty)
430 { 438 {
431 if (FRAME_TERMCAP_P (XFRAME (selected_frame))) 439 if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
432 { 440 {
433 OUTPUT_IF (TS_termcap_modes); 441 OUTPUT_IF (tty, TS_termcap_modes);
434 OUTPUT_IF (TS_cursor_visible); 442 OUTPUT_IF (tty, TS_cursor_visible);
435 OUTPUT_IF (TS_keypad_mode); 443 OUTPUT_IF (tty, TS_keypad_mode);
436 losecursor (); 444 losecursor ();
437 } 445 }
438 else 446 else
439 (*set_terminal_modes_hook) (); 447 (*set_terminal_modes_hook) ();
440 } 448 }
441 449
442 void 450 void
443 reset_terminal_modes () 451 reset_terminal_modes (struct tty_output *tty)
444 { 452 {
445 if (FRAME_TERMCAP_P (XFRAME (selected_frame))) 453 if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
446 { 454 {
447 turn_off_highlight (); 455 turn_off_highlight ();
448 turn_off_insert (); 456 turn_off_insert ();
449 OUTPUT_IF (TS_end_keypad_mode); 457 OUTPUT_IF (tty, TS_end_keypad_mode);
450 OUTPUT_IF (TS_cursor_normal); 458 OUTPUT_IF (tty, TS_cursor_normal);
451 OUTPUT_IF (TS_end_termcap_modes); 459 OUTPUT_IF (tty, TS_end_termcap_modes);
452 OUTPUT_IF (TS_orig_pair); 460 OUTPUT_IF (tty, TS_orig_pair);
453 /* Output raw CR so kernel can track the cursor hpos. */ 461 /* Output raw CR so kernel can track the cursor hpos. */
462 current_tty = tty;
454 cmputc ('\r'); 463 cmputc ('\r');
455 } 464 }
456 else if (reset_terminal_modes_hook) 465 else if (reset_terminal_modes_hook)
457 (*reset_terminal_modes_hook) (); 466 (*reset_terminal_modes_hook) ();
458 } 467 }
488 int size; 497 int size;
489 { 498 {
490 if (FRAME_TERMCAP_P (updating_frame)) 499 if (FRAME_TERMCAP_P (updating_frame))
491 { 500 {
492 specified_window = size ? size : FRAME_LINES (updating_frame); 501 specified_window = size ? size : FRAME_LINES (updating_frame);
493 if (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())) 502 if (TTY_SCROLL_REGION_OK (FRAME_TTY (updating_frame)))
494 set_scroll_region (0, specified_window); 503 set_scroll_region (0, specified_window);
495 } 504 }
496 else 505 else
497 set_terminal_window_hook (size); 506 set_terminal_window_hook (size);
498 } 507 }
512 FRAME_LINES (sf) - stop, 521 FRAME_LINES (sf) - stop,
513 FRAME_LINES (sf)); 522 FRAME_LINES (sf));
514 else 523 else
515 buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_COLS (sf)); 524 buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_COLS (sf));
516 525
517 OUTPUT (buf); 526 OUTPUT (CURTTY (), buf);
518 xfree (buf); 527 xfree (buf);
519 losecursor (); 528 losecursor ();
520 } 529 }
521 530
522 531
523 static void 532 static void
524 turn_on_insert () 533 turn_on_insert ()
525 { 534 {
526 if (!insert_mode) 535 if (!insert_mode)
527 OUTPUT (TS_insert_mode); 536 OUTPUT (CURTTY (), TS_insert_mode);
528 insert_mode = 1; 537 insert_mode = 1;
529 } 538 }
530 539
531 void 540 void
532 turn_off_insert () 541 turn_off_insert ()
533 { 542 {
534 if (insert_mode) 543 if (insert_mode)
535 OUTPUT (TS_end_insert_mode); 544 OUTPUT (CURTTY (), TS_end_insert_mode);
536 insert_mode = 0; 545 insert_mode = 0;
537 } 546 }
538 547
539 /* Handle highlighting. */ 548 /* Handle highlighting. */
540 549
541 void 550 void
542 turn_off_highlight () 551 turn_off_highlight ()
543 { 552 {
544 if (standout_mode) 553 if (standout_mode)
545 OUTPUT_IF (TS_end_standout_mode); 554 OUTPUT_IF (CURTTY (), TS_end_standout_mode);
546 standout_mode = 0; 555 standout_mode = 0;
547 } 556 }
548 557
549 static void 558 static void
550 turn_on_highlight () 559 turn_on_highlight ()
551 { 560 {
552 if (!standout_mode) 561 if (!standout_mode)
553 OUTPUT_IF (TS_standout_mode); 562 OUTPUT_IF (CURTTY(), TS_standout_mode);
554 standout_mode = 1; 563 standout_mode = 1;
555 } 564 }
556 565
557 static void 566 static void
558 toggle_highlight () 567 toggle_highlight ()
570 tty_hide_cursor () 579 tty_hide_cursor ()
571 { 580 {
572 if (tty_cursor_hidden == 0) 581 if (tty_cursor_hidden == 0)
573 { 582 {
574 tty_cursor_hidden = 1; 583 tty_cursor_hidden = 1;
575 OUTPUT_IF (TS_cursor_invisible); 584 OUTPUT_IF (CURTTY (), TS_cursor_invisible);
576 } 585 }
577 } 586 }
578 587
579 588
580 /* Ensure that cursor is visible. */ 589 /* Ensure that cursor is visible. */
583 tty_show_cursor () 592 tty_show_cursor ()
584 { 593 {
585 if (tty_cursor_hidden) 594 if (tty_cursor_hidden)
586 { 595 {
587 tty_cursor_hidden = 0; 596 tty_cursor_hidden = 0;
588 OUTPUT_IF (TS_cursor_normal); 597 OUTPUT_IF (CURTTY (), TS_cursor_normal);
589 OUTPUT_IF (TS_cursor_visible); 598 OUTPUT_IF (CURTTY (), TS_cursor_visible);
590 } 599 }
591 } 600 }
592 601
593 602
594 /* Set standout mode to the state it should be in for 603 /* Set standout mode to the state it should be in for
640 return; 649 return;
641 if (!TF_standout_motion) 650 if (!TF_standout_motion)
642 background_highlight (); 651 background_highlight ();
643 if (!TF_insmode_motion) 652 if (!TF_insmode_motion)
644 turn_off_insert (); 653 turn_off_insert ();
645 cmgoto (vpos, hpos); 654 cmgoto (FRAME_TTY (f), vpos, hpos);
646 } 655 }
647 656
648 /* Similar but don't take any account of the wasted characters. */ 657 /* Similar but don't take any account of the wasted characters. */
649 658
650 void 659 void
661 return; 670 return;
662 if (!TF_standout_motion) 671 if (!TF_standout_motion)
663 background_highlight (); 672 background_highlight ();
664 if (!TF_insmode_motion) 673 if (!TF_insmode_motion)
665 turn_off_insert (); 674 turn_off_insert ();
666 cmgoto (row, col); 675 cmgoto (FRAME_TTY (f), row, col);
667 } 676 }
668 677
669 /* Erase operations */ 678 /* Erase operations */
670 679
671 /* clear from cursor to end of frame */ 680 /* clear from cursor to end of frame */
680 return; 689 return;
681 } 690 }
682 if (TS_clr_to_bottom) 691 if (TS_clr_to_bottom)
683 { 692 {
684 background_highlight (); 693 background_highlight ();
685 OUTPUT (TS_clr_to_bottom); 694 OUTPUT (CURTTY (), TS_clr_to_bottom);
686 } 695 }
687 else 696 else
688 { 697 {
689 for (i = curY; i < FRAME_LINES (XFRAME (selected_frame)); i++) 698 for (i = curY; i < FRAME_LINES (XFRAME (selected_frame)); i++)
690 { 699 {
708 return; 717 return;
709 } 718 }
710 if (TS_clr_frame) 719 if (TS_clr_frame)
711 { 720 {
712 background_highlight (); 721 background_highlight ();
713 OUTPUT (TS_clr_frame); 722 OUTPUT (FRAME_TTY (updating_frame ? updating_frame : sf), TS_clr_frame);
714 cmat (0, 0); 723 cmat (0, 0);
715 } 724 }
716 else 725 else
717 { 726 {
718 cursor_to (0, 0); 727 cursor_to (0, 0);
748 if (curX >= first_unused_hpos) 757 if (curX >= first_unused_hpos)
749 return; 758 return;
750 background_highlight (); 759 background_highlight ();
751 if (TS_clr_line) 760 if (TS_clr_line)
752 { 761 {
753 OUTPUT1 (TS_clr_line); 762 OUTPUT1 (CURTTY (), TS_clr_line);
754 } 763 }
755 else 764 else
756 { /* have to do it the hard way */ 765 { /* have to do it the hard way */
757 struct frame *sf = XFRAME (selected_frame); 766 struct frame *sf = XFRAME (selected_frame);
758 turn_off_insert (); 767 turn_off_insert ();
762 && first_unused_hpos == FRAME_COLS (sf)) 771 && first_unused_hpos == FRAME_COLS (sf))
763 first_unused_hpos--; 772 first_unused_hpos--;
764 773
765 for (i = curX; i < first_unused_hpos; i++) 774 for (i = curX; i < first_unused_hpos; i++)
766 { 775 {
767 if (termscript) 776 if (TTY_TERMSCRIPT (CURTTY ()))
768 fputc (' ', termscript); 777 fputc (' ', TTY_TERMSCRIPT (CURTTY ()));
769 putchar (' '); 778 fputc (' ', TTY_OUTPUT (CURTTY ()));
770 } 779 }
771 cmplus (first_unused_hpos - curX); 780 cmplus (first_unused_hpos - curX);
772 } 781 }
773 } 782 }
774 783
940 produced = encode_terminal_code (string, conversion_buffer, 949 produced = encode_terminal_code (string, conversion_buffer,
941 n, conversion_buffer_size, 950 n, conversion_buffer_size,
942 &consumed); 951 &consumed);
943 if (produced > 0) 952 if (produced > 0)
944 { 953 {
945 fwrite (conversion_buffer, 1, produced, stdout); 954 fwrite (conversion_buffer, 1, produced,
946 if (ferror (stdout)) 955 TTY_OUTPUT (FRAME_TTY (f)));
947 clearerr (stdout); 956 if (ferror (TTY_OUTPUT (FRAME_TTY (f))))
948 if (termscript) 957 clearerr (TTY_OUTPUT (FRAME_TTY (f)));
949 fwrite (conversion_buffer, 1, produced, termscript); 958 if (TTY_TERMSCRIPT (FRAME_TTY (f)))
959 fwrite (conversion_buffer, 1, produced,
960 TTY_TERMSCRIPT (FRAME_TTY (f)));
950 } 961 }
951 len -= consumed; 962 len -= consumed;
952 n -= consumed; 963 n -= consumed;
953 string += consumed; 964 string += consumed;
954 } 965 }
964 terminal_coding.mode |= CODING_MODE_LAST_BLOCK; 975 terminal_coding.mode |= CODING_MODE_LAST_BLOCK;
965 encode_coding (&terminal_coding, "", conversion_buffer, 976 encode_coding (&terminal_coding, "", conversion_buffer,
966 0, conversion_buffer_size); 977 0, conversion_buffer_size);
967 if (terminal_coding.produced > 0) 978 if (terminal_coding.produced > 0)
968 { 979 {
969 fwrite (conversion_buffer, 1, terminal_coding.produced, stdout); 980 fwrite (conversion_buffer, 1, terminal_coding.produced,
970 if (ferror (stdout)) 981 TTY_OUTPUT (FRAME_TTY (f)));
971 clearerr (stdout); 982 if (ferror (TTY_OUTPUT (FRAME_TTY (f))))
972 if (termscript) 983 clearerr (TTY_OUTPUT (FRAME_TTY (f)));
984 if (TTY_TERMSCRIPT (FRAME_TTY (f)))
973 fwrite (conversion_buffer, 1, terminal_coding.produced, 985 fwrite (conversion_buffer, 1, terminal_coding.produced,
974 termscript); 986 TTY_TERMSCRIPT (FRAME_TTY (f)));
975 } 987 }
976 } 988 }
977 989
978 cmcheckmagic (); 990 cmcheckmagic (FRAME_TTY (f));
979 } 991 }
980 992
981 /* If start is zero, insert blanks instead of a string at start */ 993 /* If start is zero, insert blanks instead of a string at start */
982 994
983 void 995 void
1002 f = updating_frame ? updating_frame : sf; 1014 f = updating_frame ? updating_frame : sf;
1003 1015
1004 if (TS_ins_multi_chars) 1016 if (TS_ins_multi_chars)
1005 { 1017 {
1006 buf = tparam (TS_ins_multi_chars, 0, 0, len); 1018 buf = tparam (TS_ins_multi_chars, 0, 0, len);
1007 OUTPUT1 (buf); 1019 OUTPUT1 (FRAME_TTY (f), buf);
1008 xfree (buf); 1020 xfree (buf);
1009 if (start) 1021 if (start)
1010 write_glyphs (start, len); 1022 write_glyphs (start, len);
1011 return; 1023 return;
1012 } 1024 }
1019 { 1031 {
1020 int produced, consumed; 1032 int produced, consumed;
1021 unsigned char conversion_buffer[1024]; 1033 unsigned char conversion_buffer[1024];
1022 int conversion_buffer_size = sizeof conversion_buffer; 1034 int conversion_buffer_size = sizeof conversion_buffer;
1023 1035
1024 OUTPUT1_IF (TS_ins_char); 1036 OUTPUT1_IF (FRAME_TTY (f), TS_ins_char);
1025 if (!start) 1037 if (!start)
1026 { 1038 {
1027 conversion_buffer[0] = SPACEGLYPH; 1039 conversion_buffer[0] = SPACEGLYPH;
1028 produced = 1; 1040 produced = 1;
1029 } 1041 }
1035 ++start; 1047 ++start;
1036 /* We must open sufficient space for a character which 1048 /* We must open sufficient space for a character which
1037 occupies more than one column. */ 1049 occupies more than one column. */
1038 while (len && CHAR_GLYPH_PADDING_P (*start)) 1050 while (len && CHAR_GLYPH_PADDING_P (*start))
1039 { 1051 {
1040 OUTPUT1_IF (TS_ins_char); 1052 OUTPUT1_IF (FRAME_TTY (f), TS_ins_char);
1041 start++, len--; 1053 start++, len--;
1042 } 1054 }
1043 1055
1044 if (len <= 0) 1056 if (len <= 0)
1045 /* This is the last glyph. */ 1057 /* This is the last glyph. */
1051 conversion_buffer_size, &consumed); 1063 conversion_buffer_size, &consumed);
1052 } 1064 }
1053 1065
1054 if (produced > 0) 1066 if (produced > 0)
1055 { 1067 {
1056 fwrite (conversion_buffer, 1, produced, stdout); 1068 fwrite (conversion_buffer, 1, produced,
1057 if (ferror (stdout)) 1069 TTY_OUTPUT (FRAME_TTY (f)));
1058 clearerr (stdout); 1070 if (ferror (TTY_OUTPUT (FRAME_TTY (f))))
1059 if (termscript) 1071 clearerr (TTY_OUTPUT (FRAME_TTY (f)));
1060 fwrite (conversion_buffer, 1, produced, termscript); 1072 if (TTY_TERMSCRIPT (FRAME_TTY (f)))
1073 fwrite (conversion_buffer, 1, produced,
1074 TTY_TERMSCRIPT (FRAME_TTY (f)));
1061 } 1075 }
1062 1076
1063 OUTPUT1_IF (TS_pad_inserted_char); 1077 OUTPUT1_IF (FRAME_TTY (f), TS_pad_inserted_char);
1064 if (start) 1078 if (start)
1065 { 1079 {
1066 turn_off_face (f, glyph->face_id); 1080 turn_off_face (f, glyph->face_id);
1067 turn_off_highlight (); 1081 turn_off_highlight ();
1068 } 1082 }
1069 } 1083 }
1070 1084
1071 cmcheckmagic (); 1085 cmcheckmagic (FRAME_TTY (f));
1072 } 1086 }
1073 1087
1074 void 1088 void
1075 delete_glyphs (n) 1089 delete_glyphs (n)
1076 register int n; 1090 register int n;
1089 turn_on_insert (); 1103 turn_on_insert ();
1090 } 1104 }
1091 else 1105 else
1092 { 1106 {
1093 turn_off_insert (); 1107 turn_off_insert ();
1094 OUTPUT_IF (TS_delete_mode); 1108 OUTPUT_IF (FRAME_TTY (updating_frame), TS_delete_mode);
1095 } 1109 }
1096 1110
1097 if (TS_del_multi_chars) 1111 if (TS_del_multi_chars)
1098 { 1112 {
1099 buf = tparam (TS_del_multi_chars, 0, 0, n); 1113 buf = tparam (TS_del_multi_chars, 0, 0, n);
1100 OUTPUT1 (buf); 1114 OUTPUT1 (FRAME_TTY (updating_frame), buf);
1101 xfree (buf); 1115 xfree (buf);
1102 } 1116 }
1103 else 1117 else
1104 for (i = 0; i < n; i++) 1118 for (i = 0; i < n; i++)
1105 OUTPUT1 (TS_del_char); 1119 OUTPUT1 (FRAME_TTY (updating_frame), TS_del_char);
1106 if (!delete_in_insert_mode) 1120 if (!delete_in_insert_mode)
1107 OUTPUT_IF (TS_end_delete_mode); 1121 OUTPUT_IF (FRAME_TTY (updating_frame), TS_end_delete_mode);
1108 } 1122 }
1109 1123
1110 /* Insert N lines at vpos VPOS. If N is negative, delete -N lines. */ 1124 /* Insert N lines at vpos VPOS. If N is negative, delete -N lines. */
1111 1125
1112 void 1126 void
1134 and we know the lines are already clear, since the matching 1148 and we know the lines are already clear, since the matching
1135 deletion has already been done. So can ignore this. */ 1149 deletion has already been done. So can ignore this. */
1136 /* If the lines below the deletion are blank lines coming 1150 /* If the lines below the deletion are blank lines coming
1137 out of the end of the window, don't bother, 1151 out of the end of the window, don't bother,
1138 as there will be a matching inslines later that will flush them. */ 1152 as there will be a matching inslines later that will flush them. */
1139 if (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) 1153 if (TTY_SCROLL_REGION_OK (FRAME_TTY (sf))
1140 && vpos + i >= specified_window) 1154 && vpos + i >= specified_window)
1141 return; 1155 return;
1142 if (!TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) 1156 if (!TTY_MEMORY_BELOW_FRAME (FRAME_TTY (sf))
1143 && vpos + i >= FRAME_LINES (sf)) 1157 && vpos + i >= FRAME_LINES (sf))
1144 return; 1158 return;
1145 1159
1146 if (multi) 1160 if (multi)
1147 { 1161 {
1148 raw_cursor_to (vpos, 0); 1162 raw_cursor_to (vpos, 0);
1149 background_highlight (); 1163 background_highlight ();
1150 buf = tparam (multi, 0, 0, i); 1164 buf = tparam (multi, 0, 0, i);
1151 OUTPUT (buf); 1165 OUTPUT (FRAME_TTY (sf), buf);
1152 xfree (buf); 1166 xfree (buf);
1153 } 1167 }
1154 else if (single) 1168 else if (single)
1155 { 1169 {
1156 raw_cursor_to (vpos, 0); 1170 raw_cursor_to (vpos, 0);
1157 background_highlight (); 1171 background_highlight ();
1158 while (--i >= 0) 1172 while (--i >= 0)
1159 OUTPUT (single); 1173 OUTPUT (FRAME_TTY (sf), single);
1160 if (TF_teleray) 1174 if (TF_teleray)
1161 curX = 0; 1175 curX = 0;
1162 } 1176 }
1163 else 1177 else
1164 { 1178 {
1167 raw_cursor_to (specified_window - 1, 0); 1181 raw_cursor_to (specified_window - 1, 0);
1168 else 1182 else
1169 raw_cursor_to (vpos, 0); 1183 raw_cursor_to (vpos, 0);
1170 background_highlight (); 1184 background_highlight ();
1171 while (--i >= 0) 1185 while (--i >= 0)
1172 OUTPUTL (scroll, specified_window - vpos); 1186 OUTPUTL (FRAME_TTY (sf), scroll, specified_window - vpos);
1173 set_scroll_region (0, specified_window); 1187 set_scroll_region (0, specified_window);
1174 } 1188 }
1175 1189
1176 if (!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) 1190 if (!TTY_SCROLL_REGION_OK (FRAME_TTY (sf))
1177 && TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) 1191 && TTY_MEMORY_BELOW_FRAME (FRAME_TTY (sf))
1178 && n < 0) 1192 && n < 0)
1179 { 1193 {
1180 cursor_to (FRAME_LINES (sf) + n, 0); 1194 cursor_to (FRAME_LINES (sf) + n, 0);
1181 clear_to_end (); 1195 clear_to_end ();
1182 } 1196 }
1304 ? TS_set_scroll_region 1318 ? TS_set_scroll_region
1305 : TS_set_scroll_region_1); 1319 : TS_set_scroll_region_1);
1306 1320
1307 FRAME_COST_BAUD_RATE (frame) = baud_rate; 1321 FRAME_COST_BAUD_RATE (frame) = baud_rate;
1308 1322
1309 TERMINAL_SCROLL_REGION_COST (CURRENT_TERMINAL ()) = string_cost (f); 1323 if (FRAME_TERMCAP_P (frame))
1324 TTY_SCROLL_REGION_COST (frame->output_data.tty) = string_cost (f);
1310 1325
1311 /* These variables are only used for terminal stuff. They are allocated 1326 /* These variables are only used for terminal stuff. They are allocated
1312 once for the terminal frame of X-windows emacs, but not used afterwards. 1327 once for the terminal frame of X-windows emacs, but not used afterwards.
1313 1328
1314 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because 1329 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because
1864 } 1879 }
1865 1880
1866 if (face->tty_bold_p) 1881 if (face->tty_bold_p)
1867 { 1882 {
1868 if (MAY_USE_WITH_COLORS_P (NC_BOLD)) 1883 if (MAY_USE_WITH_COLORS_P (NC_BOLD))
1869 OUTPUT1_IF (TS_enter_bold_mode); 1884 OUTPUT1_IF (FRAME_TTY (f), TS_enter_bold_mode);
1870 } 1885 }
1871 else if (face->tty_dim_p) 1886 else if (face->tty_dim_p)
1872 if (MAY_USE_WITH_COLORS_P (NC_DIM)) 1887 if (MAY_USE_WITH_COLORS_P (NC_DIM))
1873 OUTPUT1_IF (TS_enter_dim_mode); 1888 OUTPUT1_IF (FRAME_TTY (f), TS_enter_dim_mode);
1874 1889
1875 /* Alternate charset and blinking not yet used. */ 1890 /* Alternate charset and blinking not yet used. */
1876 if (face->tty_alt_charset_p 1891 if (face->tty_alt_charset_p
1877 && MAY_USE_WITH_COLORS_P (NC_ALT_CHARSET)) 1892 && MAY_USE_WITH_COLORS_P (NC_ALT_CHARSET))
1878 OUTPUT1_IF (TS_enter_alt_charset_mode); 1893 OUTPUT1_IF (FRAME_TTY (f), TS_enter_alt_charset_mode);
1879 1894
1880 if (face->tty_blinking_p 1895 if (face->tty_blinking_p
1881 && MAY_USE_WITH_COLORS_P (NC_BLINK)) 1896 && MAY_USE_WITH_COLORS_P (NC_BLINK))
1882 OUTPUT1_IF (TS_enter_blink_mode); 1897 OUTPUT1_IF (FRAME_TTY (f), TS_enter_blink_mode);
1883 1898
1884 if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (NC_UNDERLINE)) 1899 if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (NC_UNDERLINE))
1885 OUTPUT1_IF (TS_enter_underline_mode); 1900 OUTPUT1_IF (FRAME_TTY (f), TS_enter_underline_mode);
1886 1901
1887 if (TN_max_colors > 0) 1902 if (TN_max_colors > 0)
1888 { 1903 {
1889 char *p; 1904 char *p;
1890 1905
1891 if (fg >= 0 && TS_set_foreground) 1906 if (fg >= 0 && TS_set_foreground)
1892 { 1907 {
1893 p = tparam (TS_set_foreground, NULL, 0, (int) fg); 1908 p = tparam (TS_set_foreground, NULL, 0, (int) fg);
1894 OUTPUT (p); 1909 OUTPUT (FRAME_TTY (f), p);
1895 xfree (p); 1910 xfree (p);
1896 } 1911 }
1897 1912
1898 if (bg >= 0 && TS_set_background) 1913 if (bg >= 0 && TS_set_background)
1899 { 1914 {
1900 p = tparam (TS_set_background, NULL, 0, (int) bg); 1915 p = tparam (TS_set_background, NULL, 0, (int) bg);
1901 OUTPUT (p); 1916 OUTPUT (FRAME_TTY (f), p);
1902 xfree (p); 1917 xfree (p);
1903 } 1918 }
1904 } 1919 }
1905 } 1920 }
1906 1921
1926 || face->tty_reverse_p 1941 || face->tty_reverse_p
1927 || face->tty_alt_charset_p 1942 || face->tty_alt_charset_p
1928 || face->tty_blinking_p 1943 || face->tty_blinking_p
1929 || face->tty_underline_p) 1944 || face->tty_underline_p)
1930 { 1945 {
1931 OUTPUT1_IF (TS_exit_attribute_mode); 1946 OUTPUT1_IF (FRAME_TTY (f), TS_exit_attribute_mode);
1932 if (strcmp (TS_exit_attribute_mode, TS_end_standout_mode) == 0) 1947 if (strcmp (TS_exit_attribute_mode, TS_end_standout_mode) == 0)
1933 standout_mode = 0; 1948 standout_mode = 0;
1934 } 1949 }
1935 1950
1936 if (face->tty_alt_charset_p) 1951 if (face->tty_alt_charset_p)
1937 OUTPUT_IF (TS_exit_alt_charset_mode); 1952 OUTPUT_IF (FRAME_TTY (f), TS_exit_alt_charset_mode);
1938 } 1953 }
1939 else 1954 else
1940 { 1955 {
1941 /* If we don't have "me" we can only have those appearances 1956 /* If we don't have "me" we can only have those appearances
1942 that have exit sequences defined. */ 1957 that have exit sequences defined. */
1943 if (face->tty_alt_charset_p) 1958 if (face->tty_alt_charset_p)
1944 OUTPUT_IF (TS_exit_alt_charset_mode); 1959 OUTPUT_IF (FRAME_TTY (f), TS_exit_alt_charset_mode);
1945 1960
1946 if (face->tty_underline_p) 1961 if (face->tty_underline_p)
1947 OUTPUT_IF (TS_exit_underline_mode); 1962 OUTPUT_IF (FRAME_TTY (f), TS_exit_underline_mode);
1948 } 1963 }
1949 1964
1950 /* Switch back to default colors. */ 1965 /* Switch back to default colors. */
1951 if (TN_max_colors > 0 1966 if (TN_max_colors > 0
1952 && ((face->foreground != FACE_TTY_DEFAULT_COLOR 1967 && ((face->foreground != FACE_TTY_DEFAULT_COLOR
1953 && face->foreground != FACE_TTY_DEFAULT_FG_COLOR) 1968 && face->foreground != FACE_TTY_DEFAULT_FG_COLOR)
1954 || (face->background != FACE_TTY_DEFAULT_COLOR 1969 || (face->background != FACE_TTY_DEFAULT_COLOR
1955 && face->background != FACE_TTY_DEFAULT_BG_COLOR))) 1970 && face->background != FACE_TTY_DEFAULT_BG_COLOR)))
1956 OUTPUT1_IF (TS_orig_pair); 1971 OUTPUT1_IF (FRAME_TTY (f), TS_orig_pair);
1957 } 1972 }
1958 1973
1959 1974
1960 /* Return non-zero if the terminal on frame F supports all of the 1975 /* Return non-zero if the terminal on frame F supports all of the
1961 capabilities in CAPS simultaneously, with foreground and background 1976 capabilities in CAPS simultaneously, with foreground and background
2142 } 2157 }
2143 2158
2144 #endif /* !WINDOWSNT */ 2159 #endif /* !WINDOWSNT */
2145 2160
2146 2161
2162
2163 struct tty_output *
2164 get_named_tty (name)
2165 char *name;
2166 {
2167 struct tty_output *tty = tty_list;
2168
2169 while (tty) {
2170 if ((tty->name == 0 && name == 0)
2171 || (name && tty->name && !strcmp (tty->name, name)))
2172 return tty;
2173 tty = tty->next;
2174 };
2175
2176 return 0;
2177 }
2178
2179
2147 /*********************************************************************** 2180 /***********************************************************************
2148 Initialization 2181 Initialization
2149 ***********************************************************************/ 2182 ***********************************************************************/
2150 2183
2151 void 2184 struct tty_output *
2152 term_init (terminal_type) 2185 term_dummy_init (void)
2186 {
2187 if (initialized || tty_list)
2188 error ("tty already initialized");
2189
2190 tty_list = xmalloc (sizeof (struct tty_output));
2191 bzero (tty_list, sizeof (struct tty_output));
2192 TTY_NAME (tty_list) = 0;
2193 TTY_INPUT (tty_list) = stdin;
2194 TTY_OUTPUT (tty_list) = stdout;
2195 return tty_list;
2196 }
2197
2198
2199 struct tty_output *
2200 term_init (name, terminal_type)
2201 char *name;
2153 char *terminal_type; 2202 char *terminal_type;
2154 { 2203 {
2155 char *area; 2204 char *area;
2156 char **address = &area; 2205 char **address = &area;
2157 char *buffer = NULL; 2206 char *buffer = NULL;
2158 int buffer_size = 4096; 2207 int buffer_size = 4096;
2159 register char *p; 2208 register char *p;
2160 int status; 2209 int status;
2161 struct frame *sf = XFRAME (selected_frame); 2210 struct frame *sf = XFRAME (selected_frame);
2162 2211
2212 struct tty_output *tty;
2213
2214 tty = get_named_tty (name);
2215 if (tty)
2216 {
2217 /* Return the previously initialized terminal, except if it is the dummy
2218 terminal created for the initial frame. */
2219 if (tty->type)
2220 return tty;
2221 }
2222 else
2223 {
2224 if (!terminal_type)
2225 error ("Unknown terminal type");
2226
2227 tty = (struct tty_output *) xmalloc (sizeof (struct tty_output));
2228 bzero (tty, sizeof (struct tty_output));
2229 tty->next = tty_list;
2230 tty_list = tty;
2231 }
2232
2233 if (name)
2234 {
2235 int fd;
2236 FILE *f;
2237 fd = emacs_open (name, O_RDWR, 0);
2238 if (fd < 0)
2239 {
2240 tty_list = tty->next;
2241 xfree (tty);
2242 error ("could not open file: %s", name);
2243 }
2244 f = fdopen (fd, "w+");
2245 TTY_NAME (tty) = xstrdup (name);
2246 TTY_INPUT (tty) = f;
2247 TTY_OUTPUT (tty) = f;
2248 }
2249 else
2250 {
2251 TTY_NAME (tty) = 0;
2252 TTY_INPUT (tty) = stdin;
2253 TTY_OUTPUT (tty) = stdout;
2254 }
2255
2256 init_sys_modes (tty);
2257
2163 #ifdef WINDOWSNT 2258 #ifdef WINDOWSNT
2164 initialize_w32_display (); 2259 initialize_w32_display ();
2165 2260
2166 Wcm_clear (); 2261 Wcm_clear ();
2167 2262
2172 specified_window = FRAME_LINES (sf); 2267 specified_window = FRAME_LINES (sf);
2173 2268
2174 delete_in_insert_mode = 1; 2269 delete_in_insert_mode = 1;
2175 2270
2176 UseTabs = 0; 2271 UseTabs = 0;
2177 TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) = 0; 2272 TTY_SCROLL_REGION_OK (tty) = 0;
2178 2273
2179 /* Seems to insert lines when it's not supposed to, messing 2274 /* Seems to insert lines when it's not supposed to, messing
2180 up the display. In doing a trace, it didn't seem to be 2275 up the display. In doing a trace, it didn't seem to be
2181 called much, so I don't think we're losing anything by 2276 called much, so I don't think we're losing anything by
2182 turning it off. */ 2277 turning it off. */
2183 2278 TTY_LINE_INS_DEL_OK (tty) = 0;
2184 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()) = 0; 2279
2185 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) = 1; 2280 TTY_CHAR_INS_DEL_OK (tty) = 1;
2186 2281
2187 baud_rate = 19200; 2282 baud_rate = 19200;
2188 2283
2189 FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0; 2284 FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0;
2190 FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none; 2285 FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none;
2191 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ 2286 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
2192 2287
2193 return; 2288 return tty;
2194 #else /* not WINDOWSNT */ 2289 #else /* not WINDOWSNT */
2195 2290
2196 Wcm_clear (); 2291 Wcm_clear ();
2292
2293 TTY_TYPE (tty) = xstrdup (terminal_type);
2197 2294
2198 buffer = (char *) xmalloc (buffer_size); 2295 buffer = (char *) xmalloc (buffer_size);
2199 status = tgetent (buffer, terminal_type); 2296 status = tgetent (buffer, terminal_type);
2200 if (status < 0) 2297 if (status < 0)
2201 { 2298 {
2211 fatal ("Terminal type %s is not defined.\n\ 2308 fatal ("Terminal type %s is not defined.\n\
2212 If that is not the actual type of terminal you have,\n\ 2309 If that is not the actual type of terminal you have,\n\
2213 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ 2310 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
2214 `setenv TERM ...') to specify the correct type. It may be necessary\n\ 2311 `setenv TERM ...') to specify the correct type. It may be necessary\n\
2215 to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", 2312 to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
2216 terminal_type); 2313 terminal_type);
2217 #else 2314 #else
2218 fatal ("Terminal type %s is not defined.\n\ 2315 fatal ("Terminal type %s is not defined.\n\
2219 If that is not the actual type of terminal you have,\n\ 2316 If that is not the actual type of terminal you have,\n\
2220 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ 2317 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
2221 `setenv TERM ...') to specify the correct type. It may be necessary\n\ 2318 `setenv TERM ...') to specify the correct type. It may be necessary\n\
2222 to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", 2319 to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2223 terminal_type); 2320 terminal_type);
2224 #endif 2321 #endif
2225 } 2322 }
2226 2323
2227 #ifndef TERMINFO 2324 #ifndef TERMINFO
2228 if (strlen (buffer) >= buffer_size) 2325 if (strlen (buffer) >= buffer_size)
2324 TN_max_colors = tgetnum ("Co"); 2421 TN_max_colors = tgetnum ("Co");
2325 TN_max_pairs = tgetnum ("pa"); 2422 TN_max_pairs = tgetnum ("pa");
2326 2423
2327 TN_no_color_video = tgetnum ("NC"); 2424 TN_no_color_video = tgetnum ("NC");
2328 if (TN_no_color_video == -1) 2425 if (TN_no_color_video == -1)
2329 TN_no_color_video = 0; 2426 TN_no_color_video = 0;
2330 } 2427 }
2331 2428
2332 tty_default_color_capabilities (1); 2429 tty_default_color_capabilities (1);
2333 2430
2334 MagicWrap = tgetflag ("xn"); 2431 MagicWrap = tgetflag ("xn");
2335 /* Since we make MagicWrap terminals look like AutoWrap, we need to have 2432 /* Since we make MagicWrap terminals look like AutoWrap, we need to have
2336 the former flag imply the latter. */ 2433 the former flag imply the latter. */
2337 AutoWrap = MagicWrap || tgetflag ("am"); 2434 AutoWrap = MagicWrap || tgetflag ("am");
2338 TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) = tgetflag ("db"); 2435 TTY_MEMORY_BELOW_FRAME (tty) = tgetflag ("db");
2339 TF_hazeltine = tgetflag ("hz"); 2436 TF_hazeltine = tgetflag ("hz");
2340 TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ()) = tgetflag ("in"); 2437 TTY_MUST_WRITE_SPACES (tty) = tgetflag ("in");
2341 meta_key = tgetflag ("km") || tgetflag ("MT"); 2438 meta_key = tgetflag ("km") || tgetflag ("MT");
2342 TF_insmode_motion = tgetflag ("mi"); 2439 TF_insmode_motion = tgetflag ("mi");
2343 TF_standout_motion = tgetflag ("ms"); 2440 TF_standout_motion = tgetflag ("ms");
2344 TF_underscore = tgetflag ("ul"); 2441 TF_underscore = tgetflag ("ul");
2345 TF_teleray = tgetflag ("xt"); 2442 TF_teleray = tgetflag ("xt");
2362 if (FRAME_LINES (sf) <= 0) 2459 if (FRAME_LINES (sf) <= 0)
2363 FRAME_LINES (sf) = tgetnum ("li"); 2460 FRAME_LINES (sf) = tgetnum ("li");
2364 2461
2365 if (FRAME_LINES (sf) < 3 || FRAME_COLS (sf) < 3) 2462 if (FRAME_LINES (sf) < 3 || FRAME_COLS (sf) < 3)
2366 fatal ("Screen size %dx%d is too small", 2463 fatal ("Screen size %dx%d is too small",
2367 FRAME_LINES (sf), FRAME_COLS (sf)); 2464 FRAME_LINES (sf), FRAME_COLS (sf));
2368 2465
2369 #if 0 /* This is not used anywhere. */ 2466 #if 0 /* This is not used anywhere. */
2370 TERMINAL_MIN_PADDING_SPEED (CURRENT_TERMINAL ()) = tgetnum ("pb"); 2467 TTY_MIN_PADDING_SPEED (tty) = tgetnum ("pb");
2371 #endif 2468 #endif
2372 2469
2373 TabWidth = tgetnum ("tw"); 2470 TabWidth = tgetnum ("tw");
2374 2471
2375 #ifdef VMS 2472 #ifdef VMS
2376 /* These capabilities commonly use ^J. 2473 /* These capabilities commonly use ^J.
2377 I don't know why, but sending them on VMS does not work; 2474 I don't know why, but sending them on VMS does not work;
2422 If that fails, we can't use standout mode at all. */ 2519 If that fails, we can't use standout mode at all. */
2423 if (TS_end_standout_mode == 0) 2520 if (TS_end_standout_mode == 0)
2424 { 2521 {
2425 char *s = tgetstr ("me", address); 2522 char *s = tgetstr ("me", address);
2426 if (s != 0) 2523 if (s != 0)
2427 TS_end_standout_mode = s; 2524 TS_end_standout_mode = s;
2428 else 2525 else
2429 TS_standout_mode = 0; 2526 TS_standout_mode = 0;
2430 } 2527 }
2431 2528
2432 if (TF_teleray) 2529 if (TF_teleray)
2433 { 2530 {
2434 Wcm.cm_tab = 0; 2531 Wcm.cm_tab = 0;
2443 2540
2444 /* Special handling for certain terminal types known to need it */ 2541 /* Special handling for certain terminal types known to need it */
2445 2542
2446 if (!strcmp (terminal_type, "supdup")) 2543 if (!strcmp (terminal_type, "supdup"))
2447 { 2544 {
2448 TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) = 1; 2545 TTY_MEMORY_BELOW_FRAME (tty) = 1;
2449 Wcm.cm_losewrap = 1; 2546 Wcm.cm_losewrap = 1;
2450 } 2547 }
2451 if (!strncmp (terminal_type, "c10", 3) 2548 if (!strncmp (terminal_type, "c10", 3)
2452 || !strcmp (terminal_type, "perq")) 2549 || !strcmp (terminal_type, "perq"))
2453 { 2550 {
2454 /* Supply a makeshift :wi string. 2551 /* Supply a makeshift :wi string.
2455 This string is not valid in general since it works only 2552 This string is not valid in general since it works only
2456 for windows starting at the upper left corner; 2553 for windows starting at the upper left corner;
2457 but that is all Emacs uses. 2554 but that is all Emacs uses.
2458 2555
2459 This string works only if the frame is using 2556 This string works only if the frame is using
2460 the top of the video memory, because addressing is memory-relative. 2557 the top of the video memory, because addressing is memory-relative.
2461 So first check the :ti string to see if that is true. 2558 So first check the :ti string to see if that is true.
2462 2559
2463 It would be simpler if the :wi string could go in the termcap 2560 It would be simpler if the :wi string could go in the termcap
2470 p++; 2567 p++;
2471 if (*p) 2568 if (*p)
2472 TS_set_window = "\033v%C %C %C %C "; 2569 TS_set_window = "\033v%C %C %C %C ";
2473 } 2570 }
2474 /* Termcap entry often fails to have :in: flag */ 2571 /* Termcap entry often fails to have :in: flag */
2475 TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ()) = 1; 2572 TTY_MUST_WRITE_SPACES (tty) = 1;
2476 /* :ti string typically fails to have \E^G! in it */ 2573 /* :ti string typically fails to have \E^G! in it */
2477 /* This limits scope of insert-char to one line. */ 2574 /* This limits scope of insert-char to one line. */
2478 strcpy (area, TS_termcap_modes); 2575 strcpy (area, TS_termcap_modes);
2479 strcat (area, "\033\007!"); 2576 strcat (area, "\033\007!");
2480 TS_termcap_modes = area; 2577 TS_termcap_modes = area;
2481 area += strlen (area) + 1; 2578 area += strlen (area) + 1;
2482 p = AbsPosition; 2579 p = AbsPosition;
2483 /* Change all %+ parameters to %C, to handle 2580 /* Change all %+ parameters to %C, to handle
2484 values above 96 correctly for the C100. */ 2581 values above 96 correctly for the C100. */
2485 while (*p) 2582 while (*p)
2486 { 2583 {
2487 if (p[0] == '%' && p[1] == '+') 2584 if (p[0] == '%' && p[1] == '+')
2488 p[1] = 'C'; 2585 p[1] = 'C';
2489 p++; 2586 p++;
2490 } 2587 }
2491 } 2588 }
2492 2589
2493 FrameRows = FRAME_LINES (sf); 2590 FrameRows = FRAME_LINES (sf);
2494 FrameCols = FRAME_COLS (sf); 2591 FrameCols = FRAME_COLS (sf);
2495 specified_window = FRAME_LINES (sf); 2592 specified_window = FRAME_LINES (sf);
2502 DCL command `SET TERMINAL/DEVICE= ...' for DEC-compatible terminals,\n\ 2599 DCL command `SET TERMINAL/DEVICE= ...' for DEC-compatible terminals,\n\
2503 or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.", 2600 or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.",
2504 terminal_type); 2601 terminal_type);
2505 #else /* not VMS */ 2602 #else /* not VMS */
2506 # ifdef TERMINFO 2603 # ifdef TERMINFO
2507 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ 2604 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\
2508 It lacks the ability to position the cursor.\n\ 2605 It lacks the ability to position the cursor.\n\
2509 If that is not the actual type of terminal you have,\n\ 2606 If that is not the actual type of terminal you have,\n\
2510 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ 2607 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
2511 `setenv TERM ...') to specify the correct type. It may be necessary\n\ 2608 `setenv TERM ...') to specify the correct type. It may be necessary\n\
2512 to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", 2609 to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
2513 terminal_type); 2610 terminal_type);
2514 # else /* TERMCAP */ 2611 # else /* TERMCAP */
2515 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ 2612 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\
2516 It lacks the ability to position the cursor.\n\ 2613 It lacks the ability to position the cursor.\n\
2517 If that is not the actual type of terminal you have,\n\ 2614 If that is not the actual type of terminal you have,\n\
2518 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ 2615 use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
2519 `setenv TERM ...') to specify the correct type. It may be necessary\n\ 2616 `setenv TERM ...') to specify the correct type. It may be necessary\n\
2520 to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", 2617 to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2521 terminal_type); 2618 terminal_type);
2522 # endif /* TERMINFO */ 2619 # endif /* TERMINFO */
2523 #endif /*VMS */ 2620 #endif /*VMS */
2524 if (FRAME_LINES (sf) <= 0 2621 if (FRAME_LINES (sf) <= 0
2525 || FRAME_COLS (sf) <= 0) 2622 || FRAME_COLS (sf) <= 0)
2526 fatal ("The frame size has not been specified"); 2623 fatal ("The frame size has not been specified");
2527 2624
2528 delete_in_insert_mode 2625 delete_in_insert_mode
2529 = TS_delete_mode && TS_insert_mode 2626 = TS_delete_mode && TS_insert_mode
2530 && !strcmp (TS_delete_mode, TS_insert_mode); 2627 && !strcmp (TS_delete_mode, TS_insert_mode);
2531 2628
2532 se_is_so = (TS_standout_mode 2629 se_is_so = (TS_standout_mode
2533 && TS_end_standout_mode 2630 && TS_end_standout_mode
2534 && !strcmp (TS_standout_mode, TS_end_standout_mode)); 2631 && !strcmp (TS_standout_mode, TS_end_standout_mode));
2535 2632
2536 UseTabs = tabs_safe_p () && TabWidth == 8; 2633 UseTabs = tabs_safe_p () && TabWidth == 8;
2537 2634
2538 TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) 2635 TTY_SCROLL_REGION_OK (tty)
2539 = (Wcm.cm_abs 2636 = (Wcm.cm_abs
2540 && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1)); 2637 && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1));
2541 2638
2542 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()) 2639 TTY_LINE_INS_DEL_OK (tty)
2543 = (((TS_ins_line || TS_ins_multi_lines) 2640 = (((TS_ins_line || TS_ins_multi_lines)
2544 && (TS_del_line || TS_del_multi_lines)) 2641 && (TS_del_line || TS_del_multi_lines))
2545 || (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) 2642 || (TTY_SCROLL_REGION_OK (tty)
2546 && TS_fwd_scroll && TS_rev_scroll)); 2643 && TS_fwd_scroll && TS_rev_scroll));
2547 2644
2548 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) 2645 TTY_CHAR_INS_DEL_OK (tty)
2549 = ((TS_ins_char || TS_insert_mode 2646 = ((TS_ins_char || TS_insert_mode
2550 || TS_pad_inserted_char || TS_ins_multi_chars) 2647 || TS_pad_inserted_char || TS_ins_multi_chars)
2551 && (TS_del_char || TS_del_multi_chars)); 2648 && (TS_del_char || TS_del_multi_chars));
2552 2649
2553 TERMINAL_FAST_CLEAR_END_OF_LINE (CURRENT_TERMINAL ()) = TS_clr_line != 0; 2650 TTY_FAST_CLEAR_END_OF_LINE (tty) = TS_clr_line != 0;
2554 2651
2555 init_baud_rate (); 2652 init_baud_rate ();
2556 if (read_socket_hook) /* Baudrate is somewhat */ 2653 if (read_socket_hook) /* Baudrate is somewhat
2557 /* meaningless in this case */ 2654 meaningless in this case */
2558 baud_rate = 9600; 2655 baud_rate = 9600;
2559 2656
2560 FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0; 2657 FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0;
2561 FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none; 2658 FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none;
2562 #endif /* WINDOWSNT */ 2659 #endif /* WINDOWSNT */
2563 2660
2564 xfree (buffer); 2661 xfree (buffer);
2662
2663 return tty;
2565 } 2664 }
2566 2665
2567 /* VARARGS 1 */ 2666 /* VARARGS 1 */
2568 void 2667 void
2569 fatal (str, arg1, arg2) 2668 fatal (str, arg1, arg2)
2595 2694
2596 defsubr (&Stty_display_color_p); 2695 defsubr (&Stty_display_color_p);
2597 defsubr (&Stty_display_color_cells); 2696 defsubr (&Stty_display_color_cells);
2598 } 2697 }
2599 2698
2699 struct tty_output *
2700 get_current_tty ()
2701 {
2702 return CURTTY();
2703 }
2704
2705
2600 /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 2706 /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193
2601 (do not change this comment) */ 2707 (do not change this comment) */