msdos.c 78.9 KB
Newer Older
1
/* MS-DOS specific C utilities.
2
   Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
3 4 5 6 7

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Richard M. Stallman's avatar
Richard M. Stallman committed
8
the Free Software Foundation; either version 2, or (at your option)
Richard M. Stallman's avatar
Richard M. Stallman committed
9 10 11 12 13 14 15 16 17
any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
18 19
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
20

21
/* Contributed by Morten Welinder */
Kim F. Storm's avatar
Kim F. Storm committed
22
/* New display, keyboard, and mouse control by Kim F. Storm */
23

Richard M. Stallman's avatar
Richard M. Stallman committed
24 25
/* Note: some of the stuff here was taken from end of sysdep.c in demacs. */

Richard M. Stallman's avatar
Richard M. Stallman committed
26
#include <config.h>
Richard M. Stallman's avatar
Richard M. Stallman committed
27 28 29 30 31 32 33 34

#ifdef MSDOS
#include "lisp.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/time.h>
#include <dos.h>
35 36
#include <errno.h>
#include <sys/stat.h>    /* for _fixpath */
37 38
#if __DJGPP__ >= 2
#include <fcntl.h>
39 40
#include <dpmi.h>	 /* for __dpmi_xxx stuff */
#include <sys/farptr.h>	 /* for _farsetsel, _farnspokeb */
41
#include <libc/dosio.h>  /* for _USE_LFN */
42 43
#endif

Richard M. Stallman's avatar
Richard M. Stallman committed
44 45 46 47
#include "dosfns.h"
#include "msdos.h"
#include "systime.h"
#include "termhooks.h"
Morten Welinder's avatar
Morten Welinder committed
48 49
#include "dispextern.h"
#include "termopts.h"
Richard M. Stallman's avatar
Richard M. Stallman committed
50
#include "frame.h"
Morten Welinder's avatar
Morten Welinder committed
51
#include "window.h"
52 53
#include "buffer.h"
#include "commands.h"
Richard M. Stallman's avatar
Richard M. Stallman committed
54 55 56 57 58 59 60
#include <go32.h>
#include <pc.h>
#include <ctype.h>
/* #include <process.h> */
/* Damn that local process.h!  Instead we can define P_WAIT ourselves.  */
#define P_WAIT 1

61 62 63 64
#ifndef _USE_LFN
#define _USE_LFN 0
#endif

65 66
#if __DJGPP__ > 1

Richard M. Stallman's avatar
Richard M. Stallman committed
67 68
#include <signal.h>

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#ifndef SYSTEM_MALLOC

#ifdef GNU_MALLOC

/* If other `malloc' than ours is used, force our `sbrk' behave like
   Unix programs expect (resize memory blocks to keep them contiguous).
   If `sbrk' from `ralloc.c' is NOT used, also zero-out sbrk'ed memory,
   because that's what `gmalloc' expects to get.  */
#include <crt0.h>

#ifdef REL_ALLOC
int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK;
#else  /* not REL_ALLOC */
int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY);
#endif /* not REL_ALLOC */
#endif /* GNU_MALLOC */

#endif /* not SYSTEM_MALLOC */
#endif /* __DJGPP__ > 1 */
88 89 90 91 92 93

static unsigned long
event_timestamp ()
{
  struct time t;
  unsigned long s;
Kim F. Storm's avatar
Kim F. Storm committed
94
  
95 96 97 98 99 100
  gettime (&t);
  s = t.ti_min;
  s *= 60;
  s += t.ti_sec;
  s *= 1000;
  s += t.ti_hund * 10;
Kim F. Storm's avatar
Kim F. Storm committed
101
  
102 103 104
  return s;
}

Kim F. Storm's avatar
Kim F. Storm committed
105 106 107 108 109 110

/* ------------------------ Mouse control ---------------------------
 *
 * Coordinates are in screen positions and zero based.
 * Mouse buttons are numbered from left to right and also zero based.
 */
Richard M. Stallman's avatar
Richard M. Stallman committed
111

Kim F. Storm's avatar
Kim F. Storm committed
112 113
int have_mouse;          /* 0: no, 1: enabled, -1: disabled */
static int mouse_visible;
Richard M. Stallman's avatar
Richard M. Stallman committed
114

Kim F. Storm's avatar
Kim F. Storm committed
115 116
static int mouse_last_x;
static int mouse_last_y;
Richard M. Stallman's avatar
Richard M. Stallman committed
117

Kim F. Storm's avatar
Kim F. Storm committed
118 119
static int mouse_button_translate[NUM_MOUSE_BUTTONS];
static int mouse_button_count;
Richard M. Stallman's avatar
Richard M. Stallman committed
120

Kim F. Storm's avatar
Kim F. Storm committed
121 122
void
mouse_on ()
Richard M. Stallman's avatar
Richard M. Stallman committed
123 124 125
{
  union REGS regs;

Kim F. Storm's avatar
Kim F. Storm committed
126
  if (have_mouse > 0 && !mouse_visible)
Richard M. Stallman's avatar
Richard M. Stallman committed
127
    {
Kim F. Storm's avatar
Kim F. Storm committed
128 129 130 131 132
      if (termscript)
	fprintf (termscript, "<M_ON>");
      regs.x.ax = 0x0001;
      int86 (0x33, &regs, &regs);
      mouse_visible = 1;
Richard M. Stallman's avatar
Richard M. Stallman committed
133 134 135
    }
}

