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