Mercurial > emacs
annotate src/msdos.c @ 16900:b0961ba869d6
(timezone-parse-date): Handle 1-digit year.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 20 Jan 1997 23:23:17 +0000 |
| parents | 1efa81ac7e5a |
| children | 8d28d96f6031 |
| 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. |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2 Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc. |
| 5503 | 3 |
| 4 This file is part of GNU Emacs. | |
| 5 | |
| 6 GNU Emacs is free software; you can redistribute it and/or modify | |
| 7 it under the terms of the GNU General Public License as published by | |
| 10504 | 8 the Free Software Foundation; either version 2, or (at your option) |
| 5503 | 9 any later version. |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14157
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14157
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
| 5503 | 20 |
|
7666
13a977e6777a
(dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents:
7523
diff
changeset
|
21 /* Contributed by Morten Welinder */ |
| 13179 | 22 /* New display, keyboard, and mouse control by Kim F. Storm */ |
|
7666
13a977e6777a
(dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents:
7523
diff
changeset
|
23 |
| 5503 | 24 /* Note: some of the stuff here was taken from end of sysdep.c in demacs. */ |
| 25 | |
| 5980 | 26 #include <config.h> |
| 5503 | 27 |
| 28 #ifdef MSDOS | |
| 29 #include "lisp.h" | |
| 30 #include <stdio.h> | |
| 31 #include <stdlib.h> | |
| 32 #include <sys/param.h> | |
| 33 #include <sys/time.h> | |
| 34 #include <dos.h> | |
|
15125
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
35 #include <errno.h> |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
36 #include <sys/stat.h> /* for _fixpath */ |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
37 #if __DJGPP__ >= 2 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
38 #include <fcntl.h> |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
39 #include <dpmi.h> /* for __dpmi_xxx stuff */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
40 #include <sys/farptr.h> /* for _farsetsel, _farnspokeb */ |
|
15125
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
41 #include <libc/dosio.h> /* for _USE_LFN */ |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
42 #endif |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
43 |
| 5503 | 44 #include "dosfns.h" |
| 45 #include "msdos.h" | |
| 46 #include "systime.h" | |
| 47 #include "termhooks.h" | |
| 9572 | 48 #include "dispextern.h" |
| 49 #include "termopts.h" | |
| 5503 | 50 #include "frame.h" |
| 9572 | 51 #include "window.h" |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
52 #include "buffer.h" |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
53 #include "commands.h" |
| 5503 | 54 #include <go32.h> |
| 55 #include <pc.h> | |
| 56 #include <ctype.h> | |
| 57 /* #include <process.h> */ | |
| 58 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */ | |
| 59 #define P_WAIT 1 | |
| 60 | |
|
15125
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
61 #ifndef _USE_LFN |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
62 #define _USE_LFN 0 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
63 #endif |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
64 |
|
16837
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
65 #ifndef _dos_ds |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
66 #define _dos_ds _go32_info_block.selector_for_linear_memory |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
67 #endif |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
68 |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
69 #if __DJGPP__ > 1 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
70 |
| 14999 | 71 #include <signal.h> |
|
16872
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
72 #include "syssignal.h" |
| 14999 | 73 |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
74 #ifndef SYSTEM_MALLOC |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
75 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
76 #ifdef GNU_MALLOC |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
77 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
78 /* If other `malloc' than ours is used, force our `sbrk' behave like |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
79 Unix programs expect (resize memory blocks to keep them contiguous). |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
80 If `sbrk' from `ralloc.c' is NOT used, also zero-out sbrk'ed memory, |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
81 because that's what `gmalloc' expects to get. */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
82 #include <crt0.h> |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
83 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
84 #ifdef REL_ALLOC |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
85 int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK; |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
86 #else /* not REL_ALLOC */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
87 int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY); |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
88 #endif /* not REL_ALLOC */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
89 #endif /* GNU_MALLOC */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
90 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
91 #endif /* not SYSTEM_MALLOC */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
92 #endif /* __DJGPP__ > 1 */ |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
93 |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
94 static unsigned long |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
95 event_timestamp () |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
96 { |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
97 struct time t; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
98 unsigned long s; |
| 13179 | 99 |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
100 gettime (&t); |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
101 s = t.ti_min; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
102 s *= 60; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
103 s += t.ti_sec; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
104 s *= 1000; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
105 s += t.ti_hund * 10; |
| 13179 | 106 |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
107 return s; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
108 } |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
109 |
| 13179 | 110 |
| 111 /* ------------------------ Mouse control --------------------------- | |
| 112 * | |
| 113 * Coordinates are in screen positions and zero based. | |
| 114 * Mouse buttons are numbered from left to right and also zero based. | |
| 115 */ | |
| 5503 | 116 |
| 13179 | 117 int have_mouse; /* 0: no, 1: enabled, -1: disabled */ |
| 118 static int mouse_visible; | |
| 5503 | 119 |
| 13179 | 120 static int mouse_last_x; |
| 121 static int mouse_last_y; | |
| 5503 | 122 |
| 13179 | 123 static int mouse_button_translate[NUM_MOUSE_BUTTONS]; |
| 124 static int mouse_button_count; | |
| 5503 | 125 |
| 13179 | 126 void |
| 127 mouse_on () | |
| 128 { | |
| 129 union REGS regs; | |
| 5503 | 130 |
| 13179 | 131 if (have_mouse > 0 && !mouse_visible) |
| 132 { | |
| 133 if (termscript) | |
| 134 fprintf (termscript, "<M_ON>"); | |
| 135 regs.x.ax = 0x0001; | |
| 136 int86 (0x33, ®s, ®s); | |
| 137 mouse_visible = 1; | |
| 5503 | 138 } |
| 139 } | |
| 140 | |
| 13179 | 141 void |
| 142 mouse_off () | |
| 5503 | 143 { |
| 13179 | 144 union REGS regs; |
| 5503 | 145 |
| 13179 | 146 if (have_mouse > 0 && mouse_visible) |
| 5503 | 147 { |
| 13179 | 148 if (termscript) |
| 149 fprintf (termscript, "<M_OFF>"); | |
| 150 regs.x.ax = 0x0002; | |
| 151 int86 (0x33, ®s, ®s); | |
| 152 mouse_visible = 0; | |
| 5503 | 153 } |
| 154 } | |
| 155 | |
| 156 void | |
| 13179 | 157 mouse_moveto (x, y) |
| 158 int x, y; | |
| 5503 | 159 { |
| 13179 | 160 union REGS regs; |
| 161 | |
| 162 if (termscript) | |
| 163 fprintf (termscript, "<M_XY=%dx%d>", x, y); | |
| 164 regs.x.ax = 0x0004; | |
| 165 mouse_last_x = regs.x.cx = x * 8; | |
| 166 mouse_last_y = regs.x.dx = y * 8; | |
| 167 int86 (0x33, ®s, ®s); | |
| 5503 | 168 } |
| 169 | |
| 13179 | 170 static int |
| 171 mouse_pressed (b, xp, yp) | |
| 172 int b, *xp, *yp; | |
| 173 { | |
| 174 union REGS regs; | |
| 175 | |
| 176 if (b >= mouse_button_count) | |
| 177 return 0; | |
| 178 regs.x.ax = 0x0005; | |
| 179 regs.x.bx = mouse_button_translate[b]; | |
| 180 int86 (0x33, ®s, ®s); | |
| 181 if (regs.x.bx) | |
| 182 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8; | |
| 183 return (regs.x.bx != 0); | |
| 184 } | |
| 185 | |
| 186 static int | |
| 187 mouse_released (b, xp, yp) | |
| 188 int b, *xp, *yp; | |
| 189 { | |
| 190 union REGS regs; | |
| 191 | |
| 192 if (b >= mouse_button_count) | |
| 193 return 0; | |
| 194 regs.x.ax = 0x0006; | |
| 195 regs.x.bx = mouse_button_translate[b]; | |
| 196 int86 (0x33, ®s, ®s); | |
| 197 if (regs.x.bx) | |
| 198 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8; | |
| 199 return (regs.x.bx != 0); | |
| 200 } | |
| 201 | |
| 202 static void | |
| 203 mouse_get_xy (int *x, int *y) | |
| 5503 | 204 { |
| 205 union REGS regs; | |
| 206 | |
| 13179 | 207 regs.x.ax = 0x0003; |
| 208 int86 (0x33, ®s, ®s); | |
| 209 *x = regs.x.cx / 8; | |
| 210 *y = regs.x.dx / 8; | |
| 211 } | |
| 212 | |
| 213 void | |
| 214 mouse_get_pos (f, insist, bar_window, part, x, y, time) | |
| 215 FRAME_PTR *f; | |
| 216 int insist; | |
| 217 Lisp_Object *bar_window, *x, *y; | |
| 218 enum scroll_bar_part *part; | |
| 219 unsigned long *time; | |
| 220 { | |
| 221 int ix, iy; | |
| 222 union REGS regs; | |
| 223 | |
| 224 regs.x.ax = 0x0003; | |
| 225 int86 (0x33, ®s, ®s); | |
| 226 *f = selected_frame; | |
| 227 *bar_window = Qnil; | |
| 228 mouse_get_xy (&ix, &iy); | |
| 229 selected_frame->mouse_moved = 0; | |
| 230 *x = make_number (ix); | |
| 231 *y = make_number (iy); | |
| 232 *time = event_timestamp (); | |
| 233 } | |
| 234 | |
| 235 static void | |
| 236 mouse_check_moved () | |
| 237 { | |
| 238 int x, y; | |
| 239 | |
| 240 mouse_get_xy (&x, &y); | |
| 241 selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y); | |
| 242 mouse_last_x = x; | |
| 243 mouse_last_y = y; | |
| 5503 | 244 } |
| 245 | |
| 13179 | 246 void |
| 247 mouse_init () | |
| 5503 | 248 { |
| 13179 | 249 union REGS regs; |
| 250 | |
| 251 if (termscript) | |
| 252 fprintf (termscript, "<M_INIT>"); | |
| 253 | |
| 254 regs.x.ax = 0x0021; | |
| 255 int86 (0x33, ®s, ®s); | |
| 256 | |
| 257 regs.x.ax = 0x0007; | |
| 258 regs.x.cx = 0; | |
| 259 regs.x.dx = 8 * (ScreenCols () - 1); | |
| 260 int86 (0x33, ®s, ®s); | |
| 261 | |
| 262 regs.x.ax = 0x0008; | |
| 263 regs.x.cx = 0; | |
| 264 regs.x.dx = 8 * (ScreenRows () - 1); | |
| 265 int86 (0x33, ®s, ®s); | |
| 266 | |
| 267 mouse_moveto (0, 0); | |
| 268 mouse_visible = 0; | |
| 269 } | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
270 |
| 13179 | 271 /* ------------------------- Screen control ---------------------- |
| 272 * | |
| 273 */ | |
| 5503 | 274 |
| 13179 | 275 static int internal_terminal = 0; |
| 276 | |
| 277 #ifndef HAVE_X_WINDOWS | |
| 278 extern unsigned char ScreenAttrib; | |
| 279 static int screen_face; | |
| 280 static int highlight; | |
| 281 | |
| 282 static int screen_size_X; | |
| 283 static int screen_size_Y; | |
| 284 static int screen_size; | |
| 285 | |
| 286 static int current_pos_X; | |
| 287 static int current_pos_Y; | |
| 288 static int new_pos_X; | |
| 289 static int new_pos_Y; | |
| 290 | |
| 291 static void *startup_screen_buffer; | |
| 292 static int startup_screen_size_X; | |
| 293 static int startup_screen_size_Y; | |
| 294 static int startup_pos_X; | |
| 295 static int startup_pos_Y; | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
296 static unsigned char startup_screen_attrib; |
| 13179 | 297 |
| 298 static int term_setup_done; | |
| 299 | |
| 300 /* Similar to the_only_frame. */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
301 struct x_output the_only_x_display; |
| 13179 | 302 |
| 303 /* This is never dereferenced. */ | |
| 304 Display *x_current_display; | |
| 5503 | 305 |
| 13179 | 306 static |
| 307 dos_direct_output (y, x, buf, len) | |
| 308 int y; | |
| 309 int x; | |
| 310 char *buf; | |
| 311 int len; | |
| 5503 | 312 { |
| 13179 | 313 int t = (int) ScreenPrimary + 2 * (x + y * screen_size_X); |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
314 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
315 #if (__DJGPP__ < 2) |
| 13179 | 316 while (--len >= 0) { |
| 317 dosmemput (buf++, 1, t); | |
| 318 t += 2; | |
| 319 } | |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
320 #else |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
321 /* This is faster. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
322 for (_farsetsel (_dos_ds); --len >= 0; t += 2, buf++) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
323 _farnspokeb (t, *buf); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
324 #endif |
| 5503 | 325 } |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
326 #endif |
| 5503 | 327 |
| 328 /* Flash the screen as a substitute for BEEPs. */ | |
| 329 | |
| 13179 | 330 #if (__DJGPP__ < 2) |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
331 static void |
|
7667
bae9c0fa1c2f
(do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents:
7666
diff
changeset
|
332 do_visible_bell (xorattr) |
| 5503 | 333 unsigned char xorattr; |
| 334 { | |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
335 asm volatile |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
336 (" movb $1,%%dl |
| 5503 | 337 visible_bell_0: |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
338 movl _ScreenPrimary,%%eax |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
339 call dosmemsetup |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
340 movl %%eax,%%ebx |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
341 movl %1,%%ecx |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
342 movb %0,%%al |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
343 incl %%ebx |
| 5503 | 344 visible_bell_1: |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
345 xorb %%al,%%gs:(%%ebx) |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
346 addl $2,%%ebx |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
347 decl %%ecx |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
348 jne visible_bell_1 |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
349 decb %%dl |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
350 jne visible_bell_3 |
| 5503 | 351 visible_bell_2: |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
352 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
353 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
354 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
355 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
356 decw %%cx |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
357 jne visible_bell_2 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
358 jmp visible_bell_0 |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
359 visible_bell_3:" |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
360 : /* no output */ |
| 13179 | 361 : "m" (xorattr), "g" (screen_size) |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
362 : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx"); |
| 5503 | 363 } |
| 364 | |
| 13179 | 365 static void |
| 366 ScreenVisualBell (void) | |
| 367 { | |
| 368 /* This creates an xor-mask that will swap the default fore- and | |
| 369 background colors. */ | |
| 370 do_visible_bell (((the_only_x_display.foreground_pixel | |
| 371 ^ the_only_x_display.background_pixel) | |
| 372 * 0x11) & 0x7f); | |
| 373 } | |
| 374 #endif | |
| 375 | |
| 376 #ifndef HAVE_X_WINDOWS | |
| 377 | |
|
16837
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
378 static int blink_bit = -1; /* the state of the blink bit at startup */ |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
379 |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
380 /* Enable bright background colors. */ |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
381 static void |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
382 bright_bg (void) |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
383 { |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
384 union REGS regs; |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
385 |
|
16837
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
386 /* Remember the original state of the blink/bright-background bit. |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
387 It is stored at 0040:0065h in the BIOS data area. */ |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
388 if (blink_bit == -1) |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
389 blink_bit = (_farpeekb (_dos_ds, 0x465) & 0x20) == 0x20; |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
390 |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
391 regs.h.bl = 0; |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
392 regs.x.ax = 0x1003; |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
393 int86 (0x10, ®s, ®s); |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
394 } |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
395 |
|
16837
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
396 /* Disable bright background colors (and enable blinking) if we found |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
397 the video system in that state at startup. */ |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
398 static void |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
399 maybe_enable_blinking (void) |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
400 { |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
401 if (blink_bit == 1) |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
402 { |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
403 union REGS regs; |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
404 |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
405 regs.h.bl = 1; |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
406 regs.x.ax = 0x1003; |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
407 int86 (0x10, ®s, ®s); |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
408 } |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
409 } |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
410 |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
411 /* Set the screen dimensions so that it can show no less than |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
412 ROWS x COLS frame. */ |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
413 |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
414 void |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
415 dos_set_window_size (rows, cols) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
416 int *rows, *cols; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
417 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
418 char video_name[30]; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
419 Lisp_Object video_mode; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
420 int video_mode_value; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
421 int have_vga = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
422 union REGS regs; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
423 int current_rows = ScreenRows (), current_cols = ScreenCols (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
424 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
425 if (*rows == current_rows && *cols == current_cols) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
426 return; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
427 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
428 /* Do we have a VGA? */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
429 regs.x.ax = 0x1a00; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
430 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
431 if (regs.h.al == 0x1a && regs.h.bl > 5 && regs.h.bl < 13) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
432 have_vga = 1; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
433 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
434 mouse_off (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
435 |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
436 /* If the user specified a special video mode for these dimensions, |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
437 use that mode. */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
438 sprintf (video_name, "screen-dimensions-%dx%d", *rows, *cols); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
439 video_mode = XSYMBOL (Fintern_soft (build_string (video_name), |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
440 Qnil))-> value; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
441 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
442 if (INTEGERP (video_mode) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
443 && (video_mode_value = XINT (video_mode)) > 0) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
444 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
445 regs.x.ax = video_mode_value; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
446 int86 (0x10, ®s, ®s); |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
447 |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
448 if (have_mouse) |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
449 { |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
450 /* Must hardware-reset the mouse, or else it won't update |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
451 its notion of screen dimensions for some non-standard |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
452 video modes. This is *painfully* slow... */ |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
453 regs.x.ax = 0; |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
454 int86 (0x33, ®s, ®s); |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
455 } |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
456 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
457 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
458 /* Find one of the dimensions supported by standard EGA/VGA |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
459 which gives us at least the required dimensions. */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
460 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
461 #if __DJGPP__ > 1 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
462 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
463 else |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
464 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
465 static struct { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
466 int rows; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
467 int need_vga; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
468 } std_dimension[] = { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
469 {25, 0}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
470 {28, 1}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
471 {35, 0}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
472 {40, 1}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
473 {43, 0}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
474 {50, 1} |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
475 }; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
476 int i = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
477 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
478 while (i < sizeof (std_dimension) / sizeof (std_dimension[0])) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
479 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
480 if (std_dimension[i].need_vga <= have_vga |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
481 && std_dimension[i].rows >= *rows) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
482 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
483 if (std_dimension[i].rows != current_rows |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
484 || *cols != current_cols) |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
485 _set_screen_lines (std_dimension[i].rows); |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
486 break; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
487 } |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
488 i++; |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
489 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
490 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
491 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
492 #else /* not __DJGPP__ > 1 */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
493 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
494 else if (*rows <= 25) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
495 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
496 if (current_rows != 25 || current_cols != 80) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
497 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
498 regs.x.ax = 3; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
499 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
500 regs.x.ax = 0x1101; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
501 regs.h.bl = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
502 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
503 regs.x.ax = 0x1200; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
504 regs.h.bl = 32; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
505 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
506 regs.x.ax = 3; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
507 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
508 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
509 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
510 else if (*rows <= 50) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
511 if (have_vga && (current_rows != 50 || current_cols != 80) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
512 || *rows <= 43 && (current_rows != 43 || current_cols != 80)) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
513 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
514 regs.x.ax = 3; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
515 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
516 regs.x.ax = 0x1112; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
517 regs.h.bl = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
518 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
519 regs.x.ax = 0x1200; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
520 regs.h.bl = 32; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
521 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
522 regs.x.ax = 0x0100; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
523 regs.x.cx = 7; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
524 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
525 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
526 #endif /* not __DJGPP__ > 1 */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
527 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
528 if (have_mouse) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
529 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
530 mouse_init (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
531 mouse_on (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
532 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
533 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
534 /* Tell the caller what dimensions have been REALLY set. */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
535 *rows = ScreenRows (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
536 *cols = ScreenCols (); |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
537 |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
538 /* Enable bright background colors. */ |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
539 bright_bg (); |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
540 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
541 |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
542 /* If we write a character in the position where the mouse is, |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
543 the mouse cursor may need to be refreshed. */ |
|
7744
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
544 |
|
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
545 static void |
| 13179 | 546 mouse_off_maybe () |
|
7744
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
547 { |
| 13179 | 548 int x, y; |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
549 |
| 13179 | 550 if (!mouse_visible) |
| 551 return; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
552 |
| 13179 | 553 mouse_get_xy (&x, &y); |
| 554 if (y != new_pos_Y || x < new_pos_X) | |
| 555 return; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
556 |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
557 mouse_off (); |
| 9572 | 558 } |
| 559 | |
| 560 static | |
| 561 IT_ring_bell () | |
| 562 { | |
| 563 if (visible_bell) | |
| 564 { | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
565 mouse_off (); |
| 13179 | 566 ScreenVisualBell (); |
| 9572 | 567 } |
| 568 else | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
569 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
570 union REGS inregs, outregs; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
571 inregs.h.ah = 2; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
572 inregs.h.dl = 7; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
573 intdos (&inregs, &outregs); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
574 } |
| 9572 | 575 } |
| 576 | |
| 577 static void | |
| 578 IT_set_face (int face) | |
| 579 { | |
| 580 struct face *fp; | |
| 581 extern struct face *intern_face (/* FRAME_PTR, struct face * */); | |
| 582 | |
| 583 if (face == 1 || (face == 0 && highlight)) | |
| 584 fp = FRAME_MODE_LINE_FACE (foo); | |
| 585 else if (face <= 0 || face >= FRAME_N_COMPUTED_FACES (foo)) | |
| 586 fp = FRAME_DEFAULT_FACE (foo); | |
| 587 else | |
| 588 fp = intern_face (selected_frame, FRAME_COMPUTED_FACES (foo)[face]); | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
589 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
590 fprintf (termscript, "<FACE:%d:%d>", FACE_FOREGROUND (fp), FACE_BACKGROUND (fp)); |
| 13179 | 591 screen_face = face; |
| 592 ScreenAttrib = (FACE_BACKGROUND (fp) << 4) | FACE_FOREGROUND (fp); | |
| 9572 | 593 } |
| 594 | |
| 595 static | |
| 596 IT_write_glyphs (GLYPH *str, int len) | |
| 597 { | |
| 598 int newface; | |
| 13179 | 599 int ch, l = len; |
| 600 unsigned char *buf, *bp; | |
| 601 | |
| 602 if (len == 0) return; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
603 |
| 13179 | 604 buf = bp = alloca (len * 2); |
| 605 | |
| 606 while (--l >= 0) | |
| 9572 | 607 { |
| 608 newface = FAST_GLYPH_FACE (*str); | |
| 13179 | 609 if (newface != screen_face) |
| 610 IT_set_face (newface); | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
611 ch = FAST_GLYPH_CHAR (*str); |
| 13179 | 612 *bp++ = (unsigned char)ch; |
| 613 *bp++ = ScreenAttrib; | |
| 614 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
615 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
616 fputc (ch, termscript); |
| 13179 | 617 str++; |
| 9572 | 618 } |
| 13179 | 619 |
| 620 mouse_off_maybe (); | |
| 621 dosmemput (buf, 2 * len, | |
| 622 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | |
| 623 new_pos_X += len; | |
| 9572 | 624 } |
| 625 | |
| 626 static | |
| 627 IT_clear_end_of_line (first_unused) | |
| 628 { | |
| 13179 | 629 char *spaces, *sp; |
| 630 int i, j; | |
| 631 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
632 IT_set_face (0); |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
633 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
634 fprintf (termscript, "<CLR:EOL>"); |
| 13179 | 635 i = (j = screen_size_X - new_pos_X) * 2; |
| 636 spaces = sp = alloca (i); | |
| 637 | |
| 638 while (--j >= 0) | |
| 639 { | |
| 640 *sp++ = ' '; | |
| 641 *sp++ = ScreenAttrib; | |
| 642 } | |
| 643 | |
| 644 mouse_off_maybe (); | |
| 645 dosmemput (spaces, i, | |
| 646 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | |
| 647 } | |
| 648 | |
| 649 static | |
| 650 IT_clear_screen (void) | |
| 651 { | |
| 652 if (termscript) | |
| 653 fprintf (termscript, "<CLR:SCR>"); | |
| 654 IT_set_face (0); | |
| 655 mouse_off (); | |
| 656 ScreenClear (); | |
| 657 new_pos_X = new_pos_Y = 0; | |
| 658 } | |
| 659 | |
| 660 static | |
| 661 IT_clear_to_end (void) | |
| 662 { | |
| 663 if (termscript) | |
| 664 fprintf (termscript, "<CLR:EOS>"); | |
| 665 | |
| 666 while (new_pos_Y < screen_size_Y) { | |
| 667 new_pos_X = 0; | |
| 668 IT_clear_end_of_line (0); | |
| 669 new_pos_Y++; | |
| 670 } | |
| 9572 | 671 } |
| 672 | |
| 673 static | |
| 674 IT_cursor_to (int y, int x) | |
| 675 { | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
676 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
677 fprintf (termscript, "\n<XY=%dx%d>", x, y); |
| 13179 | 678 new_pos_X = x; |
| 679 new_pos_Y = y; | |
| 9572 | 680 } |
| 681 | |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
682 static int cursor_cleared; |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
683 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
684 static |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
685 IT_display_cursor (int on) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
686 { |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
687 if (on && cursor_cleared) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
688 { |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
689 ScreenSetCursor (current_pos_Y, current_pos_X); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
690 cursor_cleared = 0; |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
691 } |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
692 else if (!on && !cursor_cleared) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
693 { |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
694 ScreenSetCursor (-1, -1); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
695 cursor_cleared = 1; |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
696 } |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
697 } |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
698 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
699 /* Emacs calls cursor-movement functions a lot when it updates the |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
700 display (probably a legacy of old terminals where you cannot |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
701 update a screen line without first moving the cursor there). |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
702 However, cursor movement is expensive on MSDOS (it calls a slow |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
703 BIOS function and requires 2 mode switches), while actual screen |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
704 updates access the video memory directly and don't depend on |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
705 cursor position. To avoid slowing down the redisplay, we cheat: |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
706 all functions that move the cursor only set internal variables |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
707 which record the cursor position, whereas the cursor is only |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
708 moved to its final position whenever screen update is complete. |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
709 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
710 `IT_cmgoto' is called from the keyboard reading loop and when the |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
711 frame update is complete. This means that we are ready for user |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
712 input, so we update the cursor position to show where the point is, |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
713 and also make the mouse pointer visible. |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
714 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
715 Special treatment is required when the cursor is in the echo area, |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
716 to put the cursor at the end of the text displayed there. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
717 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
718 static |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
719 IT_cmgoto (f) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
720 FRAME_PTR f; |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
721 { |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
722 /* Only set the cursor to where it should be if the display is |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
723 already in sync with the window contents. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
724 int update_cursor_pos = MODIFF == unchanged_modified; |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
725 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
726 /* If we are in the echo area, put the cursor at the end of text. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
727 if (!update_cursor_pos |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
728 && XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top) <= new_pos_Y) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
729 { |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
730 new_pos_X = FRAME_DESIRED_GLYPHS (f)->used[new_pos_Y]; |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
731 update_cursor_pos = 1; |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
732 } |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
733 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
734 if (update_cursor_pos |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
735 && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y)) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
736 { |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
737 ScreenSetCursor (current_pos_Y = new_pos_Y, current_pos_X = new_pos_X); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
738 if (termscript) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
739 fprintf (termscript, "\n<CURSOR:%dx%d>", current_pos_X, current_pos_Y); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
740 } |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
741 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
742 /* Maybe cursor is invisible, so make it visible. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
743 IT_display_cursor (1); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
744 |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
745 /* Mouse pointer should be always visible if we are waiting for |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
746 keyboard input. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
747 if (!mouse_visible) |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
748 mouse_on (); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
749 } |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
750 |
| 13179 | 751 static |
| 9572 | 752 IT_reassert_line_highlight (new, vpos) |
| 753 int new, vpos; | |
| 754 { | |
| 755 highlight = new; | |
| 756 IT_set_face (0); /* To possibly clear the highlighting. */ | |
| 757 } | |
| 758 | |
| 759 static | |
| 760 IT_change_line_highlight (new_highlight, vpos, first_unused_hpos) | |
| 761 { | |
| 762 highlight = new_highlight; | |
| 763 IT_set_face (0); /* To possibly clear the highlighting. */ | |
| 764 IT_cursor_to (vpos, 0); | |
| 765 IT_clear_end_of_line (first_unused_hpos); | |
| 766 } | |
| 767 | |
| 768 static | |
| 769 IT_update_begin () | |
| 770 { | |
| 771 highlight = 0; | |
| 772 IT_set_face (0); /* To possibly clear the highlighting. */ | |
| 13179 | 773 screen_face = -1; |
| 774 } | |
| 775 | |
| 776 static | |
| 777 IT_update_end () | |
| 778 { | |
| 9572 | 779 } |
| 780 | |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
781 /* This was more or less copied from xterm.c |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
782 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
783 Nowadays, the corresponding function under X is `x_set_menu_bar_lines_1' |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
784 on xfns.c */ |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
785 |
| 9572 | 786 static void |
| 787 IT_set_menu_bar_lines (window, n) | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
788 Lisp_Object window; |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
789 int n; |
| 9572 | 790 { |
| 791 struct window *w = XWINDOW (window); | |
| 792 | |
|
13646
7714b87119a3
(IT_set_menu_bar_lines): Clear last_modified field.
Richard M. Stallman <rms@gnu.org>
parents:
13642
diff
changeset
|
793 XSETFASTINT (w->last_modified, 0); |
|
16210
4c03f0e575d7
(IT_set_menu_bar_lines): Clear last_overlay_modified field.
Richard M. Stallman <rms@gnu.org>
parents:
15627
diff
changeset
|
794 XSETFASTINT (w->last_overlay_modified, 0); |
| 9572 | 795 XSETFASTINT (w->top, XFASTINT (w->top) + n); |
| 796 XSETFASTINT (w->height, XFASTINT (w->height) - n); | |
| 797 | |
| 798 /* Handle just the top child in a vertical split. */ | |
| 799 if (!NILP (w->vchild)) | |
| 800 IT_set_menu_bar_lines (w->vchild, n); | |
| 801 | |
| 802 /* Adjust all children in a horizontal split. */ | |
| 803 for (window = w->hchild; !NILP (window); window = w->next) | |
| 804 { | |
| 805 w = XWINDOW (window); | |
| 806 IT_set_menu_bar_lines (window, n); | |
| 807 } | |
| 808 } | |
| 809 | |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
810 /* This was copied from xfns.c */ |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
811 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
812 void |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
813 x_set_menu_bar_lines (f, value, oldval) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
814 struct frame *f; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
815 Lisp_Object value, oldval; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
816 { |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
817 int nlines; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
818 int olines = FRAME_MENU_BAR_LINES (f); |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
819 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
820 /* Right now, menu bars don't work properly in minibuf-only frames; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
821 most of the commands try to apply themselves to the minibuffer |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
822 frame itslef, and get an error because you can't switch buffers |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
823 in or split the minibuffer window. */ |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
824 if (FRAME_MINIBUF_ONLY_P (f)) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
825 return; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
826 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
827 if (INTEGERP (value)) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
828 nlines = XINT (value); |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
829 else |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
830 nlines = 0; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
831 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
832 FRAME_MENU_BAR_LINES (f) = nlines; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
833 IT_set_menu_bar_lines (f->root_window, nlines - olines); |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
834 } |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
835 |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
836 /* IT_set_terminal_modes is called when emacs is started, |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
837 resumed, and whenever the screen is redrawn! */ |
| 13179 | 838 |
| 839 static | |
| 840 IT_set_terminal_modes (void) | |
| 841 { | |
| 842 char *colors; | |
| 843 FRAME_PTR f; | |
| 844 struct face *fp; | |
| 845 | |
| 846 if (termscript) | |
| 847 fprintf (termscript, "\n<SET_TERM>"); | |
| 848 highlight = 0; | |
| 849 | |
| 850 screen_size_X = ScreenCols (); | |
| 851 screen_size_Y = ScreenRows (); | |
| 852 screen_size = screen_size_X * screen_size_Y; | |
| 853 | |
| 854 new_pos_X = new_pos_Y = 0; | |
| 855 current_pos_X = current_pos_Y = -1; | |
| 856 | |
| 857 if (term_setup_done) | |
| 858 return; | |
| 859 term_setup_done = 1; | |
| 860 | |
| 861 startup_screen_size_X = screen_size_X; | |
| 862 startup_screen_size_Y = screen_size_Y; | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
863 startup_screen_attrib = ScreenAttrib; |
| 13179 | 864 |
| 865 ScreenGetCursor (&startup_pos_Y, &startup_pos_X); | |
| 866 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); | |
| 867 | |
| 868 if (termscript) | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
869 fprintf (termscript, "<SCREEN SAVED (dimensions=%dx%d)>\n", |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
870 screen_size_X, screen_size_Y); |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
871 |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
872 bright_bg (); |
| 13179 | 873 } |
| 874 | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
875 /* IT_reset_terminal_modes is called when emacs is |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
876 suspended or killed. */ |
| 13179 | 877 |
| 878 static | |
| 879 IT_reset_terminal_modes (void) | |
| 880 { | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
881 int display_row_start = (int) ScreenPrimary; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
882 int saved_row_len = startup_screen_size_X * 2; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
883 int update_row_len = ScreenCols () * 2; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
884 int current_rows = ScreenRows (); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
885 int to_next_row = update_row_len; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
886 unsigned char *saved_row = startup_screen_buffer; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
887 int cursor_pos_X = ScreenCols () - 1; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
888 int cursor_pos_Y = ScreenRows () - 1; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
889 |
| 13179 | 890 if (termscript) |
| 13274 | 891 fprintf (termscript, "\n<RESET_TERM>"); |
| 13179 | 892 |
| 893 highlight = 0; | |
| 894 | |
| 895 if (!term_setup_done) | |
| 896 return; | |
| 897 | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
898 mouse_off (); |
|
16837
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
899 |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
900 /* Leave the video system in the same state as we found it, |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
901 as far as the blink/bright-background bit is concerned. */ |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
902 maybe_enable_blinking (); |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
903 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
904 /* We have a situation here. |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
905 We cannot just do ScreenUpdate(startup_screen_buffer) because |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
906 the luser could have changed screen dimensions inside Emacs |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
907 and failed (or didn't want) to restore them before killing |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
908 Emacs. ScreenUpdate() uses the *current* screen dimensions and |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
909 thus will happily use memory outside what was allocated for |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
910 `startup_screen_buffer'. |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
911 Thus we only restore as much as the current screen dimensions |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
912 can hold, and clear the rest (if the saved screen is smaller than |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
913 the current) with the color attribute saved at startup. The cursor |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
914 is also restored within the visible dimensions. */ |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
915 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
916 ScreenAttrib = startup_screen_attrib; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
917 ScreenClear (); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
918 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
919 if (update_row_len > saved_row_len) |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
920 update_row_len = saved_row_len; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
921 if (current_rows > startup_screen_size_Y) |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
922 current_rows = startup_screen_size_Y; |
| 13179 | 923 |
| 924 if (termscript) | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
925 fprintf (termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n", |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
926 update_row_len / 2, current_rows); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
927 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
928 while (current_rows--) |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
929 { |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
930 dosmemput (saved_row, update_row_len, display_row_start); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
931 saved_row += saved_row_len; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
932 display_row_start += to_next_row; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
933 } |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
934 if (startup_pos_X < cursor_pos_X) |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
935 cursor_pos_X = startup_pos_X; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
936 if (startup_pos_Y < cursor_pos_Y) |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
937 cursor_pos_Y = startup_pos_Y; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
938 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
939 ScreenSetCursor (cursor_pos_Y, cursor_pos_X); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
940 xfree (startup_screen_buffer); |
| 13179 | 941 |
| 942 term_setup_done = 0; | |
| 943 } | |
| 944 | |
| 945 static | |
| 946 IT_set_terminal_window (void) | |
| 947 { | |
| 948 } | |
| 949 | |
| 9572 | 950 void |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
951 IT_set_frame_parameters (f, alist) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
952 FRAME_PTR f; |
| 9572 | 953 Lisp_Object alist; |
| 954 { | |
| 955 Lisp_Object tail; | |
| 956 int redraw; | |
| 957 extern unsigned long load_color (); | |
| 958 | |
| 959 redraw = 0; | |
| 960 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) | |
| 961 { | |
| 962 Lisp_Object elt, prop, val; | |
| 963 | |
| 964 elt = Fcar (tail); | |
| 965 prop = Fcar (elt); | |
| 966 val = Fcdr (elt); | |
| 967 CHECK_SYMBOL (prop, 1); | |
| 968 | |
| 969 if (EQ (prop, intern ("foreground-color"))) | |
| 970 { | |
| 971 unsigned long new_color = load_color (f, val); | |
| 972 if (new_color != ~0) | |
| 973 { | |
| 974 FRAME_FOREGROUND_PIXEL (f) = new_color; | |
| 975 redraw = 1; | |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
976 if (termscript) |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
977 fprintf (termscript, "<FGCOLOR %d>\n", new_color); |
| 9572 | 978 } |
| 979 } | |
| 980 else if (EQ (prop, intern ("background-color"))) | |
| 981 { | |
| 982 unsigned long new_color = load_color (f, val); | |
| 983 if (new_color != ~0) | |
| 984 { | |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
985 FRAME_BACKGROUND_PIXEL (f) = new_color; |
| 9572 | 986 redraw = 1; |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
987 if (termscript) |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
988 fprintf (termscript, "<BGCOLOR %d>\n", new_color); |
| 9572 | 989 } |
| 990 } | |
| 991 else if (EQ (prop, intern ("menu-bar-lines"))) | |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
992 x_set_menu_bar_lines (f, val, 0); |
| 9572 | 993 } |
| 994 | |
| 995 if (redraw) | |
| 996 { | |
| 997 recompute_basic_faces (f); | |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
998 if (f == selected_frame) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
999 redraw_frame (f); |
| 9572 | 1000 } |
| 1001 } | |
| 1002 | |
| 13179 | 1003 #endif /* !HAVE_X_WINDOWS */ |
| 9572 | 1004 |
| 1005 | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1006 /* Do we need the internal terminal? */ |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1007 |
| 5503 | 1008 void |
| 1009 internal_terminal_init () | |
| 1010 { | |
| 1011 char *term = getenv ("TERM"); | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1012 char *colors; |
| 13179 | 1013 |
| 9572 | 1014 #ifdef HAVE_X_WINDOWS |
| 1015 if (!inhibit_window_system) | |
| 1016 return; | |
| 1017 #endif | |
| 1018 | |
| 5503 | 1019 internal_terminal |
| 1020 = (!noninteractive) && term && !strcmp (term, "internal"); | |
| 9572 | 1021 |
| 13179 | 1022 if (getenv ("EMACSTEST")) |
| 13274 | 1023 termscript = fopen (getenv ("EMACSTEST"), "wt"); |
| 13179 | 1024 |
| 9572 | 1025 #ifndef HAVE_X_WINDOWS |
| 13179 | 1026 if (!internal_terminal || inhibit_window_system) |
| 9572 | 1027 { |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1028 selected_frame->output_method = output_termcap; |
| 13179 | 1029 return; |
| 1030 } | |
| 9572 | 1031 |
| 13179 | 1032 Vwindow_system = intern ("pc"); |
| 1033 Vwindow_system_version = make_number (1); | |
| 1034 | |
| 1035 bzero (&the_only_x_display, sizeof the_only_x_display); | |
| 1036 the_only_x_display.background_pixel = 7; /* White */ | |
| 1037 the_only_x_display.foreground_pixel = 0; /* Black */ | |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1038 bright_bg (); |
| 13274 | 1039 colors = getenv ("EMACSCOLORS"); |
| 13179 | 1040 if (colors && strlen (colors) >= 2) |
| 1041 { | |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1042 /* The colors use 4 bits each (we enable bright background). */ |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1043 if (isdigit (colors[0])) |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1044 colors[0] -= '0'; |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1045 else if (isxdigit (colors[0])) |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1046 colors[0] -= (isupper (colors[0]) ? 'A' : 'a') - 10; |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
1047 if (colors[0] >= 0 && colors[0] < 16) |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
1048 the_only_x_display.foreground_pixel = colors[0]; |
|
15341
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1049 if (isdigit (colors[1])) |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1050 colors[1] -= '0'; |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1051 else if (isxdigit (colors[1])) |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1052 colors[1] -= (isupper (colors[1]) ? 'A' : 'a') - 10; |
|
8a0f5a5937e5
(bright_bg): New function, enables bright background colors.
Richard M. Stallman <rms@gnu.org>
parents:
15222
diff
changeset
|
1053 if (colors[1] >= 0 && colors[1] < 16) |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
1054 the_only_x_display.background_pixel = colors[1]; |
| 13179 | 1055 } |
| 1056 the_only_x_display.line_height = 1; | |
|
13625
397f07418271
(internal_terminal_init): Initialize the_only_x_display.font.
Richard M. Stallman <rms@gnu.org>
parents:
13624
diff
changeset
|
1057 the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */ |
| 9572 | 1058 |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1059 init_frame_faces (selected_frame); |
| 13179 | 1060 |
| 1061 ring_bell_hook = IT_ring_bell; | |
| 1062 write_glyphs_hook = IT_write_glyphs; | |
| 1063 cursor_to_hook = raw_cursor_to_hook = IT_cursor_to; | |
| 1064 clear_to_end_hook = IT_clear_to_end; | |
| 1065 clear_end_of_line_hook = IT_clear_end_of_line; | |
| 1066 clear_frame_hook = IT_clear_screen; | |
| 1067 change_line_highlight_hook = IT_change_line_highlight; | |
| 1068 update_begin_hook = IT_update_begin; | |
| 1069 update_end_hook = IT_update_end; | |
| 1070 reassert_line_highlight_hook = IT_reassert_line_highlight; | |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
1071 frame_up_to_date_hook = IT_cmgoto; /* position cursor when update is done */ |
| 13179 | 1072 |
| 1073 /* These hooks are called by term.c without being checked. */ | |
| 1074 set_terminal_modes_hook = IT_set_terminal_modes; | |
| 1075 reset_terminal_modes_hook = IT_reset_terminal_modes; | |
| 1076 set_terminal_window_hook = IT_set_terminal_window; | |
| 9572 | 1077 #endif |
| 5503 | 1078 } |
| 13179 | 1079 |
| 1080 dos_get_saved_screen (screen, rows, cols) | |
| 1081 char **screen; | |
| 1082 int *rows; | |
| 1083 int *cols; | |
| 1084 { | |
| 1085 #ifndef HAVE_X_WINDOWS | |
| 1086 *screen = startup_screen_buffer; | |
| 1087 *cols = startup_screen_size_X; | |
| 1088 *rows = startup_screen_size_Y; | |
| 1089 return 1; | |
| 1090 #else | |
| 1091 return 0; | |
| 1092 #endif | |
| 1093 } | |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1094 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1095 #ifndef HAVE_X_WINDOWS |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1096 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1097 /* We are not X, but we can emulate it well enough for our needs... */ |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1098 void |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1099 check_x (void) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1100 { |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1101 if (! FRAME_MSDOS_P (selected_frame)) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1102 error ("Not running under a windows system"); |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1103 } |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1104 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1105 #endif |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
1106 |
| 13274 | 1107 |
| 13179 | 1108 /* ----------------------- Keyboard control ---------------------- |
| 1109 * | |
| 1110 * Keymaps reflect the following keyboard layout: | |
| 1111 * | |
| 1112 * 0 1 2 3 4 5 6 7 8 9 10 11 12 BS | |
| 1113 * TAB 15 16 17 18 19 20 21 22 23 24 25 26 (41) | |
| 1114 * CLOK 30 31 32 33 34 35 36 37 38 39 40 (41) RET | |
| 1115 * SH () 45 46 47 48 49 50 51 52 53 54 SHIFT | |
| 1116 * SPACE | |
| 1117 */ | |
| 1118 | |
| 1119 static int extended_kbd; /* 101 (102) keyboard present. */ | |
| 1120 | |
| 1121 struct dos_keyboard_map | |
| 1122 { | |
| 1123 char *unshifted; | |
| 1124 char *shifted; | |
| 1125 char *alt_gr; | |
| 1126 }; | |
| 1127 | |
|
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
1128 |
| 13179 | 1129 static struct dos_keyboard_map us_keyboard = { |
| 1130 /* 0 1 2 3 4 5 */ | |
| 1131 /* 01234567890123456789012345678901234567890 12345678901234 */ | |
| 1132 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ", | |
| 1133 /* 0123456789012345678901234567890123456789 012345678901234 */ | |
| 1134 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ", | |
| 1135 0 /* no Alt-Gr key */ | |
| 1136 }; | |
| 1137 | |
| 1138 static struct dos_keyboard_map fr_keyboard = { | |
| 1139 /* 0 1 2 3 4 5 */ | |
| 1140 /* 012 3456789012345678901234567890123456789012345678901234 */ | |
| 1141 "ý&‚\",(-Š_€…)= azertyuiop^$ qsdfghjklm—* wxcvbnm;:! ", | |
| 1142 /* 0123456789012345678901234567890123456789012345678901234 */ | |
| 1143 " 1234567890ø+ AZERTYUIOPùœ QSDFGHJKLM%æ WXCVBN?./õ ", | |
| 1144 /* 01234567 89012345678901234567890123456789012345678901234 */ | |
| 1145 " ~#{[|`\\^@]} Ï " | |
| 1146 }; | |
| 1147 | |
| 1148 static struct dos_keyboard_map dk_keyboard = { | |
| 1149 /* 0 1 2 3 4 5 */ | |
| 1150 /* 0123456789012345678901234567890123456789012345678901234 */ | |
| 1151 "«1234567890+| qwertyuiop†~ asdfghjkl‘›' zxcvbnm,.- ", | |
| 1152 /* 01 23456789012345678901234567890123456789012345678901234 */ | |
| 1153 "õ!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL’* ZXCVBNM;:_ ", | |
| 1154 /* 0123456789012345678901234567890123456789012345678901234 */ | |
| 1155 " @œ$ {[]} | " | |
| 1156 }; | |
| 1157 | |
| 1158 static struct keyboard_layout_list | |
| 1159 { | |
| 1160 int country_code; | |
| 1161 struct dos_keyboard_map *keyboard_map; | |
| 13274 | 1162 } keyboard_layout_list[] = |
| 1163 { | |
| 1164 1, &us_keyboard, | |
| 1165 33, &fr_keyboard, | |
| 1166 45, &dk_keyboard | |
| 13179 | 1167 }; |
| 1168 | |
| 1169 static struct dos_keyboard_map *keyboard; | |
| 1170 static int keyboard_map_all; | |
|
16763
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1171 static int international_keyboard; |
|
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1172 |
|
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1173 int |
| 13179 | 1174 dos_set_keyboard (code, always) |
| 1175 int code; | |
| 1176 int always; | |
|
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1177 { |
| 13179 | 1178 int i; |
|
16763
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1179 union REGS regs; |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1180 |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1181 /* See if Keyb.Com is installed (for international keyboard support). */ |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1182 regs.x.ax = 0xad80; |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1183 int86 (0x2f, ®s, ®s); |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1184 if (regs.h.al == 0xff) |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1185 international_keyboard = 1; |
|
13624
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1186 |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1187 /* Initialize to US settings, for countries that don't have their own. */ |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1188 keyboard = keyboard_layout_list[0].keyboard_map; |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1189 keyboard_map_all = always; |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1190 dos_keyboard_layout = 1; |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
1191 |
| 13179 | 1192 for (i = 0; i < (sizeof (keyboard_layout_list)/sizeof (struct keyboard_layout_list)); i++) |
| 1193 if (code == keyboard_layout_list[i].country_code) | |
| 1194 { | |
| 1195 keyboard = keyboard_layout_list[i].keyboard_map; | |
| 1196 keyboard_map_all = always; | |
| 1197 dos_keyboard_layout = code; | |
| 1198 return 1; | |
| 1199 } | |
|
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1200 return 0; |
|
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
1201 } |
| 13274 | 1202 |
| 13179 | 1203 #define Ignore 0x0000 |
| 1204 #define Normal 0x0000 /* normal key - alt changes scan-code */ | |
| 1205 #define FctKey 0x1000 /* func key if c == 0, else c */ | |
| 1206 #define Special 0x2000 /* func key even if c != 0 */ | |
| 1207 #define ModFct 0x3000 /* special if mod-keys, else 'c' */ | |
| 1208 #define Map 0x4000 /* alt scan-code, map to unshift/shift key */ | |
| 1209 #define KeyPad 0x5000 /* map to insert/kp-0 depending on c == 0xe0 */ | |
| 1210 #define Grey 0x6000 /* Grey keypad key */ | |
| 1211 | |
| 1212 #define Alt 0x0100 /* alt scan-code */ | |
| 1213 #define Ctrl 0x0200 /* ctrl scan-code */ | |
| 1214 #define Shift 0x0400 /* shift scan-code */ | |
| 1215 | |
| 1216 static struct | |
| 1217 { | |
| 1218 unsigned char char_code; /* normal code */ | |
| 1219 unsigned char meta_code; /* M- code */ | |
| 1220 unsigned char keypad_code; /* keypad code */ | |
| 1221 unsigned char editkey_code; /* edit key */ | |
| 1222 } keypad_translate_map[] = { | |
| 1223 '0', '0', 0xb0, /* kp-0 */ 0x63, /* insert */ | |
| 1224 '1', '1', 0xb1, /* kp-1 */ 0x57, /* end */ | |
| 1225 '2', '2', 0xb2, /* kp-2 */ 0x54, /* down */ | |
| 1226 '3', '3', 0xb3, /* kp-3 */ 0x56, /* next */ | |
| 1227 '4', '4', 0xb4, /* kp-4 */ 0x51, /* left */ | |
| 1228 '5', '5', 0xb5, /* kp-5 */ 0xb5, /* kp-5 */ | |
| 1229 '6', '6', 0xb6, /* kp-6 */ 0x53, /* right */ | |
| 1230 '7', '7', 0xb7, /* kp-7 */ 0x50, /* home */ | |
| 1231 '8', '8', 0xb8, /* kp-8 */ 0x52, /* up */ | |
| 1232 '9', '9', 0xb9, /* kp-9 */ 0x55, /* prior */ | |
| 1233 '.', '-', 0xae, /* kp-decimal */ 0xff /* delete */ | |
| 1234 }; | |
| 1235 | |
| 1236 static struct | |
| 1237 { | |
| 1238 unsigned char char_code; /* normal code */ | |
| 1239 unsigned char keypad_code; /* keypad code */ | |
| 1240 } grey_key_translate_map[] = { | |
| 1241 '/', 0xaf, /* kp-decimal */ | |
| 1242 '*', 0xaa, /* kp-multiply */ | |
| 1243 '-', 0xad, /* kp-subtract */ | |
| 1244 '+', 0xab, /* kp-add */ | |
| 1245 '\r', 0x8d /* kp-enter */ | |
| 1246 }; | |
| 1247 | |
| 1248 static unsigned short | |
| 1249 ibmpc_translate_map[] = | |
|
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
1250 { |
| 13179 | 1251 /* --------------- 00 to 0f --------------- */ |
| 1252 Normal | 0xff, /* Ctrl Break + Alt-NNN */ | |
| 1253 Alt | ModFct | 0x1b, /* Escape */ | |
| 1254 Normal | 1, /* '1' */ | |
| 1255 Normal | 2, /* '2' */ | |
| 1256 Normal | 3, /* '3' */ | |
| 1257 Normal | 4, /* '4' */ | |
| 1258 Normal | 5, /* '5' */ | |
| 1259 Normal | 6, /* '6' */ | |
| 1260 Normal | 7, /* '7' */ | |
| 1261 Normal | 8, /* '8' */ | |
| 1262 Normal | 9, /* '9' */ | |
| 1263 Normal | 10, /* '0' */ | |
| 1264 Normal | 11, /* '-' */ | |
| 1265 Normal | 12, /* '=' */ | |
| 1266 Special | 0x08, /* Backspace */ | |
| 1267 ModFct | 0x74, /* Tab/Backtab */ | |
| 1268 | |
| 1269 /* --------------- 10 to 1f --------------- */ | |
| 1270 Map | 15, /* 'q' */ | |
| 1271 Map | 16, /* 'w' */ | |
| 1272 Map | 17, /* 'e' */ | |
| 1273 Map | 18, /* 'r' */ | |
| 1274 Map | 19, /* 't' */ | |
| 1275 Map | 20, /* 'y' */ | |
| 1276 Map | 21, /* 'u' */ | |
| 1277 Map | 22, /* 'i' */ | |
| 1278 Map | 23, /* 'o' */ | |
| 1279 Map | 24, /* 'p' */ | |
| 1280 Map | 25, /* '[' */ | |
| 1281 Map | 26, /* ']' */ | |
| 1282 ModFct | 0x0d, /* Return */ | |
| 1283 Ignore, /* Ctrl */ | |
| 1284 Map | 30, /* 'a' */ | |
| 1285 Map | 31, /* 's' */ | |
| 1286 | |
| 1287 /* --------------- 20 to 2f --------------- */ | |
| 1288 Map | 32, /* 'd' */ | |
| 1289 Map | 33, /* 'f' */ | |
| 1290 Map | 34, /* 'g' */ | |
| 1291 Map | 35, /* 'h' */ | |
| 1292 Map | 36, /* 'j' */ | |
| 1293 Map | 37, /* 'k' */ | |
| 1294 Map | 38, /* 'l' */ | |
| 1295 Map | 39, /* ';' */ | |
| 1296 Map | 40, /* '\'' */ | |
| 1297 Map | 0, /* '`' */ | |
| 1298 Ignore, /* Left shift */ | |
| 1299 Map | 41, /* '\\' */ | |
| 1300 Map | 45, /* 'z' */ | |
| 1301 Map | 46, /* 'x' */ | |
| 1302 Map | 47, /* 'c' */ | |
| 1303 Map | 48, /* 'v' */ | |
| 1304 | |
| 1305 /* --------------- 30 to 3f --------------- */ | |
| 1306 Map | 49, /* 'b' */ | |
| 1307 Map | 50, /* 'n' */ | |
| 1308 Map | 51, /* 'm' */ | |
| 1309 Map | 52, /* ',' */ | |
| 1310 Map | 53, /* '.' */ | |
| 1311 Map | 54, /* '/' */ | |
| 1312 Ignore, /* Right shift */ | |
| 1313 Grey | 1, /* Grey * */ | |
| 1314 Ignore, /* Alt */ | |
| 1315 Normal | ' ', /* ' ' */ | |
| 1316 Ignore, /* Caps Lock */ | |
| 1317 FctKey | 0xbe, /* F1 */ | |
| 1318 FctKey | 0xbf, /* F2 */ | |
| 1319 FctKey | 0xc0, /* F3 */ | |
| 1320 FctKey | 0xc1, /* F4 */ | |
| 1321 FctKey | 0xc2, /* F5 */ | |
| 1322 | |
| 1323 /* --------------- 40 to 4f --------------- */ | |
| 1324 FctKey | 0xc3, /* F6 */ | |
| 1325 FctKey | 0xc4, /* F7 */ | |
| 1326 FctKey | 0xc5, /* F8 */ | |
| 1327 FctKey | 0xc6, /* F9 */ | |
| 1328 FctKey | 0xc7, /* F10 */ | |
| 1329 Ignore, /* Num Lock */ | |
| 1330 Ignore, /* Scroll Lock */ | |
| 1331 KeyPad | 7, /* Home */ | |
| 1332 KeyPad | 8, /* Up */ | |
| 1333 KeyPad | 9, /* Page Up */ | |
| 1334 Grey | 2, /* Grey - */ | |
| 1335 KeyPad | 4, /* Left */ | |
| 1336 KeyPad | 5, /* Keypad 5 */ | |
| 1337 KeyPad | 6, /* Right */ | |
| 1338 Grey | 3, /* Grey + */ | |
| 1339 KeyPad | 1, /* End */ | |
| 1340 | |
| 1341 /* --------------- 50 to 5f --------------- */ | |
| 1342 KeyPad | 2, /* Down */ | |
| 1343 KeyPad | 3, /* Page Down */ | |
| 1344 KeyPad | 0, /* Insert */ | |
| 1345 KeyPad | 10, /* Delete */ | |
| 1346 Shift | FctKey | 0xbe, /* (Shift) F1 */ | |
| 1347 Shift | FctKey | 0xbf, /* (Shift) F2 */ | |
| 1348 Shift | FctKey | 0xc0, /* (Shift) F3 */ | |
| 1349 Shift | FctKey | 0xc1, /* (Shift) F4 */ | |
| 1350 Shift | FctKey | 0xc2, /* (Shift) F5 */ | |
| 1351 Shift | FctKey | 0xc3, /* (Shift) F6 */ | |
| 1352 Shift | FctKey | 0xc4, /* (Shift) F7 */ | |
| 1353 Shift | FctKey | 0xc5, /* (Shift) F8 */ | |
| 1354 Shift | FctKey | 0xc6, /* (Shift) F9 */ | |
| 1355 Shift | FctKey | 0xc7, /* (Shift) F10 */ | |
| 1356 Ctrl | FctKey | 0xbe, /* (Ctrl) F1 */ | |
| 1357 Ctrl | FctKey | 0xbf, /* (Ctrl) F2 */ | |
|
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
1358 |
| 13179 | 1359 /* --------------- 60 to 6f --------------- */ |
| 1360 Ctrl | FctKey | 0xc0, /* (Ctrl) F3 */ | |
| 1361 Ctrl | FctKey | 0xc1, /* (Ctrl) F4 */ | |
| 1362 Ctrl | FctKey | 0xc2, /* (Ctrl) F5 */ | |
| 1363 Ctrl | FctKey | 0xc3, /* (Ctrl) F6 */ | |
| 1364 Ctrl | FctKey | 0xc4, /* (Ctrl) F7 */ | |
| 1365 Ctrl | FctKey | 0xc5, /* (Ctrl) F8 */ | |
| 1366 Ctrl | FctKey | 0xc6, /* (Ctrl) F9 */ | |
| 1367 Ctrl | FctKey | 0xc7, /* (Ctrl) F10 */ | |
| 1368 Alt | FctKey | 0xbe, /* (Alt) F1 */ | |
| 1369 Alt | FctKey | 0xbf, /* (Alt) F2 */ | |
| 1370 Alt | FctKey | 0xc0, /* (Alt) F3 */ | |
| 1371 Alt | FctKey | 0xc1, /* (Alt) F4 */ | |
| 1372 Alt | FctKey | 0xc2, /* (Alt) F5 */ | |
| 1373 Alt | FctKey | 0xc3, /* (Alt) F6 */ | |
| 1374 Alt | FctKey | 0xc4, /* (Alt) F7 */ | |
| 1375 Alt | FctKey | 0xc5, /* (Alt) F8 */ | |
| 1376 | |
| 1377 /* --------------- 70 to 7f --------------- */ | |
| 1378 Alt | FctKey | 0xc6, /* (Alt) F9 */ | |
| 1379 Alt | FctKey | 0xc7, /* (Alt) F10 */ | |
| 1380 Ctrl | FctKey | 0x6d, /* (Ctrl) Sys Rq */ | |
| 1381 Ctrl | KeyPad | 4, /* (Ctrl) Left */ | |
| 1382 Ctrl | KeyPad | 6, /* (Ctrl) Right */ | |
| 1383 Ctrl | KeyPad | 1, /* (Ctrl) End */ | |
| 1384 Ctrl | KeyPad | 3, /* (Ctrl) Page Down */ | |
| 1385 Ctrl | KeyPad | 7, /* (Ctrl) Home */ | |
| 1386 Alt | Map | 1, /* '1' */ | |
| 1387 Alt | Map | 2, /* '2' */ | |
| 1388 Alt | Map | 3, /* '3' */ | |
| 1389 Alt | Map | 4, /* '4' */ | |
| 1390 Alt | Map | 5, /* '5' */ | |
| 1391 Alt | Map | 6, /* '6' */ | |
| 1392 Alt | Map | 7, /* '7' */ | |
| 1393 Alt | Map | 8, /* '8' */ | |
| 1394 | |
| 1395 /* --------------- 80 to 8f --------------- */ | |
| 1396 Alt | Map | 9, /* '9' */ | |
| 1397 Alt | Map | 10, /* '0' */ | |
| 1398 Alt | Map | 11, /* '-' */ | |
| 1399 Alt | Map | 12, /* '=' */ | |
| 1400 Ctrl | KeyPad | 9, /* (Ctrl) Page Up */ | |
| 1401 FctKey | 0xc8, /* F11 */ | |
| 1402 FctKey | 0xc9, /* F12 */ | |
| 1403 Shift | FctKey | 0xc8, /* (Shift) F11 */ | |
| 1404 Shift | FctKey | 0xc9, /* (Shift) F12 */ | |
| 1405 Ctrl | FctKey | 0xc8, /* (Ctrl) F11 */ | |
| 1406 Ctrl | FctKey | 0xc9, /* (Ctrl) F12 */ | |
| 1407 Alt | FctKey | 0xc8, /* (Alt) F11 */ | |
| 1408 Alt | FctKey | 0xc9, /* (Alt) F12 */ | |
| 1409 Ctrl | KeyPad | 8, /* (Ctrl) Up */ | |
| 1410 Ctrl | Grey | 2, /* (Ctrl) Grey - */ | |
| 1411 Ctrl | KeyPad | 5, /* (Ctrl) Keypad 5 */ | |
| 1412 | |
| 1413 /* --------------- 90 to 9f --------------- */ | |
| 1414 Ctrl | Grey | 3, /* (Ctrl) Grey + */ | |
| 1415 Ctrl | KeyPad | 2, /* (Ctrl) Down */ | |
| 1416 Ctrl | KeyPad | 0, /* (Ctrl) Insert */ | |
| 1417 Ctrl | KeyPad | 10, /* (Ctrl) Delete */ | |
| 1418 Ctrl | FctKey | 0x09, /* (Ctrl) Tab */ | |
| 1419 Ctrl | Grey | 0, /* (Ctrl) Grey / */ | |
| 1420 Ctrl | Grey | 1, /* (Ctrl) Grey * */ | |
| 1421 Alt | FctKey | 0x50, /* (Alt) Home */ | |
| 1422 Alt | FctKey | 0x52, /* (Alt) Up */ | |
| 1423 Alt | FctKey | 0x55, /* (Alt) Page Up */ | |
| 1424 Ignore, /* NO KEY */ | |
| 1425 Alt | FctKey | 0x51, /* (Alt) Left */ | |
| 1426 Ignore, /* NO KEY */ | |
| 1427 Alt | FctKey | 0x53, /* (Alt) Right */ | |
| 1428 Ignore, /* NO KEY */ | |
| 1429 Alt | FctKey | 0x57, /* (Alt) End */ | |
| 1430 | |
| 1431 /* --------------- a0 to af --------------- */ | |
| 1432 Alt | KeyPad | 2, /* (Alt) Down */ | |
| 1433 Alt | KeyPad | 3, /* (Alt) Page Down */ | |
| 1434 Alt | KeyPad | 0, /* (Alt) Insert */ | |
| 1435 Alt | KeyPad | 10, /* (Alt) Delete */ | |
| 1436 Alt | Grey | 0, /* (Alt) Grey / */ | |
| 1437 Alt | FctKey | 0x09, /* (Alt) Tab */ | |
| 1438 Alt | Grey | 4 /* (Alt) Keypad Enter */ | |
| 1439 }; | |
| 13274 | 1440 |
| 13179 | 1441 /* These bit-positions corresponds to values returned by BIOS */ |
| 1442 #define SHIFT_P 0x0003 /* two bits! */ | |
| 1443 #define CTRL_P 0x0004 | |
| 1444 #define ALT_P 0x0008 | |
| 1445 #define SCRLOCK_P 0x0010 | |
| 1446 #define NUMLOCK_P 0x0020 | |
| 1447 #define CAPSLOCK_P 0x0040 | |
| 1448 #define ALT_GR_P 0x0800 | |
| 1449 #define SUPER_P 0x4000 /* pseudo */ | |
| 1450 #define HYPER_P 0x8000 /* pseudo */ | |
| 1451 | |
| 1452 static int | |
| 1453 dos_get_modifiers (keymask) | |
| 1454 int *keymask; | |
| 5503 | 1455 { |
| 13179 | 1456 union REGS regs; |
| 1457 int mask; | |
| 1458 int modifiers = 0; | |
| 1459 | |
| 1460 /* Calculate modifier bits */ | |
| 1461 regs.h.ah = extended_kbd ? 0x12 : 0x02; | |
| 1462 int86 (0x16, ®s, ®s); | |
| 1463 | |
| 1464 if (!extended_kbd) | |
| 1465 { | |
| 1466 mask = regs.h.al & (SHIFT_P | CTRL_P | ALT_P | | |
| 1467 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | |
| 1468 } | |
| 1469 else | |
| 1470 { | |
| 1471 mask = regs.h.al & (SHIFT_P | | |
| 1472 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | |
| 1473 | |
| 1474 /* Do not break international keyboard support. */ | |
| 1475 /* When Keyb.Com is loaded, the right Alt key is */ | |
| 1476 /* used for accessing characters like { and } */ | |
| 1477 if (regs.h.ah & 2) /* Left ALT pressed ? */ | |
| 1478 mask |= ALT_P; | |
| 1479 | |
| 1480 if ((regs.h.ah & 8) != 0) /* Right ALT pressed ? */ | |
| 1481 { | |
| 1482 mask |= ALT_GR_P; | |
| 1483 if (dos_hyper_key == 1) | |
| 1484 { | |
| 1485 mask |= HYPER_P; | |
| 1486 modifiers |= hyper_modifier; | |
| 1487 } | |
| 1488 else if (dos_super_key == 1) | |
| 1489 { | |
| 1490 mask |= SUPER_P; | |
| 1491 modifiers |= super_modifier; | |
| 1492 } | |
|
16763
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1493 else if (!international_keyboard) |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1494 { |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1495 /* If Keyb.Com is NOT installed, let Right Alt behave |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1496 like the Left Alt. */ |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1497 mask &= ~ALT_GR_P; |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1498 mask |= ALT_P; |
|
e4f0f7fe8304
(dos_set_keyboard): Test whether KEYB.COM is installed
Richard M. Stallman <rms@gnu.org>
parents:
16613
diff
changeset
|
1499 } |
| 13179 | 1500 } |
| 1501 | |
|
15125
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
1502 if (regs.h.ah & 1) /* Left CTRL pressed ? */ |
| 13179 | 1503 mask |= CTRL_P; |
| 1504 | |
| 1505 if (regs.h.ah & 4) /* Right CTRL pressed ? */ | |
| 1506 { | |
| 1507 if (dos_hyper_key == 2) | |
| 1508 { | |
| 1509 mask |= HYPER_P; | |
| 1510 modifiers |= hyper_modifier; | |
| 1511 } | |
| 1512 else if (dos_super_key == 2) | |
| 1513 { | |
| 1514 mask |= SUPER_P; | |
| 1515 modifiers |= super_modifier; | |
| 1516 } | |
| 1517 else | |
| 1518 mask |= CTRL_P; | |
| 1519 } | |
| 1520 } | |
| 1521 | |
| 1522 if (mask & SHIFT_P) | |
| 1523 modifiers |= shift_modifier; | |
| 1524 if (mask & CTRL_P) | |
| 1525 modifiers |= ctrl_modifier; | |
| 1526 if (mask & ALT_P) | |
| 1527 modifiers |= meta_modifier; | |
| 1528 | |
| 1529 if (keymask) | |
| 1530 *keymask = mask; | |
| 1531 return modifiers; | |
| 5503 | 1532 } |
| 1533 | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1534 #define NUM_RECENT_DOSKEYS (100) |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1535 int recent_doskeys_index; /* Index for storing next element into recent_doskeys */ |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1536 int total_doskeys; /* Total number of elements stored into recent_doskeys */ |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1537 Lisp_Object recent_doskeys; /* A vector, holding the last 100 keystrokes */ |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1538 |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1539 DEFUN ("recent-doskeys", Frecent_doskeys, Srecent_doskeys, 0, 0, 0, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1540 "Return vector of last 100 keyboard input values seen in dos_rawgetc.\n\ |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1541 Each input key receives two values in this vector: first the ASCII code,\n\ |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1542 and then the scan code.") |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1543 () |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1544 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1545 Lisp_Object *keys = XVECTOR (recent_doskeys)->contents; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1546 Lisp_Object val; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1547 |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1548 if (total_doskeys < NUM_RECENT_DOSKEYS) |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1549 return Fvector (total_doskeys, keys); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1550 else |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1551 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1552 val = Fvector (NUM_RECENT_DOSKEYS, keys); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1553 bcopy (keys + recent_doskeys_index, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1554 XVECTOR (val)->contents, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1555 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1556 bcopy (keys, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1557 XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1558 recent_doskeys_index * sizeof (Lisp_Object)); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1559 return val; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1560 } |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1561 } |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1562 |
| 13179 | 1563 /* Get a char from keyboard. Function keys are put into the event queue. */ |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1564 |
| 13179 | 1565 static int |
| 1566 dos_rawgetc () | |
| 5503 | 1567 { |
| 13179 | 1568 struct input_event event; |
| 1569 union REGS regs; | |
| 1570 | |
| 1571 #ifndef HAVE_X_WINDOWS | |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
1572 /* Maybe put the cursor where it should be. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
1573 IT_cmgoto (selected_frame); |
| 13179 | 1574 #endif |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
1575 |
| 13179 | 1576 /* The following condition is equivalent to `kbhit ()', except that |
| 1577 it uses the bios to do its job. This pleases DESQview/X. */ | |
| 1578 while ((regs.h.ah = extended_kbd ? 0x11 : 0x01), | |
| 1579 int86 (0x16, ®s, ®s), | |
| 1580 (regs.x.flags & 0x40) == 0) | |
| 5503 | 1581 { |
| 13179 | 1582 union REGS regs; |
| 1583 register unsigned char c; | |
| 1584 int sc, code, mask, kp_mode; | |
| 1585 int modifiers; | |
| 1586 | |
| 1587 regs.h.ah = extended_kbd ? 0x10 : 0x00; | |
| 1588 int86 (0x16, ®s, ®s); | |
| 1589 c = regs.h.al; | |
| 1590 sc = regs.h.ah; | |
| 5503 | 1591 |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1592 total_doskeys += 2; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1593 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1594 = make_number (c); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1595 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1596 recent_doskeys_index = 0; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1597 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1598 = make_number (sc); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1599 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1600 recent_doskeys_index = 0; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1601 |
| 13274 | 1602 modifiers = dos_get_modifiers (&mask); |
| 13179 | 1603 |
| 1604 #ifndef HAVE_X_WINDOWS | |
| 13274 | 1605 if (!NILP (Vdos_display_scancodes)) |
| 13179 | 1606 { |
|
14157
38606398dfa6
(dos_rawgetc): Make buf longer.
Richard M. Stallman <rms@gnu.org>
parents:
14036
diff
changeset
|
1607 char buf[11]; |
| 13179 | 1608 sprintf (buf, "%02x:%02x*%04x", |
| 1609 (unsigned) (sc&0xff), (unsigned) c, mask); | |
| 1610 dos_direct_output (screen_size_Y - 2, screen_size_X - 12, buf, 10); | |
| 1611 } | |
| 1612 #endif | |
| 5503 | 1613 |
| 13179 | 1614 if (sc == 0xe0) |
| 1615 { | |
| 1616 switch (c) | |
| 1617 { | |
| 1618 case 10: /* Ctrl Grey Enter */ | |
| 1619 code = Ctrl | Grey | 4; | |
| 1620 break; | |
| 1621 case 13: /* Grey Enter */ | |
| 1622 code = Grey | 4; | |
| 1623 break; | |
| 1624 case '/': /* Grey / */ | |
| 1625 code = Grey | 0; | |
| 1626 break; | |
| 1627 default: | |
| 1628 continue; | |
| 1629 }; | |
| 1630 c = 0; | |
| 1631 } | |
| 1632 else | |
| 1633 { | |
| 1634 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) | |
| 1635 continue; | |
| 1636 if ((code = ibmpc_translate_map[sc]) == Ignore) | |
| 1637 continue; | |
| 1638 } | |
| 1639 | |
| 1640 if (c == 0) | |
| 1641 { | |
| 1642 if (code & Alt) | |
| 1643 modifiers |= meta_modifier; | |
| 1644 if (code & Ctrl) | |
| 1645 modifiers |= ctrl_modifier; | |
| 1646 if (code & Shift) | |
| 1647 modifiers |= shift_modifier; | |
| 1648 } | |
| 1649 | |
| 1650 switch (code & 0xf000) | |
| 1651 { | |
| 1652 case ModFct: | |
| 1653 if (c && !(mask & (SHIFT_P | ALT_P | CTRL_P | HYPER_P | SUPER_P))) | |
| 1654 return c; | |
| 1655 c = 0; /* Special */ | |
| 1656 | |
| 1657 case FctKey: | |
| 1658 if (c != 0) | |
| 1659 return c; | |
| 1660 | |
| 1661 case Special: | |
| 1662 code |= 0xff00; | |
| 1663 break; | |
| 1664 | |
| 1665 case Normal: | |
| 1666 if (sc == 0) | |
| 1667 { | |
| 1668 if (c == 0) /* ctrl-break */ | |
| 1669 continue; | |
| 1670 return c; /* ALT-nnn */ | |
| 1671 } | |
| 1672 if (!keyboard_map_all) | |
| 1673 { | |
| 1674 if (c != ' ') | |
| 1675 return c; | |
| 1676 code = c; | |
| 1677 break; | |
| 1678 } | |
| 1679 | |
| 1680 case Map: | |
| 1681 if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) | |
| 1682 if (!keyboard_map_all) | |
| 1683 return c; | |
| 5503 | 1684 |
| 13179 | 1685 code &= 0xff; |
| 1686 if (mask & ALT_P && code <= 10 && code > 0 && dos_keypad_mode & 0x200) | |
| 1687 mask |= SHIFT_P; /* ALT-1 => M-! etc. */ | |
| 1688 | |
| 1689 if (mask & SHIFT_P) | |
| 1690 { | |
| 13274 | 1691 code = keyboard->shifted[code]; |
| 13179 | 1692 mask -= SHIFT_P; |
| 1693 modifiers &= ~shift_modifier; | |
| 1694 } | |
| 1695 else | |
| 13274 | 1696 if ((mask & ALT_GR_P) && keyboard->alt_gr && keyboard->alt_gr[code] != ' ') |
| 1697 code = keyboard->alt_gr[code]; | |
| 13179 | 1698 else |
| 13274 | 1699 code = keyboard->unshifted[code]; |
| 13179 | 1700 break; |
| 1701 | |
| 1702 case KeyPad: | |
| 1703 code &= 0xff; | |
| 1704 if (c == 0xe0) /* edit key */ | |
| 1705 kp_mode = 3; | |
| 1706 else | |
| 1707 if ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) /* numlock on */ | |
| 1708 kp_mode = dos_keypad_mode & 0x03; | |
| 1709 else | |
| 1710 kp_mode = (dos_keypad_mode >> 4) & 0x03; | |
| 1711 | |
| 1712 switch (kp_mode) | |
| 1713 { | |
| 1714 case 0: | |
| 1715 if (code == 10 && dos_decimal_point) | |
| 1716 return dos_decimal_point; | |
| 13274 | 1717 return keypad_translate_map[code].char_code; |
| 5503 | 1718 |
| 13179 | 1719 case 1: |
| 13274 | 1720 code = 0xff00 | keypad_translate_map[code].keypad_code; |
| 13179 | 1721 break; |
| 5503 | 1722 |
| 13179 | 1723 case 2: |
| 13274 | 1724 code = keypad_translate_map[code].meta_code; |
| 13179 | 1725 modifiers = meta_modifier; |
| 1726 break; | |
| 1727 | |
| 1728 case 3: | |
| 13274 | 1729 code = 0xff00 | keypad_translate_map[code].editkey_code; |
| 13179 | 1730 break; |
| 1731 } | |
| 1732 break; | |
| 1733 | |
| 1734 case Grey: | |
| 1735 code &= 0xff; | |
| 1736 kp_mode = ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) ? 0x04 : 0x40; | |
| 1737 if (dos_keypad_mode & kp_mode) | |
| 13274 | 1738 code = 0xff00 | grey_key_translate_map[code].keypad_code; |
| 13179 | 1739 else |
| 13274 | 1740 code = grey_key_translate_map[code].char_code; |
| 13179 | 1741 break; |
| 1742 } | |
| 1743 | |
| 1744 make_event: | |
| 1745 if (code == 0) | |
| 1746 continue; | |
| 1747 | |
| 1748 if (code >= 0x100) | |
| 1749 event.kind = non_ascii_keystroke; | |
| 1750 else | |
| 1751 event.kind = ascii_keystroke; | |
| 1752 event.code = code; | |
| 1753 event.modifiers = modifiers; | |
| 1754 XSETFRAME (event.frame_or_window, selected_frame); | |
| 1755 event.timestamp = event_timestamp (); | |
| 1756 kbd_buffer_store_event (&event); | |
| 1757 } | |
| 5503 | 1758 |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1759 if (have_mouse > 0) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1760 { |
| 13179 | 1761 int but, press, x, y, ok; |
| 5503 | 1762 |
| 13179 | 1763 /* Check for mouse movement *before* buttons. */ |
| 1764 mouse_check_moved (); | |
| 5503 | 1765 |
| 13179 | 1766 for (but = 0; but < NUM_MOUSE_BUTTONS; but++) |
| 1767 for (press = 0; press < 2; press++) | |
| 1768 { | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1769 int button_num = but; |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1770 |
| 13179 | 1771 if (press) |
| 1772 ok = mouse_pressed (but, &x, &y); | |
| 1773 else | |
| 1774 ok = mouse_released (but, &x, &y); | |
| 1775 if (ok) | |
| 1776 { | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1777 /* Allow a simultaneous press/release of Mouse-1 and |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1778 Mouse-2 to simulate Mouse-3 on two-button mice. */ |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1779 if (mouse_button_count == 2 && but < 2) |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1780 { |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1781 int x2, y2; /* don't clobber original coordinates */ |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1782 |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1783 /* If only one button is pressed, wait 100 msec and |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1784 check again. This way, Speedy Gonzales isn't |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1785 punished, while the slow get their chance. */ |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1786 if (press && mouse_pressed (1-but, &x2, &y2) |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1787 || !press && mouse_released (1-but, &x2, &y2)) |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1788 button_num = 2; |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1789 else |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1790 { |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1791 delay (100); |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1792 if (press && mouse_pressed (1-but, &x2, &y2) |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1793 || !press && mouse_released (1-but, &x2, &y2)) |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1794 button_num = 2; |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1795 } |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1796 } |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1797 |
| 13179 | 1798 event.kind = mouse_click; |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1799 event.code = button_num; |
| 13179 | 1800 event.modifiers = dos_get_modifiers (0) |
| 1801 | (press ? down_modifier : up_modifier); | |
| 1802 event.x = x; | |
| 1803 event.y = y; | |
| 1804 XSETFRAME (event.frame_or_window, selected_frame); | |
| 1805 event.timestamp = event_timestamp (); | |
| 1806 kbd_buffer_store_event (&event); | |
| 1807 } | |
| 1808 } | |
| 1809 } | |
| 5503 | 1810 |
| 13179 | 1811 return -1; |
| 9572 | 1812 } |
| 1813 | |
| 13179 | 1814 static int prev_get_char = -1; |
| 5503 | 1815 |
| 13179 | 1816 /* Return 1 if a key is ready to be read without suspending execution. */ |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1817 |
| 13179 | 1818 dos_keysns () |
| 5503 | 1819 { |
| 13179 | 1820 if (prev_get_char != -1) |
| 1821 return 1; | |
| 1822 else | |
| 1823 return ((prev_get_char = dos_rawgetc ()) != -1); | |
| 5503 | 1824 } |
| 1825 | |
| 13179 | 1826 /* Read a key. Return -1 if no key is ready. */ |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1827 |
| 13179 | 1828 dos_keyread () |
| 5503 | 1829 { |
| 13179 | 1830 if (prev_get_char != -1) |
|
8246
d48c2b01fba5
(mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents:
8194
diff
changeset
|
1831 { |
| 13179 | 1832 int c = prev_get_char; |
| 1833 prev_get_char = -1; | |
| 1834 return c; | |
|
8246
d48c2b01fba5
(mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents:
8194
diff
changeset
|
1835 } |
| 13179 | 1836 else |
| 1837 return dos_rawgetc (); | |
| 1838 } | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1839 |
| 9572 | 1840 #ifndef HAVE_X_WINDOWS |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1841 /* See xterm.c for more info. */ |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1842 void |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1843 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
|
1844 FRAME_PTR f; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1845 register int pix_x, pix_y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1846 register int *x, *y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1847 void /* XRectangle */ *bounds; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1848 int noclip; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1849 { |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1850 if (bounds) abort (); |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1851 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1852 /* Ignore clipping. */ |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1853 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1854 *x = pix_x; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1855 *y = pix_y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1856 } |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1857 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1858 void |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1859 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
|
1860 FRAME_PTR f; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1861 register int x, y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1862 register int *pix_x, *pix_y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1863 { |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1864 *pix_x = x; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1865 *pix_y = y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1866 } |
| 9572 | 1867 |
| 1868 /* Simulation of X's menus. Nothing too fancy here -- just make it work | |
| 1869 for now. | |
| 1870 | |
| 1871 Actually, I don't know the meaning of all the parameters of the functions | |
| 1872 here -- I only know how they are called by xmenu.c. I could of course | |
| 1873 grab the nearest Xlib manual (down the hall, second-to-last door on the | |
| 1874 left), but I don't think it's worth the effort. */ | |
| 1875 | |
| 1876 static XMenu * | |
| 1877 IT_menu_create () | |
| 1878 { | |
| 1879 XMenu *menu; | |
| 1880 | |
| 1881 menu = (XMenu *) xmalloc (sizeof (XMenu)); | |
| 1882 menu->allocated = menu->count = menu->panecount = menu->width = 0; | |
| 1883 return menu; | |
| 1884 } | |
| 1885 | |
| 1886 /* Allocate some (more) memory for MENU ensuring that there is room for one | |
| 1887 for item. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1888 |
| 9572 | 1889 static void |
| 1890 IT_menu_make_room (XMenu *menu) | |
| 1891 { | |
| 1892 if (menu->allocated == 0) | |
| 1893 { | |
| 1894 int count = menu->allocated = 10; | |
| 1895 menu->text = (char **) xmalloc (count * sizeof (char *)); | |
| 1896 menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); | |
| 1897 menu->panenumber = (int *) xmalloc (count * sizeof (int)); | |
| 1898 } | |
| 1899 else if (menu->allocated == menu->count) | |
| 1900 { | |
| 1901 int count = menu->allocated = menu->allocated + 10; | |
| 1902 menu->text | |
| 1903 = (char **) xrealloc (menu->text, count * sizeof (char *)); | |
| 1904 menu->submenu | |
| 1905 = (XMenu **) xrealloc (menu->submenu, count * sizeof (XMenu *)); | |
| 1906 menu->panenumber | |
| 1907 = (int *) xrealloc (menu->panenumber, count * sizeof (int)); | |
| 1908 } | |
| 1909 } | |
| 1910 | |
| 1911 /* Search the given menu structure for a given pane number. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1912 |
| 9572 | 1913 static XMenu * |
| 1914 IT_menu_search_pane (XMenu *menu, int pane) | |
| 1915 { | |
| 1916 int i; | |
| 1917 XMenu *try; | |
| 1918 | |
| 1919 for (i = 0; i < menu->count; i++) | |
| 1920 if (menu->submenu[i]) | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1921 { |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1922 if (pane == menu->panenumber[i]) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1923 return menu->submenu[i]; |
| 13179 | 1924 if ((try = IT_menu_search_pane (menu->submenu[i], pane))) |
| 9572 | 1925 return try; |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1926 } |
| 9572 | 1927 return (XMenu *) 0; |
| 1928 } | |
| 1929 | |
| 1930 /* Determine how much screen space a given menu needs. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1931 |
| 9572 | 1932 static void |
| 1933 IT_menu_calc_size (XMenu *menu, int *width, int *height) | |
| 1934 { | |
| 1935 int i, h2, w2, maxsubwidth, maxheight; | |
| 1936 | |
| 1937 maxsubwidth = 0; | |
| 1938 maxheight = menu->count; | |
| 1939 for (i = 0; i < menu->count; i++) | |
| 1940 { | |
| 1941 if (menu->submenu[i]) | |
| 1942 { | |
| 1943 IT_menu_calc_size (menu->submenu[i], &w2, &h2); | |
| 1944 if (w2 > maxsubwidth) maxsubwidth = w2; | |
| 1945 if (i + h2 > maxheight) maxheight = i + h2; | |
| 1946 } | |
| 1947 } | |
| 1948 *width = menu->width + maxsubwidth; | |
| 1949 *height = maxheight; | |
| 1950 } | |
| 1951 | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
1952 /* Display MENU at (X,Y) using FACES. */ |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1953 |
| 9572 | 1954 static void |
| 1955 IT_menu_display (XMenu *menu, int y, int x, int *faces) | |
| 1956 { | |
| 1957 int i, j, face, width; | |
| 1958 GLYPH *text, *p; | |
| 1959 char *q; | |
| 1960 int mx, my; | |
| 1961 int enabled, mousehere; | |
| 1962 int row, col; | |
| 1963 | |
| 1964 width = menu->width; | |
| 1965 text = (GLYPH *) xmalloc ((width + 2) * sizeof (GLYPH)); | |
| 1966 ScreenGetCursor (&row, &col); | |
| 1967 mouse_get_xy (&mx, &my); | |
| 13179 | 1968 IT_update_begin (); |
| 9572 | 1969 for (i = 0; i < menu->count; i++) |
| 1970 { | |
| 13179 | 1971 IT_cursor_to (y + i, x); |
| 9572 | 1972 enabled |
| 1973 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]); | |
| 1974 mousehere = (y + i == my && x <= mx && mx < x + width + 2); | |
| 1975 face = faces[enabled + mousehere * 2]; | |
| 1976 p = text; | |
| 1977 *p++ = FAST_MAKE_GLYPH (' ', face); | |
| 1978 for (j = 0, q = menu->text[i]; *q; j++) | |
|
15627
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1979 { |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1980 if (*q > 26) |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1981 *p++ = FAST_MAKE_GLYPH (*q++, face); |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1982 else /* make '^x' */ |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1983 { |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1984 *p++ = FAST_MAKE_GLYPH ('^', face); |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1985 j++; |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1986 *p++ = FAST_MAKE_GLYPH (*q++ + 64, face); |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1987 } |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1988 } |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
1989 |
| 9572 | 1990 for (; j < width; j++) |
| 1991 *p++ = FAST_MAKE_GLYPH (' ', face); | |
| 1992 *p++ = FAST_MAKE_GLYPH (menu->submenu[i] ? 16 : ' ', face); | |
| 13179 | 1993 IT_write_glyphs (text, width + 2); |
| 9572 | 1994 } |
| 13179 | 1995 IT_update_end (); |
| 1996 IT_cursor_to (row, col); | |
| 9572 | 1997 xfree (text); |
| 1998 } | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1999 |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2000 /* --------------------------- X Menu emulation ---------------------- */ |
| 9572 | 2001 |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2002 /* Report availability of menus. */ |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2003 |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2004 int |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2005 have_menus_p () |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2006 { |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2007 return 1; |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2008 } |
| 13179 | 2009 |
| 9572 | 2010 /* Create a brand new menu structure. */ |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2011 |
| 9572 | 2012 XMenu * |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2013 XMenuCreate (Display *foo1, Window foo2, char *foo3) |
| 9572 | 2014 { |
| 2015 return IT_menu_create (); | |
| 2016 } | |
| 2017 | |
| 2018 /* Create a new pane and place it on the outer-most level. It is not | |
| 2019 clear that it should be placed out there, but I don't know what else | |
| 2020 to do. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2021 |
| 9572 | 2022 int |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2023 XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable) |
| 9572 | 2024 { |
| 2025 int len; | |
|
15627
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2026 char *p; |
| 9572 | 2027 |
| 2028 if (!enable) | |
| 2029 abort (); | |
| 2030 | |
| 2031 IT_menu_make_room (menu); | |
| 2032 menu->submenu[menu->count] = IT_menu_create (); | |
| 2033 menu->text[menu->count] = txt; | |
| 2034 menu->panenumber[menu->count] = ++menu->panecount; | |
| 2035 menu->count++; | |
|
15627
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2036 |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2037 /* Adjust length for possible control characters (which will |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2038 be written as ^x). */ |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2039 for (len = strlen (txt), p = txt; *p; p++) |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2040 if (*p < 27) |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2041 len++; |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2042 |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2043 if (len > menu->width) |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2044 menu->width = len; |
|
15627
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2045 |
| 9572 | 2046 return menu->panecount; |
| 2047 } | |
| 2048 | |
| 2049 /* Create a new item in a menu pane. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2050 |
| 9572 | 2051 int |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2052 XMenuAddSelection (Display *bar, XMenu *menu, int pane, |
|
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2053 int foo, char *txt, int enable) |
| 9572 | 2054 { |
| 2055 int len; | |
|
15627
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2056 char *p; |
| 9572 | 2057 |
| 2058 if (pane) | |
| 2059 if (!(menu = IT_menu_search_pane (menu, pane))) | |
| 2060 return XM_FAILURE; | |
| 2061 IT_menu_make_room (menu); | |
| 2062 menu->submenu[menu->count] = (XMenu *) 0; | |
| 2063 menu->text[menu->count] = txt; | |
| 2064 menu->panenumber[menu->count] = enable; | |
| 2065 menu->count++; | |
|
15627
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2066 |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2067 /* Adjust length for possible control characters (which will |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2068 be written as ^x). */ |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2069 for (len = strlen (txt), p = txt; *p; p++) |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2070 if (*p < 27) |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2071 len++; |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2072 |
|
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2073 if (len > menu->width) |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2074 menu->width = len; |
|
15627
c5c4d478c78d
(IT_menu_display): Display control characters as ^X.
Karl Heuer <kwzh@gnu.org>
parents:
15618
diff
changeset
|
2075 |
| 9572 | 2076 return XM_SUCCESS; |
| 2077 } | |
| 2078 | |
| 2079 /* Decide where the menu would be placed if requested at (X,Y). */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2080 |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2081 void |
|
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2082 XMenuLocate (Display *foo0, XMenu *menu, int foo1, int foo2, int x, int y, |
| 9572 | 2083 int *ulx, int *uly, int *width, int *height) |
| 2084 { | |
|
13714
45e71ea63d71
(XMenuActivate): Display the menu pane title.
Karl Heuer <kwzh@gnu.org>
parents:
13657
diff
changeset
|
2085 IT_menu_calc_size (menu, width, height); |
| 9572 | 2086 *ulx = x + 1; |
| 2087 *uly = y; | |
| 2088 *width += 2; | |
| 2089 } | |
| 2090 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2091 struct IT_menu_state |
| 9572 | 2092 { |
| 2093 void *screen_behind; | |
| 2094 XMenu *menu; | |
| 2095 int pane; | |
| 2096 int x, y; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2097 }; |
| 9572 | 2098 |
| 2099 | |
| 2100 /* Display menu, wait for user's response, and return that response. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2101 |
| 9572 | 2102 int |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2103 XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx, |
| 9572 | 2104 int x0, int y0, unsigned ButtonMask, char **txt) |
| 2105 { | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2106 struct IT_menu_state *state; |
| 9572 | 2107 int statecount; |
| 2108 int x, y, i, b; | |
| 2109 int screensize; | |
| 2110 int faces[4], selectface; | |
| 2111 int leave, result, onepane; | |
|
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
2112 int title_faces[4]; /* face to display the menu title */ |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2113 int buffers_num_deleted = 0; |
| 9572 | 2114 |
| 2115 /* Just in case we got here without a mouse present... */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2116 if (have_mouse <= 0) |
| 9572 | 2117 return XM_IA_SELECT; |
|
16871
45a12f628d3f
* (XMenuActivate): Don't allow non-positive menu
Eli Zaretskii <eliz@gnu.org>
parents:
16837
diff
changeset
|
2118 /* Don't allow non-positive x0 and y0, lest the menu will wrap |
|
45a12f628d3f
* (XMenuActivate): Don't allow non-positive menu
Eli Zaretskii <eliz@gnu.org>
parents:
16837
diff
changeset
|
2119 around the display. */ |
|
45a12f628d3f
* (XMenuActivate): Don't allow non-positive menu
Eli Zaretskii <eliz@gnu.org>
parents:
16837
diff
changeset
|
2120 if (x0 <= 0) |
|
45a12f628d3f
* (XMenuActivate): Don't allow non-positive menu
Eli Zaretskii <eliz@gnu.org>
parents:
16837
diff
changeset
|
2121 x0 = 1; |
|
45a12f628d3f
* (XMenuActivate): Don't allow non-positive menu
Eli Zaretskii <eliz@gnu.org>
parents:
16837
diff
changeset
|
2122 if (y0 <= 0) |
|
45a12f628d3f
* (XMenuActivate): Don't allow non-positive menu
Eli Zaretskii <eliz@gnu.org>
parents:
16837
diff
changeset
|
2123 y0 = 1; |
| 9572 | 2124 |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2125 state = alloca (menu->panecount * sizeof (struct IT_menu_state)); |
| 13179 | 2126 screensize = screen_size * 2; |
| 9572 | 2127 faces[0] |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2128 = compute_glyph_face (selected_frame, |
| 9572 | 2129 face_name_id_number |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2130 (selected_frame, |
| 9572 | 2131 intern ("msdos-menu-passive-face")), |
| 2132 0); | |
| 2133 faces[1] | |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2134 = compute_glyph_face (selected_frame, |
| 9572 | 2135 face_name_id_number |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2136 (selected_frame, |
| 9572 | 2137 intern ("msdos-menu-active-face")), |
| 2138 0); | |
| 2139 selectface | |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2140 = face_name_id_number (selected_frame, intern ("msdos-menu-select-face")); |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2141 faces[2] = compute_glyph_face (selected_frame, selectface, faces[0]); |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2142 faces[3] = compute_glyph_face (selected_frame, selectface, faces[1]); |
| 9572 | 2143 |
|
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
2144 /* Make sure the menu title is always displayed with |
|
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
2145 `msdos-menu-active-face', no matter where the mouse pointer is. */ |
|
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
2146 for (i = 0; i < 4; i++) |
|
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
2147 title_faces[i] = faces[3]; |
|
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
2148 |
| 9572 | 2149 statecount = 1; |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2150 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2151 /* Don't let the title for the "Buffers" popup menu include a |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2152 digit (which is ugly). |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2153 |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2154 This is a terrible kludge, but I think the "Buffers" case is |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2155 the only one where the title includes a number, so it doesn't |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2156 seem to be necessary to make this more general. */ |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2157 if (strncmp (menu->text[0], "Buffers 1", 9) == 0) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2158 { |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2159 menu->text[0][7] = '\0'; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2160 buffers_num_deleted = 1; |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2161 } |
| 9572 | 2162 state[0].menu = menu; |
| 2163 mouse_off (); | |
| 2164 ScreenRetrieve (state[0].screen_behind = xmalloc (screensize)); | |
|
13714
45e71ea63d71
(XMenuActivate): Display the menu pane title.
Karl Heuer <kwzh@gnu.org>
parents:
13657
diff
changeset
|
2165 |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
2166 /* Turn off the cursor. Otherwise it shows through the menu |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
2167 panes, which is ugly. */ |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
2168 IT_display_cursor (0); |
|
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
2169 |
|
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
2170 IT_menu_display (menu, y0 - 1, x0 - 1, title_faces); /* display menu title */ |
|
15387
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2171 if (buffers_num_deleted) |
|
9ac116f47f33
(check_x): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
15341
diff
changeset
|
2172 menu->text[0][7] = ' '; |
| 9572 | 2173 if ((onepane = menu->count == 1 && menu->submenu[0])) |
| 2174 { | |
| 2175 menu->width = menu->submenu[0]->width; | |
| 2176 state[0].menu = menu->submenu[0]; | |
| 2177 } | |
| 2178 else | |
| 2179 { | |
| 2180 state[0].menu = menu; | |
| 2181 } | |
| 2182 state[0].x = x0 - 1; | |
| 2183 state[0].y = y0; | |
| 2184 state[0].pane = onepane; | |
| 2185 | |
| 2186 mouse_last_x = -1; /* A hack that forces display. */ | |
| 2187 leave = 0; | |
| 2188 while (!leave) | |
| 2189 { | |
| 13179 | 2190 if (!mouse_visible) mouse_on (); |
| 9572 | 2191 mouse_check_moved (); |
|
12573
f8193b0f95ed
(mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents:
11124
diff
changeset
|
2192 if (selected_frame->mouse_moved) |
| 9572 | 2193 { |
|
12573
f8193b0f95ed
(mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents:
11124
diff
changeset
|
2194 selected_frame->mouse_moved = 0; |
| 9572 | 2195 result = XM_IA_SELECT; |
| 2196 mouse_get_xy (&x, &y); | |
| 2197 for (i = 0; i < statecount; i++) | |
| 2198 if (state[i].x <= x && x < state[i].x + state[i].menu->width + 2) | |
| 2199 { | |
| 2200 int dy = y - state[i].y; | |
| 2201 if (0 <= dy && dy < state[i].menu->count) | |
| 2202 { | |
| 2203 if (!state[i].menu->submenu[dy]) | |
| 2204 if (state[i].menu->panenumber[dy]) | |
| 2205 result = XM_SUCCESS; | |
| 2206 else | |
| 2207 result = XM_IA_SELECT; | |
| 2208 *pane = state[i].pane - 1; | |
| 2209 *selidx = dy; | |
| 14036 | 2210 /* We hit some part of a menu, so drop extra menus that |
| 9572 | 2211 have been opened. That does not include an open and |
| 2212 active submenu. */ | |
| 2213 if (i != statecount - 2 | |
| 2214 || state[i].menu->submenu[dy] != state[i+1].menu) | |
| 2215 while (i != statecount - 1) | |
| 2216 { | |
| 2217 statecount--; | |
| 2218 mouse_off (); | |
| 2219 ScreenUpdate (state[statecount].screen_behind); | |
| 2220 xfree (state[statecount].screen_behind); | |
| 2221 } | |
| 2222 if (i == statecount - 1 && state[i].menu->submenu[dy]) | |
| 2223 { | |
| 2224 IT_menu_display (state[i].menu, | |
| 2225 state[i].y, | |
| 2226 state[i].x, | |
| 2227 faces); | |
| 2228 state[statecount].menu = state[i].menu->submenu[dy]; | |
| 2229 state[statecount].pane = state[i].menu->panenumber[dy]; | |
| 2230 mouse_off (); | |
| 2231 ScreenRetrieve (state[statecount].screen_behind | |
| 2232 = xmalloc (screensize)); | |
| 2233 state[statecount].x | |
| 2234 = state[i].x + state[i].menu->width + 2; | |
| 2235 state[statecount].y = y; | |
| 2236 statecount++; | |
| 2237 } | |
| 2238 } | |
| 2239 } | |
| 2240 IT_menu_display (state[statecount - 1].menu, | |
| 2241 state[statecount - 1].y, | |
| 2242 state[statecount - 1].x, | |
| 2243 faces); | |
| 2244 } | |
| 2245 for (b = 0; b < mouse_button_count; b++) | |
| 2246 { | |
| 2247 (void) mouse_pressed (b, &x, &y); | |
| 2248 if (mouse_released (b, &x, &y)) | |
| 2249 leave = 1; | |
| 2250 } | |
| 2251 } | |
| 2252 | |
| 2253 mouse_off (); | |
| 2254 ScreenUpdate (state[0].screen_behind); | |
| 2255 while (statecount--) | |
| 2256 xfree (state[statecount].screen_behind); | |
|
16598
4b0b6719bbd2
[__DJGPP__ >= 2] (dos_direct_output): Faster method of
Karl Heuer <kwzh@gnu.org>
parents:
16524
diff
changeset
|
2257 IT_display_cursor (1); /* turn cursor back on */ |
| 9572 | 2258 return result; |
| 2259 } | |
| 2260 | |
| 2261 /* Dispose of a menu. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2262 |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2263 void |
|
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2264 XMenuDestroy (Display *foo, XMenu *menu) |
| 9572 | 2265 { |
| 2266 int i; | |
| 2267 if (menu->allocated) | |
| 2268 { | |
| 2269 for (i = 0; i < menu->count; i++) | |
| 2270 if (menu->submenu[i]) | |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2271 XMenuDestroy (foo, menu->submenu[i]); |
| 9572 | 2272 xfree (menu->text); |
| 2273 xfree (menu->submenu); | |
| 2274 xfree (menu->panenumber); | |
| 2275 } | |
| 2276 xfree (menu); | |
| 2277 } | |
| 2278 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2279 int |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2280 x_pixel_width (struct frame *f) |
| 9572 | 2281 { |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2282 return FRAME_WIDTH (f); |
| 9572 | 2283 } |
| 2284 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2285 int |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2286 x_pixel_height (struct frame *f) |
| 9572 | 2287 { |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
2288 return FRAME_HEIGHT (f); |
| 9572 | 2289 } |
| 2290 #endif /* !HAVE_X_WINDOWS */ | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2291 |
| 13179 | 2292 /* ----------------------- DOS / UNIX conversion --------------------- */ |
| 2293 | |
|
15618
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2294 void msdos_downcase_filename (unsigned char *); |
|
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2295 |
| 13179 | 2296 /* Destructively turn backslashes into slashes. */ |
| 2297 | |
| 2298 void | |
| 2299 dostounix_filename (p) | |
| 2300 register char *p; | |
| 2301 { | |
|
15618
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2302 msdos_downcase_filename (p); |
|
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2303 |
| 13179 | 2304 while (*p) |
| 2305 { | |
| 2306 if (*p == '\\') | |
| 2307 *p = '/'; | |
| 2308 p++; | |
| 2309 } | |
| 2310 } | |
| 2311 | |
| 2312 /* Destructively turn slashes into backslashes. */ | |
| 2313 | |
| 2314 void | |
| 2315 unixtodos_filename (p) | |
| 2316 register char *p; | |
| 2317 { | |
|
15618
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2318 if (p[1] == ':' && *p >= 'A' && *p <= 'Z') |
|
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2319 { |
|
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2320 *p += 'a' - 'A'; |
|
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2321 p += 2; |
|
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2322 } |
|
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2323 |
| 13179 | 2324 while (*p) |
| 2325 { | |
| 2326 if (*p == '/') | |
| 2327 *p = '\\'; | |
| 2328 p++; | |
| 2329 } | |
| 2330 } | |
| 2331 | |
| 2332 /* Get the default directory for a given drive. 0=def, 1=A, 2=B, ... */ | |
| 2333 | |
| 2334 int | |
| 2335 getdefdir (drive, dst) | |
| 2336 int drive; | |
| 2337 char *dst; | |
| 2338 { | |
|
15125
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2339 char in_path[4], *p = in_path; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2340 int e = errno; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2341 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2342 /* Generate "X:." (when drive is X) or "." (when drive is 0). */ |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2343 if (drive != 0) |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2344 { |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2345 *p++ = drive + 'A' - 1; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2346 *p++ = ':'; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2347 } |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2348 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2349 *p++ = '.'; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2350 *p = '\0'; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2351 errno = 0; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2352 _fixpath (in_path, dst); |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2353 if (errno) |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2354 return 0; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2355 |
|
15219
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2356 msdos_downcase_filename (dst); |
|
15125
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2357 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2358 errno = e; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
2359 return 1; |
| 13179 | 2360 } |
| 2361 | |
| 2362 /* Remove all CR's that are followed by a LF. */ | |
| 2363 | |
| 2364 int | |
| 2365 crlf_to_lf (n, buf) | |
| 2366 register int n; | |
| 2367 register unsigned char *buf; | |
| 2368 { | |
| 2369 unsigned char *np = buf; | |
| 2370 unsigned char *startp = buf; | |
| 2371 unsigned char *endp = buf + n; | |
| 2372 unsigned char c; | |
| 2373 | |
| 2374 if (n == 0) | |
| 2375 return n; | |
| 2376 while (buf < endp - 1) | |
| 2377 { | |
| 2378 if (*buf == 0x0d) | |
| 2379 { | |
| 2380 if (*(++buf) != 0x0a) | |
| 2381 *np++ = 0x0d; | |
| 2382 } | |
| 2383 else | |
| 2384 *np++ = *buf++; | |
| 2385 } | |
| 2386 if (buf < endp) | |
| 2387 *np++ = *buf++; | |
| 2388 return np - startp; | |
| 2389 } | |
| 14999 | 2390 |
| 2391 #if defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 0 | |
| 2392 | |
| 2393 /* In DJGPP v2.0, library `write' can call `malloc', which might | |
| 2394 cause relocation of the buffer whose address we get in ADDR. | |
| 2395 Here is a version of `write' that avoids calling `malloc', | |
| 2396 to serve us until such time as the library is fixed. | |
| 2397 Actually, what we define here is called `__write', because | |
| 2398 `write' is a stub that just jmp's to `__write' (to be | |
| 2399 POSIXLY-correct with respect to the global name-space). */ | |
| 2400 | |
| 2401 #include <io.h> /* for _write */ | |
| 2402 #include <libc/dosio.h> /* for __file_handle_modes[] */ | |
| 2403 | |
| 2404 static char xbuf[64 * 1024]; /* DOS cannot write more in one chunk */ | |
| 2405 | |
| 2406 #define XBUF_END (xbuf + sizeof (xbuf) - 1) | |
| 2407 | |
| 2408 int | |
| 2409 __write (int handle, const void *buffer, size_t count) | |
| 2410 { | |
| 2411 if (count == 0) | |
| 2412 return 0; | |
| 2413 | |
| 2414 if(__file_handle_modes[handle] & O_BINARY) | |
| 2415 return _write (handle, buffer, count); | |
| 2416 else | |
| 2417 { | |
| 2418 char *xbp = xbuf; | |
| 2419 const char *bp = buffer; | |
| 2420 int total_written = 0; | |
| 2421 int nmoved = 0, ncr = 0; | |
| 2422 | |
| 2423 while (count) | |
| 2424 { | |
| 2425 /* The next test makes sure there's space for at least 2 more | |
| 2426 characters in xbuf[], so both CR and LF can be put there. */ | |
| 2427 if (xbp < XBUF_END) | |
| 2428 { | |
| 2429 if (*bp == '\n') | |
| 2430 { | |
| 2431 ncr++; | |
| 2432 *xbp++ = '\r'; | |
| 2433 } | |
| 2434 *xbp++ = *bp++; | |
| 2435 nmoved++; | |
| 2436 count--; | |
| 2437 } | |
| 2438 if (xbp >= XBUF_END || !count) | |
| 2439 { | |
| 2440 size_t to_write = nmoved + ncr; | |
| 2441 int written = _write (handle, xbuf, to_write); | |
| 2442 | |
| 2443 if (written == -1) | |
| 2444 return -1; | |
| 2445 else | |
| 2446 total_written += nmoved; /* CRs aren't counted in ret value */ | |
| 2447 | |
| 2448 /* If some, but not all were written (disk full?), return | |
| 2449 an estimate of the total written bytes not counting CRs. */ | |
| 2450 if (written < to_write) | |
| 2451 return total_written - (to_write - written) * nmoved/to_write; | |
| 2452 | |
| 2453 nmoved = 0; | |
| 2454 ncr = 0; | |
| 2455 xbp = xbuf; | |
| 2456 } | |
| 2457 } | |
| 2458 return total_written; | |
| 2459 } | |
| 2460 } | |
| 2461 | |
|
16524
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2462 /* A low-level file-renaming function which works around Windows 95 bug. |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2463 This is pulled directly out of DJGPP v2.01 library sources, and only |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2464 used when you compile with DJGPP v2.0. */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2465 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2466 #include <io.h> |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2467 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2468 int _rename(const char *old, const char *new) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2469 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2470 __dpmi_regs r; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2471 int olen = strlen(old) + 1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2472 int i; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2473 int use_lfn = _USE_LFN; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2474 char tempfile[FILENAME_MAX]; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2475 const char *orig = old; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2476 int lfn_fd = -1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2477 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2478 r.x.dx = __tb_offset; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2479 r.x.di = __tb_offset + olen; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2480 r.x.ds = r.x.es = __tb_segment; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2481 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2482 if (use_lfn) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2483 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2484 /* Windows 95 bug: for some filenames, when you rename |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2485 file -> file~ (as in Emacs, to leave a backup), the |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2486 short 8+3 alias doesn't change, which effectively |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2487 makes OLD and NEW the same file. We must rename |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2488 through a temporary file to work around this. */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2489 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2490 char *pbase = 0, *p; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2491 static char try_char[] = "abcdefghijklmnopqrstuvwxyz012345789"; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2492 int idx = sizeof(try_char) - 1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2493 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2494 /* Generate a temporary name. Can't use `tmpnam', since $TMPDIR |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2495 might point to another drive, which will fail the DOS call. */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2496 strcpy(tempfile, old); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2497 for (p = tempfile; *p; p++) /* ensure temporary is on the same drive */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2498 if (*p == '/' || *p == '\\' || *p == ':') |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2499 pbase = p; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2500 if (pbase) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2501 pbase++; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2502 else |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2503 pbase = tempfile; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2504 strcpy(pbase, "X$$djren$$.$$temp$$"); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2505 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2506 do |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2507 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2508 if (idx <= 0) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2509 return -1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2510 *pbase = try_char[--idx]; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2511 } while (_chmod(tempfile, 0) != -1); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2512 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2513 r.x.ax = 0x7156; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2514 _put_path2(tempfile, olen); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2515 _put_path(old); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2516 __dpmi_int(0x21, &r); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2517 if (r.x.flags & 1) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2518 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2519 errno = __doserr_to_errno(r.x.ax); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2520 return -1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2521 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2522 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2523 /* Now create a file with the original name. This will |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2524 ensure that NEW will always have a 8+3 alias |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2525 different from that of OLD. (Seems to be required |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2526 when NameNumericTail in the Registry is set to 0.) */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2527 lfn_fd = _creat(old, 0); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2528 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2529 olen = strlen(tempfile) + 1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2530 old = tempfile; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2531 r.x.di = __tb_offset + olen; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2532 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2533 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2534 for (i=0; i<2; i++) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2535 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2536 if(use_lfn) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2537 r.x.ax = 0x7156; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2538 else |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2539 r.h.ah = 0x56; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2540 _put_path2(new, olen); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2541 _put_path(old); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2542 __dpmi_int(0x21, &r); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2543 if(r.x.flags & 1) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2544 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2545 if (r.x.ax == 5 && i == 0) /* access denied */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2546 remove(new); /* and try again */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2547 else |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2548 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2549 errno = __doserr_to_errno(r.x.ax); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2550 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2551 /* Restore to original name if we renamed it to temporary. */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2552 if (use_lfn) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2553 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2554 if (lfn_fd != -1) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2555 { |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2556 _close (lfn_fd); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2557 remove (orig); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2558 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2559 _put_path2(orig, olen); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2560 _put_path(tempfile); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2561 r.x.ax = 0x7156; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2562 __dpmi_int(0x21, &r); |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2563 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2564 return -1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2565 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2566 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2567 else |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2568 break; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2569 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2570 |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2571 /* Success. Delete the file possibly created to work |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2572 around the Windows 95 bug. */ |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2573 if (lfn_fd != -1) |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2574 return (_close (lfn_fd) == 0) ? remove (orig) : -1; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2575 return 0; |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2576 } |
|
84440bd95727
[__DJGPP_MINOR__ == 0] (_rename): New function, a
Richard M. Stallman <rms@gnu.org>
parents:
16310
diff
changeset
|
2577 |
| 14999 | 2578 #endif /* __DJGPP__ == 2 && __DJGPP_MINOR__ == 0 */ |
| 2579 | |
|
15174
08937f70419e
(Fmsdos_long_file_names): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15125
diff
changeset
|
2580 DEFUN ("msdos-long-file-names", Fmsdos_long_file_names, Smsdos_long_file_names, |
|
08937f70419e
(Fmsdos_long_file_names): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15125
diff
changeset
|
2581 0, 0, 0, |
|
08937f70419e
(Fmsdos_long_file_names): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15125
diff
changeset
|
2582 "Return non-nil if long file names are supported on MSDOS.") |
|
08937f70419e
(Fmsdos_long_file_names): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15125
diff
changeset
|
2583 () |
|
08937f70419e
(Fmsdos_long_file_names): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15125
diff
changeset
|
2584 { |
|
08937f70419e
(Fmsdos_long_file_names): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15125
diff
changeset
|
2585 return (_USE_LFN ? Qt : Qnil); |
|
08937f70419e
(Fmsdos_long_file_names): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15125
diff
changeset
|
2586 } |
|
15219
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2587 |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2588 /* Convert alphabetic characters in a filename to lower-case. */ |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2589 |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2590 void |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2591 msdos_downcase_filename (p) |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2592 register unsigned char *p; |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2593 { |
| 15588 | 2594 /* Always lower-case drive letters a-z, even if the filesystem |
| 2595 preserves case in filenames. | |
| 2596 This is so MSDOS filenames could be compared by string comparison | |
| 2597 functions that are case-sensitive. Even case-preserving filesystems | |
| 2598 do not distinguish case in drive letters. */ | |
| 2599 if (p[1] == ':' && *p >= 'A' && *p <= 'Z') | |
| 2600 { | |
| 2601 *p += 'a' - 'A'; | |
| 2602 p += 2; | |
| 2603 } | |
| 2604 | |
|
15219
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2605 /* Under LFN we expect to get pathnames in their true case. */ |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2606 if (NILP (Fmsdos_long_file_names ())) |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2607 for ( ; *p; p++) |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2608 if (*p >= 'A' && *p <= 'Z') |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2609 *p += 'a' - 'A'; |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2610 } |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2611 |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2612 DEFUN ("msdos-downcase-filename", Fmsdos_downcase_filename, Smsdos_downcase_filename, |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2613 1, 1, 0, |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2614 "Convert alphabetic characters in FILENAME to lower case and return that.\n\ |
|
15222
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2615 When long filenames are supported, doesn't change FILENAME.\n\ |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2616 If FILENAME is not a string, returns nil.\n\ |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2617 The argument object is never altered--the value is a copy.") |
|
15219
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2618 (filename) |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2619 Lisp_Object filename; |
|
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2620 { |
|
15222
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2621 char *fname; |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2622 Lisp_Object tem; |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2623 |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2624 if (! STRINGP (filename)) |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2625 return Qnil; |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2626 |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2627 tem = Fcopy_sequence (filename); |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2628 msdos_downcase_filename (XSTRING (tem)->data); |
|
cc264dd966cd
(Fmsdos_downcase_filename): Don't change the argument, return a copy.
Richard M. Stallman <rms@gnu.org>
parents:
15219
diff
changeset
|
2629 return tem; |
|
15219
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
2630 } |
| 13179 | 2631 |
| 2632 /* The Emacs root directory as determined by init_environment. */ | |
| 2633 | |
| 2634 static char emacsroot[MAXPATHLEN]; | |
| 2635 | |
| 2636 char * | |
| 2637 rootrelativepath (rel) | |
| 2638 char *rel; | |
| 2639 { | |
| 2640 static char result[MAXPATHLEN + 10]; | |
| 2641 | |
| 2642 strcpy (result, emacsroot); | |
| 2643 strcat (result, "/"); | |
| 2644 strcat (result, rel); | |
| 2645 return result; | |
| 2646 } | |
| 2647 | |
| 2648 /* Define a lot of environment variables if not already defined. Don't | |
| 2649 remove anything unless you know what you're doing -- lots of code will | |
| 2650 break if one or more of these are missing. */ | |
| 2651 | |
| 2652 void | |
| 2653 init_environment (argc, argv, skip_args) | |
| 2654 int argc; | |
| 2655 char **argv; | |
| 2656 int skip_args; | |
| 2657 { | |
| 2658 char *s, *t, *root; | |
| 2659 int len; | |
| 2660 | |
| 2661 /* Find our root from argv[0]. Assuming argv[0] is, say, | |
| 2662 "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */ | |
| 2663 root = alloca (MAXPATHLEN + 20); | |
| 2664 _fixpath (argv[0], root); | |
|
15618
5da6a61ce827
(dostounix_filename): On caseless filesystems, downcase the filename.
Miles Bader <miles@gnu.org>
parents:
15588
diff
changeset
|
2665 msdos_downcase_filename (root); |
| 13179 | 2666 len = strlen (root); |
| 2667 while (len > 0 && root[len] != '/' && root[len] != ':') | |
| 2668 len--; | |
| 2669 root[len] = '\0'; | |
| 2670 if (len > 4 && strcmp (root + len - 4, "/bin") == 0) | |
| 2671 root[len - 4] = '\0'; | |
| 2672 else | |
| 2673 strcpy (root, "c:/emacs"); /* Only under debuggers, I think. */ | |
| 2674 len = strlen (root); | |
| 2675 strcpy (emacsroot, root); | |
| 2676 | |
| 2677 /* We default HOME to our root. */ | |
| 2678 setenv ("HOME", root, 0); | |
| 2679 | |
| 2680 /* We default EMACSPATH to root + "/bin". */ | |
| 2681 strcpy (root + len, "/bin"); | |
| 2682 setenv ("EMACSPATH", root, 0); | |
| 2683 | |
| 2684 /* I don't expect anybody to ever use other terminals so the internal | |
| 2685 terminal is the default. */ | |
| 2686 setenv ("TERM", "internal", 0); | |
| 2687 | |
| 2688 #ifdef HAVE_X_WINDOWS | |
| 2689 /* Emacs expects DISPLAY to be set. */ | |
| 2690 setenv ("DISPLAY", "unix:0.0", 0); | |
| 2691 #endif | |
| 2692 | |
| 2693 /* SHELL is a bit tricky -- COMSPEC is the closest we come, but we must | |
| 2694 downcase it and mirror the backslashes. */ | |
| 2695 s = getenv ("COMSPEC"); | |
| 2696 if (!s) s = "c:/command.com"; | |
| 2697 t = alloca (strlen (s) + 1); | |
| 2698 strcpy (t, s); | |
| 2699 dostounix_filename (t); | |
| 2700 setenv ("SHELL", t, 0); | |
| 2701 | |
| 2702 /* PATH is also downcased and backslashes mirrored. */ | |
| 2703 s = getenv ("PATH"); | |
| 2704 if (!s) s = ""; | |
| 2705 t = alloca (strlen (s) + 3); | |
| 2706 /* Current directory is always considered part of MsDos's path but it is | |
| 2707 not normally mentioned. Now it is. */ | |
| 2708 strcat (strcpy (t, ".;"), s); | |
| 2709 dostounix_filename (t); /* Not a single file name, but this should work. */ | |
| 2710 setenv ("PATH", t, 1); | |
| 2711 | |
| 2712 /* In some sense all dos users have root privileges, so... */ | |
| 2713 setenv ("USER", "root", 0); | |
| 2714 setenv ("NAME", getenv ("USER"), 0); | |
| 2715 | |
| 2716 /* Time zone determined from country code. To make this possible, the | |
| 2717 country code may not span more than one time zone. In other words, | |
| 2718 in the USA, you lose. */ | |
| 13274 | 2719 if (!getenv ("TZ")) |
| 13179 | 2720 switch (dos_country_code) |
| 2721 { | |
| 2722 case 31: /* Belgium */ | |
| 2723 case 32: /* The Netherlands */ | |
| 2724 case 33: /* France */ | |
| 2725 case 34: /* Spain */ | |
| 2726 case 36: /* Hungary */ | |
| 2727 case 38: /* Yugoslavia (or what's left of it?) */ | |
| 2728 case 39: /* Italy */ | |
| 2729 case 41: /* Switzerland */ | |
| 2730 case 42: /* Tjekia */ | |
| 2731 case 45: /* Denmark */ | |
| 2732 case 46: /* Sweden */ | |
| 2733 case 47: /* Norway */ | |
| 2734 case 48: /* Poland */ | |
| 2735 case 49: /* Germany */ | |
| 2736 /* Daylight saving from last Sunday in March to last Sunday in | |
| 2737 September, both at 2AM. */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2738 setenv ("TZ", "MET-01METDST-02,M3.5.0/02:00,M9.5.0/02:00", 0); |
| 13179 | 2739 break; |
| 2740 case 44: /* United Kingdom */ | |
| 2741 case 351: /* Portugal */ | |
| 2742 case 354: /* Iceland */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2743 setenv ("TZ", "GMT+00", 0); |
| 13179 | 2744 break; |
| 2745 case 81: /* Japan */ | |
| 2746 case 82: /* Korea */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2747 setenv ("TZ", "JST-09", 0); |
| 13179 | 2748 break; |
| 2749 case 90: /* Turkey */ | |
| 2750 case 358: /* Finland */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2751 setenv ("TZ", "EET-02", 0); |
|
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2752 break; |
| 13179 | 2753 case 972: /* Israel */ |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2754 /* This is an approximation. (For exact rules, use the |
|
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2755 `zoneinfo/israel' file which comes with DJGPP, but you need |
|
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2756 to install it in `/usr/share/zoneinfo/' directory first.) */ |
|
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2757 setenv ("TZ", "IST-02IDT-03,M4.1.6/00:00,M9.5.6/01:00", 0); |
| 13179 | 2758 break; |
| 2759 } | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2760 tzset (); |
| 13179 | 2761 } |
| 2762 | |
| 2763 | |
| 2764 | |
| 2765 static int break_stat; /* BREAK check mode status. */ | |
| 2766 static int stdin_stat; /* stdin IOCTL status. */ | |
| 2767 | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2768 #if __DJGPP__ < 2 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2769 |
| 13179 | 2770 /* These must be global. */ |
| 2771 static _go32_dpmi_seginfo ctrl_break_vector; | |
| 2772 static _go32_dpmi_registers ctrl_break_regs; | |
| 2773 static int ctrlbreakinstalled = 0; | |
| 2774 | |
| 2775 /* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */ | |
| 2776 | |
| 2777 void | |
| 2778 ctrl_break_func (regs) | |
| 2779 _go32_dpmi_registers *regs; | |
| 2780 { | |
| 2781 Vquit_flag = Qt; | |
| 2782 } | |
| 2783 | |
| 2784 void | |
| 2785 install_ctrl_break_check () | |
| 2786 { | |
| 2787 if (!ctrlbreakinstalled) | |
| 2788 { | |
| 2789 /* Don't press Ctrl-Break if you don't have either DPMI or Emacs | |
| 2790 was compiler with Djgpp 1.11 maintenance level 5 or later! */ | |
| 2791 ctrlbreakinstalled = 1; | |
| 2792 ctrl_break_vector.pm_offset = (int) ctrl_break_func; | |
| 2793 _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector, | |
| 2794 &ctrl_break_regs); | |
| 2795 _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector); | |
| 2796 } | |
| 2797 } | |
| 2798 | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2799 #endif /* __DJGPP__ < 2 */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2800 |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2801 /* Turn off Dos' Ctrl-C checking and inhibit interpretation of |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2802 control chars by DOS. Determine the keyboard type. */ |
| 13179 | 2803 |
| 2804 int | |
| 2805 dos_ttraw () | |
| 2806 { | |
| 2807 union REGS inregs, outregs; | |
| 2808 static int first_time = 1; | |
| 2809 | |
| 2810 break_stat = getcbrk (); | |
| 2811 setcbrk (0); | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2812 #if __DJGPP__ < 2 |
| 13179 | 2813 install_ctrl_break_check (); |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2814 #endif |
| 13179 | 2815 |
| 2816 if (first_time) | |
| 2817 { | |
| 2818 inregs.h.ah = 0xc0; | |
| 2819 int86 (0x15, &inregs, &outregs); | |
| 2820 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0); | |
| 2821 | |
| 2822 have_mouse = 0; | |
| 2823 | |
| 2824 if (internal_terminal | |
| 2825 #ifdef HAVE_X_WINDOWS | |
| 2826 && inhibit_window_system | |
| 2827 #endif | |
| 2828 ) | |
| 2829 { | |
| 2830 inregs.x.ax = 0x0021; | |
| 2831 int86 (0x33, &inregs, &outregs); | |
| 2832 have_mouse = (outregs.x.ax & 0xffff) == 0xffff; | |
| 2833 if (!have_mouse) | |
| 2834 { | |
| 2835 /* Reportedly, the above doesn't work for some mouse drivers. There | |
| 2836 is an additional detection method that should work, but might be | |
| 2837 a little slower. Use that as an alternative. */ | |
| 2838 inregs.x.ax = 0x0000; | |
| 2839 int86 (0x33, &inregs, &outregs); | |
| 2840 have_mouse = (outregs.x.ax & 0xffff) == 0xffff; | |
| 2841 } | |
| 2842 | |
| 2843 if (have_mouse) | |
| 2844 { | |
| 2845 have_mouse = 1; /* enable mouse */ | |
| 2846 mouse_visible = 0; | |
| 2847 | |
| 2848 if (outregs.x.bx == 3) | |
| 2849 { | |
| 2850 mouse_button_count = 3; | |
| 2851 mouse_button_translate[0] = 0; /* Left */ | |
| 2852 mouse_button_translate[1] = 2; /* Middle */ | |
| 2853 mouse_button_translate[2] = 1; /* Right */ | |
| 2854 } | |
| 2855 else | |
| 2856 { | |
| 2857 mouse_button_count = 2; | |
| 2858 mouse_button_translate[0] = 0; | |
| 2859 mouse_button_translate[1] = 1; | |
| 2860 } | |
| 2861 mouse_position_hook = &mouse_get_pos; | |
| 2862 mouse_init (); | |
| 2863 } | |
| 2864 } | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2865 |
| 13179 | 2866 first_time = 0; |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2867 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2868 #if __DJGPP__ >= 2 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2869 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2870 stdin_stat = setmode (fileno (stdin), O_BINARY); |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2871 return (stdin_stat != -1); |
| 13179 | 2872 } |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2873 else |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2874 return (setmode (fileno (stdin), O_BINARY) != -1); |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2875 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2876 #else /* __DJGPP__ < 2 */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2877 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2878 } |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2879 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2880 /* I think it is wrong to overwrite `stdin_stat' every time |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2881 but the first one this function is called, but I don't |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2882 want to change the way it used to work in v1.x.--EZ */ |
| 13179 | 2883 |
| 2884 inregs.x.ax = 0x4400; /* Get IOCTL status. */ | |
| 2885 inregs.x.bx = 0x00; /* 0 = stdin. */ | |
| 2886 intdos (&inregs, &outregs); | |
| 2887 stdin_stat = outregs.h.dl; | |
| 2888 | |
| 2889 inregs.x.dx = stdin_stat | 0x0020; /* raw mode */ | |
| 2890 inregs.x.ax = 0x4401; /* Set IOCTL status */ | |
| 2891 intdos (&inregs, &outregs); | |
| 2892 return !outregs.x.cflag; | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2893 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2894 #endif /* __DJGPP__ < 2 */ |
| 13179 | 2895 } |
| 2896 | |
| 2897 /* Restore status of standard input and Ctrl-C checking. */ | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2898 |
| 13179 | 2899 int |
| 2900 dos_ttcooked () | |
| 2901 { | |
| 2902 union REGS inregs, outregs; | |
| 2903 | |
| 2904 setcbrk (break_stat); | |
| 2905 mouse_off (); | |
| 2906 | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2907 #if __DJGPP__ >= 2 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2908 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2909 return (setmode (fileno (stdin), stdin_stat) != -1); |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2910 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2911 #else /* not __DJGPP__ >= 2 */ |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2912 |
| 13179 | 2913 inregs.x.ax = 0x4401; /* Set IOCTL status. */ |
| 2914 inregs.x.bx = 0x00; /* 0 = stdin. */ | |
| 2915 inregs.x.dx = stdin_stat; | |
| 2916 intdos (&inregs, &outregs); | |
| 2917 return !outregs.x.cflag; | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2918 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
2919 #endif /* not __DJGPP__ >= 2 */ |
| 13179 | 2920 } |
| 2921 | |
| 2922 | |
| 2923 /* Run command as specified by ARGV in directory DIR. | |
|
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2924 The command is run with input from TEMPIN, output to |
|
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2925 file TEMPOUT and stderr to TEMPERR. */ |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
2926 |
| 13179 | 2927 int |
|
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2928 run_msdos_command (argv, dir, tempin, tempout, temperr) |
| 13179 | 2929 unsigned char **argv; |
| 2930 Lisp_Object dir; | |
|
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2931 int tempin, tempout, temperr; |
| 13179 | 2932 { |
|
16310
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2933 char *saveargv1, *saveargv2, **envv, *lowcase_argv0, *pa, *pl; |
| 13179 | 2934 char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ |
| 2935 int msshell, result = -1; | |
| 2936 int in, out, inbak, outbak, errbak; | |
| 2937 int x, y; | |
| 2938 Lisp_Object cmd; | |
| 2939 | |
| 2940 /* Get current directory as MSDOS cwd is not per-process. */ | |
| 2941 getwd (oldwd); | |
| 2942 | |
|
16310
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2943 /* If argv[0] is the shell, it might come in any lettercase. |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2944 Since `Fmember' is case-sensitive, we need to downcase |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2945 argv[0], even if we are on case-preserving filesystems. */ |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2946 lowcase_argv0 = alloca (strlen (argv[0]) + 1); |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2947 for (pa = argv[0], pl = lowcase_argv0; *pa; pl++) |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2948 { |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2949 *pl = *pa++; |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2950 if (*pl >= 'A' && *pl <= 'Z') |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2951 *pl += 'a' - 'A'; |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2952 } |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2953 *pl = '\0'; |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2954 |
|
c987c025d448
(run_msdos_command): When testing whether a shell
Richard M. Stallman <rms@gnu.org>
parents:
16210
diff
changeset
|
2955 cmd = Ffile_name_nondirectory (build_string (lowcase_argv0)); |
| 13179 | 2956 msshell = !NILP (Fmember (cmd, Fsymbol_value (intern ("msdos-shells")))) |
| 2957 && !strcmp ("-c", argv[1]); | |
| 2958 if (msshell) | |
| 2959 { | |
| 2960 saveargv1 = argv[1]; | |
| 2961 saveargv2 = argv[2]; | |
| 2962 argv[1] = "/c"; | |
| 2963 if (argv[2]) | |
| 2964 { | |
| 2965 char *p = alloca (strlen (argv[2]) + 1); | |
| 2966 | |
| 2967 strcpy (argv[2] = p, saveargv2); | |
| 2968 while (*p && isspace (*p)) | |
| 2969 p++; | |
| 2970 while (*p && !isspace (*p)) | |
| 2971 if (*p == '/') | |
| 2972 *p++ = '\\'; | |
| 2973 else | |
| 2974 p++; | |
| 2975 } | |
| 2976 } | |
| 2977 | |
| 2978 /* Build the environment array. */ | |
| 2979 { | |
| 2980 extern Lisp_Object Vprocess_environment; | |
| 2981 Lisp_Object tmp, lst; | |
| 2982 int i, len; | |
| 2983 | |
| 2984 lst = Vprocess_environment; | |
| 2985 len = XFASTINT (Flength (lst)); | |
| 2986 | |
| 2987 envv = alloca ((len + 1) * sizeof (char *)); | |
| 2988 for (i = 0; i < len; i++) | |
| 2989 { | |
| 2990 tmp = Fcar (lst); | |
| 2991 lst = Fcdr (lst); | |
| 2992 CHECK_STRING (tmp, 0); | |
| 2993 envv[i] = alloca (XSTRING (tmp)->size + 1); | |
| 2994 strcpy (envv[i], XSTRING (tmp)->data); | |
| 2995 } | |
| 2996 envv[len] = (char *) 0; | |
| 2997 } | |
| 2998 | |
| 2999 if (STRINGP (dir)) | |
| 3000 chdir (XSTRING (dir)->data); | |
| 3001 inbak = dup (0); | |
| 3002 outbak = dup (1); | |
| 3003 errbak = dup (2); | |
| 3004 if (inbak < 0 || outbak < 0 || errbak < 0) | |
| 3005 goto done; /* Allocation might fail due to lack of descriptors. */ | |
| 3006 | |
| 3007 if (have_mouse > 0) | |
| 3008 mouse_get_xy (&x, &y); | |
| 3009 | |
| 3010 dos_ttcooked (); /* do it here while 0 = stdin */ | |
| 3011 | |
| 3012 dup2 (tempin, 0); | |
| 3013 dup2 (tempout, 1); | |
|
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
3014 dup2 (temperr, 2); |
| 13179 | 3015 |
|
15125
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3016 #if __DJGPP__ > 1 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3017 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3018 if (msshell && !argv[3]) |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3019 { |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3020 /* MS-DOS native shells are too restrictive. For starters, they |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3021 cannot grok commands longer than 126 characters. In DJGPP v2 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3022 and later, `system' is much smarter, so we'll call it instead. */ |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3023 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3024 extern char **environ; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3025 environ = envv; |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3026 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3027 /* A shell gets a single argument--its full command |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3028 line--whose original was saved in `saveargv2'. */ |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3029 result = system (saveargv2); |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3030 } |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3031 else |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3032 |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3033 #endif /* __DJGPP__ > 1 */ |
|
4dc406e38d68
(dos_get_modifiers): Restore missing comment terminator.
Richard M. Stallman <rms@gnu.org>
parents:
15096
diff
changeset
|
3034 |
| 13179 | 3035 result = spawnve (P_WAIT, argv[0], argv, envv); |
| 3036 | |
| 3037 dup2 (inbak, 0); | |
| 3038 dup2 (outbak, 1); | |
| 3039 dup2 (errbak, 2); | |
| 3040 close (inbak); | |
| 3041 close (outbak); | |
| 3042 close (errbak); | |
| 3043 | |
| 13274 | 3044 dos_ttraw (); |
| 13179 | 3045 if (have_mouse > 0) |
| 3046 { | |
| 3047 mouse_init (); | |
| 3048 mouse_moveto (x, y); | |
| 3049 } | |
|
16837
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
3050 |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
3051 /* Some programs might change the meaning of the highest bit of the |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
3052 text attribute byte, so we get blinking characters instead of the |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
3053 bright background colors. Restore that. */ |
|
7370bcad5cb1
(bright_bg): Save the original state of video blink bit.
Richard M. Stallman <rms@gnu.org>
parents:
16763
diff
changeset
|
3054 bright_bg (); |
| 13179 | 3055 |
| 3056 done: | |
| 3057 chdir (oldwd); | |
| 3058 if (msshell) | |
| 3059 { | |
| 3060 argv[1] = saveargv1; | |
| 3061 argv[2] = saveargv2; | |
| 3062 } | |
| 3063 return result; | |
| 3064 } | |
| 3065 | |
| 3066 croak (badfunc) | |
| 3067 char *badfunc; | |
| 3068 { | |
| 3069 fprintf (stderr, "%s not yet implemented\r\n", badfunc); | |
| 3070 reset_sys_modes (); | |
| 3071 exit (1); | |
| 3072 } | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
3073 |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
3074 #if __DJGPP__ < 2 |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
3075 |
| 13179 | 3076 /* ------------------------- Compatibility functions ------------------- |
| 3077 * gethostname | |
| 3078 * gettimeofday | |
| 3079 */ | |
| 3080 | |
|
14413
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
3081 /* Hostnames for a pc are not really funny, |
|
77ed54321a41
(dos_rawgetc): Allow simulation of `Mouse-3' by
Richard M. Stallman <rms@gnu.org>
parents:
14284
diff
changeset
|
3082 but they are used in change log so we emulate the best we can. */ |
| 13179 | 3083 |
| 3084 gethostname (p, size) | |
| 3085 char *p; | |
| 3086 int size; | |
| 3087 { | |
| 3088 char *q = egetenv ("HOSTNAME"); | |
| 3089 | |
| 3090 if (!q) q = "pc"; | |
| 3091 strcpy (p, q); | |
| 3092 return 0; | |
| 3093 } | |
| 3094 | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
3095 /* When time zones are set from Ms-Dos too many C-libraries are playing |
| 13179 | 3096 tricks with time values. We solve this by defining our own version |
| 3097 of `gettimeofday' bypassing GO32. Our version needs to be initialized | |
| 3098 once and after each call to `tzset' with TZ changed. That is | |
| 3099 accomplished by aliasing tzset to init_gettimeofday. */ | |
| 3100 | |
| 3101 static struct tm time_rec; | |
| 3102 | |
| 3103 int | |
| 3104 gettimeofday (struct timeval *tp, struct timezone *tzp) | |
| 3105 { | |
| 3106 if (tp) | |
| 3107 { | |
| 3108 struct time t; | |
| 3109 struct tm tm; | |
| 3110 | |
| 3111 gettime (&t); | |
| 3112 if (t.ti_hour < time_rec.tm_hour) /* midnight wrap */ | |
| 3113 { | |
| 3114 struct date d; | |
| 3115 getdate (&d); | |
| 3116 time_rec.tm_year = d.da_year - 1900; | |
| 3117 time_rec.tm_mon = d.da_mon - 1; | |
| 3118 time_rec.tm_mday = d.da_day; | |
| 3119 } | |
| 3120 | |
| 3121 time_rec.tm_hour = t.ti_hour; | |
| 3122 time_rec.tm_min = t.ti_min; | |
| 3123 time_rec.tm_sec = t.ti_sec; | |
| 3124 | |
| 3125 tm = time_rec; | |
| 3126 tm.tm_gmtoff = dos_timezone_offset; | |
| 3127 | |
| 3128 tp->tv_sec = mktime (&tm); /* may modify tm */ | |
| 3129 tp->tv_usec = t.ti_hund * (1000000 / 100); | |
| 3130 } | |
| 3131 /* Ignore tzp; it's obsolescent. */ | |
| 3132 return 0; | |
| 3133 } | |
| 3134 | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
3135 #endif /* __DJGPP__ < 2 */ |
| 13179 | 3136 |
| 3137 /* | |
| 3138 * A list of unimplemented functions that we silently ignore. | |
| 3139 */ | |
| 3140 | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
3141 #if __DJGPP__ < 2 |
| 13179 | 3142 unsigned alarm (s) unsigned s; {} |
| 3143 fork () { return 0; } | |
| 3144 int kill (x, y) int x, y; { return -1; } | |
| 3145 nice (p) int p; {} | |
| 3146 void volatile pause () {} | |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
3147 sigsetmask (x) int x; { return 0; } |
|
16872
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3148 sigblock (mask) int mask; { return 0; } |
|
14974
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
3149 #endif |
|
b99490300747
[MSDOS]: If DJGPP version 2, include fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
14783
diff
changeset
|
3150 |
| 13179 | 3151 request_sigio () {} |
| 3152 setpgrp () {return 0; } | |
| 3153 setpriority (x,y,z) int x,y,z; { return 0; } | |
|
16872
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3154 unrequest_sigio () {} |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3155 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3156 #if __DJGPP__ > 1 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3157 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3158 #ifdef POSIX_SIGNALS |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3159 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3160 /* Augment DJGPP library POSIX signal functions. This is needed |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3161 as of DJGPP v2.01, but might be in the library in later releases. */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3162 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3163 #include <libc/bss.h> |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3164 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3165 /* A counter to know when to re-initialize the static sets. */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3166 static int sigprocmask_count = -1; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3167 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3168 /* Which signals are currently blocked (initially none). */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3169 static sigset_t current_mask; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3170 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3171 /* Which signals are pending (initially none). */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3172 static sigset_t pending_signals; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3173 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3174 /* Previous handlers to restore when the blocked signals are unblocked. */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3175 typedef void (*sighandler_t)(int); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3176 static sighandler_t prev_handlers[320]; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3177 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3178 /* A signal handler which just records that a signal occured |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3179 (it will be raised later, if and when the signal is unblocked). */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3180 static void |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3181 sig_suspender (signo) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3182 int signo; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3183 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3184 sigaddset (&pending_signals, signo); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3185 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3186 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3187 int |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3188 sigprocmask (how, new_set, old_set) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3189 int how; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3190 const sigset_t *new_set; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3191 sigset_t *old_set; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3192 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3193 int signo; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3194 sigset_t new_mask; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3195 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3196 /* If called for the first time, initialize. */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3197 if (sigprocmask_count != __bss_count) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3198 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3199 sigprocmask_count = __bss_count; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3200 sigemptyset (&pending_signals); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3201 sigemptyset (¤t_mask); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3202 for (signo = 0; signo < 320; signo++) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3203 prev_handlers[signo] = SIG_ERR; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3204 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3205 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3206 if (old_set) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3207 *old_set = current_mask; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3208 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3209 if (new_set == 0) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3210 return 0; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3211 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3212 if (how != SIG_BLOCK && how != SIG_UNBLOCK && how != SIG_SETMASK) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3213 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3214 errno = EINVAL; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3215 return -1; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3216 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3217 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3218 sigemptyset (&new_mask); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3219 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3220 /* DJGPP supports upto 320 signals. */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3221 for (signo = 0; signo < 320; signo++) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3222 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3223 if (sigismember (¤t_mask, signo)) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3224 sigaddset (&new_mask, signo); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3225 else if (sigismember (new_set, signo) && how != SIG_UNBLOCK) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3226 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3227 sigaddset (&new_mask, signo); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3228 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3229 /* SIGKILL is silently ignored, as on other platforms. */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3230 if (signo != SIGKILL && prev_handlers[signo] == SIG_ERR) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3231 prev_handlers[signo] = signal (signo, sig_suspender); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3232 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3233 if (( how == SIG_UNBLOCK |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3234 && sigismember (&new_mask, signo) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3235 && sigismember (new_set, signo)) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3236 || (how == SIG_SETMASK |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3237 && sigismember (&new_mask, signo) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3238 && !sigismember (new_set, signo))) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3239 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3240 sigdelset (&new_mask, signo); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3241 if (prev_handlers[signo] != SIG_ERR) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3242 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3243 signal (signo, prev_handlers[signo]); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3244 prev_handlers[signo] = SIG_ERR; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3245 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3246 if (sigismember (&pending_signals, signo)) |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3247 { |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3248 sigdelset (&pending_signals, signo); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3249 raise (signo); |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3250 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3251 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3252 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3253 current_mask = new_mask; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3254 return 0; |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3255 } |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3256 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3257 #else /* not POSIX_SIGNALS */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3258 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3259 sigsetmask (x) int x; { return 0; } |
|
14262
ef10a42c21f4
(sigblock): New (dummy) function.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
3260 sigblock (mask) int mask; { return 0; } |
|
16872
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3261 |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3262 #endif /* not POSIX_SIGNALS */ |
|
1efa81ac7e5a
* (sigprocmask, sig_suspender): New functions, implement
Eli Zaretskii <eliz@gnu.org>
parents:
16871
diff
changeset
|
3263 #endif /* __DJGPP__ > 1 */ |
| 13179 | 3264 |
| 3265 #ifndef HAVE_SELECT | |
| 3266 #include "sysselect.h" | |
| 3267 | |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3268 #ifndef EMACS_TIME_ZERO_OR_NEG_P |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3269 #define EMACS_TIME_ZERO_OR_NEG_P(time) \ |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3270 ((long)(time).tv_sec < 0 \ |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3271 || ((time).tv_sec == 0 \ |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3272 && (long)(time).tv_usec <= 0)) |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3273 #endif |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3274 |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3275 |
| 13179 | 3276 /* Only event queue is checked. */ |
| 14999 | 3277 /* We don't have to call timer_check here |
| 3278 because wait_reading_process_input takes care of that. */ | |
| 13179 | 3279 int |
| 3280 sys_select (nfds, rfds, wfds, efds, timeout) | |
| 3281 int nfds; | |
| 3282 SELECT_TYPE *rfds, *wfds, *efds; | |
| 3283 EMACS_TIME *timeout; | |
| 3284 { | |
| 3285 int check_input; | |
| 3286 struct time t; | |
| 3287 | |
| 3288 check_input = 0; | |
| 3289 if (rfds) | |
| 3290 { | |
| 3291 check_input = FD_ISSET (0, rfds); | |
| 3292 FD_ZERO (rfds); | |
| 3293 } | |
| 3294 if (wfds) | |
| 3295 FD_ZERO (wfds); | |
| 3296 if (efds) | |
| 3297 FD_ZERO (efds); | |
| 3298 | |
| 3299 if (nfds != 1) | |
| 3300 abort (); | |
| 3301 | |
| 3302 /* If we are looking only for the terminal, with no timeout, | |
| 3303 just read it and wait -- that's more efficient. */ | |
| 3304 if (!timeout) | |
| 3305 { | |
|
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3306 while (!detect_input_pending ()) |
|
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3307 { |
|
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3308 #if __DJGPP__ >= 2 |
|
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3309 __dpmi_yield (); |
|
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3310 #endif |
|
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3311 } |
| 13179 | 3312 } |
| 3313 else | |
| 3314 { | |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3315 EMACS_TIME clnow, cllast, cldiff; |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3316 |
|
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3317 gettime (&t); |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3318 EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L); |
| 13179 | 3319 |
| 3320 while (!check_input || !detect_input_pending ()) | |
| 3321 { | |
|
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3322 gettime (&t); |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3323 EMACS_SET_SECS_USECS (clnow, t.ti_sec, t.ti_hund * 10000L); |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3324 EMACS_SUB_TIME (cldiff, clnow, cllast); |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3325 |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3326 /* When seconds wrap around, we assume that no more than |
|
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3327 1 minute passed since last `gettime'. */ |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3328 if (EMACS_TIME_NEG_P (cldiff)) |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3329 EMACS_SET_SECS (cldiff, EMACS_SECS (cldiff) + 60); |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3330 EMACS_SUB_TIME (*timeout, *timeout, cldiff); |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3331 |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3332 /* Stop when timeout value crosses zero. */ |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
3333 if (EMACS_TIME_ZERO_OR_NEG_P (*timeout)) |
| 13179 | 3334 return 0; |
| 3335 cllast = clnow; | |
|
15033
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3336 #if __DJGPP__ >= 2 |
|
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3337 __dpmi_yield (); |
|
9e174c2b4ba6
(check_timer): Removed; use gettime instead.
Richard M. Stallman <rms@gnu.org>
parents:
14999
diff
changeset
|
3338 #endif |
| 13179 | 3339 } |
| 3340 } | |
| 3341 | |
| 3342 FD_SET (0, rfds); | |
| 3343 return 1; | |
| 3344 } | |
| 3345 #endif | |
| 3346 | |
| 3347 /* | |
| 14036 | 3348 * Define overlaid functions: |
| 13179 | 3349 * |
| 3350 * chdir -> sys_chdir | |
| 3351 * tzset -> init_gettimeofday | |
| 3352 * abort -> dos_abort | |
| 3353 */ | |
| 3354 | |
| 3355 #ifdef chdir | |
| 3356 #undef chdir | |
| 3357 extern int chdir (); | |
| 3358 | |
| 3359 int | |
| 3360 sys_chdir (path) | |
| 3361 const char* path; | |
| 3362 { | |
| 3363 int len = strlen (path); | |
| 3364 char *tmp = (char *)path; | |
| 3365 | |
| 3366 if (*tmp && tmp[1] == ':') | |
| 3367 { | |
| 3368 if (getdisk () != tolower (tmp[0]) - 'a') | |
| 3369 setdisk (tolower (tmp[0]) - 'a'); | |
| 3370 tmp += 2; /* strip drive: KFS 1995-07-06 */ | |
| 3371 len -= 2; | |
| 3372 } | |
| 3373 | |
| 3374 if (len > 1 && (tmp[len - 1] == '/')) | |
| 3375 { | |
| 3376 char *tmp1 = (char *) alloca (len + 1); | |
| 3377 strcpy (tmp1, tmp); | |
| 3378 tmp1[len - 1] = 0; | |
| 3379 tmp = tmp1; | |
| 3380 } | |
| 3381 return chdir (tmp); | |
| 3382 } | |
| 3383 #endif | |
| 3384 | |
| 3385 #ifdef tzset | |
| 3386 #undef tzset | |
| 3387 extern void tzset (void); | |
| 3388 | |
| 3389 void | |
| 3390 init_gettimeofday () | |
| 3391 { | |
| 3392 time_t ltm, gtm; | |
| 3393 struct tm *lstm; | |
| 3394 | |
| 3395 tzset (); | |
| 3396 ltm = gtm = time (NULL); | |
| 3397 ltm = mktime (lstm = localtime (<m)); | |
| 3398 gtm = mktime (gmtime (>m)); | |
| 3399 time_rec.tm_hour = 99; /* force gettimeofday to get date */ | |
| 3400 time_rec.tm_isdst = lstm->tm_isdst; | |
| 3401 dos_timezone_offset = time_rec.tm_gmtoff = (int)(gtm - ltm) / 60; | |
| 3402 } | |
| 3403 #endif | |
| 3404 | |
| 3405 #ifdef abort | |
| 3406 #undef abort | |
| 3407 void | |
| 3408 dos_abort (file, line) | |
| 3409 char *file; | |
| 3410 int line; | |
| 3411 { | |
| 3412 char buffer1[200], buffer2[400]; | |
| 3413 int i, j; | |
| 3414 | |
| 3415 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line); | |
| 3416 for (i = j = 0; buffer1[i]; i++) { | |
| 3417 buffer2[j++] = buffer1[i]; | |
| 3418 buffer2[j++] = 0x70; | |
| 3419 } | |
| 3420 dosmemput (buffer2, j, (int)ScreenPrimary); | |
| 3421 ScreenSetCursor (2, 0); | |
| 3422 abort (); | |
| 3423 } | |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3424 #else |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3425 void |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3426 abort () |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3427 { |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3428 dos_ttcooked (); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3429 ScreenSetCursor (10, 0); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3430 cputs ("\r\n\nEmacs aborted!\r\n"); |
| 14999 | 3431 #if __DJGPP__ > 1 |
| 3432 /* Generate traceback, so we could tell whodunit. */ | |
| 3433 signal (SIGINT, SIG_DFL); | |
| 3434 __asm__ __volatile__ ("movb $0x1b,%al;call ___djgpp_hw_exception"); | |
| 3435 #endif | |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3436 exit (2); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
3437 } |
| 13179 | 3438 #endif |
| 3439 | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3440 syms_of_msdos () |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3441 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3442 recent_doskeys = Fmake_vector (make_number (NUM_RECENT_DOSKEYS), Qnil); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3443 staticpro (&recent_doskeys); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3444 |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3445 defsubr (&Srecent_doskeys); |
|
15186
242bddc25e5a
(syms_of_msdos): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
15174
diff
changeset
|
3446 defsubr (&Smsdos_long_file_names); |
|
15219
a800d1a0f07e
(msdos_downcase_filename): New function to convert case in filenames.
Richard M. Stallman <rms@gnu.org>
parents:
15186
diff
changeset
|
3447 defsubr (&Smsdos_downcase_filename); |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3448 } |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
3449 |
| 5503 | 3450 #endif /* MSDOS */ |
