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