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