1 /* MS-DOS specific Lisp utilities. Coded by Manabu Higashida, 1991.
2 Major changes May-July 1993 Morten Welinder (only 10% original code left)
3 Copyright (C) 1991, 1993 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
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
9 the Free Software Foundation; either version 2, or (at your option)
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.
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
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 /* The entire file is within this conditional */
33 #include "termhooks.h"
40 DEFUN ("int86", Fint86
, Sint86
, 2, 2, 0,
41 "Call specific MSDOS interrupt number INTERRUPT with REGISTERS.\n\
42 Return the updated REGISTER vector.\n\
44 INTERRUPT should be an integer in the range 0 to 255.\n\
45 REGISTERS should be a vector produced by `make-register' and\n\
46 `set-register-value'.")
47 (interrupt
, registers
)
48 Lisp_Object interrupt
, registers
;
52 union REGS inregs
, outregs
;
55 CHECK_NUMBER (interrupt
, 0);
56 no
= (unsigned long) XINT (interrupt
);
57 CHECK_VECTOR (registers
, 1);
58 if (no
< 0 || no
> 0xff || XVECTOR (registers
)-> size
!= 8)
60 for (i
= 0; i
< 8; i
++)
61 CHECK_NUMBER (XVECTOR (registers
)->contents
[i
], 1);
63 inregs
.x
.ax
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[0]);
64 inregs
.x
.bx
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[1]);
65 inregs
.x
.cx
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[2]);
66 inregs
.x
.dx
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[3]);
67 inregs
.x
.si
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[4]);
68 inregs
.x
.di
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[5]);
69 inregs
.x
.cflag
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[6]);
70 inregs
.x
.flags
= (unsigned long) XFASTINT (XVECTOR (registers
)->contents
[7]);
72 int86 (no
, &inregs
, &outregs
);
74 XVECTOR (registers
)->contents
[0] = make_number (outregs
.x
.ax
);
75 XVECTOR (registers
)->contents
[1] = make_number (outregs
.x
.bx
);
76 XVECTOR (registers
)->contents
[2] = make_number (outregs
.x
.cx
);
77 XVECTOR (registers
)->contents
[3] = make_number (outregs
.x
.dx
);
78 XVECTOR (registers
)->contents
[4] = make_number (outregs
.x
.si
);
79 XVECTOR (registers
)->contents
[5] = make_number (outregs
.x
.di
);
80 XVECTOR (registers
)->contents
[6] = make_number (outregs
.x
.cflag
);
81 XVECTOR (registers
)->contents
[7] = make_number (outregs
.x
.flags
);
86 DEFUN ("msdos-memget", Fdos_memget
, Sdos_memget
, 2, 2, 0,
87 "Read DOS memory at offset ADDRESS into VECTOR.\n\
88 Return the updated VECTOR.")
90 Lisp_Object address
, vector
;
97 CHECK_NUMBER (address
, 0);
98 offs
= (unsigned long) XINT (address
);
99 CHECK_VECTOR (vector
, 1);
100 len
= XVECTOR (vector
)-> size
;
101 if (len
< 1 || len
> 2048 || address
< 0 || address
> 0xfffff - len
)
104 dosmemget (offs
, len
, buf
);
106 for (i
= 0; i
< len
; i
++)
107 XVECTOR (vector
)->contents
[i
] = make_number (buf
[i
]);
112 DEFUN ("msdos-memput", Fdos_memput
, Sdos_memput
, 2, 2, 0,
113 "Write DOS memory at offset ADDRESS from VECTOR.")
115 Lisp_Object address
, vector
;
122 CHECK_NUMBER (address
, 0);
123 offs
= (unsigned long) XINT (address
);
124 CHECK_VECTOR (vector
, 1);
125 len
= XVECTOR (vector
)-> size
;
126 if (len
< 1 || len
> 2048 || address
< 0 || address
> 0xfffff - len
)
130 for (i
= 0; i
< len
; i
++)
132 CHECK_NUMBER (XVECTOR (vector
)->contents
[i
], 1);
133 buf
[i
] = (unsigned char) XFASTINT (XVECTOR (vector
)->contents
[i
]) & 0xFF;
136 dosmemput (buf
, len
, offs
);
140 DEFUN ("msdos-set-keyboard", Fmsdos_set_keyboard
, Smsdos_set_keyboard
, 1, 2, 0,
141 "Set keyboard layout according to COUNTRY-CODE.\n\
142 If the optional argument ALLKEYS is non-nil, the keyboard is mapped for\n\
143 all keys; otherwise it is only used when the ALT key is pressed.\n\
144 The current keyboard layout is available in dos-keyboard-code.")
145 (country_code
, allkeys
)
146 Lisp_Object country_code
;
148 CHECK_NUMBER (country_code
, 0);
149 if (!dos_set_keyboard (XINT (country_code
), !NILP (allkeys
)))
154 #ifndef HAVE_X_WINDOWS
155 /* Later we might want to control the mouse interface with this function,
156 e.g., with respect to non-80 column screen modes. */
158 DEFUN ("msdos-mouse-p", Fmsdos_mouse_p
, Smsdos_mouse_p
, 0, 0, 0, "\
159 Report whether a mouse is present.")
168 /* Function to translate colour names to integers. See lisp/term/pc-win.el
169 for its definition. */
171 Lisp_Object Qmsdos_color_translate
;
175 DEFUN ("msdos-mouse-init", Fmsdos_mouse_init
, Smsdos_mouse_init
, 0, 0, "",
176 "Initialize and enable mouse if available.")
188 DEFUN ("msdos-mouse-enable", Fmsdos_mouse_enable
, Smsdos_mouse_enable
, 0, 0, "",
189 "Enable mouse if available.")
197 return have_mouse
? Qt
: Qnil
;
200 DEFUN ("msdos-mouse-disable", Fmsdos_mouse_disable
, Smsdos_mouse_disable
, 0, 0, "",
201 "Disable mouse if available.")
205 if (have_mouse
) have_mouse
= -1;
209 DEFUN ("insert-startup-screen", Finsert_startup_screen
, Sinsert_startup_screen
, 0, 0, "", "\
210 Insert copy of screen contents prior to starting emacs.\n\
211 Return nil if startup screen is not available.")
218 if (!dos_get_saved_screen (&s
, &rows
, &cols
))
221 for (i
= 0; i
< rows
; i
++)
223 for (j
= 0; j
< cols
; j
++)
228 insert_char ('\n', 1);
235 int dos_country_code
;
237 int dos_timezone_offset
;
238 int dos_decimal_point
;
239 int dos_keyboard_layout
;
240 unsigned char dos_country_info
[DOS_COUNTRY_INFO
];
246 Lisp_Object Vdos_version
;
247 Lisp_Object Vdos_display_scancodes
;
253 _go32_dpmi_seginfo info
;
254 _go32_dpmi_registers dpmiregs
;
256 #ifndef SYSTEM_MALLOC
257 get_lim_data (); /* why the hell isn't this called elsewhere? */
261 intdos (®s
, ®s
);
262 Vdos_version
= Fcons (make_number (regs
.h
.al
), make_number (regs
.h
.ah
));
264 /* Obtain the country code by calling Dos via Dpmi. Don't rely on GO32. */
265 info
.size
= (sizeof(dos_country_info
) + 15) / 16;
266 if (_go32_dpmi_allocate_dos_memory (&info
))
267 dos_country_code
= 1;
270 dpmiregs
.x
.ax
= 0x3800;
271 dpmiregs
.x
.ds
= info
.rm_segment
;
273 dpmiregs
.x
.ss
= dpmiregs
.x
.sp
= 0;
274 _go32_dpmi_simulate_int (0x21, &dpmiregs
);
275 dos_country_code
= dpmiregs
.x
.bx
;
276 dosmemget (info
.rm_segment
* 16, DOS_COUNTRY_INFO
, dos_country_info
);
277 _go32_dpmi_free_dos_memory (&info
);
279 dos_set_keyboard (dos_country_code
, 0);
282 intdos (®s
, ®s
);
284 /* Estimate code page from country code */
285 switch (dos_country_code
)
287 case 45: /* Denmark */
288 case 47: /* Norway */
296 dos_codepage
= regs
.x
.bx
& 0xffff;
300 /* Without this, we never see hidden files. */
301 __opendir_flags
|= __OPENDIR_FIND_HIDDEN
;
303 /* Under LFN, preserve the case of files as recorded in the directory. */
304 if (!NILP (Fmsdos_long_file_names ()))
305 __opendir_flags
|= __OPENDIR_PRESERVE_CASE
;
316 defsubr (&Sdos_memget
);
317 defsubr (&Sdos_memput
);
318 defsubr (&Smsdos_mouse_init
);
319 defsubr (&Smsdos_mouse_enable
);
320 defsubr (&Smsdos_set_keyboard
);
321 defsubr (&Sinsert_startup_screen
);
322 defsubr (&Smsdos_mouse_disable
);
323 #ifndef HAVE_X_WINDOWS
324 defsubr (&Smsdos_mouse_p
);
325 Qmsdos_color_translate
= intern ("msdos-color-translate");
326 staticpro (&Qmsdos_color_translate
);
329 DEFVAR_INT ("dos-country-code", &dos_country_code
,
330 "The country code returned by Dos when Emacs was started.\n\
331 Usually this is the international telephone prefix.");
333 DEFVAR_INT ("dos-codepage", &dos_codepage
,
334 "The codepage active when Emacs was started.\n\
335 The following are known:\n\
337 850 Multilingual (Latin I)\n\
338 852 Slavic (Latin II)\n\
342 863 Canada (French)\n\
343 865 Norway/Denmark");
345 DEFVAR_INT ("dos-timezone-offset", &dos_timezone_offset
,
346 "The current timezone offset to UTC in minutes.
347 Implicitly modified when the TZ variable is changed.");
349 DEFVAR_LISP ("dos-version", &Vdos_version
,
350 "The (MAJOR . MINOR) Dos version (subject to modification with setver).");
352 DEFVAR_LISP ("dos-display-scancodes", &Vdos_display_scancodes
,
353 "*When non-nil, the keyboard scan-codes are displayed at the bottom right\n\
354 corner of the display (typically at the end of the mode line).\n\
355 The output format is: scan code:char code*modifiers.");
356 Vdos_display_scancodes
= Qnil
;
358 DEFVAR_INT ("dos-hyper-key", &dos_hyper_key
,
359 "*If set to 1, use right ALT key as hyper key.\n\
360 If set to 2, use right CTRL key as hyper key.");
363 DEFVAR_INT ("dos-super-key", &dos_super_key
,
364 "*If set to 1, use right ALT key as super key.\n\
365 If set to 2, use right CTRL key as super key.");
368 DEFVAR_INT ("dos-keypad-mode", &dos_keypad_mode
,
369 "*Controls what key code is returned by a key in the numeric keypad.\n\
370 The `numlock ON' action is only taken if no modifier keys are pressed.\n\
371 The value is an integer constructed by adding the following bits together:\n\
373 0x00 Digit key returns digit (if numlock ON)\n\
374 0x01 Digit key returns kp-digit (if numlock ON)\n\
375 0x02 Digit key returns M-digit (if numlock ON)\n\
376 0x03 Digit key returns edit key (if numlock ON)\n\
378 0x00 Grey key returns char (if numlock ON)\n\
379 0x04 Grey key returns kp-key (if numlock ON)\n\
381 0x00 Digit key returns digit (if numlock OFF)\n\
382 0x10 Digit key returns kp-digit (if numlock OFF)\n\
383 0x20 Digit key returns M-digit (if numlock OFF)\n\
384 0x30 Digit key returns edit key (if numlock OFF)\n\
386 0x00 Grey key returns char (if numlock OFF)\n\
387 0x40 Grey key returns kp-key (if numlock OFF)\n\
389 0x200 ALT-0..ALT-9 in top-row produces shifted codes.");
390 dos_keypad_mode
= 0x75;
392 DEFVAR_INT ("dos-keyboard-layout", &dos_keyboard_layout
,
393 "Contains the country code for the current keyboard layout.\n\
394 Use msdos-set-keyboard to select another keyboard layout.");
395 dos_keyboard_layout
= 1; /* US */
397 DEFVAR_INT ("dos-decimal-point", &dos_decimal_point
,
398 "If non-zero, it contains the character to be returned when the\n\
399 decimal point key in the numeric keypad is pressed when Num Lock is on.\n\
400 If zero, the decimal point key returns the country code specific value.");
401 dos_decimal_point
= 0;