Kim F. Storm's avatar
Kim F. Storm committed
136 137
void
mouse_off ()
Richard M. Stallman's avatar
Richard M. Stallman committed
138
{
Kim F. Storm's avatar
Kim F. Storm committed
139
  union REGS regs;
Richard M. Stallman's avatar
Richard M. Stallman committed
140

Kim F. Storm's avatar
Kim F. Storm committed
141
  if (have_mouse > 0 && mouse_visible)
Richard M. Stallman's avatar
Richard M. Stallman committed
142
    {
Kim F. Storm's avatar
Kim F. Storm committed
143 144 145 146 147
      if (termscript)
	fprintf (termscript, "<M_OFF>");
      regs.x.ax = 0x0002;
      int86 (0x33, &regs, &regs);
      mouse_visible = 0;
Richard M. Stallman's avatar
Richard M. Stallman committed
148 149 150
    }
}

Kim F. Storm's avatar
Kim F. Storm committed
151 152 153
void
mouse_moveto (x, y)
     int x, y;
Richard M. Stallman's avatar
Richard M. Stallman committed
154
{
Kim F. Storm's avatar
Kim F. Storm committed
155
  union REGS regs;
Richard M. Stallman's avatar
Richard M. Stallman committed
156

Kim F. Storm's avatar
Kim F. Storm committed
157 158 159 160 161 162
  if (termscript)
    fprintf (termscript, "<M_XY=%dx%d>", x, y);
  regs.x.ax = 0x0004;
  mouse_last_x = regs.x.cx = x * 8;
  mouse_last_y = regs.x.dx = y * 8;
  int86 (0x33, &regs, &regs);
Richard M. Stallman's avatar
Richard M. Stallman committed
163 164
}

Kim F. Storm's avatar
Kim F. Storm committed
165 166 167
static int
mouse_pressed (b, xp, yp)
     int b, *xp, *yp;
Richard M. Stallman's avatar
Richard M. Stallman committed
168
{
Kim F. Storm's avatar
Kim F. Storm committed
169
  union REGS regs;
Richard M. Stallman's avatar
Richard M. Stallman committed
170

Kim F. Storm's avatar
Kim F. Storm committed
171 172 173 174 175 176 177 178
  if (b >= mouse_button_count)
    return 0;
  regs.x.ax = 0x0005;
  regs.x.bx = mouse_button_translate[b];
  int86 (0x33, &regs, &regs);
  if (regs.x.bx)
    *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
  return (regs.x.bx != 0);
Richard M. Stallman's avatar
Richard M. Stallman committed
179 180
}

Kim F. Storm's avatar
Kim F. Storm committed
181 182 183
static int
mouse_released (b, xp, yp)
     int b, *xp, *yp;
Richard M. Stallman's avatar
Richard M. Stallman committed
184 185 186
{
  union REGS regs;

Kim F. Storm's avatar
Kim F. Storm committed
187 188 189 190 191 192 193 194
  if (b >= mouse_button_count)
    return 0;
  regs.x.ax = 0x0006;
  regs.x.bx = mouse_button_translate[b];
  int86 (0x33, &regs, &regs);
  if (regs.x.bx)
    *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
  return (regs.x.bx != 0);
Richard M. Stallman's avatar
Richard M. Stallman committed
195 196
}

Kim F. Storm's avatar
Kim F. Storm committed
197 198
static void
mouse_get_xy (int *x, int *y)
Richard M. Stallman's avatar
Richard M. Stallman committed
199
{
Kim F. Storm's avatar
Kim F. Storm committed
200
  union REGS regs;
Richard M. Stallman's avatar
Richard M. Stallman committed
201

Kim F. Storm's avatar
Kim F. Storm committed
202 203 204 205
  regs.x.ax = 0x0003;
  int86 (0x33, &regs, &regs);
  *x = regs.x.cx / 8;
  *y = regs.x.dx / 8;
Richard M. Stallman's avatar
Richard M. Stallman committed
206 207
}

Kim F. Storm's avatar
Kim F. Storm committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
void
mouse_get_pos (f, insist, bar_window, part, x, y, time)
     FRAME_PTR *f;
     int insist;
     Lisp_Object *bar_window, *x, *y;
     enum scroll_bar_part *part;
     unsigned long *time;
{
  int ix, iy;
  union REGS regs;

  regs.x.ax = 0x0003;
  int86 (0x33, &regs, &regs);
  *f = selected_frame;
  *bar_window = Qnil;
  mouse_get_xy (&ix, &iy);
  selected_frame->mouse_moved = 0;
  *x = make_number (ix);
  *y = make_number (iy);
  *time = event_timestamp ();
}
Richard M. Stallman's avatar
Richard M. Stallman committed
229

Kim F. Storm's avatar
Kim F. Storm committed
230 231
static void
mouse_check_moved ()
Richard M. Stallman's avatar
Richard M. Stallman committed
232
{
233
  int x, y;
Richard M. Stallman's avatar
Richard M. Stallman committed
234

Kim F. Storm's avatar
Kim F. Storm committed
235 236 237 238 239
  mouse_get_xy (&x, &y);
  selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y);
  mouse_last_x = x;
  mouse_last_y = y;
}
Richard M. Stallman's avatar
Richard M. Stallman committed
240

Kim F. Storm's avatar
Kim F. Storm committed
241 242 243 244
void
mouse_init ()
{
  union REGS regs;
245

Kim F. Storm's avatar
Kim F. Storm committed
246 247
  if (termscript)
    fprintf (termscript, "<M_INIT>");
Richard M. Stallman's avatar
Richard M. Stallman committed
248

Kim F. Storm's avatar
Kim F. Storm committed
249 250
  regs.x.ax = 0x0021;
  int86 (0x33, &regs, &regs);
251

Kim F. Storm's avatar
Kim F. Storm committed
252 253 254 255
  regs.x.ax = 0x0007;
  regs.x.cx = 0;
  regs.x.dx = 8 * (ScreenCols () - 1);
  int86 (0x33, &regs, &regs);
Richard M. Stallman's avatar
Richard M. Stallman committed
256

Kim F. Storm's avatar
Kim F. Storm committed
257 258 259 260
  regs.x.ax = 0x0008;
  regs.x.cx = 0;
  regs.x.dx = 8 * (ScreenRows () - 1);
  int86 (0x33, &regs, &regs);
Richard M. Stallman's avatar
Richard M. Stallman committed
261

Kim F. Storm's avatar
Kim F. Storm committed
262 263 264
  mouse_moveto (0, 0);
  mouse_visible = 0;
}
Richard M. Stallman's avatar
Richard M. Stallman committed
265

