Commit | Line | Data |
---|---|---|
1b94449f RS |
1 | /* MS-DOS specific Lisp utilities. Coded by Manabu Higashida, 1991. |
2 | Major changes May-July 1993 Morten Welinder (only 10% original code left) | |
e089dc62 | 3 | Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc. |
1b94449f RS |
4 | |
5 | This file is part of GNU Emacs. | |
6 | ||
7 | GNU Emacs is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
edfc0d45 | 9 | the Free Software Foundation; either version 2, or (at your option) |
1b94449f RS |
10 | any later version. |
11 | ||
12 | GNU Emacs is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU Emacs; see the file COPYING. If not, write to | |
3b7ad313 EN |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
1b94449f RS |
21 | |
22 | ||
48984716 | 23 | #include <config.h> |
1b94449f RS |
24 | |
25 | #ifdef MSDOS | |
26 | /* The entire file is within this conditional */ | |
27 | ||
28 | #include <stdio.h> | |
e4441df0 | 29 | #include <string.h> |
1b94449f RS |
30 | #include <dos.h> |
31 | #include "lisp.h" | |
32 | #include "buffer.h" | |
33 | #include "termchar.h" | |
34 | #include "termhooks.h" | |
35 | #include "frame.h" | |
838a94b8 EZ |
36 | #include "blockinput.h" |
37 | #include "window.h" | |
1b94449f RS |
38 | #include "dosfns.h" |
39 | #include "msdos.h" | |
e4441df0 | 40 | #include "dispextern.h" |
838a94b8 | 41 | #include <dpmi.h> |
5f08dc78 | 42 | #include <go32.h> |
50666766 | 43 | #include <dirent.h> |
1b94449f | 44 | |
838a94b8 EZ |
45 | #ifndef __DJGPP_MINOR__ |
46 | # define __tb _go32_info_block.linear_address_of_transfer_buffer; | |
47 | #endif | |
48 | ||
1b94449f RS |
49 | DEFUN ("int86", Fint86, Sint86, 2, 2, 0, |
50 | "Call specific MSDOS interrupt number INTERRUPT with REGISTERS.\n\ | |
51 | Return the updated REGISTER vector.\n\ | |
52 | \n\ | |
53 | INTERRUPT should be an integer in the range 0 to 255.\n\ | |
54 | REGISTERS should be a vector produced by `make-register' and\n\ | |
55 | `set-register-value'.") | |
e20104ba EN |
56 | (interrupt, registers) |
57 | Lisp_Object interrupt, registers; | |
1b94449f RS |
58 | { |
59 | register int i; | |
60 | int no; | |
61 | union REGS inregs, outregs; | |
62 | Lisp_Object val; | |
63 | ||
e20104ba EN |
64 | CHECK_NUMBER (interrupt, 0); |
65 | no = (unsigned long) XINT (interrupt); | |
66 | CHECK_VECTOR (registers, 1); | |
67 | if (no < 0 || no > 0xff || XVECTOR (registers)-> size != 8) | |
1b94449f RS |
68 | return Qnil; |
69 | for (i = 0; i < 8; i++) | |
e20104ba | 70 | CHECK_NUMBER (XVECTOR (registers)->contents[i], 1); |
1b94449f | 71 | |
e20104ba EN |
72 | inregs.x.ax = (unsigned long) XFASTINT (XVECTOR (registers)->contents[0]); |
73 | inregs.x.bx = (unsigned long) XFASTINT (XVECTOR (registers)->contents[1]); | |
74 | inregs.x.cx = (unsigned long) XFASTINT (XVECTOR (registers)->contents[2]); | |
75 | inregs.x.dx = (unsigned long) XFASTINT (XVECTOR (registers)->contents[3]); | |
76 | inregs.x.si = (unsigned long) XFASTINT (XVECTOR (registers)->contents[4]); | |
77 | inregs.x.di = (unsigned long) XFASTINT (XVECTOR (registers)->contents[5]); | |
78 | inregs.x.cflag = (unsigned long) XFASTINT (XVECTOR (registers)->contents[6]); | |
79 | inregs.x.flags = (unsigned long) XFASTINT (XVECTOR (registers)->contents[7]); | |
1b94449f RS |
80 | |
81 | int86 (no, &inregs, &outregs); | |
82 | ||
e20104ba EN |
83 | XVECTOR (registers)->contents[0] = make_number (outregs.x.ax); |
84 | XVECTOR (registers)->contents[1] = make_number (outregs.x.bx); | |
85 | XVECTOR (registers)->contents[2] = make_number (outregs.x.cx); | |
86 | XVECTOR (registers)->contents[3] = make_number (outregs.x.dx); | |
87 | XVECTOR (registers)->contents[4] = make_number (outregs.x.si); | |
88 | XVECTOR (registers)->contents[5] = make_number (outregs.x.di); | |
89 | XVECTOR (registers)->contents[6] = make_number (outregs.x.cflag); | |
90 | XVECTOR (registers)->contents[7] = make_number (outregs.x.flags); | |
1b94449f | 91 | |
e20104ba | 92 | return registers; |
1b94449f RS |
93 | } |
94 | ||
5f08dc78 KS |
95 | DEFUN ("msdos-memget", Fdos_memget, Sdos_memget, 2, 2, 0, |
96 | "Read DOS memory at offset ADDRESS into VECTOR.\n\ | |
97 | Return the updated VECTOR.") | |
e20104ba EN |
98 | (address, vector) |
99 | Lisp_Object address, vector; | |
5f08dc78 KS |
100 | { |
101 | register int i; | |
102 | int offs, len; | |
103 | char *buf; | |
104 | Lisp_Object val; | |
105 | ||
e20104ba EN |
106 | CHECK_NUMBER (address, 0); |
107 | offs = (unsigned long) XINT (address); | |
108 | CHECK_VECTOR (vector, 1); | |
109 | len = XVECTOR (vector)-> size; | |
110 | if (len < 1 || len > 2048 || address < 0 || address > 0xfffff - len) | |
5f08dc78 KS |
111 | return Qnil; |
112 | buf = alloca (len); | |
113 | dosmemget (offs, len, buf); | |
114 | ||
115 | for (i = 0; i < len; i++) | |
e20104ba | 116 | XVECTOR (vector)->contents[i] = make_number (buf[i]); |
5f08dc78 | 117 | |
e20104ba | 118 | return vector; |
5f08dc78 KS |
119 | } |
120 | ||
121 | DEFUN ("msdos-memput", Fdos_memput, Sdos_memput, 2, 2, 0, | |
122 | "Write DOS memory at offset ADDRESS from VECTOR.") | |
e20104ba EN |
123 | (address, vector) |
124 | Lisp_Object address, vector; | |
5f08dc78 KS |
125 | { |
126 | register int i; | |
127 | int offs, len; | |
128 | char *buf; | |
129 | Lisp_Object val; | |
130 | ||
e20104ba EN |
131 | CHECK_NUMBER (address, 0); |
132 | offs = (unsigned long) XINT (address); | |
133 | CHECK_VECTOR (vector, 1); | |
134 | len = XVECTOR (vector)-> size; | |
135 | if (len < 1 || len > 2048 || address < 0 || address > 0xfffff - len) | |
5f08dc78 KS |
136 | return Qnil; |
137 | buf = alloca (len); | |
138 | ||
139 | for (i = 0; i < len; i++) | |
140 | { | |
e20104ba EN |
141 | CHECK_NUMBER (XVECTOR (vector)->contents[i], 1); |
142 | buf[i] = (unsigned char) XFASTINT (XVECTOR (vector)->contents[i]) & 0xFF; | |
5f08dc78 KS |
143 | } |
144 | ||
145 | dosmemput (buf, len, offs); | |
146 | return Qt; | |
147 | } | |
148 | ||
149 | DEFUN ("msdos-set-keyboard", Fmsdos_set_keyboard, Smsdos_set_keyboard, 1, 2, 0, | |
e20104ba | 150 | "Set keyboard layout according to COUNTRY-CODE.\n\ |
5f08dc78 KS |
151 | If the optional argument ALLKEYS is non-nil, the keyboard is mapped for\n\ |
152 | all keys; otherwise it is only used when the ALT key is pressed.\n\ | |
153 | The current keyboard layout is available in dos-keyboard-code.") | |
154 | (country_code, allkeys) | |
155 | Lisp_Object country_code; | |
156 | { | |
157 | CHECK_NUMBER (country_code, 0); | |
158 | if (!dos_set_keyboard (XINT (country_code), !NILP (allkeys))) | |
159 | return Qnil; | |
160 | return Qt; | |
161 | } | |
162 | ||
87485d6f MW |
163 | #ifndef HAVE_X_WINDOWS |
164 | /* Later we might want to control the mouse interface with this function, | |
165 | e.g., with respect to non-80 column screen modes. */ | |
166 | ||
167 | DEFUN ("msdos-mouse-p", Fmsdos_mouse_p, Smsdos_mouse_p, 0, 0, 0, "\ | |
168 | Report whether a mouse is present.") | |
169 | () | |
170 | { | |
171 | if (have_mouse) | |
172 | return Qt; | |
173 | else | |
174 | return Qnil; | |
175 | } | |
176 | ||
87485d6f MW |
177 | /* Function to translate colour names to integers. See lisp/term/pc-win.el |
178 | for its definition. */ | |
179 | ||
180 | Lisp_Object Qmsdos_color_translate; | |
181 | #endif | |
182 | ||
ac3b0279 RS |
183 | |
184 | DEFUN ("msdos-mouse-init", Fmsdos_mouse_init, Smsdos_mouse_init, 0, 0, "", | |
185 | "Initialize and enable mouse if available.") | |
186 | () | |
187 | { | |
5f08dc78 KS |
188 | if (have_mouse) |
189 | { | |
190 | have_mouse = 1; | |
191 | mouse_init (); | |
192 | return Qt; | |
193 | } | |
ac3b0279 RS |
194 | return Qnil; |
195 | } | |
196 | ||
197 | DEFUN ("msdos-mouse-enable", Fmsdos_mouse_enable, Smsdos_mouse_enable, 0, 0, "", | |
198 | "Enable mouse if available.") | |
199 | () | |
200 | { | |
201 | if (have_mouse) | |
202 | { | |
5f08dc78 KS |
203 | have_mouse = 1; |
204 | mouse_on (); | |
ac3b0279 RS |
205 | } |
206 | return have_mouse ? Qt : Qnil; | |
207 | } | |
208 | ||
209 | DEFUN ("msdos-mouse-disable", Fmsdos_mouse_disable, Smsdos_mouse_disable, 0, 0, "", | |
210 | "Disable mouse if available.") | |
211 | () | |
212 | { | |
213 | mouse_off (); | |
214 | if (have_mouse) have_mouse = -1; | |
215 | return Qnil; | |
216 | } | |
217 | ||
5f08dc78 KS |
218 | DEFUN ("insert-startup-screen", Finsert_startup_screen, Sinsert_startup_screen, 0, 0, "", "\ |
219 | Insert copy of screen contents prior to starting emacs.\n\ | |
220 | Return nil if startup screen is not available.") | |
221 | () | |
222 | { | |
223 | char *s; | |
224 | int rows, cols; | |
225 | int i, j; | |
226 | ||
227 | if (!dos_get_saved_screen (&s, &rows, &cols)) | |
228 | return Qnil; | |
229 | ||
230 | for (i = 0; i < rows; i++) | |
231 | { | |
232 | for (j = 0; j < cols; j++) | |
233 | { | |
65788bc2 | 234 | insert_char (*s); |
5f08dc78 KS |
235 | s += 2; |
236 | } | |
65788bc2 | 237 | insert_char ('\n'); |
5f08dc78 KS |
238 | } |
239 | ||
240 | return Qt; | |
241 | } | |
87485d6f | 242 | \f |
5f08dc78 | 243 | /* country info */ |
1b94449f RS |
244 | int dos_country_code; |
245 | int dos_codepage; | |
5f08dc78 KS |
246 | int dos_timezone_offset; |
247 | int dos_decimal_point; | |
248 | int dos_keyboard_layout; | |
249 | unsigned char dos_country_info[DOS_COUNTRY_INFO]; | |
e089dc62 RS |
250 | static unsigned char usa_country_info[DOS_COUNTRY_INFO] = { |
251 | 0, 0, /* date format */ | |
252 | '$', 0, 0, 0, 0, /* currency string */ | |
253 | ',', 0, /* thousands separator */ | |
254 | '.', 0, /* decimal separator */ | |
255 | '/', 0, /* date separator */ | |
256 | ':', 0, /* time separator */ | |
257 | 0, /* currency format */ | |
258 | 2, /* digits after decimal in currency */ | |
259 | 0, /* time format */ | |
260 | 0, 0, 0, 0, /* address of case map routine, GPF if used */ | |
261 | ' ', 0, /* data-list separator (?) */ | |
262 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* reserved */ | |
263 | }; | |
5f08dc78 KS |
264 | |
265 | int dos_hyper_key; | |
266 | int dos_super_key; | |
267 | int dos_keypad_mode; | |
1b94449f | 268 | |
5f08dc78 KS |
269 | Lisp_Object Vdos_version; |
270 | Lisp_Object Vdos_display_scancodes; | |
838a94b8 EZ |
271 | |
272 | #ifndef HAVE_X_WINDOWS | |
273 | static unsigned dos_windows_version; | |
274 | Lisp_Object Vdos_windows_version; | |
275 | ||
276 | char parent_vm_title[50]; /* Ralf Brown says 30 is enough */ | |
277 | int w95_set_virtual_machine_title (const char *); | |
278 | ||
279 | void | |
280 | restore_parent_vm_title (void) | |
281 | { | |
282 | if (NILP (Vdos_windows_version)) | |
283 | return; | |
284 | if ((dos_windows_version & 0xff) >= 4 && parent_vm_title[0]) | |
285 | w95_set_virtual_machine_title (parent_vm_title); | |
286 | delay (50); | |
287 | } | |
288 | #endif /* !HAVE_X_WINDOWS */ | |
5f08dc78 | 289 | |
1b94449f RS |
290 | void |
291 | init_dosfns () | |
292 | { | |
293 | union REGS regs; | |
1b94449f | 294 | _go32_dpmi_registers dpmiregs; |
e089dc62 | 295 | unsigned long xbuf = _go32_info_block.linear_address_of_transfer_buffer; |
1b94449f | 296 | |
87485d6f | 297 | #ifndef SYSTEM_MALLOC |
1b94449f | 298 | get_lim_data (); /* why the hell isn't this called elsewhere? */ |
87485d6f | 299 | #endif |
1b94449f RS |
300 | |
301 | regs.x.ax = 0x3000; | |
302 | intdos (®s, ®s); | |
303 | Vdos_version = Fcons (make_number (regs.h.al), make_number (regs.h.ah)); | |
304 | ||
e089dc62 RS |
305 | /* Obtain the country code via DPMI, use DJGPP transfer buffer. */ |
306 | dpmiregs.x.ax = 0x3800; | |
7a2fd369 | 307 | dpmiregs.x.ds = xbuf >> 4; |
e089dc62 RS |
308 | dpmiregs.x.dx = 0; |
309 | dpmiregs.x.ss = dpmiregs.x.sp = dpmiregs.x.flags = 0; | |
310 | _go32_dpmi_simulate_int (0x21, &dpmiregs); | |
311 | if (dpmiregs.x.flags & 1) | |
312 | { | |
313 | dos_country_code = 1; /* assume USA if 213800 failed */ | |
314 | memcpy (dos_country_info, usa_country_info, DOS_COUNTRY_INFO); | |
315 | } | |
1b94449f RS |
316 | else |
317 | { | |
1b94449f | 318 | dos_country_code = dpmiregs.x.bx; |
e089dc62 | 319 | dosmemget (xbuf, DOS_COUNTRY_INFO, dos_country_info); |
1b94449f | 320 | } |
e089dc62 | 321 | |
5f08dc78 | 322 | dos_set_keyboard (dos_country_code, 0); |
1b94449f RS |
323 | |
324 | regs.x.ax = 0x6601; | |
325 | intdos (®s, ®s); | |
326 | if (regs.x.cflag) | |
327 | /* Estimate code page from country code */ | |
328 | switch (dos_country_code) | |
329 | { | |
330 | case 45: /* Denmark */ | |
331 | case 47: /* Norway */ | |
332 | dos_codepage = 865; | |
333 | break; | |
334 | default: | |
335 | /* US */ | |
336 | dos_codepage = 437; | |
337 | } | |
338 | else | |
339 | dos_codepage = regs.x.bx & 0xffff; | |
50666766 | 340 | |
838a94b8 EZ |
341 | #ifndef HAVE_X_WINDOWS |
342 | parent_vm_title[0] = '\0'; | |
343 | ||
344 | /* If we are running from DOS box on MS-Windows, get Windows version. */ | |
345 | dpmiregs.x.ax = 0x1600; /* enhanced mode installation check */ | |
346 | dpmiregs.x.ss = dpmiregs.x.sp = dpmiregs.x.flags = 0; | |
347 | _go32_dpmi_simulate_int (0x2f, &dpmiregs); | |
348 | /* We only support Windows-specific features when we run on Windows 9X | |
349 | or on Windows 3.X/enhanced mode. | |
350 | ||
351 | Int 2Fh/AX=1600h returns: | |
352 | ||
353 | AL = 00: no Windows at all; | |
354 | AL = 01: Windows/386 2.x; | |
355 | AL = 80h: Windows 3.x in mode other than enhanced; | |
356 | AL = FFh: Windows/386 2.x | |
357 | ||
358 | We also check AH > 0 (Windows 3.1 or later), in case AL tricks us. */ | |
359 | if (dpmiregs.h.al > 2 && dpmiregs.h.al != 0x80 && dpmiregs.h.al != 0xff | |
360 | && (dpmiregs.h.al > 3 || dpmiregs.h.ah > 0)) | |
361 | { | |
362 | dos_windows_version = dpmiregs.x.ax; | |
363 | Vdos_windows_version = | |
364 | Fcons (make_number (dpmiregs.h.al), make_number (dpmiregs.h.ah)); | |
365 | ||
366 | /* Save the current title of this virtual machine, so we can restore | |
367 | it before exiting. Otherwise, Windows 95 will continue to use | |
368 | the title we set even after we are history, stupido... */ | |
369 | if (dpmiregs.h.al >= 4) | |
370 | { | |
371 | dpmiregs.x.ax = 0x168e; | |
372 | dpmiregs.x.dx = 3; /* get VM title */ | |
373 | dpmiregs.x.cx = sizeof(parent_vm_title) - 1; | |
374 | dpmiregs.x.es = __tb >> 4; | |
375 | dpmiregs.x.di = __tb & 15; | |
376 | dpmiregs.x.sp = dpmiregs.x.ss = dpmiregs.x.flags = 0; | |
377 | _go32_dpmi_simulate_int (0x2f, &dpmiregs); | |
378 | if (dpmiregs.x.ax == 1) | |
379 | dosmemget (__tb, sizeof(parent_vm_title), parent_vm_title); | |
380 | } | |
381 | } | |
382 | else | |
383 | { | |
384 | dos_windows_version = 0; | |
385 | Vdos_windows_version = Qnil; | |
386 | } | |
387 | #endif /* !HAVE_X_WINDOWS */ | |
388 | ||
50666766 RS |
389 | #if __DJGPP__ >= 2 |
390 | ||
459f4042 RS |
391 | /* Without this, we never see hidden files. |
392 | Don't OR it with the previous value, so the value recorded at dump | |
393 | time, possibly with `preserve-case' flags set, won't get through. */ | |
394 | __opendir_flags = __OPENDIR_FIND_HIDDEN; | |
395 | ||
396 | #if __DJGPP_MINOR__ == 0 | |
397 | /* Under LFN, preserve the case of files as recorded in the directory | |
398 | (in DJGPP 2.01 and later this is automagically done by the library). */ | |
50666766 RS |
399 | if (!NILP (Fmsdos_long_file_names ())) |
400 | __opendir_flags |= __OPENDIR_PRESERVE_CASE; | |
459f4042 RS |
401 | #endif /* __DJGPP_MINOR__ == 0 */ |
402 | #endif /* __DJGPP__ >= 2 */ | |
1b94449f RS |
403 | } |
404 | \f | |
838a94b8 | 405 | #ifndef HAVE_X_WINDOWS |
e4441df0 EZ |
406 | |
407 | /* Emulation of some X window features from xfns.c and xfaces.c. */ | |
408 | ||
409 | /* Standard VGA colors, in the order of their standard numbering | |
410 | in the default VGA palette. */ | |
411 | static char *vga_colors[16] = { | |
412 | "black", "blue", "green", "cyan", "red", "magenta", "brown", | |
413 | "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan", | |
414 | "lightred", "lightmagenta", "yellow", "white" | |
415 | }; | |
416 | ||
417 | /* Given a color name, return its index, or -1 if not found. Note | |
418 | that this only performs case-insensitive comparison against the | |
419 | standard names. For anything more sophisticated, like matching | |
420 | "gray" with "grey" or translating X color names into their MSDOS | |
421 | equivalents, call the Lisp function Qmsdos_color_translate (defined | |
422 | on lisp/term/pc-win.el). */ | |
423 | int | |
424 | msdos_stdcolor_idx (const char *name) | |
425 | { | |
426 | int i; | |
427 | ||
428 | for (i = 0; i < sizeof (vga_colors) / sizeof (vga_colors[0]); i++) | |
429 | if (strcasecmp (name, vga_colors[i]) == 0) | |
430 | return i; | |
431 | ||
432 | return FACE_TTY_DEFAULT_COLOR; | |
433 | } | |
434 | ||
435 | /* Given a color index, return its standard name. */ | |
6821243b | 436 | char * |
e4441df0 EZ |
437 | msdos_stdcolor_name (int idx) |
438 | { | |
439 | if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0])) | |
440 | return ""; /* meaning the default */ | |
441 | return vga_colors[idx]; | |
442 | } | |
443 | ||
838a94b8 EZ |
444 | /* Support for features that are available when we run in a DOS box |
445 | on MS-Windows. */ | |
446 | int | |
447 | ms_windows_version (void) | |
448 | { | |
449 | return dos_windows_version; | |
450 | } | |
451 | ||
452 | /* Set the title of the current virtual machine, to appear on | |
453 | the caption bar of that machine's window. */ | |
454 | ||
455 | int | |
456 | w95_set_virtual_machine_title (const char *title_string) | |
457 | { | |
458 | /* Only Windows 9X (version 4 and higher) support this function. */ | |
459 | if (!NILP (Vdos_windows_version) | |
460 | && (dos_windows_version & 0xff) >= 4) | |
461 | { | |
462 | _go32_dpmi_registers regs; | |
463 | dosmemput (title_string, strlen (title_string) + 1, __tb); | |
464 | regs.x.ax = 0x168e; | |
465 | regs.x.dx = 1; | |
466 | regs.x.es = __tb >> 4; | |
467 | regs.x.di = __tb & 15; | |
468 | regs.x.sp = regs.x.ss = regs.x.flags = 0; | |
469 | _go32_dpmi_simulate_int (0x2f, ®s); | |
470 | return regs.x.ax == 1; | |
471 | } | |
472 | return 0; | |
473 | } | |
474 | ||
475 | /* Change the title of frame F to NAME. | |
476 | If NAME is nil, use the frame name as the title. | |
477 | ||
478 | If Emacs is not run from a DOS box on Windows 9X, this only | |
479 | sets the name in the frame struct, but has no other effects. */ | |
480 | ||
481 | void | |
482 | x_set_title (f, name) | |
483 | struct frame *f; | |
484 | Lisp_Object name; | |
485 | { | |
486 | /* Don't change the title if it's already NAME. */ | |
487 | if (EQ (name, f->title)) | |
488 | return; | |
489 | ||
490 | update_mode_lines = 1; | |
491 | ||
492 | f->title = name; | |
493 | ||
494 | if (NILP (name)) | |
495 | name = f->name; | |
496 | ||
497 | if (FRAME_MSDOS_P (f)) | |
498 | { | |
499 | BLOCK_INPUT; | |
500 | w95_set_virtual_machine_title (XSTRING (name)->data); | |
501 | UNBLOCK_INPUT; | |
502 | } | |
503 | } | |
504 | #endif /* !HAVE_X_WINDOWS */ | |
505 | \f | |
506 | void | |
507 | dos_cleanup (void) | |
508 | { | |
509 | #ifndef HAVE_X_WINDOWS | |
510 | restore_parent_vm_title (); | |
511 | #endif | |
6f855d64 EZ |
512 | /* Make sure the termscript file is committed, in case we are |
513 | crashing and some vital info was written there. */ | |
514 | if (termscript) | |
515 | { | |
516 | fflush (termscript); | |
517 | fsync (fileno (termscript)); | |
518 | } | |
838a94b8 EZ |
519 | } |
520 | ||
1b94449f RS |
521 | /* |
522 | * Define everything | |
523 | */ | |
524 | syms_of_dosfns () | |
525 | { | |
1b94449f | 526 | defsubr (&Sint86); |
5f08dc78 KS |
527 | defsubr (&Sdos_memget); |
528 | defsubr (&Sdos_memput); | |
ac3b0279 RS |
529 | defsubr (&Smsdos_mouse_init); |
530 | defsubr (&Smsdos_mouse_enable); | |
5f08dc78 KS |
531 | defsubr (&Smsdos_set_keyboard); |
532 | defsubr (&Sinsert_startup_screen); | |
ac3b0279 | 533 | defsubr (&Smsdos_mouse_disable); |
87485d6f MW |
534 | #ifndef HAVE_X_WINDOWS |
535 | defsubr (&Smsdos_mouse_p); | |
87485d6f MW |
536 | Qmsdos_color_translate = intern ("msdos-color-translate"); |
537 | staticpro (&Qmsdos_color_translate); | |
538 | #endif | |
1b94449f RS |
539 | |
540 | DEFVAR_INT ("dos-country-code", &dos_country_code, | |
541 | "The country code returned by Dos when Emacs was started.\n\ | |
542 | Usually this is the international telephone prefix."); | |
543 | ||
544 | DEFVAR_INT ("dos-codepage", &dos_codepage, | |
5f08dc78 | 545 | "The codepage active when Emacs was started.\n\ |
24ba360b RS |
546 | The following are known:\n\ |
547 | 437 United States\n\ | |
548 | 850 Multilingual (Latin I)\n\ | |
549 | 852 Slavic (Latin II)\n\ | |
550 | 857 Turkish\n\ | |
551 | 860 Portugal\n\ | |
552 | 861 Iceland\n\ | |
553 | 863 Canada (French)\n\ | |
1b94449f RS |
554 | 865 Norway/Denmark"); |
555 | ||
5f08dc78 KS |
556 | DEFVAR_INT ("dos-timezone-offset", &dos_timezone_offset, |
557 | "The current timezone offset to UTC in minutes. | |
558 | Implicitly modified when the TZ variable is changed."); | |
559 | ||
1b94449f RS |
560 | DEFVAR_LISP ("dos-version", &Vdos_version, |
561 | "The (MAJOR . MINOR) Dos version (subject to modification with setver)."); | |
5f08dc78 | 562 | |
838a94b8 EZ |
563 | #ifndef HAVE_X_WINDOWS |
564 | DEFVAR_LISP ("dos-windows-version", &Vdos_windows_version, | |
565 | "The (MAJOR . MINOR) Windows version for DOS session on MS-Windows."); | |
566 | #endif | |
567 | ||
5f08dc78 KS |
568 | DEFVAR_LISP ("dos-display-scancodes", &Vdos_display_scancodes, |
569 | "*When non-nil, the keyboard scan-codes are displayed at the bottom right\n\ | |
570 | corner of the display (typically at the end of the mode line).\n\ | |
571 | The output format is: scan code:char code*modifiers."); | |
572 | Vdos_display_scancodes = Qnil; | |
573 | ||
5f08dc78 KS |
574 | DEFVAR_INT ("dos-hyper-key", &dos_hyper_key, |
575 | "*If set to 1, use right ALT key as hyper key.\n\ | |
576 | If set to 2, use right CTRL key as hyper key."); | |
577 | dos_hyper_key = 0; | |
578 | ||
579 | DEFVAR_INT ("dos-super-key", &dos_super_key, | |
580 | "*If set to 1, use right ALT key as super key.\n\ | |
581 | If set to 2, use right CTRL key as super key."); | |
582 | dos_super_key = 0; | |
583 | ||
584 | DEFVAR_INT ("dos-keypad-mode", &dos_keypad_mode, | |
585 | "*Controls what key code is returned by a key in the numeric keypad.\n\ | |
586 | The `numlock ON' action is only taken if no modifier keys are pressed.\n\ | |
587 | The value is an integer constructed by adding the following bits together:\n\ | |
588 | \n\ | |
589 | 0x00 Digit key returns digit (if numlock ON)\n\ | |
590 | 0x01 Digit key returns kp-digit (if numlock ON)\n\ | |
591 | 0x02 Digit key returns M-digit (if numlock ON)\n\ | |
592 | 0x03 Digit key returns edit key (if numlock ON)\n\ | |
593 | \n\ | |
594 | 0x00 Grey key returns char (if numlock ON)\n\ | |
595 | 0x04 Grey key returns kp-key (if numlock ON)\n\ | |
596 | \n\ | |
597 | 0x00 Digit key returns digit (if numlock OFF)\n\ | |
598 | 0x10 Digit key returns kp-digit (if numlock OFF)\n\ | |
599 | 0x20 Digit key returns M-digit (if numlock OFF)\n\ | |
600 | 0x30 Digit key returns edit key (if numlock OFF)\n\ | |
601 | \n\ | |
602 | 0x00 Grey key returns char (if numlock OFF)\n\ | |
603 | 0x40 Grey key returns kp-key (if numlock OFF)\n\ | |
604 | \n\ | |
605 | 0x200 ALT-0..ALT-9 in top-row produces shifted codes."); | |
b3d5621c | 606 | dos_keypad_mode = 0x75; |
5f08dc78 KS |
607 | |
608 | DEFVAR_INT ("dos-keyboard-layout", &dos_keyboard_layout, | |
609 | "Contains the country code for the current keyboard layout.\n\ | |
610 | Use msdos-set-keyboard to select another keyboard layout."); | |
611 | dos_keyboard_layout = 1; /* US */ | |
612 | ||
613 | DEFVAR_INT ("dos-decimal-point", &dos_decimal_point, | |
614 | "If non-zero, it contains the character to be returned when the\n\ | |
615 | decimal point key in the numeric keypad is pressed when Num Lock is on.\n\ | |
616 | If zero, the decimal point key returns the country code specific value."); | |
617 | dos_decimal_point = 0; | |
1b94449f RS |
618 | } |
619 | #endif /* MSDOS */ |