Mercurial > emacs
annotate src/dispnew.c @ 2085:a5e2213a5c4a
Version 5 baseline.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Tue, 09 Mar 1993 22:56:29 +0000 |
parents | 98ecf99d7b1a |
children | 0f4b18efebf5 |
rev | line source |
---|---|
314 | 1 /* Updating of data structures for redisplay. |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
2 Copyright (C) 1985, 1986, 1987, 1988, 1990, |
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
3 1992, 1993 Free Software Foundation, Inc. |
314 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
314 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
19 the 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 "cm.h" | |
31 #include "lisp.h" | |
32 #include "dispextern.h" | |
33 #include "buffer.h" | |
764 | 34 #include "frame.h" |
314 | 35 #include "window.h" |
36 #include "commands.h" | |
37 #include "disptab.h" | |
38 #include "indent.h" | |
39 | |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
40 #include "systty.h" |
554 | 41 #include "systime.h" |
42 | |
314 | 43 #ifdef HAVE_X_WINDOWS |
44 #include "xterm.h" | |
45 #endif /* HAVE_X_WINDOWS */ | |
46 | |
47 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
48 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
49 | |
50 #ifndef PENDING_OUTPUT_COUNT | |
51 /* Get number of chars of output now in the buffer of a stdio stream. | |
52 This ought to be built in in stdio, but it isn't. | |
53 Some s- files override this because their stdio internals differ. */ | |
54 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base) | |
55 #endif | |
56 | |
554 | 57 /* Nonzero upon entry to redisplay means do not assume anything about |
764 | 58 current contents of actual terminal frame; clear and redraw it. */ |
314 | 59 |
764 | 60 int frame_garbaged; |
314 | 61 |
62 /* Nonzero means last display completed. Zero means it was preempted. */ | |
63 | |
64 int display_completed; | |
65 | |
66 /* Lisp variable visible-bell; enables use of screen-flash | |
67 instead of audible bell. */ | |
68 | |
69 int visible_bell; | |
70 | |
764 | 71 /* Invert the color of the whole frame, at a low level. */ |
314 | 72 |
73 int inverse_video; | |
74 | |
75 /* Line speed of the terminal. */ | |
76 | |
77 int baud_rate; | |
78 | |
79 /* nil or a symbol naming the window system under which emacs is | |
80 running ('x is the only current possibility). */ | |
81 | |
82 Lisp_Object Vwindow_system; | |
83 | |
84 /* Version number of X windows: 10, 11 or nil. */ | |
85 Lisp_Object Vwindow_system_version; | |
86 | |
87 /* Vector of glyph definitions. Indexed by glyph number, | |
88 the contents are a string which is how to output the glyph. | |
89 | |
90 If Vglyph_table is nil, a glyph is output by using its low 8 bits | |
91 as a character code. */ | |
92 | |
93 Lisp_Object Vglyph_table; | |
94 | |
95 /* Display table to use for vectors that don't specify their own. */ | |
96 | |
97 Lisp_Object Vstandard_display_table; | |
98 | |
99 /* Nonzero means reading single-character input with prompt | |
708 | 100 so put cursor on minibuffer after the prompt. |
101 positive means at end of text in echo area; | |
102 negative means at beginning of line. */ | |
314 | 103 int cursor_in_echo_area; |
104 | |
764 | 105 /* The currently selected frame. |
106 In a single-frame version, this variable always remains 0. */ | |
314 | 107 |
764 | 108 FRAME_PTR selected_frame; |
314 | 109 |
764 | 110 /* A frame which is not just a minibuffer, or 0 if there are no such |
111 frames. This is usually the most recent such frame that was | |
112 selected. In a single-frame version, this variable always remains 0. */ | |
113 FRAME_PTR last_nonminibuf_frame; | |
732 | 114 |
764 | 115 /* 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
|
116 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
|
117 |
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
118 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
|
119 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
|
120 |
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
121 You're not/The only frame in town/... */ |
314 | 122 |
764 | 123 #ifndef MULTI_FRAME |
124 struct frame the_only_frame; | |
732 | 125 #endif |
314 | 126 |
127 /* This is a vector, made larger whenever it isn't large enough, | |
764 | 128 which is used inside `update_frame' to hold the old contents |
129 of the FRAME_PHYS_LINES of the frame being updated. */ | |
130 struct frame_glyphs **ophys_lines; | |
314 | 131 /* Length of vector currently allocated. */ |
132 int ophys_lines_length; | |
133 | |
134 FILE *termscript; /* Stdio stream being used for copy of all output. */ | |
135 | |
136 struct cm Wcm; /* Structure for info on cursor positioning */ | |
137 | |
138 extern short ospeed; /* Output speed (from sg_ospeed) */ | |
139 | |
140 int delayed_size_change; /* 1 means SIGWINCH happened when not safe. */ | |
141 | |
764 | 142 #ifdef MULTI_FRAME |
314 | 143 |
764 | 144 DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, |
145 "Clear frame FRAME and output again what is supposed to appear on it.") | |
146 (frame) | |
147 Lisp_Object frame; | |
314 | 148 { |
764 | 149 FRAME_PTR f; |
314 | 150 |
764 | 151 CHECK_LIVE_FRAME (frame, 0); |
152 f = XFRAME (frame); | |
153 update_begin (f); | |
314 | 154 /* set_terminal_modes (); */ |
764 | 155 clear_frame (); |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
156 clear_frame_records (f); |
764 | 157 update_end (f); |
314 | 158 fflush (stdout); |
159 windows_or_buffers_changed++; | |
160 /* Mark all windows as INaccurate, | |
161 so that every window will have its redisplay done. */ | |
764 | 162 mark_window_display_accurate (FRAME_ROOT_WINDOW (f), 0); |
163 f->garbaged = 0; | |
314 | 164 return Qnil; |
165 } | |
166 | |
167 DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "", | |
1791
4e554ea437ed
* dispnew.c (Fredraw_display): DEFUN was missing a closing paren.
Jim Blandy <jimb@redhat.com>
parents:
1777
diff
changeset
|
168 "Clear and redisplay all visible frames.") |
314 | 169 () |
170 { | |
764 | 171 Lisp_Object frame, tail; |
314 | 172 |
764 | 173 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
314 | 174 { |
764 | 175 frame = XCONS (tail)->car; |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
176 |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
177 /* If we simply redrew all visible frames, whether or not they |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
178 were garbaged, then this would make all frames clear and |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
179 redraw whenever a new frame is created or an existing frame |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
180 is de-iconified; those events set the global frame_garbaged |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
181 flag, to which redisplay responds by calling this function. |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
182 |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
183 This used to redraw all visible frames; the only advantage of |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
184 that approach is that if a frame changes from invisible to |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
185 visible without setting its garbaged flag, it still gets |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
186 redisplayed. But that should never happen; since invisible |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
187 frames are not updated, they should always be marked as |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
188 garbaged when they become visible again. If that doesn't |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
189 happen, it's a bug in the visibility code, not a bug here. */ |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
190 if (FRAME_VISIBLE_P (XFRAME (frame)) |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1791
diff
changeset
|
191 && FRAME_GARBAGED_P (XFRAME (frame))) |
764 | 192 Fredraw_frame (frame); |
314 | 193 } |
194 return Qnil; | |
195 } | |
196 | |
764 | 197 redraw_frame (f) |
198 FRAME_PTR f; | |
314 | 199 { |
764 | 200 Lisp_Object frame; |
201 XSET (frame, Lisp_Frame, f); | |
202 Fredraw_frame (frame); | |
314 | 203 } |
204 | |
764 | 205 #else /* not MULTI_FRAME */ |
314 | 206 |
1766
be62942446f0
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
1708
diff
changeset
|
207 DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "", |
314 | 208 "Clear screen and output again what is supposed to appear on it.") |
209 () | |
210 { | |
211 update_begin (0); | |
212 set_terminal_modes (); | |
764 | 213 clear_frame (); |
314 | 214 update_end (0); |
215 fflush (stdout); | |
764 | 216 clear_frame_records (0); |
314 | 217 windows_or_buffers_changed++; |
218 /* Mark all windows as INaccurate, | |
219 so that every window will have its redisplay done. */ | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
220 mark_window_display_accurate (FRAME_ROOT_WINDOW (0), 0); |
314 | 221 return Qnil; |
222 } | |
223 | |
764 | 224 #endif /* not MULTI_FRAME */ |
314 | 225 |
764 | 226 static struct frame_glyphs * |
227 make_frame_glyphs (frame, empty) | |
228 register FRAME_PTR frame; | |
314 | 229 int empty; |
230 { | |
231 register int i; | |
764 | 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)); | |
314 | 236 |
764 | 237 SET_GLYPHS_FRAME (new, frame); |
314 | 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 | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
248 if (FRAME_X_P (frame)) |
314 | 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)); | |
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
254 new->max_ascent = (short *) xmalloc (height * sizeof (short)); |
314 | 255 } |
256 #endif | |
257 | |
258 if (empty) | |
259 { | |
260 /* Make the buffer used by decode_mode_spec. This buffer is also | |
764 | 261 used as temporary storage when updating the frame. See scroll.c. */ |
314 | 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 | |
280 static void | |
764 | 281 free_frame_glyphs (frame, glyphs) |
282 FRAME_PTR frame; | |
283 struct frame_glyphs *glyphs; | |
314 | 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 | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
295 if (FRAME_X_P (frame)) |
314 | 296 { |
297 free (glyphs->top_left_x); | |
298 free (glyphs->top_left_y); | |
299 free (glyphs->pix_width); | |
300 free (glyphs->pix_height); | |
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
301 free (glyphs->max_ascent); |
314 | 302 } |
303 #endif | |
304 | |
305 free (glyphs); | |
306 } | |
307 | |
308 static void | |
764 | 309 remake_frame_glyphs (frame) |
310 FRAME_PTR frame; | |
314 | 311 { |
764 | 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)); | |
314 | 318 |
764 | 319 if (FRAME_MESSAGE_BUF (frame)) |
1872
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
320 { |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
321 /* Reallocate the frame's message buffer; remember that |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
322 echo_area_glyphs may be pointing here. */ |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
323 char *old_message_buf = FRAME_MESSAGE_BUF (frame); |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
324 |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
325 FRAME_MESSAGE_BUF (frame) |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
326 = (char *) xrealloc (FRAME_MESSAGE_BUF (frame), |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
327 FRAME_WIDTH (frame) + 1); |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
328 |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
329 if (echo_area_glyphs == old_message_buf) |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
330 echo_area_glyphs = FRAME_MESSAGE_BUF (frame); |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
331 if (previous_echo_glyphs == old_message_buf) |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
332 previous_echo_glyphs = FRAME_MESSAGE_BUF (frame); |
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
333 } |
314 | 334 else |
764 | 335 FRAME_MESSAGE_BUF (frame) |
336 = (char *) xmalloc (FRAME_WIDTH (frame) + 1); | |
314 | 337 |
764 | 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); | |
314 | 342 } |
343 | |
764 | 344 /* Return the hash code of contents of line VPOS in frame-matrix M. */ |
314 | 345 |
346 static int | |
347 line_hash_code (m, vpos) | |
764 | 348 register struct frame_glyphs *m; |
314 | 349 int vpos; |
350 { | |
351 register GLYPH *body, *end; | |
352 register int h = 0; | |
353 | |
354 if (!m->enable[vpos]) | |
355 return 0; | |
356 | |
1495
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
357 /* Give all highlighted lines the same hash code |
314 | 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 | |
392 static unsigned int | |
393 line_draw_cost (m, vpos) | |
764 | 394 struct frame_glyphs *m; |
314 | 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 | |
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 | |
764 | 437 FRAME_CURSOR_X (frame) and FRAME_CURSOR_Y (frame) |
438 and SET_FRAME_GARBAGED (frame). */ | |
314 | 439 |
440 /* cancel_line eliminates any request to display a line at position `vpos' */ | |
441 | |
764 | 442 cancel_line (vpos, frame) |
314 | 443 int vpos; |
764 | 444 register FRAME_PTR frame; |
314 | 445 { |
764 | 446 FRAME_DESIRED_GLYPHS (frame)->enable[vpos] = 0; |
314 | 447 } |
448 | |
764 | 449 clear_frame_records (frame) |
450 register FRAME_PTR frame; | |
314 | 451 { |
764 | 452 bzero (FRAME_CURRENT_GLYPHS (frame)->enable, FRAME_HEIGHT (frame)); |
314 | 453 } |
454 | |
455 /* Prepare to display on line VPOS starting at HPOS within it. */ | |
456 | |
457 void | |
764 | 458 get_display_line (frame, vpos, hpos) |
459 register FRAME_PTR frame; | |
314 | 460 int vpos; |
461 register int hpos; | |
462 { | |
764 | 463 register struct frame_glyphs *glyphs; |
464 register struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (frame); | |
314 | 465 register GLYPH *p; |
466 | |
1192
5c380ec3cfc6
* dispnew.c (get_display_line): Don't abort if the frame is
Jim Blandy <jimb@redhat.com>
parents:
1042
diff
changeset
|
467 if (vpos < 0) |
314 | 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 | |
493 void | |
494 safe_bcopy (from, to, size) | |
495 char *from, *to; | |
496 int size; | |
497 { | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
498 if (size <= 0 || from == to) |
314 | 499 return; |
500 | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
501 /* If the source and destination don't overlap, then bcopy can |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
502 handle it. If they do overlap, but the destination is lower in |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
503 memory than the source, we'll assume bcopy can handle that. */ |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
504 if (to < from || from + size <= to) |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
505 bcopy (from, to, size); |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
506 |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
507 /* Otherwise, we'll copy from the end. */ |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
508 else |
314 | 509 { |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
510 register char *endf = from + size; |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
511 register char *endt = to + size; |
314 | 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 | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
517 anywhere. Since I don't think the obvious copy loop is too |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
518 bad, I'm trying to err in its favor. */ |
314 | 519 if (to - from < 64) |
520 { | |
521 do | |
522 *--endt = *--endf; | |
523 while (endf != from); | |
524 } | |
525 else | |
526 { | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
527 for (;;) |
314 | 528 { |
529 endt -= (to - from); | |
530 endf -= (to - from); | |
531 | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
532 if (endt < to) |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
533 break; |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
534 |
314 | 535 bcopy (endf, endt, to - from); |
536 } | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
537 |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
538 /* If SIZE wasn't a multiple of TO - FROM, there will be a |
314 | 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 | |
352 | 546 /* Rotate a vector of SIZE bytes right, by DISTANCE bytes. |
314 | 547 DISTANCE may be negative. */ |
548 | |
549 static void | |
550 rotate_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 | |
569 int | |
764 | 570 scroll_frame_lines (frame, from, end, amount) |
571 register FRAME_PTR frame; | |
314 | 572 int from, end, amount; |
573 { | |
574 register int i; | |
764 | 575 register struct frame_glyphs *current_frame |
576 = FRAME_CURRENT_GLYPHS (frame); | |
314 | 577 |
578 if (!line_ins_del_ok) | |
579 return 0; | |
580 | |
581 if (amount == 0) | |
582 return 1; | |
583 | |
584 if (amount > 0) | |
585 { | |
764 | 586 update_begin (frame); |
314 | 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 | |
764 | 593 rotate_vector (current_frame->glyphs + from, |
314 | 594 sizeof (GLYPH *) * (end + amount - from), |
595 amount * sizeof (GLYPH *)); | |
596 | |
764 | 597 safe_bcopy (current_frame->used + from, |
598 current_frame->used + from + amount, | |
599 (end - from) * sizeof current_frame->used[0]); | |
314 | 600 |
764 | 601 safe_bcopy (current_frame->highlight + from, |
602 current_frame->highlight + from + amount, | |
603 (end - from) * sizeof current_frame->highlight[0]); | |
314 | 604 |
764 | 605 safe_bcopy (current_frame->enable + from, |
606 current_frame->enable + from + amount, | |
607 (end - from) * sizeof current_frame->enable[0]); | |
314 | 608 |
609 /* Mark the lines made empty by scrolling as enabled, empty and | |
610 normal video. */ | |
764 | 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]); | |
314 | 615 for (i = from; i < from + amount; i++) |
616 { | |
764 | 617 current_frame->glyphs[i][0] = '\0'; |
618 current_frame->enable[i] = 1; | |
314 | 619 } |
620 | |
764 | 621 safe_bcopy (current_frame->bufp + from, |
622 current_frame->bufp + from + amount, | |
623 (end - from) * sizeof current_frame->bufp[0]); | |
314 | 624 |
625 #ifdef HAVE_X_WINDOWS | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
626 if (FRAME_X_P (frame)) |
314 | 627 { |
764 | 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]); | |
314 | 631 |
764 | 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]); | |
314 | 635 |
764 | 636 safe_bcopy (current_frame->pix_width + from, |
637 current_frame->pix_width + from + amount, | |
638 (end - from) * sizeof current_frame->pix_width[0]); | |
314 | 639 |
764 | 640 safe_bcopy (current_frame->pix_height + from, |
641 current_frame->pix_height + from + amount, | |
642 (end - from) * sizeof current_frame->pix_height[0]); | |
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
643 |
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
644 safe_bcopy (current_frame->max_ascent + from, |
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
645 current_frame->max_ascent + from + amount, |
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
646 (end - from) * sizeof current_frame->max_ascent[0]); |
314 | 647 } |
648 #endif /* HAVE_X_WINDOWS */ | |
649 | |
764 | 650 update_end (frame); |
314 | 651 } |
652 if (amount < 0) | |
653 { | |
764 | 654 update_begin (frame); |
314 | 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 | |
764 | 661 rotate_vector (current_frame->glyphs + from + amount, |
314 | 662 sizeof (GLYPH *) * (end - from - amount), |
663 amount * sizeof (GLYPH *)); | |
664 | |
764 | 665 safe_bcopy (current_frame->used + from, |
666 current_frame->used + from + amount, | |
667 (end - from) * sizeof current_frame->used[0]); | |
314 | 668 |
764 | 669 safe_bcopy (current_frame->highlight + from, |
670 current_frame->highlight + from + amount, | |
671 (end - from) * sizeof current_frame->highlight[0]); | |
314 | 672 |
764 | 673 safe_bcopy (current_frame->enable + from, |
674 current_frame->enable + from + amount, | |
675 (end - from) * sizeof current_frame->enable[0]); | |
314 | 676 |
677 /* Mark the lines made empty by scrolling as enabled, empty and | |
678 normal video. */ | |
764 | 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]); | |
314 | 683 for (i = end + amount; i < end; i++) |
684 { | |
764 | 685 current_frame->glyphs[i][0] = '\0'; |
686 current_frame->enable[i] = 1; | |
314 | 687 } |
688 | |
764 | 689 safe_bcopy (current_frame->bufp + from, |
690 current_frame->bufp + from + amount, | |
691 (end - from) * sizeof current_frame->bufp[0]); | |
314 | 692 |
693 #ifdef HAVE_X_WINDOWS | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
694 if (FRAME_X_P (frame)) |
314 | 695 { |
764 | 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]); | |
314 | 699 |
764 | 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]); | |
314 | 703 |
764 | 704 safe_bcopy (current_frame->pix_width + from, |
705 current_frame->pix_width + from + amount, | |
706 (end - from) * sizeof current_frame->pix_width[0]); | |
314 | 707 |
764 | 708 safe_bcopy (current_frame->pix_height + from, |
709 current_frame->pix_height + from + amount, | |
710 (end - from) * sizeof current_frame->pix_height[0]); | |
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
711 |
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
712 safe_bcopy (current_frame->max_ascent + from, |
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
713 current_frame->max_ascent + from + amount, |
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
714 (end - from) * sizeof current_frame->max_ascent[0]); |
314 | 715 } |
716 #endif /* HAVE_X_WINDOWS */ | |
717 | |
764 | 718 update_end (frame); |
314 | 719 } |
720 return 1; | |
721 } | |
722 | |
764 | 723 /* After updating a window W that isn't the full frame wide, |
314 | 724 copy all the columns that W does not occupy |
764 | 725 into the FRAME_DESIRED_GLYPHS (frame) from the FRAME_PHYS_GLYPHS (frame) |
726 so that update_frame will not change those columns. */ | |
314 | 727 |
728 preserve_other_columns (w) | |
729 struct window *w; | |
730 { | |
731 register int vpos; | |
764 | 732 register struct frame_glyphs *current_frame, *desired_frame; |
733 register FRAME_PTR frame = XFRAME (w->frame); | |
314 | 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 | |
764 | 738 current_frame = FRAME_CURRENT_GLYPHS (frame); |
739 desired_frame = FRAME_DESIRED_GLYPHS (frame); | |
314 | 740 |
741 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) | |
742 { | |
764 | 743 if (current_frame->enable[vpos] && desired_frame->enable[vpos]) |
314 | 744 { |
745 if (start > 0) | |
746 { | |
747 int len; | |
748 | |
764 | 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; | |
314 | 754 } |
764 | 755 if (current_frame->used[vpos] > end |
756 && desired_frame->used[vpos] < current_frame->used[vpos]) | |
314 | 757 { |
764 | 758 while (desired_frame->used[vpos] < end) |
759 desired_frame->glyphs[vpos][desired_frame->used[vpos]++] | |
314 | 760 = SPACEGLYPH; |
764 | 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]; | |
314 | 765 } |
766 } | |
767 } | |
768 } | |
769 | |
770 #if 0 | |
771 | |
764 | 772 /* If window w does not need to be updated and isn't the full frame wide, |
314 | 773 copy all the columns that w does occupy |
764 | 774 into the FRAME_DESIRED_LINES (frame) from the FRAME_PHYS_LINES (frame) |
775 so that update_frame will not change those columns. | |
314 | 776 |
777 Have not been able to figure out how to use this correctly. */ | |
778 | |
779 preserve_my_columns (w) | |
780 struct window *w; | |
781 { | |
782 register int vpos, fin; | |
764 | 783 register struct frame_glyphs *l1, *l2; |
784 register FRAME_PTR frame = XFRAME (w->frame); | |
314 | 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 { | |
764 | 791 if ((l1 = FRAME_DESIRED_GLYPHS (frame)->glyphs[vpos + 1]) |
792 && (l2 = FRAME_PHYS_GLYPHS (frame)->glyphs[vpos + 1])) | |
314 | 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 | |
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 | |
813 cancel_my_columns (w) | |
814 struct window *w; | |
815 { | |
816 register int vpos; | |
764 | 817 register struct frame_glyphs *desired_glyphs = |
818 FRAME_DESIRED_GLYPHS (XFRAME (w->frame)); | |
314 | 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 | |
764 | 828 /* These functions try to perform directly and immediately on the frame |
314 | 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. | |
764 | 832 They assume that the frame was up to date before the buffer |
1495
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
833 change being displayed. They make various other assumptions too; |
314 | 834 see command_loop_1 where these are called. */ |
835 | |
836 int | |
837 direct_output_for_insert (g) | |
838 int g; | |
839 { | |
764 | 840 register FRAME_PTR frame = selected_frame; |
841 register struct frame_glyphs *current_frame | |
842 = FRAME_CURRENT_GLYPHS (frame); | |
314 | 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 */ | |
764 | 851 int hpos = FRAME_CURSOR_X (frame); |
314 | 852 #ifndef COMPILER_REGISTER_BUG |
853 register | |
854 #endif /* COMPILER_REGISTER_BUG */ | |
764 | 855 int vpos = FRAME_CURSOR_Y (frame); |
314 | 856 |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
857 /* Give up if about to continue line. */ |
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
858 if (hpos >= XFASTINT (w->left) + window_internal_width (w) - 1 |
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
859 |
314 | 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) */ | |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
864 || cursor_in_echo_area |
764 | 865 || FRAME_CURSOR_Y (frame) < XFASTINT (w->top) |
866 || FRAME_CURSOR_Y (frame) >= XFASTINT (w->top) + XFASTINT (w->height) | |
314 | 867 |
764 | 868 /* Give up if cursor not really at FRAME_CURSOR_X, FRAME_CURSOR_Y */ |
314 | 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 | |
764 | 878 current_frame->glyphs[vpos][hpos] = g; |
314 | 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); | |
764 | 886 write_glyphs (¤t_frame->glyphs[vpos][hpos], 1); |
314 | 887 fflush (stdout); |
764 | 888 ++FRAME_CURSOR_X (frame); |
889 if (hpos == current_frame->used[vpos]) | |
314 | 890 { |
764 | 891 current_frame->used[vpos] = hpos + 1; |
892 current_frame->glyphs[vpos][hpos + 1] = 0; | |
314 | 893 } |
894 | |
895 return 1; | |
896 } | |
897 | |
898 int | |
899 direct_output_forward_char (n) | |
900 int n; | |
901 { | |
764 | 902 register FRAME_PTR frame = selected_frame; |
314 | 903 register struct window *w = XWINDOW (selected_window); |
904 | |
543 | 905 /* Avoid losing if cursor is in invisible text off left margin |
906 or about to go off either side of window. */ | |
764 | 907 if ((FRAME_CURSOR_X (frame) == XFASTINT (w->left) |
543 | 908 && (XINT (w->hscroll) || n < 0)) |
909 || (n > 0 | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
910 && (FRAME_CURSOR_X (frame) + 1 >= window_internal_width (w) - 1)) |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
911 || cursor_in_echo_area) |
314 | 912 return 0; |
913 | |
764 | 914 FRAME_CURSOR_X (frame) += n; |
915 XFASTINT (w->last_point_x) = FRAME_CURSOR_X (frame); | |
314 | 916 XFASTINT (w->last_point) = point; |
764 | 917 cursor_to (FRAME_CURSOR_Y (frame), FRAME_CURSOR_X (frame)); |
314 | 918 fflush (stdout); |
919 return 1; | |
920 } | |
921 | |
922 static void update_line (); | |
923 | |
764 | 924 /* Update frame F based on the data in FRAME_DESIRED_GLYPHS. |
314 | 925 Value is nonzero if redisplay stopped due to pending input. |
926 FORCE nonzero means do not stop for pending input. */ | |
927 | |
928 int | |
764 | 929 update_frame (f, force, inhibit_hairy_id) |
930 FRAME_PTR f; | |
314 | 931 int force; |
932 int inhibit_hairy_id; | |
933 { | |
764 | 934 register struct frame_glyphs *current_frame = FRAME_CURRENT_GLYPHS (f); |
935 register struct frame_glyphs *desired_frame = FRAME_DESIRED_GLYPHS (f); | |
314 | 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 | |
764 | 944 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
314 | 945 |
946 detect_input_pending (); | |
947 if (input_pending && !force) | |
948 { | |
949 pause = 1; | |
950 goto do_pause; | |
951 } | |
952 | |
764 | 953 update_begin (f); |
314 | 954 |
955 if (!line_ins_del_ok) | |
956 inhibit_hairy_id = 1; | |
957 | |
493 | 958 /* See if any of the desired lines are enabled; don't compute for |
959 i/d line if just want cursor motion. */ | |
764 | 960 for (i = 0; i < FRAME_HEIGHT (f); i++) |
961 if (desired_frame->enable[i]) | |
314 | 962 break; |
963 | |
964 /* Try doing i/d line, if not yet inhibited. */ | |
764 | 965 if (!inhibit_hairy_id && i < FRAME_HEIGHT (f)) |
966 force |= scrolling (f); | |
314 | 967 |
968 /* Update the individual lines as needed. Do bottom line first. */ | |
969 | |
764 | 970 if (desired_frame->enable[FRAME_HEIGHT (f) - 1]) |
971 update_line (f, FRAME_HEIGHT (f) - 1); | |
314 | 972 |
973 #ifdef HAVE_X_WINDOWS | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
974 if (FRAME_X_P (f)) |
314 | 975 { |
764 | 976 leftmost = downto = f->display.x->internal_border_width; |
977 if (desired_frame->enable[0]) | |
314 | 978 { |
764 | 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 | |
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
982 - current_frame->pix_height[FRAME_HEIGHT (f) - 1]; |
764 | 983 current_frame->top_left_x[0] = leftmost; |
984 current_frame->top_left_y[0] = downto; | |
314 | 985 } |
986 } | |
987 #endif /* HAVE_X_WINDOWS */ | |
988 | |
989 /* Now update the rest of the lines. */ | |
764 | 990 for (i = 0; i < FRAME_HEIGHT (f) - 1 && (force || !input_pending); i++) |
314 | 991 { |
764 | 992 if (desired_frame->enable[i]) |
314 | 993 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
994 if (FRAME_TERMCAP_P (f)) |
314 | 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 { | |
554 | 1007 #ifdef EMACS_OUTQSIZE |
1008 if (EMACS_OUTQSIZE (0, &outq) < 0) | |
314 | 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 | |
764 | 1021 update_line (f, i); |
314 | 1022 #ifdef HAVE_X_WINDOWS |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1023 if (FRAME_X_P (f)) |
314 | 1024 { |
764 | 1025 current_frame->top_left_y[i] = downto; |
1026 current_frame->top_left_x[i] = leftmost; | |
314 | 1027 } |
1028 #endif /* HAVE_X_WINDOWS */ | |
1029 } | |
1030 | |
732 | 1031 #ifdef HAVE_X_WINDOWS |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1032 if (FRAME_X_P (f)) |
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
1033 downto += current_frame->pix_height[i]; |
732 | 1034 #endif |
314 | 1035 } |
764 | 1036 pause = (i < FRAME_HEIGHT (f) - 1) ? i : 0; |
314 | 1037 |
1038 /* Now just clean up termcap drivers and set cursor, etc. */ | |
1039 if (!pause) | |
1040 { | |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1041 if (cursor_in_echo_area |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1042 && FRAME_HAS_MINIBUF_P (f)) |
708 | 1043 { |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1044 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
|
1045 int row, col; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1046 |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1047 if (cursor_in_echo_area < 0) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1048 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1049 row = top; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1050 col = 0; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1051 } |
708 | 1052 else |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1053 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1054 /* 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
|
1055 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
|
1056 row = FRAME_HEIGHT (f); |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1057 do |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1058 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1059 row--; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1060 if (current_frame->enable[row]) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1061 col = current_frame->used[row]; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1062 else |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1063 col = 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 while (row > top && col == 0); |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1066 |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1067 if (col >= FRAME_WIDTH (f)) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1068 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1069 col = 0; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1070 if (row < FRAME_HEIGHT (f) - 1) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1071 row++; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1072 } |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1073 } |
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 cursor_to (row, col); |
708 | 1076 } |
314 | 1077 else |
764 | 1078 cursor_to (FRAME_CURSOR_Y (f), max (min (FRAME_CURSOR_X (f), |
1079 FRAME_WIDTH (f) - 1), 0)); | |
314 | 1080 } |
1081 | |
764 | 1082 update_end (f); |
314 | 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 | |
764 | 1091 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
314 | 1092 display_completed = !pause; |
1093 | |
764 | 1094 bzero (desired_frame->enable, FRAME_HEIGHT (f)); |
314 | 1095 return pause; |
1096 } | |
1097 | |
1098 /* Called when about to quit, to check for doing so | |
1099 at an improper time. */ | |
1100 | |
1101 void | |
1102 quit_error_check () | |
1103 { | |
764 | 1104 if (FRAME_DESIRED_GLYPHS (selected_frame) == 0) |
314 | 1105 return; |
764 | 1106 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[0]) |
314 | 1107 abort (); |
764 | 1108 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[FRAME_HEIGHT (selected_frame) - 1]) |
314 | 1109 abort (); |
1110 } | |
1111 | |
1112 /* Decide what insert/delete line to do, and do it */ | |
1113 | |
1114 extern void scrolling_1 (); | |
1115 | |
764 | 1116 scrolling (frame) |
1117 FRAME_PTR frame; | |
314 | 1118 { |
1119 int unchanged_at_top, unchanged_at_bottom; | |
1120 int window_size; | |
1121 int changed_lines; | |
764 | 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)); | |
314 | 1125 register int i; |
764 | 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); | |
314 | 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; | |
764 | 1137 unchanged_at_bottom = FRAME_HEIGHT (frame); |
1138 for (i = 0; i < FRAME_HEIGHT (frame); i++) | |
314 | 1139 { |
1140 /* Give up on this scrolling if some old lines are not enabled. */ | |
764 | 1141 if (!current_frame->enable[i]) |
314 | 1142 return 0; |
764 | 1143 old_hash[i] = line_hash_code (current_frame, i); |
1144 if (! desired_frame->enable[i]) | |
314 | 1145 new_hash[i] = old_hash[i]; |
1146 else | |
764 | 1147 new_hash[i] = line_hash_code (desired_frame, i); |
314 | 1148 |
1149 if (old_hash[i] != new_hash[i]) | |
1150 { | |
1151 changed_lines++; | |
764 | 1152 unchanged_at_bottom = FRAME_HEIGHT (frame) - i - 1; |
314 | 1153 } |
1154 else if (i == unchanged_at_top) | |
1155 unchanged_at_top++; | |
764 | 1156 draw_cost[i] = line_draw_cost (desired_frame, i); |
314 | 1157 } |
1158 | |
1159 /* If changed lines are few, don't allow preemption, don't scroll. */ | |
1160 if (changed_lines < baud_rate / 2400 | |
764 | 1161 || unchanged_at_bottom == FRAME_HEIGHT (frame)) |
314 | 1162 return 1; |
1163 | |
764 | 1164 window_size = (FRAME_HEIGHT (frame) - unchanged_at_top |
314 | 1165 - unchanged_at_bottom); |
1166 | |
1167 if (scroll_region_ok) | |
1168 free_at_end_vpos -= unchanged_at_bottom; | |
764 | 1169 else if (memory_below_frame) |
314 | 1170 free_at_end_vpos = -1; |
1171 | |
1172 /* If large window, fast terminal and few lines in common between | |
764 | 1173 current frame and desired frame, don't bother with i/d calc. */ |
314 | 1174 if (window_size >= 18 && baud_rate > 2400 |
1175 && (window_size >= | |
1176 10 * scrolling_max_lines_saved (unchanged_at_top, | |
764 | 1177 FRAME_HEIGHT (frame) - unchanged_at_bottom, |
314 | 1178 old_hash, new_hash, draw_cost))) |
1179 return 0; | |
1180 | |
764 | 1181 scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, |
314 | 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 | |
1190 /* Return the offset in its buffer of the character at location col, line | |
1191 in the given window. */ | |
1192 int | |
1193 buffer_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 | |
493 | 1200 DISP_CONTINUE_GLYPH, and less one if it's not the rightmost |
1201 window. */ | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
1202 int window_width = window_internal_width (window) - 1; |
314 | 1203 |
493 | 1204 int startp = marker_position (window->start); |
314 | 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; | |
493 | 1209 struct position *posn; |
314 | 1210 |
1211 current_buffer = XBUFFER (window->buffer); | |
1212 | |
764 | 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 | |
493 | 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); | |
314 | 1222 |
1223 current_buffer = old_current_buffer; | |
1224 | |
764 | 1225 /* compute_motion considers frame points past the end of a line |
493 | 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; | |
314 | 1233 } |
1234 | |
1235 static int | |
1236 count_blanks (r) | |
1237 register GLYPH *r; | |
1238 { | |
1239 register GLYPH *p = r; | |
1495
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
1240 while (*p++ == SPACEGLYPH); |
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
1241 return p - r - 1; |
314 | 1242 } |
1243 | |
1244 static int | |
1245 count_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 */ | |
1255 extern int *char_ins_del_vector; | |
1256 | |
1849
23ab36427257
(char_ins_del_cost): Use FRAME_WIDTH, not FRAME_HEIGHT.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
1257 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH((f))]) |
314 | 1258 |
1259 static void | |
764 | 1260 update_line (frame, vpos) |
1261 register FRAME_PTR frame; | |
314 | 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; | |
764 | 1268 register struct frame_glyphs *current_frame |
1269 = FRAME_CURRENT_GLYPHS (frame); | |
1270 register struct frame_glyphs *desired_frame | |
1271 = FRAME_DESIRED_GLYPHS (frame); | |
314 | 1272 |
764 | 1273 if (desired_frame->highlight[vpos] |
1274 != (current_frame->enable[vpos] && current_frame->highlight[vpos])) | |
314 | 1275 { |
764 | 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; | |
314 | 1280 } |
1281 else | |
764 | 1282 reassert_line_highlight (desired_frame->highlight[vpos], vpos); |
314 | 1283 |
764 | 1284 if (! current_frame->enable[vpos]) |
314 | 1285 { |
1286 olen = 0; | |
1287 } | |
1288 else | |
1289 { | |
764 | 1290 obody = current_frame->glyphs[vpos]; |
1291 olen = current_frame->used[vpos]; | |
1292 if (! current_frame->highlight[vpos]) | |
314 | 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 | |
764 | 1301 spaces all the way to the frame edge |
314 | 1302 so that the reverse video extends all the way across. */ |
1303 | |
764 | 1304 while (olen < FRAME_WIDTH (frame) - 1) |
314 | 1305 obody[olen++] = SPACEGLYPH; |
1306 } | |
1307 } | |
1308 | |
1309 /* One way or another, this will enable the line being updated. */ | |
764 | 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]; | |
314 | 1314 |
1315 #ifdef HAVE_X_WINDOWS | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1316 if (FRAME_X_P (frame)) |
314 | 1317 { |
764 | 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); | |
314 | 1323 } |
1324 #endif /* HAVE_X_WINDOWS */ | |
1325 | |
764 | 1326 if (!desired_frame->enable[vpos]) |
314 | 1327 { |
1328 nlen = 0; | |
1329 goto just_erase; | |
1330 } | |
1331 | |
764 | 1332 nbody = desired_frame->glyphs[vpos]; |
1333 nlen = desired_frame->used[vpos]; | |
314 | 1334 |
1335 /* Pretend trailing spaces are not there at all, | |
1336 unless for one reason or another we must write all spaces. */ | |
764 | 1337 if (! desired_frame->highlight[vpos]) |
314 | 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 | |
764 | 1347 all the way to the frame edge |
314 | 1348 so that the reverse video extends all the way across. */ |
1349 | |
764 | 1350 while (nlen < FRAME_WIDTH (frame) - 1) |
314 | 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 | |
764 | 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; | |
314 | 1387 |
1388 return; | |
1389 } | |
1390 | |
1391 if (!olen) | |
1392 { | |
764 | 1393 nsp = (must_write_spaces || desired_frame->highlight[vpos]) |
314 | 1394 ? 0 : count_blanks (nbody); |
1395 if (nlen > nsp) | |
1396 { | |
1397 cursor_to (vpos, nsp); | |
1398 write_glyphs (nbody + nsp, nlen - nsp); | |
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 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); | |
764 | 1415 if (!desired_frame->highlight[vpos]) |
314 | 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 | |
764 | 1462 && (!char_ins_del_ok || endmatch <= char_ins_del_cost (frame)[tem])) |
314 | 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 | |
764 | 1472 || begmatch + endmatch <= char_ins_del_cost (frame)[nsp - osp])) |
314 | 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) */ | |
764 | 1513 if (nlen == FRAME_WIDTH (frame)) |
314 | 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. */ | |
764 | 1527 if (nlen == FRAME_WIDTH (frame) && fast_clear_end_of_line && olen > nlen) |
314 | 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 | |
764 | 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; | |
314 | 1566 } |
1567 | |
1568 DEFUN ("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\ | |
1571 FILE = 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 | |
493 | 1578 if (! NILP (file)) |
314 | 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 | |
1588 | |
1589 #ifdef SIGWINCH | |
493 | 1590 SIGTYPE |
314 | 1591 window_change_signal () |
1592 { | |
1593 int width, height; | |
1594 extern int errno; | |
1595 int old_errno = errno; | |
1596 | |
764 | 1597 get_frame_size (&width, &height); |
314 | 1598 |
764 | 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 | |
314 | 1601 one (since the redisplay code always writes to stdout, not a |
764 | 1602 FILE * specified in the frame structure). Record the new size, |
314 | 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; | |
764 | 1608 FRAME_PTR f; |
314 | 1609 |
764 | 1610 FOR_EACH_FRAME (tail, f) |
314 | 1611 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1612 if (FRAME_TERMCAP_P (f)) |
314 | 1613 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1614 change_frame_size (f, height, width, 0, 1); |
314 | 1615 break; |
1616 } | |
1617 } | |
1618 } | |
1619 | |
1620 signal (SIGWINCH, window_change_signal); | |
1621 errno = old_errno; | |
1622 } | |
1623 #endif /* SIGWINCH */ | |
1624 | |
1625 | |
764 | 1626 /* Do any change in frame size that was requested by a signal. */ |
314 | 1627 |
1628 do_pending_window_change () | |
1629 { | |
1630 /* If window_change_signal should have run before, run it now. */ | |
1631 while (delayed_size_change) | |
1632 { | |
1633 Lisp_Object tail; | |
764 | 1634 FRAME_PTR f; |
314 | 1635 |
1636 delayed_size_change = 0; | |
1637 | |
764 | 1638 FOR_EACH_FRAME (tail, f) |
314 | 1639 { |
764 | 1640 int height = FRAME_NEW_HEIGHT (f); |
1641 int width = FRAME_NEW_WIDTH (f); | |
314 | 1642 |
764 | 1643 FRAME_NEW_HEIGHT (f) = 0; |
1644 FRAME_NEW_WIDTH (f) = 0; | |
314 | 1645 |
1646 if (height != 0) | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1647 change_frame_size (f, height, width, 0, 0); |
314 | 1648 } |
1649 } | |
1650 } | |
1651 | |
1652 | |
764 | 1653 /* 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
|
1654 indicate no change is to take place. |
314 | 1655 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1656 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
|
1657 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
|
1658 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
|
1659 from a signal handler. */ |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1660 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1661 change_frame_size (frame, newheight, newwidth, pretend, delay) |
764 | 1662 register FRAME_PTR frame; |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1663 int newheight, newwidth, pretend; |
314 | 1664 { |
1665 /* 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
|
1666 if (delay) |
314 | 1667 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1668 FRAME_NEW_HEIGHT (frame) = newheight; |
764 | 1669 FRAME_NEW_WIDTH (frame) = newwidth; |
314 | 1670 delayed_size_change = 1; |
1671 return; | |
1672 } | |
1673 | |
764 | 1674 /* This size-change overrides any pending one for this frame. */ |
1675 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
|
1676 FRAME_NEW_WIDTH (frame) = 0; |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1677 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1678 /* 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
|
1679 newheight || (newheight = FRAME_HEIGHT (frame)); |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1680 newwidth || (newwidth = FRAME_WIDTH (frame)); |
314 | 1681 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1682 /* 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
|
1683 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
|
1684 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1685 /* 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
|
1686 if (newheight == FRAME_HEIGHT (frame) |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1687 && newwidth == FRAME_WIDTH (frame)) |
314 | 1688 return; |
1689 | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1690 if (newheight != FRAME_HEIGHT (frame)) |
314 | 1691 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1692 if (FRAME_HAS_MINIBUF_P (frame) |
764 | 1693 && ! FRAME_MINIBUF_ONLY_P (frame)) |
314 | 1694 { |
764 | 1695 /* Frame has both root and minibuffer. */ |
1696 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
|
1697 newheight - 1, 0); |
764 | 1698 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
|
1699 = newheight - 1; |
764 | 1700 set_window_height (FRAME_MINIBUF_WINDOW (frame), 1, 0); |
314 | 1701 } |
1702 else | |
764 | 1703 /* 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
|
1704 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
|
1705 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1706 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
|
1707 FrameRows = newheight; |
314 | 1708 |
1709 #if 0 | |
764 | 1710 if (frame->output_method == output_termcap) |
314 | 1711 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1712 frame_height = newheight; |
314 | 1713 if (!pretend) |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1714 FrameRows = newheight; |
314 | 1715 } |
1716 #endif | |
1717 } | |
1718 | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1719 if (newwidth != FRAME_WIDTH (frame)) |
314 | 1720 { |
764 | 1721 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
|
1722 if (FRAME_HAS_MINIBUF_P (frame)) |
764 | 1723 set_window_width (FRAME_MINIBUF_WINDOW (frame), newwidth, 0); |
314 | 1724 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1725 if (FRAME_TERMCAP_P (frame) && !pretend) |
764 | 1726 FrameCols = newwidth; |
314 | 1727 #if 0 |
764 | 1728 if (frame->output_method == output_termcap) |
314 | 1729 { |
764 | 1730 frame_width = newwidth; |
314 | 1731 if (!pretend) |
764 | 1732 FrameCols = newwidth; |
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 FRAME_HEIGHT (frame) = newheight; |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1738 FRAME_WIDTH (frame) = newwidth; |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1739 |
764 | 1740 remake_frame_glyphs (frame); |
1741 calculate_costs (frame); | |
314 | 1742 } |
1743 | |
1744 DEFUN ("send-string-to-terminal", Fsend_string_to_terminal, | |
1745 Ssend_string_to_terminal, 1, 1, 0, | |
1746 "Send STRING to the terminal without alteration.\n\ | |
1747 Control characters in STRING will have terminal-dependent effects.") | |
1748 (str) | |
1749 Lisp_Object str; | |
1750 { | |
1751 CHECK_STRING (str, 0); | |
1752 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, stdout); | |
1753 fflush (stdout); | |
1754 if (termscript) | |
1755 { | |
1756 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, termscript); | |
1757 fflush (termscript); | |
1758 } | |
1759 return Qnil; | |
1760 } | |
1761 | |
1762 DEFUN ("ding", Fding, Sding, 0, 1, 0, | |
1763 "Beep, or flash the screen.\n\ | |
1764 Also, unless an argument is given,\n\ | |
1765 terminate any keyboard macro currently executing.") | |
1766 (arg) | |
1767 Lisp_Object arg; | |
1768 { | |
493 | 1769 if (!NILP (arg)) |
314 | 1770 { |
649
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1771 if (noninteractive) |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1772 putchar (07); |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1773 else |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1774 ring_bell (); |
314 | 1775 fflush (stdout); |
1776 } | |
1777 else | |
1778 bitch_at_user (); | |
1779 | |
1780 return Qnil; | |
1781 } | |
1782 | |
1783 bitch_at_user () | |
1784 { | |
1785 if (noninteractive) | |
1786 putchar (07); | |
1787 else if (!INTERACTIVE) /* Stop executing a keyboard macro. */ | |
1788 error ("Keyboard macro terminated by a command ringing the bell"); | |
1789 else | |
1790 ring_bell (); | |
1791 fflush (stdout); | |
1792 } | |
1793 | |
1794 DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0, | |
1795 "Pause, without updating display, for ARG seconds.\n\ | |
1796 Optional second arg non-nil means ARG is measured in milliseconds.\n\ | |
1797 \(Not all operating systems support milliseconds.)") | |
650 | 1798 (arg, millisec) |
1799 Lisp_Object arg, millisec; | |
314 | 1800 { |
1801 int usec = 0; | |
1802 int sec; | |
1803 | |
650 | 1804 CHECK_NUMBER (arg, 0); |
1805 sec = XINT (arg); | |
314 | 1806 if (sec <= 0) |
1807 return Qnil; | |
1808 | |
493 | 1809 if (!NILP (millisec)) |
314 | 1810 { |
554 | 1811 #ifndef EMACS_HAS_USECS |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
1812 error ("millisecond `sleep-for' not supported on %s", SYSTEM_TYPE); |
314 | 1813 #else |
1814 usec = sec % 1000 * 1000; | |
1815 sec /= 1000; | |
1816 #endif | |
1817 } | |
1818 | |
650 | 1819 { |
1820 Lisp_Object zero; | |
1821 | |
1822 XFASTINT (zero) = 0; | |
1823 wait_reading_process_input (sec, usec, zero, 0); | |
1824 } | |
587 | 1825 |
1826 #if 0 /* No wait_reading_process_input */ | |
314 | 1827 immediate_quit = 1; |
1828 QUIT; | |
1829 | |
1830 #ifdef VMS | |
1831 sys_sleep (sec); | |
1832 #else /* not VMS */ | |
1833 /* The reason this is done this way | |
1834 (rather than defined (H_S) && defined (H_T)) | |
1835 is because the VMS preprocessor doesn't grok `defined' */ | |
1836 #ifdef HAVE_SELECT | |
554 | 1837 EMACS_GET_TIME (end_time); |
1838 EMACS_SET_SECS_USECS (timeout, sec, usec); | |
587 | 1839 EMACS_ADD_TIME (end_time, end_time, timeout); |
554 | 1840 |
314 | 1841 while (1) |
1842 { | |
554 | 1843 EMACS_GET_TIME (timeout); |
1844 EMACS_SUB_TIME (timeout, end_time, timeout); | |
1845 if (EMACS_TIME_NEG_P (timeout) | |
1846 || !select (1, 0, 0, 0, &timeout)) | |
314 | 1847 break; |
1848 } | |
1849 #else /* not HAVE_SELECT */ | |
1850 sleep (sec); | |
1851 #endif /* HAVE_SELECT */ | |
1852 #endif /* not VMS */ | |
1853 | |
1854 immediate_quit = 0; | |
1855 #endif /* no subprocesses */ | |
1856 | |
1857 return Qnil; | |
1858 } | |
1859 | |
650 | 1860 /* This is just like wait_reading_process_input, except that |
1861 it does the redisplay. | |
1862 | |
1863 It's also just like Fsit_for, except that it can be used for | |
1864 waiting for input as well. */ | |
1865 | |
1866 Lisp_Object | |
1867 sit_for (sec, usec, reading, display) | |
1868 int sec, usec, reading, display; | |
314 | 1869 { |
650 | 1870 Lisp_Object read_kbd; |
314 | 1871 |
1872 if (detect_input_pending ()) | |
1873 return Qnil; | |
650 | 1874 |
1875 if (display) | |
314 | 1876 redisplay_preserve_echo_area (); |
1877 | |
673 | 1878 if (sec == 0 && usec == 0) |
1879 return Qt; | |
1880 | |
314 | 1881 #ifdef SIGIO |
1915
98ecf99d7b1a
* dispnew.c (sit_for): Pass the correct number of arguments to
Jim Blandy <jimb@redhat.com>
parents:
1872
diff
changeset
|
1882 gobble_input (0); |
650 | 1883 #endif |
1884 | |
1885 XSET (read_kbd, Lisp_Int, reading ? -1 : 1); | |
1886 wait_reading_process_input (sec, usec, read_kbd, display); | |
1887 | |
587 | 1888 |
1889 #if 0 /* No wait_reading_process_input available. */ | |
314 | 1890 immediate_quit = 1; |
1891 QUIT; | |
1892 | |
1893 waitchannels = 1; | |
1894 #ifdef VMS | |
650 | 1895 input_wait_timeout (XINT (arg)); |
314 | 1896 #else /* not VMS */ |
587 | 1897 #ifndef HAVE_TIMEVAL |
1898 timeout_sec = sec; | |
1899 select (1, &waitchannels, 0, 0, &timeout_sec); | |
1900 #else /* HAVE_TIMEVAL */ | |
1901 timeout.tv_sec = sec; | |
1902 timeout.tv_usec = usec; | |
314 | 1903 select (1, &waitchannels, 0, 0, &timeout); |
587 | 1904 #endif /* HAVE_TIMEVAL */ |
314 | 1905 #endif /* not VMS */ |
1906 | |
1907 immediate_quit = 0; | |
587 | 1908 #endif |
314 | 1909 |
1910 return detect_input_pending () ? Qnil : Qt; | |
1911 } | |
1912 | |
650 | 1913 DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0, |
1914 "Perform redisplay, then wait for ARG seconds or until input is available.\n\ | |
1915 Optional second arg non-nil means ARG counts in milliseconds.\n\ | |
1916 Optional third arg non-nil means don't redisplay, just wait for input.\n\ | |
1917 Redisplay is preempted as always if input arrives, and does not happen\n\ | |
1918 if input is available before it starts.\n\ | |
1919 Value is t if waited the full time with no input arriving.") | |
1920 (arg, millisec, nodisp) | |
1921 Lisp_Object arg, millisec, nodisp; | |
1922 { | |
1923 int usec = 0; | |
708 | 1924 int sec; |
650 | 1925 |
1926 CHECK_NUMBER (arg, 0); | |
708 | 1927 sec = XINT (arg); |
650 | 1928 |
1929 if (!NILP (millisec)) | |
1930 { | |
1931 #ifndef EMACS_HAS_USECS | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
1932 error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); |
650 | 1933 #else |
1934 usec = (sec % 1000) * 1000; | |
1935 sec /= 1000; | |
1936 #endif | |
1937 } | |
1938 | |
1939 return sit_for (sec, usec, 0, NILP (nodisp)); | |
1940 } | |
1941 | |
314 | 1942 DEFUN ("sleep-for-millisecs", Fsleep_for_millisecs, Ssleep_for_millisecs, |
1943 1, 1, 0, | |
1944 "Pause, without updating display, for ARG milliseconds.") | |
650 | 1945 (arg) |
1946 Lisp_Object arg; | |
314 | 1947 { |
650 | 1948 Lisp_Object zero; |
1949 | |
554 | 1950 #ifndef EMACS_HAS_USECS |
314 | 1951 error ("sleep-for-millisecs not supported on %s", SYSTEM_TYPE); |
1952 #else | |
650 | 1953 CHECK_NUMBER (arg, 0); |
1954 | |
1955 XFASTINT (zero) = 0; | |
1956 wait_reading_process_input (XINT (arg) / 1000, XINT (arg) % 1000 * 1000, | |
1957 zero, 0); | |
314 | 1958 return Qnil; |
554 | 1959 #endif /* EMACS_HAS_USECS */ |
314 | 1960 } |
1961 | |
1962 char *terminal_type; | |
1963 | |
1964 /* Initialization done when Emacs fork is started, before doing stty. */ | |
1965 /* Determine terminal type and set terminal_driver */ | |
1966 /* Then invoke its decoding routine to set up variables | |
1967 in the terminal package */ | |
1968 | |
1969 init_display () | |
1970 { | |
1971 #ifdef HAVE_X_WINDOWS | |
1972 extern int display_arg; | |
1973 #endif | |
1974 | |
1975 meta_key = 0; | |
1976 inverse_video = 0; | |
1977 cursor_in_echo_area = 0; | |
1978 terminal_type = (char *) 0; | |
1979 | |
1980 /* If the DISPLAY environment variable is set, try to use X, and | |
1981 die with an error message if that doesn't work. */ | |
1982 | |
1983 /* Check if we're using a window system here before trying to | |
1984 initialize the terminal. If we check the terminal first, | |
1985 | |
1986 If someone has indicated that they want | |
1987 to use a window system, we shouldn't bother initializing the | |
1988 terminal. This is especially important when the terminal is so | |
1989 dumb that emacs gives up before and doesn't bother using the window | |
1990 system. */ | |
1991 | |
1992 #ifdef HAVE_X_WINDOWS | |
493 | 1993 if (!inhibit_window_system && (display_arg || getenv ("DISPLAY"))) |
314 | 1994 { |
1995 Vwindow_system = intern ("x"); | |
1996 #ifdef HAVE_X11 | |
1997 Vwindow_system_version = make_number (11); | |
1998 #else | |
1999 Vwindow_system_version = make_number (10); | |
2000 #endif | |
2001 return; | |
2002 } | |
2003 #endif /* HAVE_X_WINDOWS */ | |
2004 | |
2005 /* If no window system has been specified, try to use the terminal. */ | |
2006 if (! isatty (0)) | |
2007 { | |
2008 fprintf (stderr, "emacs: standard input is not a tty\n"); | |
2009 exit (1); | |
2010 } | |
2011 | |
2012 /* Look at the TERM variable */ | |
2013 terminal_type = (char *) getenv ("TERM"); | |
2014 if (!terminal_type) | |
2015 { | |
2016 #ifdef VMS | |
2017 fprintf (stderr, "Please specify your terminal type.\n\ | |
2018 For types defined in VMS, use set term /device=TYPE.\n\ | |
2019 For types not defined in VMS, use define emacs_term \"TYPE\".\n\ | |
2020 \(The quotation marks are necessary since terminal types are lower case.)\n"); | |
2021 #else | |
2022 fprintf (stderr, "Please set the environment variable TERM; see tset(1).\n"); | |
2023 #endif | |
2024 exit (1); | |
2025 } | |
2026 | |
2027 #ifdef VMS | |
2028 /* VMS DCL tends to upcase things, so downcase term type. | |
2029 Hardly any uppercase letters in terminal types; should be none. */ | |
2030 { | |
2031 char *new = (char *) xmalloc (strlen (terminal_type) + 1); | |
2032 char *p; | |
2033 | |
2034 strcpy (new, terminal_type); | |
2035 | |
2036 for (p = new; *p; p++) | |
2037 if (isupper (*p)) | |
2038 *p = tolower (*p); | |
2039 | |
2040 terminal_type = new; | |
2041 } | |
2042 #endif | |
2043 | |
2044 term_init (terminal_type); | |
2045 | |
764 | 2046 remake_frame_glyphs (selected_frame); |
2047 calculate_costs (selected_frame); | |
314 | 2048 |
2049 /* X and Y coordinates of the cursor between updates. */ | |
764 | 2050 FRAME_CURSOR_X (selected_frame) = 0; |
2051 FRAME_CURSOR_Y (selected_frame) = 0; | |
314 | 2052 |
2053 #ifdef SIGWINCH | |
2054 #ifndef CANNOT_DUMP | |
2055 if (initialized) | |
2056 #endif /* CANNOT_DUMP */ | |
2057 signal (SIGWINCH, window_change_signal); | |
2058 #endif /* SIGWINCH */ | |
2059 } | |
2060 | |
2061 syms_of_display () | |
2062 { | |
764 | 2063 #ifdef MULTI_FRAME |
2064 defsubr (&Sredraw_frame); | |
314 | 2065 #endif |
2066 defsubr (&Sredraw_display); | |
2067 defsubr (&Sopen_termscript); | |
2068 defsubr (&Sding); | |
2069 defsubr (&Ssit_for); | |
2070 defsubr (&Ssleep_for); | |
2071 defsubr (&Ssend_string_to_terminal); | |
2072 | |
2073 DEFVAR_INT ("baud-rate", &baud_rate, | |
2074 "The output baud rate of the terminal.\n\ | |
2075 On most systems, changing this value will affect the amount of padding\n\ | |
2076 and the other strategic decisions made during redisplay."); | |
2077 DEFVAR_BOOL ("inverse-video", &inverse_video, | |
764 | 2078 "*Non-nil means invert the entire frame display.\n\ |
314 | 2079 This means everything is in inverse video which otherwise would not be."); |
2080 DEFVAR_BOOL ("visible-bell", &visible_bell, | |
764 | 2081 "*Non-nil means try to flash the frame to represent a bell."); |
314 | 2082 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter, |
764 | 2083 "*Non-nil means no need to redraw entire frame after suspending.\n\ |
314 | 2084 A non-nil value is useful if the terminal can automatically preserve\n\ |
764 | 2085 Emacs's frame display when you reenter Emacs.\n\ |
314 | 2086 It is up to you to set this variable if your terminal can do that."); |
2087 DEFVAR_LISP ("window-system", &Vwindow_system, | |
2088 "A symbol naming the window-system under which Emacs is running\n\ | |
2089 \(such as `x'), or nil if emacs is running on an ordinary terminal."); | |
2090 DEFVAR_LISP ("window-system-version", &Vwindow_system_version, | |
2091 "The version number of the window system in use.\n\ | |
2092 For X windows, this is 10 or 11."); | |
2093 DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area, | |
2094 "Non-nil means put cursor in minibuffer, at end of any message there."); | |
2095 DEFVAR_LISP ("glyph-table", &Vglyph_table, | |
764 | 2096 "Table defining how to output a glyph code to the frame.\n\ |
314 | 2097 If not nil, this is a vector indexed by glyph code to define the glyph.\n\ |
2098 Each element can be:\n\ | |
2099 integer: a glyph code which this glyph is an alias for.\n\ | |
2100 string: output this glyph using that string (not impl. in X windows).\n\ | |
2101 nil: this glyph mod 256 is char code to output,\n\ | |
2102 and this glyph / 256 is face code for X windows (see `x-set-face')."); | |
2103 Vglyph_table = Qnil; | |
2104 | |
2105 DEFVAR_LISP ("standard-display-table", &Vstandard_display_table, | |
2106 "Display table to use for buffers that specify none.\n\ | |
2107 See `buffer-display-table' for more information."); | |
2108 Vstandard_display_table = Qnil; | |
2109 | |
2110 /* Initialize `window-system', unless init_display already decided it. */ | |
2111 #ifdef CANNOT_DUMP | |
2112 if (noninteractive) | |
2113 #endif | |
2114 { | |
2115 Vwindow_system = Qnil; | |
2116 Vwindow_system_version = Qnil; | |
2117 } | |
2118 } | |
2119 |