annotate src/msdos.c @ 9277:21f6120be5ba

(make_process, create_process, Fopen_network_stream, deactivate_process, Faccept_process_output, Fprocess_send_eof): Use new accessor macros instead of calling XSET directly.
author Karl Heuer <kwzh@gnu.org>
date Tue, 04 Oct 1994 12:21:04 +0000
parents 3c4437496ebc
children b36d5e88cccc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
1 /* MS-DOS specific C utilities.
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
20 /* Contributed by Morten Welinder */
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
21
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 /* Note: some of the stuff here was taken from end of sysdep.c in demacs. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
5980
a203b7c30300 Use <...> for config.h.
Richard M. Stallman <rms@gnu.org>
parents: 5503
diff changeset
24 #include <config.h>
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #ifdef MSDOS
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 #include "lisp.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 #include <stdio.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 #include <stdlib.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 #include <sys/param.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 #include <sys/time.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 #include <dos.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 #include "dosfns.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 #include "msdos.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 #include "systime.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 #include "termhooks.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 #include "frame.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 #include <go32.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 #include <pc.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 #include <ctype.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 /* #include <process.h> */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 #define P_WAIT 1
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 static int break_stat; /* BREAK check mode status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 static int stdin_stat; /* stdin IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 static int extended_kbd; /* 101 (102) keyboard present. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 int have_mouse; /* Mouse present? */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 static int mouse_last_x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 static int mouse_last_y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 /* Turn off Dos' Ctrl-C checking and inhibit interpretation of control chars
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 by Dos. Determine the keyboard type. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 dos_ttraw ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 union REGS inregs, outregs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 inregs.h.ah = 0xc0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 int86 (0x15, &inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 break_stat = getcbrk ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 setcbrk (0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 install_ctrl_break_check ();
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
67 have_mouse = mouse_init1 ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 inregs.x.ax = 0x4400; /* Get IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 inregs.x.bx = 0x00; /* 0 = stdin. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 stdin_stat = outregs.h.dl;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 inregs.x.dx = (outregs.x.dx | 0x0020) & 0x0027; /* raw mode */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 inregs.h.al = 0x01;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 return !outregs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 /* Restore status of standard input and Ctrl-C checking. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 dos_ttcooked ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 union REGS inregs, outregs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 setcbrk (break_stat);
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
87 if (have_mouse) mouse_off ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 inregs.x.ax = 0x4401; /* Set IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 inregs.x.bx = 0x00; /* 0 = stdin. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 inregs.x.dx = stdin_stat;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 return !outregs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 static unsigned short
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ibmpc_translate_map[] =
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 /* --------------- 00 to 0f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 0, /* Ctrl Break */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 0xff1b, /* Escape */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 0xffb1, /* Keypad 1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 0xffb2, /* Keypad 2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 0xffb3, /* Keypad 3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 0xffb4, /* Keypad 4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 0xffb5, /* Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 0xffb6, /* Keypad 6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 0xffb7, /* Keypad 7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 0xffb8, /* Keypad 8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 0xffb9, /* Keypad 9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 0xffb0, /* Keypad 0 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 '-', '=',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 0xff08, /* Backspace */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 0xff74, /* (Shift) Tab [Tab doesn't use this table] */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 /* --------------- 10 to 1f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 0xff8d, /* Keypad Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 0, /* Ctrl */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 'a', 's',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 /* --------------- 20 to 2f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 0, /* Left shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 '\\', 'z', 'x', 'c', 'v',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 /* --------------- 30 to 3f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 'b', 'n', 'm', ',', '.',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 0xffaf, /* Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 0, /* Right shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 0xffaa, /* Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 0, /* Alt */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ' ',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 0, /* Caps Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 0xffbe, /* F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 0xffbf, /* F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 0xffc0, /* F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 0xffc1, /* F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 0xffc2, /* F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 /* --------------- 40 to 4f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 0xffc3, /* F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 0xffc4, /* F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 0xffc5, /* F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 0xffc6, /* F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 0xffc7, /* F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 0, /* Num Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 0, /* Scroll Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 0xff50, /* Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 0xff52, /* Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 0xff55, /* Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 0xffad, /* Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 0xff51, /* Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 0xffb5, /* Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 0xff53, /* Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 0xffab, /* Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 0xff57, /* End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 /* --------------- 50 to 5f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 0xff54, /* Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 0xff56, /* Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 0xff63, /* Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 0xffff, /* Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 0xffbe, /* (Shift) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 0xffbf, /* (Shift) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 0xffc0, /* (Shift) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 0xffc1, /* (Shift) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 0xffc2, /* (Shift) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 0xffc3, /* (Shift) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 0xffc4, /* (Shift) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 0xffc5, /* (Shift) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 0xffc6, /* (Shift) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 0xffc7, /* (Shift) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 0xffbe, /* (Ctrl) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 0xffbf, /* (Ctrl) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 /* --------------- 60 to 6f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 0xffc0, /* (Ctrl) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 0xffc1, /* (Ctrl) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 0xffc2, /* (Ctrl) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 0xffc3, /* (Ctrl) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 0xffc4, /* (Ctrl) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 0xffc5, /* (Ctrl) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 0xffc6, /* (Ctrl) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 0xffc7, /* (Ctrl) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 0xffbe, /* (Alt) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 0xffbf, /* (Alt) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 0xffc0, /* (Alt) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 0xffc1, /* (Alt) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 0xffc2, /* (Alt) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 0xffc3, /* (Alt) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 0xffc4, /* (Alt) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 0xffc5, /* (Alt) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 /* --------------- 70 to 7f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 0xffc6, /* (Alt) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 0xffc7, /* (Alt) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 0xff6d, /* (Ctrl) Sys Rq */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 0xff51, /* (Ctrl) Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 0xff53, /* (Ctrl) Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 0xff57, /* (Ctrl) End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 0xff56, /* (Ctrl) Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 0xff50, /* (Ctrl) Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 '1', '2', '3', '4', '5', '6', '7', '8', /* (Alt) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 /* --------------- 80 to 8f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 '9', '0', '-', '=', /* (Alt) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 0xff55, /* (Ctrl) Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 0xffc8, /* F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 0xffc9, /* F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 0xffc8, /* (Shift) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 0xffc9, /* (Shift) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 0xffc8, /* (Ctrl) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 0xffc9, /* (Ctrl) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 0xffc8, /* (Alt) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 0xffc9, /* (Alt) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 0xff52, /* (Ctrl) Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 0xffae, /* (Ctrl) Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 0xffb5, /* (Ctrl) Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 /* --------------- 90 to 9f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 0xffab, /* (Ctrl) Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 0xff54, /* (Ctrl) Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 0xff63, /* (Ctrl) Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 0xffff, /* (Ctrl) Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 0xff09, /* (Ctrl) Tab */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 0xffaf, /* (Ctrl) Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 0xffaa, /* (Ctrl) Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 0xff50, /* (Alt) Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 0xff52, /* (Alt) Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 0xff55, /* (Alt) Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 0xff51, /* (Alt) Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 0xff53, /* (Alt) Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 0xff57, /* (Alt) End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 /* --------------- a0 to af --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 0xff54, /* (Alt) Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 0xff56, /* (Alt) Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 0xff63, /* (Alt) Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 0xffff, /* (Alt) Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 0xffaf, /* (Alt) Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 0xff09, /* (Alt) Tab */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 0xff0d /* (Alt) Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 };
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 /* Get a char from keyboard. Function keys are put into the event queue. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 static int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 dos_rawgetc ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 struct input_event event;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 struct timeval tv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 int ctrl_p, alt_p, shift_p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 /* Calculate modifier bits */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 regs.h.ah = extended_kbd ? 0x12 : 0x02;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 int86 (0x16, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 ctrl_p = ((regs.h.al & 4) != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 shift_p = ((regs.h.al & 3) != 0);
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
263 /* Please be very careful here not to break international keyboard support.
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
264 When Keyb.Com is loaded, the key marked `Alt Gr' is used for accessing
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
265 characters like { and } if their positions are overlaid. */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 alt_p = ((extended_kbd ? (regs.h.ah & 2) : (regs.h.al & 8)) != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
8194
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
268 /* The following condition is equivalent to `kbhit ()', except that
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
269 it uses the bios to do its job. This pleases DESQview/X. */
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
270 while ((regs.h.ah = extended_kbd ? 0x11 : 0x01),
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
271 int86 (0x16, &regs, &regs),
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
272 (regs.x.flags & 0x40) == 0)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 register unsigned char c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 int sc, code;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 regs.h.ah = extended_kbd ? 0x10 : 0x00;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 int86 (0x16, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 c = regs.h.al;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 sc = regs.h.ah;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 /* Determine from the scan code if a keypad key was pressed. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 if (c >= '0' && c <= '9' && sc > 0xb)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 sc = (c == '0') ? 0xb : (c - '0' + 1), c = 0;
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
286 else if (sc == 0x53 && c != 0xe0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
287 {
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
288 code = 0xffae; /* Keypad decimal point/comma. */
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
289 goto nonascii;
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
290 }
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 else if (sc == 0xe0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 switch (c)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 case 10: /* Ctrl Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 case 13:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 sc = 0x1c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 case '/':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 sc = 0x35;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 default:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 sc = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 };
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 c = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 if (c == 0
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 || c == ' '
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 || alt_p
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 || (ctrl_p && shift_p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 || (c == 0xe0 && sc != 0) /* Pseudo-key */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 || sc == 0x37 /* Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 || sc == 0x4a /* Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 || sc == 0x4e /* Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 || sc == 0x0e) /* Back space *key*, not Ctrl-h */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short)))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 code = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 code = ibmpc_translate_map[sc];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 if (code != 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 if (code >= 0x100)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 {
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
326 nonascii:
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 event.kind = non_ascii_keystroke;
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
328 event.code = (code & 0xff) + 0xff00;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 {
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
332 /* Don't return S- if we don't have to. `shifted' is
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
333 supposed to be the shifted versions of the characters
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
334 in `unshifted'. Unfortunately, this is only true for
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
335 US keyboard layout. If anyone knows how to do this
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
336 right, please tell us. */
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
337 static char *unshifted
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
338 = "abcdefghijklmnopqrstuvwxyz,./=;[\\]'-`0123456789";
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
339 static char *shifted
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
340 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ<>?+:{|}\"_~)!@#$%^&*(";
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
341 char *pos;
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
342
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
343 if (shift_p && (pos = strchr (unshifted, code)))
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 {
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
345 c = shifted[pos - unshifted];
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 shift_p = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 if (c == 0) c = code;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 event.kind = ascii_keystroke;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 event.code = c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 event.modifiers
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
354 = (shift_p ? shift_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
355 + (ctrl_p ? ctrl_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
356 + (alt_p ? meta_modifier : 0);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 /* EMACS == Enter Meta Alt Control Shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 event.frame_or_window = selected_frame;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 gettimeofday (&tv, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 event.timestamp = tv.tv_usec;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 kbd_buffer_store_event (&event);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 } else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 return c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 if (have_mouse)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 int but, press, x, y, ok;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 /* Check for mouse movement *before* buttons. */
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
372 mouse_check_moved ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 for (but = 0; but < NUM_MOUSE_BUTTONS; but++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 for (press = 0; press < 2; press++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 if (press)
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
378 ok = mouse_pressed (but, &x, &y);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 else
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
380 ok = mouse_released (but, &x, &y);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 if (ok)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 event.kind = mouse_click;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 event.code = but;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 event.modifiers
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
386 = (shift_p ? shift_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
387 + (ctrl_p ? ctrl_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
388 + (alt_p ? meta_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
389 + (press ? down_modifier : up_modifier);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 event.x = x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 event.y = y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 event.frame_or_window = selected_frame;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 gettimeofday (&tv, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 event.timestamp = tv.tv_usec;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 kbd_buffer_store_event (&event);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 return -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 static int prev_get_char = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 /* Return 1 if a key is ready to be read without suspending execution. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 dos_keysns ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 if (prev_get_char != -1)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 return 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 return ((prev_get_char = dos_rawgetc ()) != -1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 /* Read a key. Return -1 if no key is ready. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 dos_keyread ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 if (prev_get_char != -1)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 int c = prev_get_char;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 prev_get_char = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 return c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 return dos_rawgetc ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 /* Hostnames for a pc are not really funny, but they are used in change log
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 so we emulate the best we can. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 gethostname (p, size)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 int size;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 char *q = egetenv ("HOSTNAME");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 if (!q) q = "pc";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 strcpy (p, q);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 /* Destructively turn backslashes into slashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 dostounix_filename (p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 register char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 while (*p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 if (*p == '\\')
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 *p = '/';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 p++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 /* Destructively turn slashes into backslashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 unixtodos_filename (p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 register char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 while (*p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 if (*p == '/')
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 *p = '\\';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 p++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 /* Get the default directory for a given drive. 0=def, 1=A, 2=B, ... */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 getdefdir (drive, dst)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 int drive;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 char *dst;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 *dst++ = '/';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 regs.h.dl = drive;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 regs.x.si = (int) dst;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 regs.h.ah = 0x47;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 intdos (&regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 return !regs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 /* Remove all CR's that are followed by a LF. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 crlf_to_lf (n, buf)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 register int n;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 register unsigned char *buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 unsigned char *np = buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 unsigned char *startp = buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 unsigned char *endp = buf + n;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 unsigned char c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 if (n == 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 return n;
7507
b393834bab2a (crlf_to_lf): Fix off-by-one condition.
Richard M. Stallman <rms@gnu.org>
parents: 7273
diff changeset
495 while (buf < endp - 1)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 if (*buf == 0x0d)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 if (*(++buf) != 0x0a)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 *np++ = 0x0d;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 *np++ = *buf++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 }
7507
b393834bab2a (crlf_to_lf): Fix off-by-one condition.
Richard M. Stallman <rms@gnu.org>
parents: 7273
diff changeset
505 if (buf < endp)
b393834bab2a (crlf_to_lf): Fix off-by-one condition.
Richard M. Stallman <rms@gnu.org>
parents: 7273
diff changeset
506 *np++ = *buf++;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 return np - startp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 /* Run command as specified by ARGV in directory DIR.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 The command is run with input from TEMPIN and output to file TEMPOUT. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 run_msdos_command (argv, dir, tempin, tempout)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 unsigned char **argv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 Lisp_Object dir;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 int tempin, tempout;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 char *saveargv1, *saveargv2, **envv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 int msshell, result = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 int in, out, inbak, outbak, errbak;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 Lisp_Object cmd;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 /* Get current directory as MSDOS cwd is not per-process. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 getwd (oldwd);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 cmd = Ffile_name_nondirectory (build_string (argv[0]));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 msshell = !NILP (Fmember (cmd, Fsymbol_value (intern ("msdos-shells"))))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 && !strcmp ("-c", argv[1]);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 if (msshell)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 saveargv1 = argv[1];
7774
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
534 saveargv2 = argv[2];
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 argv[1] = "/c";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 if (argv[2])
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 {
7774
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
538 char *p = alloca (strlen (argv[2]) + 1);
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
539
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
540 strcpy (argv[2] = p, saveargv2);
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
541 while (*p && isspace (*p))
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
542 p++;
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
543 while (*p && !isspace (*p))
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
544 if (*p == '/')
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
545 *p++ = '\\';
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
546 else
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
547 p++;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 /* Build the environment array. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 extern Lisp_Object Vprocess_environment;
6505
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
554 Lisp_Object tmp, lst;
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
555 int i, len;
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
556
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
557 lst = Vprocess_environment;
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
558 len = XFASTINT (Flength (lst));
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 envv = alloca ((len + 1) * sizeof (char *));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 for (i = 0; i < len; i++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 tmp = Fcar (lst);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 lst = Fcdr (lst);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 CHECK_STRING (tmp, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 envv[i] = alloca (XSTRING (tmp)->size + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 strcpy (envv[i], XSTRING (tmp)->data);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 envv[len] = (char *) 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571
9118
3c4437496ebc (run_msdos_command): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 8246
diff changeset
572 if (STRINGP (dir))
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 chdir (XSTRING (dir)->data);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 inbak = dup (0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 outbak = dup (1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 errbak = dup (2);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 if (inbak < 0 || outbak < 0 || errbak < 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 goto done; /* Allocation might fail due to lack of descriptors. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 dup2 (tempin, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 dup2 (tempout, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 dup2 (tempout, 2);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 dos_ttcooked ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 result = spawnve (P_WAIT, argv[0], argv, envv);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 dos_ttraw ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 dup2 (inbak, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 dup2 (outbak, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 dup2 (errbak, 2);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 done:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 chdir (oldwd);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 if (msshell)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 argv[1] = saveargv1;
7774
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
594 argv[2] = saveargv2;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 return result;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 croak (badfunc)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 char *badfunc;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 fprintf (stderr, "%s not yet implemented\r\n", badfunc);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 reset_sys_modes ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 exit (1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 /* A list of unimplemented functions that we silently ignore. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 unsigned alarm (s) unsigned s; {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 fork () { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 int kill (x, y) int x, y; { return -1; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 nice (p) int p; {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 void volatile pause () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 request_sigio () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 setpgrp () {return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 setpriority (x,y,z) int x,y,z; { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 sigsetmask (x) int x; { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 unrequest_sigio () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 #ifdef chdir
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 #undef chdir
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 #endif
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 sys_chdir (path)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 const char* path;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 int len = strlen (path);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 char *tmp = (char *) alloca (len + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 /* Gotta do this extern here due to the corresponding #define: */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 extern int chdir ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 if (*path && path[1] == ':' && (getdisk () != tolower (path[0]) - 'a'))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 setdisk (tolower (path[0]) - 'a');
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 strcpy (tmp, path);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 if (strcmp (path, "/") && strcmp (path + 1, ":/") && (path[len - 1] == '/'))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 tmp[len - 1] = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 return chdir (tmp);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 /* Sleep SECS. If KBDOK also return immediately if a key is pressed. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 sleep_or_kbd_hit (secs, kbdok)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 int secs, kbdok;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 long clnow, clthen;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 struct timeval t;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 gettimeofday (&t, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 clnow = t.tv_sec * 100 + t.tv_usec / 10000;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 clthen = clnow + (100 * secs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 do
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 gettimeofday (&t, NULL);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 clnow = t.tv_sec * 100 + t.tv_usec / 10000;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 if (kbdok && detect_input_pending ())
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 return;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 while (clnow < clthen);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
664 /* The Emacs root directory as determined by init_environment. */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
665 static char emacsroot[MAXPATHLEN];
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
666
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
667 char *
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
668 rootrelativepath (rel)
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
669 char *rel;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
670 {
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
671 static char result[MAXPATHLEN + 10];
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
672
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
673 strcpy (result, emacsroot);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
674 strcat (result, "/");
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
675 strcat (result, rel);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
676 return result;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
677 }
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
678
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 /* Define a lot of environment variables if not already defined. Don't
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 remove anything unless you know what you're doing -- lots of code will
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 break if one or more of these are missing. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 init_environment (argc, argv, skip_args)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 int argc;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 char **argv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 int skip_args;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 {
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
688 char *s, *t, *root;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
689 int len;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
691 /* Find our root from argv[0]. Assuming argv[0] is, say,
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
692 "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
693 len = strlen (argv[0]);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
694 root = alloca (len + 10); /* A little extra space for the stuff below. */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
695 strcpy (root, argv[0]);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
696 while (len > 0 && root[len] != '/' && root[len] != ':')
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
697 len--;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
698 root[len] = '\0';
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
699 if (len > 4 && strcmp (root + len - 4, "/bin") == 0)
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
700 root[len - 4] = '\0';
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 else
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
702 strcpy (root, "c:/emacs"); /* Only under debuggers, I think. */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
703 len = strlen (root);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
704 strcpy (emacsroot, root);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
706 /* We default HOME to our root. */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
707 setenv ("HOME", root, 0);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
708
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
709 /* We default EMACSPATH to root + "/bin". */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
710 strcpy (root + len, "/bin");
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
711 setenv ("EMACSPATH", root, 0);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 /* I don't expect anybody to ever use other terminals so the internal
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 terminal is the default. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 setenv ("TERM", "internal", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 /* SHELL is a bit tricky -- COMSPEC is the closest we come, but we must
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 downcase it and mirror the backslashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 s = getenv ("COMSPEC");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 if (!s) s = "c:/command.com";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 t = alloca (strlen (s) + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 strcpy (t, s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 strlwr (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 dostounix_filename (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 setenv ("SHELL", t, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 /* PATH is also downcased and backslashes mirrored. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 s = getenv ("PATH");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 if (!s) s = "";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 t = alloca (strlen (s) + 3);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 /* Current directory is always considered part of MsDos's path but it is
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 not normally mentioned. Now it is. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 strcat (strcpy (t, ".;"), s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 strlwr (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 dostounix_filename (t); /* Not a single file name, but this should work. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 setenv ("PATH", t, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 /* In some sense all dos users have root privileges, so... */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 setenv ("USER", "root", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 setenv ("NAME", getenv ("USER"), 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 /* Time zone determined from country code. To make this possible, the
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 country code may not span more than one time zone. In other words,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 in the USA, you lose. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 switch (dos_country_code)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 case 31: /* Belgium */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 case 32: /* The Netherlands */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 case 33: /* France */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 case 34: /* Spain */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 case 36: /* Hungary */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 case 38: /* Yugoslavia (or what's left of it?) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 case 39: /* Italy */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 case 41: /* Switzerland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 case 42: /* Tjekia */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 case 45: /* Denmark */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 case 46: /* Sweden */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 case 47: /* Norway */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 case 48: /* Poland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 case 49: /* Germany */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 /* Daylight saving from last Sunday in March to last Sunday in
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 September, both at 2AM. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 setenv ("TZ", "MET-01METDST-02,M3.5.0/02:00,M9.5.0/02:00", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 case 44: /* United Kingdom */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 case 351: /* Portugal */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 case 354: /* Iceland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 setenv ("TZ", "GMT+00", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 case 81: /* Japan */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 case 82: /* Korea */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 setenv ("TZ", "???-09", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 case 90: /* Turkey */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 case 358: /* Finland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 case 972: /* Israel */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 setenv ("TZ", "EET-02", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 tzset ();
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
781 init_gettimeofday ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 /* Flash the screen as a substitute for BEEPs. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
786 static void
7667
bae9c0fa1c2f (do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents: 7666
diff changeset
787 do_visible_bell (xorattr)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 unsigned char xorattr;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 {
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
790 asm volatile
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
791 (" movb $1,%%dl
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 visible_bell_0:
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
793 movl _ScreenPrimary,%%eax
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
794 call dosmemsetup
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
795 movl %%eax,%%ebx
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
796 movl %1,%%ecx
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
797 movb %0,%%al
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
798 incl %%ebx
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 visible_bell_1:
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
800 xorb %%al,%%gs:(%%ebx)
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
801 addl $2,%%ebx
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
802 decl %%ecx
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
803 jne visible_bell_1
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
804 decb %%dl
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
805 jne visible_bell_3
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 visible_bell_2:
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
807 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
808 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
809 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
810 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
811 decw %%cx
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
812 jne visible_bell_2
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
813 jmp visible_bell_0
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
814 visible_bell_3:"
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
815 : /* no output */
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
816 : "m" (xorattr), "g" (ScreenCols () * ScreenRows ())
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
817 : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx");
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
820 /* At screen position (X,Y), output C characters from string S with
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
821 attribute A. Do it fast! */
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
822
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
823 static void
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
824 output_string (x, y, s, c, a)
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
825 int x, y, c;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
826 unsigned char *s;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
827 unsigned char a;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
828 {
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
829 char *t = (char *)ScreenPrimary + 2 * (x + ScreenCols () * y);
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
830 asm volatile
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
831 (" movl %1,%%eax
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
832 call dosmemsetup
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
833 movl %%eax,%%edi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
834 movb %0,%%ah
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
835 movl %2,%%ecx
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
836 movl %3,%%esi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
837 output_string1:
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
838 movb (%%esi),%%al
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
839 movw %%ax,%%gs:(%%edi)
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
840 addl $2,%%edi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
841 incl %%esi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
842 decl %%ecx
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
843 jne output_string1"
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
844 : /* no output */
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
845 : "m" (a), "g" (t), "g" (c), "g" (s)
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
846 : "%eax", "%ecx", /* "%gs",*/ "%esi", "%edi");
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
847 }
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
848
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 static int internal_terminal = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 #undef fflush
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 internal_flush (f)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 FILE *f;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 {
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
856 static char spaces[] = " ";
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 static int x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 static int y;
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
859 unsigned char *cp, *cp0;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
860 int count, i, j;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 if (internal_terminal && f == stdout)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 {
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
864 if (have_mouse) mouse_off ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 cp = stdout->_base;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 count = stdout->_ptr - stdout->_base;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 while (count > 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 {
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
869 switch (*cp++)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 case 27:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 switch (*cp++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 case '@':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 y = *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 x = *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 count -= 4;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 case 'A':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 ScreenAttrib = *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 count -= 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 case 'B':
7667
bae9c0fa1c2f (do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents: 7666
diff changeset
884 do_visible_bell (*cp++);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 count -= 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 case 'C':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 ScreenClear ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 x = y = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 case 'E':
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
893 i = ScreenCols () - x;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
894 j = x;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
895 while (i >= sizeof spaces)
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
896 {
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
897 output_string (j, y, spaces, sizeof spaces,
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
898 ScreenAttrib);
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
899 j += sizeof spaces;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
900 i -= sizeof spaces;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
901 }
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
902 if (i > 0)
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
903 output_string (j, y, spaces, i, ScreenAttrib);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 case 'R':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 x++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 case 'U':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 y--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 case 'X':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 ScreenAttrib ^= *cp++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 count -= 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 default:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 count -= 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 break;
7667
bae9c0fa1c2f (do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents: 7666
diff changeset
922 case 7:
bae9c0fa1c2f (do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents: 7666
diff changeset
923 write (1, "\007", 1);
bae9c0fa1c2f (do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents: 7666
diff changeset
924 count--;
bae9c0fa1c2f (do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents: 7666
diff changeset
925 break;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 case 8:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 x--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 count--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 case 13:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 x = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 count--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 case 10:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 y++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 count--;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 default:
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
939 cp0 = cp - 1;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 count--;
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
941 while (count > 0 && *cp >= ' ')
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
942 cp++, count--;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
943 output_string (x, y, cp0, cp - cp0, ScreenAttrib);
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
944 x += (cp - cp0);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 fpurge (stdout);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 ScreenSetCursor (y, x);
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
949 if (have_mouse) mouse_on ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 /* This is a call to the original fflush. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 fflush (f);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 /* Do we need the internal terminal? */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 internal_terminal_init ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 char *term = getenv ("TERM");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 internal_terminal
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 = (!noninteractive) && term && !strcmp (term, "internal");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 }
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
965
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
966 /* When time zones are set from Ms-Dos too may C-libraries are playing
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
967 tricks with time values. We solve this by defining our own version
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
968 of `gettimeofday' bypassing GO32. Our version needs to be initialized
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
969 once and after each call to `tzset' with TZ changed. */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
971 static int daylight, gmtoffset;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
972
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
973 int
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
974 gettimeofday (struct timeval *tp, struct timezone *tzp)
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
975 {
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
976 if (tp)
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
977 {
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
978 struct time t;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
979 struct date d;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
980 struct tm tmrec;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
981
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
982 gettime (&t);
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
983 getdate (&d);
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
984 tmrec.tm_year = d.da_year - 1900;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
985 tmrec.tm_mon = d.da_mon - 1;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
986 tmrec.tm_mday = d.da_day;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
987 tmrec.tm_hour = t.ti_hour;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
988 tmrec.tm_min = t.ti_min;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
989 tmrec.tm_sec = t.ti_sec;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
990 tmrec.tm_gmtoff = gmtoffset;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
991 tmrec.tm_isdst = daylight;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
992 tp->tv_sec = mktime (&tmrec);
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
993 tp->tv_usec = t.ti_hund * (1000000 / 100);
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
994 }
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
995 if (tzp)
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
996 {
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
997 tzp->tz_minuteswest = gmtoffset;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
998 tzp->tz_dsttime = daylight;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
999 }
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1000 return 0;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1001 }
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1002
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1003 void
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1004 init_gettimeofday ()
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1005 {
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1006 time_t ltm, gtm;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1007 struct tm *lstm;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1008
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1009 daylight = 0;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1010 gmtoffset = 0;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1011 ltm = gtm = time (NULL);
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1012 ltm = mktime (lstm = localtime (&ltm));
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1013 gtm = mktime (gmtime (&gtm));
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1014 daylight = lstm->tm_isdst;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1015 gmtoffset = (int)(gtm - ltm) / 60;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1016 }
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1017
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 /* These must be global. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 static _go32_dpmi_seginfo ctrl_break_vector;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 static _go32_dpmi_registers ctrl_break_regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 static int ctrlbreakinstalled = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 /* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 ctrl_break_func (regs)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 _go32_dpmi_registers *regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 Vquit_flag = Qt;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 install_ctrl_break_check ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 if (!ctrlbreakinstalled)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 /* Don't press Ctrl-Break if you don't have either DPMI or Emacs
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
1037 was compiler with Djgpp 1.11 maintenance level 5 or later! */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 ctrlbreakinstalled = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 ctrl_break_vector.pm_offset = (int) ctrl_break_func;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 &ctrl_break_regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 /* Mouse routines under devellopment follow. Coordinates are in screen
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 positions and zero based. Mouse buttons are numbered from left to
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 right and also zero based. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 static int mouse_button_translate[NUM_MOUSE_BUTTONS];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 static int mouse_button_count;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 mouse_init ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 regs.x.ax = 0x0007;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 regs.x.cx = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 regs.x.dx = 8 * (ScreenCols () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 regs.x.ax = 0x0008;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 regs.x.cx = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 regs.x.dx = 8 * (ScreenRows () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 mouse_moveto (ScreenCols () - 1, ScreenRows () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 mouse_on ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 mouse_on ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 regs.x.ax = 0x0001;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 mouse_off ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 regs.x.ax = 0x0002;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 mouse_moveto (x, y)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 int x, y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 regs.x.ax = 0x0004;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 mouse_last_x = regs.x.cx = x * 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 mouse_last_y = regs.x.dx = y * 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 mouse_pressed (b, xp, yp)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 int b, *xp, *yp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 if (b >= mouse_button_count)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 regs.x.ax = 0x0005;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 regs.x.bx = mouse_button_translate[b];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 if (regs.x.bx)
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
1115 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 return (regs.x.bx != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 mouse_released (b, xp, yp)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 int b, *xp, *yp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 if (b >= mouse_button_count)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 regs.x.ax = 0x0006;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 regs.x.bx = mouse_button_translate[b];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 if (regs.x.bx)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 return (regs.x.bx != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 mouse_get_pos (f, bar_window, part, x, y, time)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 FRAME_PTR *f;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 Lisp_Object *bar_window, *x, *y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 enum scroll_bar_part *part;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 unsigned long *time;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 struct timeval tv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 regs.x.ax = 0x0003;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 *f = selected_frame;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 *bar_window = Qnil;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 gettimeofday (&tv, NULL);
8246
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1150 *x = make_number (regs.x.cx / 8);
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1151 *y = make_number (regs.x.dx / 8);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 *time = tv.tv_usec;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 mouse_moved = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 mouse_check_moved ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 regs.x.ax = 0x0003;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 if (regs.x.cx != mouse_last_x || regs.x.dx != mouse_last_y)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 mouse_moved = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 mouse_last_x = regs.x.cx;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 mouse_last_y = regs.x.dx;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 mouse_init1 ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 int present;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176
8246
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1177 if (!internal_terminal)
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1178 return 0;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1179
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 regs.x.ax = 0x0021;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 int86 (0x33, &regs, &regs);
8246
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1182 present = (regs.x.ax & 0xffff) == 0xffff;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1183 if (!present)
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1184 {
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1185 /* Reportedly, the above doesn't work for some mouse drivers. There
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1186 is an additional detection method that should work, but might be
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1187 a little slower. Use that as an alternative. */
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1188 regs.x.ax = 0x0000;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1189 int86 (0x33, &regs, &regs);
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1190 present = (regs.x.ax & 0xffff) == 0xffff;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1191 }
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1192
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 if (present)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 if (regs.x.bx == 3)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 mouse_button_count = 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 mouse_button_translate[0] = 0; /* Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 mouse_button_translate[1] = 2; /* Middle */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 mouse_button_translate[2] = 1; /* Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 mouse_button_count = 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 mouse_button_translate[0] = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 mouse_button_translate[1] = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 mouse_position_hook = &mouse_get_pos;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 mouse_init ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 return present;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1214 /* See xterm.c for more info. */
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1215 void
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1216 pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1217 FRAME_PTR f;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1218 register int pix_x, pix_y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1219 register int *x, *y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1220 void /* XRectangle */ *bounds;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1221 int noclip;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1222 {
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1223 if (bounds) abort ();
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1224
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1225 /* Ignore clipping. */
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1226
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1227 *x = pix_x;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1228 *y = pix_y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1229 }
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1230
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1231 void
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1232 glyph_to_pixel_coords (f, x, y, pix_x, pix_y)
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1233 FRAME_PTR f;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1234 register int x, y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1235 register int *pix_x, *pix_y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1236 {
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1237 *pix_x = x;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1238 *pix_y = y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1239 }
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1240
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 #endif /* MSDOS */