Mercurial > emacs
annotate src/msdos.c @ 14284:0eaecdc13142
(dos_set_window_size): New function; switches the screen
to the size as close as possible to requested frame dimensions.
| author | Karl Heuer <kwzh@gnu.org> |
|---|---|
| date | Wed, 24 Jan 1996 22:33:08 +0000 |
| parents | 085bc709c11d |
| children | 77ed54321a41 |
| 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. |
| 13642 | 2 Copyright (C) 1993, 1994, 1995 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> | |
| 35 #include "dosfns.h" | |
| 36 #include "msdos.h" | |
| 37 #include "systime.h" | |
| 38 #include "termhooks.h" | |
| 9572 | 39 #include "dispextern.h" |
| 40 #include "termopts.h" | |
| 5503 | 41 #include "frame.h" |
| 9572 | 42 #include "window.h" |
| 5503 | 43 #include <go32.h> |
| 44 #include <pc.h> | |
| 45 #include <ctype.h> | |
| 46 /* #include <process.h> */ | |
| 47 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */ | |
| 48 #define P_WAIT 1 | |
| 49 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
50 |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
51 static unsigned long |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
52 event_timestamp () |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
53 { |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
54 struct time t; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
55 unsigned long s; |
| 13179 | 56 |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
57 gettime (&t); |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
58 s = t.ti_min; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
59 s *= 60; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
60 s += t.ti_sec; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
61 s *= 1000; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
62 s += t.ti_hund * 10; |
| 13179 | 63 |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
64 return s; |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
65 } |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
66 |
| 13179 | 67 |
| 68 /* ------------------------ Mouse control --------------------------- | |
| 69 * | |
| 70 * Coordinates are in screen positions and zero based. | |
| 71 * Mouse buttons are numbered from left to right and also zero based. | |
| 72 */ | |
| 5503 | 73 |
| 13179 | 74 int have_mouse; /* 0: no, 1: enabled, -1: disabled */ |
| 75 static int mouse_visible; | |
| 5503 | 76 |
| 13179 | 77 static int mouse_last_x; |
| 78 static int mouse_last_y; | |
| 5503 | 79 |
| 13179 | 80 static int mouse_button_translate[NUM_MOUSE_BUTTONS]; |
| 81 static int mouse_button_count; | |
| 5503 | 82 |
| 13179 | 83 void |
| 84 mouse_on () | |
| 85 { | |
| 86 union REGS regs; | |
| 5503 | 87 |
| 13179 | 88 if (have_mouse > 0 && !mouse_visible) |
| 89 { | |
| 90 if (termscript) | |
| 91 fprintf (termscript, "<M_ON>"); | |
| 92 regs.x.ax = 0x0001; | |
| 93 int86 (0x33, ®s, ®s); | |
| 94 mouse_visible = 1; | |
| 5503 | 95 } |
| 96 } | |
| 97 | |
| 13179 | 98 void |
| 99 mouse_off () | |
| 5503 | 100 { |
| 13179 | 101 union REGS regs; |
| 5503 | 102 |
| 13179 | 103 if (have_mouse > 0 && mouse_visible) |
| 5503 | 104 { |
| 13179 | 105 if (termscript) |
| 106 fprintf (termscript, "<M_OFF>"); | |
| 107 regs.x.ax = 0x0002; | |
| 108 int86 (0x33, ®s, ®s); | |
| 109 mouse_visible = 0; | |
| 5503 | 110 } |
| 111 } | |
| 112 | |
| 113 void | |
| 13179 | 114 mouse_moveto (x, y) |
| 115 int x, y; | |
| 5503 | 116 { |
| 13179 | 117 union REGS regs; |
| 118 | |
| 119 if (termscript) | |
| 120 fprintf (termscript, "<M_XY=%dx%d>", x, y); | |
| 121 regs.x.ax = 0x0004; | |
| 122 mouse_last_x = regs.x.cx = x * 8; | |
| 123 mouse_last_y = regs.x.dx = y * 8; | |
| 124 int86 (0x33, ®s, ®s); | |
| 5503 | 125 } |
| 126 | |
| 13179 | 127 static int |
| 128 mouse_pressed (b, xp, yp) | |
| 129 int b, *xp, *yp; | |
| 130 { | |
| 131 union REGS regs; | |
| 132 | |
| 133 if (b >= mouse_button_count) | |
| 134 return 0; | |
| 135 regs.x.ax = 0x0005; | |
| 136 regs.x.bx = mouse_button_translate[b]; | |
| 137 int86 (0x33, ®s, ®s); | |
| 138 if (regs.x.bx) | |
| 139 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8; | |
| 140 return (regs.x.bx != 0); | |
| 141 } | |
| 142 | |
| 143 static int | |
| 144 mouse_released (b, xp, yp) | |
| 145 int b, *xp, *yp; | |
| 146 { | |
| 147 union REGS regs; | |
| 148 | |
| 149 if (b >= mouse_button_count) | |
| 150 return 0; | |
| 151 regs.x.ax = 0x0006; | |
| 152 regs.x.bx = mouse_button_translate[b]; | |
| 153 int86 (0x33, ®s, ®s); | |
| 154 if (regs.x.bx) | |
| 155 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8; | |
| 156 return (regs.x.bx != 0); | |
| 157 } | |
| 158 | |
| 159 static void | |
| 160 mouse_get_xy (int *x, int *y) | |
| 5503 | 161 { |
| 162 union REGS regs; | |
| 163 | |
| 13179 | 164 regs.x.ax = 0x0003; |
| 165 int86 (0x33, ®s, ®s); | |
| 166 *x = regs.x.cx / 8; | |
| 167 *y = regs.x.dx / 8; | |
| 168 } | |
| 169 | |
| 170 void | |
| 171 mouse_get_pos (f, insist, bar_window, part, x, y, time) | |
| 172 FRAME_PTR *f; | |
| 173 int insist; | |
| 174 Lisp_Object *bar_window, *x, *y; | |
| 175 enum scroll_bar_part *part; | |
| 176 unsigned long *time; | |
| 177 { | |
| 178 int ix, iy; | |
| 179 union REGS regs; | |
| 180 | |
| 181 regs.x.ax = 0x0003; | |
| 182 int86 (0x33, ®s, ®s); | |
| 183 *f = selected_frame; | |
| 184 *bar_window = Qnil; | |
| 185 mouse_get_xy (&ix, &iy); | |
| 186 selected_frame->mouse_moved = 0; | |
| 187 *x = make_number (ix); | |
| 188 *y = make_number (iy); | |
| 189 *time = event_timestamp (); | |
| 190 } | |
| 191 | |
| 192 static void | |
| 193 mouse_check_moved () | |
| 194 { | |
| 195 int x, y; | |
| 196 | |
| 197 mouse_get_xy (&x, &y); | |
| 198 selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y); | |
| 199 mouse_last_x = x; | |
| 200 mouse_last_y = y; | |
| 5503 | 201 } |
| 202 | |
| 13179 | 203 void |
| 204 mouse_init () | |
| 5503 | 205 { |
| 13179 | 206 union REGS regs; |
| 207 | |
| 208 if (termscript) | |
| 209 fprintf (termscript, "<M_INIT>"); | |
| 210 | |
| 211 regs.x.ax = 0x0021; | |
| 212 int86 (0x33, ®s, ®s); | |
| 213 | |
| 214 regs.x.ax = 0x0007; | |
| 215 regs.x.cx = 0; | |
| 216 regs.x.dx = 8 * (ScreenCols () - 1); | |
| 217 int86 (0x33, ®s, ®s); | |
| 218 | |
| 219 regs.x.ax = 0x0008; | |
| 220 regs.x.cx = 0; | |
| 221 regs.x.dx = 8 * (ScreenRows () - 1); | |
| 222 int86 (0x33, ®s, ®s); | |
| 223 | |
| 224 mouse_moveto (0, 0); | |
| 225 mouse_visible = 0; | |
| 226 } | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
227 |
| 13179 | 228 /* ------------------------- Screen control ---------------------- |
| 229 * | |
| 230 */ | |
| 5503 | 231 |
| 13179 | 232 static int internal_terminal = 0; |
| 233 | |
| 234 #ifndef HAVE_X_WINDOWS | |
| 235 extern unsigned char ScreenAttrib; | |
| 236 static int screen_face; | |
| 237 static int highlight; | |
| 238 | |
| 239 static int screen_size_X; | |
| 240 static int screen_size_Y; | |
| 241 static int screen_size; | |
| 242 | |
| 243 static int current_pos_X; | |
| 244 static int current_pos_Y; | |
| 245 static int new_pos_X; | |
| 246 static int new_pos_Y; | |
| 247 | |
| 248 static void *startup_screen_buffer; | |
| 249 static int startup_screen_size_X; | |
| 250 static int startup_screen_size_Y; | |
| 251 static int startup_pos_X; | |
| 252 static int startup_pos_Y; | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
253 static unsigned char startup_screen_attrib; |
| 13179 | 254 |
| 255 static int term_setup_done; | |
| 256 | |
| 257 /* 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
|
258 struct x_output the_only_x_display; |
| 13179 | 259 |
| 260 /* This is never dereferenced. */ | |
| 261 Display *x_current_display; | |
| 5503 | 262 |
| 263 | |
| 13179 | 264 #define SCREEN_SET_CURSOR() \ |
| 265 if (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y) \ | |
| 266 ScreenSetCursor (current_pos_Y = new_pos_Y, current_pos_X = new_pos_X) | |
| 5503 | 267 |
| 13179 | 268 static |
| 269 dos_direct_output (y, x, buf, len) | |
| 270 int y; | |
| 271 int x; | |
| 272 char *buf; | |
| 273 int len; | |
| 5503 | 274 { |
| 13179 | 275 int t = (int) ScreenPrimary + 2 * (x + y * screen_size_X); |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
276 |
| 13179 | 277 while (--len >= 0) { |
| 278 dosmemput (buf++, 1, t); | |
| 279 t += 2; | |
| 280 } | |
| 5503 | 281 } |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
282 #endif |
| 5503 | 283 |
| 284 /* Flash the screen as a substitute for BEEPs. */ | |
| 285 | |
| 13179 | 286 #if (__DJGPP__ < 2) |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
287 static void |
|
7667
bae9c0fa1c2f
(do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents:
7666
diff
changeset
|
288 do_visible_bell (xorattr) |
| 5503 | 289 unsigned char xorattr; |
| 290 { | |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
291 asm volatile |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
292 (" movb $1,%%dl |
| 5503 | 293 visible_bell_0: |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
294 movl _ScreenPrimary,%%eax |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
295 call dosmemsetup |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
296 movl %%eax,%%ebx |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
297 movl %1,%%ecx |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
298 movb %0,%%al |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
299 incl %%ebx |
| 5503 | 300 visible_bell_1: |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
301 xorb %%al,%%gs:(%%ebx) |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
302 addl $2,%%ebx |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
303 decl %%ecx |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
304 jne visible_bell_1 |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
305 decb %%dl |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
306 jne visible_bell_3 |
| 5503 | 307 visible_bell_2: |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
308 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
309 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
310 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
311 movzwl %%ax,%%eax |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
312 decw %%cx |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
313 jne visible_bell_2 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
314 jmp visible_bell_0 |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
315 visible_bell_3:" |
|
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
316 : /* no output */ |
| 13179 | 317 : "m" (xorattr), "g" (screen_size) |
|
8183
d35fd7fd0ef8
(install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7821
diff
changeset
|
318 : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx"); |
| 5503 | 319 } |
| 320 | |
| 13179 | 321 static void |
| 322 ScreenVisualBell (void) | |
| 323 { | |
| 324 /* This creates an xor-mask that will swap the default fore- and | |
| 325 background colors. */ | |
| 326 do_visible_bell (((the_only_x_display.foreground_pixel | |
| 327 ^ the_only_x_display.background_pixel) | |
| 328 * 0x11) & 0x7f); | |
| 329 } | |
| 330 #endif | |
| 331 | |
| 332 #ifndef HAVE_X_WINDOWS | |
| 333 | |
|
14284
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
334 /* 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
|
335 ROWS x COLS frame. */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
336 void |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
337 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
|
338 int *rows, *cols; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
339 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
340 char video_name[30]; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
341 Lisp_Object video_mode; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
342 int video_mode_value; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
343 int have_vga = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
344 union REGS regs; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
345 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
|
346 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
347 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
|
348 return; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
349 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
350 /* Do we have a VGA? */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
351 regs.x.ax = 0x1a00; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
352 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
353 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
|
354 have_vga = 1; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
355 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
356 mouse_off (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
357 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
358 /* If the user specify a special video mode for these dimensions, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
359 use that mode. */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
360 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
|
361 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
|
362 Qnil))-> value; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
363 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
364 if (INTEGERP (video_mode) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
365 && (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
|
366 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
367 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
|
368 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
369 regs.h.bl = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
370 regs.x.ax = 0x1003; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
371 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
372 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
373 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
374 /* 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
|
375 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
|
376 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
377 #if __DJGPP__ > 1 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
378 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
379 else |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
380 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
381 static struct { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
382 int rows; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
383 int need_vga; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
384 } std_dimension[] = { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
385 {25, 0}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
386 {28, 1}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
387 {35, 0}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
388 {40, 1}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
389 {43, 0}, |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
390 {50, 1} |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
391 }; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
392 int i = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
393 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
394 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
|
395 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
396 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
|
397 && std_dimension[i].rows >= *rows) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
398 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
399 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
|
400 || *cols != current_cols) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
401 _set_screen_lines (*rows); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
402 break; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
403 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
404 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
405 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
406 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
407 #else /* not __DJGPP__ > 1 */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
408 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
409 else if (*rows <= 25) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
410 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
411 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
|
412 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
413 regs.x.ax = 3; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
414 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
415 regs.x.ax = 0x1101; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
416 regs.h.bl = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
417 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
418 regs.x.ax = 0x1200; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
419 regs.h.bl = 32; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
420 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
421 regs.x.ax = 3; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
422 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
423 } |
|
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 else if (*rows <= 50) |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
426 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
|
427 || *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
|
428 { |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
429 regs.x.ax = 3; |
|
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 regs.x.ax = 0x1112; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
432 regs.h.bl = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
433 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
434 regs.x.ax = 0x1200; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
435 regs.h.bl = 32; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
436 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
437 regs.x.ax = 0x0100; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
438 regs.x.cx = 7; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
439 int86 (0x10, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
440 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
441 #endif /* not __DJGPP__ > 1 */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
442 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
443 if (have_mouse) |
|
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 /* Must hardware-reset the mouse, or else it won't update |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
446 its notion of screen dimensions. */ |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
447 regs.x.ax = 0; |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
448 int86 (0x33, ®s, ®s); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
449 mouse_init (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
450 mouse_on (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
451 } |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
452 |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
453 /* 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
|
454 *rows = ScreenRows (); |
|
0eaecdc13142
(dos_set_window_size): New function; switches the screen
Karl Heuer <kwzh@gnu.org>
parents:
14279
diff
changeset
|
455 *cols = ScreenCols (); |
|
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 |
| 13179 | 458 /* |
| 459 * If we write a character in the position where the mouse is, | |
| 460 * the mouse cursor may need to be refreshed. | |
| 461 */ | |
|
7744
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
462 |
|
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
463 static void |
| 13179 | 464 mouse_off_maybe () |
|
7744
da18793f532d
(output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7667
diff
changeset
|
465 { |
| 13179 | 466 int x, y; |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
467 |
| 13179 | 468 if (!mouse_visible) |
| 469 return; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
470 |
| 13179 | 471 mouse_get_xy (&x, &y); |
| 472 if (y != new_pos_Y || x < new_pos_X) | |
| 473 return; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
474 |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
475 mouse_off (); |
| 9572 | 476 } |
| 477 | |
| 478 static | |
| 479 IT_ring_bell () | |
| 480 { | |
| 481 if (visible_bell) | |
| 482 { | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
483 mouse_off (); |
| 13179 | 484 ScreenVisualBell (); |
| 9572 | 485 } |
| 486 else | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
487 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
488 union REGS inregs, outregs; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
489 inregs.h.ah = 2; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
490 inregs.h.dl = 7; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
491 intdos (&inregs, &outregs); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
492 } |
| 9572 | 493 } |
| 494 | |
| 495 static void | |
| 496 IT_set_face (int face) | |
| 497 { | |
| 498 struct face *fp; | |
| 499 extern struct face *intern_face (/* FRAME_PTR, struct face * */); | |
| 500 | |
| 501 if (face == 1 || (face == 0 && highlight)) | |
| 502 fp = FRAME_MODE_LINE_FACE (foo); | |
| 503 else if (face <= 0 || face >= FRAME_N_COMPUTED_FACES (foo)) | |
| 504 fp = FRAME_DEFAULT_FACE (foo); | |
| 505 else | |
| 506 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
|
507 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
508 fprintf (termscript, "<FACE:%d:%d>", FACE_FOREGROUND (fp), FACE_BACKGROUND (fp)); |
| 13179 | 509 screen_face = face; |
| 510 ScreenAttrib = (FACE_BACKGROUND (fp) << 4) | FACE_FOREGROUND (fp); | |
| 9572 | 511 } |
| 512 | |
| 513 static | |
| 514 IT_write_glyphs (GLYPH *str, int len) | |
| 515 { | |
| 516 int newface; | |
| 13179 | 517 int ch, l = len; |
| 518 unsigned char *buf, *bp; | |
| 519 | |
| 520 if (len == 0) return; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
521 |
| 13179 | 522 buf = bp = alloca (len * 2); |
| 523 | |
| 524 while (--l >= 0) | |
| 9572 | 525 { |
| 526 newface = FAST_GLYPH_FACE (*str); | |
| 13179 | 527 if (newface != screen_face) |
| 528 IT_set_face (newface); | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
529 ch = FAST_GLYPH_CHAR (*str); |
| 13179 | 530 *bp++ = (unsigned char)ch; |
| 531 *bp++ = ScreenAttrib; | |
| 532 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
533 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
534 fputc (ch, termscript); |
| 13179 | 535 str++; |
| 9572 | 536 } |
| 13179 | 537 |
| 538 mouse_off_maybe (); | |
| 539 dosmemput (buf, 2 * len, | |
| 540 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | |
| 541 new_pos_X += len; | |
| 9572 | 542 } |
| 543 | |
| 544 static | |
| 545 IT_clear_end_of_line (first_unused) | |
| 546 { | |
| 13179 | 547 char *spaces, *sp; |
| 548 int i, j; | |
| 549 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
550 IT_set_face (0); |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
551 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
552 fprintf (termscript, "<CLR:EOL>"); |
| 13179 | 553 i = (j = screen_size_X - new_pos_X) * 2; |
| 554 spaces = sp = alloca (i); | |
| 555 | |
| 556 while (--j >= 0) | |
| 557 { | |
| 558 *sp++ = ' '; | |
| 559 *sp++ = ScreenAttrib; | |
| 560 } | |
| 561 | |
| 562 mouse_off_maybe (); | |
| 563 dosmemput (spaces, i, | |
| 564 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y)); | |
| 565 } | |
| 566 | |
| 567 static | |
| 568 IT_clear_screen (void) | |
| 569 { | |
| 570 if (termscript) | |
| 571 fprintf (termscript, "<CLR:SCR>"); | |
| 572 IT_set_face (0); | |
| 573 mouse_off (); | |
| 574 ScreenClear (); | |
| 575 new_pos_X = new_pos_Y = 0; | |
| 576 } | |
| 577 | |
| 578 static | |
| 579 IT_clear_to_end (void) | |
| 580 { | |
| 581 if (termscript) | |
| 582 fprintf (termscript, "<CLR:EOS>"); | |
| 583 | |
| 584 while (new_pos_Y < screen_size_Y) { | |
| 585 new_pos_X = 0; | |
| 586 IT_clear_end_of_line (0); | |
| 587 new_pos_Y++; | |
| 588 } | |
| 9572 | 589 } |
| 590 | |
| 591 static | |
| 592 IT_cursor_to (int y, int x) | |
| 593 { | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
594 if (termscript) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
595 fprintf (termscript, "\n<XY=%dx%d>", x, y); |
| 13179 | 596 new_pos_X = x; |
| 597 new_pos_Y = y; | |
| 9572 | 598 } |
| 599 | |
| 13179 | 600 static |
| 9572 | 601 IT_reassert_line_highlight (new, vpos) |
| 602 int new, vpos; | |
| 603 { | |
| 604 highlight = new; | |
| 605 IT_set_face (0); /* To possibly clear the highlighting. */ | |
| 606 } | |
| 607 | |
| 608 static | |
| 609 IT_change_line_highlight (new_highlight, vpos, first_unused_hpos) | |
| 610 { | |
| 611 highlight = new_highlight; | |
| 612 IT_set_face (0); /* To possibly clear the highlighting. */ | |
| 613 IT_cursor_to (vpos, 0); | |
| 614 IT_clear_end_of_line (first_unused_hpos); | |
| 615 } | |
| 616 | |
| 617 static | |
| 618 IT_update_begin () | |
| 619 { | |
| 620 highlight = 0; | |
| 621 IT_set_face (0); /* To possibly clear the highlighting. */ | |
| 13179 | 622 screen_face = -1; |
| 623 } | |
| 624 | |
| 625 static | |
| 626 IT_update_end () | |
| 627 { | |
| 9572 | 628 } |
| 629 | |
| 630 /* This was more or less copied from xterm.c */ | |
| 631 static void | |
| 632 IT_set_menu_bar_lines (window, n) | |
| 633 Lisp_Object window; | |
| 634 int n; | |
| 635 { | |
| 636 struct window *w = XWINDOW (window); | |
| 637 | |
|
13646
7714b87119a3
(IT_set_menu_bar_lines): Clear last_modified field.
Richard M. Stallman <rms@gnu.org>
parents:
13642
diff
changeset
|
638 XSETFASTINT (w->last_modified, 0); |
| 9572 | 639 XSETFASTINT (w->top, XFASTINT (w->top) + n); |
| 640 XSETFASTINT (w->height, XFASTINT (w->height) - n); | |
| 641 | |
| 642 /* Handle just the top child in a vertical split. */ | |
| 643 if (!NILP (w->vchild)) | |
| 644 IT_set_menu_bar_lines (w->vchild, n); | |
| 645 | |
| 646 /* Adjust all children in a horizontal split. */ | |
| 647 for (window = w->hchild; !NILP (window); window = w->next) | |
| 648 { | |
| 649 w = XWINDOW (window); | |
| 650 IT_set_menu_bar_lines (window, n); | |
| 651 } | |
| 652 } | |
| 653 | |
| 13179 | 654 /* |
| 655 * IT_set_terminal_modes is called when emacs is started, | |
| 656 * resumed, and whenever the screen is redrawn! | |
| 657 */ | |
| 658 | |
| 659 static | |
| 660 IT_set_terminal_modes (void) | |
| 661 { | |
| 662 char *colors; | |
| 663 FRAME_PTR f; | |
| 664 struct face *fp; | |
| 665 | |
| 666 if (termscript) | |
| 667 fprintf (termscript, "\n<SET_TERM>"); | |
| 668 highlight = 0; | |
| 669 | |
| 670 screen_size_X = ScreenCols (); | |
| 671 screen_size_Y = ScreenRows (); | |
| 672 screen_size = screen_size_X * screen_size_Y; | |
| 673 | |
| 674 new_pos_X = new_pos_Y = 0; | |
| 675 current_pos_X = current_pos_Y = -1; | |
| 676 | |
| 677 if (term_setup_done) | |
| 678 return; | |
| 679 term_setup_done = 1; | |
| 680 | |
| 681 startup_screen_size_X = screen_size_X; | |
| 682 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
|
683 startup_screen_attrib = ScreenAttrib; |
| 13179 | 684 |
| 685 ScreenGetCursor (&startup_pos_Y, &startup_pos_X); | |
| 686 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); | |
| 687 | |
| 688 if (termscript) | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
689 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
|
690 screen_size_X, screen_size_Y); |
| 13179 | 691 } |
| 692 | |
| 693 /* | |
| 694 * IT_reset_terminal_modes is called when emacs is | |
| 695 * suspended or killed. | |
| 696 */ | |
| 697 | |
| 698 static | |
| 699 IT_reset_terminal_modes (void) | |
| 700 { | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
701 int display_row_start = (int) ScreenPrimary; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
702 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
|
703 int update_row_len = ScreenCols () * 2; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
704 int current_rows = ScreenRows (); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
705 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
|
706 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
|
707 int cursor_pos_X = ScreenCols () - 1; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
708 int cursor_pos_Y = ScreenRows () - 1; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
709 |
| 13179 | 710 if (termscript) |
| 13274 | 711 fprintf (termscript, "\n<RESET_TERM>"); |
| 13179 | 712 |
| 713 highlight = 0; | |
| 714 | |
| 715 if (!term_setup_done) | |
| 716 return; | |
| 717 | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
718 mouse_off (); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
719 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
720 /* We have a situation here. |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
721 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
|
722 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
|
723 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
|
724 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
|
725 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
|
726 `startup_screen_buffer'. |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
727 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
|
728 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
|
729 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
|
730 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
|
731 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
732 ScreenAttrib = startup_screen_attrib; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
733 ScreenClear (); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
734 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
735 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
|
736 update_row_len = saved_row_len; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
737 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
|
738 current_rows = startup_screen_size_Y; |
| 13179 | 739 |
| 740 if (termscript) | |
|
13717
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
741 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
|
742 update_row_len / 2, current_rows); |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
743 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
744 while (current_rows--) |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
745 { |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
746 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
|
747 saved_row += saved_row_len; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
748 display_row_start += to_next_row; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
749 } |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
750 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
|
751 cursor_pos_X = startup_pos_X; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
752 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
|
753 cursor_pos_Y = startup_pos_Y; |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
754 |
|
d7bb4093a950
(IT_set_terminal_modes): Save screen color attribute
Karl Heuer <kwzh@gnu.org>
parents:
13714
diff
changeset
|
755 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
|
756 xfree (startup_screen_buffer); |
| 13179 | 757 |
| 758 term_setup_done = 0; | |
| 759 } | |
| 760 | |
| 761 static | |
| 762 IT_set_terminal_window (void) | |
| 763 { | |
| 764 } | |
| 765 | |
| 9572 | 766 void |
| 767 IT_set_frame_parameters (frame, alist) | |
| 768 FRAME_PTR frame; | |
| 769 Lisp_Object alist; | |
| 770 { | |
| 771 Lisp_Object tail; | |
| 772 int redraw; | |
| 773 extern unsigned long load_color (); | |
| 774 FRAME_PTR f = (FRAME_PTR) &the_only_frame; | |
| 775 | |
| 776 redraw = 0; | |
| 777 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) | |
| 778 { | |
| 779 Lisp_Object elt, prop, val; | |
| 780 | |
| 781 elt = Fcar (tail); | |
| 782 prop = Fcar (elt); | |
| 783 val = Fcdr (elt); | |
| 784 CHECK_SYMBOL (prop, 1); | |
| 785 | |
| 786 if (EQ (prop, intern ("foreground-color"))) | |
| 787 { | |
| 788 unsigned long new_color = load_color (f, val); | |
| 789 if (new_color != ~0) | |
| 790 { | |
| 791 FRAME_FOREGROUND_PIXEL (f) = new_color; | |
| 792 redraw = 1; | |
| 793 } | |
| 794 } | |
| 795 else if (EQ (prop, intern ("background-color"))) | |
| 796 { | |
| 797 unsigned long new_color = load_color (f, val); | |
| 798 if (new_color != ~0) | |
| 799 { | |
| 800 FRAME_BACKGROUND_PIXEL (f) = new_color & ~8; | |
| 801 redraw = 1; | |
| 802 } | |
| 803 } | |
| 804 else if (EQ (prop, intern ("menu-bar-lines"))) | |
| 805 { | |
| 806 int new; | |
| 807 int old = FRAME_MENU_BAR_LINES (the_only_frame); | |
| 808 | |
| 809 if (INTEGERP (val)) | |
| 810 new = XINT (val); | |
| 811 else | |
| 812 new = 0; | |
| 813 FRAME_MENU_BAR_LINES (f) = new; | |
| 814 IT_set_menu_bar_lines (the_only_frame.root_window, new - old); | |
| 815 } | |
| 816 } | |
| 817 | |
| 818 if (redraw) | |
| 819 { | |
| 820 recompute_basic_faces (f); | |
| 821 Fredraw_frame (Fselected_frame ()); | |
| 822 } | |
| 823 } | |
| 824 | |
| 13179 | 825 #endif /* !HAVE_X_WINDOWS */ |
| 9572 | 826 |
| 827 | |
| 5503 | 828 /* Do we need the internal terminal? */ |
| 829 void | |
| 830 internal_terminal_init () | |
| 831 { | |
| 832 char *term = getenv ("TERM"); | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
833 char *colors; |
| 13179 | 834 |
| 9572 | 835 #ifdef HAVE_X_WINDOWS |
| 836 if (!inhibit_window_system) | |
| 837 return; | |
| 838 #endif | |
| 839 | |
| 5503 | 840 internal_terminal |
| 841 = (!noninteractive) && term && !strcmp (term, "internal"); | |
| 9572 | 842 |
| 13179 | 843 if (getenv ("EMACSTEST")) |
| 13274 | 844 termscript = fopen (getenv ("EMACSTEST"), "wt"); |
| 13179 | 845 |
| 9572 | 846 #ifndef HAVE_X_WINDOWS |
| 13179 | 847 if (!internal_terminal || inhibit_window_system) |
| 9572 | 848 { |
| 13179 | 849 the_only_frame.output_method = output_termcap; |
| 850 return; | |
| 851 } | |
| 9572 | 852 |
| 13179 | 853 Vwindow_system = intern ("pc"); |
| 854 Vwindow_system_version = make_number (1); | |
| 855 | |
| 856 bzero (&the_only_x_display, sizeof the_only_x_display); | |
| 857 the_only_x_display.background_pixel = 7; /* White */ | |
| 858 the_only_x_display.foreground_pixel = 0; /* Black */ | |
| 13274 | 859 colors = getenv ("EMACSCOLORS"); |
| 13179 | 860 if (colors && strlen (colors) >= 2) |
| 861 { | |
| 862 the_only_x_display.foreground_pixel = colors[0] & 0x07; | |
| 863 the_only_x_display.background_pixel = colors[1] & 0x07; | |
| 864 } | |
| 865 the_only_x_display.line_height = 1; | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
866 the_only_frame.output_data.x = &the_only_x_display; |
| 13179 | 867 the_only_frame.output_method = output_msdos_raw; |
|
13625
397f07418271
(internal_terminal_init): Initialize the_only_x_display.font.
Richard M. Stallman <rms@gnu.org>
parents:
13624
diff
changeset
|
868 the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */ |
| 9572 | 869 |
| 13179 | 870 init_frame_faces ((FRAME_PTR) &the_only_frame); |
| 871 | |
| 872 ring_bell_hook = IT_ring_bell; | |
| 873 write_glyphs_hook = IT_write_glyphs; | |
| 874 cursor_to_hook = raw_cursor_to_hook = IT_cursor_to; | |
| 875 clear_to_end_hook = IT_clear_to_end; | |
| 876 clear_end_of_line_hook = IT_clear_end_of_line; | |
| 877 clear_frame_hook = IT_clear_screen; | |
| 878 change_line_highlight_hook = IT_change_line_highlight; | |
| 879 update_begin_hook = IT_update_begin; | |
| 880 update_end_hook = IT_update_end; | |
| 881 reassert_line_highlight_hook = IT_reassert_line_highlight; | |
| 882 | |
| 883 /* These hooks are called by term.c without being checked. */ | |
| 884 set_terminal_modes_hook = IT_set_terminal_modes; | |
| 885 reset_terminal_modes_hook = IT_reset_terminal_modes; | |
| 886 set_terminal_window_hook = IT_set_terminal_window; | |
| 9572 | 887 #endif |
| 5503 | 888 } |
| 13179 | 889 |
| 890 dos_get_saved_screen (screen, rows, cols) | |
| 891 char **screen; | |
| 892 int *rows; | |
| 893 int *cols; | |
| 894 { | |
| 895 #ifndef HAVE_X_WINDOWS | |
| 896 *screen = startup_screen_buffer; | |
| 897 *cols = startup_screen_size_X; | |
| 898 *rows = startup_screen_size_Y; | |
| 899 return 1; | |
| 900 #else | |
| 901 return 0; | |
| 902 #endif | |
| 903 } | |
| 13274 | 904 |
| 13179 | 905 /* ----------------------- Keyboard control ---------------------- |
| 906 * | |
| 907 * Keymaps reflect the following keyboard layout: | |
| 908 * | |
| 909 * 0 1 2 3 4 5 6 7 8 9 10 11 12 BS | |
| 910 * TAB 15 16 17 18 19 20 21 22 23 24 25 26 (41) | |
| 911 * CLOK 30 31 32 33 34 35 36 37 38 39 40 (41) RET | |
| 912 * SH () 45 46 47 48 49 50 51 52 53 54 SHIFT | |
| 913 * SPACE | |
| 914 */ | |
| 915 | |
| 916 static int extended_kbd; /* 101 (102) keyboard present. */ | |
| 917 | |
| 918 struct dos_keyboard_map | |
| 919 { | |
| 920 char *unshifted; | |
| 921 char *shifted; | |
| 922 char *alt_gr; | |
| 923 }; | |
| 924 | |
|
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
925 |
| 13179 | 926 static struct dos_keyboard_map us_keyboard = { |
| 927 /* 0 1 2 3 4 5 */ | |
| 928 /* 01234567890123456789012345678901234567890 12345678901234 */ | |
| 929 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ", | |
| 930 /* 0123456789012345678901234567890123456789 012345678901234 */ | |
| 931 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ", | |
| 932 0 /* no Alt-Gr key */ | |
| 933 }; | |
| 934 | |
| 935 static struct dos_keyboard_map fr_keyboard = { | |
| 936 /* 0 1 2 3 4 5 */ | |
| 937 /* 012 3456789012345678901234567890123456789012345678901234 */ | |
| 938 "ý&‚\",(-Š_€…)= azertyuiop^$ qsdfghjklm—* wxcvbnm;:! ", | |
| 939 /* 0123456789012345678901234567890123456789012345678901234 */ | |
| 940 " 1234567890ø+ AZERTYUIOPùœ QSDFGHJKLM%æ WXCVBN?./õ ", | |
| 941 /* 01234567 89012345678901234567890123456789012345678901234 */ | |
| 942 " ~#{[|`\\^@]} Ï " | |
| 943 }; | |
| 944 | |
| 945 static struct dos_keyboard_map dk_keyboard = { | |
| 946 /* 0 1 2 3 4 5 */ | |
| 947 /* 0123456789012345678901234567890123456789012345678901234 */ | |
| 948 "«1234567890+| qwertyuiop†~ asdfghjkl‘›' zxcvbnm,.- ", | |
| 949 /* 01 23456789012345678901234567890123456789012345678901234 */ | |
| 950 "õ!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL’* ZXCVBNM;:_ ", | |
| 951 /* 0123456789012345678901234567890123456789012345678901234 */ | |
| 952 " @œ$ {[]} | " | |
| 953 }; | |
| 954 | |
| 955 static struct keyboard_layout_list | |
| 956 { | |
| 957 int country_code; | |
| 958 struct dos_keyboard_map *keyboard_map; | |
| 13274 | 959 } keyboard_layout_list[] = |
| 960 { | |
| 961 1, &us_keyboard, | |
| 962 33, &fr_keyboard, | |
| 963 45, &dk_keyboard | |
| 13179 | 964 }; |
| 965 | |
| 966 static struct dos_keyboard_map *keyboard; | |
| 967 static int keyboard_map_all; | |
|
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
968 |
|
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
969 int |
| 13179 | 970 dos_set_keyboard (code, always) |
| 971 int code; | |
| 972 int always; | |
|
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
973 { |
| 13179 | 974 int i; |
|
13624
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
975 |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
976 /* 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
|
977 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
|
978 keyboard_map_all = always; |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
979 dos_keyboard_layout = 1; |
|
47484dd9a970
(dos_set_keyboard): If CODE is not recognized,
Richard M. Stallman <rms@gnu.org>
parents:
13520
diff
changeset
|
980 |
| 13179 | 981 for (i = 0; i < (sizeof (keyboard_layout_list)/sizeof (struct keyboard_layout_list)); i++) |
| 982 if (code == keyboard_layout_list[i].country_code) | |
| 983 { | |
| 984 keyboard = keyboard_layout_list[i].keyboard_map; | |
| 985 keyboard_map_all = always; | |
| 986 dos_keyboard_layout = code; | |
| 987 return 1; | |
| 988 } | |
|
7523
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
989 return 0; |
|
8994727ff976
(gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents:
7507
diff
changeset
|
990 } |
| 13274 | 991 |
| 13179 | 992 #define Ignore 0x0000 |
| 993 #define Normal 0x0000 /* normal key - alt changes scan-code */ | |
| 994 #define FctKey 0x1000 /* func key if c == 0, else c */ | |
| 995 #define Special 0x2000 /* func key even if c != 0 */ | |
| 996 #define ModFct 0x3000 /* special if mod-keys, else 'c' */ | |
| 997 #define Map 0x4000 /* alt scan-code, map to unshift/shift key */ | |
| 998 #define KeyPad 0x5000 /* map to insert/kp-0 depending on c == 0xe0 */ | |
| 999 #define Grey 0x6000 /* Grey keypad key */ | |
| 1000 | |
| 1001 #define Alt 0x0100 /* alt scan-code */ | |
| 1002 #define Ctrl 0x0200 /* ctrl scan-code */ | |
| 1003 #define Shift 0x0400 /* shift scan-code */ | |
| 1004 | |
| 1005 static struct | |
| 1006 { | |
| 1007 unsigned char char_code; /* normal code */ | |
| 1008 unsigned char meta_code; /* M- code */ | |
| 1009 unsigned char keypad_code; /* keypad code */ | |
| 1010 unsigned char editkey_code; /* edit key */ | |
| 1011 } keypad_translate_map[] = { | |
| 1012 '0', '0', 0xb0, /* kp-0 */ 0x63, /* insert */ | |
| 1013 '1', '1', 0xb1, /* kp-1 */ 0x57, /* end */ | |
| 1014 '2', '2', 0xb2, /* kp-2 */ 0x54, /* down */ | |
| 1015 '3', '3', 0xb3, /* kp-3 */ 0x56, /* next */ | |
| 1016 '4', '4', 0xb4, /* kp-4 */ 0x51, /* left */ | |
| 1017 '5', '5', 0xb5, /* kp-5 */ 0xb5, /* kp-5 */ | |
| 1018 '6', '6', 0xb6, /* kp-6 */ 0x53, /* right */ | |
| 1019 '7', '7', 0xb7, /* kp-7 */ 0x50, /* home */ | |
| 1020 '8', '8', 0xb8, /* kp-8 */ 0x52, /* up */ | |
| 1021 '9', '9', 0xb9, /* kp-9 */ 0x55, /* prior */ | |
| 1022 '.', '-', 0xae, /* kp-decimal */ 0xff /* delete */ | |
| 1023 }; | |
| 1024 | |
| 1025 static struct | |
| 1026 { | |
| 1027 unsigned char char_code; /* normal code */ | |
| 1028 unsigned char keypad_code; /* keypad code */ | |
| 1029 } grey_key_translate_map[] = { | |
| 1030 '/', 0xaf, /* kp-decimal */ | |
| 1031 '*', 0xaa, /* kp-multiply */ | |
| 1032 '-', 0xad, /* kp-subtract */ | |
| 1033 '+', 0xab, /* kp-add */ | |
| 1034 '\r', 0x8d /* kp-enter */ | |
| 1035 }; | |
| 1036 | |
| 1037 static unsigned short | |
| 1038 ibmpc_translate_map[] = | |
|
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
1039 { |
| 13179 | 1040 /* --------------- 00 to 0f --------------- */ |
| 1041 Normal | 0xff, /* Ctrl Break + Alt-NNN */ | |
| 1042 Alt | ModFct | 0x1b, /* Escape */ | |
| 1043 Normal | 1, /* '1' */ | |
| 1044 Normal | 2, /* '2' */ | |
| 1045 Normal | 3, /* '3' */ | |
| 1046 Normal | 4, /* '4' */ | |
| 1047 Normal | 5, /* '5' */ | |
| 1048 Normal | 6, /* '6' */ | |
| 1049 Normal | 7, /* '7' */ | |
| 1050 Normal | 8, /* '8' */ | |
| 1051 Normal | 9, /* '9' */ | |
| 1052 Normal | 10, /* '0' */ | |
| 1053 Normal | 11, /* '-' */ | |
| 1054 Normal | 12, /* '=' */ | |
| 1055 Special | 0x08, /* Backspace */ | |
| 1056 ModFct | 0x74, /* Tab/Backtab */ | |
| 1057 | |
| 1058 /* --------------- 10 to 1f --------------- */ | |
| 1059 Map | 15, /* 'q' */ | |
| 1060 Map | 16, /* 'w' */ | |
| 1061 Map | 17, /* 'e' */ | |
| 1062 Map | 18, /* 'r' */ | |
| 1063 Map | 19, /* 't' */ | |
| 1064 Map | 20, /* 'y' */ | |
| 1065 Map | 21, /* 'u' */ | |
| 1066 Map | 22, /* 'i' */ | |
| 1067 Map | 23, /* 'o' */ | |
| 1068 Map | 24, /* 'p' */ | |
| 1069 Map | 25, /* '[' */ | |
| 1070 Map | 26, /* ']' */ | |
| 1071 ModFct | 0x0d, /* Return */ | |
| 1072 Ignore, /* Ctrl */ | |
| 1073 Map | 30, /* 'a' */ | |
| 1074 Map | 31, /* 's' */ | |
| 1075 | |
| 1076 /* --------------- 20 to 2f --------------- */ | |
| 1077 Map | 32, /* 'd' */ | |
| 1078 Map | 33, /* 'f' */ | |
| 1079 Map | 34, /* 'g' */ | |
| 1080 Map | 35, /* 'h' */ | |
| 1081 Map | 36, /* 'j' */ | |
| 1082 Map | 37, /* 'k' */ | |
| 1083 Map | 38, /* 'l' */ | |
| 1084 Map | 39, /* ';' */ | |
| 1085 Map | 40, /* '\'' */ | |
| 1086 Map | 0, /* '`' */ | |
| 1087 Ignore, /* Left shift */ | |
| 1088 Map | 41, /* '\\' */ | |
| 1089 Map | 45, /* 'z' */ | |
| 1090 Map | 46, /* 'x' */ | |
| 1091 Map | 47, /* 'c' */ | |
| 1092 Map | 48, /* 'v' */ | |
| 1093 | |
| 1094 /* --------------- 30 to 3f --------------- */ | |
| 1095 Map | 49, /* 'b' */ | |
| 1096 Map | 50, /* 'n' */ | |
| 1097 Map | 51, /* 'm' */ | |
| 1098 Map | 52, /* ',' */ | |
| 1099 Map | 53, /* '.' */ | |
| 1100 Map | 54, /* '/' */ | |
| 1101 Ignore, /* Right shift */ | |
| 1102 Grey | 1, /* Grey * */ | |
| 1103 Ignore, /* Alt */ | |
| 1104 Normal | ' ', /* ' ' */ | |
| 1105 Ignore, /* Caps Lock */ | |
| 1106 FctKey | 0xbe, /* F1 */ | |
| 1107 FctKey | 0xbf, /* F2 */ | |
| 1108 FctKey | 0xc0, /* F3 */ | |
| 1109 FctKey | 0xc1, /* F4 */ | |
| 1110 FctKey | 0xc2, /* F5 */ | |
| 1111 | |
| 1112 /* --------------- 40 to 4f --------------- */ | |
| 1113 FctKey | 0xc3, /* F6 */ | |
| 1114 FctKey | 0xc4, /* F7 */ | |
| 1115 FctKey | 0xc5, /* F8 */ | |
| 1116 FctKey | 0xc6, /* F9 */ | |
| 1117 FctKey | 0xc7, /* F10 */ | |
| 1118 Ignore, /* Num Lock */ | |
| 1119 Ignore, /* Scroll Lock */ | |
| 1120 KeyPad | 7, /* Home */ | |
| 1121 KeyPad | 8, /* Up */ | |
| 1122 KeyPad | 9, /* Page Up */ | |
| 1123 Grey | 2, /* Grey - */ | |
| 1124 KeyPad | 4, /* Left */ | |
| 1125 KeyPad | 5, /* Keypad 5 */ | |
| 1126 KeyPad | 6, /* Right */ | |
| 1127 Grey | 3, /* Grey + */ | |
| 1128 KeyPad | 1, /* End */ | |
| 1129 | |
| 1130 /* --------------- 50 to 5f --------------- */ | |
| 1131 KeyPad | 2, /* Down */ | |
| 1132 KeyPad | 3, /* Page Down */ | |
| 1133 KeyPad | 0, /* Insert */ | |
| 1134 KeyPad | 10, /* Delete */ | |
| 1135 Shift | FctKey | 0xbe, /* (Shift) F1 */ | |
| 1136 Shift | FctKey | 0xbf, /* (Shift) F2 */ | |
| 1137 Shift | FctKey | 0xc0, /* (Shift) F3 */ | |
| 1138 Shift | FctKey | 0xc1, /* (Shift) F4 */ | |
| 1139 Shift | FctKey | 0xc2, /* (Shift) F5 */ | |
| 1140 Shift | FctKey | 0xc3, /* (Shift) F6 */ | |
| 1141 Shift | FctKey | 0xc4, /* (Shift) F7 */ | |
| 1142 Shift | FctKey | 0xc5, /* (Shift) F8 */ | |
| 1143 Shift | FctKey | 0xc6, /* (Shift) F9 */ | |
| 1144 Shift | FctKey | 0xc7, /* (Shift) F10 */ | |
| 1145 Ctrl | FctKey | 0xbe, /* (Ctrl) F1 */ | |
| 1146 Ctrl | FctKey | 0xbf, /* (Ctrl) F2 */ | |
|
13040
169d50e2ee4c
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents:
13020
diff
changeset
|
1147 |
| 13179 | 1148 /* --------------- 60 to 6f --------------- */ |
| 1149 Ctrl | FctKey | 0xc0, /* (Ctrl) F3 */ | |
| 1150 Ctrl | FctKey | 0xc1, /* (Ctrl) F4 */ | |
| 1151 Ctrl | FctKey | 0xc2, /* (Ctrl) F5 */ | |
| 1152 Ctrl | FctKey | 0xc3, /* (Ctrl) F6 */ | |
| 1153 Ctrl | FctKey | 0xc4, /* (Ctrl) F7 */ | |
| 1154 Ctrl | FctKey | 0xc5, /* (Ctrl) F8 */ | |
| 1155 Ctrl | FctKey | 0xc6, /* (Ctrl) F9 */ | |
| 1156 Ctrl | FctKey | 0xc7, /* (Ctrl) F10 */ | |
| 1157 Alt | FctKey | 0xbe, /* (Alt) F1 */ | |
| 1158 Alt | FctKey | 0xbf, /* (Alt) F2 */ | |
| 1159 Alt | FctKey | 0xc0, /* (Alt) F3 */ | |
| 1160 Alt | FctKey | 0xc1, /* (Alt) F4 */ | |
| 1161 Alt | FctKey | 0xc2, /* (Alt) F5 */ | |
| 1162 Alt | FctKey | 0xc3, /* (Alt) F6 */ | |
| 1163 Alt | FctKey | 0xc4, /* (Alt) F7 */ | |
| 1164 Alt | FctKey | 0xc5, /* (Alt) F8 */ | |
| 1165 | |
| 1166 /* --------------- 70 to 7f --------------- */ | |
| 1167 Alt | FctKey | 0xc6, /* (Alt) F9 */ | |
| 1168 Alt | FctKey | 0xc7, /* (Alt) F10 */ | |
| 1169 Ctrl | FctKey | 0x6d, /* (Ctrl) Sys Rq */ | |
| 1170 Ctrl | KeyPad | 4, /* (Ctrl) Left */ | |
| 1171 Ctrl | KeyPad | 6, /* (Ctrl) Right */ | |
| 1172 Ctrl | KeyPad | 1, /* (Ctrl) End */ | |
| 1173 Ctrl | KeyPad | 3, /* (Ctrl) Page Down */ | |
| 1174 Ctrl | KeyPad | 7, /* (Ctrl) Home */ | |
| 1175 Alt | Map | 1, /* '1' */ | |
| 1176 Alt | Map | 2, /* '2' */ | |
| 1177 Alt | Map | 3, /* '3' */ | |
| 1178 Alt | Map | 4, /* '4' */ | |
| 1179 Alt | Map | 5, /* '5' */ | |
| 1180 Alt | Map | 6, /* '6' */ | |
| 1181 Alt | Map | 7, /* '7' */ | |
| 1182 Alt | Map | 8, /* '8' */ | |
| 1183 | |
| 1184 /* --------------- 80 to 8f --------------- */ | |
| 1185 Alt | Map | 9, /* '9' */ | |
| 1186 Alt | Map | 10, /* '0' */ | |
| 1187 Alt | Map | 11, /* '-' */ | |
| 1188 Alt | Map | 12, /* '=' */ | |
| 1189 Ctrl | KeyPad | 9, /* (Ctrl) Page Up */ | |
| 1190 FctKey | 0xc8, /* F11 */ | |
| 1191 FctKey | 0xc9, /* F12 */ | |
| 1192 Shift | FctKey | 0xc8, /* (Shift) F11 */ | |
| 1193 Shift | FctKey | 0xc9, /* (Shift) F12 */ | |
| 1194 Ctrl | FctKey | 0xc8, /* (Ctrl) F11 */ | |
| 1195 Ctrl | FctKey | 0xc9, /* (Ctrl) F12 */ | |
| 1196 Alt | FctKey | 0xc8, /* (Alt) F11 */ | |
| 1197 Alt | FctKey | 0xc9, /* (Alt) F12 */ | |
| 1198 Ctrl | KeyPad | 8, /* (Ctrl) Up */ | |
| 1199 Ctrl | Grey | 2, /* (Ctrl) Grey - */ | |
| 1200 Ctrl | KeyPad | 5, /* (Ctrl) Keypad 5 */ | |
| 1201 | |
| 1202 /* --------------- 90 to 9f --------------- */ | |
| 1203 Ctrl | Grey | 3, /* (Ctrl) Grey + */ | |
| 1204 Ctrl | KeyPad | 2, /* (Ctrl) Down */ | |
| 1205 Ctrl | KeyPad | 0, /* (Ctrl) Insert */ | |
| 1206 Ctrl | KeyPad | 10, /* (Ctrl) Delete */ | |
| 1207 Ctrl | FctKey | 0x09, /* (Ctrl) Tab */ | |
| 1208 Ctrl | Grey | 0, /* (Ctrl) Grey / */ | |
| 1209 Ctrl | Grey | 1, /* (Ctrl) Grey * */ | |
| 1210 Alt | FctKey | 0x50, /* (Alt) Home */ | |
| 1211 Alt | FctKey | 0x52, /* (Alt) Up */ | |
| 1212 Alt | FctKey | 0x55, /* (Alt) Page Up */ | |
| 1213 Ignore, /* NO KEY */ | |
| 1214 Alt | FctKey | 0x51, /* (Alt) Left */ | |
| 1215 Ignore, /* NO KEY */ | |
| 1216 Alt | FctKey | 0x53, /* (Alt) Right */ | |
| 1217 Ignore, /* NO KEY */ | |
| 1218 Alt | FctKey | 0x57, /* (Alt) End */ | |
| 1219 | |
| 1220 /* --------------- a0 to af --------------- */ | |
| 1221 Alt | KeyPad | 2, /* (Alt) Down */ | |
| 1222 Alt | KeyPad | 3, /* (Alt) Page Down */ | |
| 1223 Alt | KeyPad | 0, /* (Alt) Insert */ | |
| 1224 Alt | KeyPad | 10, /* (Alt) Delete */ | |
| 1225 Alt | Grey | 0, /* (Alt) Grey / */ | |
| 1226 Alt | FctKey | 0x09, /* (Alt) Tab */ | |
| 1227 Alt | Grey | 4 /* (Alt) Keypad Enter */ | |
| 1228 }; | |
| 13274 | 1229 |
| 13179 | 1230 /* These bit-positions corresponds to values returned by BIOS */ |
| 1231 #define SHIFT_P 0x0003 /* two bits! */ | |
| 1232 #define CTRL_P 0x0004 | |
| 1233 #define ALT_P 0x0008 | |
| 1234 #define SCRLOCK_P 0x0010 | |
| 1235 #define NUMLOCK_P 0x0020 | |
| 1236 #define CAPSLOCK_P 0x0040 | |
| 1237 #define ALT_GR_P 0x0800 | |
| 1238 #define SUPER_P 0x4000 /* pseudo */ | |
| 1239 #define HYPER_P 0x8000 /* pseudo */ | |
| 1240 | |
| 1241 static int | |
| 1242 dos_get_modifiers (keymask) | |
| 1243 int *keymask; | |
| 5503 | 1244 { |
| 13179 | 1245 union REGS regs; |
| 1246 int mask; | |
| 1247 int modifiers = 0; | |
| 1248 | |
| 1249 /* Calculate modifier bits */ | |
| 1250 regs.h.ah = extended_kbd ? 0x12 : 0x02; | |
| 1251 int86 (0x16, ®s, ®s); | |
| 1252 | |
| 1253 if (!extended_kbd) | |
| 1254 { | |
| 1255 mask = regs.h.al & (SHIFT_P | CTRL_P | ALT_P | | |
| 1256 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | |
| 1257 } | |
| 1258 else | |
| 1259 { | |
| 1260 mask = regs.h.al & (SHIFT_P | | |
| 1261 SCRLOCK_P | NUMLOCK_P | CAPSLOCK_P); | |
| 1262 | |
| 1263 /* Do not break international keyboard support. */ | |
| 1264 /* When Keyb.Com is loaded, the right Alt key is */ | |
| 1265 /* used for accessing characters like { and } */ | |
| 1266 if (regs.h.ah & 2) /* Left ALT pressed ? */ | |
| 1267 mask |= ALT_P; | |
| 1268 | |
| 1269 if ((regs.h.ah & 8) != 0) /* Right ALT pressed ? */ | |
| 1270 { | |
| 1271 mask |= ALT_GR_P; | |
| 1272 if (dos_hyper_key == 1) | |
| 1273 { | |
| 1274 mask |= HYPER_P; | |
| 1275 modifiers |= hyper_modifier; | |
| 1276 } | |
| 1277 else if (dos_super_key == 1) | |
| 1278 { | |
| 1279 mask |= SUPER_P; | |
| 1280 modifiers |= super_modifier; | |
| 1281 } | |
| 1282 } | |
| 1283 | |
| 1284 if (regs.h.ah & 1) /* Left CTRL pressed | |
| 1285 mask |= CTRL_P; | |
| 1286 | |
| 1287 if (regs.h.ah & 4) /* Right CTRL pressed ? */ | |
| 1288 { | |
| 1289 if (dos_hyper_key == 2) | |
| 1290 { | |
| 1291 mask |= HYPER_P; | |
| 1292 modifiers |= hyper_modifier; | |
| 1293 } | |
| 1294 else if (dos_super_key == 2) | |
| 1295 { | |
| 1296 mask |= SUPER_P; | |
| 1297 modifiers |= super_modifier; | |
| 1298 } | |
| 1299 else | |
| 1300 mask |= CTRL_P; | |
| 1301 } | |
| 1302 } | |
| 1303 | |
| 1304 if (mask & SHIFT_P) | |
| 1305 modifiers |= shift_modifier; | |
| 1306 if (mask & CTRL_P) | |
| 1307 modifiers |= ctrl_modifier; | |
| 1308 if (mask & ALT_P) | |
| 1309 modifiers |= meta_modifier; | |
| 1310 | |
| 1311 if (keymask) | |
| 1312 *keymask = mask; | |
| 1313 return modifiers; | |
| 5503 | 1314 } |
| 1315 | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1316 #define NUM_RECENT_DOSKEYS (100) |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1317 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
|
1318 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
|
1319 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
|
1320 |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1321 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
|
1322 "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
|
1323 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
|
1324 and then the scan code.") |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1325 () |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1326 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1327 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
|
1328 Lisp_Object val; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1329 |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1330 if (total_doskeys < NUM_RECENT_DOSKEYS) |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1331 return Fvector (total_doskeys, keys); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1332 else |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1333 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1334 val = Fvector (NUM_RECENT_DOSKEYS, keys); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1335 bcopy (keys + recent_doskeys_index, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1336 XVECTOR (val)->contents, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1337 (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
|
1338 bcopy (keys, |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1339 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
|
1340 recent_doskeys_index * sizeof (Lisp_Object)); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1341 return val; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1342 } |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1343 } |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1344 |
| 13179 | 1345 /* Get a char from keyboard. Function keys are put into the event queue. */ |
| 1346 static int | |
| 1347 dos_rawgetc () | |
| 5503 | 1348 { |
| 13179 | 1349 struct input_event event; |
| 1350 union REGS regs; | |
| 1351 | |
| 1352 #ifndef HAVE_X_WINDOWS | |
| 13274 | 1353 SCREEN_SET_CURSOR (); |
| 13179 | 1354 if (!mouse_visible) mouse_on (); |
| 1355 #endif | |
| 1356 | |
| 1357 /* The following condition is equivalent to `kbhit ()', except that | |
| 1358 it uses the bios to do its job. This pleases DESQview/X. */ | |
| 1359 while ((regs.h.ah = extended_kbd ? 0x11 : 0x01), | |
| 1360 int86 (0x16, ®s, ®s), | |
| 1361 (regs.x.flags & 0x40) == 0) | |
| 5503 | 1362 { |
| 13179 | 1363 union REGS regs; |
| 1364 register unsigned char c; | |
| 1365 int sc, code, mask, kp_mode; | |
| 1366 int modifiers; | |
| 1367 | |
| 1368 regs.h.ah = extended_kbd ? 0x10 : 0x00; | |
| 1369 int86 (0x16, ®s, ®s); | |
| 1370 c = regs.h.al; | |
| 1371 sc = regs.h.ah; | |
| 5503 | 1372 |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1373 total_doskeys += 2; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1374 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
|
1375 = make_number (c); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1376 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
|
1377 recent_doskeys_index = 0; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1378 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
|
1379 = make_number (sc); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1380 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
|
1381 recent_doskeys_index = 0; |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1382 |
| 13274 | 1383 modifiers = dos_get_modifiers (&mask); |
| 13179 | 1384 |
| 1385 #ifndef HAVE_X_WINDOWS | |
| 13274 | 1386 if (!NILP (Vdos_display_scancodes)) |
| 13179 | 1387 { |
|
14157
38606398dfa6
(dos_rawgetc): Make buf longer.
Richard M. Stallman <rms@gnu.org>
parents:
14036
diff
changeset
|
1388 char buf[11]; |
| 13179 | 1389 sprintf (buf, "%02x:%02x*%04x", |
| 1390 (unsigned) (sc&0xff), (unsigned) c, mask); | |
| 1391 dos_direct_output (screen_size_Y - 2, screen_size_X - 12, buf, 10); | |
| 1392 } | |
| 1393 #endif | |
| 5503 | 1394 |
| 13179 | 1395 if (sc == 0xe0) |
| 1396 { | |
| 1397 switch (c) | |
| 1398 { | |
| 1399 case 10: /* Ctrl Grey Enter */ | |
| 1400 code = Ctrl | Grey | 4; | |
| 1401 break; | |
| 1402 case 13: /* Grey Enter */ | |
| 1403 code = Grey | 4; | |
| 1404 break; | |
| 1405 case '/': /* Grey / */ | |
| 1406 code = Grey | 0; | |
| 1407 break; | |
| 1408 default: | |
| 1409 continue; | |
| 1410 }; | |
| 1411 c = 0; | |
| 1412 } | |
| 1413 else | |
| 1414 { | |
| 1415 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) | |
| 1416 continue; | |
| 1417 if ((code = ibmpc_translate_map[sc]) == Ignore) | |
| 1418 continue; | |
| 1419 } | |
| 1420 | |
| 1421 if (c == 0) | |
| 1422 { | |
| 1423 if (code & Alt) | |
| 1424 modifiers |= meta_modifier; | |
| 1425 if (code & Ctrl) | |
| 1426 modifiers |= ctrl_modifier; | |
| 1427 if (code & Shift) | |
| 1428 modifiers |= shift_modifier; | |
| 1429 } | |
| 1430 | |
| 1431 switch (code & 0xf000) | |
| 1432 { | |
| 1433 case ModFct: | |
| 1434 if (c && !(mask & (SHIFT_P | ALT_P | CTRL_P | HYPER_P | SUPER_P))) | |
| 1435 return c; | |
| 1436 c = 0; /* Special */ | |
| 1437 | |
| 1438 case FctKey: | |
| 1439 if (c != 0) | |
| 1440 return c; | |
| 1441 | |
| 1442 case Special: | |
| 1443 code |= 0xff00; | |
| 1444 break; | |
| 1445 | |
| 1446 case Normal: | |
| 1447 if (sc == 0) | |
| 1448 { | |
| 1449 if (c == 0) /* ctrl-break */ | |
| 1450 continue; | |
| 1451 return c; /* ALT-nnn */ | |
| 1452 } | |
| 1453 if (!keyboard_map_all) | |
| 1454 { | |
| 1455 if (c != ' ') | |
| 1456 return c; | |
| 1457 code = c; | |
| 1458 break; | |
| 1459 } | |
| 1460 | |
| 1461 case Map: | |
| 1462 if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) | |
| 1463 if (!keyboard_map_all) | |
| 1464 return c; | |
| 5503 | 1465 |
| 13179 | 1466 code &= 0xff; |
| 1467 if (mask & ALT_P && code <= 10 && code > 0 && dos_keypad_mode & 0x200) | |
| 1468 mask |= SHIFT_P; /* ALT-1 => M-! etc. */ | |
| 1469 | |
| 1470 if (mask & SHIFT_P) | |
| 1471 { | |
| 13274 | 1472 code = keyboard->shifted[code]; |
| 13179 | 1473 mask -= SHIFT_P; |
| 1474 modifiers &= ~shift_modifier; | |
| 1475 } | |
| 1476 else | |
| 13274 | 1477 if ((mask & ALT_GR_P) && keyboard->alt_gr && keyboard->alt_gr[code] != ' ') |
| 1478 code = keyboard->alt_gr[code]; | |
| 13179 | 1479 else |
| 13274 | 1480 code = keyboard->unshifted[code]; |
| 13179 | 1481 break; |
| 1482 | |
| 1483 case KeyPad: | |
| 1484 code &= 0xff; | |
| 1485 if (c == 0xe0) /* edit key */ | |
| 1486 kp_mode = 3; | |
| 1487 else | |
| 1488 if ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) /* numlock on */ | |
| 1489 kp_mode = dos_keypad_mode & 0x03; | |
| 1490 else | |
| 1491 kp_mode = (dos_keypad_mode >> 4) & 0x03; | |
| 1492 | |
| 1493 switch (kp_mode) | |
| 1494 { | |
| 1495 case 0: | |
| 1496 if (code == 10 && dos_decimal_point) | |
| 1497 return dos_decimal_point; | |
| 13274 | 1498 return keypad_translate_map[code].char_code; |
| 5503 | 1499 |
| 13179 | 1500 case 1: |
| 13274 | 1501 code = 0xff00 | keypad_translate_map[code].keypad_code; |
| 13179 | 1502 break; |
| 5503 | 1503 |
| 13179 | 1504 case 2: |
| 13274 | 1505 code = keypad_translate_map[code].meta_code; |
| 13179 | 1506 modifiers = meta_modifier; |
| 1507 break; | |
| 1508 | |
| 1509 case 3: | |
| 13274 | 1510 code = 0xff00 | keypad_translate_map[code].editkey_code; |
| 13179 | 1511 break; |
| 1512 } | |
| 1513 break; | |
| 1514 | |
| 1515 case Grey: | |
| 1516 code &= 0xff; | |
| 1517 kp_mode = ((mask & (NUMLOCK_P|CTRL_P|SHIFT_P|ALT_P)) == NUMLOCK_P) ? 0x04 : 0x40; | |
| 1518 if (dos_keypad_mode & kp_mode) | |
| 13274 | 1519 code = 0xff00 | grey_key_translate_map[code].keypad_code; |
| 13179 | 1520 else |
| 13274 | 1521 code = grey_key_translate_map[code].char_code; |
| 13179 | 1522 break; |
| 1523 } | |
| 1524 | |
| 1525 make_event: | |
| 1526 if (code == 0) | |
| 1527 continue; | |
| 1528 | |
| 1529 if (code >= 0x100) | |
| 1530 event.kind = non_ascii_keystroke; | |
| 1531 else | |
| 1532 event.kind = ascii_keystroke; | |
| 1533 event.code = code; | |
| 1534 event.modifiers = modifiers; | |
| 1535 XSETFRAME (event.frame_or_window, selected_frame); | |
| 1536 event.timestamp = event_timestamp (); | |
| 1537 kbd_buffer_store_event (&event); | |
| 1538 } | |
| 5503 | 1539 |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1540 if (have_mouse > 0) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1541 { |
| 13179 | 1542 int but, press, x, y, ok; |
| 5503 | 1543 |
| 13179 | 1544 /* Check for mouse movement *before* buttons. */ |
| 1545 mouse_check_moved (); | |
| 5503 | 1546 |
| 13179 | 1547 for (but = 0; but < NUM_MOUSE_BUTTONS; but++) |
| 1548 for (press = 0; press < 2; press++) | |
| 1549 { | |
| 1550 if (press) | |
| 1551 ok = mouse_pressed (but, &x, &y); | |
| 1552 else | |
| 1553 ok = mouse_released (but, &x, &y); | |
| 1554 if (ok) | |
| 1555 { | |
| 1556 event.kind = mouse_click; | |
| 1557 event.code = but; | |
| 1558 event.modifiers = dos_get_modifiers (0) | |
| 1559 | (press ? down_modifier : up_modifier); | |
| 1560 event.x = x; | |
| 1561 event.y = y; | |
| 1562 XSETFRAME (event.frame_or_window, selected_frame); | |
| 1563 event.timestamp = event_timestamp (); | |
| 1564 kbd_buffer_store_event (&event); | |
| 1565 } | |
| 1566 } | |
| 1567 } | |
| 5503 | 1568 |
| 13179 | 1569 return -1; |
| 9572 | 1570 } |
| 1571 | |
| 13179 | 1572 static int prev_get_char = -1; |
| 5503 | 1573 |
| 13179 | 1574 /* Return 1 if a key is ready to be read without suspending execution. */ |
| 1575 dos_keysns () | |
| 5503 | 1576 { |
| 13179 | 1577 if (prev_get_char != -1) |
| 1578 return 1; | |
| 1579 else | |
| 1580 return ((prev_get_char = dos_rawgetc ()) != -1); | |
| 5503 | 1581 } |
| 1582 | |
| 13179 | 1583 /* Read a key. Return -1 if no key is ready. */ |
| 1584 dos_keyread () | |
| 5503 | 1585 { |
| 13179 | 1586 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
|
1587 { |
| 13179 | 1588 int c = prev_get_char; |
| 1589 prev_get_char = -1; | |
| 1590 return c; | |
|
8246
d48c2b01fba5
(mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents:
8194
diff
changeset
|
1591 } |
| 13179 | 1592 else |
| 1593 return dos_rawgetc (); | |
| 1594 } | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
1595 |
| 9572 | 1596 #ifndef HAVE_X_WINDOWS |
|
7273
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1597 /* See xterm.c for more info. */ |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1598 void |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1599 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
|
1600 FRAME_PTR f; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1601 register int pix_x, pix_y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1602 register int *x, *y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1603 void /* XRectangle */ *bounds; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1604 int noclip; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1605 { |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1606 if (bounds) abort (); |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1607 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1608 /* Ignore clipping. */ |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1609 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1610 *x = pix_x; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1611 *y = pix_y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1612 } |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1613 |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1614 void |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1615 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
|
1616 FRAME_PTR f; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1617 register int x, y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1618 register int *pix_x, *pix_y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1619 { |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1620 *pix_x = x; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1621 *pix_y = y; |
|
24426d7e14eb
Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents:
6505
diff
changeset
|
1622 } |
| 9572 | 1623 |
| 1624 /* Simulation of X's menus. Nothing too fancy here -- just make it work | |
| 1625 for now. | |
| 1626 | |
| 1627 Actually, I don't know the meaning of all the parameters of the functions | |
| 1628 here -- I only know how they are called by xmenu.c. I could of course | |
| 1629 grab the nearest Xlib manual (down the hall, second-to-last door on the | |
| 1630 left), but I don't think it's worth the effort. */ | |
| 1631 | |
| 1632 static XMenu * | |
| 1633 IT_menu_create () | |
| 1634 { | |
| 1635 XMenu *menu; | |
| 1636 | |
| 1637 menu = (XMenu *) xmalloc (sizeof (XMenu)); | |
| 1638 menu->allocated = menu->count = menu->panecount = menu->width = 0; | |
| 1639 return menu; | |
| 1640 } | |
| 1641 | |
| 1642 /* Allocate some (more) memory for MENU ensuring that there is room for one | |
| 1643 for item. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1644 |
| 9572 | 1645 static void |
| 1646 IT_menu_make_room (XMenu *menu) | |
| 1647 { | |
| 1648 if (menu->allocated == 0) | |
| 1649 { | |
| 1650 int count = menu->allocated = 10; | |
| 1651 menu->text = (char **) xmalloc (count * sizeof (char *)); | |
| 1652 menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); | |
| 1653 menu->panenumber = (int *) xmalloc (count * sizeof (int)); | |
| 1654 } | |
| 1655 else if (menu->allocated == menu->count) | |
| 1656 { | |
| 1657 int count = menu->allocated = menu->allocated + 10; | |
| 1658 menu->text | |
| 1659 = (char **) xrealloc (menu->text, count * sizeof (char *)); | |
| 1660 menu->submenu | |
| 1661 = (XMenu **) xrealloc (menu->submenu, count * sizeof (XMenu *)); | |
| 1662 menu->panenumber | |
| 1663 = (int *) xrealloc (menu->panenumber, count * sizeof (int)); | |
| 1664 } | |
| 1665 } | |
| 1666 | |
| 1667 /* 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
|
1668 |
| 9572 | 1669 static XMenu * |
| 1670 IT_menu_search_pane (XMenu *menu, int pane) | |
| 1671 { | |
| 1672 int i; | |
| 1673 XMenu *try; | |
| 1674 | |
| 1675 for (i = 0; i < menu->count; i++) | |
| 1676 if (menu->submenu[i]) | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1677 { |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1678 if (pane == menu->panenumber[i]) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1679 return menu->submenu[i]; |
| 13179 | 1680 if ((try = IT_menu_search_pane (menu->submenu[i], pane))) |
| 9572 | 1681 return try; |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1682 } |
| 9572 | 1683 return (XMenu *) 0; |
| 1684 } | |
| 1685 | |
| 1686 /* 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
|
1687 |
| 9572 | 1688 static void |
| 1689 IT_menu_calc_size (XMenu *menu, int *width, int *height) | |
| 1690 { | |
| 1691 int i, h2, w2, maxsubwidth, maxheight; | |
| 1692 | |
| 1693 maxsubwidth = 0; | |
| 1694 maxheight = menu->count; | |
| 1695 for (i = 0; i < menu->count; i++) | |
| 1696 { | |
| 1697 if (menu->submenu[i]) | |
| 1698 { | |
| 1699 IT_menu_calc_size (menu->submenu[i], &w2, &h2); | |
| 1700 if (w2 > maxsubwidth) maxsubwidth = w2; | |
| 1701 if (i + h2 > maxheight) maxheight = i + h2; | |
| 1702 } | |
| 1703 } | |
| 1704 *width = menu->width + maxsubwidth; | |
| 1705 *height = maxheight; | |
| 1706 } | |
| 1707 | |
| 1708 /* 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
|
1709 |
| 9572 | 1710 static void |
| 1711 IT_menu_display (XMenu *menu, int y, int x, int *faces) | |
| 1712 { | |
| 1713 int i, j, face, width; | |
| 1714 GLYPH *text, *p; | |
| 1715 char *q; | |
| 1716 int mx, my; | |
| 1717 int enabled, mousehere; | |
| 1718 int row, col; | |
| 1719 | |
| 1720 width = menu->width; | |
| 1721 text = (GLYPH *) xmalloc ((width + 2) * sizeof (GLYPH)); | |
| 1722 ScreenGetCursor (&row, &col); | |
| 1723 mouse_get_xy (&mx, &my); | |
| 13179 | 1724 IT_update_begin (); |
| 9572 | 1725 for (i = 0; i < menu->count; i++) |
| 1726 { | |
| 13179 | 1727 IT_cursor_to (y + i, x); |
| 9572 | 1728 enabled |
| 1729 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]); | |
| 1730 mousehere = (y + i == my && x <= mx && mx < x + width + 2); | |
| 1731 face = faces[enabled + mousehere * 2]; | |
| 1732 p = text; | |
| 1733 *p++ = FAST_MAKE_GLYPH (' ', face); | |
| 1734 for (j = 0, q = menu->text[i]; *q; j++) | |
| 1735 *p++ = FAST_MAKE_GLYPH (*q++, face); | |
| 1736 for (; j < width; j++) | |
| 1737 *p++ = FAST_MAKE_GLYPH (' ', face); | |
| 1738 *p++ = FAST_MAKE_GLYPH (menu->submenu[i] ? 16 : ' ', face); | |
| 13179 | 1739 IT_write_glyphs (text, width + 2); |
| 9572 | 1740 } |
| 13179 | 1741 IT_update_end (); |
| 1742 IT_cursor_to (row, col); | |
| 9572 | 1743 xfree (text); |
| 1744 } | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1745 |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1746 /* --------------------------- X Menu emulation ---------------------- */ |
| 9572 | 1747 |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1748 /* Report availability of menus. */ |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1749 |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1750 int |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1751 have_menus_p () |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1752 { |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1753 return 1; |
|
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1754 } |
| 13179 | 1755 |
| 9572 | 1756 /* 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
|
1757 |
| 9572 | 1758 XMenu * |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1759 XMenuCreate (Display *foo1, Window foo2, char *foo3) |
| 9572 | 1760 { |
| 1761 return IT_menu_create (); | |
| 1762 } | |
| 1763 | |
| 1764 /* Create a new pane and place it on the outer-most level. It is not | |
| 1765 clear that it should be placed out there, but I don't know what else | |
| 1766 to do. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1767 |
| 9572 | 1768 int |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1769 XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable) |
| 9572 | 1770 { |
| 1771 int len; | |
| 1772 | |
| 1773 if (!enable) | |
| 1774 abort (); | |
| 1775 | |
| 1776 IT_menu_make_room (menu); | |
| 1777 menu->submenu[menu->count] = IT_menu_create (); | |
| 1778 menu->text[menu->count] = txt; | |
| 1779 menu->panenumber[menu->count] = ++menu->panecount; | |
| 1780 menu->count++; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1781 if ((len = strlen (txt)) > menu->width) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1782 menu->width = len; |
| 9572 | 1783 return menu->panecount; |
| 1784 } | |
| 1785 | |
| 1786 /* 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
|
1787 |
| 9572 | 1788 int |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1789 XMenuAddSelection (Display *bar, XMenu *menu, int pane, |
|
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1790 int foo, char *txt, int enable) |
| 9572 | 1791 { |
| 1792 int len; | |
| 1793 | |
| 1794 if (pane) | |
| 1795 if (!(menu = IT_menu_search_pane (menu, pane))) | |
| 1796 return XM_FAILURE; | |
| 1797 IT_menu_make_room (menu); | |
| 1798 menu->submenu[menu->count] = (XMenu *) 0; | |
| 1799 menu->text[menu->count] = txt; | |
| 1800 menu->panenumber[menu->count] = enable; | |
| 1801 menu->count++; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1802 if ((len = strlen (txt)) > menu->width) |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1803 menu->width = len; |
| 9572 | 1804 return XM_SUCCESS; |
| 1805 } | |
| 1806 | |
| 1807 /* 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
|
1808 |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1809 void |
|
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1810 XMenuLocate (Display *foo0, XMenu *menu, int foo1, int foo2, int x, int y, |
| 9572 | 1811 int *ulx, int *uly, int *width, int *height) |
| 1812 { | |
|
13714
45e71ea63d71
(XMenuActivate): Display the menu pane title.
Karl Heuer <kwzh@gnu.org>
parents:
13657
diff
changeset
|
1813 IT_menu_calc_size (menu, width, height); |
| 9572 | 1814 *ulx = x + 1; |
| 1815 *uly = y; | |
| 1816 *width += 2; | |
| 1817 } | |
| 1818 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1819 struct IT_menu_state |
| 9572 | 1820 { |
| 1821 void *screen_behind; | |
| 1822 XMenu *menu; | |
| 1823 int pane; | |
| 1824 int x, y; | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1825 }; |
| 9572 | 1826 |
| 1827 | |
| 1828 /* 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
|
1829 |
| 9572 | 1830 int |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1831 XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx, |
| 9572 | 1832 int x0, int y0, unsigned ButtonMask, char **txt) |
| 1833 { | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1834 struct IT_menu_state *state; |
| 9572 | 1835 int statecount; |
| 1836 int x, y, i, b; | |
| 1837 int screensize; | |
| 1838 int faces[4], selectface; | |
| 1839 int leave, result, onepane; | |
|
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1840 int title_faces[4]; /* face to display the menu title */ |
| 9572 | 1841 |
| 1842 /* 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
|
1843 if (have_mouse <= 0) |
| 9572 | 1844 return XM_IA_SELECT; |
| 1845 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1846 state = alloca (menu->panecount * sizeof (struct IT_menu_state)); |
| 13179 | 1847 screensize = screen_size * 2; |
| 9572 | 1848 faces[0] |
| 1849 = compute_glyph_face (&the_only_frame, | |
| 1850 face_name_id_number | |
| 1851 (&the_only_frame, | |
| 1852 intern ("msdos-menu-passive-face")), | |
| 1853 0); | |
| 1854 faces[1] | |
| 1855 = compute_glyph_face (&the_only_frame, | |
| 1856 face_name_id_number | |
| 1857 (&the_only_frame, | |
| 1858 intern ("msdos-menu-active-face")), | |
| 1859 0); | |
| 1860 selectface | |
| 1861 = face_name_id_number (&the_only_frame, intern ("msdos-menu-select-face")); | |
| 1862 faces[2] = compute_glyph_face (&the_only_frame, selectface, faces[0]); | |
| 1863 faces[3] = compute_glyph_face (&the_only_frame, selectface, faces[1]); | |
| 1864 | |
|
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1865 /* 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
|
1866 `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
|
1867 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
|
1868 title_faces[i] = faces[3]; |
|
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1869 |
| 9572 | 1870 statecount = 1; |
| 1871 state[0].menu = menu; | |
| 1872 mouse_off (); | |
| 1873 ScreenRetrieve (state[0].screen_behind = xmalloc (screensize)); | |
|
13714
45e71ea63d71
(XMenuActivate): Display the menu pane title.
Karl Heuer <kwzh@gnu.org>
parents:
13657
diff
changeset
|
1874 |
|
13860
659a54e026bb
(XMenuActivate): Make sure the menu title is always
Richard M. Stallman <rms@gnu.org>
parents:
13848
diff
changeset
|
1875 IT_menu_display (menu, y0 - 1, x0 - 1, title_faces); /* display menu title */ |
| 9572 | 1876 if ((onepane = menu->count == 1 && menu->submenu[0])) |
| 1877 { | |
| 1878 menu->width = menu->submenu[0]->width; | |
| 1879 state[0].menu = menu->submenu[0]; | |
| 1880 } | |
| 1881 else | |
| 1882 { | |
| 1883 state[0].menu = menu; | |
| 1884 } | |
| 1885 state[0].x = x0 - 1; | |
| 1886 state[0].y = y0; | |
| 1887 state[0].pane = onepane; | |
| 1888 | |
| 1889 mouse_last_x = -1; /* A hack that forces display. */ | |
| 1890 leave = 0; | |
| 1891 while (!leave) | |
| 1892 { | |
| 13179 | 1893 if (!mouse_visible) mouse_on (); |
| 9572 | 1894 mouse_check_moved (); |
|
12573
f8193b0f95ed
(mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents:
11124
diff
changeset
|
1895 if (selected_frame->mouse_moved) |
| 9572 | 1896 { |
|
12573
f8193b0f95ed
(mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents:
11124
diff
changeset
|
1897 selected_frame->mouse_moved = 0; |
| 9572 | 1898 result = XM_IA_SELECT; |
| 1899 mouse_get_xy (&x, &y); | |
| 1900 for (i = 0; i < statecount; i++) | |
| 1901 if (state[i].x <= x && x < state[i].x + state[i].menu->width + 2) | |
| 1902 { | |
| 1903 int dy = y - state[i].y; | |
| 1904 if (0 <= dy && dy < state[i].menu->count) | |
| 1905 { | |
| 1906 if (!state[i].menu->submenu[dy]) | |
| 1907 if (state[i].menu->panenumber[dy]) | |
| 1908 result = XM_SUCCESS; | |
| 1909 else | |
| 1910 result = XM_IA_SELECT; | |
| 1911 *pane = state[i].pane - 1; | |
| 1912 *selidx = dy; | |
| 14036 | 1913 /* We hit some part of a menu, so drop extra menus that |
| 9572 | 1914 have been opened. That does not include an open and |
| 1915 active submenu. */ | |
| 1916 if (i != statecount - 2 | |
| 1917 || state[i].menu->submenu[dy] != state[i+1].menu) | |
| 1918 while (i != statecount - 1) | |
| 1919 { | |
| 1920 statecount--; | |
| 1921 mouse_off (); | |
| 1922 ScreenUpdate (state[statecount].screen_behind); | |
| 1923 xfree (state[statecount].screen_behind); | |
| 1924 } | |
| 1925 if (i == statecount - 1 && state[i].menu->submenu[dy]) | |
| 1926 { | |
| 1927 IT_menu_display (state[i].menu, | |
| 1928 state[i].y, | |
| 1929 state[i].x, | |
| 1930 faces); | |
| 1931 state[statecount].menu = state[i].menu->submenu[dy]; | |
| 1932 state[statecount].pane = state[i].menu->panenumber[dy]; | |
| 1933 mouse_off (); | |
| 1934 ScreenRetrieve (state[statecount].screen_behind | |
| 1935 = xmalloc (screensize)); | |
| 1936 state[statecount].x | |
| 1937 = state[i].x + state[i].menu->width + 2; | |
| 1938 state[statecount].y = y; | |
| 1939 statecount++; | |
| 1940 } | |
| 1941 } | |
| 1942 } | |
| 1943 IT_menu_display (state[statecount - 1].menu, | |
| 1944 state[statecount - 1].y, | |
| 1945 state[statecount - 1].x, | |
| 1946 faces); | |
| 1947 } | |
| 1948 for (b = 0; b < mouse_button_count; b++) | |
| 1949 { | |
| 1950 (void) mouse_pressed (b, &x, &y); | |
| 1951 if (mouse_released (b, &x, &y)) | |
| 1952 leave = 1; | |
| 1953 } | |
| 1954 } | |
| 1955 | |
| 1956 mouse_off (); | |
| 1957 ScreenUpdate (state[0].screen_behind); | |
| 1958 while (statecount--) | |
| 1959 xfree (state[statecount].screen_behind); | |
| 1960 return result; | |
| 1961 } | |
| 1962 | |
| 1963 /* Dispose of a menu. */ | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1964 |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1965 void |
|
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1966 XMenuDestroy (Display *foo, XMenu *menu) |
| 9572 | 1967 { |
| 1968 int i; | |
| 1969 if (menu->allocated) | |
| 1970 { | |
| 1971 for (i = 0; i < menu->count; i++) | |
| 1972 if (menu->submenu[i]) | |
|
10501
19c4a9ef23e5
(XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1973 XMenuDestroy (foo, menu->submenu[i]); |
| 9572 | 1974 xfree (menu->text); |
| 1975 xfree (menu->submenu); | |
| 1976 xfree (menu->panenumber); | |
| 1977 } | |
| 1978 xfree (menu); | |
| 1979 } | |
| 1980 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1981 int |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1982 x_pixel_width (struct frame *f) |
| 9572 | 1983 { |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1984 return FRAME_WIDTH (f); |
| 9572 | 1985 } |
| 1986 | |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1987 int |
|
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1988 x_pixel_height (struct frame *f) |
| 9572 | 1989 { |
|
12995
a3620c5ffad7
(putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents:
12614
diff
changeset
|
1990 return FRAME_HEIGHT (f); |
| 9572 | 1991 } |
| 1992 #endif /* !HAVE_X_WINDOWS */ | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
1993 |
| 13179 | 1994 /* ----------------------- DOS / UNIX conversion --------------------- */ |
| 1995 | |
| 1996 /* Destructively turn backslashes into slashes. */ | |
| 1997 | |
| 1998 void | |
| 1999 dostounix_filename (p) | |
| 2000 register char *p; | |
| 2001 { | |
| 2002 while (*p) | |
| 2003 { | |
| 2004 if (*p == '\\') | |
| 2005 *p = '/'; | |
| 2006 p++; | |
| 2007 } | |
| 2008 } | |
| 2009 | |
| 2010 /* Destructively turn slashes into backslashes. */ | |
| 2011 | |
| 2012 void | |
| 2013 unixtodos_filename (p) | |
| 2014 register char *p; | |
| 2015 { | |
| 2016 while (*p) | |
| 2017 { | |
| 2018 if (*p == '/') | |
| 2019 *p = '\\'; | |
| 2020 p++; | |
| 2021 } | |
| 2022 } | |
| 2023 | |
| 2024 /* Get the default directory for a given drive. 0=def, 1=A, 2=B, ... */ | |
| 2025 | |
| 2026 int | |
| 2027 getdefdir (drive, dst) | |
| 2028 int drive; | |
| 2029 char *dst; | |
| 2030 { | |
| 2031 union REGS regs; | |
| 2032 | |
| 2033 *dst++ = '/'; | |
| 2034 regs.h.dl = drive; | |
| 2035 regs.x.si = (int) dst; | |
| 2036 regs.h.ah = 0x47; | |
| 2037 intdos (®s, ®s); | |
| 2038 return !regs.x.cflag; | |
| 2039 } | |
| 2040 | |
| 2041 /* Remove all CR's that are followed by a LF. */ | |
| 2042 | |
| 2043 int | |
| 2044 crlf_to_lf (n, buf) | |
| 2045 register int n; | |
| 2046 register unsigned char *buf; | |
| 2047 { | |
| 2048 unsigned char *np = buf; | |
| 2049 unsigned char *startp = buf; | |
| 2050 unsigned char *endp = buf + n; | |
| 2051 unsigned char c; | |
| 2052 | |
| 2053 if (n == 0) | |
| 2054 return n; | |
| 2055 while (buf < endp - 1) | |
| 2056 { | |
| 2057 if (*buf == 0x0d) | |
| 2058 { | |
| 2059 if (*(++buf) != 0x0a) | |
| 2060 *np++ = 0x0d; | |
| 2061 } | |
| 2062 else | |
| 2063 *np++ = *buf++; | |
| 2064 } | |
| 2065 if (buf < endp) | |
| 2066 *np++ = *buf++; | |
| 2067 return np - startp; | |
| 2068 } | |
| 2069 | |
| 2070 /* The Emacs root directory as determined by init_environment. */ | |
| 2071 | |
| 2072 static char emacsroot[MAXPATHLEN]; | |
| 2073 | |
| 2074 char * | |
| 2075 rootrelativepath (rel) | |
| 2076 char *rel; | |
| 2077 { | |
| 2078 static char result[MAXPATHLEN + 10]; | |
| 2079 | |
| 2080 strcpy (result, emacsroot); | |
| 2081 strcat (result, "/"); | |
| 2082 strcat (result, rel); | |
| 2083 return result; | |
| 2084 } | |
| 2085 | |
| 2086 /* Define a lot of environment variables if not already defined. Don't | |
| 2087 remove anything unless you know what you're doing -- lots of code will | |
| 2088 break if one or more of these are missing. */ | |
| 2089 | |
| 2090 void | |
| 2091 init_environment (argc, argv, skip_args) | |
| 2092 int argc; | |
| 2093 char **argv; | |
| 2094 int skip_args; | |
| 2095 { | |
| 2096 char *s, *t, *root; | |
| 2097 int len; | |
| 2098 | |
| 2099 /* Find our root from argv[0]. Assuming argv[0] is, say, | |
| 2100 "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */ | |
| 2101 root = alloca (MAXPATHLEN + 20); | |
| 2102 _fixpath (argv[0], root); | |
| 2103 strlwr (root); | |
| 2104 len = strlen (root); | |
| 2105 while (len > 0 && root[len] != '/' && root[len] != ':') | |
| 2106 len--; | |
| 2107 root[len] = '\0'; | |
| 2108 if (len > 4 && strcmp (root + len - 4, "/bin") == 0) | |
| 2109 root[len - 4] = '\0'; | |
| 2110 else | |
| 2111 strcpy (root, "c:/emacs"); /* Only under debuggers, I think. */ | |
| 2112 len = strlen (root); | |
| 2113 strcpy (emacsroot, root); | |
| 2114 | |
| 2115 /* We default HOME to our root. */ | |
| 2116 setenv ("HOME", root, 0); | |
| 2117 | |
| 2118 /* We default EMACSPATH to root + "/bin". */ | |
| 2119 strcpy (root + len, "/bin"); | |
| 2120 setenv ("EMACSPATH", root, 0); | |
| 2121 | |
| 2122 /* I don't expect anybody to ever use other terminals so the internal | |
| 2123 terminal is the default. */ | |
| 2124 setenv ("TERM", "internal", 0); | |
| 2125 | |
| 2126 #ifdef HAVE_X_WINDOWS | |
| 2127 /* Emacs expects DISPLAY to be set. */ | |
| 2128 setenv ("DISPLAY", "unix:0.0", 0); | |
| 2129 #endif | |
| 2130 | |
| 2131 /* SHELL is a bit tricky -- COMSPEC is the closest we come, but we must | |
| 2132 downcase it and mirror the backslashes. */ | |
| 2133 s = getenv ("COMSPEC"); | |
| 2134 if (!s) s = "c:/command.com"; | |
| 2135 t = alloca (strlen (s) + 1); | |
| 2136 strcpy (t, s); | |
| 2137 strlwr (t); | |
| 2138 dostounix_filename (t); | |
| 2139 setenv ("SHELL", t, 0); | |
| 2140 | |
| 2141 /* PATH is also downcased and backslashes mirrored. */ | |
| 2142 s = getenv ("PATH"); | |
| 2143 if (!s) s = ""; | |
| 2144 t = alloca (strlen (s) + 3); | |
| 2145 /* Current directory is always considered part of MsDos's path but it is | |
| 2146 not normally mentioned. Now it is. */ | |
| 2147 strcat (strcpy (t, ".;"), s); | |
| 2148 strlwr (t); | |
| 2149 dostounix_filename (t); /* Not a single file name, but this should work. */ | |
| 2150 setenv ("PATH", t, 1); | |
| 2151 | |
| 2152 /* In some sense all dos users have root privileges, so... */ | |
| 2153 setenv ("USER", "root", 0); | |
| 2154 setenv ("NAME", getenv ("USER"), 0); | |
| 2155 | |
| 2156 /* Time zone determined from country code. To make this possible, the | |
| 2157 country code may not span more than one time zone. In other words, | |
| 2158 in the USA, you lose. */ | |
| 13274 | 2159 if (!getenv ("TZ")) |
| 13179 | 2160 switch (dos_country_code) |
| 2161 { | |
| 2162 case 31: /* Belgium */ | |
| 2163 case 32: /* The Netherlands */ | |
| 2164 case 33: /* France */ | |
| 2165 case 34: /* Spain */ | |
| 2166 case 36: /* Hungary */ | |
| 2167 case 38: /* Yugoslavia (or what's left of it?) */ | |
| 2168 case 39: /* Italy */ | |
| 2169 case 41: /* Switzerland */ | |
| 2170 case 42: /* Tjekia */ | |
| 2171 case 45: /* Denmark */ | |
| 2172 case 46: /* Sweden */ | |
| 2173 case 47: /* Norway */ | |
| 2174 case 48: /* Poland */ | |
| 2175 case 49: /* Germany */ | |
| 2176 /* Daylight saving from last Sunday in March to last Sunday in | |
| 2177 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
|
2178 setenv ("TZ", "MET-01METDST-02,M3.5.0/02:00,M9.5.0/02:00", 0); |
| 13179 | 2179 break; |
| 2180 case 44: /* United Kingdom */ | |
| 2181 case 351: /* Portugal */ | |
| 2182 case 354: /* Iceland */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2183 setenv ("TZ", "GMT+00", 0); |
| 13179 | 2184 break; |
| 2185 case 81: /* Japan */ | |
| 2186 case 82: /* Korea */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2187 setenv ("TZ", "JST-09", 0); |
| 13179 | 2188 break; |
| 2189 case 90: /* Turkey */ | |
| 2190 case 358: /* Finland */ | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2191 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
|
2192 break; |
| 13179 | 2193 case 972: /* Israel */ |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2194 /* 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
|
2195 `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
|
2196 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
|
2197 setenv ("TZ", "IST-02IDT-03,M4.1.6/00:00,M9.5.6/01:00", 0); |
| 13179 | 2198 break; |
| 2199 } | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2200 init_gettimeofday (); |
| 13179 | 2201 } |
| 2202 | |
| 2203 | |
| 2204 | |
| 2205 static int break_stat; /* BREAK check mode status. */ | |
| 2206 static int stdin_stat; /* stdin IOCTL status. */ | |
| 2207 | |
| 2208 /* These must be global. */ | |
| 2209 static _go32_dpmi_seginfo ctrl_break_vector; | |
| 2210 static _go32_dpmi_registers ctrl_break_regs; | |
| 2211 static int ctrlbreakinstalled = 0; | |
| 2212 | |
| 2213 /* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */ | |
| 2214 | |
| 2215 void | |
| 2216 ctrl_break_func (regs) | |
| 2217 _go32_dpmi_registers *regs; | |
| 2218 { | |
| 2219 Vquit_flag = Qt; | |
| 2220 } | |
| 2221 | |
| 2222 void | |
| 2223 install_ctrl_break_check () | |
| 2224 { | |
| 2225 if (!ctrlbreakinstalled) | |
| 2226 { | |
| 2227 /* Don't press Ctrl-Break if you don't have either DPMI or Emacs | |
| 2228 was compiler with Djgpp 1.11 maintenance level 5 or later! */ | |
| 2229 ctrlbreakinstalled = 1; | |
| 2230 ctrl_break_vector.pm_offset = (int) ctrl_break_func; | |
| 2231 _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector, | |
| 2232 &ctrl_break_regs); | |
| 2233 _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector); | |
| 2234 } | |
| 2235 } | |
| 2236 | |
| 2237 /* | |
| 2238 * Turn off Dos' Ctrl-C checking and inhibit interpretation of | |
| 2239 * control chars by Dos. | |
| 2240 * Determine the keyboard type. | |
| 2241 */ | |
| 2242 | |
| 2243 int | |
| 2244 dos_ttraw () | |
| 2245 { | |
| 2246 union REGS inregs, outregs; | |
| 2247 static int first_time = 1; | |
| 2248 | |
| 2249 break_stat = getcbrk (); | |
| 2250 setcbrk (0); | |
| 2251 install_ctrl_break_check (); | |
| 2252 | |
| 2253 if (first_time) | |
| 2254 { | |
| 2255 inregs.h.ah = 0xc0; | |
| 2256 int86 (0x15, &inregs, &outregs); | |
| 2257 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0); | |
| 2258 | |
| 2259 have_mouse = 0; | |
| 2260 | |
| 2261 if (internal_terminal | |
| 2262 #ifdef HAVE_X_WINDOWS | |
| 2263 && inhibit_window_system | |
| 2264 #endif | |
| 2265 ) | |
| 2266 { | |
| 2267 inregs.x.ax = 0x0021; | |
| 2268 int86 (0x33, &inregs, &outregs); | |
| 2269 have_mouse = (outregs.x.ax & 0xffff) == 0xffff; | |
| 2270 if (!have_mouse) | |
| 2271 { | |
| 2272 /* Reportedly, the above doesn't work for some mouse drivers. There | |
| 2273 is an additional detection method that should work, but might be | |
| 2274 a little slower. Use that as an alternative. */ | |
| 2275 inregs.x.ax = 0x0000; | |
| 2276 int86 (0x33, &inregs, &outregs); | |
| 2277 have_mouse = (outregs.x.ax & 0xffff) == 0xffff; | |
| 2278 } | |
| 2279 | |
| 2280 if (have_mouse) | |
| 2281 { | |
| 2282 have_mouse = 1; /* enable mouse */ | |
| 2283 mouse_visible = 0; | |
| 2284 | |
| 2285 if (outregs.x.bx == 3) | |
| 2286 { | |
| 2287 mouse_button_count = 3; | |
| 2288 mouse_button_translate[0] = 0; /* Left */ | |
| 2289 mouse_button_translate[1] = 2; /* Middle */ | |
| 2290 mouse_button_translate[2] = 1; /* Right */ | |
| 2291 } | |
| 2292 else | |
| 2293 { | |
| 2294 mouse_button_count = 2; | |
| 2295 mouse_button_translate[0] = 0; | |
| 2296 mouse_button_translate[1] = 1; | |
| 2297 } | |
| 2298 mouse_position_hook = &mouse_get_pos; | |
| 2299 mouse_init (); | |
| 2300 } | |
| 2301 } | |
| 2302 | |
| 2303 first_time = 0; | |
| 2304 } | |
| 2305 | |
| 2306 inregs.x.ax = 0x4400; /* Get IOCTL status. */ | |
| 2307 inregs.x.bx = 0x00; /* 0 = stdin. */ | |
| 2308 intdos (&inregs, &outregs); | |
| 2309 stdin_stat = outregs.h.dl; | |
| 2310 | |
| 2311 inregs.x.dx = stdin_stat | 0x0020; /* raw mode */ | |
| 2312 inregs.x.ax = 0x4401; /* Set IOCTL status */ | |
| 2313 intdos (&inregs, &outregs); | |
| 2314 return !outregs.x.cflag; | |
| 2315 } | |
| 2316 | |
| 2317 /* Restore status of standard input and Ctrl-C checking. */ | |
| 2318 int | |
| 2319 dos_ttcooked () | |
| 2320 { | |
| 2321 union REGS inregs, outregs; | |
| 2322 | |
| 2323 setcbrk (break_stat); | |
| 2324 mouse_off (); | |
| 2325 | |
| 2326 inregs.x.ax = 0x4401; /* Set IOCTL status. */ | |
| 2327 inregs.x.bx = 0x00; /* 0 = stdin. */ | |
| 2328 inregs.x.dx = stdin_stat; | |
| 2329 intdos (&inregs, &outregs); | |
| 2330 return !outregs.x.cflag; | |
| 2331 } | |
| 2332 | |
| 2333 | |
| 2334 /* 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
|
2335 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
|
2336 file TEMPOUT and stderr to TEMPERR. */ |
| 13179 | 2337 int |
|
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2338 run_msdos_command (argv, dir, tempin, tempout, temperr) |
| 13179 | 2339 unsigned char **argv; |
| 2340 Lisp_Object dir; | |
|
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2341 int tempin, tempout, temperr; |
| 13179 | 2342 { |
| 2343 char *saveargv1, *saveargv2, **envv; | |
| 2344 char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ | |
| 2345 int msshell, result = -1; | |
| 2346 int in, out, inbak, outbak, errbak; | |
| 2347 int x, y; | |
| 2348 Lisp_Object cmd; | |
| 2349 | |
| 2350 /* Get current directory as MSDOS cwd is not per-process. */ | |
| 2351 getwd (oldwd); | |
| 2352 | |
| 2353 cmd = Ffile_name_nondirectory (build_string (argv[0])); | |
| 2354 msshell = !NILP (Fmember (cmd, Fsymbol_value (intern ("msdos-shells")))) | |
| 2355 && !strcmp ("-c", argv[1]); | |
| 2356 if (msshell) | |
| 2357 { | |
| 2358 saveargv1 = argv[1]; | |
| 2359 saveargv2 = argv[2]; | |
| 2360 argv[1] = "/c"; | |
| 2361 if (argv[2]) | |
| 2362 { | |
| 2363 char *p = alloca (strlen (argv[2]) + 1); | |
| 2364 | |
| 2365 strcpy (argv[2] = p, saveargv2); | |
| 2366 while (*p && isspace (*p)) | |
| 2367 p++; | |
| 2368 while (*p && !isspace (*p)) | |
| 2369 if (*p == '/') | |
| 2370 *p++ = '\\'; | |
| 2371 else | |
| 2372 p++; | |
| 2373 } | |
| 2374 } | |
| 2375 | |
| 2376 /* Build the environment array. */ | |
| 2377 { | |
| 2378 extern Lisp_Object Vprocess_environment; | |
| 2379 Lisp_Object tmp, lst; | |
| 2380 int i, len; | |
| 2381 | |
| 2382 lst = Vprocess_environment; | |
| 2383 len = XFASTINT (Flength (lst)); | |
| 2384 | |
| 2385 envv = alloca ((len + 1) * sizeof (char *)); | |
| 2386 for (i = 0; i < len; i++) | |
| 2387 { | |
| 2388 tmp = Fcar (lst); | |
| 2389 lst = Fcdr (lst); | |
| 2390 CHECK_STRING (tmp, 0); | |
| 2391 envv[i] = alloca (XSTRING (tmp)->size + 1); | |
| 2392 strcpy (envv[i], XSTRING (tmp)->data); | |
| 2393 } | |
| 2394 envv[len] = (char *) 0; | |
| 2395 } | |
| 2396 | |
| 2397 if (STRINGP (dir)) | |
| 2398 chdir (XSTRING (dir)->data); | |
| 2399 inbak = dup (0); | |
| 2400 outbak = dup (1); | |
| 2401 errbak = dup (2); | |
| 2402 if (inbak < 0 || outbak < 0 || errbak < 0) | |
| 2403 goto done; /* Allocation might fail due to lack of descriptors. */ | |
| 2404 | |
| 2405 if (have_mouse > 0) | |
| 2406 mouse_get_xy (&x, &y); | |
| 2407 | |
| 2408 dos_ttcooked (); /* do it here while 0 = stdin */ | |
| 2409 | |
| 2410 dup2 (tempin, 0); | |
| 2411 dup2 (tempout, 1); | |
|
13718
e1b33f87545f
(run_msdos_command): Support redirection of stderr.
Karl Heuer <kwzh@gnu.org>
parents:
13717
diff
changeset
|
2412 dup2 (temperr, 2); |
| 13179 | 2413 |
| 2414 result = spawnve (P_WAIT, argv[0], argv, envv); | |
| 2415 | |
| 2416 dup2 (inbak, 0); | |
| 2417 dup2 (outbak, 1); | |
| 2418 dup2 (errbak, 2); | |
| 2419 close (inbak); | |
| 2420 close (outbak); | |
| 2421 close (errbak); | |
| 2422 | |
| 13274 | 2423 dos_ttraw (); |
| 13179 | 2424 if (have_mouse > 0) |
| 2425 { | |
| 2426 mouse_init (); | |
| 2427 mouse_moveto (x, y); | |
| 2428 } | |
| 2429 | |
| 2430 done: | |
| 2431 chdir (oldwd); | |
| 2432 if (msshell) | |
| 2433 { | |
| 2434 argv[1] = saveargv1; | |
| 2435 argv[2] = saveargv2; | |
| 2436 } | |
| 2437 return result; | |
| 2438 } | |
| 2439 | |
| 2440 croak (badfunc) | |
| 2441 char *badfunc; | |
| 2442 { | |
| 2443 fprintf (stderr, "%s not yet implemented\r\n", badfunc); | |
| 2444 reset_sys_modes (); | |
| 2445 exit (1); | |
| 2446 } | |
|
13848
5f38596d591e
(have_menus_p): Defined.
Richard M. Stallman <rms@gnu.org>
parents:
13744
diff
changeset
|
2447 |
| 13179 | 2448 /* ------------------------- Compatibility functions ------------------- |
| 2449 * gethostname | |
| 2450 * gettimeofday | |
| 2451 */ | |
| 2452 | |
| 2453 /* | |
| 2454 * Hostnames for a pc are not really funny, | |
| 2455 * but they are used in change log so we emulate the best we can. | |
| 2456 */ | |
| 2457 | |
| 2458 gethostname (p, size) | |
| 2459 char *p; | |
| 2460 int size; | |
| 2461 { | |
| 2462 char *q = egetenv ("HOSTNAME"); | |
| 2463 | |
| 2464 if (!q) q = "pc"; | |
| 2465 strcpy (p, q); | |
| 2466 return 0; | |
| 2467 } | |
| 2468 | |
|
13394
c4549fcdd5f3
(the_only_x_display): Type is now struct x_output.
Karl Heuer <kwzh@gnu.org>
parents:
13305
diff
changeset
|
2469 /* When time zones are set from Ms-Dos too many C-libraries are playing |
| 13179 | 2470 tricks with time values. We solve this by defining our own version |
| 2471 of `gettimeofday' bypassing GO32. Our version needs to be initialized | |
| 2472 once and after each call to `tzset' with TZ changed. That is | |
| 2473 accomplished by aliasing tzset to init_gettimeofday. */ | |
| 2474 | |
| 2475 static struct tm time_rec; | |
| 2476 | |
| 2477 int | |
| 2478 gettimeofday (struct timeval *tp, struct timezone *tzp) | |
| 2479 { | |
| 2480 if (tp) | |
| 2481 { | |
| 2482 struct time t; | |
| 2483 struct tm tm; | |
| 2484 | |
| 2485 gettime (&t); | |
| 2486 if (t.ti_hour < time_rec.tm_hour) /* midnight wrap */ | |
| 2487 { | |
| 2488 struct date d; | |
| 2489 getdate (&d); | |
| 2490 time_rec.tm_year = d.da_year - 1900; | |
| 2491 time_rec.tm_mon = d.da_mon - 1; | |
| 2492 time_rec.tm_mday = d.da_day; | |
| 2493 } | |
| 2494 | |
| 2495 time_rec.tm_hour = t.ti_hour; | |
| 2496 time_rec.tm_min = t.ti_min; | |
| 2497 time_rec.tm_sec = t.ti_sec; | |
| 2498 | |
| 2499 tm = time_rec; | |
| 2500 tm.tm_gmtoff = dos_timezone_offset; | |
| 2501 | |
| 2502 tp->tv_sec = mktime (&tm); /* may modify tm */ | |
| 2503 tp->tv_usec = t.ti_hund * (1000000 / 100); | |
| 2504 } | |
| 2505 /* Ignore tzp; it's obsolescent. */ | |
| 2506 return 0; | |
| 2507 } | |
| 2508 | |
| 2509 | |
| 2510 /* | |
| 2511 * A list of unimplemented functions that we silently ignore. | |
| 2512 */ | |
| 2513 | |
| 2514 unsigned alarm (s) unsigned s; {} | |
| 2515 fork () { return 0; } | |
| 2516 int kill (x, y) int x, y; { return -1; } | |
| 2517 nice (p) int p; {} | |
| 2518 void volatile pause () {} | |
| 2519 request_sigio () {} | |
| 2520 setpgrp () {return 0; } | |
| 2521 setpriority (x,y,z) int x,y,z; { return 0; } | |
| 2522 sigsetmask (x) int x; { return 0; } | |
|
14262
ef10a42c21f4
(sigblock): New (dummy) function.
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
2523 sigblock (mask) int mask; { return 0; } |
| 13179 | 2524 unrequest_sigio () {} |
| 2525 | |
| 2526 #ifndef HAVE_SELECT | |
| 2527 #include "sysselect.h" | |
| 2528 | |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2529 static struct time last_time = {120, 120, 120, 120}; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2530 static int modeline_time_displayed = 0; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2531 |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2532 Lisp_Object Vdos_display_time; |
| 13179 | 2533 |
| 2534 static void | |
| 2535 check_timer (t) | |
| 2536 struct time *t; | |
| 2537 { | |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2538 int sec, min, hour, hund; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2539 |
| 13179 | 2540 gettime (t); |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2541 sec = t->ti_sec; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2542 hund = t->ti_hund; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2543 hour = t->ti_hour; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2544 min = t->ti_min; |
| 13179 | 2545 |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2546 /* Any chance of not getting here 24 hours or more since last time? */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2547 if (hour == last_time.ti_hour |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2548 && min == last_time.ti_min |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2549 && sec == last_time.ti_sec) |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2550 return; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2551 |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2552 if (!NILP (Vdos_display_time)) |
| 13179 | 2553 { |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2554 int interval; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2555 Lisp_Object dti = XSYMBOL (Fintern_soft (build_string ("display-time-interval"), Qnil))->value; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2556 int delta_time = ((hour - last_time.ti_hour) * 3600 |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2557 + (min - last_time.ti_min) * 60 |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2558 + (sec - last_time.ti_sec)); |
| 13179 | 2559 |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2560 /* Who knows what the user may put into `display-time-interval'? */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2561 if (!INTEGERP (dti) || (interval = XINT (dti)) <= 0) |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2562 interval = 60; |
| 13179 | 2563 |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2564 /* When it's time to renew the display, fake a `wakeup' call. */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2565 if (!modeline_time_displayed /* first time */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2566 || delta_time >= interval /* or if we were busy for a long time */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2567 || interval == 1 /* and every `interval' seconds hence */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2568 || interval == 60 && sec == 0 /* (usual cases first) */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2569 || (hour * 3600 + min * 60 + sec) % interval == 0) |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2570 call2 (intern ("display-time-filter"), Qnil, |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2571 build_string ("Wake up!\n")); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2572 |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2573 modeline_time_displayed = 1; |
|
13520
8c7a3533a688
(dos_menubar_clock_displayed): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13394
diff
changeset
|
2574 } |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2575 else if (modeline_time_displayed) |
|
13520
8c7a3533a688
(dos_menubar_clock_displayed): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13394
diff
changeset
|
2576 { |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2577 modeline_time_displayed = 0; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2578 Fset (intern ("display-time-string"), build_string ("")); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2579 |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2580 /* Force immediate redisplay of modelines. */ |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2581 update_mode_lines++; |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2582 redisplay_preserve_echo_area (); |
| 13179 | 2583 } |
| 2584 | |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2585 last_time = *t; |
| 13179 | 2586 } |
| 2587 | |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2588 #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
|
2589 #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
|
2590 ((long)(time).tv_sec < 0 \ |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2591 || ((time).tv_sec == 0 \ |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2592 && (long)(time).tv_usec <= 0)) |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2593 #endif |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2594 |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2595 |
| 13179 | 2596 /* Only event queue is checked. */ |
| 2597 int | |
| 2598 sys_select (nfds, rfds, wfds, efds, timeout) | |
| 2599 int nfds; | |
| 2600 SELECT_TYPE *rfds, *wfds, *efds; | |
| 2601 EMACS_TIME *timeout; | |
| 2602 { | |
| 2603 int check_input; | |
| 2604 struct time t; | |
| 2605 | |
| 2606 check_input = 0; | |
| 2607 if (rfds) | |
| 2608 { | |
| 2609 check_input = FD_ISSET (0, rfds); | |
| 2610 FD_ZERO (rfds); | |
| 2611 } | |
| 2612 if (wfds) | |
| 2613 FD_ZERO (wfds); | |
| 2614 if (efds) | |
| 2615 FD_ZERO (efds); | |
| 2616 | |
| 2617 if (nfds != 1) | |
| 2618 abort (); | |
| 2619 | |
| 2620 /* If we are looking only for the terminal, with no timeout, | |
| 2621 just read it and wait -- that's more efficient. */ | |
| 2622 if (!timeout) | |
| 2623 { | |
|
13657
0dd21f630fb0
(sys_select): Check timer once even if input is pending.
Richard M. Stallman <rms@gnu.org>
parents:
13646
diff
changeset
|
2624 do |
|
0dd21f630fb0
(sys_select): Check timer once even if input is pending.
Richard M. Stallman <rms@gnu.org>
parents:
13646
diff
changeset
|
2625 check_timer (&t); /* check timer even if some input is pending */ |
|
0dd21f630fb0
(sys_select): Check timer once even if input is pending.
Richard M. Stallman <rms@gnu.org>
parents:
13646
diff
changeset
|
2626 while (!detect_input_pending ()); |
| 13179 | 2627 } |
| 2628 else | |
| 2629 { | |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2630 EMACS_TIME clnow, cllast, cldiff; |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2631 |
| 13179 | 2632 check_timer (&t); |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2633 EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L); |
| 13179 | 2634 |
| 2635 while (!check_input || !detect_input_pending ()) | |
| 2636 { | |
| 2637 check_timer (&t); | |
|
14279
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2638 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
|
2639 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
|
2640 |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2641 /* When seconds wrap around, we assume that no more than |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2642 1 minute passed since last `check_timer'. */ |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2643 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
|
2644 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
|
2645 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
|
2646 |
|
085bc709c11d
(sys_select): Use time macros to prevent time values
Karl Heuer <kwzh@gnu.org>
parents:
14262
diff
changeset
|
2647 /* 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
|
2648 if (EMACS_TIME_ZERO_OR_NEG_P (*timeout)) |
| 13179 | 2649 return 0; |
| 2650 cllast = clnow; | |
| 2651 } | |
| 2652 } | |
| 2653 | |
| 2654 FD_SET (0, rfds); | |
| 2655 return 1; | |
| 2656 } | |
| 2657 #endif | |
| 2658 | |
| 2659 /* | |
| 14036 | 2660 * Define overlaid functions: |
| 13179 | 2661 * |
| 2662 * chdir -> sys_chdir | |
| 2663 * tzset -> init_gettimeofday | |
| 2664 * abort -> dos_abort | |
| 2665 */ | |
| 2666 | |
| 2667 #ifdef chdir | |
| 2668 #undef chdir | |
| 2669 extern int chdir (); | |
| 2670 | |
| 2671 int | |
| 2672 sys_chdir (path) | |
| 2673 const char* path; | |
| 2674 { | |
| 2675 int len = strlen (path); | |
| 2676 char *tmp = (char *)path; | |
| 2677 | |
| 2678 if (*tmp && tmp[1] == ':') | |
| 2679 { | |
| 2680 if (getdisk () != tolower (tmp[0]) - 'a') | |
| 2681 setdisk (tolower (tmp[0]) - 'a'); | |
| 2682 tmp += 2; /* strip drive: KFS 1995-07-06 */ | |
| 2683 len -= 2; | |
| 2684 } | |
| 2685 | |
| 2686 if (len > 1 && (tmp[len - 1] == '/')) | |
| 2687 { | |
| 2688 char *tmp1 = (char *) alloca (len + 1); | |
| 2689 strcpy (tmp1, tmp); | |
| 2690 tmp1[len - 1] = 0; | |
| 2691 tmp = tmp1; | |
| 2692 } | |
| 2693 return chdir (tmp); | |
| 2694 } | |
| 2695 #endif | |
| 2696 | |
| 2697 #ifdef tzset | |
| 2698 #undef tzset | |
| 2699 extern void tzset (void); | |
| 2700 | |
| 2701 void | |
| 2702 init_gettimeofday () | |
| 2703 { | |
| 2704 time_t ltm, gtm; | |
| 2705 struct tm *lstm; | |
| 2706 | |
| 2707 tzset (); | |
| 2708 ltm = gtm = time (NULL); | |
| 2709 ltm = mktime (lstm = localtime (<m)); | |
| 2710 gtm = mktime (gmtime (>m)); | |
| 2711 time_rec.tm_hour = 99; /* force gettimeofday to get date */ | |
| 2712 time_rec.tm_isdst = lstm->tm_isdst; | |
| 2713 dos_timezone_offset = time_rec.tm_gmtoff = (int)(gtm - ltm) / 60; | |
| 2714 } | |
| 2715 #endif | |
| 2716 | |
| 2717 #ifdef abort | |
| 2718 #undef abort | |
| 2719 void | |
| 2720 dos_abort (file, line) | |
| 2721 char *file; | |
| 2722 int line; | |
| 2723 { | |
| 2724 char buffer1[200], buffer2[400]; | |
| 2725 int i, j; | |
| 2726 | |
| 2727 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line); | |
| 2728 for (i = j = 0; buffer1[i]; i++) { | |
| 2729 buffer2[j++] = buffer1[i]; | |
| 2730 buffer2[j++] = 0x70; | |
| 2731 } | |
| 2732 dosmemput (buffer2, j, (int)ScreenPrimary); | |
| 2733 ScreenSetCursor (2, 0); | |
| 2734 abort (); | |
| 2735 } | |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2736 #else |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2737 void |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2738 abort () |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2739 { |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2740 dos_ttcooked (); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2741 ScreenSetCursor (10, 0); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2742 cputs ("\r\n\nEmacs aborted!\r\n"); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2743 exit (2); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2744 } |
| 13179 | 2745 #endif |
| 2746 | |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2747 syms_of_msdos () |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2748 { |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2749 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
|
2750 staticpro (&recent_doskeys); |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2751 |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2752 defsubr (&Srecent_doskeys); |
|
13744
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2753 |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2754 DEFVAR_LISP ("dos-display-time", &Vdos_display_time, |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2755 "*When non-nil, `display-time' is in effect on DOS systems."); |
|
120c884de8a2
(check_timer): get rid of the DOS-specific menubar clock
Karl Heuer <kwzh@gnu.org>
parents:
13718
diff
changeset
|
2756 Vdos_display_time = Qnil; |
|
13305
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2757 } |
|
63a43c4b29b2
(IT_ring_bell): Use intdos, not write.
Richard M. Stallman <rms@gnu.org>
parents:
13274
diff
changeset
|
2758 |
| 5503 | 2759 #endif /* MSDOS */ |
