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