annotate src/msdos.c @ 6325:d6817c9c0413

Undo previous change. Instead: (Fx_popup_dialog) [! USE_X_TOOLKIT]: Call Fx_popup_menu.
author Richard M. Stallman <rms@gnu.org>
date Mon, 14 Mar 1994 00:18:52 +0000
parents afa75a0c15f8
children ce4fbb055f87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 /* MS-DOS specific C utilities. Coded by Morten Welinder 1993
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 Copyright (C) 1993 Free Software Foundation, Inc.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 /* Note: some of the stuff here was taken from end of sysdep.c in demacs. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
5980
a203b7c30300 Use <...> for config.h.
Richard M. Stallman <rms@gnu.org>
parents: 5503
diff changeset
22 #include <config.h>
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 #ifdef MSDOS
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #include "lisp.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #include <stdio.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 #include <stdlib.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 #include <sys/param.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 #include <sys/time.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 #include <dos.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 #include "dosfns.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 #include "msdos.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 #include "systime.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 #include "termhooks.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 #include "frame.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 #include <go32.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 #include <pc.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 #include <ctype.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 /* #include <process.h> */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 #define P_WAIT 1
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 static int break_stat; /* BREAK check mode status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 static int stdin_stat; /* stdin IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 static int extended_kbd; /* 101 (102) keyboard present. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 int have_mouse; /* Mouse present? */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 static int mouse_last_x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 static int mouse_last_y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 /* Turn off Dos' Ctrl-C checking and inhibit interpretation of control chars
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 by Dos. Determine the keyboard type. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 dos_ttraw ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 union REGS inregs, outregs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 inregs.h.ah = 0xc0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 int86 (0x15, &inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 break_stat = getcbrk ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 setcbrk (0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 install_ctrl_break_check ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 have_mouse = Mouse_init1 ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 inregs.x.ax = 0x4400; /* Get IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 inregs.x.bx = 0x00; /* 0 = stdin. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 stdin_stat = outregs.h.dl;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 inregs.x.dx = (outregs.x.dx | 0x0020) & 0x0027; /* raw mode */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 inregs.h.al = 0x01;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 return !outregs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 /* Restore status of standard input and Ctrl-C checking. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 dos_ttcooked ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 union REGS inregs, outregs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 setcbrk (break_stat);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 if (have_mouse) Mouse_off ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 inregs.x.ax = 0x4401; /* Set IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 inregs.x.bx = 0x00; /* 0 = stdin. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 inregs.x.dx = stdin_stat;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 return !outregs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 static unsigned short
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ibmpc_translate_map[] =
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 /* --------------- 00 to 0f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 0, /* Ctrl Break */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 0xff1b, /* Escape */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 0xffb1, /* Keypad 1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 0xffb2, /* Keypad 2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 0xffb3, /* Keypad 3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 0xffb4, /* Keypad 4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 0xffb5, /* Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 0xffb6, /* Keypad 6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 0xffb7, /* Keypad 7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 0xffb8, /* Keypad 8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 0xffb9, /* Keypad 9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 0xffb0, /* Keypad 0 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 '-', '=',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 0xff08, /* Backspace */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 0xff74, /* (Shift) Tab [Tab doesn't use this table] */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 /* --------------- 10 to 1f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 0xff8d, /* Keypad Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 0, /* Ctrl */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 'a', 's',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 /* --------------- 20 to 2f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 0, /* Left shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 '\\', 'z', 'x', 'c', 'v',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 /* --------------- 30 to 3f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 'b', 'n', 'm', ',', '.',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 0xffaf, /* Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 0, /* Right shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 0xffaa, /* Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 0, /* Alt */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ' ',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 0, /* Caps Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 0xffbe, /* F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 0xffbf, /* F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 0xffc0, /* F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 0xffc1, /* F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 0xffc2, /* F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 /* --------------- 40 to 4f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 0xffc3, /* F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 0xffc4, /* F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 0xffc5, /* F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 0xffc6, /* F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 0xffc7, /* F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 0, /* Num Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 0, /* Scroll Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 0xff50, /* Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 0xff52, /* Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 0xff55, /* Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 0xffad, /* Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 0xff51, /* Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 0xffb5, /* Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 0xff53, /* Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 0xffab, /* Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 0xff57, /* End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 /* --------------- 50 to 5f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 0xff54, /* Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 0xff56, /* Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 0xff63, /* Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 0xffff, /* Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 0xffbe, /* (Shift) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 0xffbf, /* (Shift) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 0xffc0, /* (Shift) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 0xffc1, /* (Shift) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 0xffc2, /* (Shift) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 0xffc3, /* (Shift) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 0xffc4, /* (Shift) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 0xffc5, /* (Shift) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 0xffc6, /* (Shift) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 0xffc7, /* (Shift) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 0xffbe, /* (Ctrl) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 0xffbf, /* (Ctrl) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 /* --------------- 60 to 6f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 0xffc0, /* (Ctrl) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 0xffc1, /* (Ctrl) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 0xffc2, /* (Ctrl) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 0xffc3, /* (Ctrl) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 0xffc4, /* (Ctrl) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 0xffc5, /* (Ctrl) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 0xffc6, /* (Ctrl) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 0xffc7, /* (Ctrl) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 0xffbe, /* (Alt) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 0xffbf, /* (Alt) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 0xffc0, /* (Alt) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 0xffc1, /* (Alt) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 0xffc2, /* (Alt) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 0xffc3, /* (Alt) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 0xffc4, /* (Alt) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 0xffc5, /* (Alt) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 /* --------------- 70 to 7f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 0xffc6, /* (Alt) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 0xffc7, /* (Alt) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 0xff6d, /* (Ctrl) Sys Rq */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 0xff51, /* (Ctrl) Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 0xff53, /* (Ctrl) Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 0xff57, /* (Ctrl) End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 0xff56, /* (Ctrl) Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 0xff50, /* (Ctrl) Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 '1', '2', '3', '4', '5', '6', '7', '8', /* (Alt) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 /* --------------- 80 to 8f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 '9', '0', '-', '=', /* (Alt) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 0xff55, /* (Ctrl) Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 0xffc8, /* F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 0xffc9, /* F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 0xffc8, /* (Shift) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 0xffc9, /* (Shift) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 0xffc8, /* (Ctrl) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 0xffc9, /* (Ctrl) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 0xffc8, /* (Alt) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 0xffc9, /* (Alt) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 0xff52, /* (Ctrl) Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 0xffae, /* (Ctrl) Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 0xffb5, /* (Ctrl) Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 /* --------------- 90 to 9f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 0xffab, /* (Ctrl) Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 0xff54, /* (Ctrl) Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 0xff63, /* (Ctrl) Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 0xffff, /* (Ctrl) Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 0xff09, /* (Ctrl) Tab */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 0xffaf, /* (Ctrl) Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 0xffaa, /* (Ctrl) Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 0xff50, /* (Alt) Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 0xff52, /* (Alt) Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 0xff55, /* (Alt) Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 0xff51, /* (Alt) Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 0xff53, /* (Alt) Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 0xff57, /* (Alt) End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 /* --------------- a0 to af --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 0xff54, /* (Alt) Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 0xff56, /* (Alt) Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 0xff63, /* (Alt) Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 0xffff, /* (Alt) Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 0xffaf, /* (Alt) Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 0xff09, /* (Alt) Tab */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 0xff0d /* (Alt) Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 };
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 /* Get a char from keyboard. Function keys are put into the event queue. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 static int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 dos_rawgetc ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 struct input_event event;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 struct timeval tv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 int ctrl_p, alt_p, shift_p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 /* Calculate modifier bits */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 regs.h.ah = extended_kbd ? 0x12 : 0x02;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 int86 (0x16, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 ctrl_p = ((regs.h.al & 4) != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 shift_p = ((regs.h.al & 3) != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 alt_p = ((extended_kbd ? (regs.h.ah & 2) : (regs.h.al & 8)) != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 while (kbhit ())
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 register unsigned char c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 int sc, code;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 regs.h.ah = extended_kbd ? 0x10 : 0x00;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 int86 (0x16, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 c = regs.h.al;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 sc = regs.h.ah;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 /* Determine from the scan code if a keypad key was pressed. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 if (c >= '0' && c <= '9' && sc > 0xb)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 sc = (c == '0') ? 0xb : (c - '0' + 1), c = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 else if (sc == 0xe0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 switch (c)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 case 10: /* Ctrl Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 case 13:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 sc = 0x1c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 case '.': /* Decimal point or decimal comma */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 case ',':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 sc = 0x53;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 case '/':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 sc = 0x35;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 default:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 sc = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 };
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 c = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 if (c == 0
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 || c == ' '
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 || alt_p
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 || (ctrl_p && shift_p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 || (c == 0xe0 && sc != 0) /* Pseudo-key */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 || sc == 0x37 /* Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 || sc == 0x4a /* Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 || sc == 0x4e /* Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 || sc == 0x0e) /* Back space *key*, not Ctrl-h */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short)))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 code = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 code = ibmpc_translate_map[sc];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 if (code != 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 if (code >= 0x100)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 event.kind = non_ascii_keystroke;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 event.code = code & 0xff;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 /* Don't return S- if we don't have to. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 if (code >= 'a' && code <= 'z')
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 c = shift_p ? toupper (code) : code;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 shift_p = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 if (c == 0) c = code;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 event.kind = ascii_keystroke;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 event.code = c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 event.modifiers
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 = (shift_p ? shift_modifier : 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 + (ctrl_p ? ctrl_modifier : 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 + (alt_p ? meta_modifier : 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 /* EMACS == Enter Meta Alt Control Shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 event.frame_or_window = selected_frame;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 gettimeofday (&tv, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 event.timestamp = tv.tv_usec;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 kbd_buffer_store_event (&event);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 } else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 return c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 if (have_mouse)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 int but, press, x, y, ok;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 /* Check for mouse movement *before* buttons. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 Mouse_check_moved ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 for (but = 0; but < NUM_MOUSE_BUTTONS; but++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 for (press = 0; press < 2; press++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 if (press)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 ok = Mouse_pressed (but, &x, &y);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 ok = Mouse_released (but, &x, &y);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 if (ok)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 event.kind = mouse_click;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 event.code = but;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 event.modifiers
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 = (shift_p ? shift_modifier : 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 + (ctrl_p ? ctrl_modifier : 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 + (alt_p ? meta_modifier : 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 + (press ? down_modifier : up_modifier);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 event.x = x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 event.y = y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 event.frame_or_window = selected_frame;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 gettimeofday (&tv, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 event.timestamp = tv.tv_usec;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 kbd_buffer_store_event (&event);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 return -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 static int prev_get_char = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 /* Return 1 if a key is ready to be read without suspending execution. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 dos_keysns ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 if (prev_get_char != -1)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 return 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 return ((prev_get_char = dos_rawgetc ()) != -1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 /* Read a key. Return -1 if no key is ready. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 dos_keyread ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 if (prev_get_char != -1)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 int c = prev_get_char;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 prev_get_char = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 return c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 return dos_rawgetc ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 /* Hostnames for a pc are not really funny, but they are used in change log
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 so we emulate the best we can. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 gethostname (p, size)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 int size;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 char *q = egetenv ("HOSTNAME");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 if (!q) q = "pc";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 strcpy (p, q);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 /* Destructively turn backslashes into slashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 dostounix_filename (p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 register char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 while (*p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 if (*p == '\\')
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 *p = '/';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 p++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 /* Destructively turn slashes into backslashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 unixtodos_filename (p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 register char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 while (*p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 if (*p == '/')
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 *p = '\\';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 p++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 /* Get the default directory for a given drive. 0=def, 1=A, 2=B, ... */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 getdefdir (drive, dst)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 int drive;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 char *dst;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 *dst++ = '/';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 regs.h.dl = drive;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 regs.x.si = (int) dst;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 regs.h.ah = 0x47;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 intdos (&regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 return !regs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 /* Remove all CR's that are followed by a LF. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 crlf_to_lf (n, buf)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 register int n;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 register unsigned char *buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 unsigned char *np = buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 unsigned char *startp = buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 unsigned char *endp = buf + n;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 unsigned char c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 if (n == 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 return n;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 while (buf < endp)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 if (*buf == 0x0d)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 if (*(++buf) != 0x0a)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 *np++ = 0x0d;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 *np++ = *buf++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 return np - startp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 /* Run command as specified by ARGV in directory DIR.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 The command is run with input from TEMPIN and output to file TEMPOUT. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 run_msdos_command (argv, dir, tempin, tempout)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 unsigned char **argv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 Lisp_Object dir;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 int tempin, tempout;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 char *saveargv1, *saveargv2, **envv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 int msshell, result = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 int in, out, inbak, outbak, errbak;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 Lisp_Object cmd;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 /* Get current directory as MSDOS cwd is not per-process. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 getwd (oldwd);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 cmd = Ffile_name_nondirectory (build_string (argv[0]));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 msshell = !NILP (Fmember (cmd, Fsymbol_value (intern ("msdos-shells"))))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 && !strcmp ("-c", argv[1]);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 if (msshell)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 saveargv1 = argv[1];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 argv[1] = "/c";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 if (argv[2])
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 saveargv2 = argv[2];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 unixtodos_filename (argv[2] = strdup (argv[2]));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 /* Build the environment array. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 extern Lisp_Object Vprocess_environment;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 Lisp_Object tmp, lst = Vprocess_environment;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 int i, len = XFASTINT (Flength (lst));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 envv = alloca ((len + 1) * sizeof (char *));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 for (i = 0; i < len; i++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 tmp = Fcar (lst);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 lst = Fcdr (lst);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 CHECK_STRING (tmp, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 envv[i] = alloca (XSTRING (tmp)->size + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 strcpy (envv[i], XSTRING (tmp)->data);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 envv[len] = (char *) 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 if (XTYPE (dir) == Lisp_String)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 chdir (XSTRING (dir)->data);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 inbak = dup (0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 outbak = dup (1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 errbak = dup (2);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 if (inbak < 0 || outbak < 0 || errbak < 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 goto done; /* Allocation might fail due to lack of descriptors. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 dup2 (tempin, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 dup2 (tempout, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 dup2 (tempout, 2);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 dos_ttcooked ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 result = spawnve (P_WAIT, argv[0], argv, envv);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 dos_ttraw ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 dup2 (inbak, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 dup2 (outbak, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 dup2 (errbak, 2);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 done:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 chdir (oldwd);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 if (msshell)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 argv[1] = saveargv1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 if (argv[2])
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 free (argv[2]);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 argv[2] = saveargv2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 return result;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 croak (badfunc)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 char *badfunc;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 fprintf (stderr, "%s not yet implemented\r\n", badfunc);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 reset_sys_modes ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 exit (1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 /* A list of unimplemented functions that we silently ignore. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 unsigned alarm (s) unsigned s; {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 fork () { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 int kill (x, y) int x, y; { return -1; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 nice (p) int p; {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 void volatile pause () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 request_sigio () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 setpgrp () {return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 setpriority (x,y,z) int x,y,z; { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 sigsetmask (x) int x; { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 unrequest_sigio () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 #ifdef chdir
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 #undef chdir
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 #endif
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 sys_chdir (path)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 const char* path;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 int len = strlen (path);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 char *tmp = (char *) alloca (len + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 /* Gotta do this extern here due to the corresponding #define: */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 extern int chdir ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 if (*path && path[1] == ':' && (getdisk () != tolower (path[0]) - 'a'))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 setdisk (tolower (path[0]) - 'a');
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 strcpy (tmp, path);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 if (strcmp (path, "/") && strcmp (path + 1, ":/") && (path[len - 1] == '/'))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 tmp[len - 1] = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 return chdir (tmp);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 /* Sleep SECS. If KBDOK also return immediately if a key is pressed. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 sleep_or_kbd_hit (secs, kbdok)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 int secs, kbdok;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 long clnow, clthen;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 struct timeval t;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 gettimeofday (&t, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 clnow = t.tv_sec * 100 + t.tv_usec / 10000;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 clthen = clnow + (100 * secs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 do
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 gettimeofday (&t, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 clnow = t.tv_sec * 100 + t.tv_usec / 10000;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 if (kbdok && detect_input_pending ())
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 return;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 while (clnow < clthen);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 /* Define a lot of environment variables if not already defined. Don't
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 remove anything unless you know what you're doing -- lots of code will
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 break if one or more of these are missing. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 init_environment (argc, argv, skip_args)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 int argc;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 char **argv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 int skip_args;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 char *s, *t;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 /* We default HOME to the directory from which Emacs was started, but with
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 a "/bin" suffix removed. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 s = argv[0];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 t = alloca (strlen (s) + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 strcpy (t, s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 s = t + strlen (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 while (s != t && *s != '/' && *s != ':') s--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 if (s == t)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 t = "c:/emacs"; /* When run under debug32. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 if (*s == ':') s++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 *s = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 if (s - 4 >= t && strcmp (s - 4, "/bin") == 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 s[strlen (s) - 4] = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 setenv ("HOME", t, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 /* We set EMACSPATH to ~/bin (expanded) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 s = getenv ("HOME");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 t = strcpy (alloca (strlen (s) + 6), s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 if (s[strlen (s) - 1] != '/') strcat (t, "/");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 strcat (t, "bin");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 setenv ("EMACSPATH", t, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 /* I don't expect anybody to ever use other terminals so the internal
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 terminal is the default. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 setenv ("TERM", "internal", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 /* SHELL is a bit tricky -- COMSPEC is the closest we come, but we must
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 downcase it and mirror the backslashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 s = getenv ("COMSPEC");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 if (!s) s = "c:/command.com";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 t = alloca (strlen (s) + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 strcpy (t, s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 strlwr (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 dostounix_filename (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 setenv ("SHELL", t, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 /* PATH is also downcased and backslashes mirrored. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 s = getenv ("PATH");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 if (!s) s = "";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 t = alloca (strlen (s) + 3);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 /* Current directory is always considered part of MsDos's path but it is
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 not normally mentioned. Now it is. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 strcat (strcpy (t, ".;"), s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 strlwr (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 dostounix_filename (t); /* Not a single file name, but this should work. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 setenv ("PATH", t, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 /* In some sense all dos users have root privileges, so... */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 setenv ("USER", "root", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 setenv ("NAME", getenv ("USER"), 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 /* Time zone determined from country code. To make this possible, the
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 country code may not span more than one time zone. In other words,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 in the USA, you lose. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 switch (dos_country_code)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 case 31: /* Belgium */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 case 32: /* The Netherlands */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 case 33: /* France */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 case 34: /* Spain */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 case 36: /* Hungary */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 case 38: /* Yugoslavia (or what's left of it?) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 case 39: /* Italy */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 case 41: /* Switzerland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 case 42: /* Tjekia */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 case 45: /* Denmark */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 case 46: /* Sweden */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 case 47: /* Norway */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 case 48: /* Poland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 case 49: /* Germany */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 /* Daylight saving from last Sunday in March to last Sunday in
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 September, both at 2AM. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 setenv ("TZ", "MET-01METDST-02,M3.5.0/02:00,M9.5.0/02:00", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 case 44: /* United Kingdom */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 case 351: /* Portugal */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 case 354: /* Iceland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 setenv ("TZ", "GMT+00", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 case 81: /* Japan */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 case 82: /* Korea */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 setenv ("TZ", "???-09", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 case 90: /* Turkey */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 case 358: /* Finland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 case 972: /* Israel */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 setenv ("TZ", "EET-02", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 tzset ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 /* Flash the screen as a substitute for BEEPs. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 static unsigned char _xorattr;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 visible_bell (xorattr)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 unsigned char xorattr;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 _xorattr = xorattr;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 asm (" pushl %eax
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 pushl %ebx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 pushl %ecx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 pushl %edx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 movl $1,%edx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 visible_bell_0:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 movl _ScreenPrimary,%eax
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 call dosmemsetup
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 movl %eax,%ebx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 call _ScreenRows
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 movl %eax,%ecx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 call _ScreenCols
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 imull %eax,%ecx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 movb (__xorattr),%al
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 incl %ebx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 visible_bell_1:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 xorb %al,%gs:(%ebx)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 addl $2,%ebx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 decl %ecx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 jne visible_bell_1
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 decl %edx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 jne visible_bell_3
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 visible_bell_2:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 movzwl %ax,%eax
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 movzwl %ax,%eax
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 movzwl %ax,%eax
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 movzwl %ax,%eax
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 decw %cx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 jne visible_bell_2
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 jmp visible_bell_0
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 visible_bell_3:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 popl %edx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 popl %ecx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 popl %ebx
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 popl %eax");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 static int internal_terminal = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 #undef fflush
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 internal_flush (f)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 FILE *f;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 static int x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 static int y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 char c, *cp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 int count, i;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 if (internal_terminal && f == stdout)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 if (have_mouse) Mouse_off ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 cp = stdout->_base;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 count = stdout->_ptr - stdout->_base;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 while (count > 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 switch (c = *cp++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 case 27:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 switch (*cp++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 case '@':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 y = *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 x = *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 count -= 4;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 case 'A':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 ScreenAttrib = *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 count -= 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 case 'B':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 visible_bell (*cp++);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 count -= 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 case 'C':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 ScreenClear ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 x = y = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 case 'E':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 for (i = ScreenCols () - 1; i >= x; i--)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 ScreenPutChar (' ', ScreenAttrib, i, y);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 case 'R':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 x++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 case 'U':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 y--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 case 'X':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 ScreenAttrib ^= *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 count -= 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 default:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 case 8:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 x--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 count--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 case 13:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 x = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 count--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 case 10:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 y++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 count--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 default:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 ScreenPutChar (c, ScreenAttrib, x++, y);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 count--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 fpurge (stdout);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 ScreenSetCursor (y, x);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 if (have_mouse) Mouse_on ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 /* This is a call to the original fflush. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 fflush (f);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 /* Do we need the internal terminal? */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 internal_terminal_init ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 char *term = getenv ("TERM");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 internal_terminal
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 = (!noninteractive) && term && !strcmp (term, "internal");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 /* These must be global. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 static _go32_dpmi_seginfo ctrl_break_vector;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 static _go32_dpmi_registers ctrl_break_regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 static int ctrlbreakinstalled = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 /* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 ctrl_break_func (regs)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 _go32_dpmi_registers *regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 Vquit_flag = Qt;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 install_ctrl_break_check ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 if (!ctrlbreakinstalled)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 /* Don't press Ctrl-Break if you don't have either DPMI or Emacs
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 was compiler with Djgpp 1.11 maintenance level 2 or later! */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 ctrlbreakinstalled = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 ctrl_break_vector.pm_offset = (int) ctrl_break_func;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 &ctrl_break_regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 /* Mouse routines under devellopment follow. Coordinates are in screen
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 positions and zero based. Mouse buttons are numbered from left to
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 right and also zero based. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 static int mouse_button_translate[NUM_MOUSE_BUTTONS];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 static int mouse_button_count;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 mouse_init ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 regs.x.ax = 0x0007;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 regs.x.cx = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 regs.x.dx = 8 * (ScreenCols () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 regs.x.ax = 0x0008;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 regs.x.cx = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 regs.x.dx = 8 * (ScreenRows () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 mouse_moveto (ScreenCols () - 1, ScreenRows () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 mouse_on ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 mouse_on ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 regs.x.ax = 0x0001;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 mouse_off ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 regs.x.ax = 0x0002;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 mouse_moveto (x, y)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 int x, y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 regs.x.ax = 0x0004;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 mouse_last_x = regs.x.cx = x * 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 mouse_last_y = regs.x.dx = y * 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 mouse_pressed (b, xp, yp)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 int b, *xp, *yp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 if (b >= mouse_button_count)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 regs.x.ax = 0x0005;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 regs.x.bx = mouse_button_translate[b];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 if (regs.x.bx)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 *xp = regs.x.cx / 8, *yp = regs.x.dx /8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 return (regs.x.bx != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 mouse_released (b, xp, yp)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 int b, *xp, *yp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 if (b >= mouse_button_count)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 regs.x.ax = 0x0006;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 regs.x.bx = mouse_button_translate[b];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 if (regs.x.bx)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 return (regs.x.bx != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 mouse_get_pos (f, bar_window, part, x, y, time)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 FRAME_PTR *f;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 Lisp_Object *bar_window, *x, *y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 enum scroll_bar_part *part;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 unsigned long *time;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 struct timeval tv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 regs.x.ax = 0x0003;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 *f = selected_frame;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 *bar_window = Qnil;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 gettimeofday (&tv, NULL);
6056
afa75a0c15f8 (mouse_get_pos): Don't convert to glyph units.
Richard M. Stallman <rms@gnu.org>
parents: 5980
diff changeset
1016 *x = make_number (regs.x.cx);
afa75a0c15f8 (mouse_get_pos): Don't convert to glyph units.
Richard M. Stallman <rms@gnu.org>
parents: 5980
diff changeset
1017 *y = make_number (regs.x.dx);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 *time = tv.tv_usec;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 mouse_moved = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 mouse_check_moved ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 regs.x.ax = 0x0003;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 if (regs.x.cx != mouse_last_x || regs.x.dx != mouse_last_y)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 mouse_moved = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 mouse_last_x = regs.x.cx;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 mouse_last_y = regs.x.dx;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 mouse_init1 ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 int present;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 regs.x.ax = 0x0021;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 present = internal_terminal && (regs.x.ax & 0xffff) == 0xffff;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 if (present)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 if (regs.x.bx == 3)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 mouse_button_count = 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 mouse_button_translate[0] = 0; /* Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 mouse_button_translate[1] = 2; /* Middle */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 mouse_button_translate[2] = 1; /* Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 mouse_button_count = 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 mouse_button_translate[0] = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 mouse_button_translate[1] = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 mouse_position_hook = &mouse_get_pos;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 mouse_init ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 return present;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 #endif /* MSDOS */