Kim F. Storm's avatar
Kim F. Storm committed
266 267 268
/* ------------------------- Screen control ----------------------
 *
 */
269

Kim F. Storm's avatar
Kim F. Storm committed
270
static int internal_terminal = 0;
271

Kim F. Storm's avatar
Kim F. Storm committed
272 273 274 275
#ifndef HAVE_X_WINDOWS
extern unsigned char ScreenAttrib;
static int screen_face;
static int highlight;
276

Kim F. Storm's avatar
Kim F. Storm committed
277 278 279
static int screen_size_X;
static int screen_size_Y;
static int screen_size;
Richard M. Stallman's avatar
Richard M. Stallman committed
280

Kim F. Storm's avatar
Kim F. Storm committed
281 282 283 284
static int current_pos_X;
static int current_pos_Y;
static int new_pos_X;
static int new_pos_Y;
Richard M. Stallman's avatar
Richard M. Stallman committed
285

Kim F. Storm's avatar
Kim F. Storm committed
286 287 288 289 290
static void *startup_screen_buffer;
static int startup_screen_size_X;
static int startup_screen_size_Y;
static int startup_pos_X;
static int startup_pos_Y;
291
static unsigned char startup_screen_attrib;
Richard M. Stallman's avatar
Richard M. Stallman committed
292

Kim F. Storm's avatar
Kim F. Storm committed
293
static int term_setup_done;
Richard M. Stallman's avatar
Richard M. Stallman committed
294

Kim F. Storm's avatar
Kim F. Storm committed
295
/* Similar to the_only_frame.  */
296
struct x_output the_only_x_display;
Richard M. Stallman's avatar
Richard M. Stallman committed
297

Kim F. Storm's avatar
Kim F. Storm committed
298 299
/* This is never dereferenced.  */
Display *x_current_display;
Richard M. Stallman's avatar
Richard M. Stallman committed
300

Kim F. Storm's avatar
Kim F. Storm committed
301 302 303 304 305 306
static
dos_direct_output (y, x, buf, len)
     int y;
     int x;
     char *buf;
     int len;
Richard M. Stallman's avatar
Richard M. Stallman committed
307
{
Kim F. Storm's avatar
Kim F. Storm committed
308
  int t = (int) ScreenPrimary + 2 * (x + y * screen_size_X);
309 310

#if (__DJGPP__ < 2)
Kim F. Storm's avatar
Kim F. Storm committed
311 312 313 314
  while (--len >= 0) {
    dosmemput (buf++, 1, t);
    t += 2;
  }
315 316 317 318 319
#else
  /* This is faster.  */
  for (_farsetsel (_dos_ds); --len >= 0; t += 2, buf++)
    _farnspokeb (t, *buf);
#endif
Richard M. Stallman's avatar
Richard M. Stallman committed
320
}
321
#endif
Richard M. Stallman's avatar
Richard M. Stallman committed
322 323 324

/* Flash the screen as a substitute for BEEPs.  */

