aboutsummaryrefslogtreecommitdiffstats
path: root/src/msdos.c
diff options
context:
space:
mode:
authorEli Zaretskii2008-08-23 16:54:45 +0000
committerEli Zaretskii2008-08-23 16:54:45 +0000
commit3e1944a3d890c2c9a85a7beef0caff322ae2ddec (patch)
treea7dd103b039af753da084a4f6af3adf7888611ca /src/msdos.c
parentcb22456dd34eb898dca2ab9e2808a3b9d29750fe (diff)
downloademacs-3e1944a3d890c2c9a85a7beef0caff322ae2ddec.tar.gz
emacs-3e1944a3d890c2c9a85a7beef0caff322ae2ddec.zip
Include frame.h before termhooks.h.
(mouse_on, mouse_off, mouse_moveto, mouse_init) (msdos_set_cursor_shape, IT_set_face, IT_write_glyphs) (show_mouse_face, IT_clear_end_of_line, IT_clear_screen) (IT_clear_to_end, IT_cursor_to, IT_display_cursor, IT_cmgoto) (IT_set_terminal_modes, IT_reset_terminal_modes) (IT_set_frame_parameters): Use tty->termscript instead of a global variable termscript. (IT_write_glyphs): Use tty->terminal->terminal_coding instead of a global variable terminal_coding. Don't refer to Vnonascii_translation_table. (internal_terminal_init): Set Vwindow_system in current_kboard. Don't use TTY_CHAR_INS_DEL_OK. Set Vinitial_window_system. Announce date and time of session start, if termscript is open. Don't zero out the_only_display_info (it is done in term.c:init_tty). Open termscript only of not already open. Log "SCREEN SAVED" here, instead of IT_set_terminal_modes. Init mouse here instead of dos_ttraw. Don't initialize display if this is an initial tty. Don't set FRAME_FONT. (Vwindow_system_version): Bump to 23. (dos_ttraw): Accept a TTY argument; all callers fixed. If mouse is available, set up mouse_position_hook. (dos_ttraw, IT_set_terminal_modes): If called with initial terminal, do nothing. (IT_set_frame_parameters): Handle the Qtty_type frame parameter by calling internal_terminal_init. (dos_set_window_size, show_mouse_face) (clear_mouse_face, IT_note_mode_line_highlight) (IT_note_mouse_highlight, IT_update_begin, IT_frame_up_to_date) (dos_rawgetc): Use tty_display_info instead of x_display_info. (initialize_msdos_display): New function. (IT_cursor_to, IT_clear_to_end, IT_clear_screen) (IT_clear_end_of_line, IT_insert_glyphs, IT_write_glyphs) (IT_delete_glyphs, IT_ring_bell, IT_reset_terminal_modes) (IT_set_terminal_modes, IT_set_terminal_window, IT_update_begin): Accept additional argument: a pointer to a frame. All callers changed. (request_sigio, unrequest_sigio): Don't define, now defined on sysdep.c. (IT_write_glyphs): Rewrite to use encode_terminal_code.
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c540
1 files changed, 248 insertions, 292 deletions
diff --git a/src/msdos.c b/src/msdos.c
index b3877172d51..6f0286240e2 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -50,6 +50,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50 50
51#include "msdos.h" 51#include "msdos.h"
52#include "systime.h" 52#include "systime.h"
53#include "frame.h"
53#include "termhooks.h" 54#include "termhooks.h"
54#include "termchar.h" 55#include "termchar.h"
55#include "dispextern.h" 56#include "dispextern.h"
@@ -58,7 +59,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58#include "character.h" 59#include "character.h"
59#include "coding.h" 60#include "coding.h"
60#include "disptab.h" 61#include "disptab.h"
61#include "frame.h"
62#include "window.h" 62#include "window.h"
63#include "buffer.h" 63#include "buffer.h"
64#include "commands.h" 64#include "commands.h"
@@ -80,6 +80,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
80#define _dos_ds _go32_info_block.selector_for_linear_memory 80#define _dos_ds _go32_info_block.selector_for_linear_memory
81#endif 81#endif
82 82
83extern FILE *prdebug;
84
83#if __DJGPP__ > 1 85#if __DJGPP__ > 1
84 86
85#include <signal.h> 87#include <signal.h>
@@ -148,8 +150,10 @@ mouse_on ()
148 150
149 if (have_mouse > 0 && !mouse_visible) 151 if (have_mouse > 0 && !mouse_visible)
150 { 152 {
151 if (termscript) 153 struct tty_display_info *tty = CURTTY ();
152 fprintf (termscript, "<M_ON>"); 154
155 if (tty->termscript)
156 fprintf (tty->termscript, "<M_ON>");
153 regs.x.ax = 0x0001; 157 regs.x.ax = 0x0001;
154 int86 (0x33, &regs, &regs); 158 int86 (0x33, &regs, &regs);
155 mouse_visible = 1; 159 mouse_visible = 1;
@@ -163,8 +167,10 @@ mouse_off ()
163 167
164 if (have_mouse > 0 && mouse_visible) 168 if (have_mouse > 0 && mouse_visible)
165 { 169 {
166 if (termscript) 170 struct tty_display_info *tty = CURTTY ();
167 fprintf (termscript, "<M_OFF>"); 171
172 if (tty->termscript)
173 fprintf (tty->termscript, "<M_OFF>");
168 regs.x.ax = 0x0002; 174 regs.x.ax = 0x0002;
169 int86 (0x33, &regs, &regs); 175 int86 (0x33, &regs, &regs);
170 mouse_visible = 0; 176 mouse_visible = 0;
@@ -226,9 +232,10 @@ mouse_moveto (x, y)
226 int x, y; 232 int x, y;
227{ 233{
228 union REGS regs; 234 union REGS regs;
235 struct tty_display_info *tty = CURTTY ();
229 236
230 if (termscript) 237 if (tty->termscript)
231 fprintf (termscript, "<M_XY=%dx%d>", x, y); 238 fprintf (tty->termscript, "<M_XY=%dx%d>", x, y);
232 regs.x.ax = 0x0004; 239 regs.x.ax = 0x0004;
233 mouse_last_x = regs.x.cx = x * 8; 240 mouse_last_x = regs.x.cx = x * 8;
234 mouse_last_y = regs.x.dx = y * 8; 241 mouse_last_y = regs.x.dx = y * 8;
@@ -340,9 +347,10 @@ void
340mouse_init () 347mouse_init ()
341{ 348{
342 union REGS regs; 349 union REGS regs;
350 struct tty_display_info *tty = CURTTY ();
343 351
344 if (termscript) 352 if (tty->termscript)
345 fprintf (termscript, "<M_INIT>"); 353 fprintf (tty->termscript, "<M_INIT>");
346 354
347 regs.x.ax = 0x0021; 355 regs.x.ax = 0x0021;
348 int86 (0x33, &regs, &regs); 356 int86 (0x33, &regs, &regs);
@@ -400,7 +408,7 @@ static int term_setup_done;
400static unsigned short outside_cursor; 408static unsigned short outside_cursor;
401 409
402/* Similar to the_only_frame. */ 410/* Similar to the_only_frame. */
403struct x_output the_only_x_display; 411struct tty_display_info the_only_display_info;
404 412
405/* Support for DOS/V (allows Japanese characters to be displayed on 413/* Support for DOS/V (allows Japanese characters to be displayed on
406 standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */ 414 standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */
@@ -691,7 +699,7 @@ dos_set_window_size (rows, cols)
691 if (current_rows != *rows || current_cols != *cols) 699 if (current_rows != *rows || current_cols != *cols)
692 { 700 {
693 struct frame *f = SELECTED_FRAME(); 701 struct frame *f = SELECTED_FRAME();
694 struct display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 702 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
695 Lisp_Object window = dpyinfo->mouse_face_window; 703 Lisp_Object window = dpyinfo->mouse_face_window;
696 704
697 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f) 705 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f)
@@ -744,6 +752,7 @@ msdos_set_cursor_shape (struct frame *f, int start_line, int width)
744 unsigned desired_cursor; 752 unsigned desired_cursor;
745 __dpmi_regs regs; 753 __dpmi_regs regs;
746 int max_line, top_line, bot_line; 754 int max_line, top_line, bot_line;
755 struct tty_display_info *tty = FRAME_TTY (f);
747 756
748 /* Avoid the costly BIOS call if F isn't the currently selected 757 /* Avoid the costly BIOS call if F isn't the currently selected
749 frame. Allow for NULL as unconditionally meaning the selected 758 frame. Allow for NULL as unconditionally meaning the selected
@@ -751,8 +760,8 @@ msdos_set_cursor_shape (struct frame *f, int start_line, int width)
751 if (f && f != SELECTED_FRAME()) 760 if (f && f != SELECTED_FRAME())
752 return; 761 return;
753 762
754 if (termscript) 763 if (tty->termscript)
755 fprintf (termscript, "\nCURSOR SHAPE=(%d,%d)", start_line, width); 764 fprintf (tty->termscript, "\nCURSOR SHAPE=(%d,%d)", start_line, width);
756 765
757 /* The character cell size in scan lines is stored at 40:85 in the 766 /* The character cell size in scan lines is stored at 40:85 in the
758 BIOS data area. */ 767 BIOS data area. */
@@ -862,7 +871,7 @@ IT_set_cursor_type (struct frame *f, Lisp_Object cursor_type)
862} 871}
863 872
864static void 873static void
865IT_ring_bell (void) 874IT_ring_bell (struct frame *f)
866{ 875{
867 if (visible_bell) 876 if (visible_bell)
868 { 877 {
@@ -890,6 +899,7 @@ IT_set_face (int face)
890 struct face *fp = FACE_FROM_ID (sf, face); 899 struct face *fp = FACE_FROM_ID (sf, face);
891 struct face *dfp = FACE_FROM_ID (sf, DEFAULT_FACE_ID); 900 struct face *dfp = FACE_FROM_ID (sf, DEFAULT_FACE_ID);
892 unsigned long fg, bg, dflt_fg, dflt_bg; 901 unsigned long fg, bg, dflt_fg, dflt_bg;
902 struct tty_display_info *tty = FRAME_TTY (sf);
893 903
894 if (!fp) 904 if (!fp)
895 { 905 {
@@ -934,8 +944,8 @@ IT_set_face (int face)
934 fg = bg; 944 fg = bg;
935 bg = tem2; 945 bg = tem2;
936 } 946 }
937 if (termscript) 947 if (tty->termscript)
938 fprintf (termscript, "<FACE %d: %d/%d[FG:%d/BG:%d]>", face, 948 fprintf (tty->termscript, "<FACE %d: %d/%d[FG:%d/BG:%d]>", face,
939 fp->foreground, fp->background, fg, bg); 949 fp->foreground, fp->background, fg, bg);
940 if (fg >= 0 && fg < 16) 950 if (fg >= 0 && fg < 16)
941 { 951 {
@@ -950,9 +960,10 @@ IT_set_face (int face)
950} 960}
951 961
952Lisp_Object Vdos_unsupported_char_glyph; 962Lisp_Object Vdos_unsupported_char_glyph;
953 963extern unsigned char *encode_terminal_code (struct glyph *, int,
964 struct coding_system *);
954static void 965static void
955IT_write_glyphs (struct glyph *str, int str_len) 966IT_write_glyphs (struct frame *f, struct glyph *str, int str_len)
956{ 967{
957 unsigned char *screen_buf, *screen_bp, *screen_buf_end, *bp; 968 unsigned char *screen_buf, *screen_bp, *screen_buf_end, *bp;
958 int unsupported_face = 0; 969 int unsupported_face = 0;
@@ -961,15 +972,9 @@ IT_write_glyphs (struct glyph *str, int str_len)
961 register int sl = str_len; 972 register int sl = str_len;
962 register int tlen = GLYPH_TABLE_LENGTH; 973 register int tlen = GLYPH_TABLE_LENGTH;
963 register Lisp_Object *tbase = GLYPH_TABLE_BASE; 974 register Lisp_Object *tbase = GLYPH_TABLE_BASE;
964 975 struct tty_display_info *tty = FRAME_TTY (f);
965 /* If terminal_coding does any conversion, use it, otherwise use
966 safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here
967 because it always returns 1 if terminal_coding.src_multibyte is 1. */
968 struct coding_system *coding =
969 (terminal_coding.common_flags & CODING_REQUIRE_ENCODING_MASK
970 ? &terminal_coding
971 : &safe_terminal_coding);
972 struct frame *sf; 976 struct frame *sf;
977 unsigned char *conversion_buffer;
973 978
974 /* Do we need to consider conversion of unibyte characters to 979 /* Do we need to consider conversion of unibyte characters to
975 multibyte? */ 980 multibyte? */
@@ -977,18 +982,16 @@ IT_write_glyphs (struct glyph *str, int str_len)
977 = (NILP (current_buffer->enable_multibyte_characters) 982 = (NILP (current_buffer->enable_multibyte_characters)
978 && unibyte_display_via_language_environment); 983 && unibyte_display_via_language_environment);
979 984
980 unsigned char conversion_buffer[256]; 985 /* If terminal_coding does any conversion, use it, otherwise use
981 int conversion_buffer_size = sizeof conversion_buffer; 986 safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here
987 because it always returns 1 if terminal_coding.src_multibyte is 1. */
988 struct coding_system *coding = FRAME_TERMINAL_CODING (f);
989
990 if (!(coding->common_flags & CODING_REQUIRE_ENCODING_MASK))
991 coding = &safe_terminal_coding;
982 992
983 if (str_len <= 0) return; 993 if (str_len <= 0) return;
984 994
985 /* Set up the unsupported character glyph */
986 if (!NILP (Vdos_unsupported_char_glyph))
987 {
988 unsupported_char = GLYPH_CHAR (XINT (Vdos_unsupported_char_glyph));
989 unsupported_face = GLYPH_FACE (XINT (Vdos_unsupported_char_glyph));
990 }
991
992 screen_buf = screen_bp = alloca (str_len * 2); 995 screen_buf = screen_bp = alloca (str_len * 2);
993 screen_buf_end = screen_buf + str_len * 2; 996 screen_buf_end = screen_buf + str_len * 2;
994 sf = SELECTED_FRAME(); 997 sf = SELECTED_FRAME();
@@ -1002,12 +1005,10 @@ IT_write_glyphs (struct glyph *str, int str_len)
1002 1005
1003 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at 1006 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
1004 the tail. */ 1007 the tail. */
1005 terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK; 1008 coding->mode &= ~CODING_MODE_LAST_BLOCK;
1006 while (sl) 1009 while (sl > 0)
1007 { 1010 {
1008 int cf, chlen, enclen; 1011 int cf;
1009 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *buf;
1010 unsigned ch;
1011 1012
1012 /* Glyphs with GLYPH_MASK_PADDING bit set are actually there 1013 /* Glyphs with GLYPH_MASK_PADDING bit set are actually there
1013 only for the redisplay code to know how many columns does 1014 only for the redisplay code to know how many columns does
@@ -1019,139 +1020,55 @@ IT_write_glyphs (struct glyph *str, int str_len)
1019 } 1020 }
1020 else 1021 else
1021 { 1022 {
1022 GLYPH g;
1023 int glyph_not_in_table = 0;
1024
1025 SET_GLYPH_FROM_CHAR_GLYPH (g, *str);
1026
1027 if (GLYPH_INVALID_P (g) || GLYPH_SIMPLE_P (tbase, tlen, g))
1028 {
1029 /* This glyph doesn't have an entry in Vglyph_table. */
1030 ch = str->u.ch;
1031 glyph_not_in_table = 1;
1032 }
1033 else
1034 {
1035 /* This glyph has an entry in Vglyph_table, so process
1036 any aliases before testing for simpleness. */
1037 GLYPH_FOLLOW_ALIASES (tbase, tlen, g);
1038 ch = GLYPH_CHAR (g);
1039 }
1040
1041 /* Convert the character code to multibyte, if they
1042 requested display via language environment. We only want
1043 to convert unibyte characters to multibyte in unibyte
1044 buffers! Otherwise, the 8-bit value in CH came from the
1045 display table set up to display foreign characters. */
1046 if (SINGLE_BYTE_CHAR_P (ch) && convert_unibyte_characters
1047 && (ch >= 0240
1048 || (ch >= 0200 && !NILP (Vnonascii_translation_table))))
1049 ch = unibyte_char_to_multibyte (ch);
1050
1051 /* Invalid characters are displayed with a special glyph. */
1052 if (! CHAR_VALID_P (ch, 0))
1053 {
1054 ch = !NILP (Vdos_unsupported_char_glyph)
1055 ? XINT (Vdos_unsupported_char_glyph)
1056 : '\177';
1057 SET_GLYPH_CHAR (g, ch);
1058 }
1059
1060 /* If the face of this glyph is different from the current 1023 /* If the face of this glyph is different from the current
1061 screen face, update the screen attribute byte. */ 1024 screen face, update the screen attribute byte. */
1062 cf = str->face_id; 1025 cf = str->face_id;
1063 if (cf != screen_face) 1026 if (cf != screen_face)
1064 IT_set_face (cf); /* handles invalid faces gracefully */ 1027 IT_set_face (cf); /* handles invalid faces gracefully */
1065 1028
1066 if (glyph_not_in_table || GLYPH_SIMPLE_P (tbase, tlen, g)) 1029 if (sl <= 1)
1067 { 1030 /* This is the last glyph. */
1068 /* We generate the multi-byte form of CH in WORKBUF. */ 1031 coding->mode |= CODING_MODE_LAST_BLOCK;
1069 chlen = CHAR_STRING (ch, workbuf);
1070 buf = workbuf;
1071 }
1072 else
1073 {
1074 /* We have a string in Vglyph_table. */
1075 chlen = GLYPH_LENGTH (tbase, g);
1076 buf = GLYPH_STRING (tbase, g);
1077 }
1078 1032
1079 /* If the character is not multibyte, don't bother converting it. */ 1033 conversion_buffer = encode_terminal_code (str, 1, coding);
1080 if (chlen == 1) 1034 if (coding->produced > 0)
1081 {
1082 *conversion_buffer = (unsigned char)ch;
1083 chlen = 0;
1084 enclen = 1;
1085 }
1086 else
1087 { 1035 {
1088 coding->src_multibyte = 1; 1036 if (2*coding->produced > screen_buf_end - screen_bp)
1089 encode_coding (coding, buf, conversion_buffer, chlen,
1090 conversion_buffer_size);
1091 chlen -= coding->consumed;
1092 enclen = coding->produced;
1093
1094 /* Replace glyph codes that cannot be converted by
1095 terminal_coding with Vdos_unsupported_char_glyph. */
1096 if (*conversion_buffer == '?')
1097 { 1037 {
1098 unsigned char *cbp = conversion_buffer; 1038 /* The allocated buffer for screen writes is too small.
1099 1039 Flush it and loop again without incrementing STR, so
1100 while (cbp < conversion_buffer + enclen && *cbp == '?') 1040 that the next loop will begin with the same glyph. */
1101 *cbp++ = unsupported_char; 1041 int nbytes = screen_bp - screen_buf;
1102 if (unsupported_face != screen_face) 1042
1103 IT_set_face (unsupported_face); 1043 mouse_off_maybe ();
1044 dosmemput (screen_buf, nbytes, (int)ScreenPrimary + offset);
1045 if (screen_virtual_segment)
1046 dosv_refresh_virtual_screen (offset, nbytes / 2);
1047 new_pos_X += nbytes / 2;
1048 offset += nbytes;
1049
1050 /* Prepare to reuse the same buffer again. */
1051 screen_bp = screen_buf;
1052 continue;
1104 } 1053 }
1105 } 1054 else
1106
1107 if (enclen + chlen > screen_buf_end - screen_bp)
1108 {
1109 /* The allocated buffer for screen writes is too small.
1110 Flush it and loop again without incrementing STR, so
1111 that the next loop will begin with the same glyph. */
1112 int nbytes = screen_bp - screen_buf;
1113
1114 mouse_off_maybe ();
1115 dosmemput (screen_buf, nbytes, (int)ScreenPrimary + offset);
1116 if (screen_virtual_segment)
1117 dosv_refresh_virtual_screen (offset, nbytes / 2);
1118 new_pos_X += nbytes / 2;
1119 offset += nbytes;
1120
1121 /* Prepare to reuse the same buffer again. */
1122 screen_bp = screen_buf;
1123 }
1124 else
1125 {
1126 /* There's enough place in the allocated buffer to add
1127 the encoding of this glyph. */
1128
1129 /* First, copy the encoded bytes. */
1130 for (bp = conversion_buffer; enclen--; bp++)
1131 { 1055 {
1132 *screen_bp++ = (unsigned char)*bp; 1056 /* There's enough place in the allocated buffer to add
1133 *screen_bp++ = ScreenAttrib; 1057 the encoding of this glyph. */
1134 if (termscript)
1135 fputc (*bp, termscript);
1136 }
1137 1058
1138 /* Now copy the bytes not consumed by the encoding. */ 1059 /* Copy the encoded bytes to the allocated buffer. */
1139 if (chlen > 0) 1060 for (bp = conversion_buffer; coding->produced--; bp++)
1140 {
1141 buf += coding->consumed;
1142 while (chlen--)
1143 { 1061 {
1144 if (termscript) 1062 *screen_bp++ = (unsigned char)*bp;
1145 fputc (*buf, termscript);
1146 *screen_bp++ = (unsigned char)*buf++;
1147 *screen_bp++ = ScreenAttrib; 1063 *screen_bp++ = ScreenAttrib;
1064 if (tty->termscript)
1065 fputc (*bp, tty->termscript);
1148 } 1066 }
1149 } 1067 }
1150
1151 /* Update STR and its remaining length. */
1152 str++;
1153 sl--;
1154 } 1068 }
1069 /* Update STR and its remaining length. */
1070 str++;
1071 sl--;
1155 } 1072 }
1156 } 1073 }
1157 1074
@@ -1161,32 +1078,6 @@ IT_write_glyphs (struct glyph *str, int str_len)
1161 if (screen_virtual_segment) 1078 if (screen_virtual_segment)
1162 dosv_refresh_virtual_screen (offset, (screen_bp - screen_buf) / 2); 1079 dosv_refresh_virtual_screen (offset, (screen_bp - screen_buf) / 2);
1163 new_pos_X += (screen_bp - screen_buf) / 2; 1080 new_pos_X += (screen_bp - screen_buf) / 2;
1164
1165 /* We may have to output some codes to terminate the writing. */
1166 if (CODING_REQUIRE_FLUSHING (coding))
1167 {
1168 coding->mode |= CODING_MODE_LAST_BLOCK;
1169 encode_coding (coding, "", conversion_buffer, 0, conversion_buffer_size);
1170 if (coding->produced > 0)
1171 {
1172 screen_buf = alloca (coding->produced * 2);
1173 for (screen_bp = screen_buf, bp = conversion_buffer;
1174 coding->produced--; bp++)
1175 {
1176 *screen_bp++ = (unsigned char)*bp;
1177 *screen_bp++ = ScreenAttrib;
1178 if (termscript)
1179 fputc (*bp, termscript);
1180 }
1181 offset += screen_bp - screen_buf;
1182 mouse_off_maybe ();
1183 dosmemput (screen_buf, screen_bp - screen_buf,
1184 (int)ScreenPrimary + offset);
1185 if (screen_virtual_segment)
1186 dosv_refresh_virtual_screen (offset, (screen_bp - screen_buf) / 2);
1187 new_pos_X += (screen_bp - screen_buf) / 2;
1188 }
1189 }
1190} 1081}
1191 1082
1192/************************************************************************ 1083/************************************************************************
@@ -1214,12 +1105,13 @@ IT_set_mouse_pointer (int mode)
1214/* Display the active region described by mouse_face_* 1105/* Display the active region described by mouse_face_*
1215 in its mouse-face if HL > 0, in its normal face if HL = 0. */ 1106 in its mouse-face if HL > 0, in its normal face if HL = 0. */
1216static void 1107static void
1217show_mouse_face (struct display_info *dpyinfo, int hl) 1108show_mouse_face (struct tty_display_info *dpyinfo, int hl)
1218{ 1109{
1219 struct window *w = XWINDOW (dpyinfo->mouse_face_window); 1110 struct window *w = XWINDOW (dpyinfo->mouse_face_window);
1220 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1111 struct frame *f = XFRAME (WINDOW_FRAME (w));
1221 int i; 1112 int i;
1222 struct face *fp; 1113 struct face *fp;
1114 struct tty_display_info *tty = FRAME_TTY (f);
1223 1115
1224 1116
1225 /* If window is in the process of being destroyed, don't bother 1117 /* If window is in the process of being destroyed, don't bother
@@ -1279,8 +1171,8 @@ show_mouse_face (struct display_info *dpyinfo, int hl)
1279 int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1; 1171 int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1;
1280 int start_offset = offset; 1172 int start_offset = offset;
1281 1173
1282 if (termscript) 1174 if (tty->termscript)
1283 fprintf (termscript, "\n<MH+ %d-%d:%d>", 1175 fprintf (tty->termscript, "\n<MH+ %d-%d:%d>",
1284 kstart, kstart + nglyphs - 1, vpos); 1176 kstart, kstart + nglyphs - 1, vpos);
1285 1177
1286 mouse_off (); 1178 mouse_off ();
@@ -1319,12 +1211,12 @@ show_mouse_face (struct display_info *dpyinfo, int hl)
1319 new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w); 1211 new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w);
1320 new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w); 1212 new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w);
1321 1213
1322 if (termscript) 1214 if (tty->termscript)
1323 fprintf (termscript, "<MH- %d-%d:%d>", 1215 fprintf (tty->termscript, "<MH- %d-%d:%d>",
1324 new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y); 1216 new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y);
1325 IT_write_glyphs (row->glyphs[TEXT_AREA] + start_hpos, nglyphs); 1217 IT_write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
1326 if (termscript) 1218 if (tty->termscript)
1327 fputs ("\n", termscript); 1219 fputs ("\n", tty->termscript);
1328 new_pos_X = save_x; 1220 new_pos_X = save_x;
1329 new_pos_Y = save_y; 1221 new_pos_Y = save_y;
1330 } 1222 }
@@ -1338,7 +1230,7 @@ show_mouse_face (struct display_info *dpyinfo, int hl)
1338/* Clear out the mouse-highlighted active region. 1230/* Clear out the mouse-highlighted active region.
1339 Redraw it un-highlighted first. */ 1231 Redraw it un-highlighted first. */
1340static void 1232static void
1341clear_mouse_face (struct display_info *dpyinfo) 1233clear_mouse_face (struct tty_display_info *dpyinfo)
1342{ 1234{
1343 if (!dpyinfo->mouse_face_hidden && ! NILP (dpyinfo->mouse_face_window)) 1235 if (!dpyinfo->mouse_face_hidden && ! NILP (dpyinfo->mouse_face_window))
1344 show_mouse_face (dpyinfo, 0); 1236 show_mouse_face (dpyinfo, 0);
@@ -1431,7 +1323,7 @@ static void
1431IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p) 1323IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p)
1432{ 1324{
1433 struct frame *f = XFRAME (w->frame); 1325 struct frame *f = XFRAME (w->frame);
1434 struct display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 1326 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
1435 struct glyph_row *row; 1327 struct glyph_row *row;
1436 1328
1437 if (mode_line_p) 1329 if (mode_line_p)
@@ -1480,7 +1372,7 @@ IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p)
1480static void 1372static void
1481IT_note_mouse_highlight (struct frame *f, int x, int y) 1373IT_note_mouse_highlight (struct frame *f, int x, int y)
1482{ 1374{
1483 struct display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 1375 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
1484 enum window_part part = ON_NOTHING; 1376 enum window_part part = ON_NOTHING;
1485 Lisp_Object window; 1377 Lisp_Object window;
1486 struct window *w; 1378 struct window *w;
@@ -1749,19 +1641,20 @@ IT_note_mouse_highlight (struct frame *f, int x, int y)
1749} 1641}
1750 1642
1751static void 1643static void
1752IT_clear_end_of_line (int first_unused) 1644IT_clear_end_of_line (struct frame *f, int first_unused)
1753{ 1645{
1754 char *spaces, *sp; 1646 char *spaces, *sp;
1755 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); 1647 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
1756 extern int fatal_error_in_progress; 1648 extern int fatal_error_in_progress;
1649 struct tty_display_info *tty = FRAME_TTY (f);
1757 1650
1758 if (new_pos_X >= first_unused || fatal_error_in_progress) 1651 if (new_pos_X >= first_unused || fatal_error_in_progress)
1759 return; 1652 return;
1760 1653
1761 IT_set_face (0); 1654 IT_set_face (0);
1762 i = (j = first_unused - new_pos_X) * 2; 1655 i = (j = first_unused - new_pos_X) * 2;
1763 if (termscript) 1656 if (tty->termscript)
1764 fprintf (termscript, "<CLR:EOL[%d..%d)>", new_pos_X, first_unused); 1657 fprintf (tty->termscript, "<CLR:EOL[%d..%d)>", new_pos_X, first_unused);
1765 spaces = sp = alloca (i); 1658 spaces = sp = alloca (i);
1766 1659
1767 while (--j >= 0) 1660 while (--j >= 0)
@@ -1781,10 +1674,12 @@ IT_clear_end_of_line (int first_unused)
1781} 1674}
1782 1675
1783static void 1676static void
1784IT_clear_screen (void) 1677IT_clear_screen (struct frame *f)
1785{ 1678{
1786 if (termscript) 1679 struct tty_display_info *tty = FRAME_TTY (f);
1787 fprintf (termscript, "<CLR:SCR>"); 1680
1681 if (tty->termscript)
1682 fprintf (tty->termscript, "<CLR:SCR>");
1788 /* We are sometimes called (from clear_garbaged_frames) when a new 1683 /* We are sometimes called (from clear_garbaged_frames) when a new
1789 frame is being created, but its faces are not yet realized. In 1684 frame is being created, but its faces are not yet realized. In
1790 such a case we cannot call IT_set_face, since it will fail to find 1685 such a case we cannot call IT_set_face, since it will fail to find
@@ -1803,23 +1698,27 @@ IT_clear_screen (void)
1803} 1698}
1804 1699
1805static void 1700static void
1806IT_clear_to_end (void) 1701IT_clear_to_end (struct frame *f)
1807{ 1702{
1808 if (termscript) 1703 struct tty_display_info *tty = FRAME_TTY (f);
1809 fprintf (termscript, "<CLR:EOS>"); 1704
1705 if (tty->termscript)
1706 fprintf (tty->termscript, "<CLR:EOS>");
1810 1707
1811 while (new_pos_Y < screen_size_Y) { 1708 while (new_pos_Y < screen_size_Y) {
1812 new_pos_X = 0; 1709 new_pos_X = 0;
1813 IT_clear_end_of_line (screen_size_X); 1710 IT_clear_end_of_line (f, screen_size_X);
1814 new_pos_Y++; 1711 new_pos_Y++;
1815 } 1712 }
1816} 1713}
1817 1714
1818static void 1715static void
1819IT_cursor_to (int y, int x) 1716IT_cursor_to (struct frame *f, int y, int x)
1820{ 1717{
1821 if (termscript) 1718 struct tty_display_info *tty = FRAME_TTY (f);
1822 fprintf (termscript, "\n<XY=%dx%d>", x, y); 1719
1720 if (tty->termscript)
1721 fprintf (tty->termscript, "\n<XY=%dx%d>", x, y);
1823 new_pos_X = x; 1722 new_pos_X = x;
1824 new_pos_Y = y; 1723 new_pos_Y = y;
1825} 1724}
@@ -1829,8 +1728,10 @@ static int cursor_cleared;
1829static void 1728static void
1830IT_display_cursor (int on) 1729IT_display_cursor (int on)
1831{ 1730{
1832 if (termscript) 1731 struct tty_display_info *tty = CURTTY ();
1833 fprintf (termscript, "\nCURSOR %s", on ? "ON" : "OFF"); 1732
1733 if (tty->termscript)
1734 fprintf (tty->termscript, "\nCURSOR %s", on ? "ON" : "OFF");
1834 if (on && cursor_cleared) 1735 if (on && cursor_cleared)
1835 { 1736 {
1836 ScreenSetCursor (current_pos_Y, current_pos_X); 1737 ScreenSetCursor (current_pos_Y, current_pos_X);
@@ -1868,6 +1769,7 @@ IT_cmgoto (FRAME_PTR f)
1868 /* Only set the cursor to where it should be if the display is 1769 /* Only set the cursor to where it should be if the display is
1869 already in sync with the window contents. */ 1770 already in sync with the window contents. */
1870 int update_cursor_pos = 1; /* MODIFF == unchanged_modified; */ 1771 int update_cursor_pos = 1; /* MODIFF == unchanged_modified; */
1772 struct tty_display_info *tty = FRAME_TTY (f);
1871 1773
1872 /* FIXME: This needs to be rewritten for the new redisplay, or 1774 /* FIXME: This needs to be rewritten for the new redisplay, or
1873 removed. */ 1775 removed. */
@@ -1917,8 +1819,8 @@ IT_cmgoto (FRAME_PTR f)
1917 && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y)) 1819 && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y))
1918 { 1820 {
1919 ScreenSetCursor (current_pos_Y = new_pos_Y, current_pos_X = new_pos_X); 1821 ScreenSetCursor (current_pos_Y = new_pos_Y, current_pos_X = new_pos_X);
1920 if (termscript) 1822 if (tty->termscript)
1921 fprintf (termscript, "\n<CURSOR:%dx%d>", current_pos_X, current_pos_Y); 1823 fprintf (tty->termscript, "\n<CURSOR:%dx%d>", current_pos_X, current_pos_Y);
1922 } 1824 }
1923 1825
1924 /* Maybe cursor is invisible, so make it visible. */ 1826 /* Maybe cursor is invisible, so make it visible. */
@@ -1933,7 +1835,7 @@ IT_cmgoto (FRAME_PTR f)
1933static void 1835static void
1934IT_update_begin (struct frame *f) 1836IT_update_begin (struct frame *f)
1935{ 1837{
1936 struct display_info *display_info = FRAME_X_DISPLAY_INFO (f); 1838 struct tty_display_info *display_info = FRAME_X_DISPLAY_INFO (f);
1937 struct frame *mouse_face_frame = display_info->mouse_face_mouse_frame; 1839 struct frame *mouse_face_frame = display_info->mouse_face_mouse_frame;
1938 1840
1939 BLOCK_INPUT; 1841 BLOCK_INPUT;
@@ -1998,7 +1900,7 @@ IT_update_end (struct frame *f)
1998static void 1900static void
1999IT_frame_up_to_date (struct frame *f) 1901IT_frame_up_to_date (struct frame *f)
2000{ 1902{
2001 struct display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 1903 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2002 Lisp_Object new_cursor, frame_desired_cursor; 1904 Lisp_Object new_cursor, frame_desired_cursor;
2003 struct window *sw; 1905 struct window *sw;
2004 1906
@@ -2081,7 +1983,8 @@ IT_copy_glyphs (int xfrom, int xto, size_t len, int ypos)
2081 1983
2082/* Insert and delete glyphs. */ 1984/* Insert and delete glyphs. */
2083static void 1985static void
2084IT_insert_glyphs (start, len) 1986IT_insert_glyphs (f, start, len)
1987 struct frame *f;
2085 register struct glyph *start; 1988 register struct glyph *start;
2086 register int len; 1989 register int len;
2087{ 1990{
@@ -2092,11 +1995,12 @@ IT_insert_glyphs (start, len)
2092 IT_copy_glyphs (new_pos_X, new_pos_X + len, shift_by_width, new_pos_Y); 1995 IT_copy_glyphs (new_pos_X, new_pos_X + len, shift_by_width, new_pos_Y);
2093 1996
2094 /* Now write the glyphs to be inserted. */ 1997 /* Now write the glyphs to be inserted. */
2095 IT_write_glyphs (start, len); 1998 IT_write_glyphs (f, start, len);
2096} 1999}
2097 2000
2098static void 2001static void
2099IT_delete_glyphs (n) 2002IT_delete_glyphs (f, n)
2003 struct frame *f;
2100 register int n; 2004 register int n;
2101{ 2005{
2102 abort (); 2006 abort ();
@@ -2122,10 +2026,19 @@ extern Lisp_Object Qtitle;
2122 resumed, and whenever the screen is redrawn! */ 2026 resumed, and whenever the screen is redrawn! */
2123 2027
2124static void 2028static void
2125IT_set_terminal_modes (void) 2029IT_set_terminal_modes (struct terminal *term)
2126{ 2030{
2127 if (termscript) 2031 struct tty_display_info *tty;
2128 fprintf (termscript, "\n<SET_TERM>"); 2032
2033 /* If called with initial terminal, it's too early to do anything
2034 useful. */
2035 if (term->type == output_initial)
2036 return;
2037
2038 tty = term->display_info.tty;
2039
2040 if (tty->termscript)
2041 fprintf (tty->termscript, "\n<SET_TERM>");
2129 2042
2130 screen_size_X = ScreenCols (); 2043 screen_size_X = ScreenCols ();
2131 screen_size_Y = ScreenRows (); 2044 screen_size_Y = ScreenRows ();
@@ -2178,10 +2091,6 @@ IT_set_terminal_modes (void)
2178 ScreenGetCursor (&startup_pos_Y, &startup_pos_X); 2091 ScreenGetCursor (&startup_pos_Y, &startup_pos_X);
2179 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); 2092 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2));
2180 2093
2181 if (termscript)
2182 fprintf (termscript, "<SCREEN SAVED (dimensions=%dx%d)>\n",
2183 screen_size_X, screen_size_Y);
2184
2185 bright_bg (); 2094 bright_bg ();
2186} 2095}
2187 2096
@@ -2189,7 +2098,7 @@ IT_set_terminal_modes (void)
2189 suspended or killed. */ 2098 suspended or killed. */
2190 2099
2191static void 2100static void
2192IT_reset_terminal_modes (void) 2101IT_reset_terminal_modes (struct terminal *term)
2193{ 2102{
2194 int display_row_start = (int) ScreenPrimary; 2103 int display_row_start = (int) ScreenPrimary;
2195 int saved_row_len = startup_screen_size_X * 2; 2104 int saved_row_len = startup_screen_size_X * 2;
@@ -2197,9 +2106,10 @@ IT_reset_terminal_modes (void)
2197 int to_next_row = update_row_len; 2106 int to_next_row = update_row_len;
2198 unsigned char *saved_row = startup_screen_buffer; 2107 unsigned char *saved_row = startup_screen_buffer;
2199 int cursor_pos_X = ScreenCols () - 1, cursor_pos_Y = ScreenRows () - 1; 2108 int cursor_pos_X = ScreenCols () - 1, cursor_pos_Y = ScreenRows () - 1;
2109 struct tty_display_info *tty = term->display_info.tty;
2200 2110
2201 if (termscript) 2111 if (tty->termscript)
2202 fprintf (termscript, "\n<RESET_TERM>"); 2112 fprintf (tty->termscript, "\n<RESET_TERM>");
2203 2113
2204 if (!term_setup_done) 2114 if (!term_setup_done)
2205 return; 2115 return;
@@ -2238,8 +2148,8 @@ IT_reset_terminal_modes (void)
2238 if (current_rows > startup_screen_size_Y) 2148 if (current_rows > startup_screen_size_Y)
2239 current_rows = startup_screen_size_Y; 2149 current_rows = startup_screen_size_Y;
2240 2150
2241 if (termscript) 2151 if (tty->termscript)
2242 fprintf (termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n", 2152 fprintf (tty->termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n",
2243 update_row_len / 2, current_rows); 2153 update_row_len / 2, current_rows);
2244 2154
2245 while (current_rows--) 2155 while (current_rows--)
@@ -2259,12 +2169,13 @@ IT_reset_terminal_modes (void)
2259 2169
2260 ScreenSetCursor (cursor_pos_Y, cursor_pos_X); 2170 ScreenSetCursor (cursor_pos_Y, cursor_pos_X);
2261 xfree (startup_screen_buffer); 2171 xfree (startup_screen_buffer);
2172 startup_screen_buffer = NULL;
2262 2173
2263 term_setup_done = 0; 2174 term_setup_done = 0;
2264} 2175}
2265 2176
2266static void 2177static void
2267IT_set_terminal_window (int foo) 2178IT_set_terminal_window (struct frame *f, int foo)
2268{ 2179{
2269} 2180}
2270 2181
@@ -2315,6 +2226,7 @@ IT_set_frame_parameters (f, alist)
2315 unsigned long orig_fg, orig_bg; 2226 unsigned long orig_fg, orig_bg;
2316 Lisp_Object frame_bg, frame_fg; 2227 Lisp_Object frame_bg, frame_fg;
2317 extern Lisp_Object Qdefault, QCforeground, QCbackground; 2228 extern Lisp_Object Qdefault, QCforeground, QCbackground;
2229 struct tty_display_info *tty = FRAME_TTY (f);
2318 2230
2319 /* If we are creating a new frame, begin with the original screen colors 2231 /* If we are creating a new frame, begin with the original screen colors
2320 used for the initial frame. */ 2232 used for the initial frame. */
@@ -2363,8 +2275,8 @@ IT_set_frame_parameters (f, alist)
2363 } 2275 }
2364 2276
2365 need_to_reverse = reverse && !was_reverse; 2277 need_to_reverse = reverse && !was_reverse;
2366 if (termscript && need_to_reverse) 2278 if (tty->termscript && need_to_reverse)
2367 fprintf (termscript, "<INVERSE-VIDEO>\n"); 2279 fprintf (tty->termscript, "<INVERSE-VIDEO>\n");
2368 2280
2369 /* Now process the alist elements in reverse of specified order. */ 2281 /* Now process the alist elements in reverse of specified order. */
2370 for (i--; i >= 0; i--) 2282 for (i--; i >= 0; i--)
@@ -2401,8 +2313,8 @@ IT_set_frame_parameters (f, alist)
2401 fg_set = 1; 2313 fg_set = 1;
2402 } 2314 }
2403 redraw = 1; 2315 redraw = 1;
2404 if (termscript) 2316 if (tty->termscript)
2405 fprintf (termscript, "<FGCOLOR %lu>\n", new_color); 2317 fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color);
2406 } 2318 }
2407 } 2319 }
2408 else if (EQ (prop, Qbackground_color)) 2320 else if (EQ (prop, Qbackground_color))
@@ -2432,26 +2344,33 @@ IT_set_frame_parameters (f, alist)
2432 bg_set = 1; 2344 bg_set = 1;
2433 } 2345 }
2434 redraw = 1; 2346 redraw = 1;
2435 if (termscript) 2347 if (tty->termscript)
2436 fprintf (termscript, "<BGCOLOR %lu>\n", new_color); 2348 fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color);
2437 } 2349 }
2438 } 2350 }
2439 else if (EQ (prop, Qtitle)) 2351 else if (EQ (prop, Qtitle))
2440 { 2352 {
2441 x_set_title (f, val); 2353 x_set_title (f, val);
2442 if (termscript) 2354 if (tty->termscript)
2443 fprintf (termscript, "<TITLE: %s>\n", SDATA (val)); 2355 fprintf (tty->termscript, "<TITLE: %s>\n", SDATA (val));
2444 } 2356 }
2445 else if (EQ (prop, Qcursor_type)) 2357 else if (EQ (prop, Qcursor_type))
2446 { 2358 {
2447 IT_set_cursor_type (f, val); 2359 IT_set_cursor_type (f, val);
2448 if (termscript) 2360 if (tty->termscript)
2449 fprintf (termscript, "<CTYPE: %s>\n", 2361 fprintf (tty->termscript, "<CTYPE: %s>\n",
2450 EQ (val, Qbar) || EQ (val, Qhbar) 2362 EQ (val, Qbar) || EQ (val, Qhbar)
2451 || CONSP (val) && (EQ (XCAR (val), Qbar) 2363 || CONSP (val) && (EQ (XCAR (val), Qbar)
2452 || EQ (XCAR (val), Qhbar)) 2364 || EQ (XCAR (val), Qhbar))
2453 ? "bar" : "box"); 2365 ? "bar" : "box");
2454 } 2366 }
2367 else if (EQ (prop, Qtty_type))
2368 {
2369 internal_terminal_init ();
2370 if (tty->termscript)
2371 fprintf (tty->termscript, "<TERM_INIT done, TTY_TYPE: %.*s>\n",
2372 SBYTES (val), SDATA (val));
2373 }
2455 store_frame_param (f, prop, val); 2374 store_frame_param (f, prop, val);
2456 } 2375 }
2457 2376
@@ -2499,18 +2418,20 @@ internal_terminal_init ()
2499{ 2418{
2500 char *term = getenv ("TERM"), *colors; 2419 char *term = getenv ("TERM"), *colors;
2501 struct frame *sf = SELECTED_FRAME(); 2420 struct frame *sf = SELECTED_FRAME();
2421 struct tty_display_info *tty;
2502 2422
2503#ifdef HAVE_X_WINDOWS 2423#ifdef HAVE_X_WINDOWS
2504 if (!inhibit_window_system) 2424 if (!inhibit_window_system)
2505 return; 2425 return;
2506#endif 2426#endif
2507 2427
2428 /* If this is the initial terminal, we are done here. */
2429 if (sf->output_method == output_initial)
2430 return;
2431
2508 internal_terminal 2432 internal_terminal
2509 = (!noninteractive) && term && !strcmp (term, "internal"); 2433 = (!noninteractive) && term && !strcmp (term, "internal");
2510 2434
2511 if (getenv ("EMACSTEST"))
2512 termscript = fopen (getenv ("EMACSTEST"), "wt");
2513
2514#ifndef HAVE_X_WINDOWS 2435#ifndef HAVE_X_WINDOWS
2515 if (!internal_terminal || inhibit_window_system) 2436 if (!internal_terminal || inhibit_window_system)
2516 { 2437 {
@@ -2518,9 +2439,24 @@ internal_terminal_init ()
2518 return; 2439 return;
2519 } 2440 }
2520 2441
2521 Vwindow_system = intern ("pc"); 2442 tty = FRAME_TTY (sf);
2522 Vwindow_system_version = make_number (1); 2443 if (!tty->termscript && getenv ("EMACSTEST"))
2444 tty->termscript = fopen (getenv ("EMACSTEST"), "wt");
2445 if (tty->termscript)
2446 {
2447 time_t now = time (NULL);
2448 struct tm *tnow = localtime (&now);
2449 char tbuf[100];
2450
2451 strftime (tbuf, sizeof (tbuf) - 1, "%a %b %e %Y %H:%M:%S %Z", tnow);
2452 fprintf (tty->termscript, "\nEmacs session started at %s\n", tbuf);
2453 fprintf (tty->termscript, "=====================\n\n");
2454 }
2455
2456 Vinitial_window_system = current_kboard->Vwindow_system = Qpc;
2457 Vwindow_system_version = make_number (23); /* RE Emacs version */
2523 sf->output_method = output_msdos_raw; 2458 sf->output_method = output_msdos_raw;
2459 tty->terminal->type = output_msdos_raw;
2524 2460
2525 /* If Emacs was dumped on DOS/V machine, forget the stale VRAM address. */ 2461 /* If Emacs was dumped on DOS/V machine, forget the stale VRAM address. */
2526 screen_old_address = 0; 2462 screen_old_address = 0;
@@ -2528,7 +2464,6 @@ internal_terminal_init ()
2528 /* Forget the stale screen colors as well. */ 2464 /* Forget the stale screen colors as well. */
2529 initial_screen_colors[0] = initial_screen_colors[1] = -1; 2465 initial_screen_colors[0] = initial_screen_colors[1] = -1;
2530 2466
2531 bzero (&the_only_x_display, sizeof the_only_x_display);
2532 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = 7; /* White */ 2467 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = 7; /* White */
2533 FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ()) = 0; /* Black */ 2468 FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ()) = 0; /* Black */
2534 bright_bg (); 2469 bright_bg ();
@@ -2549,42 +2484,65 @@ internal_terminal_init ()
2549 if (colors[1] >= 0 && colors[1] < 16) 2484 if (colors[1] >= 0 && colors[1] < 16)
2550 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1]; 2485 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1];
2551 } 2486 }
2552 the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */ 2487 the_only_display_info.mouse_face_mouse_frame = NULL;
2553 the_only_x_display.display_info.mouse_face_mouse_frame = NULL; 2488 the_only_display_info.mouse_face_deferred_gc = 0;
2554 the_only_x_display.display_info.mouse_face_deferred_gc = 0; 2489 the_only_display_info.mouse_face_beg_row =
2555 the_only_x_display.display_info.mouse_face_beg_row = 2490 the_only_display_info.mouse_face_beg_col = -1;
2556 the_only_x_display.display_info.mouse_face_beg_col = -1; 2491 the_only_display_info.mouse_face_end_row =
2557 the_only_x_display.display_info.mouse_face_end_row = 2492 the_only_display_info.mouse_face_end_col = -1;
2558 the_only_x_display.display_info.mouse_face_end_col = -1; 2493 the_only_display_info.mouse_face_face_id = DEFAULT_FACE_ID;
2559 the_only_x_display.display_info.mouse_face_face_id = DEFAULT_FACE_ID; 2494 the_only_display_info.mouse_face_window = Qnil;
2560 the_only_x_display.display_info.mouse_face_window = Qnil; 2495 the_only_display_info.mouse_face_mouse_x =
2561 the_only_x_display.display_info.mouse_face_mouse_x = 2496 the_only_display_info.mouse_face_mouse_y = 0;
2562 the_only_x_display.display_info.mouse_face_mouse_y = 0; 2497 the_only_display_info.mouse_face_defer = 0;
2563 the_only_x_display.display_info.mouse_face_defer = 0; 2498 the_only_display_info.mouse_face_hidden = 0;
2564 the_only_x_display.display_info.mouse_face_hidden = 0; 2499
2500 if (have_mouse) /* detected in dos_ttraw, which see */
2501 {
2502 have_mouse = 1; /* enable mouse */
2503 mouse_visible = 0;
2504 mouse_setup_buttons (mouse_button_count);
2505 tty->terminal->mouse_position_hook = &mouse_get_pos;
2506 mouse_init ();
2507 }
2565 2508
2566 init_frame_faces (sf); 2509 if (tty->termscript && screen_size)
2510 fprintf (tty->termscript, "<SCREEN SAVED (dimensions=%dx%d)>\n",
2511 screen_size_X, screen_size_Y);
2567 2512
2568 ring_bell_hook = IT_ring_bell; 2513 init_frame_faces (sf);
2569 insert_glyphs_hook = IT_insert_glyphs;
2570 delete_glyphs_hook = IT_delete_glyphs;
2571 write_glyphs_hook = IT_write_glyphs;
2572 cursor_to_hook = raw_cursor_to_hook = IT_cursor_to;
2573 clear_to_end_hook = IT_clear_to_end;
2574 clear_end_of_line_hook = IT_clear_end_of_line;
2575 clear_frame_hook = IT_clear_screen;
2576 update_begin_hook = IT_update_begin;
2577 update_end_hook = IT_update_end;
2578 frame_up_to_date_hook = IT_frame_up_to_date;
2579
2580 /* These hooks are called by term.c without being checked. */
2581 set_terminal_modes_hook = IT_set_terminal_modes;
2582 reset_terminal_modes_hook = IT_reset_terminal_modes;
2583 set_terminal_window_hook = IT_set_terminal_window;
2584 TTY_CHAR_INS_DEL_OK (CURTTY ()) = 0;
2585#endif 2514#endif
2586} 2515}
2587 2516
2517void
2518initialize_msdos_display (struct terminal *term)
2519{
2520 term->rif = 0; /* we don't support window-based display */
2521 term->cursor_to_hook = term->raw_cursor_to_hook = IT_cursor_to;
2522 term->clear_to_end_hook = IT_clear_to_end;
2523 term->clear_frame_hook = IT_clear_screen;
2524 term->clear_end_of_line_hook = IT_clear_end_of_line;
2525 term->ins_del_lines_hook = 0;
2526 term->insert_glyphs_hook = IT_insert_glyphs;
2527 term->write_glyphs_hook = IT_write_glyphs;
2528 term->delete_glyphs_hook = IT_delete_glyphs;
2529 term->ring_bell_hook = IT_ring_bell;
2530 term->reset_terminal_modes_hook = IT_reset_terminal_modes;
2531 term->set_terminal_modes_hook = IT_set_terminal_modes;
2532 term->set_terminal_window_hook = IT_set_terminal_window;
2533 term->update_begin_hook = IT_update_begin;
2534 term->update_end_hook = IT_update_end;
2535 term->frame_up_to_date_hook = IT_frame_up_to_date;
2536 term->mouse_position_hook = 0; /* set later by dos_ttraw */
2537 term->frame_rehighlight_hook = 0;
2538 term->frame_raise_lower_hook = 0;
2539 term->set_vertical_scroll_bar_hook = 0;
2540 term->condemn_scroll_bars_hook = 0;
2541 term->redeem_scroll_bar_hook = 0;
2542 term->judge_scroll_bars_hook = 0;
2543 term->read_socket_hook = &tty_read_avail_input; /* from keyboard.c */
2544}
2545
2588dos_get_saved_screen (screen, rows, cols) 2546dos_get_saved_screen (screen, rows, cols)
2589 char **screen; 2547 char **screen;
2590 int *rows; 2548 int *rows;
@@ -3130,7 +3088,7 @@ dos_rawgetc ()
3130{ 3088{
3131 struct input_event event; 3089 struct input_event event;
3132 union REGS regs; 3090 union REGS regs;
3133 struct display_info *dpyinfo = FRAME_X_DISPLAY_INFO (SELECTED_FRAME()); 3091 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (SELECTED_FRAME());
3134 EVENT_INIT (event); 3092 EVENT_INIT (event);
3135 3093
3136#ifndef HAVE_X_WINDOWS 3094#ifndef HAVE_X_WINDOWS
@@ -3616,7 +3574,7 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
3616 { 3574 {
3617 int max_width = width + 2; 3575 int max_width = width + 2;
3618 3576
3619 IT_cursor_to (y + i, x); 3577 IT_cursor_to (sf, y + i, x);
3620 enabled 3578 enabled
3621 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]); 3579 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]);
3622 mousehere = (y + i == my && x <= mx && mx < x + width + 2); 3580 mousehere = (y + i == my && x <= mx && mx < x + width + 2);
@@ -3659,10 +3617,10 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
3659 3617
3660 SET_CHAR_GLYPH (*p, menu->submenu[i] ? 16 : ' ', face, 0); 3618 SET_CHAR_GLYPH (*p, menu->submenu[i] ? 16 : ' ', face, 0);
3661 p++; 3619 p++;
3662 IT_write_glyphs (text, max_width); 3620 IT_write_glyphs (sf, text, max_width);
3663 } 3621 }
3664 IT_update_end (sf); 3622 IT_update_end (sf);
3665 IT_cursor_to (row, col); 3623 IT_cursor_to (sf, row, col);
3666 xfree (text); 3624 xfree (text);
3667} 3625}
3668 3626
@@ -4600,11 +4558,18 @@ install_ctrl_break_check ()
4600 control chars by DOS. Determine the keyboard type. */ 4558 control chars by DOS. Determine the keyboard type. */
4601 4559
4602int 4560int
4603dos_ttraw () 4561dos_ttraw (struct tty_display_info *tty)
4604{ 4562{
4605 union REGS inregs, outregs; 4563 union REGS inregs, outregs;
4606 static int first_time = 1; 4564 static int first_time = 1;
4607 4565
4566 fprintf (prdebug, "dos_ttraw: output = %d\n", tty->terminal->type); fflush (prdebug);
4567
4568 /* If we are called for the initial terminal, it's too early to do
4569 anything, and termscript isn't set up. */
4570 if (tty->terminal->type == output_initial)
4571 return;
4572
4608 break_stat = getcbrk (); 4573 break_stat = getcbrk ();
4609 setcbrk (0); 4574 setcbrk (0);
4610#if __DJGPP__ < 2 4575#if __DJGPP__ < 2
@@ -4619,7 +4584,7 @@ dos_ttraw ()
4619 4584
4620 have_mouse = 0; 4585 have_mouse = 0;
4621 4586
4622 if (internal_terminal 4587 if (1
4623#ifdef HAVE_X_WINDOWS 4588#ifdef HAVE_X_WINDOWS
4624 && inhibit_window_system 4589 && inhibit_window_system
4625#endif 4590#endif
@@ -4637,15 +4602,8 @@ dos_ttraw ()
4637 int86 (0x33, &inregs, &outregs); 4602 int86 (0x33, &inregs, &outregs);
4638 have_mouse = (outregs.x.ax & 0xffff) == 0xffff; 4603 have_mouse = (outregs.x.ax & 0xffff) == 0xffff;
4639 } 4604 }
4640
4641 if (have_mouse) 4605 if (have_mouse)
4642 { 4606 mouse_button_count = outregs.x.bx;
4643 have_mouse = 1; /* enable mouse */
4644 mouse_visible = 0;
4645 mouse_setup_buttons (outregs.x.bx);
4646 mouse_position_hook = &mouse_get_pos;
4647 mouse_init ();
4648 }
4649 4607
4650#ifndef HAVE_X_WINDOWS 4608#ifndef HAVE_X_WINDOWS
4651#if __DJGPP__ >= 2 4609#if __DJGPP__ >= 2
@@ -4851,7 +4809,7 @@ run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv)
4851 emacs_close (outbak); 4809 emacs_close (outbak);
4852 emacs_close (errbak); 4810 emacs_close (errbak);
4853 4811
4854 dos_ttraw (); 4812 dos_ttraw (CURTTY ());
4855 if (have_mouse > 0) 4813 if (have_mouse > 0)
4856 { 4814 {
4857 mouse_init (); 4815 mouse_init ();
@@ -4959,10 +4917,8 @@ sigsetmask (x) int x; { return 0; }
4959sigblock (mask) int mask; { return 0; } 4917sigblock (mask) int mask; { return 0; }
4960#endif 4918#endif
4961 4919
4962void request_sigio (void) {}
4963setpgrp () {return 0; } 4920setpgrp () {return 0; }
4964setpriority (x,y,z) int x,y,z; { return 0; } 4921setpriority (x,y,z) int x,y,z; { return 0; }
4965void unrequest_sigio (void) {}
4966 4922
4967#if __DJGPP__ > 1 4923#if __DJGPP__ > 1
4968#if __DJGPP_MINOR__ < 2 4924#if __DJGPP_MINOR__ < 2