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