Kim F. Storm's avatar
Kim F. Storm committed
325
#if (__DJGPP__ < 2)
326
static void
327
do_visible_bell (xorattr)
Richard M. Stallman's avatar
Richard M. Stallman committed
328 329
     unsigned char xorattr;
{
330
  asm volatile
331
    ("  movb   $1,%%dl
Richard M. Stallman's avatar
Richard M. Stallman committed
332
visible_bell_0:
333
	movl   _ScreenPrimary,%%eax
334
	call   dosmemsetup
335 336 337 338
	movl   %%eax,%%ebx
	movl   %1,%%ecx
	movb   %0,%%al
	incl   %%ebx
Richard M. Stallman's avatar
Richard M. Stallman committed
339
visible_bell_1:
340 341 342
	xorb   %%al,%%gs:(%%ebx)
	addl   $2,%%ebx
	decl   %%ecx
343
	jne    visible_bell_1
344
	decb   %%dl
345
	jne    visible_bell_3
Richard M. Stallman's avatar
Richard M. Stallman committed
346
visible_bell_2:
347 348 349 350 351
	movzwl %%ax,%%eax
        movzwl %%ax,%%eax
	movzwl %%ax,%%eax
	movzwl %%ax,%%eax
	decw   %%cx
352 353
	jne    visible_bell_2
	jmp    visible_bell_0
354 355
visible_bell_3:"
     : /* no output */
Kim F. Storm's avatar
Kim F. Storm committed
356
     : "m" (xorattr), "g" (screen_size)
357
     : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx");
Richard M. Stallman's avatar
Richard M. Stallman committed
358 359
}

Kim F. Storm's avatar
Kim F. Storm committed
360 361 362 363 364 365 366 367 368 369 370 371 372
static void
ScreenVisualBell (void)
{
  /* This creates an xor-mask that will swap the default fore- and
     background colors.  */
  do_visible_bell (((the_only_x_display.foreground_pixel
		     ^ the_only_x_display.background_pixel)
		    * 0x11) & 0x7f);
}
#endif

#ifndef HAVE_X_WINDOWS

373 374 375 376 377 378 379 380 381 382 383
/* Enable bright background colors.  */
static void
bright_bg (void)
{
  union REGS regs;

  regs.h.bl = 0;
  regs.x.ax = 0x1003;
  int86 (0x10, &regs, &regs);
}

384 385
/* Set the screen dimensions so that it can show no less than
   ROWS x COLS frame.  */
386

387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
void
dos_set_window_size (rows, cols)
     int *rows, *cols;
{
  char video_name[30];
  Lisp_Object video_mode;
  int video_mode_value;
  int have_vga = 0;
  union REGS regs;
  int current_rows = ScreenRows (), current_cols = ScreenCols ();

  if (*rows == current_rows && *cols == current_cols)
    return;

  /* Do we have a VGA?  */
  regs.x.ax = 0x1a00;
  int86 (0x10, &regs, &regs);
  if (regs.h.al == 0x1a && regs.h.bl > 5 && regs.h.bl < 13)
    have_vga = 1;

  mouse_off ();

409
  /* If the user specified a special video mode for these dimensions,
410 411 412 413 414 415 416 417 418 419
     use that mode.  */
  sprintf (video_name, "screen-dimensions-%dx%d", *rows, *cols);
  video_mode = XSYMBOL (Fintern_soft (build_string (video_name),
				      Qnil))-> value;

  if (INTEGERP (video_mode)
      && (video_mode_value = XINT (video_mode)) > 0)
    {
      regs.x.ax = video_mode_value;
      int86 (0x10, &regs, &regs);
420 421 422 423 424 425 426 427 428

      if (have_mouse)
	{
	  /* Must hardware-reset the mouse, or else it won't update
	     its notion of screen dimensions for some non-standard
	     video modes.  This is *painfully* slow...  */
	  regs.x.ax = 0;
	  int86 (0x33, &regs, &regs);
	}
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
    }

  /* Find one of the dimensions supported by standard EGA/VGA
     which gives us at least the required dimensions.  */

#if __DJGPP__ > 1

  else
    {
      static struct {
	int rows;
	int need_vga;
      }	std_dimension[] = {
	  {25, 0},
	  {28, 1},
	  {35, 0},
	  {40, 1},
	  {43, 0},
	  {50, 1}
      };
      int i = 0;

      while (i < sizeof (std_dimension) / sizeof (std_dimension[0]))
	{
	 if (std_dimension[i].need_vga <= have_vga
	     && std_dimension[i].rows >= *rows)
	   {
	     if (std_dimension[i].rows != current_rows
		 || *cols != current_cols)
458
	       _set_screen_lines (std_dimension[i].rows);
459 460
	     break;
	   }
461
	 i++;
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
	}
    }

#else /* not __DJGPP__ > 1 */

  else if (*rows <= 25)
    {
      if (current_rows != 25 || current_cols != 80)
	{
	  regs.x.ax = 3;
	  int86 (0x10, &regs, &regs);
	  regs.x.ax = 0x1101;
	  regs.h.bl = 0;
	  int86 (0x10, &regs, &regs);
	  regs.x.ax = 0x1200;
	  regs.h.bl = 32;
	  int86 (0x10, &regs, &regs);
	  regs.x.ax = 3;
	  int86 (0x10, &regs, &regs);
	}
    }
  else if (*rows <= 50)
    if (have_vga && (current_rows != 50 || current_cols != 80)
	|| *rows <= 43 && (current_rows != 43 || current_cols != 80))
      {
	regs.x.ax = 3;
	int86 (0x10, &regs, &regs);
	regs.x.ax = 0x1112;
	regs.h.bl = 0;
	int86 (0x10, &regs, &regs);
	regs.x.ax = 0x1200;
	regs.h.bl = 32;
	int86 (0x10, &regs, &regs);
	regs.x.ax = 0x0100;
	regs.x.cx = 7;
	int86 (0x10, &regs, &regs);
      }
#endif /* not __DJGPP__ > 1 */

  if (have_mouse)
    {
      mouse_init ();
      mouse_on ();
    }

  /* Tell the caller what dimensions have been REALLY set.  */
  *rows = ScreenRows ();
  *cols = ScreenCols ();
510 511 512

  /* Enable bright background colors.  */
  bright_bg ();
513 514
}

515 516
/* If we write a character in the position where the mouse is,
   the mouse cursor may need to be refreshed.  */
517 518

static void
Kim F. Storm's avatar
Kim F. Storm committed
519
mouse_off_maybe ()
520
{
Kim F. Storm's avatar
Kim F. Storm committed
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
  int x, y;
  
  if (!mouse_visible)
    return;
  
  mouse_get_xy (&x, &y);
  if (y != new_pos_Y || x < new_pos_X)
    return;
  
  mouse_off ();
}

static
IT_ring_bell ()
{
  if (visible_bell)
537
    {
Kim F. Storm's avatar
Kim F. Storm committed
538 539
      mouse_off ();
      ScreenVisualBell ();
540
    }
Kim F. Storm's avatar
Kim F. Storm committed
541
  else
542 543 544 545 546 547
    {
      union REGS inregs, outregs;
      inregs.h.ah = 2;
      inregs.h.dl = 7;
      intdos (&inregs, &outregs);
    }
548 549
}

Kim F. Storm's avatar
Kim F. Storm committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
static void
IT_set_face (int face)
{
  struct face *fp;
  extern struct face *intern_face (/* FRAME_PTR, struct face * */);

  if (face == 1 || (face == 0 && highlight))
    fp = FRAME_MODE_LINE_FACE (foo);
  else if (face <= 0 || face >= FRAME_N_COMPUTED_FACES (foo))
    fp = FRAME_DEFAULT_FACE (foo);
  else
    fp = intern_face (selected_frame, FRAME_COMPUTED_FACES (foo)[face]);
  if (termscript)
    fprintf (termscript, "<FACE:%d:%d>", FACE_FOREGROUND (fp), FACE_BACKGROUND (fp));
  screen_face = face;
  ScreenAttrib = (FACE_BACKGROUND (fp) << 4) | FACE_FOREGROUND (fp);
}

static
IT_write_glyphs (GLYPH *str, int len)
{
  int newface;
  int ch, l = len;
  unsigned char *buf, *bp;
Morten Welinder's avatar
Morten Welinder committed
574

Kim F. Storm's avatar
Kim F. Storm committed
575
  if (len == 0) return;
576
  
Kim F. Storm's avatar
Kim F. Storm committed
577
  buf = bp = alloca (len * 2);
578
  
Kim F. Storm's avatar
Kim F. Storm committed
579
  while (--l >= 0)
580
    {
Kim F. Storm's avatar
Kim F. Storm committed
581 582 583 584 585 586 587 588 589 590
      newface = FAST_GLYPH_FACE (*str);
      if (newface != screen_face)
	IT_set_face (newface);
      ch = FAST_GLYPH_CHAR (*str);
      *bp++ = (unsigned char)ch;
      *bp++ = ScreenAttrib;
      
      if (termscript)
	fputc (ch, termscript);
      str++;
591 592
    }

Kim F. Storm's avatar
Kim F. Storm committed
593 594 595 596 597
  mouse_off_maybe ();
  dosmemput (buf, 2 * len, 
	     (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y));
  new_pos_X += len;
}
598

Kim F. Storm's avatar
Kim F. Storm committed
599 600 601 602 603 604 605 606 607 608 609
static
IT_clear_end_of_line (first_unused)
{
  char *spaces, *sp;
  int i, j;

  IT_set_face (0);
  if (termscript)
    fprintf (termscript, "<CLR:EOL>");
  i = (j = screen_size_X - new_pos_X) * 2;
  spaces = sp = alloca (i);
610
  
Kim F. Storm's avatar
Kim F. Storm committed
611
  while (--j >= 0)
612
    {
Kim F. Storm's avatar
Kim F. Storm committed
613 614
      *sp++ = ' ';
      *sp++ = ScreenAttrib;
615 616
    }

Kim F. Storm's avatar
Kim F. Storm committed
617 618 619
  mouse_off_maybe ();
  dosmemput (spaces, i, 
	     (int)ScreenPrimary + 2 * (new_pos_X + screen_size_X * new_pos_Y));
620 621
}

Kim F. Storm's avatar
Kim F. Storm committed
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
static
IT_clear_screen (void)
{
  if (termscript)
    fprintf (termscript, "<CLR:SCR>");
  IT_set_face (0);
  mouse_off ();
  ScreenClear ();
  new_pos_X = new_pos_Y = 0;
}

static
IT_clear_to_end (void)
{
  if (termscript)
    fprintf (termscript, "<CLR:EOS>");

  while (new_pos_Y < screen_size_Y) {
    new_pos_X = 0;
    IT_clear_end_of_line (0);
    new_pos_Y++;
  }
}

static
IT_cursor_to (int y, int x)
{
  if (termscript)
    fprintf (termscript, "\n<XY=%dx%d>", x, y);
  new_pos_X = x;
  new_pos_Y = y;
}

655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723
static int cursor_cleared;

static
IT_display_cursor (int on)
{
  if (on && cursor_cleared)
    {
      ScreenSetCursor (current_pos_Y, current_pos_X);
      cursor_cleared = 0;
    }
  else if (!on && !cursor_cleared)
    {
      ScreenSetCursor (-1, -1);
      cursor_cleared = 1;
    }
}

/* Emacs calls cursor-movement functions a lot when it updates the
   display (probably a legacy of old terminals where you cannot
   update a screen line without first moving the cursor there).
   However, cursor movement is expensive on MSDOS (it calls a slow
   BIOS function and requires 2 mode switches), while actual screen
   updates access the video memory directly and don't depend on
   cursor position.  To avoid slowing down the redisplay, we cheat:
   all functions that move the cursor only set internal variables
   which record the cursor position, whereas the cursor is only
   moved to its final position whenever screen update is complete.

   `IT_cmgoto' is called from the keyboard reading loop and when the
   frame update is complete.  This means that we are ready for user
   input, so we update the cursor position to show where the point is,
   and also make the mouse pointer visible.

   Special treatment is required when the cursor is in the echo area,
   to put the cursor at the end of the text displayed there.  */

static
IT_cmgoto (f)
     FRAME_PTR f;
{
  /* Only set the cursor to where it should be if the display is
     already in sync with the window contents.  */
  int update_cursor_pos = MODIFF == unchanged_modified;

  /* If we are in the echo area, put the cursor at the end of text.  */
  if (!update_cursor_pos
      && XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top) <= new_pos_Y)
    {
      new_pos_X = FRAME_DESIRED_GLYPHS (f)->used[new_pos_Y];
      update_cursor_pos = 1;
    }

  if (update_cursor_pos
      && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y))
    {
      ScreenSetCursor (current_pos_Y = new_pos_Y, current_pos_X = new_pos_X);
      if (termscript)
	fprintf (termscript, "\n<CURSOR:%dx%d>", current_pos_X, current_pos_Y);
    }

  /* Maybe cursor is invisible, so make it visible.  */
  IT_display_cursor (1);

  /* Mouse pointer should be always visible if we are waiting for
     keyboard input.  */
  if (!mouse_visible)
    mouse_on ();
}

