Mercurial > emacs
annotate src/msdos.c @ 15077:e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
address to `intdos' instead of SI which can be 16-bit.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 26 Apr 1996 11:56:25 +0000 |
parents | 9e174c2b4ba6 |
children | c62cd2650ced |
rev | line source |
---|---|
7666
13a977e6777a
(dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents:
7523
diff
changeset
|
1 /* MS-DOS specific C utilities. |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2 Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc. |
5503 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
10504 | 8 the Free Software Foundation; either version 2, or (at your option) |
5503 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14157
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14157
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
5503 | 20 |
7666
13a977e6777a
(dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents:
7523
diff
changeset
|
21 /* Contributed by Morten Welinder */ |
13179 | 22 /* New display, keyboard, and mouse control by Kim F. Storm */ |
7666
13a977e6777a
(dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents:
7523
diff
changeset
|
23 |
5503 | 24 /* Note: some of the stuff here was taken from end of sysdep.c in demacs. */ |
25 | |
5980 | 26 #include <config.h> |
5503 | 27 |
28 #ifdef MSDOS | |
29 #include "lisp.h" | |
30 #include <stdio.h> | |
31 #include <stdlib.h> | |
32 #include <sys/param.h> | |
33 #include <sys/time.h> | |
34 #include <dos.h> | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
35 #if __DJGPP__ >= 2 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
36 #include <fcntl.h> |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
37 #endif |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
38 |
5503 | 39 #include "dosfns.h" |
40 #include "msdos.h" | |
41 #include "systime.h" | |
42 #include "termhooks.h" | |
9572 | 43 #include "dispextern.h" |
44 #include "termopts.h" | |
5503 | 45 #include "frame.h" |
9572 | 46 #include "window.h" |
5503 | 47 #include <go32.h> |
48 #include <pc.h> | |
49 #include <ctype.h> | |
50 /* #include <process.h> */ | |
51 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */ | |
52 #define P_WAIT 1 | |
53 | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
54 #if __DJGPP__ > 1 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
55 |
14999 | 56 #include <signal.h> |
57 | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
58 #ifndef SYSTEM_MALLOC |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
59 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
60 #ifdef GNU_MALLOC |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
61 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
62 /* If other `malloc' than ours is used, force our `sbrk' behave like |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
63 Unix programs expect (resize memory blocks to keep them contiguous). |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
64 If `sbrk' from `ralloc.c' is NOT used, also zero-out sbrk'ed memory, |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
65 because that's what `gmalloc' expects to get. */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
66 #include <crt0.h> |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
67 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
68 #ifdef REL_ALLOC |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
69 int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK; |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
70 #else /* not REL_ALLOC */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
71 int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY); |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
72 #endif /* not REL_ALLOC */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
73 #endif /* GNU_MALLOC */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
74 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
75 #endif /* not SYSTEM_MALLOC */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
76 #endif /* __DJGPP__ > 1 */ |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
77 |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
78 static unsigned long |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
79 event_timestamp () |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
80 { |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
81 struct time t; |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
82 unsigned long s; |
13179 | 83 |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
84 gettime (&t); |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
85 s = t.ti_min; |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
86 s *= 60; |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
87 s += t.ti_sec; |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
88 s *= 1000; |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
89 s += t.ti_hund * 10; |
13179 | 90 |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
91 return s; |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
92 } |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
93 |
13179 | 94 |
95 /* ------------------------ Mouse control --------------------------- | |
96 * | |
97 * Coordinates are in screen positions and zero based. | |
98 * Mouse buttons are numbered from left to right and also zero based. | |
99 */ | |
5503 | 100 |
13179 | 101 int have_mouse; /* 0: no, 1: enabled, -1: disabled */ |
102 static int mouse_visible; | |
5503 | 103 |
13179 | 104 static int mouse_last_x; |
105 static int mouse_last_y; | |
5503 | 106 |
13179 | 107 static int mouse_button_translate[NUM_MOUSE_BUTTONS]; |
108 static int mouse_button_count; | |
5503 | 109 |
13179 | 110 void |
111 mouse_on () | |
112 { | |
113 union REGS regs; | |
5503 | 114 |
13179 | 115 if (have_mouse > 0 && !mouse_visible) |
116 { | |
117 if (termscript) | |
118 fprintf (termscript, "<M_ON>"); | |
119 regs.x.ax = 0x0001; | |
120 int86 (0x33, ®s, ®s); | |
121 mouse_visible = 1; | |
5503 | 122 } |
123 } | |
124 | |
13179 | 125 void |
126 mouse_off () | |
5503 | 127 { |
13179 | 128 union REGS regs; |
5503 | 129 |
13179 | 130 if (have_mouse > 0 && mouse_visible) |
5503 | 131 { |
13179 | 132 if (termscript) |
133 fprintf (termscript, "<M_OFF>"); | |
134 regs.x.ax = 0x0002; | |
135 int86 (0x33, ®s, ®s); | |
136 mouse_visible = 0; | |
5503 | 137 } |
138 } | |
139 | |
140 void | |
13179 | 141 mouse_moveto (x, y) |
142 int x, y; | |
5503 | 143 { |
13179 | 144 union REGS regs; |
145 | |
146 if (termscript) | |
147 fprintf (termscript, "<M_XY=%dx%d>", x, y); | |
148 regs.x.ax = 0x0004; | |
149 mouse_last_x = regs.x.cx = x * 8; | |
150 mouse_last_y = regs.x.dx = y * 8; | |
151 int86 (0x33, ®s, ®s); | |
5503 | 152 } |
153 | |
13179 | 154 static int |
155 mouse_pressed (b, xp, yp) | |
156 int b, *xp, *yp; | |
157 { | |
158 union REGS regs; | |
159 | |
160 if (b >= mouse_button_count) | |
161 return 0; | |
162 regs.x.ax = 0x0005; | |
163 regs.x.bx = mouse_button_translate[b]; | |
164 int86 (0x33, ®s, ®s); | |
165 if (regs.x.bx) | |
166 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8; | |
167 return (regs.x.bx != 0); | |
168 } | |
169 | |
170 static int | |
171 mouse_released (b, xp, yp) | |
172 int b, *xp, *yp; | |
173 { | |
174 union REGS regs; | |
175 | |
176 if (b >= mouse_button_count) | |
177 return 0; | |
178 regs.x.ax = 0x0006; | |
179 regs.x.bx = mouse_button_translate[b]; | |
180 int86 (0x33, ®s, ®s); | |
181 if (regs.x.bx) | |
182 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8; | |
183 return (regs.x.bx != 0); | |
184 } | |
185 | |
186 static void | |
187 mouse_get_xy (int *x, int *y) | |
5503 | 188 { |
189 union REGS regs; | |
190 | |
13179 | 191 regs.x.ax = 0x0003; |
192 int86 (0x33, ®s, ®s); | |
193 *x = regs.x.cx / 8; | |
194 *y = regs.x.dx / 8; | |
195 } | |
196 | |
197 void | |
198 mouse_get_pos (f, insist, bar_window, part, x, y, time) | |
199 FRAME_PTR *f; | |
200 int insist; | |
201 Lisp_Object *bar_window, *x, *y; | |
202 enum scroll_bar_part *part; | |
203 unsigned long *time; | |
204 { | |
205 int ix, iy; | |
206 union REGS regs; | |
207 | |
208 regs.x.ax = 0x0003; | |
209 int86 (0x33, ®s, ®s); | |
210 *f = selected_frame; | |
211 *bar_window = Qnil; | |
212 mouse_get_xy (&ix, &iy); | |
213 selected_frame->mouse_moved = 0; | |
214 *x = make_number (ix); | |
215 *y = make_number (iy); | |
216 *time = event_timestamp (); | |
217 } | |
218 | |
219 static void | |
220 mouse_check_moved () | |
221 { | |
222 int x, y; | |
223 | |
224 mouse_get_xy (&x, &y); | |
225 selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y); | |
226 mouse_last_x = x; | |
227 mouse_last_y = y; | |
5503 | 228 } |
229 | |
13179 | 230 void |
231 mouse_init () | |
5503 | 232 { |
13179 | 233 union REGS regs; |
234 | |
235 if (termscript) | |
236 fprintf (termscript, "<M_INIT>"); | |
237 | |
238 regs.x.ax = 0x0021; | |
239 int86 (0x33, ®s, ®s); | |
240 | |
241 regs.x.ax = 0x0007; | |
242 regs.x.cx = 0; | |
243 regs.x.dx = 8 * (ScreenCols () - 1); | |
244 int86 (0x33, ®s, ®s); | |
245 | |
246 regs.x.ax = 0x0008; | |
247 regs.x.cx = 0; | |
248 regs.x.dx = 8 * (ScreenRows () - 1); | |
249 int86 (0x33, ®s, ®s); | |
250 | |
251 mouse_moveto (0, 0); | |
252 mouse_visible = 0; | |
253 } | |
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
254 |
13179 | 255 /* ------------------------- Screen control ---------------------- |
256 * | |
257 */ | |
5503 | 258 |
13179 | 259 static int internal_terminal = 0; |
260 | |
261 #ifndef HAVE_X_WINDOWS | |
262 extern unsigned char ScreenAttrib; | |
263 static int screen_face; | |
264 static int highlight; | |
265 | |
266 static int screen_size_X; | |
267 static int screen_size_Y; | |
268 static int screen_size; | |
269 | |
270 static int current_pos_X; | |
271 static int current_pos_Y; | |
272 static int new_pos_X; | |
273 static int new_pos_Y; | |
274 | |
275 static void *startup_screen_buffer; | |
276 static int startup_screen_size_X; | |
277 static int startup_screen_size_Y; | |
278 static int startup_pos_X; | |
279 static int startup_pos_Y; | |
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
280 static unsigned char startup_screen_attrib; |
13179 | 281 |
282 static int term_setup_done; | |
283 | |
284 /* Similar to the_only_frame. */ | |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
285 struct x_output the_only_x_display; |
13179 | 286 |
287 /* This is never dereferenced. */ | |
288 Display *x_current_display; | |
5503 | 289 |
290 | |
13179 | 291 #define SCREEN_SET_CURSOR() \ |
292 if (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y) \ | |
293 ScreenSetCursor (current_pos_Y = new_pos_Y, current_pos_X = new_pos_X) | |
5503 | 294 |
13179 | 295 static |
296 dos_direct_output (y, x, buf, len) | |
297 int y; | |
298 int x; | |
299 char *buf; | |
300 int len; | |
5503 | 301 { |
13179 | 302 int t = (int) ScreenPrimary + 2 * (x + y * screen_size_X); |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
303 |
13179 | 304 while (--len >= 0) { |
305 dosmemput (buf++, 1, t); | |
306 t += 2; | |
307 } | |
5503 | 308 } |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
309 #endif |
5503 | 310 |
311 /* Flash the screen as a substitute for BEEPs. */ | |
312 | |
13179 | 313 #if (__DJGPP__ < 2) |
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
314 static void |
7667
bae9c0fa1c2f
(do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents:
7666
diff
changeset
|
315 do_visible_bell (xorattr) |
5503 | 316 unsigned char xorattr; |
317 { | |
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
318 asm volatile |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
319 (" movb $1,%%dl |
5503 | 320 visible_bell_0: |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
321 movl _ScreenPrimary,%%eax |
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
322 call dosmemsetup |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
323 movl %%eax,%%ebx |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
324 movl %1,%%ecx |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
325 movb %0,%%al |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
326 incl %%ebx |
5503 | 327 visible_bell_1: |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
328 xorb %%al,%%gs:(%%ebx) |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
329 addl $2,%%ebx |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
330 decl %%ecx |
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
331 jne visible_bell_1 |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
332 decb %%dl |
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
333 jne visible_bell_3 |
5503 | 334 visible_bell_2: |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
335 movzwl %%ax,%%eax |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
336 movzwl %%ax,%%eax |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
337 movzwl %%ax,%%eax |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
338 movzwl %%ax,%%eax |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
339 decw %%cx |
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
340 jne visible_bell_2 |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
341 jmp visible_bell_0 |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
342 visible_bell_3:" |
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
343 : /* no output */ |
13179 | 344 : "m" (xorattr), "g" (screen_size) |
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
345 : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx"); |
5503 | 346 } |
347 | |
13179 | 348 static void |
349 ScreenVisualBell (void) | |
350 { | |
351 /* This creates an xor-mask that will swap the default fore- and | |
352 background colors. */ | |
353 do_visible_bell (((the_only_x_display.foreground_pixel | |
354 ^ the_only_x_display.background_pixel) | |
355 * 0x11) & 0x7f); | |
356 } | |
357 #endif | |
358 | |
359 #ifndef HAVE_X_WINDOWS | |
360 | |
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
361 /* Set the screen dimensions so that it can show no less than |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
362 ROWS x COLS frame. */ |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
363 |
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
364 void |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
365 dos_set_window_size (rows, cols) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
366 int *rows, *cols; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
367 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
368 char video_name[30]; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
369 Lisp_Object video_mode; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
370 int video_mode_value; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
371 int have_vga = 0; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
372 union REGS regs; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
373 int current_rows = ScreenRows (), current_cols = ScreenCols (); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
374 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
375 if (*rows == current_rows && *cols == current_cols) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
376 return; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
377 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
378 /* Do we have a VGA? */ |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
379 regs.x.ax = 0x1a00; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
380 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
381 if (regs.h.al == 0x1a && regs.h.bl > 5 && regs.h.bl < 13) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
382 have_vga = 1; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
383 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
384 mouse_off (); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
385 |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
386 /* If the user specified a special video mode for these dimensions, |
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
387 use that mode. */ |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
388 sprintf (video_name, "screen-dimensions-%dx%d", *rows, *cols); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
389 video_mode = XSYMBOL (Fintern_soft (build_string (video_name), |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
390 Qnil))-> value; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
391 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
392 if (INTEGERP (video_mode) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
393 && (video_mode_value = XINT (video_mode)) > 0) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
394 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
395 regs.x.ax = video_mode_value; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
396 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
397 regs.h.bl = 0; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
398 regs.x.ax = 0x1003; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
399 int86 (0x10, ®s, ®s); |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
400 |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
401 if (have_mouse) |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
402 { |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
403 /* Must hardware-reset the mouse, or else it won't update |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
404 its notion of screen dimensions for some non-standard |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
405 video modes. This is *painfully* slow... */ |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
406 regs.x.ax = 0; |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
407 int86 (0x33, ®s, ®s); |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
408 } |
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
409 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
410 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
411 /* Find one of the dimensions supported by standard EGA/VGA |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
412 which gives us at least the required dimensions. */ |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
413 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
414 #if __DJGPP__ > 1 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
415 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
416 else |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
417 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
418 static struct { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
419 int rows; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
420 int need_vga; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
421 } std_dimension[] = { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
422 {25, 0}, |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
423 {28, 1}, |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
424 {35, 0}, |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
425 {40, 1}, |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
426 {43, 0}, |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
427 {50, 1} |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
428 }; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
429 int i = 0; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
430 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
431 while (i < sizeof (std_dimension) / sizeof (std_dimension[0])) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
432 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
433 if (std_dimension[i].need_vga <= have_vga |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
434 && std_dimension[i].rows >= *rows) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
435 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
436 if (std_dimension[i].rows != current_rows |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
437 || *cols != current_cols) |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
438 _set_screen_lines (std_dimension[i].rows); |
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
439 break; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
440 } |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
441 i++; |
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
442 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
443 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
444 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
445 #else /* not __DJGPP__ > 1 */ |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
446 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
447 else if (*rows <= 25) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
448 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
449 if (current_rows != 25 || current_cols != 80) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
450 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
451 regs.x.ax = 3; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
452 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
453 regs.x.ax = 0x1101; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
454 regs.h.bl = 0; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
455 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
456 regs.x.ax = 0x1200; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
457 regs.h.bl = 32; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
458 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
459 regs.x.ax = 3; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
460 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
461 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
462 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
463 else if (*rows <= 50) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
464 if (have_vga && (current_rows != 50 || current_cols != 80) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
465 || *rows <= 43 && (current_rows != 43 || current_cols != 80)) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
466 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
467 regs.x.ax = 3; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
468 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
469 regs.x.ax = 0x1112; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
470 regs.h.bl = 0; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
471 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
472 regs.x.ax = 0x1200; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
473 regs.h.bl = 32; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
474 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
475 regs.x.ax = 0x0100; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
476 regs.x.cx = 7; |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
477 int86 (0x10, ®s, ®s); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
478 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
479 #endif /* not __DJGPP__ > 1 */ |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
480 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
481 if (have_mouse) |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
482 { |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
483 mouse_init (); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
484 mouse_on (); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
485 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
486 |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
487 /* Tell the caller what dimensions have been REALLY set. */ |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
488 *rows = ScreenRows (); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
489 *cols = ScreenCols (); |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
490 } |
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
491 |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
492 /* If we write a character in the position where the mouse is, |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
493 the mouse cursor may need to be refreshed. */ |
7744
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
494 |
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
495 static void |
13179 | 496 mouse_off_maybe () |
7744
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
497 { |
13179 | 498 int x, y; |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
499 |
13179 | 500 if (!mouse_visible) |
501 return; | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
502 |
13179 | 503 mouse_get_xy (&x, &y); |
504 if (y != new_pos_Y || x < new_pos_X) | |
505 return; | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
506 |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
507 mouse_off (); |
9572 | 508 } |
509 | |
510 static | |
511 IT_ring_bell () | |
512 { | |
513 if (visible_bell) | |
514 { | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
515 mouse_off (); |
13179 | 516 ScreenVisualBell (); |
9572 | 517 } |
518 else | |
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
519 { |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
520 union REGS inregs, outregs; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
521 inregs.h.ah = 2; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
522 inregs.h.dl = 7; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
523 intdos (&inregs, &outregs); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
524 } |
9572 | 525 } |
526 | |
527 static void | |
528 IT_set_face (int face) | |
529 { | |
530 struct face *fp; | |
531 extern struct face *intern_face (/* FRAME_PTR, struct face * */); | |
532 | |
533 if (face == 1 || (face == 0 && highlight)) | |
534 fp = FRAME_MODE_LINE_FACE (foo); | |
535 else if (face <= 0 || face >= FRAME_N_COMPUTED_FACES (foo)) | |
536 fp = FRAME_DEFAULT_FACE (foo); | |
537 else | |
538 fp = intern_face (selected_frame, FRAME_COMPUTED_FACES (foo)[face]); | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
539 if (termscript) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
540 fprintf (termscript, "<FACE:%d:%d>", FACE_FOREGROUND (fp), FACE_BACKGROUND (fp)); |
13179 | 541 screen_face = face; |
542 ScreenAttrib = (FACE_BACKGROUND (fp) << 4) | FACE_FOREGROUND (fp); | |
9572 | 543 } |
544 | |
545 static | |
546 IT_write_glyphs (GLYPH *str, int len) | |
547 { | |
548 int newface; | |
13179 | 549 int ch, l = len; |
550 unsigned char *buf, *bp; | |
551 | |
552 if (len == 0) return; | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
553 |
13179 | 554 buf = bp = alloca (len * 2); |
555 | |
556 while (--l >= 0) | |
9572 | 557 { |
558 newface = FAST_GLYPH_FACE (*str); | |
13179 | 559 if (newface != screen_face) |
560 IT_set_face (newface); | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
561 ch = FAST_GLYPH_CHAR (*str); |
13179 | 562 *bp++ = (unsigned char)ch; |
563 *bp++ = ScreenAttrib; | |
564 | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
565 if (termscript) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
566 fputc (ch, termscript); |
13179 | 567 str++; |
9572 | 568 } |
13179 | 569 |
570 mouse_off_maybe (); | |
571 dosmemput (buf, 2 * len, | |
572 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | |
573 new_pos_X += len; | |
9572 | 574 } |
575 | |
576 static | |
577 IT_clear_end_of_line (first_unused) | |
578 { | |
13179 | 579 char *spaces, *sp; |
580 int i, j; | |
581 | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
582 IT_set_face (0); |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
583 if (termscript) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
584 fprintf (termscript, "<CLR:EOL>"); |
13179 | 585 i = (j = screen_size_X - new_pos_X) * 2; |
586 spaces = sp = alloca (i); | |
587 | |
588 while (--j >= 0) | |
589 { | |
590 *sp++ = ' '; | |
591 *sp++ = ScreenAttrib; | |
592 } | |
593 | |
594 mouse_off_maybe (); | |
595 dosmemput (spaces, i, | |
596 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | |
597 } | |
598 | |
599 static | |
600 IT_clear_screen (void) | |
601 { | |
602 if (termscript) | |
603 fprintf (termscript, "<CLR:SCR>"); | |
604 IT_set_face (0); | |
605 mouse_off (); | |
606 ScreenClear (); | |
607 new_pos_X = new_pos_Y = 0; | |
608 } | |
609 | |
610 static | |
611 IT_clear_to_end (void) | |
612 { | |
613 if (termscript) | |
614 fprintf (termscript, "<CLR:EOS>"); | |
615 | |
616 while (new_pos_Y < screen_size_Y) { | |
617 new_pos_X = 0; | |
618 IT_clear_end_of_line (0); | |
619 new_pos_Y++; | |
620 } | |
9572 | 621 } |
622 | |
623 static | |
624 IT_cursor_to (int y, int x) | |
625 { | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
626 if (termscript) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
627 fprintf (termscript, "\n<XY=%dx%d>", x, y); |
13179 | 628 new_pos_X = x; |
629 new_pos_Y = y; | |
9572 | 630 } |
631 | |
13179 | 632 static |
9572 | 633 IT_reassert_line_highlight (new, vpos) |
634 int new, vpos; | |
635 { | |
636 highlight = new; | |
637 IT_set_face (0); /* To possibly clear the highlighting. */ | |
638 } | |
639 | |
640 static | |
641 IT_change_line_highlight (new_highlight, vpos, first_unused_hpos) | |
642 { | |
643 highlight = new_highlight; | |
644 IT_set_face (0); /* To possibly clear the highlighting. */ | |
645 IT_cursor_to (vpos, 0); | |
646 IT_clear_end_of_line (first_unused_hpos); | |
647 } | |
648 | |
649 static | |
650 IT_update_begin () | |
651 { | |
652 highlight = 0; | |
653 IT_set_face (0); /* To possibly clear the highlighting. */ | |
13179 | 654 screen_face = -1; |
655 } | |
656 | |
657 static | |
658 IT_update_end () | |
659 { | |
9572 | 660 } |
661 | |
662 /* This was more or less copied from xterm.c */ | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
663 |
9572 | 664 static void |
665 IT_set_menu_bar_lines (window, n) | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
666 Lisp_Object window; |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
667 int n; |
9572 | 668 { |
669 struct window *w = XWINDOW (window); | |
670 | |
13646
7714b87119a3
(IT_set_menu_bar_lines): Clear last_modified field.
Richard M. Stallman <rms@gnu.org>
parents:
13642
diff
changeset
|
671 XSETFASTINT (w->last_modified, 0); |
9572 | 672 XSETFASTINT (w->top, XFASTINT (w->top) + n); |
673 XSETFASTINT (w->height, XFASTINT (w->height) - n); | |
674 | |
675 /* Handle just the top child in a vertical split. */ | |
676 if (!NILP (w->vchild)) | |
677 IT_set_menu_bar_lines (w->vchild, n); | |
678 | |
679 /* Adjust all children in a horizontal split. */ | |
680 for (window = w->hchild; !NILP (window); window = w->next) | |
681 { | |
682 w = XWINDOW (window); | |
683 IT_set_menu_bar_lines (window, n); | |
684 } | |
685 } | |
686 | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
687 /* IT_set_terminal_modes is called when emacs is started, |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
688 resumed, and whenever the screen is redrawn! */ |
13179 | 689 |
690 static | |
691 IT_set_terminal_modes (void) | |
692 { | |
693 char *colors; | |
694 FRAME_PTR f; | |
695 struct face *fp; | |
696 | |
697 if (termscript) | |
698 fprintf (termscript, "\n<SET_TERM>"); | |
699 highlight = 0; | |
700 | |
701 screen_size_X = ScreenCols (); | |
702 screen_size_Y = ScreenRows (); | |
703 screen_size = screen_size_X * screen_size_Y; | |
704 | |
705 new_pos_X = new_pos_Y = 0; | |
706 current_pos_X = current_pos_Y = -1; | |
707 | |
708 if (term_setup_done) | |
709 return; | |
710 term_setup_done = 1; | |
711 | |
712 startup_screen_size_X = screen_size_X; | |
713 startup_screen_size_Y = screen_size_Y; | |
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
714 startup_screen_attrib = ScreenAttrib; |
13179 | 715 |
716 ScreenGetCursor (&startup_pos_Y, &startup_pos_X); | |
717 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); | |
718 | |
719 if (termscript) | |
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
720 fprintf (termscript, "<SCREEN SAVED (dimensions=%dx%d)>\n", |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
721 screen_size_X, screen_size_Y); |
13179 | 722 } |
723 | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
724 /* IT_reset_terminal_modes is called when emacs is |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
725 suspended or killed. */ |
13179 | 726 |
727 static | |
728 IT_reset_terminal_modes (void) | |
729 { | |
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
730 int display_row_start = (int) ScreenPrimary; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
731 int saved_row_len = startup_screen_size_X * 2; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
732 int update_row_len = ScreenCols () * 2; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
733 int current_rows = ScreenRows (); |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
734 int to_next_row = update_row_len; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
735 unsigned char *saved_row = startup_screen_buffer; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
736 int cursor_pos_X = ScreenCols () - 1; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
737 int cursor_pos_Y = ScreenRows () - 1; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
738 |
13179 | 739 if (termscript) |
13274 | 740 fprintf (termscript, "\n<RESET_TERM>"); |
13179 | 741 |
742 highlight = 0; | |
743 | |
744 if (!term_setup_done) | |
745 return; | |
746 | |
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
747 mouse_off (); |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
748 |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
749 /* We have a situation here. |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
750 We cannot just do ScreenUpdate(startup_screen_buffer) because |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
751 the luser could have changed screen dimensions inside Emacs |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
752 and failed (or didn't want) to restore them before killing |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
753 Emacs. ScreenUpdate() uses the *current* screen dimensions and |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
754 thus will happily use memory outside what was allocated for |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
755 `startup_screen_buffer'. |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
756 Thus we only restore as much as the current screen dimensions |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
757 can hold, and clear the rest (if the saved screen is smaller than |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
758 the current) with the color attribute saved at startup. The cursor |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
759 is also restored within the visible dimensions. */ |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
760 |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
761 ScreenAttrib = startup_screen_attrib; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
762 ScreenClear (); |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
763 |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
764 if (update_row_len > saved_row_len) |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
765 update_row_len = saved_row_len; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
766 if (current_rows > startup_screen_size_Y) |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
767 current_rows = startup_screen_size_Y; |
13179 | 768 |
769 if (termscript) | |
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
770 fprintf (termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n", |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
771 update_row_len / 2, current_rows); |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
772 |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
773 while (current_rows--) |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
774 { |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
775 dosmemput (saved_row, update_row_len, display_row_start); |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
776 saved_row += saved_row_len; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
777 display_row_start += to_next_row; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
778 } |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
779 if (startup_pos_X < cursor_pos_X) |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
780 cursor_pos_X = startup_pos_X; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
781 if (startup_pos_Y < cursor_pos_Y) |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
782 cursor_pos_Y = startup_pos_Y; |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
783 |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
784 ScreenSetCursor (cursor_pos_Y, cursor_pos_X); |
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
785 xfree (startup_screen_buffer); |
13179 | 786 |
787 term_setup_done = 0; | |
788 } | |
789 | |
790 static | |
791 IT_set_terminal_window (void) | |
792 { | |
793 } | |
794 | |
9572 | 795 void |
796 IT_set_frame_parameters (frame, alist) | |
797 FRAME_PTR frame; | |
798 Lisp_Object alist; | |
799 { | |
800 Lisp_Object tail; | |
801 int redraw; | |
802 extern unsigned long load_color (); | |
803 FRAME_PTR f = (FRAME_PTR) &the_only_frame; | |
804 | |
805 redraw = 0; | |
806 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) | |
807 { | |
808 Lisp_Object elt, prop, val; | |
809 | |
810 elt = Fcar (tail); | |
811 prop = Fcar (elt); | |
812 val = Fcdr (elt); | |
813 CHECK_SYMBOL (prop, 1); | |
814 | |
815 if (EQ (prop, intern ("foreground-color"))) | |
816 { | |
817 unsigned long new_color = load_color (f, val); | |
818 if (new_color != ~0) | |
819 { | |
820 FRAME_FOREGROUND_PIXEL (f) = new_color; | |
821 redraw = 1; | |
822 } | |
823 } | |
824 else if (EQ (prop, intern ("background-color"))) | |
825 { | |
826 unsigned long new_color = load_color (f, val); | |
827 if (new_color != ~0) | |
828 { | |
829 FRAME_BACKGROUND_PIXEL (f) = new_color & ~8; | |
830 redraw = 1; | |
831 } | |
832 } | |
833 else if (EQ (prop, intern ("menu-bar-lines"))) | |
834 { | |
835 int new; | |
836 int old = FRAME_MENU_BAR_LINES (the_only_frame); | |
837 | |
838 if (INTEGERP (val)) | |
839 new = XINT (val); | |
840 else | |
841 new = 0; | |
842 FRAME_MENU_BAR_LINES (f) = new; | |
843 IT_set_menu_bar_lines (the_only_frame.root_window, new - old); | |
844 } | |
845 } | |
846 | |
847 if (redraw) | |
848 { | |
849 recompute_basic_faces (f); | |
850 Fredraw_frame (Fselected_frame ()); | |
851 } | |
852 } | |
853 | |
13179 | 854 #endif /* !HAVE_X_WINDOWS */ |
9572 | 855 |
856 | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
857 /* Do we need the internal terminal? */ |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
858 |
5503 | 859 void |
860 internal_terminal_init () | |
861 { | |
862 char *term = getenv ("TERM"); | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
863 char *colors; |
13179 | 864 |
9572 | 865 #ifdef HAVE_X_WINDOWS |
866 if (!inhibit_window_system) | |
867 return; | |
868 #endif | |
869 | |
5503 | 870 internal_terminal |
871 = (!noninteractive) && term && !strcmp (term, "internal"); | |
9572 | 872 |
13179 | 873 if (getenv ("EMACSTEST")) |
13274 | 874 termscript = fopen (getenv ("EMACSTEST"), "wt"); |
13179 | 875 |
9572 | 876 #ifndef HAVE_X_WINDOWS |
13179 | 877 if (!internal_terminal || inhibit_window_system) |
9572 | 878 { |
13179 | 879 the_only_frame.output_method = output_termcap; |
880 return; | |
881 } | |
9572 | 882 |
13179 | 883 Vwindow_system = intern ("pc"); |
884 Vwindow_system_version = make_number (1); | |
885 | |
886 bzero (&the_only_x_display, sizeof the_only_x_display); | |
887 the_only_x_display.background_pixel = 7; /* White */ | |
888 the_only_x_display.foreground_pixel = 0; /* Black */ | |
13274 | 889 colors = getenv ("EMACSCOLORS"); |
13179 | 890 if (colors && strlen (colors) >= 2) |
891 { | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
892 /* Foreground colrs use 4 bits, background only 3. */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
893 if (isxdigit (colors[0]) && !isdigit (colors[0])) |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
894 colors[0] += 10 - (isupper (colors[0]) ? 'A' : 'a'); |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
895 if (colors[0] >= 0 && colors[0] < 16) |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
896 the_only_x_display.foreground_pixel = colors[0]; |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
897 if (colors[1] >= 0 && colors[1] < 8) |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
898 the_only_x_display.background_pixel = colors[1]; |
13179 | 899 } |
900 the_only_x_display.line_height = 1; | |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
901 the_only_frame.output_data.x = &the_only_x_display; |
13179 | 902 the_only_frame.output_method = output_msdos_raw; |
13625
397f07418271
(internal_terminal_init): Initialize the_only_x_display.font.
Richard M. Stallman <rms@gnu.org>
parents:
13624
diff
changeset
|
903 the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */ |
9572 | 904 |
13179 | 905 init_frame_faces ((FRAME_PTR) &the_only_frame); |
906 | |
907 ring_bell_hook = IT_ring_bell; | |
908 write_glyphs_hook = IT_write_glyphs; | |
909 cursor_to_hook = raw_cursor_to_hook = IT_cursor_to; | |
910 clear_to_end_hook = IT_clear_to_end; | |
911 clear_end_of_line_hook = IT_clear_end_of_line; | |
912 clear_frame_hook = IT_clear_screen; | |
913 change_line_highlight_hook = IT_change_line_highlight; | |
914 update_begin_hook = IT_update_begin; | |
915 update_end_hook = IT_update_end; | |
916 reassert_line_highlight_hook = IT_reassert_line_highlight; | |
917 | |
918 /* These hooks are called by term.c without being checked. */ | |
919 set_terminal_modes_hook = IT_set_terminal_modes; | |
920 reset_terminal_modes_hook = IT_reset_terminal_modes; | |
921 set_terminal_window_hook = IT_set_terminal_window; | |
9572 | 922 #endif |
5503 | 923 } |
13179 | 924 |
925 dos_get_saved_screen (screen, rows, cols) | |
926 char **screen; | |
927 int *rows; | |
928 int *cols; | |
929 { | |
930 #ifndef HAVE_X_WINDOWS | |
931 *screen = startup_screen_buffer; | |
932 *cols = startup_screen_size_X; | |
933 *rows = startup_screen_size_Y; | |
934 return 1; | |
935 #else | |
936 return 0; | |
937 #endif | |
938 } | |
13274 | 939 |
13179 | 940 /* ----------------------- Keyboard control ---------------------- |
941 * | |
942 * Keymaps reflect the following keyboard layout: | |
943 * | |
944 * 0 1 2 3 4 5 6 7 8 9 10 11 12 BS | |
945 * TAB 15 16 17 18 19 20 21 22 23 24 25 26 (41) | |
946 * CLOK 30 31 32 33 34 35 36 37 38 39 40 (41) RET | |
947 * SH () 45 46 47 48 49 50 51 52 53 54 SHIFT | |
948 * SPACE | |
949 */ | |
950 | |
951 static int extended_kbd; /* 101 (102) keyboard present. */ | |
952 | |
953 struct dos_keyboard_map | |
954 { | |
955 char *unshifted; | |
956 char *shifted; | |
957 char *alt_gr; | |
958 }; | |
959 | |
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
960 |
13179 | 961 static struct dos_keyboard_map us_keyboard = { |
962 /* 0 1 2 3 4 5 */ | |
963 /* 01234567890123456789012345678901234567890 12345678901234 */ | |
964 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ", | |
965 /* 0123456789012345678901234567890123456789 012345678901234 */ | |
966 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ", | |
967 0 /* no Alt-Gr key */ | |
968 }; | |
969 | |
970 static struct dos_keyboard_map fr_keyboard = { | |
971 /* 0 1 2 3 4 5 */ | |
972 /* 012 3456789012345678901234567890123456789012345678901234 */ | |
973 "ý&‚\",(-Š_€…)= azertyuiop^$ qsdfghjklm—* wxcvbnm;:! ", | |
974 /* 0123456789012345678901234567890123456789012345678901234 */ | |
975 " 1234567890ø+ AZERTYUIOPùœ QSDFGHJKLM%æ WXCVBN?./õ ", | |
976 /* 01234567 89012345678901234567890123456789012345678901234 */ | |
977 " ~#{[|`\\^@]} Ï " | |
978 }; | |
979 | |
980 static struct dos_keyboard_map dk_keyboard = { | |
981 /* 0 1 2 3 4 5 */ | |
982 /* 0123456789012345678901234567890123456789012345678901234 */ | |
983 "«1234567890+| qwertyuiop†~ asdfghjkl‘›' zxcvbnm,.- ", | |
984 /* 01 23456789012345678901234567890123456789012345678901234 */ | |
985 "õ!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL’* ZXCVBNM;:_ ", | |
986 /* 0123456789012345678901234567890123456789012345678901234 */ | |
987 " @œ$ {[]} | " | |
988 }; | |
989 | |
990 static struct keyboard_layout_list | |
991 { | |
992 int country_code; | |
993 struct dos_keyboard_map *keyboard_map; | |
13274 | 994 } keyboard_layout_list[] = |
995 { | |
996 1, &us_keyboard, | |
997 33, &fr_keyboard, | |
998 45, &dk_keyboard | |
13179 | 999 }; |
1000 | |
1001 static struct dos_keyboard_map *keyboard; | |
1002 static int keyboard_map_all; | |
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1003 |
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1004 int |
13179 | 1005 dos_set_keyboard (code, always) |
1006 int code; | |
1007 int always; | |
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1008 { |
13179 | 1009 int i; |
13624
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1010 |
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1011 /* Initialize to US settings, for countries that don't have their own. */ |
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1012 keyboard = keyboard_layout_list[0].keyboard_map; |
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1013 keyboard_map_all = always; |
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1014 dos_keyboard_layout = 1; |
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1015 |
13179 | 1016 for (i = 0; i < (sizeof (keyboard_layout_list)/sizeof (struct keyboard_layout_list)); i++) |
1017 if (code == keyboard_layout_list[i].country_code) | |
1018 { | |
1019 keyboard = keyboard_layout_list[i].keyboard_map; | |
1020 keyboard_map_all = always; | |
1021 dos_keyboard_layout = code; | |
1022 return 1; | |
1023 } | |
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1024 return 0; |
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1025 } |
13274 | 1026 |
13179 | 1027 #define Ignore 0x0000 |
1028 #define Normal 0x0000 /* normal key - alt changes scan-code */ | |
1029 #define FctKey 0x1000 /* func key if c == 0, else c */ | |
1030 #define Special 0x2000 /* func key even if c != 0 */ | |
1031 #define ModFct 0x3000 /* special if mod-keys, else 'c' */ | |
1032 #define Map 0x4000 /* alt scan-code, map to unshift/shift key */ | |
1033 #define KeyPad 0x5000 /* map to insert/kp-0 depending on c == 0xe0 */ | |
1034 #define Grey 0x6000 /* Grey keypad key */ | |
1035 | |
1036 #define Alt 0x0100 /* alt scan-code */ | |
1037 #define Ctrl 0x0200 /* ctrl scan-code */ | |
1038 #define Shift 0x0400 /* shift scan-code */ | |
1039 | |
1040 static struct | |
1041 { | |
1042 unsigned char char_code; /* normal code */ | |
1043 unsigned char meta_code; /* M- code */ | |
1044 unsigned char keypad_code; /* keypad code */ | |
1045 unsigned char editkey_code; /* edit key */ | |
1046 } keypad_translate_map[] = { | |
1047 '0', '0', 0xb0, /* kp-0 */ 0x63, /* insert */ | |
1048 '1', '1', 0xb1, /* kp-1 */ 0x57, /* end */ | |
1049 '2', '2', 0xb2, /* kp-2 */ 0x54, /* down */ | |
1050 '3', '3', 0xb3, /* kp-3 */ 0x56, /* next */ | |
1051 '4', '4', 0xb4, /* kp-4 */ 0x51, /* left */ | |
1052 '5', '5', 0xb5, /* kp-5 */ 0xb5, /* kp-5 */ | |
1053 '6', '6', 0xb6, /* kp-6 */ 0x53, /* right */ | |
1054 '7', '7', 0xb7, /* kp-7 */ 0x50, /* home */ | |
1055 '8', '8', 0xb8, /* kp-8 */ 0x52, /* up */ | |
1056 '9', '9', 0xb9, /* kp-9 */ 0x55, /* prior */ | |
1057 '.', '-', 0xae, /* kp-decimal */ 0xff /* delete */ | |
1058 }; | |
1059 | |
1060 static struct | |
1061 { | |
1062 unsigned char char_code; /* normal code */ | |
1063 unsigned char keypad_code; /* keypad code */ | |
1064 } grey_key_translate_map[] = { | |
1065 '/', 0xaf, /* kp-decimal */ | |
1066 '*', 0xaa, /* kp-multiply */ | |
1067 '-', 0xad, /* kp-subtract */ | |
1068 '+', 0xab, /* kp-add */ | |
1069 '\r', 0x8d /* kp-enter */ | |
1070 }; | |
1071 | |
1072 static unsigned short | |
1073 ibmpc_translate_map[] = | |
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
1074 { |
13179 | 1075 /* --------------- 00 to 0f --------------- */ |
1076 Normal | 0xff, /* Ctrl Break + Alt-NNN */ | |
1077 Alt | ModFct | 0x1b, /* Escape */ | |
1078 Normal | 1, /* '1' */ | |
1079 Normal | 2, /* '2' */ | |
1080 Normal | 3, /* '3' */ | |
1081 Normal | 4, /* '4' */ | |
1082 Normal | 5, /* '5' */ | |
1083 Normal | 6, /* '6' */ | |
1084 Normal | 7, /* '7' */ | |
1085 Normal | 8, /* '8' */ | |
1086 Normal | 9, /* '9' */ | |
1087 Normal | 10, /* '0' */ | |
1088 Normal | 11, /* '-' */ | |
1089 Normal | 12, /* '=' */ | |
1090 Special | 0x08, /* Backspace */ | |
1091 ModFct | 0x74, /* Tab/Backtab */ | |
1092 | |
1093 /* --------------- 10 to 1f --------------- */ | |
1094 Map | 15, /* 'q' */ | |
1095 Map | 16, /* 'w' */ | |
1096 Map | 17, /* 'e' */ | |
1097 Map | 18, /* 'r' */ | |
1098 Map | 19, /* 't' */ | |
1099 Map | 20, /* 'y' */ | |
1100 Map | 21, /* 'u' */ | |
1101 Map | 22, /* 'i' */ | |
1102 Map | 23, /* 'o' */ | |
1103 Map | 24, /* 'p' */ | |
1104 Map | 25, /* '[' */ | |
1105 Map | 26, /* ']' */ | |
1106 ModFct | 0x0d, /* Return */ | |
1107 Ignore, /* Ctrl */ | |
1108 Map | 30, /* 'a' */ | |
1109 Map | 31, /* 's' */ | |
1110 | |
1111 /* --------------- 20 to 2f --------------- */ | |
1112 Map | 32, /* 'd' */ | |
1113 Map | 33, /* 'f' */ | |
1114 Map | 34, /* 'g' */ | |
1115 Map | 35, /* 'h' */ | |
1116 Map | 36, /* 'j' */ | |
1117 Map | 37, /* 'k' */ | |
1118 Map | 38, /* 'l' */ | |
1119 Map | 39, /* ';' */ | |
1120 Map | 40, /* '\'' */ | |
1121 Map | 0, /* '`' */ | |
1122 Ignore, /* Left shift */ | |
1123 Map | 41, /* '\\' */ | |
1124 Map | 45, /* 'z' */ | |
1125 Map | 46, /* 'x' */ | |
1126 Map | 47, /* 'c' */ | |
1127 Map | 48, /* 'v' */ | |
1128 | |
1129 /* --------------- 30 to 3f --------------- */ | |
1130 Map | 49, /* 'b' */ | |
1131 Map | 50, /* 'n' */ | |
1132 Map | 51, /* 'm' */ | |
1133 Map | 52, /* ',' */ | |
1134 Map | 53, /* '.' */ | |
1135 Map | 54, /* '/' */ | |
1136 Ignore, /* Right shift */ | |
1137 Grey | 1, /* Grey * */ | |
1138 Ignore, /* Alt */ | |
1139 Normal | ' ', /* ' ' */ | |
1140 Ignore, /* Caps Lock */ | |
1141 FctKey | 0xbe, /* F1 */ | |
1142 FctKey | 0xbf, /* F2 */ | |
1143 FctKey | 0xc0, /* F3 */ | |
1144 FctKey | 0xc1, /* F4 */ | |
1145 FctKey | 0xc2, /* F5 */ | |
1146 | |
1147 /* --------------- 40 to 4f --------------- */ | |
1148 FctKey | 0xc3, /* F6 */ | |
1149 FctKey | 0xc4, /* F7 */ | |
1150 FctKey | 0xc5, /* F8 */ | |
1151 FctKey | 0xc6, /* F9 */ | |
1152 FctKey | 0xc7, /* F10 */ | |
1153 Ignore, /* Num Lock */ | |
1154 Ignore, /* Scroll Lock */ | |
1155 KeyPad | 7, /* Home */ | |
1156 KeyPad | 8, /* Up */ | |
1157 KeyPad | 9, /* Page Up */ | |
1158 Grey | 2, /* Grey - */ | |
1159 KeyPad | 4, /* Left */ | |
1160 KeyPad | 5, /* Keypad 5 */ | |
1161 KeyPad | 6, /* Right */ | |
1162 Grey | 3, /* Grey + */ | |
1163 KeyPad | 1, /* End */ | |
1164 | |
1165 /* --------------- 50 to 5f --------------- */ | |
1166 KeyPad | 2, /* Down */ | |
1167 KeyPad | 3, /* Page Down */ | |
1168 KeyPad | 0, /* Insert */ | |
1169 KeyPad | 10, /* Delete */ | |
1170 Shift | FctKey | 0xbe, /* (Shift) F1 */ | |
1171 Shift | FctKey | 0xbf, /* (Shift) F2 */ | |
1172 Shift | FctKey | 0xc0, /* (Shift) F3 */ | |
1173 Shift | FctKey | 0xc1, /* (Shift) F4 */ | |
1174 Shift | FctKey | 0xc2, /* (Shift) F5 */ | |
1175 Shift | FctKey | 0xc3, /* (Shift) F6 */ | |
1176 Shift | FctKey | 0xc4, /* (Shift) F7 */ | |
1177 Shift | FctKey | 0xc5, /* (Shift) F8 */ | |
1178 Shift | FctKey | 0xc6, /* (Shift) F9 */ | |
1179 Shift | FctKey | 0xc7, /* (Shift) F10 */ | |
1180 Ctrl | FctKey | 0xbe, /* (Ctrl) F1 */ | |
1181 Ctrl | FctKey | 0xbf, /* (Ctrl) F2 */ | |
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
1182 |
13179 | 1183 /* --------------- 60 to 6f --------------- */ |
1184 Ctrl | FctKey | 0xc0, /* (Ctrl) F3 */ | |
1185 Ctrl | FctKey | 0xc1, /* (Ctrl) F4 */ | |
1186 Ctrl | FctKey | 0xc2, /* (Ctrl) F5 */ | |
1187 Ctrl | FctKey | 0xc3, /* (Ctrl) F6 */ | |
1188 Ctrl | FctKey | 0xc4, /* (Ctrl) F7 */ | |
1189 Ctrl | FctKey | 0xc5, /* (Ctrl) F8 */ | |
1190 Ctrl | FctKey | 0xc6, /* (Ctrl) F9 */ | |
1191 Ctrl | FctKey | 0xc7, /* (Ctrl) F10 */ | |
1192 Alt | FctKey | 0xbe, /* (Alt) F1 */ | |
1193 Alt | FctKey | 0xbf, /* (Alt) F2 */ | |
1194 Alt | FctKey | 0xc0, /* (Alt) F3 */ | |
1195 Alt | FctKey | 0xc1, /* (Alt) F4 */ | |
1196 Alt | FctKey | 0xc2, /* (Alt) F5 */ | |
1197 Alt | FctKey | 0xc3, /* (Alt) F6 */ | |
1198 Alt | FctKey | 0xc4, /* (Alt) F7 */ | |
1199 Alt | FctKey | 0xc5, /* (Alt) F8 */ | |
1200 | |
1201 /* --------------- 70 to 7f --------------- */ | |
1202 Alt | FctKey | 0xc6, /* (Alt) F9 */ | |
1203 Alt | FctKey | 0xc7, /* (Alt) F10 */ | |
1204 Ctrl | FctKey | 0x6d, /* (Ctrl) Sys Rq */ | |
1205 Ctrl | KeyPad | 4, /* (Ctrl) Left */ | |
1206 Ctrl | KeyPad | 6, /* (Ctrl) Right */ | |
1207 Ctrl | KeyPad | 1, /* (Ctrl) End */ | |
1208 Ctrl | KeyPad | 3, /* (Ctrl) Page Down */ | |
1209 Ctrl | KeyPad | 7, /* (Ctrl) Home */ | |
1210 Alt | Map | 1, /* '1' */ | |
1211 Alt | Map | 2, /* '2' */ | |
1212 Alt | Map | 3, /* '3' */ | |
1213 Alt | Map | 4, /* '4' */ | |
1214 Alt | Map | 5, /* '5' */ | |
1215 Alt | Map | 6, /* '6' */ | |
1216 Alt | Map | 7, /* '7' */ | |
1217 Alt | Map | 8, /* '8' */ | |
1218 | |
1219 /* --------------- 80 to 8f --------------- */ | |
1220 Alt | Map | 9, /* '9' */ | |
1221 Alt | Map | 10, /* '0' */ | |
1222 Alt | Map | 11, /* '-' */ | |
1223 Alt | Map | 12, /* '=' */ | |
1224 Ctrl | KeyPad | 9, /* (Ctrl) Page Up */ | |
1225 FctKey | 0xc8, /* F11 */ | |
1226 FctKey | 0xc9, /* F12 */ | |
1227 Shift | FctKey | 0xc8, /* (Shift) F11 */ | |
1228 Shift | FctKey | 0xc9, /* (Shift) F12 */ | |
1229 Ctrl | FctKey | 0xc8, /* (Ctrl) F11 */ | |
1230 Ctrl | FctKey | 0xc9, /* (Ctrl) F12 */ | |
1231 Alt | FctKey | 0xc8, /* (Alt) F11 */ | |
1232 Alt | FctKey | 0xc9, /* (Alt) F12 */ | |
1233 Ctrl | KeyPad | 8, /* (Ctrl) Up */ | |
1234 Ctrl | Grey | 2, /* (Ctrl) Grey - */ | |
1235 Ctrl | KeyPad | 5, /* (Ctrl) Keypad 5 */ | |
1236 | |
1237 /* --------------- 90 to 9f --------------- */ | |
1238 Ctrl | Grey | 3, /* (Ctrl) Grey + */ | |
1239 Ctrl | KeyPad | 2, /* (Ctrl) Down */ | |
1240 Ctrl | KeyPad | 0, /* (Ctrl) Insert */ | |
1241 Ctrl | KeyPad | 10, /* (Ctrl) Delete */ | |
1242 Ctrl | FctKey | 0x09, /* (Ctrl) Tab */ | |
1243 Ctrl | Grey | 0, /* (Ctrl) Grey / */ | |
1244 Ctrl | Grey | 1, /* (Ctrl) Grey * */ | |
1245 Alt | FctKey | 0x50, /* (Alt) Home */ | |
1246 Alt | FctKey | 0x52, /* (Alt) Up */ | |
1247 Alt | FctKey | 0x55, /* (Alt) Page Up */ | |
1248 Ignore, /* NO KEY */ | |
1249 Alt | FctKey | 0x51, /* (Alt) Left */ | |
1250 Ignore, /* NO KEY */ | |
1251 Alt | FctKey | 0x53, /* (Alt) Right */ | |
1252 Ignore, /* NO KEY */ | |
1253 Alt | FctKey | 0x57, /* (Alt) End */ | |
1254 | |
1255 /* --------------- a0 to af --------------- */ | |
1256 Alt | KeyPad | 2, /* (Alt) Down */ | |
1257 Alt | KeyPad | 3, /* (Alt) Page Down */ | |
1258 Alt | KeyPad | 0, /* (Alt) Insert */ | |
1259 Alt | KeyPad | 10, /* (Alt) Delete */ | |
1260 Alt | Grey | 0, /* (Alt) Grey / */ | |
1261 Alt | FctKey | 0x09, /* (Alt) Tab */ | |
1262 Alt | Grey | 4 /* (Alt) Keypad Enter */ | |
1263 }; | |
13274 | 1264 |
13179 | 1265 /* These bit-positions corresponds to values returned by BIOS */ |
1266 #define SHIFT_P 0x0003 /* two bits! */ | |
1267 #define CTRL_P 0x0004 | |
1268 #define ALT_P 0x0008 | |
1269 #define SCRLOCK_P 0x0010 | |
1270 #define NUMLOCK_P 0x0020 | |
1271 #define CAPSLOCK_P 0x0040 | |
1272 #define ALT_GR_P 0x0800 | |
1273 #define SUPER_P 0x4000 /* pseudo */ | |
1274 #define HYPER_P 0x8000 /* pseudo */ | |
1275 | |
1276 static int | |
1277 dos_get_modifiers (keymask) | |
1278 int *keymask; | |
5503 | 1279 { |
13179 | 1280 union REGS regs; |
1281 int mask; | |
1282 int modifiers = 0; | |
1283 | |
1284 /* Calculate modifier bits */ | |
1285 regs.h.ah = extended_kbd ? 0x12 : 0x02; | |
1286 int86 (0x16, ®s, ®s); | |
1287 | |
1288 if (!extended_kbd) | |
1289 { | |
1290 mask = regs.h.al & (SHIFT_P | CTRL_P | ALT_P | | |
1291 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | |
1292 } | |
1293 else | |
1294 { | |
1295 mask = regs.h.al & (SHIFT_P | | |
1296 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | |
1297 | |
1298 /* Do not break international keyboard support. */ | |
1299 /* When Keyb.Com is loaded, the right Alt key is */ | |
1300 /* used for accessing characters like { and } */ | |
1301 if (regs.h.ah & 2) /* Left ALT pressed ? */ | |
1302 mask |= ALT_P; | |
1303 | |
1304 if ((regs.h.ah & 8) != 0) /* Right ALT pressed ? */ | |
1305 { | |
1306 mask |= ALT_GR_P; | |
1307 if (dos_hyper_key == 1) | |
1308 { | |
1309 mask |= HYPER_P; | |
1310 modifiers |= hyper_modifier; | |
1311 } | |
1312 else if (dos_super_key == 1) | |
1313 { | |
1314 mask |= SUPER_P; | |
1315 modifiers |= super_modifier; | |
1316 } | |
1317 } | |
1318 | |
1319 if (regs.h.ah & 1) /* Left CTRL pressed | |
1320 mask |= CTRL_P; | |
1321 | |
1322 if (regs.h.ah & 4) /* Right CTRL pressed ? */ | |
1323 { | |
1324 if (dos_hyper_key == 2) | |
1325 { | |
1326 mask |= HYPER_P; | |
1327 modifiers |= hyper_modifier; | |
1328 } | |
1329 else if (dos_super_key == 2) | |
1330 { | |
1331 mask |= SUPER_P; | |
1332 modifiers |= super_modifier; | |
1333 } | |
1334 else | |
1335 mask |= CTRL_P; | |
1336 } | |
1337 } | |
1338 | |
1339 if (mask & SHIFT_P) | |
1340 modifiers |= shift_modifier; | |
1341 if (mask & CTRL_P) | |
1342 modifiers |= ctrl_modifier; | |
1343 if (mask & ALT_P) | |
1344 modifiers |= meta_modifier; | |
1345 | |
1346 if (keymask) | |
1347 *keymask = mask; | |
1348 return modifiers; | |
5503 | 1349 } |
1350 | |
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1351 #define NUM_RECENT_DOSKEYS (100) |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1352 int recent_doskeys_index; /* Index for storing next element into recent_doskeys */ |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1353 int total_doskeys; /* Total number of elements stored into recent_doskeys */ |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1354 Lisp_Object recent_doskeys; /* A vector, holding the last 100 keystrokes */ |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1355 |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1356 DEFUN ("recent-doskeys", Frecent_doskeys, Srecent_doskeys, 0, 0, 0, |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1357 "Return vector of last 100 keyboard input values seen in dos_rawgetc.\n\ |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1358 Each input key receives two values in this vector: first the ASCII code,\n\ |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1359 and then the scan code.") |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1360 () |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1361 { |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1362 Lisp_Object *keys = XVECTOR (recent_doskeys)->contents; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1363 Lisp_Object val; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1364 |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1365 if (total_doskeys < NUM_RECENT_DOSKEYS) |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1366 return Fvector (total_doskeys, keys); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1367 else |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1368 { |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1369 val = Fvector (NUM_RECENT_DOSKEYS, keys); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1370 bcopy (keys + recent_doskeys_index, |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1371 XVECTOR (val)->contents, |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1372 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1373 bcopy (keys, |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1374 XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1375 recent_doskeys_index * sizeof (Lisp_Object)); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1376 return val; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1377 } |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1378 } |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1379 |
13179 | 1380 /* Get a char from keyboard. Function keys are put into the event queue. */ |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1381 |
13179 | 1382 static int |
1383 dos_rawgetc () | |
5503 | 1384 { |
13179 | 1385 struct input_event event; |
1386 union REGS regs; | |
1387 | |
1388 #ifndef HAVE_X_WINDOWS | |
13274 | 1389 SCREEN_SET_CURSOR (); |
13179 | 1390 if (!mouse_visible) mouse_on (); |
1391 #endif | |
1392 | |
1393 /* The following condition is equivalent to `kbhit ()', except that | |
1394 it uses the bios to do its job. This pleases DESQview/X. */ | |
1395 while ((regs.h.ah = extended_kbd ? 0x11 : 0x01), | |
1396 int86 (0x16, ®s, ®s), | |
1397 (regs.x.flags & 0x40) == 0) | |
5503 | 1398 { |
13179 | 1399 union REGS regs; |
1400 register unsigned char c; | |
1401 int sc, code, mask, kp_mode; | |
1402 int modifiers; | |
1403 | |
1404 regs.h.ah = extended_kbd ? 0x10 : 0x00; | |
1405 int86 (0x16, ®s, ®s); | |
1406 c = regs.h.al; | |
1407 sc = regs.h.ah; | |
5503 | 1408 |
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1409 total_doskeys += 2; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1410 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1411 = make_number (c); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1412 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1413 recent_doskeys_index = 0; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1414 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1415 = make_number (sc); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1416 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1417 recent_doskeys_index = 0; |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1418 |
13274 | 1419 modifiers = dos_get_modifiers (&mask); |
13179 | 1420 |
1421 #ifndef HAVE_X_WINDOWS | |
13274 | 1422 if (!NILP (Vdos_display_scancodes)) |
13179 | 1423 { |
14157
38606398dfa6
(dos_rawgetc): Make buf longer.
Richard M. Stallman <rms@gnu.org>
parents:
14036
diff
changeset
|
1424 char buf[11]; |
13179 | 1425 sprintf (buf, "%02x:%02x*%04x", |
1426 (unsigned) (sc&0xff), (unsigned) c, mask); | |
1427 dos_direct_output (screen_size_Y - 2, screen_size_X - 12, buf, 10); | |
1428 } | |
1429 #endif | |
5503 | 1430 |
13179 | 1431 if (sc == 0xe0) |
1432 { | |
1433 switch (c) | |
1434 { | |
1435 case 10: /* Ctrl Grey Enter */ | |
1436 code = Ctrl | Grey | 4; | |
1437 break; | |
1438 case 13: /* Grey Enter */ | |
1439 code = Grey | 4; | |
1440 break; | |
1441 case '/': /* Grey / */ | |
1442 code = Grey | 0; | |
1443 break; | |
1444 default: | |
1445 continue; | |
1446 }; | |
1447 c = 0; | |
1448 } | |
1449 else | |
1450 { | |
1451 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) | |
1452 continue; | |
1453 if ((code = ibmpc_translate_map[sc]) == Ignore) | |
1454 continue; | |
1455 } | |
1456 | |
1457 if (c == 0) | |
1458 { | |
1459 if (code & Alt) | |
1460 modifiers |= meta_modifier; | |
1461 if (code & Ctrl) | |
1462 modifiers |= ctrl_modifier; | |
1463 if (code & Shift) | |
1464 modifiers |= shift_modifier; | |
1465 } | |
1466 | |
1467 switch (code & 0xf000) | |
1468 { | |
1469 case ModFct: | |
1470 if (c && !(mask & (SHIFT_P | ALT_P | CTRL_P | HYPER_P | SUPER_P))) | |
1471 return c; | |
1472 c = 0; /* Special */ | |
1473 | |
1474 case FctKey: | |
1475 if (c != 0) | |
1476 return c; | |
1477 | |
1478 case Special: | |
1479 code |= 0xff00; | |
1480 break; | |
1481 | |
1482 case Normal: | |
1483 if (sc == 0) | |
1484 { | |
1485 if (c == 0) /* ctrl-break */ | |
1486 continue; | |
1487 return c; /* ALT-nnn */ | |
1488 } | |
1489 if (!keyboard_map_all) | |
1490 { | |
1491 if (c != ' ') | |
1492 return c; | |
1493 code = c; | |
1494 break; | |
1495 } | |
1496 | |
1497 case Map: | |
1498 if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) | |
1499 if (!keyboard_map_all) | |
1500 return c; | |
5503 | 1501 |
13179 | 1502 code &= 0xff; |
1503 if (mask & ALT_P && code <= 10 && code > 0 && dos_keypad_mode & 0x200) | |
1504 mask |= SHIFT_P; /* ALT-1 => M-! etc. */ | |
1505 | |
1506 if (mask & SHIFT_P) | |
1507 { | |
13274 | 1508 code = keyboard->shifted[code]; |
13179 | 1509 mask -= SHIFT_P; |
1510 modifiers &= ~shift_modifier; | |
1511 } | |
1512 else | |
13274 | 1513 if ((mask & ALT_GR_P) && keyboard->alt_gr && keyboard->alt_gr[code] != ' ') |
1514 code = keyboard->alt_gr[code]; | |
13179 | 1515 else |
13274 | 1516 code = keyboard->unshifted[code]; |
13179 | 1517 break; |
1518 | |
1519 case KeyPad: | |
1520 code &= 0xff; | |
1521 if (c == 0xe0) /* edit key */ | |
1522 kp_mode = 3; | |
1523 else | |
1524 if ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) /* numlock on */ | |
1525 kp_mode = dos_keypad_mode & 0x03; | |
1526 else | |
1527 kp_mode = (dos_keypad_mode >> 4) & 0x03; | |
1528 | |
1529 switch (kp_mode) | |
1530 { | |
1531 case 0: | |
1532 if (code == 10 && dos_decimal_point) | |
1533 return dos_decimal_point; | |
13274 | 1534 return keypad_translate_map[code].char_code; |
5503 | 1535 |
13179 | 1536 case 1: |
13274 | 1537 code = 0xff00 | keypad_translate_map[code].keypad_code; |
13179 | 1538 break; |
5503 | 1539 |
13179 | 1540 case 2: |
13274 | 1541 code = keypad_translate_map[code].meta_code; |
13179 | 1542 modifiers = meta_modifier; |
1543 break; | |
1544 | |
1545 case 3: | |
13274 | 1546 code = 0xff00 | keypad_translate_map[code].editkey_code; |
13179 | 1547 break; |
1548 } | |
1549 break; | |
1550 | |
1551 case Grey: | |
1552 code &= 0xff; | |
1553 kp_mode = ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) ? 0x04 : 0x40; | |
1554 if (dos_keypad_mode & kp_mode) | |
13274 | 1555 code = 0xff00 | grey_key_translate_map[code].keypad_code; |
13179 | 1556 else |
13274 | 1557 code = grey_key_translate_map[code].char_code; |
13179 | 1558 break; |
1559 } | |
1560 | |
1561 make_event: | |
1562 if (code == 0) | |
1563 continue; | |
1564 | |
1565 if (code >= 0x100) | |
1566 event.kind = non_ascii_keystroke; | |
1567 else | |
1568 event.kind = ascii_keystroke; | |
1569 event.code = code; | |
1570 event.modifiers = modifiers; | |
1571 XSETFRAME (event.frame_or_window, selected_frame); | |
1572 event.timestamp = event_timestamp (); | |
1573 kbd_buffer_store_event (&event); | |
1574 } | |
5503 | 1575 |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1576 if (have_mouse > 0) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1577 { |
13179 | 1578 int but, press, x, y, ok; |
5503 | 1579 |
13179 | 1580 /* Check for mouse movement *before* buttons. */ |
1581 mouse_check_moved (); | |
5503 | 1582 |
13179 | 1583 for (but = 0; but < NUM_MOUSE_BUTTONS; but++) |
1584 for (press = 0; press < 2; press++) | |
1585 { | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1586 int button_num = but; |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1587 |
13179 | 1588 if (press) |
1589 ok = mouse_pressed (but, &x, &y); | |
1590 else | |
1591 ok = mouse_released (but, &x, &y); | |
1592 if (ok) | |
1593 { | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1594 /* Allow a simultaneous press/release of Mouse-1 and |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1595 Mouse-2 to simulate Mouse-3 on two-button mice. */ |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1596 if (mouse_button_count == 2 && but < 2) |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1597 { |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1598 int x2, y2; /* don't clobber original coordinates */ |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1599 |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1600 /* If only one button is pressed, wait 100 msec and |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1601 check again. This way, Speedy Gonzales isn't |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1602 punished, while the slow get their chance. */ |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1603 if (press && mouse_pressed (1-but, &x2, &y2) |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1604 || !press && mouse_released (1-but, &x2, &y2)) |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1605 button_num = 2; |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1606 else |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1607 { |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1608 delay (100); |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1609 if (press && mouse_pressed (1-but, &x2, &y2) |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1610 || !press && mouse_released (1-but, &x2, &y2)) |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1611 button_num = 2; |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1612 } |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1613 } |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1614 |
13179 | 1615 event.kind = mouse_click; |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1616 event.code = button_num; |
13179 | 1617 event.modifiers = dos_get_modifiers (0) |
1618 | (press ? down_modifier : up_modifier); | |
1619 event.x = x; | |
1620 event.y = y; | |
1621 XSETFRAME (event.frame_or_window, selected_frame); | |
1622 event.timestamp = event_timestamp (); | |
1623 kbd_buffer_store_event (&event); | |
1624 } | |
1625 } | |
1626 } | |
5503 | 1627 |
13179 | 1628 return -1; |
9572 | 1629 } |
1630 | |
13179 | 1631 static int prev_get_char = -1; |
5503 | 1632 |
13179 | 1633 /* Return 1 if a key is ready to be read without suspending execution. */ |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1634 |
13179 | 1635 dos_keysns () |
5503 | 1636 { |
13179 | 1637 if (prev_get_char != -1) |
1638 return 1; | |
1639 else | |
1640 return ((prev_get_char = dos_rawgetc ()) != -1); | |
5503 | 1641 } |
1642 | |
13179 | 1643 /* Read a key. Return -1 if no key is ready. */ |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1644 |
13179 | 1645 dos_keyread () |
5503 | 1646 { |
13179 | 1647 if (prev_get_char != -1) |
8246
d48c2b01fba5
(mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents:
8194
diff
changeset
|
1648 { |
13179 | 1649 int c = prev_get_char; |
1650 prev_get_char = -1; | |
1651 return c; | |
8246
d48c2b01fba5
(mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents:
8194
diff
changeset
|
1652 } |
13179 | 1653 else |
1654 return dos_rawgetc (); | |
1655 } | |
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1656 |
9572 | 1657 #ifndef HAVE_X_WINDOWS |
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1658 /* See xterm.c for more info. */ |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1659 void |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1660 pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip) |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1661 FRAME_PTR f; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1662 register int pix_x, pix_y; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1663 register int *x, *y; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1664 void /* XRectangle */ *bounds; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1665 int noclip; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1666 { |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1667 if (bounds) abort (); |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1668 |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1669 /* Ignore clipping. */ |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1670 |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1671 *x = pix_x; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1672 *y = pix_y; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1673 } |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1674 |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1675 void |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1676 glyph_to_pixel_coords (f, x, y, pix_x, pix_y) |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1677 FRAME_PTR f; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1678 register int x, y; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1679 register int *pix_x, *pix_y; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1680 { |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1681 *pix_x = x; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1682 *pix_y = y; |
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1683 } |
9572 | 1684 |
1685 /* Simulation of X's menus. Nothing too fancy here -- just make it work | |
1686 for now. | |
1687 | |
1688 Actually, I don't know the meaning of all the parameters of the functions | |
1689 here -- I only know how they are called by xmenu.c. I could of course | |
1690 grab the nearest Xlib manual (down the hall, second-to-last door on the | |
1691 left), but I don't think it's worth the effort. */ | |
1692 | |
1693 static XMenu * | |
1694 IT_menu_create () | |
1695 { | |
1696 XMenu *menu; | |
1697 | |
1698 menu = (XMenu *) xmalloc (sizeof (XMenu)); | |
1699 menu->allocated = menu->count = menu->panecount = menu->width = 0; | |
1700 return menu; | |
1701 } | |
1702 | |
1703 /* Allocate some (more) memory for MENU ensuring that there is room for one | |
1704 for item. */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1705 |
9572 | 1706 static void |
1707 IT_menu_make_room (XMenu *menu) | |
1708 { | |
1709 if (menu->allocated == 0) | |
1710 { | |
1711 int count = menu->allocated = 10; | |
1712 menu->text = (char **) xmalloc (count * sizeof (char *)); | |
1713 menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); | |
1714 menu->panenumber = (int *) xmalloc (count * sizeof (int)); | |
1715 } | |
1716 else if (menu->allocated == menu->count) | |
1717 { | |
1718 int count = menu->allocated = menu->allocated + 10; | |
1719 menu->text | |
1720 = (char **) xrealloc (menu->text, count * sizeof (char *)); | |
1721 menu->submenu | |
1722 = (XMenu **) xrealloc (menu->submenu, count * sizeof (XMenu *)); | |
1723 menu->panenumber | |
1724 = (int *) xrealloc (menu->panenumber, count * sizeof (int)); | |
1725 } | |
1726 } | |
1727 | |
1728 /* Search the given menu structure for a given pane number. */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1729 |
9572 | 1730 static XMenu * |
1731 IT_menu_search_pane (XMenu *menu, int pane) | |
1732 { | |
1733 int i; | |
1734 XMenu *try; | |
1735 | |
1736 for (i = 0; i < menu->count; i++) | |
1737 if (menu->submenu[i]) | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1738 { |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1739 if (pane == menu->panenumber[i]) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1740 return menu->submenu[i]; |
13179 | 1741 if ((try = IT_menu_search_pane (menu->submenu[i], pane))) |
9572 | 1742 return try; |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1743 } |
9572 | 1744 return (XMenu *) 0; |
1745 } | |
1746 | |
1747 /* Determine how much screen space a given menu needs. */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1748 |
9572 | 1749 static void |
1750 IT_menu_calc_size (XMenu *menu, int *width, int *height) | |
1751 { | |
1752 int i, h2, w2, maxsubwidth, maxheight; | |
1753 | |
1754 maxsubwidth = 0; | |
1755 maxheight = menu->count; | |
1756 for (i = 0; i < menu->count; i++) | |
1757 { | |
1758 if (menu->submenu[i]) | |
1759 { | |
1760 IT_menu_calc_size (menu->submenu[i], &w2, &h2); | |
1761 if (w2 > maxsubwidth) maxsubwidth = w2; | |
1762 if (i + h2 > maxheight) maxheight = i + h2; | |
1763 } | |
1764 } | |
1765 *width = menu->width + maxsubwidth; | |
1766 *height = maxheight; | |
1767 } | |
1768 | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1769 /* Display MENU at (X,Y) using FACES. */ |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1770 |
9572 | 1771 static void |
1772 IT_menu_display (XMenu *menu, int y, int x, int *faces) | |
1773 { | |
1774 int i, j, face, width; | |
1775 GLYPH *text, *p; | |
1776 char *q; | |
1777 int mx, my; | |
1778 int enabled, mousehere; | |
1779 int row, col; | |
1780 | |
1781 width = menu->width; | |
1782 text = (GLYPH *) xmalloc ((width + 2) * sizeof (GLYPH)); | |
1783 ScreenGetCursor (&row, &col); | |
1784 mouse_get_xy (&mx, &my); | |
13179 | 1785 IT_update_begin (); |
9572 | 1786 for (i = 0; i < menu->count; i++) |
1787 { | |
13179 | 1788 IT_cursor_to (y + i, x); |
9572 | 1789 enabled |
1790 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]); | |
1791 mousehere = (y + i == my && x <= mx && mx < x + width + 2); | |
1792 face = faces[enabled + mousehere * 2]; | |
1793 p = text; | |
1794 *p++ = FAST_MAKE_GLYPH (' ', face); | |
1795 for (j = 0, q = menu->text[i]; *q; j++) | |
1796 *p++ = FAST_MAKE_GLYPH (*q++, face); | |
1797 for (; j < width; j++) | |
1798 *p++ = FAST_MAKE_GLYPH (' ', face); | |
1799 *p++ = FAST_MAKE_GLYPH (menu->submenu[i] ? 16 : ' ', face); | |
13179 | 1800 IT_write_glyphs (text, width + 2); |
9572 | 1801 } |
13179 | 1802 IT_update_end (); |
1803 IT_cursor_to (row, col); | |
9572 | 1804 xfree (text); |
1805 } | |
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1806 |
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1807 /* --------------------------- X Menu emulation ---------------------- */ |
9572 | 1808 |
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1809 /* Report availability of menus. */ |
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1810 |
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1811 int |
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1812 have_menus_p () |
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1813 { |
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1814 return 1; |
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1815 } |
13179 | 1816 |
9572 | 1817 /* Create a brand new menu structure. */ |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1818 |
9572 | 1819 XMenu * |
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1820 XMenuCreate (Display *foo1, Window foo2, char *foo3) |
9572 | 1821 { |
1822 return IT_menu_create (); | |
1823 } | |
1824 | |
1825 /* Create a new pane and place it on the outer-most level. It is not | |
1826 clear that it should be placed out there, but I don't know what else | |
1827 to do. */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1828 |
9572 | 1829 int |
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1830 XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable) |
9572 | 1831 { |
1832 int len; | |
1833 | |
1834 if (!enable) | |
1835 abort (); | |
1836 | |
1837 IT_menu_make_room (menu); | |
1838 menu->submenu[menu->count] = IT_menu_create (); | |
1839 menu->text[menu->count] = txt; | |
1840 menu->panenumber[menu->count] = ++menu->panecount; | |
1841 menu->count++; | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1842 if ((len = strlen (txt)) > menu->width) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1843 menu->width = len; |
9572 | 1844 return menu->panecount; |
1845 } | |
1846 | |
1847 /* Create a new item in a menu pane. */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1848 |
9572 | 1849 int |
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1850 XMenuAddSelection (Display *bar, XMenu *menu, int pane, |
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1851 int foo, char *txt, int enable) |
9572 | 1852 { |
1853 int len; | |
1854 | |
1855 if (pane) | |
1856 if (!(menu = IT_menu_search_pane (menu, pane))) | |
1857 return XM_FAILURE; | |
1858 IT_menu_make_room (menu); | |
1859 menu->submenu[menu->count] = (XMenu *) 0; | |
1860 menu->text[menu->count] = txt; | |
1861 menu->panenumber[menu->count] = enable; | |
1862 menu->count++; | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1863 if ((len = strlen (txt)) > menu->width) |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1864 menu->width = len; |
9572 | 1865 return XM_SUCCESS; |
1866 } | |
1867 | |
1868 /* Decide where the menu would be placed if requested at (X,Y). */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1869 |
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1870 void |
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1871 XMenuLocate (Display *foo0, XMenu *menu, int foo1, int foo2, int x, int y, |
9572 | 1872 int *ulx, int *uly, int *width, int *height) |
1873 { | |
13714
45e71ea63d71
(XMenuActivate): Display the menu pane title.
Karl Heuer <kwzh@gnu.org>
parents:
13657
diff
changeset
|
1874 IT_menu_calc_size (menu, width, height); |
9572 | 1875 *ulx = x + 1; |
1876 *uly = y; | |
1877 *width += 2; | |
1878 } | |
1879 | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1880 struct IT_menu_state |
9572 | 1881 { |
1882 void *screen_behind; | |
1883 XMenu *menu; | |
1884 int pane; | |
1885 int x, y; | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1886 }; |
9572 | 1887 |
1888 | |
1889 /* Display menu, wait for user's response, and return that response. */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1890 |
9572 | 1891 int |
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1892 XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx, |
9572 | 1893 int x0, int y0, unsigned ButtonMask, char **txt) |
1894 { | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1895 struct IT_menu_state *state; |
9572 | 1896 int statecount; |
1897 int x, y, i, b; | |
1898 int screensize; | |
1899 int faces[4], selectface; | |
1900 int leave, result, onepane; | |
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1901 int title_faces[4]; /* face to display the menu title */ |
9572 | 1902 |
1903 /* Just in case we got here without a mouse present... */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1904 if (have_mouse <= 0) |
9572 | 1905 return XM_IA_SELECT; |
1906 | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1907 state = alloca (menu->panecount * sizeof (struct IT_menu_state)); |
13179 | 1908 screensize = screen_size * 2; |
9572 | 1909 faces[0] |
1910 = compute_glyph_face (&the_only_frame, | |
1911 face_name_id_number | |
1912 (&the_only_frame, | |
1913 intern ("msdos-menu-passive-face")), | |
1914 0); | |
1915 faces[1] | |
1916 = compute_glyph_face (&the_only_frame, | |
1917 face_name_id_number | |
1918 (&the_only_frame, | |
1919 intern ("msdos-menu-active-face")), | |
1920 0); | |
1921 selectface | |
1922 = face_name_id_number (&the_only_frame, intern ("msdos-menu-select-face")); | |
1923 faces[2] = compute_glyph_face (&the_only_frame, selectface, faces[0]); | |
1924 faces[3] = compute_glyph_face (&the_only_frame, selectface, faces[1]); | |
1925 | |
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1926 /* Make sure the menu title is always displayed with |
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1927 `msdos-menu-active-face', no matter where the mouse pointer is. */ |
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1928 for (i = 0; i < 4; i++) |
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1929 title_faces[i] = faces[3]; |
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1930 |
9572 | 1931 statecount = 1; |
1932 state[0].menu = menu; | |
1933 mouse_off (); | |
1934 ScreenRetrieve (state[0].screen_behind = xmalloc (screensize)); | |
13714
45e71ea63d71
(XMenuActivate): Display the menu pane title.
Karl Heuer <kwzh@gnu.org>
parents:
13657
diff
changeset
|
1935 |
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1936 IT_menu_display (menu, y0 - 1, x0 - 1, title_faces); /* display menu title */ |
9572 | 1937 if ((onepane = menu->count == 1 && menu->submenu[0])) |
1938 { | |
1939 menu->width = menu->submenu[0]->width; | |
1940 state[0].menu = menu->submenu[0]; | |
1941 } | |
1942 else | |
1943 { | |
1944 state[0].menu = menu; | |
1945 } | |
1946 state[0].x = x0 - 1; | |
1947 state[0].y = y0; | |
1948 state[0].pane = onepane; | |
1949 | |
1950 mouse_last_x = -1; /* A hack that forces display. */ | |
1951 leave = 0; | |
1952 while (!leave) | |
1953 { | |
13179 | 1954 if (!mouse_visible) mouse_on (); |
9572 | 1955 mouse_check_moved (); |
12573
f8193b0f95ed
(mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents:
11124
diff
changeset
|
1956 if (selected_frame->mouse_moved) |
9572 | 1957 { |
12573
f8193b0f95ed
(mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents:
11124
diff
changeset
|
1958 selected_frame->mouse_moved = 0; |
9572 | 1959 result = XM_IA_SELECT; |
1960 mouse_get_xy (&x, &y); | |
1961 for (i = 0; i < statecount; i++) | |
1962 if (state[i].x <= x && x < state[i].x + state[i].menu->width + 2) | |
1963 { | |
1964 int dy = y - state[i].y; | |
1965 if (0 <= dy && dy < state[i].menu->count) | |
1966 { | |
1967 if (!state[i].menu->submenu[dy]) | |
1968 if (state[i].menu->panenumber[dy]) | |
1969 result = XM_SUCCESS; | |
1970 else | |
1971 result = XM_IA_SELECT; | |
1972 *pane = state[i].pane - 1; | |
1973 *selidx = dy; | |
14036 | 1974 /* We hit some part of a menu, so drop extra menus that |
9572 | 1975 have been opened. That does not include an open and |
1976 active submenu. */ | |
1977 if (i != statecount - 2 | |
1978 || state[i].menu->submenu[dy] != state[i+1].menu) | |
1979 while (i != statecount - 1) | |
1980 { | |
1981 statecount--; | |
1982 mouse_off (); | |
1983 ScreenUpdate (state[statecount].screen_behind); | |
1984 xfree (state[statecount].screen_behind); | |
1985 } | |
1986 if (i == statecount - 1 && state[i].menu->submenu[dy]) | |
1987 { | |
1988 IT_menu_display (state[i].menu, | |
1989 state[i].y, | |
1990 state[i].x, | |
1991 faces); | |
1992 state[statecount].menu = state[i].menu->submenu[dy]; | |
1993 state[statecount].pane = state[i].menu->panenumber[dy]; | |
1994 mouse_off (); | |
1995 ScreenRetrieve (state[statecount].screen_behind | |
1996 = xmalloc (screensize)); | |
1997 state[statecount].x | |
1998 = state[i].x + state[i].menu->width + 2; | |
1999 state[statecount].y = y; | |
2000 statecount++; | |
2001 } | |
2002 } | |
2003 } | |
2004 IT_menu_display (state[statecount - 1].menu, | |
2005 state[statecount - 1].y, | |
2006 state[statecount - 1].x, | |
2007 faces); | |
2008 } | |
2009 for (b = 0; b < mouse_button_count; b++) | |
2010 { | |
2011 (void) mouse_pressed (b, &x, &y); | |
2012 if (mouse_released (b, &x, &y)) | |
2013 leave = 1; | |
2014 } | |
2015 } | |
2016 | |
2017 mouse_off (); | |
2018 ScreenUpdate (state[0].screen_behind); | |
2019 while (statecount--) | |
2020 xfree (state[statecount].screen_behind); | |
2021 return result; | |
2022 } | |
2023 | |
2024 /* Dispose of a menu. */ | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2025 |
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2026 void |
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2027 XMenuDestroy (Display *foo, XMenu *menu) |
9572 | 2028 { |
2029 int i; | |
2030 if (menu->allocated) | |
2031 { | |
2032 for (i = 0; i < menu->count; i++) | |
2033 if (menu->submenu[i]) | |
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2034 XMenuDestroy (foo, menu->submenu[i]); |
9572 | 2035 xfree (menu->text); |
2036 xfree (menu->submenu); | |
2037 xfree (menu->panenumber); | |
2038 } | |
2039 xfree (menu); | |
2040 } | |
2041 | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2042 int |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2043 x_pixel_width (struct frame *f) |
9572 | 2044 { |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2045 return FRAME_WIDTH (f); |
9572 | 2046 } |
2047 | |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2048 int |
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2049 x_pixel_height (struct frame *f) |
9572 | 2050 { |
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2051 return FRAME_HEIGHT (f); |
9572 | 2052 } |
2053 #endif /* !HAVE_X_WINDOWS */ | |
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2054 |
13179 | 2055 /* ----------------------- DOS / UNIX conversion --------------------- */ |
2056 | |
2057 /* Destructively turn backslashes into slashes. */ | |
2058 | |
2059 void | |
2060 dostounix_filename (p) | |
2061 register char *p; | |
2062 { | |
2063 while (*p) | |
2064 { | |
2065 if (*p == '\\') | |
2066 *p = '/'; | |
2067 p++; | |
2068 } | |
2069 } | |
2070 | |
2071 /* Destructively turn slashes into backslashes. */ | |
2072 | |
2073 void | |
2074 unixtodos_filename (p) | |
2075 register char *p; | |
2076 { | |
2077 while (*p) | |
2078 { | |
2079 if (*p == '/') | |
2080 *p = '\\'; | |
2081 p++; | |
2082 } | |
2083 } | |
2084 | |
2085 /* Get the default directory for a given drive. 0=def, 1=A, 2=B, ... */ | |
2086 | |
2087 int | |
2088 getdefdir (drive, dst) | |
2089 int drive; | |
2090 char *dst; | |
2091 { | |
2092 union REGS regs; | |
2093 | |
2094 *dst++ = '/'; | |
2095 regs.h.dl = drive; | |
15077
e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
Richard M. Stallman <rms@gnu.org>
parents:
15033
diff
changeset
|
2096 #if __DJGPP__ > 1 |
e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
Richard M. Stallman <rms@gnu.org>
parents:
15033
diff
changeset
|
2097 /* regs.x.si can be 16 or 32 bits, depending on whether _NAIVE_DOS_REGS |
e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
Richard M. Stallman <rms@gnu.org>
parents:
15033
diff
changeset
|
2098 or _BORLAND_DOS_REGS have or haven't been defined. We should work |
e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
Richard M. Stallman <rms@gnu.org>
parents:
15033
diff
changeset
|
2099 with either, so use regs.d.esi which is always 32 bit-wide. */ |
e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
Richard M. Stallman <rms@gnu.org>
parents:
15033
diff
changeset
|
2100 regs.d.esi = (int) dst; |
e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
Richard M. Stallman <rms@gnu.org>
parents:
15033
diff
changeset
|
2101 #else |
13179 | 2102 regs.x.si = (int) dst; |
15077
e6464ccca756
(getdefdir) [DJGPP > 1]: Use 32-bit ESI to pass buffer
Richard M. Stallman <rms@gnu.org>
parents:
15033
diff
changeset
|
2103 #endif |
13179 | 2104 regs.h.ah = 0x47; |
2105 intdos (®s, ®s); | |
2106 return !regs.x.cflag; | |
2107 } | |
2108 | |
2109 /* Remove all CR's that are followed by a LF. */ | |
2110 | |
2111 int | |
2112 crlf_to_lf (n, buf) | |
2113 register int n; | |
2114 register unsigned char *buf; | |
2115 { | |
2116 unsigned char *np = buf; | |
2117 unsigned char *startp = buf; | |
2118 unsigned char *endp = buf + n; | |
2119 unsigned char c; | |
2120 | |
2121 if (n == 0) | |
2122 return n; | |
2123 while (buf < endp - 1) | |
2124 { | |
2125 if (*buf == 0x0d) | |
2126 { | |
2127 if (*(++buf) != 0x0a) | |
2128 *np++ = 0x0d; | |
2129 } | |
2130 else | |
2131 *np++ = *buf++; | |
2132 } | |
2133 if (buf < endp) | |
2134 *np++ = *buf++; | |
2135 return np - startp; | |
2136 } | |
14999 | 2137 |
2138 #if defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 0 | |
2139 | |
2140 /* In DJGPP v2.0, library `write' can call `malloc', which might | |
2141 cause relocation of the buffer whose address we get in ADDR. | |
2142 Here is a version of `write' that avoids calling `malloc', | |
2143 to serve us until such time as the library is fixed. | |
2144 Actually, what we define here is called `__write', because | |
2145 `write' is a stub that just jmp's to `__write' (to be | |
2146 POSIXLY-correct with respect to the global name-space). */ | |
2147 | |
2148 #include <io.h> /* for _write */ | |
2149 #include <libc/dosio.h> /* for __file_handle_modes[] */ | |
2150 | |
2151 static char xbuf[64 * 1024]; /* DOS cannot write more in one chunk */ | |
2152 | |
2153 #define XBUF_END (xbuf + sizeof (xbuf) - 1) | |
2154 | |
2155 int | |
2156 __write (int handle, const void *buffer, size_t count) | |
2157 { | |
2158 if (count == 0) | |
2159 return 0; | |
2160 | |
2161 if(__file_handle_modes[handle] & O_BINARY) | |
2162 return _write (handle, buffer, count); | |
2163 else | |
2164 { | |
2165 char *xbp = xbuf; | |
2166 const char *bp = buffer; | |
2167 int total_written = 0; | |
2168 int nmoved = 0, ncr = 0; | |
2169 | |
2170 while (count) | |
2171 { | |
2172 /* The next test makes sure there's space for at least 2 more | |
2173 characters in xbuf[], so both CR and LF can be put there. */ | |
2174 if (xbp < XBUF_END) | |
2175 { | |
2176 if (*bp == '\n') | |
2177 { | |
2178 ncr++; | |
2179 *xbp++ = '\r'; | |
2180 } | |
2181 *xbp++ = *bp++; | |
2182 nmoved++; | |
2183 count--; | |
2184 } | |
2185 if (xbp >= XBUF_END || !count) | |
2186 { | |
2187 size_t to_write = nmoved + ncr; | |
2188 int written = _write (handle, xbuf, to_write); | |
2189 | |
2190 if (written == -1) | |
2191 return -1; | |
2192 else | |
2193 total_written += nmoved; /* CRs aren't counted in ret value */ | |
2194 | |
2195 /* If some, but not all were written (disk full?), return | |
2196 an estimate of the total written bytes not counting CRs. */ | |
2197 if (written < to_write) | |
2198 return total_written - (to_write - written) * nmoved/to_write; | |
2199 | |
2200 nmoved = 0; | |
2201 ncr = 0; | |
2202 xbp = xbuf; | |
2203 } | |
2204 } | |
2205 return total_written; | |
2206 } | |
2207 } | |
2208 | |
2209 #endif /* __DJGPP__ == 2 && __DJGPP_MINOR__ == 0 */ | |
2210 | |
2211 | |
13179 | 2212 |
2213 /* The Emacs root directory as determined by init_environment. */ | |
2214 | |
2215 static char emacsroot[MAXPATHLEN]; | |
2216 | |
2217 char * | |
2218 rootrelativepath (rel) | |
2219 char *rel; | |
2220 { | |
2221 static char result[MAXPATHLEN + 10]; | |
2222 | |
2223 strcpy (result, emacsroot); | |
2224 strcat (result, "/"); | |
2225 strcat (result, rel); | |
2226 return result; | |
2227 } | |
2228 | |
2229 /* Define a lot of environment variables if not already defined. Don't | |
2230 remove anything unless you know what you're doing -- lots of code will | |
2231 break if one or more of these are missing. */ | |
2232 | |
2233 void | |
2234 init_environment (argc, argv, skip_args) | |
2235 int argc; | |
2236 char **argv; | |
2237 int skip_args; | |
2238 { | |
2239 char *s, *t, *root; | |
2240 int len; | |
2241 | |
2242 /* Find our root from argv[0]. Assuming argv[0] is, say, | |
2243 "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */ | |
2244 root = alloca (MAXPATHLEN + 20); | |
2245 _fixpath (argv[0], root); | |
2246 strlwr (root); | |
2247 len = strlen (root); | |
2248 while (len > 0 && root[len] != '/' && root[len] != ':') | |
2249 len--; | |
2250 root[len] = '\0'; | |
2251 if (len > 4 && strcmp (root + len - 4, "/bin") == 0) | |
2252 root[len - 4] = '\0'; | |
2253 else | |
2254 strcpy (root, "c:/emacs"); /* Only under debuggers, I think. */ | |
2255 len = strlen (root); | |
2256 strcpy (emacsroot, root); | |
2257 | |
2258 /* We default HOME to our root. */ | |
2259 setenv ("HOME", root, 0); | |
2260 | |
2261 /* We default EMACSPATH to root + "/bin". */ | |
2262 strcpy (root + len, "/bin"); | |
2263 setenv ("EMACSPATH", root, 0); | |
2264 | |
2265 /* I don't expect anybody to ever use other terminals so the internal | |
2266 terminal is the default. */ | |
2267 setenv ("TERM", "internal", 0); | |
2268 | |
2269 #ifdef HAVE_X_WINDOWS | |
2270 /* Emacs expects DISPLAY to be set. */ | |
2271 setenv ("DISPLAY", "unix:0.0", 0); | |
2272 #endif | |
2273 | |
2274 /* SHELL is a bit tricky -- COMSPEC is the closest we come, but we must | |
2275 downcase it and mirror the backslashes. */ | |
2276 s = getenv ("COMSPEC"); | |
2277 if (!s) s = "c:/command.com"; | |
2278 t = alloca (strlen (s) + 1); | |
2279 strcpy (t, s); | |
2280 strlwr (t); | |
2281 dostounix_filename (t); | |
2282 setenv ("SHELL", t, 0); | |
2283 | |
2284 /* PATH is also downcased and backslashes mirrored. */ | |
2285 s = getenv ("PATH"); | |
2286 if (!s) s = ""; | |
2287 t = alloca (strlen (s) + 3); | |
2288 /* Current directory is always considered part of MsDos's path but it is | |
2289 not normally mentioned. Now it is. */ | |
2290 strcat (strcpy (t, ".;"), s); | |
2291 strlwr (t); | |
2292 dostounix_filename (t); /* Not a single file name, but this should work. */ | |
2293 setenv ("PATH", t, 1); | |
2294 | |
2295 /* In some sense all dos users have root privileges, so... */ | |
2296 setenv ("USER", "root", 0); | |
2297 setenv ("NAME", getenv ("USER"), 0); | |
2298 | |
2299 /* Time zone determined from country code. To make this possible, the | |
2300 country code may not span more than one time zone. In other words, | |
2301 in the USA, you lose. */ | |
13274 | 2302 if (!getenv ("TZ")) |
13179 | 2303 switch (dos_country_code) |
2304 { | |
2305 case 31: /* Belgium */ | |
2306 case 32: /* The Netherlands */ | |
2307 case 33: /* France */ | |
2308 case 34: /* Spain */ | |
2309 case 36: /* Hungary */ | |
2310 case 38: /* Yugoslavia (or what's left of it?) */ | |
2311 case 39: /* Italy */ | |
2312 case 41: /* Switzerland */ | |
2313 case 42: /* Tjekia */ | |
2314 case 45: /* Denmark */ | |
2315 case 46: /* Sweden */ | |
2316 case 47: /* Norway */ | |
2317 case 48: /* Poland */ | |
2318 case 49: /* Germany */ | |
2319 /* Daylight saving from last Sunday in March to last Sunday in | |
2320 September, both at 2AM. */ | |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2321 setenv ("TZ", "MET-01METDST-02,M3.5.0/02:00,M9.5.0/02:00", 0); |
13179 | 2322 break; |
2323 case 44: /* United Kingdom */ | |
2324 case 351: /* Portugal */ | |
2325 case 354: /* Iceland */ | |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2326 setenv ("TZ", "GMT+00", 0); |
13179 | 2327 break; |
2328 case 81: /* Japan */ | |
2329 case 82: /* Korea */ | |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2330 setenv ("TZ", "JST-09", 0); |
13179 | 2331 break; |
2332 case 90: /* Turkey */ | |
2333 case 358: /* Finland */ | |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2334 setenv ("TZ", "EET-02", 0); |
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2335 break; |
13179 | 2336 case 972: /* Israel */ |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2337 /* This is an approximation. (For exact rules, use the |
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2338 `zoneinfo/israel' file which comes with DJGPP, but you need |
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2339 to install it in `/usr/share/zoneinfo/' directory first.) */ |
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2340 setenv ("TZ", "IST-02IDT-03,M4.1.6/00:00,M9.5.6/01:00", 0); |
13179 | 2341 break; |
2342 } | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2343 tzset (); |
13179 | 2344 } |
2345 | |
2346 | |
2347 | |
2348 static int break_stat; /* BREAK check mode status. */ | |
2349 static int stdin_stat; /* stdin IOCTL status. */ | |
2350 | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2351 #if __DJGPP__ < 2 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2352 |
13179 | 2353 /* These must be global. */ |
2354 static _go32_dpmi_seginfo ctrl_break_vector; | |
2355 static _go32_dpmi_registers ctrl_break_regs; | |
2356 static int ctrlbreakinstalled = 0; | |
2357 | |
2358 /* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */ | |
2359 | |
2360 void | |
2361 ctrl_break_func (regs) | |
2362 _go32_dpmi_registers *regs; | |
2363 { | |
2364 Vquit_flag = Qt; | |
2365 } | |
2366 | |
2367 void | |
2368 install_ctrl_break_check () | |
2369 { | |
2370 if (!ctrlbreakinstalled) | |
2371 { | |
2372 /* Don't press Ctrl-Break if you don't have either DPMI or Emacs | |
2373 was compiler with Djgpp 1.11 maintenance level 5 or later! */ | |
2374 ctrlbreakinstalled = 1; | |
2375 ctrl_break_vector.pm_offset = (int) ctrl_break_func; | |
2376 _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector, | |
2377 &ctrl_break_regs); | |
2378 _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector); | |
2379 } | |
2380 } | |
2381 | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2382 #endif /* __DJGPP__ < 2 */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2383 |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2384 /* Turn off Dos' Ctrl-C checking and inhibit interpretation of |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2385 control chars by DOS. Determine the keyboard type. */ |
13179 | 2386 |
2387 int | |
2388 dos_ttraw () | |
2389 { | |
2390 union REGS inregs, outregs; | |
2391 static int first_time = 1; | |
2392 | |
2393 break_stat = getcbrk (); | |
2394 setcbrk (0); | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2395 #if __DJGPP__ < 2 |
13179 | 2396 install_ctrl_break_check (); |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2397 #endif |
13179 | 2398 |
2399 if (first_time) | |
2400 { | |
2401 inregs.h.ah = 0xc0; | |
2402 int86 (0x15, &inregs, &outregs); | |
2403 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0); | |
2404 | |
2405 have_mouse = 0; | |
2406 | |
2407 if (internal_terminal | |
2408 #ifdef HAVE_X_WINDOWS | |
2409 && inhibit_window_system | |
2410 #endif | |
2411 ) | |
2412 { | |
2413 inregs.x.ax = 0x0021; | |
2414 int86 (0x33, &inregs, &outregs); | |
2415 have_mouse = (outregs.x.ax & 0xffff) == 0xffff; | |
2416 if (!have_mouse) | |
2417 { | |
2418 /* Reportedly, the above doesn't work for some mouse drivers. There | |
2419 is an additional detection method that should work, but might be | |
2420 a little slower. Use that as an alternative. */ | |
2421 inregs.x.ax = 0x0000; | |
2422 int86 (0x33, &inregs, &outregs); | |
2423 have_mouse = (outregs.x.ax & 0xffff) == 0xffff; | |
2424 } | |
2425 | |
2426 if (have_mouse) | |
2427 { | |
2428 have_mouse = 1; /* enable mouse */ | |
2429 mouse_visible = 0; | |
2430 | |
2431 if (outregs.x.bx == 3) | |
2432 { | |
2433 mouse_button_count = 3; | |
2434 mouse_button_translate[0] = 0; /* Left */ | |
2435 mouse_button_translate[1] = 2; /* Middle */ | |
2436 mouse_button_translate[2] = 1; /* Right */ | |
2437 } | |
2438 else | |
2439 { | |
2440 mouse_button_count = 2; | |
2441 mouse_button_translate[0] = 0; | |
2442 mouse_button_translate[1] = 1; | |
2443 } | |
2444 mouse_position_hook = &mouse_get_pos; | |
2445 mouse_init (); | |
2446 } | |
2447 } | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2448 |
13179 | 2449 first_time = 0; |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2450 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2451 #if __DJGPP__ >= 2 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2452 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2453 stdin_stat = setmode (fileno (stdin), O_BINARY); |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2454 return (stdin_stat != -1); |
13179 | 2455 } |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2456 else |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2457 return (setmode (fileno (stdin), O_BINARY) != -1); |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2458 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2459 #else /* __DJGPP__ < 2 */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2460 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2461 } |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2462 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2463 /* I think it is wrong to overwrite `stdin_stat' every time |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2464 but the first one this function is called, but I don't |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2465 want to change the way it used to work in v1.x.--EZ */ |
13179 | 2466 |
2467 inregs.x.ax = 0x4400; /* Get IOCTL status. */ | |
2468 inregs.x.bx = 0x00; /* 0 = stdin. */ | |
2469 intdos (&inregs, &outregs); | |
2470 stdin_stat = outregs.h.dl; | |
2471 | |
2472 inregs.x.dx = stdin_stat | 0x0020; /* raw mode */ | |
2473 inregs.x.ax = 0x4401; /* Set IOCTL status */ | |
2474 intdos (&inregs, &outregs); | |
2475 return !outregs.x.cflag; | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2476 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2477 #endif /* __DJGPP__ < 2 */ |
13179 | 2478 } |
2479 | |
2480 /* Restore status of standard input and Ctrl-C checking. */ | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2481 |
13179 | 2482 int |
2483 dos_ttcooked () | |
2484 { | |
2485 union REGS inregs, outregs; | |
2486 | |
2487 setcbrk (break_stat); | |
2488 mouse_off (); | |
2489 | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2490 #if __DJGPP__ >= 2 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2491 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2492 return (setmode (fileno (stdin), stdin_stat) != -1); |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2493 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2494 #else /* not __DJGPP__ >= 2 */ |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2495 |
13179 | 2496 inregs.x.ax = 0x4401; /* Set IOCTL status. */ |
2497 inregs.x.bx = 0x00; /* 0 = stdin. */ | |
2498 inregs.x.dx = stdin_stat; | |
2499 intdos (&inregs, &outregs); | |
2500 return !outregs.x.cflag; | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2501 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2502 #endif /* not __DJGPP__ >= 2 */ |
13179 | 2503 } |
2504 | |
2505 | |
2506 /* Run command as specified by ARGV in directory DIR. | |
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2507 The command is run with input from TEMPIN, output to |
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2508 file TEMPOUT and stderr to TEMPERR. */ |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2509 |
13179 | 2510 int |
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2511 run_msdos_command (argv, dir, tempin, tempout, temperr) |
13179 | 2512 unsigned char **argv; |
2513 Lisp_Object dir; | |
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2514 int tempin, tempout, temperr; |
13179 | 2515 { |
2516 char *saveargv1, *saveargv2, **envv; | |
2517 char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ | |
2518 int msshell, result = -1; | |
2519 int in, out, inbak, outbak, errbak; | |
2520 int x, y; | |
2521 Lisp_Object cmd; | |
2522 | |
2523 /* Get current directory as MSDOS cwd is not per-process. */ | |
2524 getwd (oldwd); | |
2525 | |
2526 cmd = Ffile_name_nondirectory (build_string (argv[0])); | |
2527 msshell = !NILP (Fmember (cmd, Fsymbol_value (intern ("msdos-shells")))) | |
2528 && !strcmp ("-c", argv[1]); | |
2529 if (msshell) | |
2530 { | |
2531 saveargv1 = argv[1]; | |
2532 saveargv2 = argv[2]; | |
2533 argv[1] = "/c"; | |
2534 if (argv[2]) | |
2535 { | |
2536 char *p = alloca (strlen (argv[2]) + 1); | |
2537 | |
2538 strcpy (argv[2] = p, saveargv2); | |
2539 while (*p && isspace (*p)) | |
2540 p++; | |
2541 while (*p && !isspace (*p)) | |
2542 if (*p == '/') | |
2543 *p++ = '\\'; | |
2544 else | |
2545 p++; | |
2546 } | |
2547 } | |
2548 | |
2549 /* Build the environment array. */ | |
2550 { | |
2551 extern Lisp_Object Vprocess_environment; | |
2552 Lisp_Object tmp, lst; | |
2553 int i, len; | |
2554 | |
2555 lst = Vprocess_environment; | |
2556 len = XFASTINT (Flength (lst)); | |
2557 | |
2558 envv = alloca ((len + 1) * sizeof (char *)); | |
2559 for (i = 0; i < len; i++) | |
2560 { | |
2561 tmp = Fcar (lst); | |
2562 lst = Fcdr (lst); | |
2563 CHECK_STRING (tmp, 0); | |
2564 envv[i] = alloca (XSTRING (tmp)->size + 1); | |
2565 strcpy (envv[i], XSTRING (tmp)->data); | |
2566 } | |
2567 envv[len] = (char *) 0; | |
2568 } | |
2569 | |
2570 if (STRINGP (dir)) | |
2571 chdir (XSTRING (dir)->data); | |
2572 inbak = dup (0); | |
2573 outbak = dup (1); | |
2574 errbak = dup (2); | |
2575 if (inbak < 0 || outbak < 0 || errbak < 0) | |
2576 goto done; /* Allocation might fail due to lack of descriptors. */ | |
2577 | |
2578 if (have_mouse > 0) | |
2579 mouse_get_xy (&x, &y); | |
2580 | |
2581 dos_ttcooked (); /* do it here while 0 = stdin */ | |
2582 | |
2583 dup2 (tempin, 0); | |
2584 dup2 (tempout, 1); | |
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2585 dup2 (temperr, 2); |
13179 | 2586 |
2587 result = spawnve (P_WAIT, argv[0], argv, envv); | |
2588 | |
2589 dup2 (inbak, 0); | |
2590 dup2 (outbak, 1); | |
2591 dup2 (errbak, 2); | |
2592 close (inbak); | |
2593 close (outbak); | |
2594 close (errbak); | |
2595 | |
13274 | 2596 dos_ttraw (); |
13179 | 2597 if (have_mouse > 0) |
2598 { | |
2599 mouse_init (); | |
2600 mouse_moveto (x, y); | |
2601 } | |
2602 | |
2603 done: | |
2604 chdir (oldwd); | |
2605 if (msshell) | |
2606 { | |
2607 argv[1] = saveargv1; | |
2608 argv[2] = saveargv2; | |
2609 } | |
2610 return result; | |
2611 } | |
2612 | |
2613 croak (badfunc) | |
2614 char *badfunc; | |
2615 { | |
2616 fprintf (stderr, "%s not yet implemented\r\n", badfunc); | |
2617 reset_sys_modes (); | |
2618 exit (1); | |
2619 } | |
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2620 |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2621 #if __DJGPP__ < 2 |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2622 |
13179 | 2623 /* ------------------------- Compatibility functions ------------------- |
2624 * gethostname | |
2625 * gettimeofday | |
2626 */ | |
2627 | |
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2628 /* Hostnames for a pc are not really funny, |
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2629 but they are used in change log so we emulate the best we can. */ |
13179 | 2630 |
2631 gethostname (p, size) | |
2632 char *p; | |
2633 int size; | |
2634 { | |
2635 char *q = egetenv ("HOSTNAME"); | |
2636 | |
2637 if (!q) q = "pc"; | |
2638 strcpy (p, q); | |
2639 return 0; | |
2640 } | |
2641 | |
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2642 /* When time zones are set from Ms-Dos too many C-libraries are playing |
13179 | 2643 tricks with time values. We solve this by defining our own version |
2644 of `gettimeofday' bypassing GO32. Our version needs to be initialized | |
2645 once and after each call to `tzset' with TZ changed. That is | |
2646 accomplished by aliasing tzset to init_gettimeofday. */ | |
2647 | |
2648 static struct tm time_rec; | |
2649 | |
2650 int | |
2651 gettimeofday (struct timeval *tp, struct timezone *tzp) | |
2652 { | |
2653 if (tp) | |
2654 { | |
2655 struct time t; | |
2656 struct tm tm; | |
2657 | |
2658 gettime (&t); | |
2659 if (t.ti_hour < time_rec.tm_hour) /* midnight wrap */ | |
2660 { | |
2661 struct date d; | |
2662 getdate (&d); | |
2663 time_rec.tm_year = d.da_year - 1900; | |
2664 time_rec.tm_mon = d.da_mon - 1; | |
2665 time_rec.tm_mday = d.da_day; | |
2666 } | |
2667 | |
2668 time_rec.tm_hour = t.ti_hour; | |
2669 time_rec.tm_min = t.ti_min; | |
2670 time_rec.tm_sec = t.ti_sec; | |
2671 | |
2672 tm = time_rec; | |
2673 tm.tm_gmtoff = dos_timezone_offset; | |
2674 | |
2675 tp->tv_sec = mktime (&tm); /* may modify tm */ | |
2676 tp->tv_usec = t.ti_hund * (1000000 / 100); | |
2677 } | |
2678 /* Ignore tzp; it's obsolescent. */ | |
2679 return 0; | |
2680 } | |
2681 | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2682 #endif /* __DJGPP__ < 2 */ |
13179 | 2683 |
2684 /* | |
2685 * A list of unimplemented functions that we silently ignore. | |
2686 */ | |
2687 | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2688 #if __DJGPP__ < 2 |
13179 | 2689 unsigned alarm (s) unsigned s; {} |
2690 fork () { return 0; } | |
2691 int kill (x, y) int x, y; { return -1; } | |
2692 nice (p) int p; {} | |
2693 void volatile pause () {} | |
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2694 sigsetmask (x) int x; { return 0; } |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2695 #endif |
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2696 |
13179 | 2697 request_sigio () {} |
2698 setpgrp () {return 0; } | |
2699 setpriority (x,y,z) int x,y,z; { return 0; } | |
14262
ef10a42c21f4
(sigblock): New (dummy) function.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2700 sigblock (mask) int mask; { return 0; } |
13179 | 2701 unrequest_sigio () {} |
2702 | |
2703 #ifndef HAVE_SELECT | |
2704 #include "sysselect.h" | |
2705 | |
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2706 #ifndef EMACS_TIME_ZERO_OR_NEG_P |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2707 #define EMACS_TIME_ZERO_OR_NEG_P(time) \ |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2708 ((long)(time).tv_sec < 0 \ |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2709 || ((time).tv_sec == 0 \ |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2710 && (long)(time).tv_usec <= 0)) |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2711 #endif |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2712 |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2713 |
13179 | 2714 /* Only event queue is checked. */ |
14999 | 2715 /* We don't have to call timer_check here |
2716 because wait_reading_process_input takes care of that. */ | |
13179 | 2717 int |
2718 sys_select (nfds, rfds, wfds, efds, timeout) | |
2719 int nfds; | |
2720 SELECT_TYPE *rfds, *wfds, *efds; | |
2721 EMACS_TIME *timeout; | |
2722 { | |
2723 int check_input; | |
2724 struct time t; | |
2725 | |
2726 check_input = 0; | |
2727 if (rfds) | |
2728 { | |
2729 check_input = FD_ISSET (0, rfds); | |
2730 FD_ZERO (rfds); | |
2731 } | |
2732 if (wfds) | |
2733 FD_ZERO (wfds); | |
2734 if (efds) | |
2735 FD_ZERO (efds); | |
2736 | |
2737 if (nfds != 1) | |
2738 abort (); | |
2739 | |
2740 /* If we are looking only for the terminal, with no timeout, | |
2741 just read it and wait -- that's more efficient. */ | |
2742 if (!timeout) | |
2743 { | |
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2744 while (!detect_input_pending ()) |
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2745 { |
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2746 #if __DJGPP__ >= 2 |
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2747 __dpmi_yield (); |
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2748 #endif |
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2749 } |
13179 | 2750 } |
2751 else | |
2752 { | |
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2753 EMACS_TIME clnow, cllast, cldiff; |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2754 |
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2755 gettime (&t); |
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2756 EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L); |
13179 | 2757 |
2758 while (!check_input || !detect_input_pending ()) | |
2759 { | |
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2760 gettime (&t); |
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2761 EMACS_SET_SECS_USECS (clnow, t.ti_sec, t.ti_hund * 10000L); |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2762 EMACS_SUB_TIME (cldiff, clnow, cllast); |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2763 |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2764 /* When seconds wrap around, we assume that no more than |
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2765 1 minute passed since last `gettime'. */ |
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2766 if (EMACS_TIME_NEG_P (cldiff)) |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2767 EMACS_SET_SECS (cldiff, EMACS_SECS (cldiff) + 60); |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2768 EMACS_SUB_TIME (*timeout, *timeout, cldiff); |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2769 |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2770 /* Stop when timeout value crosses zero. */ |
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2771 if (EMACS_TIME_ZERO_OR_NEG_P (*timeout)) |
13179 | 2772 return 0; |
2773 cllast = clnow; | |
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2774 #if __DJGPP__ >= 2 |
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2775 __dpmi_yield (); |
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
2776 #endif |
13179 | 2777 } |
2778 } | |
2779 | |
2780 FD_SET (0, rfds); | |
2781 return 1; | |
2782 } | |
2783 #endif | |
2784 | |
2785 /* | |
14036 | 2786 * Define overlaid functions: |
13179 | 2787 * |
2788 * chdir -> sys_chdir | |
2789 * tzset -> init_gettimeofday | |
2790 * abort -> dos_abort | |
2791 */ | |
2792 | |
2793 #ifdef chdir | |
2794 #undef chdir | |
2795 extern int chdir (); | |
2796 | |
2797 int | |
2798 sys_chdir (path) | |
2799 const char* path; | |
2800 { | |
2801 int len = strlen (path); | |
2802 char *tmp = (char *)path; | |
2803 | |
2804 if (*tmp && tmp[1] == ':') | |
2805 { | |
2806 if (getdisk () != tolower (tmp[0]) - 'a') | |
2807 setdisk (tolower (tmp[0]) - 'a'); | |
2808 tmp += 2; /* strip drive: KFS 1995-07-06 */ | |
2809 len -= 2; | |
2810 } | |
2811 | |
2812 if (len > 1 && (tmp[len - 1] == '/')) | |
2813 { | |
2814 char *tmp1 = (char *) alloca (len + 1); | |
2815 strcpy (tmp1, tmp); | |
2816 tmp1[len - 1] = 0; | |
2817 tmp = tmp1; | |
2818 } | |
2819 return chdir (tmp); | |
2820 } | |
2821 #endif | |
2822 | |
2823 #ifdef tzset | |
2824 #undef tzset | |
2825 extern void tzset (void); | |
2826 | |
2827 void | |
2828 init_gettimeofday () | |
2829 { | |
2830 time_t ltm, gtm; | |
2831 struct tm *lstm; | |
2832 | |
2833 tzset (); | |
2834 ltm = gtm = time (NULL); | |
2835 ltm = mktime (lstm = localtime (<m)); | |
2836 gtm = mktime (gmtime (>m)); | |
2837 time_rec.tm_hour = 99; /* force gettimeofday to get date */ | |
2838 time_rec.tm_isdst = lstm->tm_isdst; | |
2839 dos_timezone_offset = time_rec.tm_gmtoff = (int)(gtm - ltm) / 60; | |
2840 } | |
2841 #endif | |
2842 | |
2843 #ifdef abort | |
2844 #undef abort | |
2845 void | |
2846 dos_abort (file, line) | |
2847 char *file; | |
2848 int line; | |
2849 { | |
2850 char buffer1[200], buffer2[400]; | |
2851 int i, j; | |
2852 | |
2853 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line); | |
2854 for (i = j = 0; buffer1[i]; i++) { | |
2855 buffer2[j++] = buffer1[i]; | |
2856 buffer2[j++] = 0x70; | |
2857 } | |
2858 dosmemput (buffer2, j, (int)ScreenPrimary); | |
2859 ScreenSetCursor (2, 0); | |
2860 abort (); | |
2861 } | |
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2862 #else |
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2863 void |
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2864 abort () |
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2865 { |
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2866 dos_ttcooked (); |
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2867 ScreenSetCursor (10, 0); |
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2868 cputs ("\r\n\nEmacs aborted!\r\n"); |
14999 | 2869 #if __DJGPP__ > 1 |
2870 /* Generate traceback, so we could tell whodunit. */ | |
2871 signal (SIGINT, SIG_DFL); | |
2872 __asm__ __volatile__ ("movb $0x1b,%al;call ___djgpp_hw_exception"); | |
2873 #endif | |
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2874 exit (2); |
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2875 } |
13179 | 2876 #endif |
2877 | |
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2878 syms_of_msdos () |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2879 { |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2880 recent_doskeys = Fmake_vector (make_number (NUM_RECENT_DOSKEYS), Qnil); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2881 staticpro (&recent_doskeys); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2882 |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2883 defsubr (&Srecent_doskeys); |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2884 } |
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2885 |
5503 | 2886 #endif /* MSDOS */ |