Mercurial > hg > xemacs-beta
comparison src/msdos.c @ 173:8eaf7971accc r20-3b13
Import from CVS: tag r20-3b13
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:49:09 +0200 |
parents | 131b0175ea99 |
children | 3d6bfa290dbd |
comparison
equal
deleted
inserted
replaced
172:a38aed19690b | 173:8eaf7971accc |
---|---|
47 static unsigned long | 47 static unsigned long |
48 event_timestamp (void) | 48 event_timestamp (void) |
49 { | 49 { |
50 struct time t; | 50 struct time t; |
51 unsigned long s; | 51 unsigned long s; |
52 | 52 |
53 gettime (&t); | 53 gettime (&t); |
54 s = t.ti_min; | 54 s = t.ti_min; |
55 s *= 60; | 55 s *= 60; |
56 s += t.ti_sec; | 56 s += t.ti_sec; |
57 s *= 1000; | 57 s *= 1000; |
58 s += t.ti_hund * 10; | 58 s += t.ti_hund * 10; |
59 | 59 |
60 return s; | 60 return s; |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 /* ------------------------ Mouse control --------------------------- | 64 /* ------------------------ Mouse control --------------------------- |
256 | 256 |
257 static | 257 static |
258 dos_direct_output (int y, int x, char *buf, int len) | 258 dos_direct_output (int y, int x, char *buf, int len) |
259 { | 259 { |
260 int t = (int) ScreenPrimary + 2 * (x + y * screen_size_X); | 260 int t = (int) ScreenPrimary + 2 * (x + y * screen_size_X); |
261 | 261 |
262 while (--len >= 0) { | 262 while (--len >= 0) { |
263 dosmemput (buf++, 1, t); | 263 dosmemput (buf++, 1, t); |
264 t += 2; | 264 t += 2; |
265 } | 265 } |
266 } | 266 } |
322 | 322 |
323 static void | 323 static void |
324 mouse_off_maybe (void) | 324 mouse_off_maybe (void) |
325 { | 325 { |
326 int x, y; | 326 int x, y; |
327 | 327 |
328 if (!mouse_visible) | 328 if (!mouse_visible) |
329 return; | 329 return; |
330 | 330 |
331 mouse_get_xy (&x, &y); | 331 mouse_get_xy (&x, &y); |
332 if (y != new_pos_Y || x < new_pos_X) | 332 if (y != new_pos_Y || x < new_pos_X) |
333 return; | 333 return; |
334 | 334 |
335 mouse_off (); | 335 mouse_off (); |
336 } | 336 } |
337 | 337 |
338 static | 338 static |
339 IT_ring_bell (void) | 339 IT_ring_bell (void) |
376 int newface; | 376 int newface; |
377 int ch, l = len; | 377 int ch, l = len; |
378 unsigned char *buf, *bp; | 378 unsigned char *buf, *bp; |
379 | 379 |
380 if (len == 0) return; | 380 if (len == 0) return; |
381 | 381 |
382 buf = bp = alloca (len * 2); | 382 buf = bp = alloca (len * 2); |
383 | 383 |
384 while (--l >= 0) | 384 while (--l >= 0) |
385 { | 385 { |
386 newface = FAST_GLYPH_FACE (*str); | 386 newface = FAST_GLYPH_FACE (*str); |
387 if (newface != screen_face) | 387 if (newface != screen_face) |
388 IT_set_face (newface); | 388 IT_set_face (newface); |
389 ch = FAST_GLYPH_CHAR (*str); | 389 ch = FAST_GLYPH_CHAR (*str); |
390 *bp++ = (unsigned char)ch; | 390 *bp++ = (unsigned char)ch; |
391 *bp++ = ScreenAttrib; | 391 *bp++ = ScreenAttrib; |
392 | 392 |
393 if (termscript) | 393 if (termscript) |
394 fputc (ch, termscript); | 394 fputc (ch, termscript); |
395 str++; | 395 str++; |
396 } | 396 } |
397 | 397 |
398 mouse_off_maybe (); | 398 mouse_off_maybe (); |
399 dosmemput (buf, 2 * len, | 399 dosmemput (buf, 2 * len, |
400 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | 400 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); |
401 new_pos_X += len; | 401 new_pos_X += len; |
402 } | 402 } |
403 | 403 |
404 static | 404 static |
410 IT_set_face (0); | 410 IT_set_face (0); |
411 if (termscript) | 411 if (termscript) |
412 fprintf (termscript, "<CLR:EOL>"); | 412 fprintf (termscript, "<CLR:EOL>"); |
413 i = (j = screen_size_X - new_pos_X) * 2; | 413 i = (j = screen_size_X - new_pos_X) * 2; |
414 spaces = sp = alloca (i); | 414 spaces = sp = alloca (i); |
415 | 415 |
416 while (--j >= 0) | 416 while (--j >= 0) |
417 { | 417 { |
418 *sp++ = ' '; | 418 *sp++ = ' '; |
419 *sp++ = ScreenAttrib; | 419 *sp++ = ScreenAttrib; |
420 } | 420 } |
421 | 421 |
422 mouse_off_maybe (); | 422 mouse_off_maybe (); |
423 dosmemput (spaces, i, | 423 dosmemput (spaces, i, |
424 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | 424 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); |
425 } | 425 } |
426 | 426 |
427 static | 427 static |
428 IT_clear_screen (void) | 428 IT_clear_screen (void) |
525 highlight = 0; | 525 highlight = 0; |
526 | 526 |
527 screen_size_X = ScreenCols (); | 527 screen_size_X = ScreenCols (); |
528 screen_size_Y = ScreenRows (); | 528 screen_size_Y = ScreenRows (); |
529 screen_size = screen_size_X * screen_size_Y; | 529 screen_size = screen_size_X * screen_size_Y; |
530 | 530 |
531 new_pos_X = new_pos_Y = 0; | 531 new_pos_X = new_pos_Y = 0; |
532 current_pos_X = current_pos_Y = -1; | 532 current_pos_X = current_pos_Y = -1; |
533 | 533 |
534 if (term_setup_done) | 534 if (term_setup_done) |
535 return; | 535 return; |
536 term_setup_done = 1; | 536 term_setup_done = 1; |
537 | 537 |
538 startup_screen_size_X = screen_size_X; | 538 startup_screen_size_X = screen_size_X; |
539 startup_screen_size_Y = screen_size_Y; | 539 startup_screen_size_Y = screen_size_Y; |
540 | 540 |
541 ScreenGetCursor (&startup_pos_Y, &startup_pos_X); | 541 ScreenGetCursor (&startup_pos_Y, &startup_pos_X); |
542 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); | 542 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); |
558 | 558 |
559 highlight = 0; | 559 highlight = 0; |
560 | 560 |
561 if (!term_setup_done) | 561 if (!term_setup_done) |
562 return; | 562 return; |
563 | 563 |
564 ScreenUpdate (startup_screen_buffer); | 564 ScreenUpdate (startup_screen_buffer); |
565 ScreenSetCursor (startup_pos_Y, startup_pos_X); | 565 ScreenSetCursor (startup_pos_Y, startup_pos_X); |
566 xfree (startup_screen_buffer); | 566 xfree (startup_screen_buffer); |
567 | 567 |
568 if (termscript) | 568 if (termscript) |
651 internal_terminal | 651 internal_terminal |
652 = (!noninteractive) && term && !strcmp (term, "internal"); | 652 = (!noninteractive) && term && !strcmp (term, "internal"); |
653 | 653 |
654 if (getenv ("EMACSTEST")) | 654 if (getenv ("EMACSTEST")) |
655 termscript = fopen (getenv ("EMACSTEST"), "wt"); | 655 termscript = fopen (getenv ("EMACSTEST"), "wt"); |
656 | 656 |
657 #ifndef HAVE_X_WINDOWS | 657 #ifndef HAVE_X_WINDOWS |
658 if (!internal_terminal || inhibit_window_system) | 658 if (!internal_terminal || inhibit_window_system) |
659 { | 659 { |
660 the_only_frame.output_method = output_termcap; | 660 the_only_frame.output_method = output_termcap; |
661 return; | 661 return; |
662 } | 662 } |
663 | 663 |
664 Vwindow_system = intern ("pc"); | 664 Vwindow_system = intern ("pc"); |
665 | 665 |
666 bzero (&the_only_x_display, sizeof the_only_x_display); | 666 bzero (&the_only_x_display, sizeof the_only_x_display); |
667 the_only_x_display.background_pixel = 7; /* White */ | 667 the_only_x_display.background_pixel = 7; /* White */ |
668 the_only_x_display.foreground_pixel = 0; /* Black */ | 668 the_only_x_display.foreground_pixel = 0; /* Black */ |
669 colors = getenv ("EMACSCOLORS"); | 669 colors = getenv ("EMACSCOLORS"); |
670 if (colors && strlen (colors) >= 2) | 670 if (colors && strlen (colors) >= 2) |
704 *cols = startup_screen_size_X; | 704 *cols = startup_screen_size_X; |
705 *rows = startup_screen_size_Y; | 705 *rows = startup_screen_size_Y; |
706 return 1; | 706 return 1; |
707 #else | 707 #else |
708 return 0; | 708 return 0; |
709 #endif | 709 #endif |
710 } | 710 } |
711 | 711 |
712 | 712 |
713 | 713 |
714 /* ----------------------- Keyboard control ---------------------- | 714 /* ----------------------- Keyboard control ---------------------- |
782 | 782 |
783 /* Initialize to US settings, for countries that don't have their own. */ | 783 /* Initialize to US settings, for countries that don't have their own. */ |
784 keyboard = keyboard_layout_list[0].keyboard_map; | 784 keyboard = keyboard_layout_list[0].keyboard_map; |
785 keyboard_map_all = always; | 785 keyboard_map_all = always; |
786 dos_keyboard_layout = 1; | 786 dos_keyboard_layout = 1; |
787 | 787 |
788 for (i = 0; i < (sizeof (keyboard_layout_list)/sizeof (struct keyboard_layout_list)); i++) | 788 for (i = 0; i < (sizeof (keyboard_layout_list)/sizeof (struct keyboard_layout_list)); i++) |
789 if (code == keyboard_layout_list[i].country_code) | 789 if (code == keyboard_layout_list[i].country_code) |
790 { | 790 { |
791 keyboard = keyboard_layout_list[i].keyboard_map; | 791 keyboard = keyboard_layout_list[i].keyboard_map; |
792 keyboard_map_all = always; | 792 keyboard_map_all = always; |
872 Map | 21, /* 'u' */ | 872 Map | 21, /* 'u' */ |
873 Map | 22, /* 'i' */ | 873 Map | 22, /* 'i' */ |
874 Map | 23, /* 'o' */ | 874 Map | 23, /* 'o' */ |
875 Map | 24, /* 'p' */ | 875 Map | 24, /* 'p' */ |
876 Map | 25, /* '[' */ | 876 Map | 25, /* '[' */ |
877 Map | 26, /* ']' */ | 877 Map | 26, /* ']' */ |
878 ModFct | 0x0d, /* Return */ | 878 ModFct | 0x0d, /* Return */ |
879 Ignore, /* Ctrl */ | 879 Ignore, /* Ctrl */ |
880 Map | 30, /* 'a' */ | 880 Map | 30, /* 'a' */ |
881 Map | 31, /* 's' */ | 881 Map | 31, /* 's' */ |
882 | 882 |
1049 dos_get_modifiers (int *keymask) | 1049 dos_get_modifiers (int *keymask) |
1050 { | 1050 { |
1051 union REGS regs; | 1051 union REGS regs; |
1052 int mask; | 1052 int mask; |
1053 int modifiers = 0; | 1053 int modifiers = 0; |
1054 | 1054 |
1055 /* Calculate modifier bits */ | 1055 /* Calculate modifier bits */ |
1056 regs.h.ah = extended_kbd ? 0x12 : 0x02; | 1056 regs.h.ah = extended_kbd ? 0x12 : 0x02; |
1057 int86 (0x16, ®s, ®s); | 1057 int86 (0x16, ®s, ®s); |
1058 | 1058 |
1059 if (!extended_kbd) | 1059 if (!extended_kbd) |
1060 { | 1060 { |
1061 mask = regs.h.al & (SHIFT_P | CTRL_P | ALT_P | | 1061 mask = regs.h.al & (SHIFT_P | CTRL_P | ALT_P | |
1062 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | 1062 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); |
1063 } | 1063 } |
1064 else | 1064 else |
1065 { | 1065 { |
1066 mask = regs.h.al & (SHIFT_P | | 1066 mask = regs.h.al & (SHIFT_P | |
1067 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | 1067 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); |
1068 | 1068 |
1069 /* Do not break international keyboard support. */ | 1069 /* Do not break international keyboard support. */ |
1070 /* When Keyb.Com is loaded, the right Alt key is */ | 1070 /* When Keyb.Com is loaded, the right Alt key is */ |
1071 /* used for accessing characters like { and } */ | 1071 /* used for accessing characters like { and } */ |
1072 if (regs.h.ah & 2) /* Left ALT pressed ? */ | 1072 if (regs.h.ah & 2) /* Left ALT pressed ? */ |
1073 mask |= ALT_P; | 1073 mask |= ALT_P; |
1084 { | 1084 { |
1085 mask |= SUPER_P; | 1085 mask |= SUPER_P; |
1086 modifiers |= super_modifier; | 1086 modifiers |= super_modifier; |
1087 } | 1087 } |
1088 } | 1088 } |
1089 | 1089 |
1090 if (regs.h.ah & 1) /* Left CTRL pressed | 1090 if (regs.h.ah & 1) /* Left CTRL pressed |
1091 mask |= CTRL_P; | 1091 mask |= CTRL_P; |
1092 | 1092 |
1093 if (regs.h.ah & 4) /* Right CTRL pressed ? */ | 1093 if (regs.h.ah & 4) /* Right CTRL pressed ? */ |
1094 { | 1094 { |
1129 Each input key receives two values in this vector: first the ASCII code,\n\ | 1129 Each input key receives two values in this vector: first the ASCII code,\n\ |
1130 and then the scan code. | 1130 and then the scan code. |
1131 */ | 1131 */ |
1132 ()) | 1132 ()) |
1133 { | 1133 { |
1134 Lisp_Object *keys = XVECTOR (recent_doskeys)->contents; | 1134 Lisp_Object *keys = XVECTOR_DATA (recent_doskeys); |
1135 Lisp_Object val; | 1135 Lisp_Object val; |
1136 | 1136 |
1137 if (total_doskeys < NUM_RECENT_DOSKEYS) | 1137 if (total_doskeys < NUM_RECENT_DOSKEYS) |
1138 return Fvector (total_doskeys, keys); | 1138 return Fvector (total_doskeys, keys); |
1139 else | 1139 else |
1140 { | 1140 { |
1141 val = Fvector (NUM_RECENT_DOSKEYS, keys); | 1141 val = Fvector (NUM_RECENT_DOSKEYS, keys); |
1142 bcopy (keys + recent_doskeys_index, | 1142 bcopy (keys + recent_doskeys_index, |
1143 XVECTOR (val)->contents, | 1143 XVECTOR_DATA (val), |
1144 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); | 1144 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); |
1145 bcopy (keys, | 1145 bcopy (keys, |
1146 XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, | 1146 XVECTOR_DATA (val) + NUM_RECENT_DOSKEYS - recent_doskeys_index, |
1147 recent_doskeys_index * sizeof (Lisp_Object)); | 1147 recent_doskeys_index * sizeof (Lisp_Object)); |
1148 return val; | 1148 return val; |
1149 } | 1149 } |
1150 } | 1150 } |
1151 | 1151 |
1153 static int | 1153 static int |
1154 dos_rawgetc (void) | 1154 dos_rawgetc (void) |
1155 { | 1155 { |
1156 struct input_event event; | 1156 struct input_event event; |
1157 union REGS regs; | 1157 union REGS regs; |
1158 | 1158 |
1159 #ifndef HAVE_X_WINDOWS | 1159 #ifndef HAVE_X_WINDOWS |
1160 SCREEN_SET_CURSOR (); | 1160 SCREEN_SET_CURSOR (); |
1161 if (!mouse_visible) mouse_on (); | 1161 if (!mouse_visible) mouse_on (); |
1162 #endif | 1162 #endif |
1163 | 1163 |
1164 /* The following condition is equivalent to `kbhit ()', except that | 1164 /* The following condition is equivalent to `kbhit ()', except that |
1165 it uses the bios to do its job. This pleases DESQview/X. */ | 1165 it uses the bios to do its job. This pleases DESQview/X. */ |
1166 while ((regs.h.ah = extended_kbd ? 0x11 : 0x01), | 1166 while ((regs.h.ah = extended_kbd ? 0x11 : 0x01), |
1167 int86 (0x16, ®s, ®s), | 1167 int86 (0x16, ®s, ®s), |
1168 (regs.x.flags & 0x40) == 0) | 1168 (regs.x.flags & 0x40) == 0) |
1176 int86 (0x16, ®s, ®s); | 1176 int86 (0x16, ®s, ®s); |
1177 c = regs.h.al; | 1177 c = regs.h.al; |
1178 sc = regs.h.ah; | 1178 sc = regs.h.ah; |
1179 | 1179 |
1180 total_doskeys += 2; | 1180 total_doskeys += 2; |
1181 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] | 1181 XVECTOR_DATA (recent_doskeys)[recent_doskeys_index++] = make_int (c); |
1182 = make_int (c); | |
1183 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) | 1182 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) |
1184 recent_doskeys_index = 0; | 1183 recent_doskeys_index = 0; |
1185 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] | 1184 XVECTOR_DATA (recent_doskeys)[recent_doskeys_index++] = make_int (sc); |
1186 = make_int (sc); | |
1187 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) | 1185 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) |
1188 recent_doskeys_index = 0; | 1186 recent_doskeys_index = 0; |
1189 | 1187 |
1190 modifiers = dos_get_modifiers (&mask); | 1188 modifiers = dos_get_modifiers (&mask); |
1191 | 1189 |
1192 #ifndef HAVE_X_WINDOWS | 1190 #ifndef HAVE_X_WINDOWS |
1193 if (!NILP (Vdos_display_scancodes)) | 1191 if (!NILP (Vdos_display_scancodes)) |
1194 { | 1192 { |
1195 char buf[10]; | 1193 char buf[10]; |
1196 sprintf (buf, "%02x:%02x*%04x", | 1194 sprintf (buf, "%02x:%02x*%04x", |
1222 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) | 1220 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) |
1223 continue; | 1221 continue; |
1224 if ((code = ibmpc_translate_map[sc]) == Ignore) | 1222 if ((code = ibmpc_translate_map[sc]) == Ignore) |
1225 continue; | 1223 continue; |
1226 } | 1224 } |
1227 | 1225 |
1228 if (c == 0) | 1226 if (c == 0) |
1229 { | 1227 { |
1230 if (code & Alt) | 1228 if (code & Alt) |
1231 modifiers |= meta_modifier; | 1229 modifiers |= meta_modifier; |
1232 if (code & Ctrl) | 1230 if (code & Ctrl) |
1233 modifiers |= ctrl_modifier; | 1231 modifiers |= ctrl_modifier; |
1234 if (code & Shift) | 1232 if (code & Shift) |
1235 modifiers |= shift_modifier; | 1233 modifiers |= shift_modifier; |
1236 } | 1234 } |
1237 | 1235 |
1238 switch (code & 0xf000) | 1236 switch (code & 0xf000) |
1239 { | 1237 { |
1240 case ModFct: | 1238 case ModFct: |
1241 if (c && !(mask & (SHIFT_P | ALT_P | CTRL_P | HYPER_P | SUPER_P))) | 1239 if (c && !(mask & (SHIFT_P | ALT_P | CTRL_P | HYPER_P | SUPER_P))) |
1242 return c; | 1240 return c; |
1243 c = 0; /* Special */ | 1241 c = 0; /* Special */ |
1244 | 1242 |
1245 case FctKey: | 1243 case FctKey: |
1246 if (c != 0) | 1244 if (c != 0) |
1247 return c; | 1245 return c; |
1248 | 1246 |
1249 case Special: | 1247 case Special: |
1250 code |= 0xff00; | 1248 code |= 0xff00; |
1251 break; | 1249 break; |
1252 | 1250 |
1253 case Normal: | 1251 case Normal: |
1254 if (sc == 0) | 1252 if (sc == 0) |
1255 { | 1253 { |
1256 if (c == 0) /* ctrl-break */ | 1254 if (c == 0) /* ctrl-break */ |
1257 continue; | 1255 continue; |
1262 if (c != ' ') | 1260 if (c != ' ') |
1263 return c; | 1261 return c; |
1264 code = c; | 1262 code = c; |
1265 break; | 1263 break; |
1266 } | 1264 } |
1267 | 1265 |
1268 case Map: | 1266 case Map: |
1269 if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) | 1267 if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) |
1270 if (!keyboard_map_all) | 1268 if (!keyboard_map_all) |
1271 return c; | 1269 return c; |
1272 | 1270 |
1273 code &= 0xff; | 1271 code &= 0xff; |
1274 if (mask & ALT_P && code <= 10 && code > 0 && dos_keypad_mode & 0x200) | 1272 if (mask & ALT_P && code <= 10 && code > 0 && dos_keypad_mode & 0x200) |
1275 mask |= SHIFT_P; /* ALT-1 => M-! etc. */ | 1273 mask |= SHIFT_P; /* ALT-1 => M-! etc. */ |
1276 | 1274 |
1277 if (mask & SHIFT_P) | 1275 if (mask & SHIFT_P) |
1278 { | 1276 { |
1279 code = keyboard->shifted[code]; | 1277 code = keyboard->shifted[code]; |
1280 mask -= SHIFT_P; | 1278 mask -= SHIFT_P; |
1281 modifiers &= ~shift_modifier; | 1279 modifiers &= ~shift_modifier; |
1294 else | 1292 else |
1295 if ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) /* numlock on */ | 1293 if ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) /* numlock on */ |
1296 kp_mode = dos_keypad_mode & 0x03; | 1294 kp_mode = dos_keypad_mode & 0x03; |
1297 else | 1295 else |
1298 kp_mode = (dos_keypad_mode >> 4) & 0x03; | 1296 kp_mode = (dos_keypad_mode >> 4) & 0x03; |
1299 | 1297 |
1300 switch (kp_mode) | 1298 switch (kp_mode) |
1301 { | 1299 { |
1302 case 0: | 1300 case 0: |
1303 if (code == 10 && dos_decimal_point) | 1301 if (code == 10 && dos_decimal_point) |
1304 return dos_decimal_point; | 1302 return dos_decimal_point; |
1310 | 1308 |
1311 case 2: | 1309 case 2: |
1312 code = keypad_translate_map[code].meta_code; | 1310 code = keypad_translate_map[code].meta_code; |
1313 modifiers = meta_modifier; | 1311 modifiers = meta_modifier; |
1314 break; | 1312 break; |
1315 | 1313 |
1316 case 3: | 1314 case 3: |
1317 code = 0xff00 | keypad_translate_map[code].editkey_code; | 1315 code = 0xff00 | keypad_translate_map[code].editkey_code; |
1318 break; | 1316 break; |
1319 } | 1317 } |
1320 break; | 1318 break; |
1321 | 1319 |
1322 case Grey: | 1320 case Grey: |
1323 code &= 0xff; | 1321 code &= 0xff; |
1324 kp_mode = ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) ? 0x04 : 0x40; | 1322 kp_mode = ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) ? 0x04 : 0x40; |
1325 if (dos_keypad_mode & kp_mode) | 1323 if (dos_keypad_mode & kp_mode) |
1326 code = 0xff00 | grey_key_translate_map[code].keypad_code; | 1324 code = 0xff00 | grey_key_translate_map[code].keypad_code; |
1327 else | 1325 else |
1328 code = grey_key_translate_map[code].char_code; | 1326 code = grey_key_translate_map[code].char_code; |
1329 break; | 1327 break; |
1330 } | 1328 } |
1331 | 1329 |
1332 make_event: | 1330 make_event: |
1333 if (code == 0) | 1331 if (code == 0) |
1334 continue; | 1332 continue; |
1335 | 1333 |
1336 if (code >= 0x100) | 1334 if (code >= 0x100) |
1337 event.kind = non_ascii_keystroke; | 1335 event.kind = non_ascii_keystroke; |
1338 else | 1336 else |
1339 event.kind = ascii_keystroke; | 1337 event.kind = ascii_keystroke; |
1340 event.code = code; | 1338 event.code = code; |
1725 ScreenRetrieve (state[statecount].screen_behind | 1723 ScreenRetrieve (state[statecount].screen_behind |
1726 = xmalloc (screensize)); | 1724 = xmalloc (screensize)); |
1727 state[statecount].x | 1725 state[statecount].x |
1728 = state[i].x + state[i].menu->width + 2; | 1726 = state[i].x + state[i].menu->width + 2; |
1729 state[statecount].y = y; | 1727 state[statecount].y = y; |
1730 statecount++; | 1728 statecount++; |
1731 } | 1729 } |
1732 } | 1730 } |
1733 } | 1731 } |
1734 IT_menu_display (state[statecount - 1].menu, | 1732 IT_menu_display (state[statecount - 1].menu, |
1735 state[statecount - 1].y, | 1733 state[statecount - 1].y, |
2027 int | 2025 int |
2028 dos_ttraw (void) | 2026 dos_ttraw (void) |
2029 { | 2027 { |
2030 union REGS inregs, outregs; | 2028 union REGS inregs, outregs; |
2031 static int first_time = 1; | 2029 static int first_time = 1; |
2032 | 2030 |
2033 break_stat = getcbrk (); | 2031 break_stat = getcbrk (); |
2034 setcbrk (0); | 2032 setcbrk (0); |
2035 install_ctrl_break_check (); | 2033 install_ctrl_break_check (); |
2036 | 2034 |
2037 if (first_time) | 2035 if (first_time) |
2038 { | 2036 { |
2039 inregs.h.ah = 0xc0; | 2037 inregs.h.ah = 0xc0; |
2040 int86 (0x15, &inregs, &outregs); | 2038 int86 (0x15, &inregs, &outregs); |
2041 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0); | 2039 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0); |
2042 | 2040 |
2043 have_mouse = 0; | 2041 have_mouse = 0; |
2044 | 2042 |
2045 if (internal_terminal | 2043 if (internal_terminal |
2046 #ifdef HAVE_X_WINDOWS | 2044 #ifdef HAVE_X_WINDOWS |
2047 && inhibit_window_system | 2045 && inhibit_window_system |
2063 | 2061 |
2064 if (have_mouse) | 2062 if (have_mouse) |
2065 { | 2063 { |
2066 have_mouse = 1; /* enable mouse */ | 2064 have_mouse = 1; /* enable mouse */ |
2067 mouse_visible = 0; | 2065 mouse_visible = 0; |
2068 | 2066 |
2069 if (outregs.x.bx == 3) | 2067 if (outregs.x.bx == 3) |
2070 { | 2068 { |
2071 mouse_button_count = 3; | 2069 mouse_button_count = 3; |
2072 mouse_button_translate[0] = 0; /* Left */ | 2070 mouse_button_translate[0] = 0; /* Left */ |
2073 mouse_button_translate[1] = 2; /* Middle */ | 2071 mouse_button_translate[1] = 2; /* Middle */ |
2081 } | 2079 } |
2082 mouse_position_hook = &mouse_get_pos; | 2080 mouse_position_hook = &mouse_get_pos; |
2083 mouse_init (); | 2081 mouse_init (); |
2084 } | 2082 } |
2085 } | 2083 } |
2086 | 2084 |
2087 first_time = 0; | 2085 first_time = 0; |
2088 } | 2086 } |
2089 | 2087 |
2090 inregs.x.ax = 0x4400; /* Get IOCTL status. */ | 2088 inregs.x.ax = 0x4400; /* Get IOCTL status. */ |
2091 inregs.x.bx = 0x00; /* 0 = stdin. */ | 2089 inregs.x.bx = 0x00; /* 0 = stdin. */ |
2185 | 2183 |
2186 if (have_mouse > 0) | 2184 if (have_mouse > 0) |
2187 mouse_get_xy (&x, &y); | 2185 mouse_get_xy (&x, &y); |
2188 | 2186 |
2189 dos_ttcooked (); /* do it here while 0 = stdin */ | 2187 dos_ttcooked (); /* do it here while 0 = stdin */ |
2190 | 2188 |
2191 dup2 (tempin, 0); | 2189 dup2 (tempin, 0); |
2192 dup2 (tempout, 1); | 2190 dup2 (tempout, 1); |
2193 dup2 (tempout, 2); | 2191 dup2 (tempout, 2); |
2194 | 2192 |
2195 result = spawnve (P_WAIT, argv[0], argv, envv); | 2193 result = spawnve (P_WAIT, argv[0], argv, envv); |
2196 | 2194 |
2197 dup2 (inbak, 0); | 2195 dup2 (inbak, 0); |
2198 dup2 (outbak, 1); | 2196 dup2 (outbak, 1); |
2199 dup2 (errbak, 2); | 2197 dup2 (errbak, 2); |
2200 close (inbak); | 2198 close (inbak); |
2201 close (outbak); | 2199 close (outbak); |
2205 if (have_mouse > 0) | 2203 if (have_mouse > 0) |
2206 { | 2204 { |
2207 mouse_init (); | 2205 mouse_init (); |
2208 mouse_moveto (x, y); | 2206 mouse_moveto (x, y); |
2209 } | 2207 } |
2210 | 2208 |
2211 done: | 2209 done: |
2212 chdir (oldwd); | 2210 chdir (oldwd); |
2213 if (msshell) | 2211 if (msshell) |
2214 { | 2212 { |
2215 argv[1] = saveargv1; | 2213 argv[1] = saveargv1; |
2246 } | 2244 } |
2247 | 2245 |
2248 /* When time zones are set from Ms-Dos too many C-libraries are playing | 2246 /* When time zones are set from Ms-Dos too many C-libraries are playing |
2249 tricks with time values. We solve this by defining our own version | 2247 tricks with time values. We solve this by defining our own version |
2250 of `gettimeofday' bypassing GO32. Our version needs to be initialized | 2248 of `gettimeofday' bypassing GO32. Our version needs to be initialized |
2251 once and after each call to `tzset' with TZ changed. That is | 2249 once and after each call to `tzset' with TZ changed. That is |
2252 accomplished by aliasing tzset to init_gettimeofday. */ | 2250 accomplished by aliasing tzset to init_gettimeofday. */ |
2253 | 2251 |
2254 static struct tm time_rec; | 2252 static struct tm time_rec; |
2255 | 2253 |
2256 int | 2254 int |
2258 { | 2256 { |
2259 if (tp) | 2257 if (tp) |
2260 { | 2258 { |
2261 struct time t; | 2259 struct time t; |
2262 struct tm tm; | 2260 struct tm tm; |
2263 | 2261 |
2264 gettime (&t); | 2262 gettime (&t); |
2265 if (t.ti_hour < time_rec.tm_hour) /* midnight wrap */ | 2263 if (t.ti_hour < time_rec.tm_hour) /* midnight wrap */ |
2266 { | 2264 { |
2267 struct date d; | 2265 struct date d; |
2268 getdate (&d); | 2266 getdate (&d); |
2269 time_rec.tm_year = d.da_year - 1900; | 2267 time_rec.tm_year = d.da_year - 1900; |
2270 time_rec.tm_mon = d.da_mon - 1; | 2268 time_rec.tm_mon = d.da_mon - 1; |
2271 time_rec.tm_mday = d.da_day; | 2269 time_rec.tm_mday = d.da_day; |
2272 } | 2270 } |
2273 | 2271 |
2274 time_rec.tm_hour = t.ti_hour; | 2272 time_rec.tm_hour = t.ti_hour; |
2275 time_rec.tm_min = t.ti_min; | 2273 time_rec.tm_min = t.ti_min; |
2276 time_rec.tm_sec = t.ti_sec; | 2274 time_rec.tm_sec = t.ti_sec; |
2277 | 2275 |
2278 tm = time_rec; | 2276 tm = time_rec; |
2279 tm.tm_gmtoff = dos_timezone_offset; | 2277 tm.tm_gmtoff = dos_timezone_offset; |
2280 | 2278 |
2281 tp->tv_sec = mktime (&tm); /* may modify tm */ | 2279 tp->tv_sec = mktime (&tm); /* may modify tm */ |
2282 tp->tv_usec = t.ti_hund * (1000000 / 100); | 2280 tp->tv_usec = t.ti_hund * (1000000 / 100); |
2283 } | 2281 } |
2284 /* Ignore tzp; it's obsolescent. */ | 2282 /* Ignore tzp; it's obsolescent. */ |
2285 return 0; | 2283 return 0; |
2311 | 2309 |
2312 static void | 2310 static void |
2313 check_timer (struct time *t) | 2311 check_timer (struct time *t) |
2314 { | 2312 { |
2315 gettime (t); | 2313 gettime (t); |
2316 | 2314 |
2317 if (t->ti_sec == last_ti_sec) | 2315 if (t->ti_sec == last_ti_sec) |
2318 return; | 2316 return; |
2319 last_ti_sec = t->ti_sec; | 2317 last_ti_sec = t->ti_sec; |
2320 | 2318 |
2321 if (!NILP (Vdos_menubar_clock)) | 2319 if (!NILP (Vdos_menubar_clock)) |
2332 if (min < 0) | 2330 if (min < 0) |
2333 min += 60, hour--; | 2331 min += 60, hour--; |
2334 else | 2332 else |
2335 if (min >= 60) | 2333 if (min >= 60) |
2336 min -= 60, hour++; | 2334 min -= 60, hour++; |
2337 | 2335 |
2338 if ((hour -= (tz / 60)) < 0) | 2336 if ((hour -= (tz / 60)) < 0) |
2339 hour += 24; | 2337 hour += 24; |
2340 else | 2338 else |
2341 hour %= 24; | 2339 hour %= 24; |
2342 } | 2340 } |
2343 | 2341 |
2344 if ((dos_country_info[0x11] & 0x01) == 0) /* 12 hour clock */ | 2342 if ((dos_country_info[0x11] & 0x01) == 0) /* 12 hour clock */ |
2345 { | 2343 { |
2346 hour %= 12; | 2344 hour %= 12; |
2347 if (hour == 0) hour = 12; | 2345 if (hour == 0) hour = 12; |
2348 } | 2346 } |
2355 { | 2353 { |
2356 /* Erase last displayed time. */ | 2354 /* Erase last displayed time. */ |
2357 dos_direct_output (0, screen_size_X - 9, " ", 8); | 2355 dos_direct_output (0, screen_size_X - 9, " ", 8); |
2358 dos_menubar_clock_displayed = 0; | 2356 dos_menubar_clock_displayed = 0; |
2359 } | 2357 } |
2360 | 2358 |
2361 if (!NILP (Vdos_timer_hooks)) | 2359 if (!NILP (Vdos_timer_hooks)) |
2362 run_dos_timer_hooks++; | 2360 run_dos_timer_hooks++; |
2363 } | 2361 } |
2364 | 2362 |
2365 /* Only event queue is checked. */ | 2363 /* Only event queue is checked. */ |
2382 if (efds) | 2380 if (efds) |
2383 FD_ZERO (efds); | 2381 FD_ZERO (efds); |
2384 | 2382 |
2385 if (nfds != 1) | 2383 if (nfds != 1) |
2386 abort (); | 2384 abort (); |
2387 | 2385 |
2388 /* If we are looking only for the terminal, with no timeout, | 2386 /* If we are looking only for the terminal, with no timeout, |
2389 just read it and wait -- that's more efficient. */ | 2387 just read it and wait -- that's more efficient. */ |
2390 if (!timeout) | 2388 if (!timeout) |
2391 { | 2389 { |
2392 while (! detect_input_pending ()) | 2390 while (! detect_input_pending ()) |
2409 if (timeoutval <= 0) /* Stop on timer being cleared */ | 2407 if (timeoutval <= 0) /* Stop on timer being cleared */ |
2410 return 0; | 2408 return 0; |
2411 cllast = clnow; | 2409 cllast = clnow; |
2412 } | 2410 } |
2413 } | 2411 } |
2414 | 2412 |
2415 FD_SET (0, rfds); | 2413 FD_SET (0, rfds); |
2416 return 1; | 2414 return 1; |
2417 } | 2415 } |
2418 #endif | 2416 #endif |
2419 | 2417 |
2440 if (getdisk () != tolower (tmp[0]) - 'a') | 2438 if (getdisk () != tolower (tmp[0]) - 'a') |
2441 setdisk (tolower (tmp[0]) - 'a'); | 2439 setdisk (tolower (tmp[0]) - 'a'); |
2442 tmp += 2; /* strip drive: KFS 1995-07-06 */ | 2440 tmp += 2; /* strip drive: KFS 1995-07-06 */ |
2443 len -= 2; | 2441 len -= 2; |
2444 } | 2442 } |
2445 | 2443 |
2446 if (len > 1 && (tmp[len - 1] == '/')) | 2444 if (len > 1 && (tmp[len - 1] == '/')) |
2447 { | 2445 { |
2448 char *tmp1 = (char *) alloca (len + 1); | 2446 char *tmp1 = (char *) alloca (len + 1); |
2449 strcpy (tmp1, tmp); | 2447 strcpy (tmp1, tmp); |
2450 tmp1[len - 1] = 0; | 2448 tmp1[len - 1] = 0; |
2479 void | 2477 void |
2480 dos_abort (char *file, int line) | 2478 dos_abort (char *file, int line) |
2481 { | 2479 { |
2482 char buffer1[200], buffer2[400]; | 2480 char buffer1[200], buffer2[400]; |
2483 int i, j; | 2481 int i, j; |
2484 | 2482 |
2485 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line); | 2483 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line); |
2486 for (i = j = 0; buffer1[i]; i++) { | 2484 for (i = j = 0; buffer1[i]; i++) { |
2487 buffer2[j++] = buffer1[i]; | 2485 buffer2[j++] = buffer1[i]; |
2488 buffer2[j++] = 0x70; | 2486 buffer2[j++] = 0x70; |
2489 } | 2487 } |