(HAVE_TERMIO, SIGNALS_VIA_CHARACTERS): Defined.
[bpt/emacs.git] / src / dispnew.c
... / ...
CommitLineData
1/* Updating of data structures for redisplay.
2 Copyright (C) 1985, 1986, 1987, 1988, 1990,
3 1992, 1993 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs; see the file COPYING. If not, write to
19the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22#include <signal.h>
23
24#include "config.h"
25#include <stdio.h>
26#include <ctype.h>
27
28#include "termchar.h"
29#include "termopts.h"
30#include "termhooks.h"
31#include "cm.h"
32#include "lisp.h"
33#include "dispextern.h"
34#include "buffer.h"
35#include "frame.h"
36#include "window.h"
37#include "commands.h"
38#include "disptab.h"
39#include "indent.h"
40
41#include "systty.h"
42#include "systime.h"
43
44#ifdef HAVE_X_WINDOWS
45#include "xterm.h"
46#endif /* HAVE_X_WINDOWS */
47
48#define max(a, b) ((a) > (b) ? (a) : (b))
49#define min(a, b) ((a) < (b) ? (a) : (b))
50
51#ifndef PENDING_OUTPUT_COUNT
52/* Get number of chars of output now in the buffer of a stdio stream.
53 This ought to be built in in stdio, but it isn't.
54 Some s- files override this because their stdio internals differ. */
55#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base)
56#endif
57
58/* Nonzero upon entry to redisplay means do not assume anything about
59 current contents of actual terminal frame; clear and redraw it. */
60
61int frame_garbaged;
62
63/* Nonzero means last display completed. Zero means it was preempted. */
64
65int display_completed;
66
67/* Lisp variable visible-bell; enables use of screen-flash
68 instead of audible bell. */
69
70int visible_bell;
71
72/* Invert the color of the whole frame, at a low level. */
73
74int inverse_video;
75
76/* Line speed of the terminal. */
77
78int baud_rate;
79
80/* nil or a symbol naming the window system under which emacs is
81 running ('x is the only current possibility). */
82
83Lisp_Object Vwindow_system;
84
85/* Version number of X windows: 10, 11 or nil. */
86Lisp_Object Vwindow_system_version;
87
88/* Vector of glyph definitions. Indexed by glyph number,
89 the contents are a string which is how to output the glyph.
90
91 If Vglyph_table is nil, a glyph is output by using its low 8 bits
92 as a character code. */
93
94Lisp_Object Vglyph_table;
95
96/* Display table to use for vectors that don't specify their own. */
97
98Lisp_Object Vstandard_display_table;
99
100/* Nonzero means reading single-character input with prompt
101 so put cursor on minibuffer after the prompt.
102 positive means at end of text in echo area;
103 negative means at beginning of line. */
104int cursor_in_echo_area;
105\f
106/* The currently selected frame.
107 In a single-frame version, this variable always remains 0. */
108
109FRAME_PTR selected_frame;
110
111/* A frame which is not just a minibuffer, or 0 if there are no such
112 frames. This is usually the most recent such frame that was
113 selected. In a single-frame version, this variable always remains 0. */
114FRAME_PTR last_nonminibuf_frame;
115
116/* In a single-frame version, the information that would otherwise
117 exist inside frame objects lives in the following structure instead.
118
119 NOTE: the_only_frame is not checked for garbage collection; don't
120 store collectable objects in any of its fields!
121
122 You're not/The only frame in town/... */
123
124#ifndef MULTI_FRAME
125struct frame the_only_frame;
126#endif
127
128/* This is a vector, made larger whenever it isn't large enough,
129 which is used inside `update_frame' to hold the old contents
130 of the FRAME_PHYS_LINES of the frame being updated. */
131struct frame_glyphs **ophys_lines;
132/* Length of vector currently allocated. */
133int ophys_lines_length;
134
135FILE *termscript; /* Stdio stream being used for copy of all output. */
136
137struct cm Wcm; /* Structure for info on cursor positioning */
138
139extern short ospeed; /* Output speed (from sg_ospeed) */
140
141int delayed_size_change; /* 1 means SIGWINCH happened when not safe. */
142\f
143#ifdef MULTI_FRAME
144
145DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
146 "Clear frame FRAME and output again what is supposed to appear on it.")
147 (frame)
148 Lisp_Object frame;
149{
150 FRAME_PTR f;
151
152 CHECK_LIVE_FRAME (frame, 0);
153 f = XFRAME (frame);
154 update_begin (f);
155 /* set_terminal_modes (); */
156 clear_frame ();
157 clear_frame_records (f);
158 update_end (f);
159 fflush (stdout);
160 windows_or_buffers_changed++;
161 /* Mark all windows as INaccurate,
162 so that every window will have its redisplay done. */
163 mark_window_display_accurate (FRAME_ROOT_WINDOW (f), 0);
164 f->garbaged = 0;
165 return Qnil;
166}
167
168redraw_frame (f)
169 FRAME_PTR f;
170{
171 Lisp_Object frame;
172 XSET (frame, Lisp_Frame, f);
173 Fredraw_frame (frame);
174}
175
176#else
177
178DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, "",
179 "Clear frame FRAME and output again what is supposed to appear on it.")
180 (frame)
181 Lisp_Object frame;
182{
183 update_begin (0);
184 set_terminal_modes ();
185 clear_frame ();
186 update_end (0);
187 fflush (stdout);
188 clear_frame_records (0);
189 windows_or_buffers_changed++;
190 /* Mark all windows as INaccurate,
191 so that every window will have its redisplay done. */
192 mark_window_display_accurate (FRAME_ROOT_WINDOW (0), 0);
193 return Qnil;
194}
195
196#endif
197
198DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
199 "Clear and redisplay all visible frames.")
200 ()
201{
202 Lisp_Object tail, frame;
203
204 FOR_EACH_FRAME (tail, frame)
205 /* If we simply redrew all visible frames, whether or not they
206 were garbaged, then this would make all frames clear and
207 nredraw whenever a new frame is created or an existing frame
208 is de-iconified; those events set the global frame_garbaged
209 flag, to which redisplay responds by calling this function.
210
211 This used to redraw all visible frames; the only advantage of
212 that approach is that if a frame changes from invisible to
213 visible without setting its garbaged flag, it still gets
214 redisplayed. But that should never happen; since invisible
215 frames are not updated, they should always be marked as
216 garbaged when they become visible again. If that doesn't
217 happen, it's a bug in the visibility code, not a bug here. */
218 if (FRAME_VISIBLE_P (XFRAME (frame))
219 && FRAME_GARBAGED_P (XFRAME (frame)))
220 Fredraw_frame (frame);
221
222 return Qnil;
223}
224
225\f
226static struct frame_glyphs *
227make_frame_glyphs (frame, empty)
228 register FRAME_PTR frame;
229 int empty;
230{
231 register int i;
232 register width = FRAME_WIDTH (frame);
233 register height = FRAME_HEIGHT (frame);
234 register struct frame_glyphs *new =
235 (struct frame_glyphs *) xmalloc (sizeof (struct frame_glyphs));
236
237 SET_GLYPHS_FRAME (new, frame);
238 new->height = height;
239 new->width = width;
240 new->used = (int *) xmalloc (height * sizeof (int));
241 new->glyphs = (GLYPH **) xmalloc (height * sizeof (GLYPH *));
242 new->highlight = (char *) xmalloc (height * sizeof (char));
243 new->enable = (char *) xmalloc (height * sizeof (char));
244 bzero (new->enable, height * sizeof (char));
245 new->bufp = (int *) xmalloc (height * sizeof (int));
246
247#ifdef HAVE_X_WINDOWS
248 if (FRAME_X_P (frame))
249 {
250 new->top_left_x = (short *) xmalloc (height * sizeof (short));
251 new->top_left_y = (short *) xmalloc (height * sizeof (short));
252 new->pix_width = (short *) xmalloc (height * sizeof (short));
253 new->pix_height = (short *) xmalloc (height * sizeof (short));
254 new->max_ascent = (short *) xmalloc (height * sizeof (short));
255 }
256#endif
257
258 if (empty)
259 {
260 /* Make the buffer used by decode_mode_spec. This buffer is also
261 used as temporary storage when updating the frame. See scroll.c. */
262 unsigned int total_glyphs = (width + 2) * sizeof (GLYPH);
263
264 new->total_contents = (GLYPH *) xmalloc (total_glyphs);
265 bzero (new->total_contents, total_glyphs);
266 }
267 else
268 {
269 unsigned int total_glyphs = height * (width + 2) * sizeof (GLYPH);
270
271 new->total_contents = (GLYPH *) xmalloc (total_glyphs);
272 bzero (new->total_contents, total_glyphs);
273 for (i = 0; i < height; i++)
274 new->glyphs[i] = new->total_contents + i * (width + 2) + 1;
275 }
276
277 return new;
278}
279
280static void
281free_frame_glyphs (frame, glyphs)
282 FRAME_PTR frame;
283 struct frame_glyphs *glyphs;
284{
285 if (glyphs->total_contents)
286 free (glyphs->total_contents);
287
288 free (glyphs->used);
289 free (glyphs->glyphs);
290 free (glyphs->highlight);
291 free (glyphs->enable);
292 free (glyphs->bufp);
293
294#ifdef HAVE_X_WINDOWS
295 if (FRAME_X_P (frame))
296 {
297 free (glyphs->top_left_x);
298 free (glyphs->top_left_y);
299 free (glyphs->pix_width);
300 free (glyphs->pix_height);
301 free (glyphs->max_ascent);
302 }
303#endif
304
305 free (glyphs);
306}
307
308static void
309remake_frame_glyphs (frame)
310 FRAME_PTR frame;
311{
312 if (FRAME_CURRENT_GLYPHS (frame))
313 free_frame_glyphs (frame, FRAME_CURRENT_GLYPHS (frame));
314 if (FRAME_DESIRED_GLYPHS (frame))
315 free_frame_glyphs (frame, FRAME_DESIRED_GLYPHS (frame));
316 if (FRAME_TEMP_GLYPHS (frame))
317 free_frame_glyphs (frame, FRAME_TEMP_GLYPHS (frame));
318
319 if (FRAME_MESSAGE_BUF (frame))
320 {
321 /* Reallocate the frame's message buffer; remember that
322 echo_area_glyphs may be pointing here. */
323 char *old_message_buf = FRAME_MESSAGE_BUF (frame);
324
325 FRAME_MESSAGE_BUF (frame)
326 = (char *) xrealloc (FRAME_MESSAGE_BUF (frame),
327 FRAME_WIDTH (frame) + 1);
328
329 if (echo_area_glyphs == old_message_buf)
330 echo_area_glyphs = FRAME_MESSAGE_BUF (frame);
331 if (previous_echo_glyphs == old_message_buf)
332 previous_echo_glyphs = FRAME_MESSAGE_BUF (frame);
333 }
334 else
335 FRAME_MESSAGE_BUF (frame)
336 = (char *) xmalloc (FRAME_WIDTH (frame) + 1);
337
338 FRAME_CURRENT_GLYPHS (frame) = make_frame_glyphs (frame, 0);
339 FRAME_DESIRED_GLYPHS (frame) = make_frame_glyphs (frame, 0);
340 FRAME_TEMP_GLYPHS (frame) = make_frame_glyphs (frame, 1);
341 SET_FRAME_GARBAGED (frame);
342}
343\f
344/* Return the hash code of contents of line VPOS in frame-matrix M. */
345
346static int
347line_hash_code (m, vpos)
348 register struct frame_glyphs *m;
349 int vpos;
350{
351 register GLYPH *body, *end;
352 register int h = 0;
353
354 if (!m->enable[vpos])
355 return 0;
356
357 /* Give all highlighted lines the same hash code
358 so as to encourage scrolling to leave them in place. */
359 if (m->highlight[vpos])
360 return -1;
361
362 body = m->glyphs[vpos];
363
364 if (must_write_spaces)
365 while (1)
366 {
367 GLYPH g = *body++;
368
369 if (g == 0)
370 break;
371 h = (((h << 4) + (h >> 24)) & 0x0fffffff) + g - SPACEGLYPH;
372 }
373 else
374 while (1)
375 {
376 GLYPH g = *body++;
377
378 if (g == 0)
379 break;
380 h = (((h << 4) + (h >> 24)) & 0x0fffffff) + g;
381 }
382
383 if (h)
384 return h;
385 return 1;
386}
387
388/* Return number of characters in line in M at vpos VPOS,
389 except don't count leading and trailing spaces
390 unless the terminal requires those to be explicitly output. */
391
392static unsigned int
393line_draw_cost (m, vpos)
394 struct frame_glyphs *m;
395 int vpos;
396{
397 register GLYPH *beg = m->glyphs[vpos];
398 register GLYPH *end = m->glyphs[vpos] + m->used[vpos];
399 register int i;
400 register int tlen = GLYPH_TABLE_LENGTH;
401 register Lisp_Object *tbase = GLYPH_TABLE_BASE;
402
403 /* Ignore trailing and leading spaces if we can. */
404 if (!must_write_spaces)
405 {
406 while ((end != beg) && (*end == SPACEGLYPH))
407 --end;
408 if (end == beg)
409 return (0); /* All blank line. */
410
411 while (*beg == SPACEGLYPH)
412 ++beg;
413 }
414
415 /* If we don't have a glyph-table, each glyph is one character,
416 so return the number of glyphs. */
417 if (tbase == 0)
418 return end - beg;
419
420 /* Otherwise, scan the glyphs and accumulate their total size in I. */
421 i = 0;
422 while ((beg <= end) && *beg)
423 {
424 register GLYPH g = *beg++;
425
426 if (GLYPH_SIMPLE_P (tbase, tlen, g))
427 i += 1;
428 else
429 i += GLYPH_LENGTH (tbase, g);
430 }
431 return i;
432}
433\f
434/* The functions on this page are the interface from xdisp.c to redisplay.
435
436 The only other interface into redisplay is through setting
437 FRAME_CURSOR_X (frame) and FRAME_CURSOR_Y (frame)
438 and SET_FRAME_GARBAGED (frame). */
439
440/* cancel_line eliminates any request to display a line at position `vpos' */
441
442cancel_line (vpos, frame)
443 int vpos;
444 register FRAME_PTR frame;
445{
446 FRAME_DESIRED_GLYPHS (frame)->enable[vpos] = 0;
447}
448
449clear_frame_records (frame)
450 register FRAME_PTR frame;
451{
452 bzero (FRAME_CURRENT_GLYPHS (frame)->enable, FRAME_HEIGHT (frame));
453}
454
455/* Prepare to display on line VPOS starting at HPOS within it. */
456
457void
458get_display_line (frame, vpos, hpos)
459 register FRAME_PTR frame;
460 int vpos;
461 register int hpos;
462{
463 register struct frame_glyphs *glyphs;
464 register struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (frame);
465 register GLYPH *p;
466
467 if (vpos < 0)
468 abort ();
469
470 if ((desired_glyphs->enable[vpos]) && desired_glyphs->used[vpos] > hpos)
471 abort ();
472
473 if (! desired_glyphs->enable[vpos])
474 {
475 desired_glyphs->used[vpos] = 0;
476 desired_glyphs->highlight[vpos] = 0;
477 desired_glyphs->enable[vpos] = 1;
478 }
479
480 if (hpos > desired_glyphs->used[vpos])
481 {
482 GLYPH *g = desired_glyphs->glyphs[vpos] + desired_glyphs->used[vpos];
483 GLYPH *end = desired_glyphs->glyphs[vpos] + hpos;
484
485 desired_glyphs->used[vpos] = hpos;
486 while (g != end)
487 *g++ = SPACEGLYPH;
488 }
489}
490
491/* Like bcopy except never gets confused by overlap. */
492
493void
494safe_bcopy (from, to, size)
495 char *from, *to;
496 int size;
497{
498 if (size <= 0 || from == to)
499 return;
500
501 /* If the source and destination don't overlap, then bcopy can
502 handle it. If they do overlap, but the destination is lower in
503 memory than the source, we'll assume bcopy can handle that. */
504 if (to < from || from + size <= to)
505 bcopy (from, to, size);
506
507 /* Otherwise, we'll copy from the end. */
508 else
509 {
510 register char *endf = from + size;
511 register char *endt = to + size;
512
513 /* If TO - FROM is large, then we should break the copy into
514 nonoverlapping chunks of TO - FROM bytes each. However, if
515 TO - FROM is small, then the bcopy function call overhead
516 makes this not worth it. The crossover point could be about
517 anywhere. Since I don't think the obvious copy loop is too
518 bad, I'm trying to err in its favor. */
519 if (to - from < 64)
520 {
521 do
522 *--endt = *--endf;
523 while (endf != from);
524 }
525 else
526 {
527 for (;;)
528 {
529 endt -= (to - from);
530 endf -= (to - from);
531
532 if (endt < to)
533 break;
534
535 bcopy (endf, endt, to - from);
536 }
537
538 /* If SIZE wasn't a multiple of TO - FROM, there will be a
539 little left over. The amount left over is
540 (endt + (to - from)) - to, which is endt - from. */
541 bcopy (from, to, endt - from);
542 }
543 }
544}
545
546/* Rotate a vector of SIZE bytes right, by DISTANCE bytes.
547 DISTANCE may be negative. */
548
549static void
550rotate_vector (vector, size, distance)
551 char *vector;
552 int size;
553 int distance;
554{
555 char *temp = (char *) alloca (size);
556
557 if (distance < 0)
558 distance += size;
559
560 bcopy (vector, temp + distance, size - distance);
561 bcopy (vector + size - distance, temp, distance);
562 bcopy (temp, vector, size);
563}
564
565/* Scroll lines from vpos FROM up to but not including vpos END
566 down by AMOUNT lines (AMOUNT may be negative).
567 Returns nonzero if done, zero if terminal cannot scroll them. */
568
569int
570scroll_frame_lines (frame, from, end, amount)
571 register FRAME_PTR frame;
572 int from, end, amount;
573{
574 register int i;
575 register struct frame_glyphs *current_frame
576 = FRAME_CURRENT_GLYPHS (frame);
577
578 if (!line_ins_del_ok)
579 return 0;
580
581 if (amount == 0)
582 return 1;
583
584 if (amount > 0)
585 {
586 update_begin (frame);
587 set_terminal_window (end + amount);
588 if (!scroll_region_ok)
589 ins_del_lines (end, -amount);
590 ins_del_lines (from, amount);
591 set_terminal_window (0);
592
593 rotate_vector (current_frame->glyphs + from,
594 sizeof (GLYPH *) * (end + amount - from),
595 amount * sizeof (GLYPH *));
596
597 safe_bcopy (current_frame->used + from,
598 current_frame->used + from + amount,
599 (end - from) * sizeof current_frame->used[0]);
600
601 safe_bcopy (current_frame->highlight + from,
602 current_frame->highlight + from + amount,
603 (end - from) * sizeof current_frame->highlight[0]);
604
605 safe_bcopy (current_frame->enable + from,
606 current_frame->enable + from + amount,
607 (end - from) * sizeof current_frame->enable[0]);
608
609 /* Mark the lines made empty by scrolling as enabled, empty and
610 normal video. */
611 bzero (current_frame->used + from,
612 amount * sizeof current_frame->used[0]);
613 bzero (current_frame->highlight + from,
614 amount * sizeof current_frame->highlight[0]);
615 for (i = from; i < from + amount; i++)
616 {
617 current_frame->glyphs[i][0] = '\0';
618 current_frame->enable[i] = 1;
619 }
620
621 safe_bcopy (current_frame->bufp + from,
622 current_frame->bufp + from + amount,
623 (end - from) * sizeof current_frame->bufp[0]);
624
625#ifdef HAVE_X_WINDOWS
626 if (FRAME_X_P (frame))
627 {
628 safe_bcopy (current_frame->top_left_x + from,
629 current_frame->top_left_x + from + amount,
630 (end - from) * sizeof current_frame->top_left_x[0]);
631
632 safe_bcopy (current_frame->top_left_y + from,
633 current_frame->top_left_y + from + amount,
634 (end - from) * sizeof current_frame->top_left_y[0]);
635
636 safe_bcopy (current_frame->pix_width + from,
637 current_frame->pix_width + from + amount,
638 (end - from) * sizeof current_frame->pix_width[0]);
639
640 safe_bcopy (current_frame->pix_height + from,
641 current_frame->pix_height + from + amount,
642 (end - from) * sizeof current_frame->pix_height[0]);
643
644 safe_bcopy (current_frame->max_ascent + from,
645 current_frame->max_ascent + from + amount,
646 (end - from) * sizeof current_frame->max_ascent[0]);
647 }
648#endif /* HAVE_X_WINDOWS */
649
650 update_end (frame);
651 }
652 if (amount < 0)
653 {
654 update_begin (frame);
655 set_terminal_window (end);
656 ins_del_lines (from + amount, amount);
657 if (!scroll_region_ok)
658 ins_del_lines (end + amount, -amount);
659 set_terminal_window (0);
660
661 rotate_vector (current_frame->glyphs + from + amount,
662 sizeof (GLYPH *) * (end - from - amount),
663 amount * sizeof (GLYPH *));
664
665 safe_bcopy (current_frame->used + from,
666 current_frame->used + from + amount,
667 (end - from) * sizeof current_frame->used[0]);
668
669 safe_bcopy (current_frame->highlight + from,
670 current_frame->highlight + from + amount,
671 (end - from) * sizeof current_frame->highlight[0]);
672
673 safe_bcopy (current_frame->enable + from,
674 current_frame->enable + from + amount,
675 (end - from) * sizeof current_frame->enable[0]);
676
677 /* Mark the lines made empty by scrolling as enabled, empty and
678 normal video. */
679 bzero (current_frame->used + end + amount,
680 - amount * sizeof current_frame->used[0]);
681 bzero (current_frame->highlight + end + amount,
682 - amount * sizeof current_frame->highlight[0]);
683 for (i = end + amount; i < end; i++)
684 {
685 current_frame->glyphs[i][0] = '\0';
686 current_frame->enable[i] = 1;
687 }
688
689 safe_bcopy (current_frame->bufp + from,
690 current_frame->bufp + from + amount,
691 (end - from) * sizeof current_frame->bufp[0]);
692
693#ifdef HAVE_X_WINDOWS
694 if (FRAME_X_P (frame))
695 {
696 safe_bcopy (current_frame->top_left_x + from,
697 current_frame->top_left_x + from + amount,
698 (end - from) * sizeof current_frame->top_left_x[0]);
699
700 safe_bcopy (current_frame->top_left_y + from,
701 current_frame->top_left_y + from + amount,
702 (end - from) * sizeof current_frame->top_left_y[0]);
703
704 safe_bcopy (current_frame->pix_width + from,
705 current_frame->pix_width + from + amount,
706 (end - from) * sizeof current_frame->pix_width[0]);
707
708 safe_bcopy (current_frame->pix_height + from,
709 current_frame->pix_height + from + amount,
710 (end - from) * sizeof current_frame->pix_height[0]);
711
712 safe_bcopy (current_frame->max_ascent + from,
713 current_frame->max_ascent + from + amount,
714 (end - from) * sizeof current_frame->max_ascent[0]);
715 }
716#endif /* HAVE_X_WINDOWS */
717
718 update_end (frame);
719 }
720 return 1;
721}
722\f
723/* After updating a window W that isn't the full frame wide,
724 copy all the columns that W does not occupy
725 into the FRAME_DESIRED_GLYPHS (frame) from the FRAME_PHYS_GLYPHS (frame)
726 so that update_frame will not change those columns. */
727
728preserve_other_columns (w)
729 struct window *w;
730{
731 register int vpos;
732 register struct frame_glyphs *current_frame, *desired_frame;
733 register FRAME_PTR frame = XFRAME (w->frame);
734 int start = XFASTINT (w->left);
735 int end = XFASTINT (w->left) + XFASTINT (w->width);
736 int bot = XFASTINT (w->top) + XFASTINT (w->height);
737
738 current_frame = FRAME_CURRENT_GLYPHS (frame);
739 desired_frame = FRAME_DESIRED_GLYPHS (frame);
740
741 for (vpos = XFASTINT (w->top); vpos < bot; vpos++)
742 {
743 if (current_frame->enable[vpos] && desired_frame->enable[vpos])
744 {
745 if (start > 0)
746 {
747 int len;
748
749 bcopy (current_frame->glyphs[vpos],
750 desired_frame->glyphs[vpos], start);
751 len = min (start, current_frame->used[vpos]);
752 if (desired_frame->used[vpos] < len)
753 desired_frame->used[vpos] = len;
754 }
755 if (current_frame->used[vpos] > end
756 && desired_frame->used[vpos] < current_frame->used[vpos])
757 {
758 while (desired_frame->used[vpos] < end)
759 desired_frame->glyphs[vpos][desired_frame->used[vpos]++]
760 = SPACEGLYPH;
761 bcopy (current_frame->glyphs[vpos] + end,
762 desired_frame->glyphs[vpos] + end,
763 current_frame->used[vpos] - end);
764 desired_frame->used[vpos] = current_frame->used[vpos];
765 }
766 }
767 }
768}
769\f
770#if 0
771
772/* If window w does not need to be updated and isn't the full frame wide,
773 copy all the columns that w does occupy
774 into the FRAME_DESIRED_LINES (frame) from the FRAME_PHYS_LINES (frame)
775 so that update_frame will not change those columns.
776
777 Have not been able to figure out how to use this correctly. */
778
779preserve_my_columns (w)
780 struct window *w;
781{
782 register int vpos, fin;
783 register struct frame_glyphs *l1, *l2;
784 register FRAME_PTR frame = XFRAME (w->frame);
785 int start = XFASTINT (w->left);
786 int end = XFASTINT (w->left) + XFASTINT (w->width);
787 int bot = XFASTINT (w->top) + XFASTINT (w->height);
788
789 for (vpos = XFASTINT (w->top); vpos < bot; vpos++)
790 {
791 if ((l1 = FRAME_DESIRED_GLYPHS (frame)->glyphs[vpos + 1])
792 && (l2 = FRAME_PHYS_GLYPHS (frame)->glyphs[vpos + 1]))
793 {
794 if (l2->length > start && l1->length < l2->length)
795 {
796 fin = l2->length;
797 if (fin > end) fin = end;
798 while (l1->length < start)
799 l1->body[l1->length++] = ' ';
800 bcopy (l2->body + start, l1->body + start, fin - start);
801 l1->length = fin;
802 }
803 }
804 }
805}
806
807#endif
808\f
809/* On discovering that the redisplay for a window was no good,
810 cancel the columns of that window, so that when the window is
811 displayed over again get_display_line will not complain. */
812
813cancel_my_columns (w)
814 struct window *w;
815{
816 register int vpos;
817 register struct frame_glyphs *desired_glyphs =
818 FRAME_DESIRED_GLYPHS (XFRAME (w->frame));
819 register int start = XFASTINT (w->left);
820 register int bot = XFASTINT (w->top) + XFASTINT (w->height);
821
822 for (vpos = XFASTINT (w->top); vpos < bot; vpos++)
823 if (desired_glyphs->enable[vpos]
824 && desired_glyphs->used[vpos] >= start)
825 desired_glyphs->used[vpos] = start;
826}
827\f
828/* These functions try to perform directly and immediately on the frame
829 the necessary output for one change in the buffer.
830 They may return 0 meaning nothing was done if anything is difficult,
831 or 1 meaning the output was performed properly.
832 They assume that the frame was up to date before the buffer
833 change being displayed. They make various other assumptions too;
834 see command_loop_1 where these are called. */
835
836int
837direct_output_for_insert (g)
838 int g;
839{
840 register FRAME_PTR frame = selected_frame;
841 register struct frame_glyphs *current_frame
842 = FRAME_CURRENT_GLYPHS (frame);
843
844#ifndef COMPILER_REGISTER_BUG
845 register
846#endif /* COMPILER_REGISTER_BUG */
847 struct window *w = XWINDOW (selected_window);
848#ifndef COMPILER_REGISTER_BUG
849 register
850#endif /* COMPILER_REGISTER_BUG */
851 int hpos = FRAME_CURSOR_X (frame);
852#ifndef COMPILER_REGISTER_BUG
853 register
854#endif /* COMPILER_REGISTER_BUG */
855 int vpos = FRAME_CURSOR_Y (frame);
856
857 /* Give up if about to continue line. */
858 if (hpos >= XFASTINT (w->left) + window_internal_width (w) - 1
859
860 /* Avoid losing if cursor is in invisible text off left margin */
861 || (XINT (w->hscroll) && hpos == XFASTINT (w->left))
862
863 /* Give up if cursor outside window (in minibuf, probably) */
864 || cursor_in_echo_area
865 || FRAME_CURSOR_Y (frame) < XFASTINT (w->top)
866 || FRAME_CURSOR_Y (frame) >= XFASTINT (w->top) + XFASTINT (w->height)
867
868 /* Give up if cursor not really at FRAME_CURSOR_X, FRAME_CURSOR_Y */
869 || !display_completed
870
871 /* Give up if buffer appears in two places. */
872 || buffer_shared > 1
873
874 /* Give up if w is minibuffer and a message is being displayed there */
875 || (MINI_WINDOW_P (w) && echo_area_glyphs))
876 return 0;
877
878 current_frame->glyphs[vpos][hpos] = g;
879 unchanged_modified = MODIFF;
880 beg_unchanged = GPT - BEG;
881 XFASTINT (w->last_point) = point;
882 XFASTINT (w->last_point_x) = hpos;
883 XFASTINT (w->last_modified) = MODIFF;
884
885 reassert_line_highlight (0, vpos);
886 write_glyphs (&current_frame->glyphs[vpos][hpos], 1);
887 fflush (stdout);
888 ++FRAME_CURSOR_X (frame);
889 if (hpos == current_frame->used[vpos])
890 {
891 current_frame->used[vpos] = hpos + 1;
892 current_frame->glyphs[vpos][hpos + 1] = 0;
893 }
894
895 return 1;
896}
897
898int
899direct_output_forward_char (n)
900 int n;
901{
902 register FRAME_PTR frame = selected_frame;
903 register struct window *w = XWINDOW (selected_window);
904
905 /* Avoid losing if cursor is in invisible text off left margin
906 or about to go off either side of window. */
907 if ((FRAME_CURSOR_X (frame) == XFASTINT (w->left)
908 && (XINT (w->hscroll) || n < 0))
909 || (n > 0
910 && (FRAME_CURSOR_X (frame) + 1 >= window_internal_width (w) - 1))
911 || cursor_in_echo_area)
912 return 0;
913
914 FRAME_CURSOR_X (frame) += n;
915 XFASTINT (w->last_point_x) = FRAME_CURSOR_X (frame);
916 XFASTINT (w->last_point) = point;
917 cursor_to (FRAME_CURSOR_Y (frame), FRAME_CURSOR_X (frame));
918 fflush (stdout);
919 return 1;
920}
921\f
922static void update_line ();
923
924/* Update frame F based on the data in FRAME_DESIRED_GLYPHS.
925 Value is nonzero if redisplay stopped due to pending input.
926 FORCE nonzero means do not stop for pending input. */
927
928int
929update_frame (f, force, inhibit_hairy_id)
930 FRAME_PTR f;
931 int force;
932 int inhibit_hairy_id;
933{
934 register struct frame_glyphs *current_frame = FRAME_CURRENT_GLYPHS (f);
935 register struct frame_glyphs *desired_frame = FRAME_DESIRED_GLYPHS (f);
936 register int i;
937 int pause;
938 int preempt_count = baud_rate / 2400 + 1;
939 extern input_pending;
940#ifdef HAVE_X_WINDOWS
941 register int downto, leftmost;
942#endif
943
944 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */
945
946 detect_input_pending ();
947 if (input_pending && !force)
948 {
949 pause = 1;
950 goto do_pause;
951 }
952
953 update_begin (f);
954
955 if (!line_ins_del_ok)
956 inhibit_hairy_id = 1;
957
958 /* See if any of the desired lines are enabled; don't compute for
959 i/d line if just want cursor motion. */
960 for (i = 0; i < FRAME_HEIGHT (f); i++)
961 if (desired_frame->enable[i])
962 break;
963
964 /* Try doing i/d line, if not yet inhibited. */
965 if (!inhibit_hairy_id && i < FRAME_HEIGHT (f))
966 force |= scrolling (f);
967
968 /* Update the individual lines as needed. Do bottom line first. */
969
970 if (desired_frame->enable[FRAME_HEIGHT (f) - 1])
971 update_line (f, FRAME_HEIGHT (f) - 1);
972
973#ifdef HAVE_X_WINDOWS
974 if (FRAME_X_P (f))
975 {
976 leftmost = downto = f->display.x->internal_border_width;
977 if (desired_frame->enable[0])
978 {
979 current_frame->top_left_x[FRAME_HEIGHT (f) - 1] = leftmost;
980 current_frame->top_left_y[FRAME_HEIGHT (f) - 1]
981 = PIXEL_HEIGHT (f) - f->display.x->internal_border_width
982 - current_frame->pix_height[FRAME_HEIGHT (f) - 1];
983 current_frame->top_left_x[0] = leftmost;
984 current_frame->top_left_y[0] = downto;
985 }
986 }
987#endif /* HAVE_X_WINDOWS */
988
989 /* Now update the rest of the lines. */
990 for (i = 0; i < FRAME_HEIGHT (f) - 1 && (force || !input_pending); i++)
991 {
992 if (desired_frame->enable[i])
993 {
994 if (FRAME_TERMCAP_P (f))
995 {
996 /* Flush out every so many lines.
997 Also flush out if likely to have more than 1k buffered
998 otherwise. I'm told that some telnet connections get
999 really screwed by more than 1k output at once. */
1000 int outq = PENDING_OUTPUT_COUNT (stdout);
1001 if (outq > 900
1002 || (outq > 20 && ((i - 1) % preempt_count == 0)))
1003 {
1004 fflush (stdout);
1005 if (preempt_count == 1)
1006 {
1007#ifdef EMACS_OUTQSIZE
1008 if (EMACS_OUTQSIZE (0, &outq) < 0)
1009 /* Probably not a tty. Ignore the error and reset
1010 * the outq count. */
1011 outq = PENDING_OUTPUT_COUNT (stdout);
1012#endif
1013 outq *= 10;
1014 sleep (outq / baud_rate);
1015 }
1016 }
1017 if ((i - 1) % preempt_count == 0)
1018 detect_input_pending ();
1019 }
1020
1021 update_line (f, i);
1022#ifdef HAVE_X_WINDOWS
1023 if (FRAME_X_P (f))
1024 {
1025 current_frame->top_left_y[i] = downto;
1026 current_frame->top_left_x[i] = leftmost;
1027 }
1028#endif /* HAVE_X_WINDOWS */
1029 }
1030
1031#ifdef HAVE_X_WINDOWS
1032 if (FRAME_X_P (f))
1033 downto += current_frame->pix_height[i];
1034#endif
1035 }
1036 pause = (i < FRAME_HEIGHT (f) - 1) ? i : 0;
1037
1038 /* Now just clean up termcap drivers and set cursor, etc. */
1039 if (!pause)
1040 {
1041 if (cursor_in_echo_area
1042 && FRAME_HAS_MINIBUF_P (f))
1043 {
1044 int top = XINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top);
1045 int row, col;
1046
1047 if (cursor_in_echo_area < 0)
1048 {
1049 row = top;
1050 col = 0;
1051 }
1052 else
1053 {
1054 /* If the minibuffer is several lines high, find the last
1055 line that has any text on it. */
1056 row = FRAME_HEIGHT (f);
1057 do
1058 {
1059 row--;
1060 if (current_frame->enable[row])
1061 col = current_frame->used[row];
1062 else
1063 col = 0;
1064 }
1065 while (row > top && col == 0);
1066
1067 if (col >= FRAME_WIDTH (f))
1068 {
1069 col = 0;
1070 if (row < FRAME_HEIGHT (f) - 1)
1071 row++;
1072 }
1073 }
1074
1075 cursor_to (row, col);
1076 }
1077 else
1078 cursor_to (FRAME_CURSOR_Y (f), max (min (FRAME_CURSOR_X (f),
1079 FRAME_WIDTH (f) - 1), 0));
1080 }
1081
1082 update_end (f);
1083
1084 if (termscript)
1085 fflush (termscript);
1086 fflush (stdout);
1087
1088 /* Here if output is preempted because input is detected. */
1089 do_pause:
1090
1091 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */
1092 display_completed = !pause;
1093
1094 bzero (desired_frame->enable, FRAME_HEIGHT (f));
1095 return pause;
1096}
1097
1098/* Called when about to quit, to check for doing so
1099 at an improper time. */
1100
1101void
1102quit_error_check ()
1103{
1104 if (FRAME_DESIRED_GLYPHS (selected_frame) == 0)
1105 return;
1106 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[0])
1107 abort ();
1108 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[FRAME_HEIGHT (selected_frame) - 1])
1109 abort ();
1110}
1111\f
1112/* Decide what insert/delete line to do, and do it */
1113
1114extern void scrolling_1 ();
1115
1116scrolling (frame)
1117 FRAME_PTR frame;
1118{
1119 int unchanged_at_top, unchanged_at_bottom;
1120 int window_size;
1121 int changed_lines;
1122 int *old_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int));
1123 int *new_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int));
1124 int *draw_cost = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int));
1125 register int i;
1126 int free_at_end_vpos = FRAME_HEIGHT (frame);
1127 register struct frame_glyphs *current_frame = FRAME_CURRENT_GLYPHS (frame);
1128 register struct frame_glyphs *desired_frame = FRAME_DESIRED_GLYPHS (frame);
1129
1130 /* Compute hash codes of all the lines.
1131 Also calculate number of changed lines,
1132 number of unchanged lines at the beginning,
1133 and number of unchanged lines at the end. */
1134
1135 changed_lines = 0;
1136 unchanged_at_top = 0;
1137 unchanged_at_bottom = FRAME_HEIGHT (frame);
1138 for (i = 0; i < FRAME_HEIGHT (frame); i++)
1139 {
1140 /* Give up on this scrolling if some old lines are not enabled. */
1141 if (!current_frame->enable[i])
1142 return 0;
1143 old_hash[i] = line_hash_code (current_frame, i);
1144 if (! desired_frame->enable[i])
1145 new_hash[i] = old_hash[i];
1146 else
1147 new_hash[i] = line_hash_code (desired_frame, i);
1148
1149 if (old_hash[i] != new_hash[i])
1150 {
1151 changed_lines++;
1152 unchanged_at_bottom = FRAME_HEIGHT (frame) - i - 1;
1153 }
1154 else if (i == unchanged_at_top)
1155 unchanged_at_top++;
1156 draw_cost[i] = line_draw_cost (desired_frame, i);
1157 }
1158
1159 /* If changed lines are few, don't allow preemption, don't scroll. */
1160 if (changed_lines < baud_rate / 2400
1161 || unchanged_at_bottom == FRAME_HEIGHT (frame))
1162 return 1;
1163
1164 window_size = (FRAME_HEIGHT (frame) - unchanged_at_top
1165 - unchanged_at_bottom);
1166
1167 if (scroll_region_ok)
1168 free_at_end_vpos -= unchanged_at_bottom;
1169 else if (memory_below_frame)
1170 free_at_end_vpos = -1;
1171
1172 /* If large window, fast terminal and few lines in common between
1173 current frame and desired frame, don't bother with i/d calc. */
1174 if (window_size >= 18 && baud_rate > 2400
1175 && (window_size >=
1176 10 * scrolling_max_lines_saved (unchanged_at_top,
1177 FRAME_HEIGHT (frame) - unchanged_at_bottom,
1178 old_hash, new_hash, draw_cost)))
1179 return 0;
1180
1181 scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom,
1182 draw_cost + unchanged_at_top - 1,
1183 old_hash + unchanged_at_top - 1,
1184 new_hash + unchanged_at_top - 1,
1185 free_at_end_vpos - unchanged_at_top);
1186
1187 return 0;
1188}
1189\f
1190/* Return the offset in its buffer of the character at location col, line
1191 in the given window. */
1192int
1193buffer_posn_from_coords (window, col, line)
1194 struct window *window;
1195 int col, line;
1196{
1197 int window_left = XFASTINT (window->left);
1198
1199 /* The actual width of the window is window->width less one for the
1200 DISP_CONTINUE_GLYPH, and less one if it's not the rightmost
1201 window. */
1202 int window_width = window_internal_width (window) - 1;
1203
1204 int startp = marker_position (window->start);
1205
1206 /* Since compute_motion will only operate on the current buffer,
1207 we need to save the old one and restore it when we're done. */
1208 struct buffer *old_current_buffer = current_buffer;
1209 struct position *posn;
1210
1211 current_buffer = XBUFFER (window->buffer);
1212
1213 /* It would be nice if we could use FRAME_CURRENT_GLYPHS (XFRAME
1214 (window->frame))->bufp to avoid scanning from the very top of
1215 the window, but it isn't maintained correctly, and I'm not even
1216 sure I will keep it. */
1217 posn = compute_motion (startp, 0,
1218 (window == XWINDOW (minibuf_window) && startp == 1
1219 ? minibuf_prompt_width : 0),
1220 ZV, line, col - window_left,
1221 window_width, XINT (window->hscroll), 0);
1222
1223 current_buffer = old_current_buffer;
1224
1225 /* compute_motion considers frame points past the end of a line
1226 to be *after* the newline, i.e. at the start of the next line.
1227 This is reasonable, but not really what we want. So if the
1228 result is on a line below LINE, back it up one character. */
1229 if (posn->vpos > line)
1230 return posn->bufpos - 1;
1231 else
1232 return posn->bufpos;
1233}
1234\f
1235static int
1236count_blanks (r)
1237 register GLYPH *r;
1238{
1239 register GLYPH *p = r;
1240 while (*p++ == SPACEGLYPH);
1241 return p - r - 1;
1242}
1243
1244static int
1245count_match (str1, str2)
1246 GLYPH *str1, *str2;
1247{
1248 register GLYPH *p1 = str1;
1249 register GLYPH *p2 = str2;
1250 while (*p1++ == *p2++);
1251 return p1 - str1 - 1;
1252}
1253
1254/* Char insertion/deletion cost vector, from term.c */
1255extern int *char_ins_del_vector;
1256
1257#define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH((f))])
1258
1259static void
1260update_line (frame, vpos)
1261 register FRAME_PTR frame;
1262 int vpos;
1263{
1264 register GLYPH *obody, *nbody, *op1, *op2, *np1, *temp;
1265 int tem;
1266 int osp, nsp, begmatch, endmatch, olen, nlen;
1267 int save;
1268 register struct frame_glyphs *current_frame
1269 = FRAME_CURRENT_GLYPHS (frame);
1270 register struct frame_glyphs *desired_frame
1271 = FRAME_DESIRED_GLYPHS (frame);
1272
1273 if (desired_frame->highlight[vpos]
1274 != (current_frame->enable[vpos] && current_frame->highlight[vpos]))
1275 {
1276 change_line_highlight (desired_frame->highlight[vpos], vpos,
1277 (current_frame->enable[vpos] ?
1278 current_frame->used[vpos] : 0));
1279 current_frame->enable[vpos] = 0;
1280 }
1281 else
1282 reassert_line_highlight (desired_frame->highlight[vpos], vpos);
1283
1284 if (! current_frame->enable[vpos])
1285 {
1286 olen = 0;
1287 }
1288 else
1289 {
1290 obody = current_frame->glyphs[vpos];
1291 olen = current_frame->used[vpos];
1292 if (! current_frame->highlight[vpos])
1293 {
1294 if (!must_write_spaces)
1295 while (obody[olen - 1] == SPACEGLYPH && olen > 0)
1296 olen--;
1297 }
1298 else
1299 {
1300 /* For an inverse-video line, remember we gave it
1301 spaces all the way to the frame edge
1302 so that the reverse video extends all the way across. */
1303
1304 while (olen < FRAME_WIDTH (frame) - 1)
1305 obody[olen++] = SPACEGLYPH;
1306 }
1307 }
1308
1309 /* One way or another, this will enable the line being updated. */
1310 current_frame->enable[vpos] = 1;
1311 current_frame->used[vpos] = desired_frame->used[vpos];
1312 current_frame->highlight[vpos] = desired_frame->highlight[vpos];
1313 current_frame->bufp[vpos] = desired_frame->bufp[vpos];
1314
1315#ifdef HAVE_X_WINDOWS
1316 if (FRAME_X_P (frame))
1317 {
1318 current_frame->pix_width[vpos]
1319 = current_frame->used[vpos]
1320 * FONT_WIDTH (frame->display.x->font);
1321 current_frame->pix_height[vpos]
1322 = FONT_HEIGHT (frame->display.x->font);
1323 }
1324#endif /* HAVE_X_WINDOWS */
1325
1326 if (!desired_frame->enable[vpos])
1327 {
1328 nlen = 0;
1329 goto just_erase;
1330 }
1331
1332 nbody = desired_frame->glyphs[vpos];
1333 nlen = desired_frame->used[vpos];
1334
1335 /* Pretend trailing spaces are not there at all,
1336 unless for one reason or another we must write all spaces. */
1337 if (! desired_frame->highlight[vpos])
1338 {
1339 if (!must_write_spaces)
1340 /* We know that the previous character byte contains 0. */
1341 while (nbody[nlen - 1] == SPACEGLYPH)
1342 nlen--;
1343 }
1344 else
1345 {
1346 /* For an inverse-video line, give it extra trailing spaces
1347 all the way to the frame edge
1348 so that the reverse video extends all the way across. */
1349
1350 while (nlen < FRAME_WIDTH (frame) - 1)
1351 nbody[nlen++] = SPACEGLYPH;
1352 }
1353
1354 /* If there's no i/d char, quickly do the best we can without it. */
1355 if (!char_ins_del_ok)
1356 {
1357 int i,j;
1358
1359 for (i = 0; i < nlen; i++)
1360 {
1361 if (i >= olen || nbody[i] != obody[i]) /* A non-matching char. */
1362 {
1363 cursor_to (vpos, i);
1364 for (j = 1; (i + j < nlen &&
1365 (i + j >= olen || nbody[i+j] != obody[i+j]));
1366 j++);
1367
1368 /* Output this run of non-matching chars. */
1369 write_glyphs (nbody + i, j);
1370 i += j - 1;
1371
1372 /* Now find the next non-match. */
1373 }
1374 }
1375
1376 /* Clear the rest of the line, or the non-clear part of it. */
1377 if (olen > nlen)
1378 {
1379 cursor_to (vpos, nlen);
1380 clear_end_of_line (olen);
1381 }
1382
1383 /* Exchange contents between current_frame and new_frame. */
1384 temp = desired_frame->glyphs[vpos];
1385 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos];
1386 current_frame->glyphs[vpos] = temp;
1387
1388 return;
1389 }
1390
1391 if (!olen)
1392 {
1393 nsp = (must_write_spaces || desired_frame->highlight[vpos])
1394 ? 0 : count_blanks (nbody);
1395 if (nlen > nsp)
1396 {
1397 cursor_to (vpos, nsp);
1398 write_glyphs (nbody + nsp, nlen - nsp);
1399 }
1400
1401 /* Exchange contents between current_frame and new_frame. */
1402 temp = desired_frame->glyphs[vpos];
1403 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos];
1404 current_frame->glyphs[vpos] = temp;
1405
1406 return;
1407 }
1408
1409 obody[olen] = 1;
1410 save = nbody[nlen];
1411 nbody[nlen] = 0;
1412
1413 /* Compute number of leading blanks in old and new contents. */
1414 osp = count_blanks (obody);
1415 if (!desired_frame->highlight[vpos])
1416 nsp = count_blanks (nbody);
1417 else
1418 nsp = 0;
1419
1420 /* Compute number of matching chars starting with first nonblank. */
1421 begmatch = count_match (obody + osp, nbody + nsp);
1422
1423 /* Spaces in new match implicit space past the end of old. */
1424 /* A bug causing this to be a no-op was fixed in 18.29. */
1425 if (!must_write_spaces && osp + begmatch == olen)
1426 {
1427 np1 = nbody + nsp;
1428 while (np1[begmatch] == SPACEGLYPH)
1429 begmatch++;
1430 }
1431
1432 /* Avoid doing insert/delete char
1433 just cause number of leading spaces differs
1434 when the following text does not match. */
1435 if (begmatch == 0 && osp != nsp)
1436 osp = nsp = min (osp, nsp);
1437
1438 /* Find matching characters at end of line */
1439 op1 = obody + olen;
1440 np1 = nbody + nlen;
1441 op2 = op1 + begmatch - min (olen - osp, nlen - nsp);
1442 while (op1 > op2 && op1[-1] == np1[-1])
1443 {
1444 op1--;
1445 np1--;
1446 }
1447 endmatch = obody + olen - op1;
1448
1449 /* Put correct value back in nbody[nlen].
1450 This is important because direct_output_for_insert
1451 can write into the line at a later point.
1452 If this screws up the zero at the end of the line, re-establish it. */
1453 nbody[nlen] = save;
1454 obody[olen] = 0;
1455
1456 /* tem gets the distance to insert or delete.
1457 endmatch is how many characters we save by doing so.
1458 Is it worth it? */
1459
1460 tem = (nlen - nsp) - (olen - osp);
1461 if (endmatch && tem
1462 && (!char_ins_del_ok || endmatch <= char_ins_del_cost (frame)[tem]))
1463 endmatch = 0;
1464
1465 /* nsp - osp is the distance to insert or delete.
1466 If that is nonzero, begmatch is known to be nonzero also.
1467 begmatch + endmatch is how much we save by doing the ins/del.
1468 Is it worth it? */
1469
1470 if (nsp != osp
1471 && (!char_ins_del_ok
1472 || begmatch + endmatch <= char_ins_del_cost (frame)[nsp - osp]))
1473 {
1474 begmatch = 0;
1475 endmatch = 0;
1476 osp = nsp = min (osp, nsp);
1477 }
1478
1479 /* Now go through the line, inserting, writing and
1480 deleting as appropriate. */
1481
1482 if (osp > nsp)
1483 {
1484 cursor_to (vpos, nsp);
1485 delete_glyphs (osp - nsp);
1486 }
1487 else if (nsp > osp)
1488 {
1489 /* If going to delete chars later in line
1490 and insert earlier in the line,
1491 must delete first to avoid losing data in the insert */
1492 if (endmatch && nlen < olen + nsp - osp)
1493 {
1494 cursor_to (vpos, nlen - endmatch + osp - nsp);
1495 delete_glyphs (olen + nsp - osp - nlen);
1496 olen = nlen - (nsp - osp);
1497 }
1498 cursor_to (vpos, osp);
1499 insert_glyphs ((char *)0, nsp - osp);
1500 }
1501 olen += nsp - osp;
1502
1503 tem = nsp + begmatch + endmatch;
1504 if (nlen != tem || olen != tem)
1505 {
1506 cursor_to (vpos, nsp + begmatch);
1507 if (!endmatch || nlen == olen)
1508 {
1509 /* If new text being written reaches right margin,
1510 there is no need to do clear-to-eol at the end.
1511 (and it would not be safe, since cursor is not
1512 going to be "at the margin" after the text is done) */
1513 if (nlen == FRAME_WIDTH (frame))
1514 olen = 0;
1515 write_glyphs (nbody + nsp + begmatch, nlen - tem);
1516
1517#ifdef obsolete
1518
1519/* the following code loses disastrously if tem == nlen.
1520 Rather than trying to fix that case, I am trying the simpler
1521 solution found above. */
1522
1523 /* If the text reaches to the right margin,
1524 it will lose one way or another (depending on AutoWrap)
1525 to clear to end of line after outputting all the text.
1526 So pause with one character to go and clear the line then. */
1527 if (nlen == FRAME_WIDTH (frame) && fast_clear_end_of_line && olen > nlen)
1528 {
1529 /* endmatch must be zero, and tem must equal nsp + begmatch */
1530 write_glyphs (nbody + tem, nlen - tem - 1);
1531 clear_end_of_line (olen);
1532 olen = 0; /* Don't let it be cleared again later */
1533 write_glyphs (nbody + nlen - 1, 1);
1534 }
1535 else
1536 write_glyphs (nbody + nsp + begmatch, nlen - tem);
1537#endif /* OBSOLETE */
1538
1539 }
1540 else if (nlen > olen)
1541 {
1542 write_glyphs (nbody + nsp + begmatch, olen - tem);
1543 insert_glyphs (nbody + nsp + begmatch + olen - tem, nlen - olen);
1544 olen = nlen;
1545 }
1546 else if (olen > nlen)
1547 {
1548 write_glyphs (nbody + nsp + begmatch, nlen - tem);
1549 delete_glyphs (olen - nlen);
1550 olen = nlen;
1551 }
1552 }
1553
1554 just_erase:
1555 /* If any unerased characters remain after the new line, erase them. */
1556 if (olen > nlen)
1557 {
1558 cursor_to (vpos, nlen);
1559 clear_end_of_line (olen);
1560 }
1561
1562 /* Exchange contents between current_frame and new_frame. */
1563 temp = desired_frame->glyphs[vpos];
1564 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos];
1565 current_frame->glyphs[vpos] = temp;
1566}
1567\f
1568DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript,
1569 1, 1, "FOpen termscript file: ",
1570 "Start writing all terminal output to FILE as well as the terminal.\n\
1571FILE = nil means just close any termscript file currently open.")
1572 (file)
1573 Lisp_Object file;
1574{
1575 if (termscript != 0) fclose (termscript);
1576 termscript = 0;
1577
1578 if (! NILP (file))
1579 {
1580 file = Fexpand_file_name (file, Qnil);
1581 termscript = fopen (XSTRING (file)->data, "w");
1582 if (termscript == 0)
1583 report_file_error ("Opening termscript", Fcons (file, Qnil));
1584 }
1585 return Qnil;
1586}
1587\f
1588
1589#ifdef SIGWINCH
1590SIGTYPE
1591window_change_signal ()
1592{
1593 int width, height;
1594 extern int errno;
1595 int old_errno = errno;
1596
1597 get_frame_size (&width, &height);
1598
1599 /* The frame size change obviously applies to a termcap-controlled
1600 frame. Find such a frame in the list, and assume it's the only
1601 one (since the redisplay code always writes to stdout, not a
1602 FILE * specified in the frame structure). Record the new size,
1603 but don't reallocate the data structures now. Let that be done
1604 later outside of the signal handler. */
1605
1606 {
1607 Lisp_Object tail, frame;
1608
1609 FOR_EACH_FRAME (tail, frame)
1610 {
1611 if (FRAME_TERMCAP_P (XFRAME (frame)))
1612 {
1613 change_frame_size (XFRAME (frame), height, width, 0, 1);
1614 break;
1615 }
1616 }
1617 }
1618
1619 signal (SIGWINCH, window_change_signal);
1620 errno = old_errno;
1621}
1622#endif /* SIGWINCH */
1623
1624
1625/* Do any change in frame size that was requested by a signal. */
1626
1627do_pending_window_change ()
1628{
1629 /* If window_change_signal should have run before, run it now. */
1630 while (delayed_size_change)
1631 {
1632 Lisp_Object tail, frame;
1633
1634 delayed_size_change = 0;
1635
1636 FOR_EACH_FRAME (tail, frame)
1637 {
1638 FRAME_PTR f = XFRAME (frame);
1639
1640 int height = FRAME_NEW_HEIGHT (f);
1641 int width = FRAME_NEW_WIDTH (f);
1642
1643 FRAME_NEW_HEIGHT (f) = 0;
1644 FRAME_NEW_WIDTH (f) = 0;
1645
1646 if (height != 0)
1647 change_frame_size (f, height, width, 0, 0);
1648 }
1649 }
1650}
1651
1652
1653/* Change the frame height and/or width. Values may be given as zero to
1654 indicate no change is to take place.
1655
1656 If DELAY is non-zero, then assume we're being called from a signal
1657 handler, and queue the change for later - perhaps the next
1658 redisplay. Since this tries to resize windows, we can't call it
1659 from a signal handler. */
1660
1661change_frame_size (frame, newheight, newwidth, pretend, delay)
1662 register FRAME_PTR frame;
1663 int newheight, newwidth, pretend;
1664{
1665 /* If we can't deal with the change now, queue it for later. */
1666 if (delay)
1667 {
1668 FRAME_NEW_HEIGHT (frame) = newheight;
1669 FRAME_NEW_WIDTH (frame) = newwidth;
1670 delayed_size_change = 1;
1671 return;
1672 }
1673
1674 /* This size-change overrides any pending one for this frame. */
1675 FRAME_NEW_HEIGHT (frame) = 0;
1676 FRAME_NEW_WIDTH (frame) = 0;
1677
1678 /* If an arguments is zero, set it to the current value. */
1679 newheight || (newheight = FRAME_HEIGHT (frame));
1680 newwidth || (newwidth = FRAME_WIDTH (frame));
1681
1682 /* Round up to the smallest acceptable size. */
1683 check_frame_size (frame, &newheight, &newwidth);
1684
1685 /* If we're not changing the frame size, quit now. */
1686 if (newheight == FRAME_HEIGHT (frame)
1687 && newwidth == FRAME_WIDTH (frame))
1688 return;
1689
1690 if (newheight != FRAME_HEIGHT (frame))
1691 {
1692 if (FRAME_HAS_MINIBUF_P (frame)
1693 && ! FRAME_MINIBUF_ONLY_P (frame))
1694 {
1695 /* Frame has both root and minibuffer. */
1696 set_window_height (FRAME_ROOT_WINDOW (frame),
1697 newheight - 1 - FRAME_MENU_BAR_LINES (frame), 0);
1698 XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (frame))->top)
1699 = newheight - 1;
1700 set_window_height (FRAME_MINIBUF_WINDOW (frame), 1, 0);
1701 }
1702 else
1703 /* Frame has just one top-level window. */
1704 set_window_height (FRAME_ROOT_WINDOW (frame),
1705 newheight - FRAME_MENU_BAR_LINES (frame), 0);
1706
1707 if (FRAME_TERMCAP_P (frame) && !pretend)
1708 FrameRows = newheight;
1709
1710#if 0
1711 if (frame->output_method == output_termcap)
1712 {
1713 frame_height = newheight;
1714 if (!pretend)
1715 FrameRows = newheight;
1716 }
1717#endif
1718 }
1719
1720 if (newwidth != FRAME_WIDTH (frame))
1721 {
1722 set_window_width (FRAME_ROOT_WINDOW (frame), newwidth, 0);
1723 if (FRAME_HAS_MINIBUF_P (frame))
1724 set_window_width (FRAME_MINIBUF_WINDOW (frame), newwidth, 0);
1725
1726 if (FRAME_TERMCAP_P (frame) && !pretend)
1727 FrameCols = newwidth;
1728#if 0
1729 if (frame->output_method == output_termcap)
1730 {
1731 frame_width = newwidth;
1732 if (!pretend)
1733 FrameCols = newwidth;
1734 }
1735#endif
1736 }
1737
1738 FRAME_HEIGHT (frame) = newheight;
1739 FRAME_WIDTH (frame) = newwidth;
1740
1741 remake_frame_glyphs (frame);
1742 calculate_costs (frame);
1743}
1744\f
1745DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
1746 Ssend_string_to_terminal, 1, 1, 0,
1747 "Send STRING to the terminal without alteration.\n\
1748Control characters in STRING will have terminal-dependent effects.")
1749 (str)
1750 Lisp_Object str;
1751{
1752 CHECK_STRING (str, 0);
1753 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, stdout);
1754 fflush (stdout);
1755 if (termscript)
1756 {
1757 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, termscript);
1758 fflush (termscript);
1759 }
1760 return Qnil;
1761}
1762
1763DEFUN ("ding", Fding, Sding, 0, 1, 0,
1764 "Beep, or flash the screen.\n\
1765Also, unless an argument is given,\n\
1766terminate any keyboard macro currently executing.")
1767 (arg)
1768 Lisp_Object arg;
1769{
1770 if (!NILP (arg))
1771 {
1772 if (noninteractive)
1773 putchar (07);
1774 else
1775 ring_bell ();
1776 fflush (stdout);
1777 }
1778 else
1779 bitch_at_user ();
1780
1781 return Qnil;
1782}
1783
1784bitch_at_user ()
1785{
1786 if (noninteractive)
1787 putchar (07);
1788 else if (!INTERACTIVE) /* Stop executing a keyboard macro. */
1789 error ("Keyboard macro terminated by a command ringing the bell");
1790 else
1791 ring_bell ();
1792 fflush (stdout);
1793}
1794
1795DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0,
1796 "Pause, without updating display, for SECONDS seconds.\n\
1797Optional second arg MILLISECONDS specifies an additional wait period,\n\
1798in milliseconds.\n\
1799\(Not all operating systems support milliseconds.)")
1800 (seconds, milliseconds)
1801 Lisp_Object seconds, milliseconds;
1802{
1803 int sec, usec;
1804
1805 CHECK_NUMBER (seconds, 0);
1806 sec = XINT (seconds);
1807
1808 if (NILP (milliseconds))
1809 XSET (milliseconds, Lisp_Int, 0);
1810 else
1811 CHECK_NUMBER (milliseconds, 1);
1812 usec = XINT (milliseconds);
1813
1814#ifndef EMACS_HAS_USECS
1815 if (sec == 0 && usec != 0)
1816 error ("millisecond `sleep-for' not supported on %s", SYSTEM_TYPE);
1817#endif
1818
1819 /* Assure that 0 <= usec < 1000000. */
1820 if (usec < 0)
1821 {
1822 /* We can't rely on the rounding being correct if user is negative. */
1823 if (-1000000 < usec)
1824 sec--, usec += 1000000;
1825 else
1826 sec -= -usec / 1000000, usec = 1000000 - (-usec % 1000000);
1827 }
1828 else
1829 sec += usec / 1000000, usec %= 1000000;
1830
1831 if (sec <= 0)
1832 return Qnil;
1833
1834 {
1835 Lisp_Object zero;
1836
1837 XFASTINT (zero) = 0;
1838 wait_reading_process_input (sec, usec, zero, 0);
1839 }
1840
1841 /* We should always have wait_reading_process_input; we have a dummy
1842 implementation for systems which don't support subprocesses. */
1843#if 0
1844 /* No wait_reading_process_input */
1845 immediate_quit = 1;
1846 QUIT;
1847
1848#ifdef VMS
1849 sys_sleep (sec);
1850#else /* not VMS */
1851/* The reason this is done this way
1852 (rather than defined (H_S) && defined (H_T))
1853 is because the VMS preprocessor doesn't grok `defined' */
1854#ifdef HAVE_SELECT
1855 EMACS_GET_TIME (end_time);
1856 EMACS_SET_SECS_USECS (timeout, sec, usec);
1857 EMACS_ADD_TIME (end_time, end_time, timeout);
1858
1859 while (1)
1860 {
1861 EMACS_GET_TIME (timeout);
1862 EMACS_SUB_TIME (timeout, end_time, timeout);
1863 if (EMACS_TIME_NEG_P (timeout)
1864 || !select (1, 0, 0, 0, &timeout))
1865 break;
1866 }
1867#else /* not HAVE_SELECT */
1868 sleep (sec);
1869#endif /* HAVE_SELECT */
1870#endif /* not VMS */
1871
1872 immediate_quit = 0;
1873#endif /* no subprocesses */
1874
1875 return Qnil;
1876}
1877
1878/* This is just like wait_reading_process_input, except that
1879 it does the redisplay.
1880
1881 It's also just like Fsit_for, except that it can be used for
1882 waiting for input as well. */
1883
1884Lisp_Object
1885sit_for (sec, usec, reading, display)
1886 int sec, usec, reading, display;
1887{
1888 Lisp_Object read_kbd;
1889
1890 if (detect_input_pending ())
1891 return Qnil;
1892
1893 if (display)
1894 redisplay_preserve_echo_area ();
1895
1896 if (sec == 0 && usec == 0)
1897 return Qt;
1898
1899#ifdef SIGIO
1900 gobble_input (0);
1901#endif
1902
1903 XSET (read_kbd, Lisp_Int, reading ? -1 : 1);
1904 wait_reading_process_input (sec, usec, read_kbd, display);
1905
1906
1907 /* wait_reading_process_input should always be available now; it is
1908 simulated in a simple way on systems that don't support
1909 subprocesses. */
1910#if 0
1911 /* No wait_reading_process_input available. */
1912 immediate_quit = 1;
1913 QUIT;
1914
1915 waitchannels = 1;
1916#ifdef VMS
1917 input_wait_timeout (XINT (arg));
1918#else /* not VMS */
1919#ifndef HAVE_TIMEVAL
1920 timeout_sec = sec;
1921 select (1, &waitchannels, 0, 0, &timeout_sec);
1922#else /* HAVE_TIMEVAL */
1923 timeout.tv_sec = sec;
1924 timeout.tv_usec = usec;
1925 select (1, &waitchannels, 0, 0, &timeout);
1926#endif /* HAVE_TIMEVAL */
1927#endif /* not VMS */
1928
1929 immediate_quit = 0;
1930#endif
1931
1932 return detect_input_pending () ? Qnil : Qt;
1933}
1934
1935DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0,
1936 "Perform redisplay, then wait for SECONDS seconds or until input is available.\n\
1937Optional second arg MILLISECONDS specifies an additional wait period, in\n\
1938milliseconds.\n\
1939\(Not all operating systems support milliseconds.)\n\
1940Optional third arg non-nil means don't redisplay, just wait for input.\n\
1941Redisplay is preempted as always if input arrives, and does not happen\n\
1942if input is available before it starts.\n\
1943Value is t if waited the full time with no input arriving.")
1944 (seconds, milliseconds, nodisp)
1945 Lisp_Object seconds, milliseconds, nodisp;
1946{
1947 int sec, usec;
1948
1949 CHECK_NUMBER (seconds, 0);
1950 sec = XINT (seconds);
1951
1952 if (NILP (milliseconds))
1953 XSET (milliseconds, Lisp_Int, 0);
1954 else
1955 CHECK_NUMBER (milliseconds, 1);
1956 usec = XINT (milliseconds);
1957
1958#ifndef EMACS_HAS_USECS
1959 if (usec != 0 && sec == 0)
1960 error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE);
1961#endif
1962
1963 return sit_for (sec, usec, 0, NILP (nodisp));
1964}
1965\f
1966char *terminal_type;
1967
1968/* Initialization done when Emacs fork is started, before doing stty. */
1969/* Determine terminal type and set terminal_driver */
1970/* Then invoke its decoding routine to set up variables
1971 in the terminal package */
1972
1973init_display ()
1974{
1975#ifdef HAVE_X_WINDOWS
1976 extern int display_arg;
1977#endif
1978
1979 meta_key = 0;
1980 inverse_video = 0;
1981 cursor_in_echo_area = 0;
1982 terminal_type = (char *) 0;
1983
1984 /* If the DISPLAY environment variable is set, try to use X, and
1985 die with an error message if that doesn't work. */
1986
1987 /* Check if we're using a window system here before trying to
1988 initialize the terminal. If we check the terminal first,
1989
1990 If someone has indicated that they want
1991 to use a window system, we shouldn't bother initializing the
1992 terminal. This is especially important when the terminal is so
1993 dumb that emacs gives up before and doesn't bother using the window
1994 system. */
1995
1996#ifdef HAVE_X_WINDOWS
1997 if (!inhibit_window_system && (display_arg || getenv ("DISPLAY")))
1998 {
1999 Vwindow_system = intern ("x");
2000#ifdef HAVE_X11
2001 Vwindow_system_version = make_number (11);
2002#else
2003 Vwindow_system_version = make_number (10);
2004#endif
2005 return;
2006 }
2007#endif /* HAVE_X_WINDOWS */
2008
2009 /* If no window system has been specified, try to use the terminal. */
2010 if (! isatty (0))
2011 {
2012 fprintf (stderr, "emacs: standard input is not a tty\n");
2013 exit (1);
2014 }
2015
2016 /* Look at the TERM variable */
2017 terminal_type = (char *) getenv ("TERM");
2018 if (!terminal_type)
2019 {
2020#ifdef VMS
2021 fprintf (stderr, "Please specify your terminal type.\n\
2022For types defined in VMS, use set term /device=TYPE.\n\
2023For types not defined in VMS, use define emacs_term \"TYPE\".\n\
2024\(The quotation marks are necessary since terminal types are lower case.)\n");
2025#else
2026 fprintf (stderr, "Please set the environment variable TERM; see tset(1).\n");
2027#endif
2028 exit (1);
2029 }
2030
2031#ifdef VMS
2032 /* VMS DCL tends to upcase things, so downcase term type.
2033 Hardly any uppercase letters in terminal types; should be none. */
2034 {
2035 char *new = (char *) xmalloc (strlen (terminal_type) + 1);
2036 char *p;
2037
2038 strcpy (new, terminal_type);
2039
2040 for (p = new; *p; p++)
2041 if (isupper (*p))
2042 *p = tolower (*p);
2043
2044 terminal_type = new;
2045 }
2046#endif
2047
2048 term_init (terminal_type);
2049
2050 remake_frame_glyphs (selected_frame);
2051 calculate_costs (selected_frame);
2052
2053 /* X and Y coordinates of the cursor between updates. */
2054 FRAME_CURSOR_X (selected_frame) = 0;
2055 FRAME_CURSOR_Y (selected_frame) = 0;
2056
2057#ifdef SIGWINCH
2058#ifndef CANNOT_DUMP
2059 if (initialized)
2060#endif /* CANNOT_DUMP */
2061 signal (SIGWINCH, window_change_signal);
2062#endif /* SIGWINCH */
2063}
2064\f
2065syms_of_display ()
2066{
2067#ifdef MULTI_FRAME
2068 defsubr (&Sredraw_frame);
2069#endif
2070 defsubr (&Sredraw_display);
2071 defsubr (&Sopen_termscript);
2072 defsubr (&Sding);
2073 defsubr (&Ssit_for);
2074 defsubr (&Ssleep_for);
2075 defsubr (&Ssend_string_to_terminal);
2076
2077 DEFVAR_INT ("baud-rate", &baud_rate,
2078 "The output baud rate of the terminal.\n\
2079On most systems, changing this value will affect the amount of padding\n\
2080and the other strategic decisions made during redisplay.");
2081 DEFVAR_BOOL ("inverse-video", &inverse_video,
2082 "*Non-nil means invert the entire frame display.\n\
2083This means everything is in inverse video which otherwise would not be.");
2084 DEFVAR_BOOL ("visible-bell", &visible_bell,
2085 "*Non-nil means try to flash the frame to represent a bell.");
2086 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter,
2087 "*Non-nil means no need to redraw entire frame after suspending.\n\
2088A non-nil value is useful if the terminal can automatically preserve\n\
2089Emacs's frame display when you reenter Emacs.\n\
2090It is up to you to set this variable if your terminal can do that.");
2091 DEFVAR_LISP ("window-system", &Vwindow_system,
2092 "A symbol naming the window-system under which Emacs is running\n\
2093\(such as `x'), or nil if emacs is running on an ordinary terminal.");
2094 DEFVAR_LISP ("window-system-version", &Vwindow_system_version,
2095 "The version number of the window system in use.\n\
2096For X windows, this is 10 or 11.");
2097 DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area,
2098 "Non-nil means put cursor in minibuffer, at end of any message there.");
2099 DEFVAR_LISP ("glyph-table", &Vglyph_table,
2100 "Table defining how to output a glyph code to the frame.\n\
2101If not nil, this is a vector indexed by glyph code to define the glyph.\n\
2102Each element can be:\n\
2103 integer: a glyph code which this glyph is an alias for.\n\
2104 string: output this glyph using that string (not impl. in X windows).\n\
2105 nil: this glyph mod 256 is char code to output,\n\
2106 and this glyph / 256 is face code for X windows (see `x-set-face').");
2107 Vglyph_table = Qnil;
2108
2109 DEFVAR_LISP ("standard-display-table", &Vstandard_display_table,
2110 "Display table to use for buffers that specify none.\n\
2111See `buffer-display-table' for more information.");
2112 Vstandard_display_table = Qnil;
2113
2114 /* Initialize `window-system', unless init_display already decided it. */
2115#ifdef CANNOT_DUMP
2116 if (noninteractive)
2117#endif
2118 {
2119 Vwindow_system = Qnil;
2120 Vwindow_system_version = Qnil;
2121 }
2122}
2123