Kim F. Storm's avatar
Kim F. Storm committed
724 725 726 727 728 729 730 731 732 733
static
IT_reassert_line_highlight (new, vpos)
     int new, vpos;
{
  highlight = new;
  IT_set_face (0); /* To possibly clear the highlighting.  */
}

static
IT_change_line_highlight (new_highlight, vpos, first_unused_hpos)
Richard M. Stallman's avatar
Richard M. Stallman committed
734
{
Kim F. Storm's avatar
Kim F. Storm committed
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
  highlight = new_highlight;
  IT_set_face (0); /* To possibly clear the highlighting.  */
  IT_cursor_to (vpos, 0);
  IT_clear_end_of_line (first_unused_hpos);
}

static
IT_update_begin ()
{
  highlight = 0;
  IT_set_face (0); /* To possibly clear the highlighting.  */
  screen_face = -1;
}

static
IT_update_end ()
{
}
Richard M. Stallman's avatar
Richard M. Stallman committed
753

754 755 756 757
/* This was more or less copied from xterm.c

   Nowadays, the corresponding function under X is `x_set_menu_bar_lines_1'
   on xfns.c  */
758

Kim F. Storm's avatar
Kim F. Storm committed
759 760
static void
IT_set_menu_bar_lines (window, n)
761 762
     Lisp_Object window;
     int n;
