aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii1997-10-13 16:21:52 +0000
committerEli Zaretskii1997-10-13 16:21:52 +0000
commit838a94b8a1ba915d19267d0cb8a097d055efc30c (patch)
tree06b8976227302a95e0bc54fb183fa37c9b34e596 /src
parentc8a6e3b923e946cd48f4b5bd2b8c3c56f7bdfb80 (diff)
downloademacs-838a94b8a1ba915d19267d0cb8a097d055efc30c.tar.gz
emacs-838a94b8a1ba915d19267d0cb8a097d055efc30c.zip
(__tb): Define.
(restore_parent_vm_title): New function. (ms_windows_version): New function. (w95_set_virtual_machine_title): New function (x_set_title): New function. (dos_cleanup): New function (syms_of_dosfns): Define `dos-windows-version' Lisp variable. (init_dosfns): Compute MS-Windows version and save the original title of our DOS box.
Diffstat (limited to 'src')
-rw-r--r--src/dosfns.c149
1 files changed, 149 insertions, 0 deletions
diff --git a/src/dosfns.c b/src/dosfns.c
index a70f16962f4..630dcfe64c6 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -32,11 +32,18 @@ Boston, MA 02111-1307, USA. */
32#include "termchar.h" 32#include "termchar.h"
33#include "termhooks.h" 33#include "termhooks.h"
34#include "frame.h" 34#include "frame.h"
35#include "blockinput.h"
36#include "window.h"
35#include "dosfns.h" 37#include "dosfns.h"
36#include "msdos.h" 38#include "msdos.h"
39#include <dpmi.h>
37#include <go32.h> 40#include <go32.h>
38#include <dirent.h> 41#include <dirent.h>
39 42
43#ifndef __DJGPP_MINOR__
44# define __tb _go32_info_block.linear_address_of_transfer_buffer;
45#endif
46
40DEFUN ("int86", Fint86, Sint86, 2, 2, 0, 47DEFUN ("int86", Fint86, Sint86, 2, 2, 0,
41 "Call specific MSDOS interrupt number INTERRUPT with REGISTERS.\n\ 48 "Call specific MSDOS interrupt number INTERRUPT with REGISTERS.\n\
42Return the updated REGISTER vector.\n\ 49Return the updated REGISTER vector.\n\
@@ -259,6 +266,24 @@ int dos_keypad_mode;
259 266
260Lisp_Object Vdos_version; 267Lisp_Object Vdos_version;
261Lisp_Object Vdos_display_scancodes; 268Lisp_Object Vdos_display_scancodes;
269
270#ifndef HAVE_X_WINDOWS
271static unsigned dos_windows_version;
272Lisp_Object Vdos_windows_version;
273
274char parent_vm_title[50]; /* Ralf Brown says 30 is enough */
275int w95_set_virtual_machine_title (const char *);
276
277void
278restore_parent_vm_title (void)
279{
280 if (NILP (Vdos_windows_version))
281 return;
282 if ((dos_windows_version & 0xff) >= 4 && parent_vm_title[0])
283 w95_set_virtual_machine_title (parent_vm_title);
284 delay (50);
285}
286#endif /* !HAVE_X_WINDOWS */
262 287
263void 288void
264init_dosfns () 289init_dosfns ()
@@ -311,6 +336,54 @@ init_dosfns ()
311 else 336 else
312 dos_codepage = regs.x.bx & 0xffff; 337 dos_codepage = regs.x.bx & 0xffff;
313 338
339#ifndef HAVE_X_WINDOWS
340 parent_vm_title[0] = '\0';
341
342 /* If we are running from DOS box on MS-Windows, get Windows version. */
343 dpmiregs.x.ax = 0x1600; /* enhanced mode installation check */
344 dpmiregs.x.ss = dpmiregs.x.sp = dpmiregs.x.flags = 0;
345 _go32_dpmi_simulate_int (0x2f, &dpmiregs);
346 /* We only support Windows-specific features when we run on Windows 9X
347 or on Windows 3.X/enhanced mode.
348
349 Int 2Fh/AX=1600h returns:
350
351 AL = 00: no Windows at all;
352 AL = 01: Windows/386 2.x;
353 AL = 80h: Windows 3.x in mode other than enhanced;
354 AL = FFh: Windows/386 2.x
355
356 We also check AH > 0 (Windows 3.1 or later), in case AL tricks us. */
357 if (dpmiregs.h.al > 2 && dpmiregs.h.al != 0x80 && dpmiregs.h.al != 0xff
358 && (dpmiregs.h.al > 3 || dpmiregs.h.ah > 0))
359 {
360 dos_windows_version = dpmiregs.x.ax;
361 Vdos_windows_version =
362 Fcons (make_number (dpmiregs.h.al), make_number (dpmiregs.h.ah));
363
364 /* Save the current title of this virtual machine, so we can restore
365 it before exiting. Otherwise, Windows 95 will continue to use
366 the title we set even after we are history, stupido... */
367 if (dpmiregs.h.al >= 4)
368 {
369 dpmiregs.x.ax = 0x168e;
370 dpmiregs.x.dx = 3; /* get VM title */
371 dpmiregs.x.cx = sizeof(parent_vm_title) - 1;
372 dpmiregs.x.es = __tb >> 4;
373 dpmiregs.x.di = __tb & 15;
374 dpmiregs.x.sp = dpmiregs.x.ss = dpmiregs.x.flags = 0;
375 _go32_dpmi_simulate_int (0x2f, &dpmiregs);
376 if (dpmiregs.x.ax == 1)
377 dosmemget (__tb, sizeof(parent_vm_title), parent_vm_title);
378 }
379 }
380 else
381 {
382 dos_windows_version = 0;
383 Vdos_windows_version = Qnil;
384 }
385#endif /* !HAVE_X_WINDOWS */
386
314#if __DJGPP__ >= 2 387#if __DJGPP__ >= 2
315 388
316 /* Without this, we never see hidden files. 389 /* Without this, we never see hidden files.
@@ -327,6 +400,77 @@ init_dosfns ()
327#endif /* __DJGPP__ >= 2 */ 400#endif /* __DJGPP__ >= 2 */
328} 401}
329 402
403#ifndef HAVE_X_WINDOWS
404/* Support for features that are available when we run in a DOS box
405 on MS-Windows. */
406int
407ms_windows_version (void)
408{
409 return dos_windows_version;
410}
411
412/* Set the title of the current virtual machine, to appear on
413 the caption bar of that machine's window. */
414
415int
416w95_set_virtual_machine_title (const char *title_string)
417{
418 /* Only Windows 9X (version 4 and higher) support this function. */
419 if (!NILP (Vdos_windows_version)
420 && (dos_windows_version & 0xff) >= 4)
421 {
422 _go32_dpmi_registers regs;
423 dosmemput (title_string, strlen (title_string) + 1, __tb);
424 regs.x.ax = 0x168e;
425 regs.x.dx = 1;
426 regs.x.es = __tb >> 4;
427 regs.x.di = __tb & 15;
428 regs.x.sp = regs.x.ss = regs.x.flags = 0;
429 _go32_dpmi_simulate_int (0x2f, &regs);
430 return regs.x.ax == 1;
431 }
432 return 0;
433}
434
435/* Change the title of frame F to NAME.
436 If NAME is nil, use the frame name as the title.
437
438 If Emacs is not run from a DOS box on Windows 9X, this only
439 sets the name in the frame struct, but has no other effects. */
440
441void
442x_set_title (f, name)
443 struct frame *f;
444 Lisp_Object name;
445{
446 /* Don't change the title if it's already NAME. */
447 if (EQ (name, f->title))
448 return;
449
450 update_mode_lines = 1;
451
452 f->title = name;
453
454 if (NILP (name))
455 name = f->name;
456
457 if (FRAME_MSDOS_P (f))
458 {
459 BLOCK_INPUT;
460 w95_set_virtual_machine_title (XSTRING (name)->data);
461 UNBLOCK_INPUT;
462 }
463}
464#endif /* !HAVE_X_WINDOWS */
465
466void
467dos_cleanup (void)
468{
469#ifndef HAVE_X_WINDOWS
470 restore_parent_vm_title ();
471#endif
472}
473
330/* 474/*
331 * Define everything 475 * Define everything
332 */ 476 */
@@ -369,6 +513,11 @@ Implicitly modified when the TZ variable is changed.");
369 DEFVAR_LISP ("dos-version", &Vdos_version, 513 DEFVAR_LISP ("dos-version", &Vdos_version,
370 "The (MAJOR . MINOR) Dos version (subject to modification with setver)."); 514 "The (MAJOR . MINOR) Dos version (subject to modification with setver).");
371 515
516#ifndef HAVE_X_WINDOWS
517 DEFVAR_LISP ("dos-windows-version", &Vdos_windows_version,
518 "The (MAJOR . MINOR) Windows version for DOS session on MS-Windows.");
519#endif
520
372 DEFVAR_LISP ("dos-display-scancodes", &Vdos_display_scancodes, 521 DEFVAR_LISP ("dos-display-scancodes", &Vdos_display_scancodes,
373 "*When non-nil, the keyboard scan-codes are displayed at the bottom right\n\ 522 "*When non-nil, the keyboard scan-codes are displayed at the bottom right\n\
374corner of the display (typically at the end of the mode line).\n\ 523corner of the display (typically at the end of the mode line).\n\