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