Kim F. Storm's avatar
Kim F. Storm committed
763 764 765
{
  struct window *w = XWINDOW (window);

766
  XSETFASTINT (w->last_modified, 0);
767
  XSETFASTINT (w->last_overlay_modified, 0);
Kim F. Storm's avatar
Kim F. Storm committed
768 769 770 771 772 773 774 775 776
  XSETFASTINT (w->top, XFASTINT (w->top) + n);
  XSETFASTINT (w->height, XFASTINT (w->height) - n);

  /* Handle just the top child in a vertical split.  */
  if (!NILP (w->vchild))
    IT_set_menu_bar_lines (w->vchild, n);

  /* Adjust all children in a horizontal split.  */
  for (window = w->hchild; !NILP (window); window = w->next)
Richard M. Stallman's avatar
Richard M. Stallman committed
777
    {
Kim F. Storm's avatar
Kim F. Storm committed
778 779
      w = XWINDOW (window);
      IT_set_menu_bar_lines (window, n);
780
    }
Kim F. Storm's avatar
Kim F. Storm committed
781 782
}

783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808
/* This was copied from xfns.c  */

void
x_set_menu_bar_lines (f, value, oldval)
     struct frame *f;
     Lisp_Object value, oldval;
{
  int nlines;
  int olines = FRAME_MENU_BAR_LINES (f);

  /* Right now, menu bars don't work properly in minibuf-only frames;
     most of the commands try to apply themselves to the minibuffer
     frame itslef, and get an error because you can't switch buffers
     in or split the minibuffer window.  */
  if (FRAME_MINIBUF_ONLY_P (f))
    return;

  if (INTEGERP (value))
    nlines = XINT (value);
  else
    nlines = 0;

  FRAME_MENU_BAR_LINES (f) = nlines;
  IT_set_menu_bar_lines (f->root_window, nlines - olines);
}

809 810
/* IT_set_terminal_modes is called when emacs is started,
   resumed, and whenever the screen is redrawn!  */
Kim F. Storm's avatar
Kim F. Storm committed
811 812 813 814 815 816 817

static
IT_set_terminal_modes (void)
{
  char *colors;
  FRAME_PTR f;
  struct face *fp;
818 819

  if (termscript)
Kim F. Storm's avatar
Kim F. Storm committed
820 821 822 823 824 825
    fprintf (termscript, "\n<SET_TERM>");
  highlight = 0;

  screen_size_X = ScreenCols ();
  screen_size_Y = ScreenRows ();
  screen_size = screen_size_X * screen_size_Y;
826
  
Kim F. Storm's avatar
Kim F. Storm committed
827 828 829 830 831 832
  new_pos_X = new_pos_Y = 0;
  current_pos_X = current_pos_Y = -1;

  if (term_setup_done)
    return;
  term_setup_done = 1;
833
  
Kim F. Storm's avatar
Kim F. Storm committed
834 835
  startup_screen_size_X = screen_size_X;
  startup_screen_size_Y = screen_size_Y;
836
  startup_screen_attrib = ScreenAttrib;
Kim F. Storm's avatar
Kim F. Storm committed
837 838 839 840 841

  ScreenGetCursor (&startup_pos_Y, &startup_pos_X);
  ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2));

  if (termscript)
842 843
    fprintf (termscript, "<SCREEN SAVED (dimensions=%dx%d)>\n",
             screen_size_X, screen_size_Y);
844 845

  bright_bg ();
Kim F. Storm's avatar
Kim F. Storm committed
846 847
}

848 849
/* IT_reset_terminal_modes is called when emacs is
   suspended or killed.  */
Kim F. Storm's avatar
Kim F. Storm committed
850 851 852 853

static
IT_reset_terminal_modes (void)
{
854 855 856 857 858 859 860 861 862
  int display_row_start = (int) ScreenPrimary;
  int saved_row_len     = startup_screen_size_X * 2;
  int update_row_len    = ScreenCols () * 2;
  int current_rows      = ScreenRows ();
  int to_next_row       = update_row_len;
  unsigned char *saved_row = startup_screen_buffer;
  int cursor_pos_X = ScreenCols () - 1;
  int cursor_pos_Y = ScreenRows () - 1;

Kim F. Storm's avatar
Kim F. Storm committed
863
  if (termscript)
Richard M. Stallman's avatar
Richard M. Stallman committed
864
    fprintf (termscript, "\n<RESET_TERM>");
Kim F. Storm's avatar
Kim F. Storm committed
865 866 867 868 869 870

  highlight = 0;

  if (!term_setup_done)
    return;
  
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891
  mouse_off ();
 
  /* We have a situation here.
     We cannot just do ScreenUpdate(startup_screen_buffer) because
     the luser could have changed screen dimensions inside Emacs
     and failed (or didn't want) to restore them before killing
     Emacs.  ScreenUpdate() uses the *current* screen dimensions and
     thus will happily use memory outside what was allocated for
     `startup_screen_buffer'.
     Thus we only restore as much as the current screen dimensions
     can hold, and clear the rest (if the saved screen is smaller than
     the current) with the color attribute saved at startup.  The cursor
     is also restored within the visible dimensions.  */

  ScreenAttrib = startup_screen_attrib;
  ScreenClear ();

  if (update_row_len > saved_row_len)
    update_row_len = saved_row_len;
  if (current_rows > startup_screen_size_Y)
    current_rows = startup_screen_size_Y;
Kim F. Storm's avatar
Kim F. Storm committed
892 893

  if (termscript)
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
    fprintf (termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n",
             update_row_len / 2, current_rows);

  while (current_rows--)
    {
      dosmemput (saved_row, update_row_len, display_row_start);
      saved_row         += saved_row_len;
      display_row_start += to_next_row;
    }
  if (startup_pos_X < cursor_pos_X)
    cursor_pos_X = startup_pos_X;
  if (startup_pos_Y < cursor_pos_Y)
    cursor_pos_Y = startup_pos_Y;

  ScreenSetCursor (cursor_pos_Y, cursor_pos_X);
  xfree (startup_screen_buffer);
Kim F. Storm's avatar
Kim F. Storm committed
910 911 912 913 914 915 916 917 918 919

  term_setup_done = 0;
}

