Mercurial > emacs
annotate src/dispnew.c @ 4953:7545290052bf
(Fforward_comment): On backward scan, exit inner loop
after we reach beginning of a comment.
Check the SYNTAX_COMMENT_STYLE of a one-character comment ender.
(scan_lists): Check the SYNTAX_COMMENT_STYLE
of a one-character comment ender.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 10 Nov 1993 19:45:50 +0000 |
parents | 1fc792473491 |
children | 37fecb3bf8d9 |
rev | line source |
---|---|
314 | 1 /* Updating of data structures for redisplay. |
2961 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1993 Free Software Foundation, Inc. |
314 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
314 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 #include <signal.h> | |
22 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4551
diff
changeset
|
23 #include <config.h> |
314 | 24 #include <stdio.h> |
25 #include <ctype.h> | |
26 | |
3525
58e789baa27a
Include lisp.h earlier (before termhooks.h).
Richard M. Stallman <rms@gnu.org>
parents:
3517
diff
changeset
|
27 #include "lisp.h" |
314 | 28 #include "termchar.h" |
29 #include "termopts.h" | |
2198 | 30 #include "termhooks.h" |
314 | 31 #include "cm.h" |
32 #include "dispextern.h" | |
33 #include "buffer.h" | |
764 | 34 #include "frame.h" |
314 | 35 #include "window.h" |
36 #include "commands.h" | |
37 #include "disptab.h" | |
38 #include "indent.h" | |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
39 #include "intervals.h" |
314 | 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 |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3525
diff
changeset
|
120 store collectible objects in any of its fields! |
986
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) |
3517
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
205 if (FRAME_VISIBLE_P (XFRAME (frame))) |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
206 Fredraw_frame (frame); |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
207 |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
208 return Qnil; |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
209 } |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
210 |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
211 /* This is used when frame_garbaged is set. |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
212 Redraw the individual frames marked as garbaged. */ |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
213 |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
214 void |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
215 redraw_garbaged_frames () |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
216 { |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
217 Lisp_Object tail, frame; |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
218 |
657a74662346
(Fredraw_display): Redraw all visible frames.
Richard M. Stallman <rms@gnu.org>
parents:
3449
diff
changeset
|
219 FOR_EACH_FRAME (tail, frame) |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
220 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
|
221 && 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
|
222 Fredraw_frame (frame); |
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], |
2930
839f3d132ee0
* dispnew.c (preserve_other_columns): Remember to multiply the
Jim Blandy <jimb@redhat.com>
parents:
2794
diff
changeset
|
750 desired_frame->glyphs[vpos], |
839f3d132ee0
* dispnew.c (preserve_other_columns): Remember to multiply the
Jim Blandy <jimb@redhat.com>
parents:
2794
diff
changeset
|
751 start * sizeof (current_frame->glyphs[vpos])); |
764 | 752 len = min (start, current_frame->used[vpos]); |
753 if (desired_frame->used[vpos] < len) | |
754 desired_frame->used[vpos] = len; | |
314 | 755 } |
764 | 756 if (current_frame->used[vpos] > end |
757 && desired_frame->used[vpos] < current_frame->used[vpos]) | |
314 | 758 { |
764 | 759 while (desired_frame->used[vpos] < end) |
760 desired_frame->glyphs[vpos][desired_frame->used[vpos]++] | |
314 | 761 = SPACEGLYPH; |
764 | 762 bcopy (current_frame->glyphs[vpos] + end, |
763 desired_frame->glyphs[vpos] + end, | |
2930
839f3d132ee0
* dispnew.c (preserve_other_columns): Remember to multiply the
Jim Blandy <jimb@redhat.com>
parents:
2794
diff
changeset
|
764 ((current_frame->used[vpos] - end) |
839f3d132ee0
* dispnew.c (preserve_other_columns): Remember to multiply the
Jim Blandy <jimb@redhat.com>
parents:
2794
diff
changeset
|
765 * sizeof (current_frame->glyphs[vpos]))); |
764 | 766 desired_frame->used[vpos] = current_frame->used[vpos]; |
314 | 767 } |
768 } | |
769 } | |
770 } | |
771 | |
772 #if 0 | |
773 | |
764 | 774 /* If window w does not need to be updated and isn't the full frame wide, |
314 | 775 copy all the columns that w does occupy |
764 | 776 into the FRAME_DESIRED_LINES (frame) from the FRAME_PHYS_LINES (frame) |
777 so that update_frame will not change those columns. | |
314 | 778 |
779 Have not been able to figure out how to use this correctly. */ | |
780 | |
781 preserve_my_columns (w) | |
782 struct window *w; | |
783 { | |
784 register int vpos, fin; | |
764 | 785 register struct frame_glyphs *l1, *l2; |
786 register FRAME_PTR frame = XFRAME (w->frame); | |
314 | 787 int start = XFASTINT (w->left); |
788 int end = XFASTINT (w->left) + XFASTINT (w->width); | |
789 int bot = XFASTINT (w->top) + XFASTINT (w->height); | |
790 | |
791 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) | |
792 { | |
764 | 793 if ((l1 = FRAME_DESIRED_GLYPHS (frame)->glyphs[vpos + 1]) |
794 && (l2 = FRAME_PHYS_GLYPHS (frame)->glyphs[vpos + 1])) | |
314 | 795 { |
796 if (l2->length > start && l1->length < l2->length) | |
797 { | |
798 fin = l2->length; | |
799 if (fin > end) fin = end; | |
800 while (l1->length < start) | |
801 l1->body[l1->length++] = ' '; | |
802 bcopy (l2->body + start, l1->body + start, fin - start); | |
803 l1->length = fin; | |
804 } | |
805 } | |
806 } | |
807 } | |
808 | |
809 #endif | |
810 | |
811 /* On discovering that the redisplay for a window was no good, | |
812 cancel the columns of that window, so that when the window is | |
813 displayed over again get_display_line will not complain. */ | |
814 | |
815 cancel_my_columns (w) | |
816 struct window *w; | |
817 { | |
818 register int vpos; | |
764 | 819 register struct frame_glyphs *desired_glyphs = |
820 FRAME_DESIRED_GLYPHS (XFRAME (w->frame)); | |
314 | 821 register int start = XFASTINT (w->left); |
822 register int bot = XFASTINT (w->top) + XFASTINT (w->height); | |
823 | |
824 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) | |
825 if (desired_glyphs->enable[vpos] | |
826 && desired_glyphs->used[vpos] >= start) | |
827 desired_glyphs->used[vpos] = start; | |
828 } | |
829 | |
764 | 830 /* These functions try to perform directly and immediately on the frame |
314 | 831 the necessary output for one change in the buffer. |
832 They may return 0 meaning nothing was done if anything is difficult, | |
833 or 1 meaning the output was performed properly. | |
764 | 834 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
|
835 change being displayed. They make various other assumptions too; |
314 | 836 see command_loop_1 where these are called. */ |
837 | |
838 int | |
839 direct_output_for_insert (g) | |
840 int g; | |
841 { | |
764 | 842 register FRAME_PTR frame = selected_frame; |
843 register struct frame_glyphs *current_frame | |
844 = FRAME_CURRENT_GLYPHS (frame); | |
314 | 845 |
846 #ifndef COMPILER_REGISTER_BUG | |
847 register | |
848 #endif /* COMPILER_REGISTER_BUG */ | |
849 struct window *w = XWINDOW (selected_window); | |
850 #ifndef COMPILER_REGISTER_BUG | |
851 register | |
852 #endif /* COMPILER_REGISTER_BUG */ | |
764 | 853 int hpos = FRAME_CURSOR_X (frame); |
314 | 854 #ifndef COMPILER_REGISTER_BUG |
855 register | |
856 #endif /* COMPILER_REGISTER_BUG */ | |
764 | 857 int vpos = FRAME_CURSOR_Y (frame); |
314 | 858 |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
859 /* Give up if about to continue line. */ |
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
860 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
|
861 |
314 | 862 /* Avoid losing if cursor is in invisible text off left margin */ |
863 || (XINT (w->hscroll) && hpos == XFASTINT (w->left)) | |
864 | |
865 /* 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
|
866 || cursor_in_echo_area |
764 | 867 || FRAME_CURSOR_Y (frame) < XFASTINT (w->top) |
868 || FRAME_CURSOR_Y (frame) >= XFASTINT (w->top) + XFASTINT (w->height) | |
314 | 869 |
764 | 870 /* Give up if cursor not really at FRAME_CURSOR_X, FRAME_CURSOR_Y */ |
314 | 871 || !display_completed |
872 | |
873 /* Give up if buffer appears in two places. */ | |
874 || buffer_shared > 1 | |
875 | |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
876 #ifdef USE_TEXT_PROPERTIES |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
877 /* Intervals have already been adjusted, point is after the |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
878 character that was just inserted. */ |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
879 /* Give up if character has is invisible. */ |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
880 /* Give up if character has a face property. |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
881 At the moment we only lose at end of line or end of buffer |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
882 and only with faces that have some background */ |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
883 /* Instead of wasting time, give up if character has any text properties */ |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
884 || ! NILP (Ftext_properties_at (XFASTINT (point - 1), Qnil)) |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
885 #endif |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
886 |
314 | 887 /* Give up if w is minibuffer and a message is being displayed there */ |
888 || (MINI_WINDOW_P (w) && echo_area_glyphs)) | |
889 return 0; | |
890 | |
2778
071fa2f469d7
* dispnew.c (direct_output_for_insert): Compute the face of the
Jim Blandy <jimb@redhat.com>
parents:
2648
diff
changeset
|
891 { |
071fa2f469d7
* dispnew.c (direct_output_for_insert): Compute the face of the
Jim Blandy <jimb@redhat.com>
parents:
2648
diff
changeset
|
892 #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
|
893 int dummy; |
4134
6bd55acfe9b5
* dispnew.c (direct_output_for_insert): By the time this function
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
894 int face = compute_char_face (frame, w, point - 1, -1, -1, &dummy); |
2778
071fa2f469d7
* dispnew.c (direct_output_for_insert): Compute the face of the
Jim Blandy <jimb@redhat.com>
parents:
2648
diff
changeset
|
895 #else |
071fa2f469d7
* dispnew.c (direct_output_for_insert): Compute the face of the
Jim Blandy <jimb@redhat.com>
parents:
2648
diff
changeset
|
896 int face = 0; |
071fa2f469d7
* dispnew.c (direct_output_for_insert): Compute the face of the
Jim Blandy <jimb@redhat.com>
parents:
2648
diff
changeset
|
897 #endif |
071fa2f469d7
* dispnew.c (direct_output_for_insert): Compute the face of the
Jim Blandy <jimb@redhat.com>
parents:
2648
diff
changeset
|
898 |
071fa2f469d7
* dispnew.c (direct_output_for_insert): Compute the face of the
Jim Blandy <jimb@redhat.com>
parents:
2648
diff
changeset
|
899 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
|
900 } |
314 | 901 unchanged_modified = MODIFF; |
902 beg_unchanged = GPT - BEG; | |
903 XFASTINT (w->last_point) = point; | |
904 XFASTINT (w->last_point_x) = hpos; | |
905 XFASTINT (w->last_modified) = MODIFF; | |
906 | |
907 reassert_line_highlight (0, vpos); | |
764 | 908 write_glyphs (¤t_frame->glyphs[vpos][hpos], 1); |
314 | 909 fflush (stdout); |
764 | 910 ++FRAME_CURSOR_X (frame); |
911 if (hpos == current_frame->used[vpos]) | |
314 | 912 { |
764 | 913 current_frame->used[vpos] = hpos + 1; |
914 current_frame->glyphs[vpos][hpos + 1] = 0; | |
314 | 915 } |
916 | |
917 return 1; | |
918 } | |
919 | |
920 int | |
921 direct_output_forward_char (n) | |
922 int n; | |
923 { | |
764 | 924 register FRAME_PTR frame = selected_frame; |
314 | 925 register struct window *w = XWINDOW (selected_window); |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
926 int position; |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
927 |
543 | 928 /* Avoid losing if cursor is in invisible text off left margin |
929 or about to go off either side of window. */ | |
764 | 930 if ((FRAME_CURSOR_X (frame) == XFASTINT (w->left) |
543 | 931 && (XINT (w->hscroll) || n < 0)) |
932 || (n > 0 | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
933 && (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
|
934 || cursor_in_echo_area) |
314 | 935 return 0; |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
936 |
2794
9163e4e4752c
(direct_output_forward_char): Just give up
Richard M. Stallman <rms@gnu.org>
parents:
2778
diff
changeset
|
937 /* Can't use direct output if highlighting a region. */ |
9163e4e4752c
(direct_output_forward_char): Just give up
Richard M. Stallman <rms@gnu.org>
parents:
2778
diff
changeset
|
938 if (!NILP (Vtransient_mark_mode) && !NILP (current_buffer->mark_active)) |
9163e4e4752c
(direct_output_forward_char): Just give up
Richard M. Stallman <rms@gnu.org>
parents:
2778
diff
changeset
|
939 return 0; |
9163e4e4752c
(direct_output_forward_char): Just give up
Richard M. Stallman <rms@gnu.org>
parents:
2778
diff
changeset
|
940 |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
941 #ifdef USE_TEXT_PROPERTIES |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
942 /* Don't use direct output next to an invisible character |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
943 since we might need to do something special. */ |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
944 |
4551
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
945 XFASTINT (position) = point; |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
946 if (XFASTINT (position) < ZV |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
947 && ! NILP (Fget_text_property (position, |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
948 Qinvisible, |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
949 Fcurrent_buffer ()))) |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
950 return; |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
951 |
4551
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
952 XFASTINT (position) = point - 1; |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
953 if (XFASTINT (position) >= BEGV |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
954 && ! NILP (Fget_text_property (position, |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
955 Qinvisible, |
1abd3007cbb6
(direct_output_forward_char): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
4384
diff
changeset
|
956 Fcurrent_buffer ()))) |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
957 return; |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
958 #endif |
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
959 |
764 | 960 FRAME_CURSOR_X (frame) += n; |
961 XFASTINT (w->last_point_x) = FRAME_CURSOR_X (frame); | |
314 | 962 XFASTINT (w->last_point) = point; |
764 | 963 cursor_to (FRAME_CURSOR_Y (frame), FRAME_CURSOR_X (frame)); |
314 | 964 fflush (stdout); |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
965 |
314 | 966 return 1; |
967 } | |
968 | |
969 static void update_line (); | |
970 | |
764 | 971 /* Update frame F based on the data in FRAME_DESIRED_GLYPHS. |
314 | 972 Value is nonzero if redisplay stopped due to pending input. |
973 FORCE nonzero means do not stop for pending input. */ | |
974 | |
975 int | |
764 | 976 update_frame (f, force, inhibit_hairy_id) |
977 FRAME_PTR f; | |
314 | 978 int force; |
979 int inhibit_hairy_id; | |
980 { | |
764 | 981 register struct frame_glyphs *current_frame = FRAME_CURRENT_GLYPHS (f); |
982 register struct frame_glyphs *desired_frame = FRAME_DESIRED_GLYPHS (f); | |
314 | 983 register int i; |
984 int pause; | |
985 int preempt_count = baud_rate / 2400 + 1; | |
986 extern input_pending; | |
987 #ifdef HAVE_X_WINDOWS | |
988 register int downto, leftmost; | |
989 #endif | |
990 | |
3357
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
991 if (preempt_count <= 0) |
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
992 preempt_count = 1; |
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
993 |
764 | 994 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
314 | 995 |
996 detect_input_pending (); | |
997 if (input_pending && !force) | |
998 { | |
999 pause = 1; | |
1000 goto do_pause; | |
1001 } | |
1002 | |
764 | 1003 update_begin (f); |
314 | 1004 |
1005 if (!line_ins_del_ok) | |
1006 inhibit_hairy_id = 1; | |
1007 | |
493 | 1008 /* See if any of the desired lines are enabled; don't compute for |
1009 i/d line if just want cursor motion. */ | |
764 | 1010 for (i = 0; i < FRAME_HEIGHT (f); i++) |
1011 if (desired_frame->enable[i]) | |
314 | 1012 break; |
1013 | |
1014 /* Try doing i/d line, if not yet inhibited. */ | |
764 | 1015 if (!inhibit_hairy_id && i < FRAME_HEIGHT (f)) |
1016 force |= scrolling (f); | |
314 | 1017 |
1018 /* Update the individual lines as needed. Do bottom line first. */ | |
1019 | |
764 | 1020 if (desired_frame->enable[FRAME_HEIGHT (f) - 1]) |
1021 update_line (f, FRAME_HEIGHT (f) - 1); | |
314 | 1022 |
1023 #ifdef HAVE_X_WINDOWS | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1024 if (FRAME_X_P (f)) |
314 | 1025 { |
764 | 1026 leftmost = downto = f->display.x->internal_border_width; |
1027 if (desired_frame->enable[0]) | |
314 | 1028 { |
764 | 1029 current_frame->top_left_x[FRAME_HEIGHT (f) - 1] = leftmost; |
1030 current_frame->top_left_y[FRAME_HEIGHT (f) - 1] | |
1031 = 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
|
1032 - current_frame->pix_height[FRAME_HEIGHT (f) - 1]; |
764 | 1033 current_frame->top_left_x[0] = leftmost; |
1034 current_frame->top_left_y[0] = downto; | |
314 | 1035 } |
1036 } | |
1037 #endif /* HAVE_X_WINDOWS */ | |
1038 | |
1039 /* Now update the rest of the lines. */ | |
764 | 1040 for (i = 0; i < FRAME_HEIGHT (f) - 1 && (force || !input_pending); i++) |
314 | 1041 { |
764 | 1042 if (desired_frame->enable[i]) |
314 | 1043 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1044 if (FRAME_TERMCAP_P (f)) |
314 | 1045 { |
1046 /* Flush out every so many lines. | |
1047 Also flush out if likely to have more than 1k buffered | |
1048 otherwise. I'm told that some telnet connections get | |
1049 really screwed by more than 1k output at once. */ | |
1050 int outq = PENDING_OUTPUT_COUNT (stdout); | |
1051 if (outq > 900 | |
1052 || (outq > 20 && ((i - 1) % preempt_count == 0))) | |
1053 { | |
1054 fflush (stdout); | |
1055 if (preempt_count == 1) | |
1056 { | |
554 | 1057 #ifdef EMACS_OUTQSIZE |
1058 if (EMACS_OUTQSIZE (0, &outq) < 0) | |
314 | 1059 /* Probably not a tty. Ignore the error and reset |
1060 * the outq count. */ | |
1061 outq = PENDING_OUTPUT_COUNT (stdout); | |
1062 #endif | |
1063 outq *= 10; | |
3357
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
1064 if (baud_rate > 0) |
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
1065 sleep (outq / baud_rate); |
314 | 1066 } |
1067 } | |
1068 if ((i - 1) % preempt_count == 0) | |
1069 detect_input_pending (); | |
1070 } | |
1071 | |
764 | 1072 update_line (f, i); |
314 | 1073 #ifdef HAVE_X_WINDOWS |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1074 if (FRAME_X_P (f)) |
314 | 1075 { |
764 | 1076 current_frame->top_left_y[i] = downto; |
1077 current_frame->top_left_x[i] = leftmost; | |
314 | 1078 } |
1079 #endif /* HAVE_X_WINDOWS */ | |
1080 } | |
1081 | |
732 | 1082 #ifdef HAVE_X_WINDOWS |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1083 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
|
1084 downto += current_frame->pix_height[i]; |
732 | 1085 #endif |
314 | 1086 } |
764 | 1087 pause = (i < FRAME_HEIGHT (f) - 1) ? i : 0; |
314 | 1088 |
1089 /* Now just clean up termcap drivers and set cursor, etc. */ | |
1090 if (!pause) | |
1091 { | |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1092 if (cursor_in_echo_area |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1093 && FRAME_HAS_MINIBUF_P (f)) |
708 | 1094 { |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1095 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
|
1096 int row, col; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1097 |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1098 if (cursor_in_echo_area < 0) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1099 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1100 row = top; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1101 col = 0; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1102 } |
708 | 1103 else |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1104 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1105 /* 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
|
1106 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
|
1107 row = FRAME_HEIGHT (f); |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1108 do |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1109 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1110 row--; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1111 if (current_frame->enable[row]) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1112 col = current_frame->used[row]; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1113 else |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1114 col = 0; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1115 } |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1116 while (row > top && col == 0); |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1117 |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1118 if (col >= FRAME_WIDTH (f)) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1119 { |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1120 col = 0; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1121 if (row < FRAME_HEIGHT (f) - 1) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1122 row++; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1123 } |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1124 } |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1125 |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1126 cursor_to (row, col); |
708 | 1127 } |
314 | 1128 else |
764 | 1129 cursor_to (FRAME_CURSOR_Y (f), max (min (FRAME_CURSOR_X (f), |
1130 FRAME_WIDTH (f) - 1), 0)); | |
314 | 1131 } |
1132 | |
764 | 1133 update_end (f); |
314 | 1134 |
1135 if (termscript) | |
1136 fflush (termscript); | |
1137 fflush (stdout); | |
1138 | |
1139 /* Here if output is preempted because input is detected. */ | |
1140 do_pause: | |
1141 | |
764 | 1142 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
314 | 1143 display_completed = !pause; |
1144 | |
764 | 1145 bzero (desired_frame->enable, FRAME_HEIGHT (f)); |
314 | 1146 return pause; |
1147 } | |
1148 | |
1149 /* Called when about to quit, to check for doing so | |
1150 at an improper time. */ | |
1151 | |
1152 void | |
1153 quit_error_check () | |
1154 { | |
764 | 1155 if (FRAME_DESIRED_GLYPHS (selected_frame) == 0) |
314 | 1156 return; |
764 | 1157 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[0]) |
314 | 1158 abort (); |
764 | 1159 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[FRAME_HEIGHT (selected_frame) - 1]) |
314 | 1160 abort (); |
1161 } | |
1162 | |
1163 /* Decide what insert/delete line to do, and do it */ | |
1164 | |
1165 extern void scrolling_1 (); | |
1166 | |
764 | 1167 scrolling (frame) |
1168 FRAME_PTR frame; | |
314 | 1169 { |
1170 int unchanged_at_top, unchanged_at_bottom; | |
1171 int window_size; | |
1172 int changed_lines; | |
764 | 1173 int *old_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); |
1174 int *new_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); | |
1175 int *draw_cost = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); | |
314 | 1176 register int i; |
764 | 1177 int free_at_end_vpos = FRAME_HEIGHT (frame); |
1178 register struct frame_glyphs *current_frame = FRAME_CURRENT_GLYPHS (frame); | |
1179 register struct frame_glyphs *desired_frame = FRAME_DESIRED_GLYPHS (frame); | |
314 | 1180 |
1181 /* Compute hash codes of all the lines. | |
1182 Also calculate number of changed lines, | |
1183 number of unchanged lines at the beginning, | |
1184 and number of unchanged lines at the end. */ | |
1185 | |
1186 changed_lines = 0; | |
1187 unchanged_at_top = 0; | |
764 | 1188 unchanged_at_bottom = FRAME_HEIGHT (frame); |
1189 for (i = 0; i < FRAME_HEIGHT (frame); i++) | |
314 | 1190 { |
1191 /* Give up on this scrolling if some old lines are not enabled. */ | |
764 | 1192 if (!current_frame->enable[i]) |
314 | 1193 return 0; |
764 | 1194 old_hash[i] = line_hash_code (current_frame, i); |
1195 if (! desired_frame->enable[i]) | |
314 | 1196 new_hash[i] = old_hash[i]; |
1197 else | |
764 | 1198 new_hash[i] = line_hash_code (desired_frame, i); |
314 | 1199 |
1200 if (old_hash[i] != new_hash[i]) | |
1201 { | |
1202 changed_lines++; | |
764 | 1203 unchanged_at_bottom = FRAME_HEIGHT (frame) - i - 1; |
314 | 1204 } |
1205 else if (i == unchanged_at_top) | |
1206 unchanged_at_top++; | |
764 | 1207 draw_cost[i] = line_draw_cost (desired_frame, i); |
314 | 1208 } |
1209 | |
1210 /* If changed lines are few, don't allow preemption, don't scroll. */ | |
1211 if (changed_lines < baud_rate / 2400 | |
764 | 1212 || unchanged_at_bottom == FRAME_HEIGHT (frame)) |
314 | 1213 return 1; |
1214 | |
764 | 1215 window_size = (FRAME_HEIGHT (frame) - unchanged_at_top |
314 | 1216 - unchanged_at_bottom); |
1217 | |
1218 if (scroll_region_ok) | |
1219 free_at_end_vpos -= unchanged_at_bottom; | |
764 | 1220 else if (memory_below_frame) |
314 | 1221 free_at_end_vpos = -1; |
1222 | |
1223 /* If large window, fast terminal and few lines in common between | |
764 | 1224 current frame and desired frame, don't bother with i/d calc. */ |
314 | 1225 if (window_size >= 18 && baud_rate > 2400 |
1226 && (window_size >= | |
1227 10 * scrolling_max_lines_saved (unchanged_at_top, | |
764 | 1228 FRAME_HEIGHT (frame) - unchanged_at_bottom, |
314 | 1229 old_hash, new_hash, draw_cost))) |
1230 return 0; | |
1231 | |
764 | 1232 scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, |
314 | 1233 draw_cost + unchanged_at_top - 1, |
1234 old_hash + unchanged_at_top - 1, | |
1235 new_hash + unchanged_at_top - 1, | |
1236 free_at_end_vpos - unchanged_at_top); | |
1237 | |
1238 return 0; | |
1239 } | |
1240 | |
1241 /* Return the offset in its buffer of the character at location col, line | |
1242 in the given window. */ | |
1243 int | |
1244 buffer_posn_from_coords (window, col, line) | |
1245 struct window *window; | |
1246 int col, line; | |
1247 { | |
1248 int window_left = XFASTINT (window->left); | |
1249 | |
1250 /* The actual width of the window is window->width less one for the | |
493 | 1251 DISP_CONTINUE_GLYPH, and less one if it's not the rightmost |
1252 window. */ | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
1253 int window_width = window_internal_width (window) - 1; |
314 | 1254 |
493 | 1255 int startp = marker_position (window->start); |
314 | 1256 |
1257 /* Since compute_motion will only operate on the current buffer, | |
1258 we need to save the old one and restore it when we're done. */ | |
1259 struct buffer *old_current_buffer = current_buffer; | |
493 | 1260 struct position *posn; |
314 | 1261 |
1262 current_buffer = XBUFFER (window->buffer); | |
1263 | |
764 | 1264 /* It would be nice if we could use FRAME_CURRENT_GLYPHS (XFRAME |
1265 (window->frame))->bufp to avoid scanning from the very top of | |
493 | 1266 the window, but it isn't maintained correctly, and I'm not even |
1267 sure I will keep it. */ | |
1268 posn = compute_motion (startp, 0, | |
1269 (window == XWINDOW (minibuf_window) && startp == 1 | |
1270 ? minibuf_prompt_width : 0), | |
3317
55066d2375b6
(buffer_posn_from_coords): Since COL is already
Richard M. Stallman <rms@gnu.org>
parents:
3192
diff
changeset
|
1271 ZV, line, col, |
493 | 1272 window_width, XINT (window->hscroll), 0); |
314 | 1273 |
1274 current_buffer = old_current_buffer; | |
1275 | |
764 | 1276 /* compute_motion considers frame points past the end of a line |
493 | 1277 to be *after* the newline, i.e. at the start of the next line. |
1278 This is reasonable, but not really what we want. So if the | |
1279 result is on a line below LINE, back it up one character. */ | |
1280 if (posn->vpos > line) | |
1281 return posn->bufpos - 1; | |
1282 else | |
1283 return posn->bufpos; | |
314 | 1284 } |
1285 | |
1286 static int | |
1287 count_blanks (r) | |
1288 register GLYPH *r; | |
1289 { | |
1290 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
|
1291 while (*p++ == SPACEGLYPH); |
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
1292 return p - r - 1; |
314 | 1293 } |
1294 | |
1295 static int | |
1296 count_match (str1, str2) | |
1297 GLYPH *str1, *str2; | |
1298 { | |
1299 register GLYPH *p1 = str1; | |
1300 register GLYPH *p2 = str2; | |
1301 while (*p1++ == *p2++); | |
1302 return p1 - str1 - 1; | |
1303 } | |
1304 | |
1305 /* Char insertion/deletion cost vector, from term.c */ | |
1306 extern int *char_ins_del_vector; | |
1307 | |
1849
23ab36427257
(char_ins_del_cost): Use FRAME_WIDTH, not FRAME_HEIGHT.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
1308 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH((f))]) |
314 | 1309 |
1310 static void | |
764 | 1311 update_line (frame, vpos) |
1312 register FRAME_PTR frame; | |
314 | 1313 int vpos; |
1314 { | |
1315 register GLYPH *obody, *nbody, *op1, *op2, *np1, *temp; | |
1316 int tem; | |
1317 int osp, nsp, begmatch, endmatch, olen, nlen; | |
1318 int save; | |
764 | 1319 register struct frame_glyphs *current_frame |
1320 = FRAME_CURRENT_GLYPHS (frame); | |
1321 register struct frame_glyphs *desired_frame | |
1322 = FRAME_DESIRED_GLYPHS (frame); | |
314 | 1323 |
764 | 1324 if (desired_frame->highlight[vpos] |
1325 != (current_frame->enable[vpos] && current_frame->highlight[vpos])) | |
314 | 1326 { |
764 | 1327 change_line_highlight (desired_frame->highlight[vpos], vpos, |
1328 (current_frame->enable[vpos] ? | |
1329 current_frame->used[vpos] : 0)); | |
1330 current_frame->enable[vpos] = 0; | |
314 | 1331 } |
1332 else | |
764 | 1333 reassert_line_highlight (desired_frame->highlight[vpos], vpos); |
314 | 1334 |
764 | 1335 if (! current_frame->enable[vpos]) |
314 | 1336 { |
1337 olen = 0; | |
1338 } | |
1339 else | |
1340 { | |
764 | 1341 obody = current_frame->glyphs[vpos]; |
1342 olen = current_frame->used[vpos]; | |
1343 if (! current_frame->highlight[vpos]) | |
314 | 1344 { |
1345 if (!must_write_spaces) | |
1346 while (obody[olen - 1] == SPACEGLYPH && olen > 0) | |
1347 olen--; | |
1348 } | |
1349 else | |
1350 { | |
1351 /* For an inverse-video line, remember we gave it | |
764 | 1352 spaces all the way to the frame edge |
314 | 1353 so that the reverse video extends all the way across. */ |
1354 | |
764 | 1355 while (olen < FRAME_WIDTH (frame) - 1) |
314 | 1356 obody[olen++] = SPACEGLYPH; |
1357 } | |
1358 } | |
1359 | |
1360 /* One way or another, this will enable the line being updated. */ | |
764 | 1361 current_frame->enable[vpos] = 1; |
1362 current_frame->used[vpos] = desired_frame->used[vpos]; | |
1363 current_frame->highlight[vpos] = desired_frame->highlight[vpos]; | |
1364 current_frame->bufp[vpos] = desired_frame->bufp[vpos]; | |
314 | 1365 |
1366 #ifdef HAVE_X_WINDOWS | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1367 if (FRAME_X_P (frame)) |
314 | 1368 { |
764 | 1369 current_frame->pix_width[vpos] |
1370 = current_frame->used[vpos] | |
1371 * FONT_WIDTH (frame->display.x->font); | |
1372 current_frame->pix_height[vpos] | |
1373 = FONT_HEIGHT (frame->display.x->font); | |
314 | 1374 } |
1375 #endif /* HAVE_X_WINDOWS */ | |
1376 | |
764 | 1377 if (!desired_frame->enable[vpos]) |
314 | 1378 { |
1379 nlen = 0; | |
1380 goto just_erase; | |
1381 } | |
1382 | |
764 | 1383 nbody = desired_frame->glyphs[vpos]; |
1384 nlen = desired_frame->used[vpos]; | |
314 | 1385 |
1386 /* Pretend trailing spaces are not there at all, | |
1387 unless for one reason or another we must write all spaces. */ | |
764 | 1388 if (! desired_frame->highlight[vpos]) |
314 | 1389 { |
1390 if (!must_write_spaces) | |
1391 /* We know that the previous character byte contains 0. */ | |
1392 while (nbody[nlen - 1] == SPACEGLYPH) | |
1393 nlen--; | |
1394 } | |
1395 else | |
1396 { | |
1397 /* For an inverse-video line, give it extra trailing spaces | |
764 | 1398 all the way to the frame edge |
314 | 1399 so that the reverse video extends all the way across. */ |
1400 | |
764 | 1401 while (nlen < FRAME_WIDTH (frame) - 1) |
314 | 1402 nbody[nlen++] = SPACEGLYPH; |
1403 } | |
1404 | |
1405 /* If there's no i/d char, quickly do the best we can without it. */ | |
1406 if (!char_ins_del_ok) | |
1407 { | |
1408 int i,j; | |
1409 | |
4276
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1410 #if 0 |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1411 if (FRAME_X_P (frame)) |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1412 { |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1413 /* Under X, erase everything we are going to rewrite, |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1414 and rewrite everything from the first char that's changed. |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1415 This is part of supporting fonts like Courier |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1416 whose chars can overlap outside the char width. */ |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1417 for (i = 0; i < nlen; i++) |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1418 if (i >= olen || nbody[i] != obody[i]) |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1419 break; |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1420 |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1421 cursor_to (vpos, i); |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1422 if (i != olen) |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1423 clear_end_of_line (olen); |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1424 write_glyphs (nbody + i, nlen - i); |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1425 } |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1426 else |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1427 {} |
2298d2aff61c
Commented-out code added.
Richard M. Stallman <rms@gnu.org>
parents:
4134
diff
changeset
|
1428 #endif /* 0 */ |
314 | 1429 for (i = 0; i < nlen; i++) |
1430 { | |
1431 if (i >= olen || nbody[i] != obody[i]) /* A non-matching char. */ | |
1432 { | |
1433 cursor_to (vpos, i); | |
1434 for (j = 1; (i + j < nlen && | |
1435 (i + j >= olen || nbody[i+j] != obody[i+j])); | |
1436 j++); | |
1437 | |
1438 /* Output this run of non-matching chars. */ | |
1439 write_glyphs (nbody + i, j); | |
1440 i += j - 1; | |
1441 | |
1442 /* Now find the next non-match. */ | |
1443 } | |
1444 } | |
1445 | |
1446 /* Clear the rest of the line, or the non-clear part of it. */ | |
1447 if (olen > nlen) | |
1448 { | |
1449 cursor_to (vpos, nlen); | |
1450 clear_end_of_line (olen); | |
1451 } | |
1452 | |
764 | 1453 /* Exchange contents between current_frame and new_frame. */ |
1454 temp = desired_frame->glyphs[vpos]; | |
1455 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | |
1456 current_frame->glyphs[vpos] = temp; | |
314 | 1457 |
1458 return; | |
1459 } | |
1460 | |
1461 if (!olen) | |
1462 { | |
764 | 1463 nsp = (must_write_spaces || desired_frame->highlight[vpos]) |
314 | 1464 ? 0 : count_blanks (nbody); |
1465 if (nlen > nsp) | |
1466 { | |
1467 cursor_to (vpos, nsp); | |
1468 write_glyphs (nbody + nsp, nlen - nsp); | |
1469 } | |
1470 | |
764 | 1471 /* Exchange contents between current_frame and new_frame. */ |
1472 temp = desired_frame->glyphs[vpos]; | |
1473 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | |
1474 current_frame->glyphs[vpos] = temp; | |
314 | 1475 |
1476 return; | |
1477 } | |
1478 | |
1479 obody[olen] = 1; | |
1480 save = nbody[nlen]; | |
1481 nbody[nlen] = 0; | |
1482 | |
1483 /* Compute number of leading blanks in old and new contents. */ | |
1484 osp = count_blanks (obody); | |
764 | 1485 if (!desired_frame->highlight[vpos]) |
314 | 1486 nsp = count_blanks (nbody); |
1487 else | |
1488 nsp = 0; | |
1489 | |
1490 /* Compute number of matching chars starting with first nonblank. */ | |
1491 begmatch = count_match (obody + osp, nbody + nsp); | |
1492 | |
1493 /* Spaces in new match implicit space past the end of old. */ | |
1494 /* A bug causing this to be a no-op was fixed in 18.29. */ | |
1495 if (!must_write_spaces && osp + begmatch == olen) | |
1496 { | |
1497 np1 = nbody + nsp; | |
1498 while (np1[begmatch] == SPACEGLYPH) | |
1499 begmatch++; | |
1500 } | |
1501 | |
1502 /* Avoid doing insert/delete char | |
1503 just cause number of leading spaces differs | |
1504 when the following text does not match. */ | |
1505 if (begmatch == 0 && osp != nsp) | |
1506 osp = nsp = min (osp, nsp); | |
1507 | |
1508 /* Find matching characters at end of line */ | |
1509 op1 = obody + olen; | |
1510 np1 = nbody + nlen; | |
1511 op2 = op1 + begmatch - min (olen - osp, nlen - nsp); | |
1512 while (op1 > op2 && op1[-1] == np1[-1]) | |
1513 { | |
1514 op1--; | |
1515 np1--; | |
1516 } | |
1517 endmatch = obody + olen - op1; | |
1518 | |
1519 /* Put correct value back in nbody[nlen]. | |
1520 This is important because direct_output_for_insert | |
1521 can write into the line at a later point. | |
1522 If this screws up the zero at the end of the line, re-establish it. */ | |
1523 nbody[nlen] = save; | |
1524 obody[olen] = 0; | |
1525 | |
1526 /* tem gets the distance to insert or delete. | |
1527 endmatch is how many characters we save by doing so. | |
1528 Is it worth it? */ | |
1529 | |
1530 tem = (nlen - nsp) - (olen - osp); | |
1531 if (endmatch && tem | |
764 | 1532 && (!char_ins_del_ok || endmatch <= char_ins_del_cost (frame)[tem])) |
314 | 1533 endmatch = 0; |
1534 | |
1535 /* nsp - osp is the distance to insert or delete. | |
1536 If that is nonzero, begmatch is known to be nonzero also. | |
1537 begmatch + endmatch is how much we save by doing the ins/del. | |
1538 Is it worth it? */ | |
1539 | |
1540 if (nsp != osp | |
1541 && (!char_ins_del_ok | |
764 | 1542 || begmatch + endmatch <= char_ins_del_cost (frame)[nsp - osp])) |
314 | 1543 { |
1544 begmatch = 0; | |
1545 endmatch = 0; | |
1546 osp = nsp = min (osp, nsp); | |
1547 } | |
1548 | |
1549 /* Now go through the line, inserting, writing and | |
1550 deleting as appropriate. */ | |
1551 | |
1552 if (osp > nsp) | |
1553 { | |
1554 cursor_to (vpos, nsp); | |
1555 delete_glyphs (osp - nsp); | |
1556 } | |
1557 else if (nsp > osp) | |
1558 { | |
1559 /* If going to delete chars later in line | |
1560 and insert earlier in the line, | |
1561 must delete first to avoid losing data in the insert */ | |
1562 if (endmatch && nlen < olen + nsp - osp) | |
1563 { | |
1564 cursor_to (vpos, nlen - endmatch + osp - nsp); | |
1565 delete_glyphs (olen + nsp - osp - nlen); | |
1566 olen = nlen - (nsp - osp); | |
1567 } | |
1568 cursor_to (vpos, osp); | |
1569 insert_glyphs ((char *)0, nsp - osp); | |
1570 } | |
1571 olen += nsp - osp; | |
1572 | |
1573 tem = nsp + begmatch + endmatch; | |
1574 if (nlen != tem || olen != tem) | |
1575 { | |
1576 cursor_to (vpos, nsp + begmatch); | |
1577 if (!endmatch || nlen == olen) | |
1578 { | |
1579 /* If new text being written reaches right margin, | |
1580 there is no need to do clear-to-eol at the end. | |
1581 (and it would not be safe, since cursor is not | |
1582 going to be "at the margin" after the text is done) */ | |
764 | 1583 if (nlen == FRAME_WIDTH (frame)) |
314 | 1584 olen = 0; |
1585 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
1586 | |
1587 #ifdef obsolete | |
1588 | |
1589 /* the following code loses disastrously if tem == nlen. | |
1590 Rather than trying to fix that case, I am trying the simpler | |
1591 solution found above. */ | |
1592 | |
1593 /* If the text reaches to the right margin, | |
1594 it will lose one way or another (depending on AutoWrap) | |
1595 to clear to end of line after outputting all the text. | |
1596 So pause with one character to go and clear the line then. */ | |
764 | 1597 if (nlen == FRAME_WIDTH (frame) && fast_clear_end_of_line && olen > nlen) |
314 | 1598 { |
1599 /* endmatch must be zero, and tem must equal nsp + begmatch */ | |
1600 write_glyphs (nbody + tem, nlen - tem - 1); | |
1601 clear_end_of_line (olen); | |
1602 olen = 0; /* Don't let it be cleared again later */ | |
1603 write_glyphs (nbody + nlen - 1, 1); | |
1604 } | |
1605 else | |
1606 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
1607 #endif /* OBSOLETE */ | |
1608 | |
1609 } | |
1610 else if (nlen > olen) | |
1611 { | |
1612 write_glyphs (nbody + nsp + begmatch, olen - tem); | |
1613 insert_glyphs (nbody + nsp + begmatch + olen - tem, nlen - olen); | |
1614 olen = nlen; | |
1615 } | |
1616 else if (olen > nlen) | |
1617 { | |
1618 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
1619 delete_glyphs (olen - nlen); | |
1620 olen = nlen; | |
1621 } | |
1622 } | |
1623 | |
1624 just_erase: | |
1625 /* If any unerased characters remain after the new line, erase them. */ | |
1626 if (olen > nlen) | |
1627 { | |
1628 cursor_to (vpos, nlen); | |
1629 clear_end_of_line (olen); | |
1630 } | |
1631 | |
764 | 1632 /* Exchange contents between current_frame and new_frame. */ |
1633 temp = desired_frame->glyphs[vpos]; | |
1634 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | |
1635 current_frame->glyphs[vpos] = temp; | |
314 | 1636 } |
1637 | |
1638 DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript, | |
1639 1, 1, "FOpen termscript file: ", | |
1640 "Start writing all terminal output to FILE as well as the terminal.\n\ | |
1641 FILE = nil means just close any termscript file currently open.") | |
1642 (file) | |
1643 Lisp_Object file; | |
1644 { | |
1645 if (termscript != 0) fclose (termscript); | |
1646 termscript = 0; | |
1647 | |
493 | 1648 if (! NILP (file)) |
314 | 1649 { |
1650 file = Fexpand_file_name (file, Qnil); | |
1651 termscript = fopen (XSTRING (file)->data, "w"); | |
1652 if (termscript == 0) | |
1653 report_file_error ("Opening termscript", Fcons (file, Qnil)); | |
1654 } | |
1655 return Qnil; | |
1656 } | |
1657 | |
1658 | |
1659 #ifdef SIGWINCH | |
493 | 1660 SIGTYPE |
314 | 1661 window_change_signal () |
1662 { | |
1663 int width, height; | |
1664 extern int errno; | |
1665 int old_errno = errno; | |
1666 | |
764 | 1667 get_frame_size (&width, &height); |
314 | 1668 |
764 | 1669 /* The frame size change obviously applies to a termcap-controlled |
1670 frame. Find such a frame in the list, and assume it's the only | |
314 | 1671 one (since the redisplay code always writes to stdout, not a |
764 | 1672 FILE * specified in the frame structure). Record the new size, |
314 | 1673 but don't reallocate the data structures now. Let that be done |
1674 later outside of the signal handler. */ | |
1675 | |
1676 { | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1677 Lisp_Object tail, frame; |
314 | 1678 |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1679 FOR_EACH_FRAME (tail, frame) |
314 | 1680 { |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1681 if (FRAME_TERMCAP_P (XFRAME (frame))) |
314 | 1682 { |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1683 change_frame_size (XFRAME (frame), height, width, 0, 1); |
314 | 1684 break; |
1685 } | |
1686 } | |
1687 } | |
1688 | |
1689 signal (SIGWINCH, window_change_signal); | |
1690 errno = old_errno; | |
1691 } | |
1692 #endif /* SIGWINCH */ | |
1693 | |
1694 | |
764 | 1695 /* Do any change in frame size that was requested by a signal. */ |
314 | 1696 |
1697 do_pending_window_change () | |
1698 { | |
1699 /* If window_change_signal should have run before, run it now. */ | |
1700 while (delayed_size_change) | |
1701 { | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1702 Lisp_Object tail, frame; |
314 | 1703 |
1704 delayed_size_change = 0; | |
1705 | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1706 FOR_EACH_FRAME (tail, frame) |
314 | 1707 { |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1708 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
|
1709 |
764 | 1710 int height = FRAME_NEW_HEIGHT (f); |
1711 int width = FRAME_NEW_WIDTH (f); | |
314 | 1712 |
3449
ad455da9b789
(do_pending_window_change): No need to clear
Richard M. Stallman <rms@gnu.org>
parents:
3357
diff
changeset
|
1713 if (height != 0 || width != 0) |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1714 change_frame_size (f, height, width, 0, 0); |
314 | 1715 } |
1716 } | |
1717 } | |
1718 | |
1719 | |
764 | 1720 /* 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
|
1721 indicate no change is to take place. |
314 | 1722 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1723 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
|
1724 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
|
1725 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
|
1726 from a signal handler. */ |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1727 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1728 change_frame_size (frame, newheight, newwidth, pretend, delay) |
764 | 1729 register FRAME_PTR frame; |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1730 int newheight, newwidth, pretend; |
314 | 1731 { |
1732 /* 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
|
1733 if (delay) |
314 | 1734 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1735 FRAME_NEW_HEIGHT (frame) = newheight; |
764 | 1736 FRAME_NEW_WIDTH (frame) = newwidth; |
314 | 1737 delayed_size_change = 1; |
1738 return; | |
1739 } | |
1740 | |
764 | 1741 /* This size-change overrides any pending one for this frame. */ |
1742 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
|
1743 FRAME_NEW_WIDTH (frame) = 0; |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1744 |
3449
ad455da9b789
(do_pending_window_change): No need to clear
Richard M. Stallman <rms@gnu.org>
parents:
3357
diff
changeset
|
1745 /* If an argument is zero, set it to the current value. */ |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1746 newheight || (newheight = FRAME_HEIGHT (frame)); |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1747 newwidth || (newwidth = FRAME_WIDTH (frame)); |
314 | 1748 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1749 /* 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
|
1750 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
|
1751 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1752 /* 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
|
1753 if (newheight == FRAME_HEIGHT (frame) |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1754 && newwidth == FRAME_WIDTH (frame)) |
314 | 1755 return; |
1756 | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1757 if (newheight != FRAME_HEIGHT (frame)) |
314 | 1758 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1759 if (FRAME_HAS_MINIBUF_P (frame) |
764 | 1760 && ! FRAME_MINIBUF_ONLY_P (frame)) |
314 | 1761 { |
764 | 1762 /* Frame has both root and minibuffer. */ |
1763 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
|
1764 newheight - 1 - FRAME_MENU_BAR_LINES (frame), 0); |
764 | 1765 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
|
1766 = newheight - 1; |
764 | 1767 set_window_height (FRAME_MINIBUF_WINDOW (frame), 1, 0); |
314 | 1768 } |
1769 else | |
764 | 1770 /* 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
|
1771 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
|
1772 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
|
1773 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1774 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
|
1775 FrameRows = newheight; |
314 | 1776 |
1777 #if 0 | |
764 | 1778 if (frame->output_method == output_termcap) |
314 | 1779 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1780 frame_height = newheight; |
314 | 1781 if (!pretend) |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1782 FrameRows = newheight; |
314 | 1783 } |
1784 #endif | |
1785 } | |
1786 | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1787 if (newwidth != FRAME_WIDTH (frame)) |
314 | 1788 { |
764 | 1789 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
|
1790 if (FRAME_HAS_MINIBUF_P (frame)) |
764 | 1791 set_window_width (FRAME_MINIBUF_WINDOW (frame), newwidth, 0); |
314 | 1792 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1793 if (FRAME_TERMCAP_P (frame) && !pretend) |
764 | 1794 FrameCols = newwidth; |
314 | 1795 #if 0 |
764 | 1796 if (frame->output_method == output_termcap) |
314 | 1797 { |
764 | 1798 frame_width = newwidth; |
314 | 1799 if (!pretend) |
764 | 1800 FrameCols = newwidth; |
314 | 1801 } |
1802 #endif | |
1803 } | |
1804 | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1805 FRAME_HEIGHT (frame) = newheight; |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1806 FRAME_WIDTH (frame) = newwidth; |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1807 |
764 | 1808 remake_frame_glyphs (frame); |
1809 calculate_costs (frame); | |
314 | 1810 } |
1811 | |
1812 DEFUN ("send-string-to-terminal", Fsend_string_to_terminal, | |
1813 Ssend_string_to_terminal, 1, 1, 0, | |
1814 "Send STRING to the terminal without alteration.\n\ | |
1815 Control characters in STRING will have terminal-dependent effects.") | |
1816 (str) | |
1817 Lisp_Object str; | |
1818 { | |
1819 CHECK_STRING (str, 0); | |
1820 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, stdout); | |
1821 fflush (stdout); | |
1822 if (termscript) | |
1823 { | |
1824 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, termscript); | |
1825 fflush (termscript); | |
1826 } | |
1827 return Qnil; | |
1828 } | |
1829 | |
1830 DEFUN ("ding", Fding, Sding, 0, 1, 0, | |
1831 "Beep, or flash the screen.\n\ | |
1832 Also, unless an argument is given,\n\ | |
1833 terminate any keyboard macro currently executing.") | |
1834 (arg) | |
1835 Lisp_Object arg; | |
1836 { | |
493 | 1837 if (!NILP (arg)) |
314 | 1838 { |
649
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1839 if (noninteractive) |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1840 putchar (07); |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1841 else |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1842 ring_bell (); |
314 | 1843 fflush (stdout); |
1844 } | |
1845 else | |
1846 bitch_at_user (); | |
1847 | |
1848 return Qnil; | |
1849 } | |
1850 | |
1851 bitch_at_user () | |
1852 { | |
1853 if (noninteractive) | |
1854 putchar (07); | |
1855 else if (!INTERACTIVE) /* Stop executing a keyboard macro. */ | |
1856 error ("Keyboard macro terminated by a command ringing the bell"); | |
1857 else | |
1858 ring_bell (); | |
1859 fflush (stdout); | |
1860 } | |
1861 | |
1862 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
|
1863 "Pause, without updating display, for SECONDS seconds.\n\ |
2648 | 1864 SECONDS may be a floating-point value, meaning that you can wait for a\n\ |
1865 fraction of a second. Optional second arg MILLISECONDS specifies an\n\ | |
1866 additional wait period, in milliseconds; this may be useful if your\n\ | |
1867 Emacs was built without floating point support.\n\ | |
1868 \(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
|
1869 (seconds, milliseconds) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1870 Lisp_Object seconds, milliseconds; |
314 | 1871 { |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1872 int sec, usec; |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1873 |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1874 if (NILP (milliseconds)) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1875 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
|
1876 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1877 CHECK_NUMBER (milliseconds, 1); |
2648 | 1878 usec = XINT (milliseconds) * 1000; |
1879 | |
1880 #ifdef LISP_FLOAT_TYPE | |
1881 { | |
1882 double duration = extract_float (seconds); | |
1883 sec = (int) duration; | |
1884 usec += (duration - sec) * 1000000; | |
1885 } | |
1886 #else | |
1887 CHECK_NUMBER (seconds, 0); | |
1888 sec = XINT (seconds); | |
1889 #endif | |
314 | 1890 |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1891 #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
|
1892 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
|
1893 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
|
1894 #endif |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1895 |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1896 /* 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
|
1897 if (usec < 0) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1898 { |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1899 /* 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
|
1900 if (-1000000 < usec) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1901 sec--, usec += 1000000; |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1902 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1903 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
|
1904 } |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1905 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1906 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
|
1907 |
4290
885452da2a8f
(Fsleep_for): If arg is 0, return right away.
Richard M. Stallman <rms@gnu.org>
parents:
4276
diff
changeset
|
1908 if (sec <= 0) |
314 | 1909 return Qnil; |
1910 | |
650 | 1911 { |
1912 Lisp_Object zero; | |
1913 | |
1914 XFASTINT (zero) = 0; | |
1915 wait_reading_process_input (sec, usec, zero, 0); | |
1916 } | |
587 | 1917 |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1918 /* 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
|
1919 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
|
1920 #if 0 |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1921 /* No wait_reading_process_input */ |
314 | 1922 immediate_quit = 1; |
1923 QUIT; | |
1924 | |
1925 #ifdef VMS | |
1926 sys_sleep (sec); | |
1927 #else /* not VMS */ | |
1928 /* The reason this is done this way | |
1929 (rather than defined (H_S) && defined (H_T)) | |
1930 is because the VMS preprocessor doesn't grok `defined' */ | |
1931 #ifdef HAVE_SELECT | |
554 | 1932 EMACS_GET_TIME (end_time); |
1933 EMACS_SET_SECS_USECS (timeout, sec, usec); | |
587 | 1934 EMACS_ADD_TIME (end_time, end_time, timeout); |
554 | 1935 |
314 | 1936 while (1) |
1937 { | |
554 | 1938 EMACS_GET_TIME (timeout); |
1939 EMACS_SUB_TIME (timeout, end_time, timeout); | |
1940 if (EMACS_TIME_NEG_P (timeout) | |
1941 || !select (1, 0, 0, 0, &timeout)) | |
314 | 1942 break; |
1943 } | |
1944 #else /* not HAVE_SELECT */ | |
1945 sleep (sec); | |
1946 #endif /* HAVE_SELECT */ | |
1947 #endif /* not VMS */ | |
1948 | |
1949 immediate_quit = 0; | |
1950 #endif /* no subprocesses */ | |
1951 | |
1952 return Qnil; | |
1953 } | |
1954 | |
650 | 1955 /* This is just like wait_reading_process_input, except that |
1956 it does the redisplay. | |
1957 | |
1958 It's also just like Fsit_for, except that it can be used for | |
1959 waiting for input as well. */ | |
1960 | |
1961 Lisp_Object | |
1962 sit_for (sec, usec, reading, display) | |
1963 int sec, usec, reading, display; | |
314 | 1964 { |
650 | 1965 Lisp_Object read_kbd; |
314 | 1966 |
1967 if (detect_input_pending ()) | |
1968 return Qnil; | |
650 | 1969 |
1970 if (display) | |
314 | 1971 redisplay_preserve_echo_area (); |
1972 | |
673 | 1973 if (sec == 0 && usec == 0) |
1974 return Qt; | |
1975 | |
314 | 1976 #ifdef SIGIO |
1915
98ecf99d7b1a
* dispnew.c (sit_for): Pass the correct number of arguments to
Jim Blandy <jimb@redhat.com>
parents:
1872
diff
changeset
|
1977 gobble_input (0); |
650 | 1978 #endif |
1979 | |
1980 XSET (read_kbd, Lisp_Int, reading ? -1 : 1); | |
1981 wait_reading_process_input (sec, usec, read_kbd, display); | |
1982 | |
587 | 1983 |
2288
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1984 /* 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
|
1985 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
|
1986 subprocesses. */ |
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1987 #if 0 |
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1988 /* No wait_reading_process_input available. */ |
314 | 1989 immediate_quit = 1; |
1990 QUIT; | |
1991 | |
1992 waitchannels = 1; | |
1993 #ifdef VMS | |
650 | 1994 input_wait_timeout (XINT (arg)); |
314 | 1995 #else /* not VMS */ |
587 | 1996 #ifndef HAVE_TIMEVAL |
1997 timeout_sec = sec; | |
1998 select (1, &waitchannels, 0, 0, &timeout_sec); | |
1999 #else /* HAVE_TIMEVAL */ | |
2000 timeout.tv_sec = sec; | |
2001 timeout.tv_usec = usec; | |
314 | 2002 select (1, &waitchannels, 0, 0, &timeout); |
587 | 2003 #endif /* HAVE_TIMEVAL */ |
314 | 2004 #endif /* not VMS */ |
2005 | |
2006 immediate_quit = 0; | |
587 | 2007 #endif |
314 | 2008 |
2009 return detect_input_pending () ? Qnil : Qt; | |
2010 } | |
2011 | |
650 | 2012 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
|
2013 "Perform redisplay, then wait for SECONDS seconds or until input is available.\n\ |
2648 | 2014 SECONDS may be a floating-point value, meaning that you can wait for a\n\ |
2015 fraction of a second. Optional second arg MILLISECONDS specifies an\n\ | |
2016 additional wait period, in milliseconds; this may be useful if your\n\ | |
2017 Emacs was built without floating point support.\n\ | |
2018 \(Not all operating systems support waiting for a fraction of a second.)\n\ | |
650 | 2019 Optional third arg non-nil means don't redisplay, just wait for input.\n\ |
2020 Redisplay is preempted as always if input arrives, and does not happen\n\ | |
2021 if input is available before it starts.\n\ | |
2022 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
|
2023 (seconds, milliseconds, nodisp) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
2024 Lisp_Object seconds, milliseconds, nodisp; |
650 | 2025 { |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
2026 int sec, usec; |
650 | 2027 |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
2028 if (NILP (milliseconds)) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
2029 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
|
2030 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
2031 CHECK_NUMBER (milliseconds, 1); |
2648 | 2032 usec = XINT (milliseconds) * 1000; |
2033 | |
2034 #ifdef LISP_FLOAT_TYPE | |
2035 { | |
2036 double duration = extract_float (seconds); | |
2037 sec = (int) duration; | |
2038 usec += (duration - sec) * 1000000; | |
2039 } | |
2040 #else | |
2041 CHECK_NUMBER (seconds, 0); | |
2042 sec = XINT (seconds); | |
2043 #endif | |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
2044 |
650 | 2045 #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
|
2046 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
|
2047 error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); |
650 | 2048 #endif |
2049 | |
2050 return sit_for (sec, usec, 0, NILP (nodisp)); | |
2051 } | |
314 | 2052 |
2053 char *terminal_type; | |
2054 | |
2055 /* Initialization done when Emacs fork is started, before doing stty. */ | |
2056 /* Determine terminal type and set terminal_driver */ | |
2057 /* Then invoke its decoding routine to set up variables | |
2058 in the terminal package */ | |
2059 | |
2060 init_display () | |
2061 { | |
2062 #ifdef HAVE_X_WINDOWS | |
2063 extern int display_arg; | |
2064 #endif | |
2065 | |
2066 meta_key = 0; | |
2067 inverse_video = 0; | |
2068 cursor_in_echo_area = 0; | |
2069 terminal_type = (char *) 0; | |
2070 | |
2339
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
2071 /* 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
|
2072 during startup. */ |
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
2073 Vwindow_system = Qnil; |
314 | 2074 |
2339
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
2075 /* 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
|
2076 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
|
2077 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
|
2078 using the window system. |
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
2079 |
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
2080 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
|
2081 with an error message if that doesn't work. */ |
314 | 2082 |
2083 #ifdef HAVE_X_WINDOWS | |
2359
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
2084 if (! display_arg) |
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
2085 { |
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
2086 #ifdef VMS |
2511
4fc5338ebb8f
* dispnew.c (getenv): Extern declaration deleted; this is done in
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
2087 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
|
2088 #else |
2511
4fc5338ebb8f
* dispnew.c (getenv): Extern declaration deleted; this is done in
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
2089 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
|
2090 #endif |
2364 | 2091 } |
2359
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
2092 |
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
2093 if (!inhibit_window_system && display_arg) |
314 | 2094 { |
2095 Vwindow_system = intern ("x"); | |
2096 #ifdef HAVE_X11 | |
2097 Vwindow_system_version = make_number (11); | |
2098 #else | |
2099 Vwindow_system_version = make_number (10); | |
2100 #endif | |
2101 return; | |
2102 } | |
2103 #endif /* HAVE_X_WINDOWS */ | |
2104 | |
2105 /* If no window system has been specified, try to use the terminal. */ | |
2106 if (! isatty (0)) | |
2107 { | |
2108 fprintf (stderr, "emacs: standard input is not a tty\n"); | |
2109 exit (1); | |
2110 } | |
2111 | |
2112 /* Look at the TERM variable */ | |
2113 terminal_type = (char *) getenv ("TERM"); | |
2114 if (!terminal_type) | |
2115 { | |
2116 #ifdef VMS | |
2117 fprintf (stderr, "Please specify your terminal type.\n\ | |
2118 For types defined in VMS, use set term /device=TYPE.\n\ | |
2119 For types not defined in VMS, use define emacs_term \"TYPE\".\n\ | |
2120 \(The quotation marks are necessary since terminal types are lower case.)\n"); | |
2121 #else | |
2122 fprintf (stderr, "Please set the environment variable TERM; see tset(1).\n"); | |
2123 #endif | |
2124 exit (1); | |
2125 } | |
2126 | |
2127 #ifdef VMS | |
2128 /* VMS DCL tends to upcase things, so downcase term type. | |
2129 Hardly any uppercase letters in terminal types; should be none. */ | |
2130 { | |
2131 char *new = (char *) xmalloc (strlen (terminal_type) + 1); | |
2132 char *p; | |
2133 | |
2134 strcpy (new, terminal_type); | |
2135 | |
2136 for (p = new; *p; p++) | |
2137 if (isupper (*p)) | |
2138 *p = tolower (*p); | |
2139 | |
2140 terminal_type = new; | |
2141 } | |
2142 #endif | |
2143 | |
2144 term_init (terminal_type); | |
2145 | |
764 | 2146 remake_frame_glyphs (selected_frame); |
2147 calculate_costs (selected_frame); | |
314 | 2148 |
2149 /* X and Y coordinates of the cursor between updates. */ | |
764 | 2150 FRAME_CURSOR_X (selected_frame) = 0; |
2151 FRAME_CURSOR_Y (selected_frame) = 0; | |
314 | 2152 |
2153 #ifdef SIGWINCH | |
2154 #ifndef CANNOT_DUMP | |
2155 if (initialized) | |
2156 #endif /* CANNOT_DUMP */ | |
2157 signal (SIGWINCH, window_change_signal); | |
2158 #endif /* SIGWINCH */ | |
2159 } | |
2160 | |
2161 syms_of_display () | |
2162 { | |
764 | 2163 #ifdef MULTI_FRAME |
2164 defsubr (&Sredraw_frame); | |
314 | 2165 #endif |
2166 defsubr (&Sredraw_display); | |
2167 defsubr (&Sopen_termscript); | |
2168 defsubr (&Sding); | |
2169 defsubr (&Ssit_for); | |
2170 defsubr (&Ssleep_for); | |
2171 defsubr (&Ssend_string_to_terminal); | |
2172 | |
2173 DEFVAR_INT ("baud-rate", &baud_rate, | |
2174 "The output baud rate of the terminal.\n\ | |
2175 On most systems, changing this value will affect the amount of padding\n\ | |
2176 and the other strategic decisions made during redisplay."); | |
2177 DEFVAR_BOOL ("inverse-video", &inverse_video, | |
764 | 2178 "*Non-nil means invert the entire frame display.\n\ |
314 | 2179 This means everything is in inverse video which otherwise would not be."); |
2180 DEFVAR_BOOL ("visible-bell", &visible_bell, | |
764 | 2181 "*Non-nil means try to flash the frame to represent a bell."); |
314 | 2182 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter, |
764 | 2183 "*Non-nil means no need to redraw entire frame after suspending.\n\ |
314 | 2184 A non-nil value is useful if the terminal can automatically preserve\n\ |
764 | 2185 Emacs's frame display when you reenter Emacs.\n\ |
314 | 2186 It is up to you to set this variable if your terminal can do that."); |
2187 DEFVAR_LISP ("window-system", &Vwindow_system, | |
2188 "A symbol naming the window-system under which Emacs is running\n\ | |
2189 \(such as `x'), or nil if emacs is running on an ordinary terminal."); | |
2190 DEFVAR_LISP ("window-system-version", &Vwindow_system_version, | |
2191 "The version number of the window system in use.\n\ | |
2192 For X windows, this is 10 or 11."); | |
2193 DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area, | |
2194 "Non-nil means put cursor in minibuffer, at end of any message there."); | |
2195 DEFVAR_LISP ("glyph-table", &Vglyph_table, | |
764 | 2196 "Table defining how to output a glyph code to the frame.\n\ |
314 | 2197 If not nil, this is a vector indexed by glyph code to define the glyph.\n\ |
2198 Each element can be:\n\ | |
2199 integer: a glyph code which this glyph is an alias for.\n\ | |
2200 string: output this glyph using that string (not impl. in X windows).\n\ | |
2201 nil: this glyph mod 256 is char code to output,\n\ | |
2202 and this glyph / 256 is face code for X windows (see `x-set-face')."); | |
2203 Vglyph_table = Qnil; | |
2204 | |
2205 DEFVAR_LISP ("standard-display-table", &Vstandard_display_table, | |
2206 "Display table to use for buffers that specify none.\n\ | |
2207 See `buffer-display-table' for more information."); | |
2208 Vstandard_display_table = Qnil; | |
2209 | |
2210 /* Initialize `window-system', unless init_display already decided it. */ | |
2211 #ifdef CANNOT_DUMP | |
2212 if (noninteractive) | |
2213 #endif | |
2214 { | |
2215 Vwindow_system = Qnil; | |
2216 Vwindow_system_version = Qnil; | |
2217 } | |
2218 } | |
2219 |