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