static
IT_set_terminal_window (void)
{
}

void
920 921
IT_set_frame_parameters (f, alist)
     FRAME_PTR f;
Kim F. Storm's avatar
Kim F. Storm committed
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944
     Lisp_Object alist;
{
  Lisp_Object tail;
  int redraw;
  extern unsigned long load_color ();

  redraw = 0;
  for (tail = alist; CONSP (tail); tail = Fcdr (tail))
    {
      Lisp_Object elt, prop, val;

      elt = Fcar (tail);
      prop = Fcar (elt);
      val = Fcdr (elt);
      CHECK_SYMBOL (prop, 1);

      if (EQ (prop, intern ("foreground-color")))
	{
	  unsigned long new_color = load_color (f, val);
	  if (new_color != ~0)
	    {
	      FRAME_FOREGROUND_PIXEL (f) = new_color;
	      redraw = 1;
945 946
	      if (termscript)
		fprintf (termscript, "<FGCOLOR %d>\n", new_color);
Kim F. Storm's avatar
Kim F. Storm committed
947 948 949 950 951 952 953
	    }
	}
      else if (EQ (prop, intern ("background-color")))
	{
	  unsigned long new_color = load_color (f, val);
	  if (new_color != ~0)
	    {
954
	      FRAME_BACKGROUND_PIXEL (f) = new_color;
Kim F. Storm's avatar
Kim F. Storm committed
955
	      redraw = 1;
956 957
	      if (termscript)
		fprintf (termscript, "<BGCOLOR %d>\n", new_color);
Kim F. Storm's avatar
Kim F. Storm committed
958 959 960
	    }
	}
      else if (EQ (prop, intern ("menu-bar-lines")))
961
	x_set_menu_bar_lines (f, val, 0);
Kim F. Storm's avatar
Kim F. Storm committed
962 963 964 965 966
    }

  if (redraw)
    {
      recompute_basic_faces (f);
967 968
      if (f == selected_frame)
	redraw_frame (f);
Kim F. Storm's avatar
Kim F. Storm committed
969 970 971 972 973 974
    }
}

#endif /* !HAVE_X_WINDOWS */


975 976
/* Do we need the internal terminal?  */

Kim F. Storm's avatar
Kim F. Storm committed
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991
void
internal_terminal_init ()
{
  char *term = getenv ("TERM");
  char *colors;

#ifdef HAVE_X_WINDOWS
  if (!inhibit_window_system)
    return;
#endif

  internal_terminal
    = (!noninteractive) && term && !strcmp (term, "internal");

  if (getenv ("EMACSTEST"))
Richard M. Stallman's avatar
Richard M. Stallman committed
992
    termscript = fopen (getenv ("EMACSTEST"), "wt");
Kim F. Storm's avatar
Kim F. Storm committed
993 994 995 996
  
#ifndef HAVE_X_WINDOWS
  if (!internal_terminal || inhibit_window_system)
    {
997
      selected_frame->output_method = output_termcap;
Kim F. Storm's avatar
Kim F. Storm committed
998 999 1000 1001 1002 1003 1004 1005 1006
      return;
    }

  Vwindow_system = intern ("pc");
  Vwindow_system_version = make_number (1);
 
  bzero (&the_only_x_display, sizeof the_only_x_display);
  the_only_x_display.background_pixel = 7; /* White */
  the_only_x_display.foreground_pixel = 0; /* Black */
1007
  bright_bg ();
Richard M. Stallman's avatar
Richard M. Stallman committed
1008
  colors = getenv ("EMACSCOLORS");
Kim F. Storm's avatar
Kim F. Storm committed
1009 1010
  if (colors && strlen (colors) >= 2)
    {
1011 1012 1013 1014 1015
      /* The colors use 4 bits each (we enable bright background).  */
      if (isdigit (colors[0]))
        colors[0] -= '0';
      else if (isxdigit (colors[0]))
        colors[0] -= (isupper (colors[0]) ? 'A' : 'a') - 10;
1016 1017
      if (colors[0] >= 0 && colors[0] < 16)
        the_only_x_display.foreground_pixel = colors[0];
1018 1019 1020 1021 1022
      if (isdigit (colors[1]))
        colors[1] -= '0';
      else if (isxdigit (colors[1]))
        colors[1] -= (isupper (colors[1]) ? 'A' : 'a') - 10;
      if (colors[1] >= 0 && colors[1] < 16)
1023
        the_only_x_display.background_pixel = colors[1];
Kim F. Storm's avatar
Kim F. Storm committed
1024 1025
    }
  the_only_x_display.line_height = 1;
1026
  the_only_x_display.font = (XFontStruct *)1;   /* must *not* be zero */
Kim F. Storm's avatar
Kim F. Storm committed
1027

1028
  init_frame_faces (selected_frame);
Kim F. Storm's avatar
Kim F. Storm committed
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039

  ring_bell_hook = IT_ring_bell;
  write_glyphs_hook = IT_write_glyphs;
  cursor_to_hook = raw_cursor_to_hook = IT_cursor_to;
  clear_to_end_hook = IT_clear_to_end;
  clear_end_of_line_hook = IT_clear_end_of_line;
  clear_frame_hook = IT_clear_screen;
  change_line_highlight_hook = IT_change_line_highlight;
  update_begin_hook = IT_update_begin;
  update_end_hook = IT_update_end;
  reassert_line_highlight_hook = IT_reassert_line_highlight;
1040
  frame_up_to_date_hook = IT_cmgoto; /* position cursor when update is done */
Kim F. Storm's avatar
Kim F. Storm committed
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062

  /* These hooks are called by term.c without being checked.  */
  set_terminal_modes_hook = IT_set_terminal_modes;
  reset_terminal_modes_hook = IT_reset_terminal_modes;
  set_terminal_window_hook = IT_set_terminal_window;
#endif
}

