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