(command-line-1): Update copyright in startup banner.
[bpt/emacs.git] / src / msdos.c
CommitLineData
9da6e765 1/* MS-DOS specific C utilities.
1d28946c 2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
1b94449f
RS
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
edfc0d45 8the Free Software Foundation; either version 2, or (at your option)
1b94449f
RS
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
3b7ad313
EN
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
1b94449f 20
9da6e765 21/* Contributed by Morten Welinder */
f32d4091 22/* New display, keyboard, and mouse control by Kim F. Storm */
9da6e765 23
1b94449f
RS
24/* Note: some of the stuff here was taken from end of sysdep.c in demacs. */
25
48984716 26#include <config.h>
1b94449f
RS
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"
87485d6f
MW
39#include "dispextern.h"
40#include "termopts.h"
1b94449f 41#include "frame.h"
87485d6f 42#include "window.h"
1b94449f
RS
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
aee81730
RS
50
51static unsigned long
52event_timestamp ()
53{
54 struct time t;
55 unsigned long s;
f32d4091 56
aee81730
RS
57 gettime (&t);
58 s = t.ti_min;
59 s *= 60;
60 s += t.ti_sec;
61 s *= 1000;
62 s += t.ti_hund * 10;
f32d4091 63
aee81730
RS
64 return s;
65}
66
f32d4091
KS
67\f
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 */
1b94449f 73
f32d4091
KS
74int have_mouse; /* 0: no, 1: enabled, -1: disabled */
75static int mouse_visible;
1b94449f 76
f32d4091
KS
77static int mouse_last_x;
78static int mouse_last_y;
1b94449f 79
f32d4091
KS
80static int mouse_button_translate[NUM_MOUSE_BUTTONS];
81static int mouse_button_count;
1b94449f 82
f32d4091
KS
83void
84mouse_on ()
1b94449f 85{
1b94449f 86 union REGS regs;
1b94449f 87
f32d4091 88 if (have_mouse > 0 && !mouse_visible)
1b94449f 89 {
f32d4091
KS
90 if (termscript)
91 fprintf (termscript, "<M_ON>");
92 regs.x.ax = 0x0001;
93 int86 (0x33, &regs, &regs);
94 mouse_visible = 1;
1b94449f 95 }
1b94449f
RS
96}
97
f32d4091
KS
98void
99mouse_off ()
1b94449f 100{
f32d4091 101 union REGS regs;
1b94449f 102
f32d4091 103 if (have_mouse > 0 && mouse_visible)
1b94449f 104 {
f32d4091
KS
105 if (termscript)
106 fprintf (termscript, "<M_OFF>");
107 regs.x.ax = 0x0002;
108 int86 (0x33, &regs, &regs);
109 mouse_visible = 0;
1b94449f 110 }
1b94449f
RS
111}
112
f32d4091
KS
113void
114mouse_moveto (x, y)
115 int x, y;
1b94449f 116{
f32d4091 117 union REGS regs;
1b94449f 118
f32d4091
KS
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, &regs, &regs);
1b94449f
RS
125}
126
f32d4091
KS
127static int
128mouse_pressed (b, xp, yp)
129 int b, *xp, *yp;
1b94449f 130{
f32d4091 131 union REGS regs;
1b94449f 132
f32d4091
KS
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, &regs, &regs);
138 if (regs.x.bx)
139 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
140 return (regs.x.bx != 0);
1b94449f
RS
141}
142
f32d4091
KS
143static int
144mouse_released (b, xp, yp)
145 int b, *xp, *yp;
1b94449f
RS
146{
147 union REGS regs;
148
f32d4091
KS
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, &regs, &regs);
154 if (regs.x.bx)
155 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
156 return (regs.x.bx != 0);
1b94449f
RS
157}
158
f32d4091
KS
159static void
160mouse_get_xy (int *x, int *y)
1b94449f 161{
f32d4091 162 union REGS regs;
1b94449f 163
f32d4091
KS
164 regs.x.ax = 0x0003;
165 int86 (0x33, &regs, &regs);
166 *x = regs.x.cx / 8;
167 *y = regs.x.dx / 8;
1b94449f
RS
168}
169
f32d4091
KS
170void
171mouse_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, &regs, &regs);
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}
1b94449f 191
f32d4091
KS
192static void
193mouse_check_moved ()
1b94449f 194{
aee81730 195 int x, y;
1b94449f 196
f32d4091
KS
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;
201}
1b94449f 202
f32d4091
KS
203void
204mouse_init ()
205{
206 union REGS regs;
647c32eb 207
f32d4091
KS
208 if (termscript)
209 fprintf (termscript, "<M_INIT>");
1b94449f 210
f32d4091
KS
211 regs.x.ax = 0x0021;
212 int86 (0x33, &regs, &regs);
091d0bdf 213
f32d4091
KS
214 regs.x.ax = 0x0007;
215 regs.x.cx = 0;
216 regs.x.dx = 8 * (ScreenCols () - 1);
217 int86 (0x33, &regs, &regs);
1b94449f 218
f32d4091
KS
219 regs.x.ax = 0x0008;
220 regs.x.cx = 0;
221 regs.x.dx = 8 * (ScreenRows () - 1);
222 int86 (0x33, &regs, &regs);
1b94449f 223
f32d4091
KS
224 mouse_moveto (0, 0);
225 mouse_visible = 0;
226}
3eb1dbb6 227\f
f32d4091
KS
228/* ------------------------- Screen control ----------------------
229 *
230 */
aee81730 231
f32d4091 232static int internal_terminal = 0;
aee81730 233
f32d4091
KS
234#ifndef HAVE_X_WINDOWS
235extern unsigned char ScreenAttrib;
236static int screen_face;
237static int highlight;
aee81730 238
f32d4091
KS
239static int screen_size_X;
240static int screen_size_Y;
241static int screen_size;
1b94449f 242
f32d4091
KS
243static int current_pos_X;
244static int current_pos_Y;
245static int new_pos_X;
246static int new_pos_Y;
1b94449f 247
f32d4091
KS
248static void *startup_screen_buffer;
249static int startup_screen_size_X;
250static int startup_screen_size_Y;
251static int startup_pos_X;
252static int startup_pos_Y;
c9adab25 253static unsigned char startup_screen_attrib;
1b94449f 254
f32d4091 255static int term_setup_done;
1b94449f 256
f32d4091 257/* Similar to the_only_frame. */
f6816f88 258struct x_output the_only_x_display;
1b94449f 259
f32d4091
KS
260/* This is never dereferenced. */
261Display *x_current_display;
1b94449f 262
1b94449f 263
f32d4091
KS
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)
aee81730 267
f32d4091
KS
268static
269dos_direct_output (y, x, buf, len)
270 int y;
271 int x;
272 char *buf;
273 int len;
1b94449f 274{
f32d4091 275 int t = (int) ScreenPrimary + 2 * (x + y * screen_size_X);
aee81730 276
f32d4091
KS
277 while (--len >= 0) {
278 dosmemput (buf++, 1, t);
279 t += 2;
280 }
1b94449f 281}
aee81730 282#endif
1b94449f 283
1b94449f
RS
284/* Flash the screen as a substitute for BEEPs. */
285
f32d4091 286#if (__DJGPP__ < 2)
49a09c76 287static void
fcea9cd4 288do_visible_bell (xorattr)
1b94449f
RS
289 unsigned char xorattr;
290{
49a09c76 291 asm volatile
ca986694 292 (" movb $1,%%dl
1b94449f 293visible_bell_0:
ca986694 294 movl _ScreenPrimary,%%eax
49a09c76 295 call dosmemsetup
ca986694
RS
296 movl %%eax,%%ebx
297 movl %1,%%ecx
298 movb %0,%%al
299 incl %%ebx
1b94449f 300visible_bell_1:
ca986694
RS
301 xorb %%al,%%gs:(%%ebx)
302 addl $2,%%ebx
303 decl %%ecx
49a09c76 304 jne visible_bell_1
ca986694 305 decb %%dl
49a09c76 306 jne visible_bell_3
1b94449f 307visible_bell_2:
ca986694
RS
308 movzwl %%ax,%%eax
309 movzwl %%ax,%%eax
310 movzwl %%ax,%%eax
311 movzwl %%ax,%%eax
312 decw %%cx
49a09c76
RS
313 jne visible_bell_2
314 jmp visible_bell_0
ca986694
RS
315visible_bell_3:"
316 : /* no output */
f32d4091 317 : "m" (xorattr), "g" (screen_size)
ca986694 318 : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx");
1b94449f
RS
319}
320
f32d4091
KS
321static void
322ScreenVisualBell (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
334/*
335 * If we write a character in the position where the mouse is,
336 * the mouse cursor may need to be refreshed.
337 */
09e2ac30
RS
338
339static void
f32d4091 340mouse_off_maybe ()
09e2ac30 341{
f32d4091
KS
342 int x, y;
343
344 if (!mouse_visible)
345 return;
346
347 mouse_get_xy (&x, &y);
348 if (y != new_pos_Y || x < new_pos_X)
349 return;
350
351 mouse_off ();
352}
353
354static
355IT_ring_bell ()
356{
357 if (visible_bell)
aee81730 358 {
f32d4091
KS
359 mouse_off ();
360 ScreenVisualBell ();
aee81730 361 }
f32d4091 362 else
3635be47
RS
363 {
364 union REGS inregs, outregs;
365 inregs.h.ah = 2;
366 inregs.h.dl = 7;
367 intdos (&inregs, &outregs);
368 }
09e2ac30
RS
369}
370
f32d4091
KS
371static void
372IT_set_face (int face)
373{
374 struct face *fp;
375 extern struct face *intern_face (/* FRAME_PTR, struct face * */);
376
377 if (face == 1 || (face == 0 && highlight))
378 fp = FRAME_MODE_LINE_FACE (foo);
379 else if (face <= 0 || face >= FRAME_N_COMPUTED_FACES (foo))
380 fp = FRAME_DEFAULT_FACE (foo);
381 else
382 fp = intern_face (selected_frame, FRAME_COMPUTED_FACES (foo)[face]);
383 if (termscript)
384 fprintf (termscript, "<FACE:%d:%d>", FACE_FOREGROUND (fp), FACE_BACKGROUND (fp));
385 screen_face = face;
386 ScreenAttrib = (FACE_BACKGROUND (fp) << 4) | FACE_FOREGROUND (fp);
387}
388
389static
390IT_write_glyphs (GLYPH *str, int len)
391{
392 int newface;
393 int ch, l = len;
394 unsigned char *buf, *bp;
87485d6f 395
f32d4091 396 if (len == 0) return;
aee81730 397
f32d4091 398 buf = bp = alloca (len * 2);
aee81730 399
f32d4091 400 while (--l >= 0)
aee81730 401 {
f32d4091
KS
402 newface = FAST_GLYPH_FACE (*str);
403 if (newface != screen_face)
404 IT_set_face (newface);
405 ch = FAST_GLYPH_CHAR (*str);
406 *bp++ = (unsigned char)ch;
407 *bp++ = ScreenAttrib;
408
409 if (termscript)
410 fputc (ch, termscript);
411 str++;
aee81730
RS
412 }
413
f32d4091
KS
414 mouse_off_maybe ();
415 dosmemput (buf, 2 * len,
416 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y));
417 new_pos_X += len;
418}
aee81730 419
f32d4091
KS
420static
421IT_clear_end_of_line (first_unused)
422{
423 char *spaces, *sp;
424 int i, j;
425
426 IT_set_face (0);
427 if (termscript)
428 fprintf (termscript, "<CLR:EOL>");
429 i = (j = screen_size_X - new_pos_X) * 2;
430 spaces = sp = alloca (i);
aee81730 431
f32d4091 432 while (--j >= 0)
aee81730 433 {
f32d4091
KS
434 *sp++ = ' ';
435 *sp++ = ScreenAttrib;
aee81730
RS
436 }
437
f32d4091
KS
438 mouse_off_maybe ();
439 dosmemput (spaces, i,
440 (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y));
aee81730
RS
441}
442
f32d4091
KS
443static
444IT_clear_screen (void)
445{
446 if (termscript)
447 fprintf (termscript, "<CLR:SCR>");
448 IT_set_face (0);
449 mouse_off ();
450 ScreenClear ();
451 new_pos_X = new_pos_Y = 0;
452}
453
454static
455IT_clear_to_end (void)
456{
457 if (termscript)
458 fprintf (termscript, "<CLR:EOS>");
459
460 while (new_pos_Y < screen_size_Y) {
461 new_pos_X = 0;
462 IT_clear_end_of_line (0);
463 new_pos_Y++;
464 }
465}
466
467static
468IT_cursor_to (int y, int x)
469{
470 if (termscript)
471 fprintf (termscript, "\n<XY=%dx%d>", x, y);
472 new_pos_X = x;
473 new_pos_Y = y;
474}
475
476static
477IT_reassert_line_highlight (new, vpos)
478 int new, vpos;
479{
480 highlight = new;
481 IT_set_face (0); /* To possibly clear the highlighting. */
482}
483
484static
485IT_change_line_highlight (new_highlight, vpos, first_unused_hpos)
1b94449f 486{
f32d4091
KS
487 highlight = new_highlight;
488 IT_set_face (0); /* To possibly clear the highlighting. */
489 IT_cursor_to (vpos, 0);
490 IT_clear_end_of_line (first_unused_hpos);
491}
492
493static
494IT_update_begin ()
495{
496 highlight = 0;
497 IT_set_face (0); /* To possibly clear the highlighting. */
498 screen_face = -1;
499}
500
501static
502IT_update_end ()
503{
504}
1b94449f 505
f32d4091
KS
506/* This was more or less copied from xterm.c */
507static void
508IT_set_menu_bar_lines (window, n)
509 Lisp_Object window;
510 int n;
511{
512 struct window *w = XWINDOW (window);
513
9a166e40 514 XSETFASTINT (w->last_modified, 0);
f32d4091
KS
515 XSETFASTINT (w->top, XFASTINT (w->top) + n);
516 XSETFASTINT (w->height, XFASTINT (w->height) - n);
517
518 /* Handle just the top child in a vertical split. */
519 if (!NILP (w->vchild))
520 IT_set_menu_bar_lines (w->vchild, n);
521
522 /* Adjust all children in a horizontal split. */
523 for (window = w->hchild; !NILP (window); window = w->next)
1b94449f 524 {
f32d4091
KS
525 w = XWINDOW (window);
526 IT_set_menu_bar_lines (window, n);
aee81730 527 }
f32d4091
KS
528}
529
530/*
531 * IT_set_terminal_modes is called when emacs is started,
532 * resumed, and whenever the screen is redrawn!
533 */
534
535static
536IT_set_terminal_modes (void)
537{
538 char *colors;
539 FRAME_PTR f;
540 struct face *fp;
aee81730 541
aee81730 542 if (termscript)
f32d4091
KS
543 fprintf (termscript, "\n<SET_TERM>");
544 highlight = 0;
545
546 screen_size_X = ScreenCols ();
547 screen_size_Y = ScreenRows ();
548 screen_size = screen_size_X * screen_size_Y;
aee81730 549
f32d4091
KS
550 new_pos_X = new_pos_Y = 0;
551 current_pos_X = current_pos_Y = -1;
552
553 if (term_setup_done)
554 return;
555 term_setup_done = 1;
aee81730 556
f32d4091
KS
557 startup_screen_size_X = screen_size_X;
558 startup_screen_size_Y = screen_size_Y;
c9adab25 559 startup_screen_attrib = ScreenAttrib;
f32d4091
KS
560
561 ScreenGetCursor (&startup_pos_Y, &startup_pos_X);
562 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2));
563
564 if (termscript)
c9adab25
KH
565 fprintf (termscript, "<SCREEN SAVED (dimensions=%dx%d)>\n",
566 screen_size_X, screen_size_Y);
f32d4091
KS
567}
568
569/*
570 * IT_reset_terminal_modes is called when emacs is
571 * suspended or killed.
572 */
573
574static
575IT_reset_terminal_modes (void)
576{
c9adab25
KH
577 int display_row_start = (int) ScreenPrimary;
578 int saved_row_len = startup_screen_size_X * 2;
579 int update_row_len = ScreenCols () * 2;
580 int current_rows = ScreenRows ();
581 int to_next_row = update_row_len;
582 unsigned char *saved_row = startup_screen_buffer;
583 int cursor_pos_X = ScreenCols () - 1;
584 int cursor_pos_Y = ScreenRows () - 1;
585
f32d4091 586 if (termscript)
5063b150 587 fprintf (termscript, "\n<RESET_TERM>");
f32d4091
KS
588
589 highlight = 0;
590
591 if (!term_setup_done)
592 return;
593
c9adab25
KH
594 mouse_off ();
595
596 /* We have a situation here.
597 We cannot just do ScreenUpdate(startup_screen_buffer) because
598 the luser could have changed screen dimensions inside Emacs
599 and failed (or didn't want) to restore them before killing
600 Emacs. ScreenUpdate() uses the *current* screen dimensions and
601 thus will happily use memory outside what was allocated for
602 `startup_screen_buffer'.
603 Thus we only restore as much as the current screen dimensions
604 can hold, and clear the rest (if the saved screen is smaller than
605 the current) with the color attribute saved at startup. The cursor
606 is also restored within the visible dimensions. */
607
608 ScreenAttrib = startup_screen_attrib;
609 ScreenClear ();
610
611 if (update_row_len > saved_row_len)
612 update_row_len = saved_row_len;
613 if (current_rows > startup_screen_size_Y)
614 current_rows = startup_screen_size_Y;
f32d4091
KS
615
616 if (termscript)
c9adab25
KH
617 fprintf (termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n",
618 update_row_len / 2, current_rows);
619
620 while (current_rows--)
621 {
622 dosmemput (saved_row, update_row_len, display_row_start);
623 saved_row += saved_row_len;
624 display_row_start += to_next_row;
625 }
626 if (startup_pos_X < cursor_pos_X)
627 cursor_pos_X = startup_pos_X;
628 if (startup_pos_Y < cursor_pos_Y)
629 cursor_pos_Y = startup_pos_Y;
630
631 ScreenSetCursor (cursor_pos_Y, cursor_pos_X);
632 xfree (startup_screen_buffer);
f32d4091
KS
633
634 term_setup_done = 0;
635}
636
637static
638IT_set_terminal_window (void)
639{
640}
641
642void
643IT_set_frame_parameters (frame, alist)
644 FRAME_PTR frame;
645 Lisp_Object alist;
646{
647 Lisp_Object tail;
648 int redraw;
649 extern unsigned long load_color ();
650 FRAME_PTR f = (FRAME_PTR) &the_only_frame;
651
652 redraw = 0;
653 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
654 {
655 Lisp_Object elt, prop, val;
656
657 elt = Fcar (tail);
658 prop = Fcar (elt);
659 val = Fcdr (elt);
660 CHECK_SYMBOL (prop, 1);
661
662 if (EQ (prop, intern ("foreground-color")))
663 {
664 unsigned long new_color = load_color (f, val);
665 if (new_color != ~0)
666 {
667 FRAME_FOREGROUND_PIXEL (f) = new_color;
668 redraw = 1;
669 }
670 }
671 else if (EQ (prop, intern ("background-color")))
672 {
673 unsigned long new_color = load_color (f, val);
674 if (new_color != ~0)
675 {
676 FRAME_BACKGROUND_PIXEL (f) = new_color & ~8;
677 redraw = 1;
678 }
679 }
680 else if (EQ (prop, intern ("menu-bar-lines")))
681 {
682 int new;
683 int old = FRAME_MENU_BAR_LINES (the_only_frame);
684
685 if (INTEGERP (val))
686 new = XINT (val);
687 else
688 new = 0;
689 FRAME_MENU_BAR_LINES (f) = new;
690 IT_set_menu_bar_lines (the_only_frame.root_window, new - old);
691 }
692 }
693
694 if (redraw)
695 {
696 recompute_basic_faces (f);
697 Fredraw_frame (Fselected_frame ());
698 }
699}
700
701#endif /* !HAVE_X_WINDOWS */
702
703
704/* Do we need the internal terminal? */
705void
706internal_terminal_init ()
707{
708 char *term = getenv ("TERM");
709 char *colors;
710
711#ifdef HAVE_X_WINDOWS
712 if (!inhibit_window_system)
713 return;
714#endif
715
716 internal_terminal
717 = (!noninteractive) && term && !strcmp (term, "internal");
718
719 if (getenv ("EMACSTEST"))
5063b150 720 termscript = fopen (getenv ("EMACSTEST"), "wt");
f32d4091
KS
721
722#ifndef HAVE_X_WINDOWS
723 if (!internal_terminal || inhibit_window_system)
724 {
725 the_only_frame.output_method = output_termcap;
726 return;
727 }
728
729 Vwindow_system = intern ("pc");
730 Vwindow_system_version = make_number (1);
731
732 bzero (&the_only_x_display, sizeof the_only_x_display);
733 the_only_x_display.background_pixel = 7; /* White */
734 the_only_x_display.foreground_pixel = 0; /* Black */
5063b150 735 colors = getenv ("EMACSCOLORS");
f32d4091
KS
736 if (colors && strlen (colors) >= 2)
737 {
738 the_only_x_display.foreground_pixel = colors[0] & 0x07;
739 the_only_x_display.background_pixel = colors[1] & 0x07;
740 }
741 the_only_x_display.line_height = 1;
f6816f88 742 the_only_frame.output_data.x = &the_only_x_display;
f32d4091 743 the_only_frame.output_method = output_msdos_raw;
64ec6a02 744 the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */
f32d4091
KS
745
746 init_frame_faces ((FRAME_PTR) &the_only_frame);
747
748 ring_bell_hook = IT_ring_bell;
749 write_glyphs_hook = IT_write_glyphs;
750 cursor_to_hook = raw_cursor_to_hook = IT_cursor_to;
751 clear_to_end_hook = IT_clear_to_end;
752 clear_end_of_line_hook = IT_clear_end_of_line;
753 clear_frame_hook = IT_clear_screen;
754 change_line_highlight_hook = IT_change_line_highlight;
755 update_begin_hook = IT_update_begin;
756 update_end_hook = IT_update_end;
757 reassert_line_highlight_hook = IT_reassert_line_highlight;
758
759 /* These hooks are called by term.c without being checked. */
760 set_terminal_modes_hook = IT_set_terminal_modes;
761 reset_terminal_modes_hook = IT_reset_terminal_modes;
762 set_terminal_window_hook = IT_set_terminal_window;
763#endif
764}
765
766dos_get_saved_screen (screen, rows, cols)
767 char **screen;
768 int *rows;
769 int *cols;
770{
771#ifndef HAVE_X_WINDOWS
772 *screen = startup_screen_buffer;
773 *cols = startup_screen_size_X;
774 *rows = startup_screen_size_Y;
775 return 1;
776#else
777 return 0;
778#endif
779}
5063b150 780\f
f32d4091
KS
781/* ----------------------- Keyboard control ----------------------
782 *
783 * Keymaps reflect the following keyboard layout:
784 *
785 * 0 1 2 3 4 5 6 7 8 9 10 11 12 BS
786 * TAB 15 16 17 18 19 20 21 22 23 24 25 26 (41)
787 * CLOK 30 31 32 33 34 35 36 37 38 39 40 (41) RET
788 * SH () 45 46 47 48 49 50 51 52 53 54 SHIFT
789 * SPACE
790 */
791
792static int extended_kbd; /* 101 (102) keyboard present. */
793
794struct dos_keyboard_map
795{
796 char *unshifted;
797 char *shifted;
798 char *alt_gr;
799};
800
801
802static struct dos_keyboard_map us_keyboard = {
803/* 0 1 2 3 4 5 */
804/* 01234567890123456789012345678901234567890 12345678901234 */
805 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ",
806/* 0123456789012345678901234567890123456789 012345678901234 */
807 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ",
808 0 /* no Alt-Gr key */
809};
810
811static struct dos_keyboard_map fr_keyboard = {
812/* 0 1 2 3 4 5 */
813/* 012 3456789012345678901234567890123456789012345678901234 */
814