dos_get_saved_screen (screen, rows, cols)
     char **screen;
     int *rows;
     int *cols;
{
#ifndef HAVE_X_WINDOWS
  *screen = startup_screen_buffer;
  *cols = startup_screen_size_X;
  *rows = startup_screen_size_Y;
  return 1;
#else
  return 0;
#endif  
}
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075

#ifndef HAVE_X_WINDOWS

/* We are not X, but we can emulate it well enough for our needs... */
void
check_x (void)
{
  if (! FRAME_MSDOS_P (selected_frame))
    error ("Not running under a windows system");
}

#endif

Richard M. Stallman's avatar
Richard M. Stallman committed
1076

Kim F. Storm's avatar
Kim F. Storm committed
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
/* ----------------------- Keyboard control ----------------------
 *
 * Keymaps reflect the following keyboard layout:
 *
 *    0  1  2  3  4  5  6  7  8  9  10 11 12  BS
 *    TAB 15 16 17 18 19 20 21 22 23 24 25 26 (41)
 *    CLOK 30 31 32 33 34 35 36 37 38 39 40 (41) RET
 *    SH () 45 46 47 48 49 50 51 52 53 54  SHIFT
 *                    SPACE
 */

static int extended_kbd; /* 101 (102) keyboard present.	*/

struct dos_keyboard_map
{
  char *unshifted;
  char *shifted;
  char *alt_gr;
};


static struct dos_keyboard_map us_keyboard = {
/* 0         1         2         3         4         5      */
/* 01234567890123456789012345678901234567890 12345678901234 */
  "`1234567890-=  qwertyuiop[]   asdfghjkl;'\\   zxcvbnm,./  ",
/* 0123456789012345678901234567890123456789 012345678901234 */
  "~!@#$%^&*()_+  QWERTYUIOP{}   ASDFGHJKL:\"|   ZXCVBNM<>?  ",
  0				/* no Alt-Gr key */
};

static struct dos_keyboard_map fr_keyboard = {
/* 0         1         2         3         4         5      */
/* 012 3456789012345678901234567890123456789012345678901234 */
  "&\",(-_)=  azertyuiop^$   qsdfghjklm*   wxcvbnm;:!  ",
/* 0123456789012345678901234567890123456789012345678901234 */
  " 1234567890+  AZERTYUIOP   QSDFGHJKLM%   WXCVBN?./  ",
/* 01234567 89012345678901234567890123456789012345678901234 */
  "  ~#{[|`\\^@]}                                           "
};

static struct dos_keyboard_map dk_keyboard = {
/* 0         1         2         3         4         5      */
/* 0123456789012345678901234567890123456789012345678901234 */
  "1234567890+|  qwertyuiop~   asdfghjkl'   zxcvbnm,.-  ",
/* 01 23456789012345678901234567890123456789012345678901234 */
  "!\"#$%&/()=?`  QWERTYUIOP^   ASDFGHJKL*   ZXCVBNM;:_  ",
/* 0123456789012345678901234567890123456789012345678901234 */
  "  @$  {[]} |                                             "
};

static struct keyboard_layout_list
{
  int country_code;
  struct dos_keyboard_map *keyboard_map;
Richard M. Stallman's avatar
Richard M. Stallman committed
1131 1132 1133 1134 1135
} keyboard_layout_list[] =
{
  1, &us_keyboard,
  33, &fr_keyboard,
  45, &dk_keyboard
Kim F. Storm's avatar
Kim F. Storm committed
1136 1137 1138 1139
};

static struct dos_keyboard_map *keyboard;
static int keyboard_map_all;
1140
static int international_keyboard;
Kim F. Storm's avatar
Kim F. Storm committed
1141 1142 1143 1144 1145 1146 1147

int
dos_set_keyboard (code, always)
     int code;
     int always;
{
  int i;
1148 1149 1150 1151 1152 1153 1154
  union REGS regs;

  /* See if Keyb.Com is installed (for international keyboard support).  */
  regs.x.ax = 0xad80;
  int86 (0x2f, &regs, &regs);
  if (regs.h.al == 0xff)
    international_keyboard = 1;
1155 1156 1157 1158 1159 1160

  /* Initialize to US settings, for countries that don't have their own.  */
  keyboard = keyboard_layout_list[0].keyboard_map;
  keyboard_map_all = always;
  dos_keyboard_layout = 1;
  
Kim F. Storm's avatar
Kim F. Storm committed
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170
  for (i = 0; i < (sizeof (keyboard_layout_list)/sizeof (struct keyboard_layout_list)); i++)
    if (code == keyboard_layout_list[i].country_code)
      {
	keyboard = keyboard_layout_list[i].keyboard_map;
	keyboard_map_all = always;
	dos_keyboard_layout = code;
	return 1;
      }
  return 0;
}
Richard M. Stallman's avatar
Richard M. Stallman committed
1171

Kim F. Storm's avatar
Kim F. Storm committed
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
#define Ignore	0x0000