Mercurial > emacs
annotate src/dispnew.c @ 34851:452349a9192a
(init_from_display_pos): Pop until the iterator's
stack is empty; there may be frames for stretch or images
on the stack.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sat, 23 Dec 2000 19:23:02 +0000 |
parents | eac70be4cb58 |
children | 4f47fc699608 |
rev | line source |
---|---|
314 | 1 /* Updating of data structures for redisplay. |
33596
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 97, 98, 1999, 2000 |
18853
4501a367a887
(direct_output_forward_char): Reenable check against
Richard M. Stallman <rms@gnu.org>
parents:
18774
diff
changeset
|
3 Free Software Foundation, Inc. |
314 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
314 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14125
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14125
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
314 | 21 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25781
diff
changeset
|
22 #include <config.h> |
314 | 23 #include <signal.h> |
7900
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7814
diff
changeset
|
24 #include <stdio.h> |
314 | 25 #include <ctype.h> |
26 | |
21514 | 27 #ifdef HAVE_UNISTD_H |
28 #include <unistd.h> | |
29 #endif | |
30 | |
3525
58e789baa27a
Include lisp.h earlier (before termhooks.h).
Richard M. Stallman <rms@gnu.org>
parents:
3517
diff
changeset
|
31 #include "lisp.h" |
314 | 32 #include "termchar.h" |
33 #include "termopts.h" | |
2198 | 34 #include "termhooks.h" |
13526
34382f4e23cb
Always include dispextern.h before cm.h.
Richard M. Stallman <rms@gnu.org>
parents:
13448
diff
changeset
|
35 /* cm.h must come after dispextern.h on Windows. */ |
13408
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
36 #include "dispextern.h" |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
37 #include "cm.h" |
314 | 38 #include "buffer.h" |
17015
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
39 #include "charset.h" |
31093
6da961dff718
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30720
diff
changeset
|
40 #include "keyboard.h" |
764 | 41 #include "frame.h" |
314 | 42 #include "window.h" |
43 #include "commands.h" | |
44 #include "disptab.h" | |
45 #include "indent.h" | |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
46 #include "intervals.h" |
15065 | 47 #include "blockinput.h" |
21514 | 48 #include "process.h" |
314 | 49 |
17015
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
50 /* I don't know why DEC Alpha OSF1 fail to compile this file if we |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
51 include the following file. */ |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
52 /* #include "systty.h" */ |
12917 | 53 #include "syssignal.h" |
554 | 54 |
314 | 55 #ifdef HAVE_X_WINDOWS |
56 #include "xterm.h" | |
25012 | 57 #endif /* HAVE_X_WINDOWS */ |
314 | 58 |
13408
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
59 #ifdef HAVE_NTGUI |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
60 #include "w32term.h" |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
61 #endif /* HAVE_NTGUI */ |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
62 |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
63 #ifdef macintosh |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
64 #include "macterm.h" |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
65 #endif /* macintosh */ |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
66 |
25012 | 67 /* Include systime.h after xterm.h to avoid double inclusion of time.h. */ |
68 | |
7808
52e2eb6245d4
Include systime.h after xterm.h.
Richard M. Stallman <rms@gnu.org>
parents:
7648
diff
changeset
|
69 #include "systime.h" |
7558
8497bcb9fb8e
(PENDING_OUTPUT_COUNT): If __GNU_LIBRARY__,
Richard M. Stallman <rms@gnu.org>
parents:
7530
diff
changeset
|
70 #include <errno.h> |
8497bcb9fb8e
(PENDING_OUTPUT_COUNT): If __GNU_LIBRARY__,
Richard M. Stallman <rms@gnu.org>
parents:
7530
diff
changeset
|
71 |
25012 | 72 /* To get the prototype for `sleep'. */ |
73 | |
74 #ifdef HAVE_UNISTD_H | |
75 #include <unistd.h> | |
76 #endif | |
77 | |
314 | 78 #define max(a, b) ((a) > (b) ? (a) : (b)) |
79 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
80 | |
81 /* Get number of chars of output now in the buffer of a stdio stream. | |
25012 | 82 This ought to be built in in stdio, but it isn't. Some s- files |
83 override this because their stdio internals differ. */ | |
84 | |
5214
c4bf07b226be
(PENDING_OUTPUT_COUNT) [__GNU_LIBRARY__]: Alternate definition for the GNU
Roland McGrath <roland@gnu.org>
parents:
5083
diff
changeset
|
85 #ifdef __GNU_LIBRARY__ |
25012 | 86 |
87 /* The s- file might have overridden the definition with one that | |
88 works for the system's C library. But we are using the GNU C | |
89 library, so this is the right definition for every system. */ | |
90 | |
7558
8497bcb9fb8e
(PENDING_OUTPUT_COUNT): If __GNU_LIBRARY__,
Richard M. Stallman <rms@gnu.org>
parents:
7530
diff
changeset
|
91 #ifdef GNU_LIBRARY_PENDING_OUTPUT_COUNT |
8497bcb9fb8e
(PENDING_OUTPUT_COUNT): If __GNU_LIBRARY__,
Richard M. Stallman <rms@gnu.org>
parents:
7530
diff
changeset
|
92 #define PENDING_OUTPUT_COUNT GNU_LIBRARY_PENDING_OUTPUT_COUNT |
8497bcb9fb8e
(PENDING_OUTPUT_COUNT): If __GNU_LIBRARY__,
Richard M. Stallman <rms@gnu.org>
parents:
7530
diff
changeset
|
93 #else |
7443
a9cb818e5316
[__GNU_LIBRARY__]: Redefine PENDING_OUTPUT_COUNT even if already defined.
Roland McGrath <roland@gnu.org>
parents:
7247
diff
changeset
|
94 #undef PENDING_OUTPUT_COUNT |
5214
c4bf07b226be
(PENDING_OUTPUT_COUNT) [__GNU_LIBRARY__]: Alternate definition for the GNU
Roland McGrath <roland@gnu.org>
parents:
5083
diff
changeset
|
95 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->__bufp - (FILE)->__buffer) |
7558
8497bcb9fb8e
(PENDING_OUTPUT_COUNT): If __GNU_LIBRARY__,
Richard M. Stallman <rms@gnu.org>
parents:
7530
diff
changeset
|
96 #endif |
8497bcb9fb8e
(PENDING_OUTPUT_COUNT): If __GNU_LIBRARY__,
Richard M. Stallman <rms@gnu.org>
parents:
7530
diff
changeset
|
97 #else /* not __GNU_LIBRARY__ */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25781
diff
changeset
|
98 #if !defined (PENDING_OUTPUT_COUNT) && HAVE_STDIO_EXT_H && HAVE___FPENDING |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25781
diff
changeset
|
99 #include <stdio_ext.h> |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25781
diff
changeset
|
100 #define PENDING_OUTPUT_COUNT(FILE) __fpending (FILE) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25781
diff
changeset
|
101 #endif |
7443
a9cb818e5316
[__GNU_LIBRARY__]: Redefine PENDING_OUTPUT_COUNT even if already defined.
Roland McGrath <roland@gnu.org>
parents:
7247
diff
changeset
|
102 #ifndef PENDING_OUTPUT_COUNT |
314 | 103 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base) |
104 #endif | |
25012 | 105 #endif /* not __GNU_LIBRARY__ */ |
106 | |
29437 | 107 #if defined (LINUX) && defined (HAVE_LIBNCURSES) |
108 #include <term.h> /* for tgetent */ | |
109 #endif | |
25012 | 110 |
111 /* Structure to pass dimensions around. Used for character bounding | |
112 boxes, glyph matrix dimensions and alike. */ | |
113 | |
114 struct dim | |
115 { | |
116 int width; | |
117 int height; | |
118 }; | |
119 | |
120 | |
121 /* Function prototypes. */ | |
122 | |
34849
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
123 static void save_or_restore_current_matrix P_ ((struct frame *, int)); |
34736
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
124 static void fake_current_matrices P_ ((Lisp_Object)); |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
125 static void redraw_overlapping_rows P_ ((struct window *, int)); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
126 static void redraw_overlapped_rows P_ ((struct window *, int)); |
25012 | 127 static int count_blanks P_ ((struct glyph *, int)); |
128 static int count_match P_ ((struct glyph *, struct glyph *, | |
129 struct glyph *, struct glyph *)); | |
130 static unsigned line_draw_cost P_ ((struct glyph_matrix *, int)); | |
131 static void update_frame_line P_ ((struct frame *, int)); | |
132 static struct dim allocate_matrices_for_frame_redisplay | |
133 P_ ((Lisp_Object, int, int, struct dim, int, int *)); | |
134 static void allocate_matrices_for_window_redisplay P_ ((struct window *, | |
135 struct dim)); | |
136 static int realloc_glyph_pool P_ ((struct glyph_pool *, struct dim)); | |
137 static void adjust_frame_glyphs P_ ((struct frame *)); | |
138 struct glyph_matrix *new_glyph_matrix P_ ((struct glyph_pool *)); | |
139 static void free_glyph_matrix P_ ((struct glyph_matrix *)); | |
140 static void adjust_glyph_matrix P_ ((struct window *, struct glyph_matrix *, | |
141 int, int, struct dim)); | |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
142 static void change_frame_size_1 P_ ((struct frame *, int, int, int, int, int)); |
25012 | 143 static void swap_glyph_pointers P_ ((struct glyph_row *, struct glyph_row *)); |
30323
4cd1b8fe118c
(direct_output_for_insert): Remove confusing
Gerd Moellmann <gerd@gnu.org>
parents:
30307
diff
changeset
|
144 #ifdef GLYPH_DEBUG |
25012 | 145 static int glyph_row_slice_p P_ ((struct glyph_row *, struct glyph_row *)); |
30323
4cd1b8fe118c
(direct_output_for_insert): Remove confusing
Gerd Moellmann <gerd@gnu.org>
parents:
30307
diff
changeset
|
146 #endif |
25012 | 147 static void fill_up_frame_row_with_spaces P_ ((struct glyph_row *, int)); |
148 static void build_frame_matrix_from_window_tree P_ ((struct glyph_matrix *, | |
149 struct window *)); | |
150 static void build_frame_matrix_from_leaf_window P_ ((struct glyph_matrix *, | |
151 struct window *)); | |
152 static struct glyph_pool *new_glyph_pool P_ ((void)); | |
153 static void free_glyph_pool P_ ((struct glyph_pool *)); | |
154 static void adjust_frame_glyphs_initially P_ ((void)); | |
155 static void adjust_frame_message_buffer P_ ((struct frame *)); | |
156 static void adjust_decode_mode_spec_buffer P_ ((struct frame *)); | |
157 static void fill_up_glyph_row_with_spaces P_ ((struct glyph_row *)); | |
158 static void build_frame_matrix P_ ((struct frame *)); | |
159 void clear_current_matrices P_ ((struct frame *)); | |
160 void scroll_glyph_matrix_range P_ ((struct glyph_matrix *, int, int, | |
161 int, int)); | |
162 static void clear_window_matrices P_ ((struct window *, int)); | |
163 static void fill_up_glyph_row_area_with_spaces P_ ((struct glyph_row *, int)); | |
164 static int scrolling_window P_ ((struct window *, int)); | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
165 static int update_window_line P_ ((struct window *, int, int *)); |
25012 | 166 static void update_marginal_area P_ ((struct window *, int, int)); |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
167 static int update_text_area P_ ((struct window *, int)); |
25012 | 168 static void make_current P_ ((struct glyph_matrix *, struct glyph_matrix *, |
169 int)); | |
170 static void mirror_make_current P_ ((struct window *, int)); | |
171 void check_window_matrix_pointers P_ ((struct window *)); | |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
172 #if GLYPH_DEBUG |
25012 | 173 static void check_matrix_pointers P_ ((struct glyph_matrix *, |
174 struct glyph_matrix *)); | |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
175 #endif |
25012 | 176 static void mirror_line_dance P_ ((struct window *, int, int, int *, char *)); |
177 static int update_window_tree P_ ((struct window *, int)); | |
178 static int update_window P_ ((struct window *, int)); | |
179 static int update_frame_1 P_ ((struct frame *, int, int)); | |
180 static void set_window_cursor_after_update P_ ((struct window *)); | |
181 static int row_equal_p P_ ((struct window *, struct glyph_row *, | |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
182 struct glyph_row *, int)); |
25012 | 183 static void adjust_frame_glyphs_for_window_redisplay P_ ((struct frame *)); |
184 static void adjust_frame_glyphs_for_frame_redisplay P_ ((struct frame *)); | |
185 static void reverse_rows P_ ((struct glyph_matrix *, int, int)); | |
186 static int margin_glyphs_to_reserve P_ ((struct window *, int, Lisp_Object)); | |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
187 static void sync_window_with_frame_matrix_rows P_ ((struct window *)); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
188 struct window *frame_row_to_window P_ ((struct window *, int)); |
25012 | 189 |
190 | |
191 | |
192 /* Non-zero means don't pause redisplay for pending input. (This is | |
193 for debugging and for a future implementation of EDT-like | |
194 scrolling. */ | |
195 | |
196 int redisplay_dont_pause; | |
10770
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
197 |
554 | 198 /* Nonzero upon entry to redisplay means do not assume anything about |
764 | 199 current contents of actual terminal frame; clear and redraw it. */ |
314 | 200 |
764 | 201 int frame_garbaged; |
314 | 202 |
25012 | 203 /* Nonzero means last display completed. Zero means it was preempted. */ |
314 | 204 |
205 int display_completed; | |
206 | |
25012 | 207 /* Lisp variable visible-bell; enables use of screen-flash instead of |
208 audible bell. */ | |
314 | 209 |
210 int visible_bell; | |
211 | |
764 | 212 /* Invert the color of the whole frame, at a low level. */ |
314 | 213 |
214 int inverse_video; | |
215 | |
216 /* Line speed of the terminal. */ | |
217 | |
218 int baud_rate; | |
219 | |
25012 | 220 /* Either nil or a symbol naming the window system under which Emacs |
221 is running. */ | |
314 | 222 |
223 Lisp_Object Vwindow_system; | |
224 | |
225 /* Version number of X windows: 10, 11 or nil. */ | |
25012 | 226 |
314 | 227 Lisp_Object Vwindow_system_version; |
228 | |
25012 | 229 /* Vector of glyph definitions. Indexed by glyph number, the contents |
230 are a string which is how to output the glyph. | |
314 | 231 |
232 If Vglyph_table is nil, a glyph is output by using its low 8 bits | |
25012 | 233 as a character code. |
234 | |
235 This is an obsolete feature that is no longer used. The variable | |
236 is retained for compatibility. */ | |
314 | 237 |
238 Lisp_Object Vglyph_table; | |
239 | |
240 /* Display table to use for vectors that don't specify their own. */ | |
241 | |
242 Lisp_Object Vstandard_display_table; | |
243 | |
25012 | 244 /* Nonzero means reading single-character input with prompt so put |
245 cursor on mini-buffer after the prompt. positive means at end of | |
246 text in echo area; negative means at beginning of line. */ | |
247 | |
314 | 248 int cursor_in_echo_area; |
13220
2e9014617492
(Qdisplay_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13105
diff
changeset
|
249 |
30720
64f3338f72d8
(Qredisplay_dont_pause): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
30713
diff
changeset
|
250 Lisp_Object Qdisplay_table, Qredisplay_dont_pause; |
25012 | 251 |
314 | 252 |
25012 | 253 /* The currently selected frame. In a single-frame version, this |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
254 variable always equals the_only_frame. */ |
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
255 |
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
256 Lisp_Object selected_frame; |
25012 | 257 |
258 /* A frame which is not just a mini-buffer, or 0 if there are no such | |
764 | 259 frames. This is usually the most recent such frame that was |
9572 | 260 selected. In a single-frame version, this variable always holds |
261 the address of the_only_frame. */ | |
25012 | 262 |
263 struct frame *last_nonminibuf_frame; | |
264 | |
265 /* Stdio stream being used for copy of all output. */ | |
266 | |
267 FILE *termscript; | |
268 | |
269 /* Structure for info on cursor positioning. */ | |
270 | |
271 struct cm Wcm; | |
272 | |
273 /* 1 means SIGWINCH happened when not safe. */ | |
274 | |
275 int delayed_size_change; | |
276 | |
277 /* 1 means glyph initialization has been completed at startup. */ | |
278 | |
279 static int glyphs_initialized_initially_p; | |
280 | |
281 /* Updated window if != 0. Set by update_window. */ | |
282 | |
283 struct window *updated_window; | |
284 | |
285 /* Glyph row updated in update_window_line, and area that is updated. */ | |
286 | |
287 struct glyph_row *updated_row; | |
288 int updated_area; | |
289 | |
290 /* A glyph for a space. */ | |
291 | |
292 struct glyph space_glyph; | |
293 | |
294 /* Non-zero means update has been performed directly, so that there's | |
295 no need for redisplay_internal to do much work. Set by | |
296 direct_output_for_insert. */ | |
297 | |
298 int redisplay_performed_directly_p; | |
299 | |
300 /* Counts of allocated structures. These counts serve to diagnose | |
301 memory leaks and double frees. */ | |
302 | |
303 int glyph_matrix_count; | |
304 int glyph_pool_count; | |
305 | |
306 /* If non-null, the frame whose frame matrices are manipulated. If | |
307 null, window matrices are worked on. */ | |
308 | |
309 static struct frame *frame_matrix_frame; | |
310 | |
311 /* Current interface for window-based redisplay. Set from init_xterm. | |
312 A null value means we are not using window-based redisplay. */ | |
313 | |
314 struct redisplay_interface *rif; | |
315 | |
316 /* Non-zero means that fonts have been loaded since the last glyph | |
317 matrix adjustments. Redisplay must stop, and glyph matrices must | |
318 be adjusted when this flag becomes non-zero during display. The | |
319 reason fonts can be loaded so late is that fonts of fontsets are | |
320 loaded on demand. */ | |
321 | |
322 int fonts_changed_p; | |
323 | |
324 /* Convert vpos and hpos from frame to window and vice versa. | |
325 This may only be used for terminal frames. */ | |
326 | |
327 #if GLYPH_DEBUG | |
328 | |
329 static int window_to_frame_vpos P_ ((struct window *, int)); | |
330 static int window_to_frame_hpos P_ ((struct window *, int)); | |
331 #define WINDOW_TO_FRAME_VPOS(W, VPOS) window_to_frame_vpos ((W), (VPOS)) | |
332 #define WINDOW_TO_FRAME_HPOS(W, HPOS) window_to_frame_hpos ((W), (HPOS)) | |
333 | |
334 #else /* GLYPH_DEBUG == 0 */ | |
335 | |
336 #define WINDOW_TO_FRAME_VPOS(W, VPOS) ((VPOS) + XFASTINT ((W)->top)) | |
337 #define WINDOW_TO_FRAME_HPOS(W, HPOS) ((HPOS) + XFASTINT ((W)->left)) | |
338 | |
339 #endif /* GLYPH_DEBUG == 0 */ | |
340 | |
341 | |
342 /* Like bcopy except never gets confused by overlap. Let this be the | |
343 first function defined in this file, or change emacs.c where the | |
344 address of this function is used. */ | |
314 | 345 |
346 void | |
347 safe_bcopy (from, to, size) | |
348 char *from, *to; | |
349 int size; | |
350 { | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
351 if (size <= 0 || from == to) |
314 | 352 return; |
353 | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
354 /* 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
|
355 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
|
356 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
|
357 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
|
358 bcopy (from, to, size); |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
359 |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
360 /* 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
|
361 else |
314 | 362 { |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
363 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
|
364 register char *endt = to + size; |
314 | 365 |
366 /* If TO - FROM is large, then we should break the copy into | |
367 nonoverlapping chunks of TO - FROM bytes each. However, if | |
368 TO - FROM is small, then the bcopy function call overhead | |
369 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
|
370 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
|
371 bad, I'm trying to err in its favor. */ |
314 | 372 if (to - from < 64) |
373 { | |
374 do | |
375 *--endt = *--endf; | |
376 while (endf != from); | |
377 } | |
378 else | |
379 { | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
380 for (;;) |
314 | 381 { |
382 endt -= (to - from); | |
383 endf -= (to - from); | |
384 | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
385 if (endt < to) |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
386 break; |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
387 |
314 | 388 bcopy (endf, endt, to - from); |
389 } | |
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
390 |
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
391 /* If SIZE wasn't a multiple of TO - FROM, there will be a |
25012 | 392 little left over. The amount left over is (endt + (to - |
393 from)) - to, which is endt - from. */ | |
314 | 394 bcopy (from, to, endt - from); |
395 } | |
396 } | |
397 } | |
398 | |
25012 | 399 |
400 | |
401 /*********************************************************************** | |
402 Glyph Matrices | |
403 ***********************************************************************/ | |
404 | |
405 /* Allocate and return a glyph_matrix structure. POOL is the glyph | |
406 pool from which memory for the matrix should be allocated, or null | |
407 for window-based redisplay where no glyph pools are used. The | |
408 member `pool' of the glyph matrix structure returned is set to | |
409 POOL, the structure is otherwise zeroed. */ | |
410 | |
411 struct glyph_matrix * | |
412 new_glyph_matrix (pool) | |
413 struct glyph_pool *pool; | |
414 { | |
415 struct glyph_matrix *result; | |
416 | |
417 /* Allocate and clear. */ | |
418 result = (struct glyph_matrix *) xmalloc (sizeof *result); | |
419 bzero (result, sizeof *result); | |
420 | |
421 /* Increment number of allocated matrices. This count is used | |
422 to detect memory leaks. */ | |
423 ++glyph_matrix_count; | |
424 | |
425 /* Set pool and return. */ | |
426 result->pool = pool; | |
427 return result; | |
428 } | |
429 | |
430 | |
431 /* Free glyph matrix MATRIX. Passing in a null MATRIX is allowed. | |
432 | |
433 The global counter glyph_matrix_count is decremented when a matrix | |
434 is freed. If the count gets negative, more structures were freed | |
435 than allocated, i.e. one matrix was freed more than once or a bogus | |
436 pointer was passed to this function. | |
437 | |
438 If MATRIX->pool is null, this means that the matrix manages its own | |
439 glyph memory---this is done for matrices on X frames. Freeing the | |
440 matrix also frees the glyph memory in this case. */ | |
441 | |
442 static void | |
443 free_glyph_matrix (matrix) | |
444 struct glyph_matrix *matrix; | |
445 { | |
446 if (matrix) | |
447 { | |
448 int i; | |
449 | |
450 /* Detect the case that more matrices are freed than were | |
451 allocated. */ | |
452 if (--glyph_matrix_count < 0) | |
453 abort (); | |
454 | |
455 /* Free glyph memory if MATRIX owns it. */ | |
456 if (matrix->pool == NULL) | |
457 for (i = 0; i < matrix->rows_allocated; ++i) | |
458 xfree (matrix->rows[i].glyphs[LEFT_MARGIN_AREA]); | |
459 | |
460 /* Free row structures and the matrix itself. */ | |
461 xfree (matrix->rows); | |
462 xfree (matrix); | |
463 } | |
464 } | |
465 | |
466 | |
467 /* Return the number of glyphs to reserve for a marginal area of | |
468 window W. TOTAL_GLYPHS is the number of glyphs in a complete | |
469 display line of window W. MARGIN gives the width of the marginal | |
470 area in canonical character units. MARGIN should be an integer | |
471 or a float. */ | |
472 | |
473 static int | |
474 margin_glyphs_to_reserve (w, total_glyphs, margin) | |
475 struct window *w; | |
476 int total_glyphs; | |
477 Lisp_Object margin; | |
478 { | |
479 int n; | |
480 | |
481 if (NUMBERP (margin)) | |
482 { | |
483 int width = XFASTINT (w->width); | |
484 double d = max (0, XFLOATINT (margin)); | |
485 d = min (width / 2 - 1, d); | |
486 n = (int) ((double) total_glyphs / width * d); | |
487 } | |
488 else | |
489 n = 0; | |
490 | |
491 return n; | |
492 } | |
493 | |
494 | |
495 /* Adjust glyph matrix MATRIX on window W or on a frame to changed | |
496 window sizes. | |
497 | |
498 W is null if the function is called for a frame glyph matrix. | |
499 Otherwise it is the window MATRIX is a member of. X and Y are the | |
500 indices of the first column and row of MATRIX within the frame | |
501 matrix, if such a matrix exists. They are zero for purely | |
502 window-based redisplay. DIM is the needed size of the matrix. | |
503 | |
504 In window-based redisplay, where no frame matrices exist, glyph | |
505 matrices manage their own glyph storage. Otherwise, they allocate | |
506 storage from a common frame glyph pool which can be found in | |
507 MATRIX->pool. | |
508 | |
509 The reason for this memory management strategy is to avoid complete | |
510 frame redraws if possible. When we allocate from a common pool, a | |
511 change of the location or size of a sub-matrix within the pool | |
512 requires a complete redisplay of the frame because we cannot easily | |
513 make sure that the current matrices of all windows still agree with | |
514 what is displayed on the screen. While this is usually fast, it | |
515 leads to screen flickering. */ | |
516 | |
517 static void | |
518 adjust_glyph_matrix (w, matrix, x, y, dim) | |
519 struct window *w; | |
520 struct glyph_matrix *matrix; | |
521 int x, y; | |
522 struct dim dim; | |
523 { | |
524 int i; | |
525 int new_rows; | |
526 int marginal_areas_changed_p = 0; | |
25546 | 527 int header_line_changed_p = 0; |
528 int header_line_p = 0; | |
25012 | 529 int left = -1, right = -1; |
34203
e55480843a8e
(scrolling_window): Fix code inserting runs in list of all runs.
Gerd Moellmann <gerd@gnu.org>
parents:
33763
diff
changeset
|
530 int window_x, window_y, window_width = -1, window_height; |
25012 | 531 |
532 /* See if W had a top line that has disappeared now, or vice versa. */ | |
533 if (w) | |
534 { | |
25546 | 535 header_line_p = WINDOW_WANTS_HEADER_LINE_P (w); |
536 header_line_changed_p = header_line_p != matrix->header_line_p; | |
25012 | 537 } |
25546 | 538 matrix->header_line_p = header_line_p; |
25012 | 539 |
540 /* Do nothing if MATRIX' size, position, vscroll, and marginal areas | |
541 haven't changed. This optimization is important because preserving | |
542 the matrix means preventing redisplay. */ | |
543 if (matrix->pool == NULL) | |
544 { | |
545 window_box (w, -1, &window_x, &window_y, &window_width, &window_height); | |
546 left = margin_glyphs_to_reserve (w, dim.width, w->left_margin_width); | |
547 right = margin_glyphs_to_reserve (w, dim.width, w->right_margin_width); | |
548 xassert (left >= 0 && right >= 0); | |
549 marginal_areas_changed_p = (left != matrix->left_margin_glyphs | |
550 || right != matrix->right_margin_glyphs); | |
551 | |
552 if (!marginal_areas_changed_p | |
553 && !fonts_changed_p | |
25546 | 554 && !header_line_changed_p |
34279
7ab25b4a077c
(adjust_glyph_matrix): Don't reuse a window's current
Gerd Moellmann <gerd@gnu.org>
parents:
34203
diff
changeset
|
555 && matrix->window_left_x == XFASTINT (w->left) |
25012 | 556 && matrix->window_top_y == XFASTINT (w->top) |
557 && matrix->window_height == window_height | |
558 && matrix->window_vscroll == w->vscroll | |
559 && matrix->window_width == window_width) | |
560 return; | |
561 } | |
562 | |
563 /* Enlarge MATRIX->rows if necessary. New rows are cleared. */ | |
564 if (matrix->rows_allocated < dim.height) | |
565 { | |
566 int size = dim.height * sizeof (struct glyph_row); | |
567 new_rows = dim.height - matrix->rows_allocated; | |
568 matrix->rows = (struct glyph_row *) xrealloc (matrix->rows, size); | |
569 bzero (matrix->rows + matrix->rows_allocated, | |
570 new_rows * sizeof *matrix->rows); | |
571 matrix->rows_allocated = dim.height; | |
572 } | |
573 else | |
574 new_rows = 0; | |
575 | |
576 /* If POOL is not null, MATRIX is a frame matrix or a window matrix | |
577 on a frame not using window-based redisplay. Set up pointers for | |
578 each row into the glyph pool. */ | |
579 if (matrix->pool) | |
580 { | |
581 xassert (matrix->pool->glyphs); | |
582 | |
583 if (w) | |
584 { | |
585 left = margin_glyphs_to_reserve (w, dim.width, | |
586 w->left_margin_width); | |
587 right = margin_glyphs_to_reserve (w, dim.width, | |
588 w->right_margin_width); | |
589 } | |
590 else | |
591 left = right = 0; | |
592 | |
593 for (i = 0; i < dim.height; ++i) | |
594 { | |
595 struct glyph_row *row = &matrix->rows[i]; | |
596 | |
597 row->glyphs[LEFT_MARGIN_AREA] | |
598 = (matrix->pool->glyphs | |
599 + (y + i) * matrix->pool->ncolumns | |
600 + x); | |
601 | |
602 if (w == NULL | |
603 || row == matrix->rows + dim.height - 1 | |
25546 | 604 || (row == matrix->rows && matrix->header_line_p)) |
25012 | 605 { |
606 row->glyphs[TEXT_AREA] | |
607 = row->glyphs[LEFT_MARGIN_AREA]; | |
608 row->glyphs[RIGHT_MARGIN_AREA] | |
609 = row->glyphs[TEXT_AREA] + dim.width; | |
610 row->glyphs[LAST_AREA] | |
611 = row->glyphs[RIGHT_MARGIN_AREA]; | |
612 } | |
613 else | |
614 { | |
615 row->glyphs[TEXT_AREA] | |
616 = row->glyphs[LEFT_MARGIN_AREA] + left; | |
617 row->glyphs[RIGHT_MARGIN_AREA] | |
618 = row->glyphs[TEXT_AREA] + dim.width - left - right; | |
619 row->glyphs[LAST_AREA] | |
620 = row->glyphs[LEFT_MARGIN_AREA] + dim.width; | |
621 } | |
622 } | |
623 | |
624 matrix->left_margin_glyphs = left; | |
625 matrix->right_margin_glyphs = right; | |
626 } | |
627 else | |
628 { | |
629 /* If MATRIX->pool is null, MATRIX is responsible for managing | |
630 its own memory. Allocate glyph memory from the heap. */ | |
631 if (dim.width > matrix->matrix_w | |
632 || new_rows | |
25546 | 633 || header_line_changed_p |
25012 | 634 || marginal_areas_changed_p) |
635 { | |
636 struct glyph_row *row = matrix->rows; | |
637 struct glyph_row *end = row + matrix->rows_allocated; | |
638 | |
639 while (row < end) | |
640 { | |
641 row->glyphs[LEFT_MARGIN_AREA] | |
642 = (struct glyph *) xrealloc (row->glyphs[LEFT_MARGIN_AREA], | |
643 (dim.width | |
644 * sizeof (struct glyph))); | |
645 | |
646 /* The mode line never has marginal areas. */ | |
647 if (row == matrix->rows + dim.height - 1 | |
25546 | 648 || (row == matrix->rows && matrix->header_line_p)) |
25012 | 649 { |
650 row->glyphs[TEXT_AREA] | |
651 = row->glyphs[LEFT_MARGIN_AREA]; | |
652 row->glyphs[RIGHT_MARGIN_AREA] | |
653 = row->glyphs[TEXT_AREA] + dim.width; | |
654 row->glyphs[LAST_AREA] | |
655 = row->glyphs[RIGHT_MARGIN_AREA]; | |
656 } | |
657 else | |
658 { | |
659 row->glyphs[TEXT_AREA] | |
660 = row->glyphs[LEFT_MARGIN_AREA] + left; | |
661 row->glyphs[RIGHT_MARGIN_AREA] | |
662 = row->glyphs[TEXT_AREA] + dim.width - left - right; | |
663 row->glyphs[LAST_AREA] | |
664 = row->glyphs[LEFT_MARGIN_AREA] + dim.width; | |
665 } | |
666 ++row; | |
667 } | |
668 } | |
669 | |
670 xassert (left >= 0 && right >= 0); | |
671 matrix->left_margin_glyphs = left; | |
672 matrix->right_margin_glyphs = right; | |
673 } | |
674 | |
675 /* Number of rows to be used by MATRIX. */ | |
676 matrix->nrows = dim.height; | |
31932
081edde76197
(adjust_glyph_matrix, enable_glyph_matrix_rows):
Gerd Moellmann <gerd@gnu.org>
parents:
31850
diff
changeset
|
677 xassert (matrix->nrows >= 0); |
25012 | 678 |
679 /* Mark rows in a current matrix of a window as not having valid | |
680 contents. It's important to not do this for desired matrices. | |
681 When Emacs starts, it may already be building desired matrices | |
682 when this function runs. */ | |
683 if (w && matrix == w->current_matrix) | |
684 { | |
34203
e55480843a8e
(scrolling_window): Fix code inserting runs in list of all runs.
Gerd Moellmann <gerd@gnu.org>
parents:
33763
diff
changeset
|
685 if (window_width < 0) |
e55480843a8e
(scrolling_window): Fix code inserting runs in list of all runs.
Gerd Moellmann <gerd@gnu.org>
parents:
33763
diff
changeset
|
686 window_width = window_box_width (w, -1); |
e55480843a8e
(scrolling_window): Fix code inserting runs in list of all runs.
Gerd Moellmann <gerd@gnu.org>
parents:
33763
diff
changeset
|
687 |
25012 | 688 /* Optimize the case that only the height has changed (C-x 2, |
689 upper window). Invalidate all rows that are no longer part | |
690 of the window. */ | |
691 if (!marginal_areas_changed_p | |
34279
7ab25b4a077c
(adjust_glyph_matrix): Don't reuse a window's current
Gerd Moellmann <gerd@gnu.org>
parents:
34203
diff
changeset
|
692 && matrix->window_left_x == XFASTINT (w->left) |
25012 | 693 && matrix->window_top_y == XFASTINT (w->top) |
34203
e55480843a8e
(scrolling_window): Fix code inserting runs in list of all runs.
Gerd Moellmann <gerd@gnu.org>
parents:
33763
diff
changeset
|
694 && matrix->window_width == window_box_width (w, -1)) |
25012 | 695 { |
696 i = 0; | |
697 while (matrix->rows[i].enabled_p | |
698 && (MATRIX_ROW_BOTTOM_Y (matrix->rows + i) | |
699 < matrix->window_height)) | |
700 ++i; | |
701 | |
702 /* Window end is invalid, if inside of the rows that | |
703 are invalidated. */ | |
704 if (INTEGERP (w->window_end_vpos) | |
705 && XFASTINT (w->window_end_vpos) >= i) | |
706 w->window_end_valid = Qnil; | |
707 | |
708 while (i < matrix->nrows) | |
709 matrix->rows[i++].enabled_p = 0; | |
710 } | |
711 else | |
712 { | |
713 for (i = 0; i < matrix->nrows; ++i) | |
714 matrix->rows[i].enabled_p = 0; | |
715 } | |
716 } | |
717 | |
718 /* Remember last values to be able to optimize frame redraws. */ | |
719 matrix->matrix_x = x; | |
720 matrix->matrix_y = y; | |
721 matrix->matrix_w = dim.width; | |
722 matrix->matrix_h = dim.height; | |
723 | |
724 /* Record the top y location and height of W at the time the matrix | |
725 was last adjusted. This is used to optimize redisplay above. */ | |
726 if (w) | |
727 { | |
34279
7ab25b4a077c
(adjust_glyph_matrix): Don't reuse a window's current
Gerd Moellmann <gerd@gnu.org>
parents:
34203
diff
changeset
|
728 matrix->window_left_x = XFASTINT (w->left); |
25012 | 729 matrix->window_top_y = XFASTINT (w->top); |
730 matrix->window_height = window_height; | |
731 matrix->window_width = window_width; | |
732 matrix->window_vscroll = w->vscroll; | |
733 } | |
734 } | |
735 | |
736 | |
737 /* Reverse the contents of rows in MATRIX between START and END. The | |
738 contents of the row at END - 1 end up at START, END - 2 at START + | |
739 1 etc. This is part of the implementation of rotate_matrix (see | |
740 below). */ | |
314 | 741 |
742 static void | |
25012 | 743 reverse_rows (matrix, start, end) |
744 struct glyph_matrix *matrix; | |
745 int start, end; | |
314 | 746 { |
25012 | 747 int i, j; |
748 | |
749 for (i = start, j = end - 1; i < j; ++i, --j) | |
750 { | |
751 /* Non-ISO HP/UX compiler doesn't like auto struct | |
752 initialization. */ | |
753 struct glyph_row temp; | |
754 temp = matrix->rows[i]; | |
755 matrix->rows[i] = matrix->rows[j]; | |
756 matrix->rows[j] = temp; | |
757 } | |
314 | 758 } |
759 | |
25012 | 760 |
761 /* Rotate the contents of rows in MATRIX in the range FIRST .. LAST - | |
762 1 by BY positions. BY < 0 means rotate left, i.e. towards lower | |
763 indices. (Note: this does not copy glyphs, only glyph pointers in | |
764 row structures are moved around). | |
765 | |
766 The algorithm used for rotating the vector was, I believe, first | |
767 described by Kernighan. See the vector R as consisting of two | |
768 sub-vectors AB, where A has length BY for BY >= 0. The result | |
769 after rotating is then BA. Reverse both sub-vectors to get ArBr | |
770 and reverse the result to get (ArBr)r which is BA. Similar for | |
771 rotating right. */ | |
772 | |
773 void | |
774 rotate_matrix (matrix, first, last, by) | |
775 struct glyph_matrix *matrix; | |
776 int first, last, by; | |
314 | 777 { |
25012 | 778 if (by < 0) |
779 { | |
780 /* Up (rotate left, i.e. towards lower indices). */ | |
781 by = -by; | |
782 reverse_rows (matrix, first, first + by); | |
783 reverse_rows (matrix, first + by, last); | |
784 reverse_rows (matrix, first, last); | |
785 } | |
786 else if (by > 0) | |
314 | 787 { |
25012 | 788 /* Down (rotate right, i.e. towards higher indices). */ |
789 reverse_rows (matrix, last - by, last); | |
790 reverse_rows (matrix, first, last - by); | |
791 reverse_rows (matrix, first, last); | |
314 | 792 } |
25012 | 793 } |
794 | |
795 | |
796 /* Increment buffer positions in glyph rows of MATRIX. Do it for rows | |
797 with indices START <= index < END. Increment positions by DELTA/ | |
798 DELTA_BYTES. */ | |
799 | |
800 void | |
28708
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
801 increment_matrix_positions (matrix, start, end, delta, delta_bytes) |
25012 | 802 struct glyph_matrix *matrix; |
803 int start, end, delta, delta_bytes; | |
804 { | |
805 /* Check that START and END are reasonable values. */ | |
806 xassert (start >= 0 && start <= matrix->nrows); | |
807 xassert (end >= 0 && end <= matrix->nrows); | |
808 xassert (start <= end); | |
809 | |
810 for (; start < end; ++start) | |
28708
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
811 increment_row_positions (matrix->rows + start, delta, delta_bytes); |
25012 | 812 } |
813 | |
814 | |
815 /* Enable a range of rows in glyph matrix MATRIX. START and END are | |
816 the row indices of the first and last + 1 row to enable. If | |
817 ENABLED_P is non-zero, enabled_p flags in rows will be set to 1. */ | |
818 | |
819 void | |
820 enable_glyph_matrix_rows (matrix, start, end, enabled_p) | |
821 struct glyph_matrix *matrix; | |
822 int start, end; | |
823 int enabled_p; | |
824 { | |
31932
081edde76197
(adjust_glyph_matrix, enable_glyph_matrix_rows):
Gerd Moellmann <gerd@gnu.org>
parents:
31850
diff
changeset
|
825 xassert (start <= end); |
081edde76197
(adjust_glyph_matrix, enable_glyph_matrix_rows):
Gerd Moellmann <gerd@gnu.org>
parents:
31850
diff
changeset
|
826 xassert (start >= 0 && start < matrix->nrows); |
081edde76197
(adjust_glyph_matrix, enable_glyph_matrix_rows):
Gerd Moellmann <gerd@gnu.org>
parents:
31850
diff
changeset
|
827 xassert (end >= 0 && end <= matrix->nrows); |
081edde76197
(adjust_glyph_matrix, enable_glyph_matrix_rows):
Gerd Moellmann <gerd@gnu.org>
parents:
31850
diff
changeset
|
828 |
25012 | 829 for (; start < end; ++start) |
830 matrix->rows[start].enabled_p = enabled_p != 0; | |
831 } | |
832 | |
833 | |
834 /* Clear MATRIX. | |
835 | |
836 This empties all rows in MATRIX by setting the enabled_p flag for | |
837 all rows of the matrix to zero. The function prepare_desired_row | |
838 will eventually really clear a row when it sees one with a zero | |
839 enabled_p flag. | |
840 | |
841 Resets update hints to defaults value. The only update hint | |
842 currently present is the flag MATRIX->no_scrolling_p. */ | |
843 | |
844 void | |
845 clear_glyph_matrix (matrix) | |
846 struct glyph_matrix *matrix; | |
847 { | |
848 if (matrix) | |
314 | 849 { |
25012 | 850 enable_glyph_matrix_rows (matrix, 0, matrix->nrows, 0); |
851 matrix->no_scrolling_p = 0; | |
314 | 852 } |
853 } | |
25012 | 854 |
855 | |
856 /* Shift part of the glyph matrix MATRIX of window W up or down. | |
857 Increment y-positions in glyph rows between START and END by DY, | |
858 and recompute their visible height. */ | |
859 | |
860 void | |
861 shift_glyph_matrix (w, matrix, start, end, dy) | |
862 struct window *w; | |
863 struct glyph_matrix *matrix; | |
864 int start, end, dy; | |
865 { | |
866 int min_y, max_y; | |
867 | |
868 xassert (start <= end); | |
869 xassert (start >= 0 && start < matrix->nrows); | |
870 xassert (end >= 0 && end <= matrix->nrows); | |
871 | |
25546 | 872 min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w); |
25012 | 873 max_y = WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w); |
874 | |
875 for (; start < end; ++start) | |
876 { | |
877 struct glyph_row *row = &matrix->rows[start]; | |
878 | |
879 row->y += dy; | |
880 | |
881 if (row->y < min_y) | |
882 row->visible_height = row->height - (min_y - row->y); | |
883 else if (row->y + row->height > max_y) | |
884 row->visible_height = row->height - (row->y + row->height - max_y); | |
885 else | |
886 row->visible_height = row->height; | |
887 } | |
888 } | |
889 | |
890 | |
891 /* Mark all rows in current matrices of frame F as invalid. Marking | |
892 invalid is done by setting enabled_p to zero for all rows in a | |
893 current matrix. */ | |
894 | |
895 void | |
896 clear_current_matrices (f) | |
897 register struct frame *f; | |
898 { | |
899 /* Clear frame current matrix, if we have one. */ | |
900 if (f->current_matrix) | |
901 clear_glyph_matrix (f->current_matrix); | |
902 | |
903 /* Clear the matrix of the menu bar window, if such a window exists. | |
904 The menu bar window is currently used to display menus on X when | |
905 no toolkit support is compiled in. */ | |
906 if (WINDOWP (f->menu_bar_window)) | |
907 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix); | |
908 | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
909 /* Clear the matrix of the tool-bar window, if any. */ |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
910 if (WINDOWP (f->tool_bar_window)) |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
911 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix); |
25012 | 912 |
913 /* Clear current window matrices. */ | |
914 xassert (WINDOWP (FRAME_ROOT_WINDOW (f))); | |
915 clear_window_matrices (XWINDOW (FRAME_ROOT_WINDOW (f)), 0); | |
916 } | |
917 | |
918 | |
919 /* Clear out all display lines of F for a coming redisplay. */ | |
314 | 920 |
21514 | 921 void |
25012 | 922 clear_desired_matrices (f) |
923 register struct frame *f; | |
314 | 924 { |
25012 | 925 if (f->desired_matrix) |
926 clear_glyph_matrix (f->desired_matrix); | |
927 | |
928 if (WINDOWP (f->menu_bar_window)) | |
929 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->desired_matrix); | |
930 | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
931 if (WINDOWP (f->tool_bar_window)) |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
932 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->desired_matrix); |
25012 | 933 |
934 /* Do it for window matrices. */ | |
935 xassert (WINDOWP (FRAME_ROOT_WINDOW (f))); | |
936 clear_window_matrices (XWINDOW (FRAME_ROOT_WINDOW (f)), 1); | |
937 } | |
938 | |
939 | |
940 /* Clear matrices in window tree rooted in W. If DESIRED_P is | |
941 non-zero clear desired matrices, otherwise clear current matrices. */ | |
942 | |
943 static void | |
944 clear_window_matrices (w, desired_p) | |
945 struct window *w; | |
946 int desired_p; | |
947 { | |
948 while (w) | |
314 | 949 { |
25012 | 950 if (!NILP (w->hchild)) |
951 { | |
952 xassert (WINDOWP (w->hchild)); | |
953 clear_window_matrices (XWINDOW (w->hchild), desired_p); | |
954 } | |
955 else if (!NILP (w->vchild)) | |
314 | 956 { |
25012 | 957 xassert (WINDOWP (w->vchild)); |
958 clear_window_matrices (XWINDOW (w->vchild), desired_p); | |
959 } | |
960 else | |
961 { | |
962 if (desired_p) | |
963 clear_glyph_matrix (w->desired_matrix); | |
964 else | |
314 | 965 { |
25012 | 966 clear_glyph_matrix (w->current_matrix); |
967 w->window_end_valid = Qnil; | |
314 | 968 } |
25012 | 969 } |
970 | |
971 w = NILP (w->next) ? 0 : XWINDOW (w->next); | |
972 } | |
973 } | |
974 | |
975 | |
976 | |
977 /*********************************************************************** | |
978 Glyph Rows | |
979 | |
980 See dispextern.h for an overall explanation of glyph rows. | |
981 ***********************************************************************/ | |
982 | |
983 /* Clear glyph row ROW. Do it in a way that makes it robust against | |
984 changes in the glyph_row structure, i.e. addition or removal of | |
985 structure members. */ | |
986 | |
33527
c4c7abc48752
(null_row): New gloval static variable.
Kenichi Handa <handa@m17n.org>
parents:
33101
diff
changeset
|
987 static struct glyph_row null_row; |
c4c7abc48752
(null_row): New gloval static variable.
Kenichi Handa <handa@m17n.org>
parents:
33101
diff
changeset
|
988 |
25012 | 989 void |
990 clear_glyph_row (row) | |
991 struct glyph_row *row; | |
992 { | |
993 struct glyph *p[1 + LAST_AREA]; | |
994 | |
995 /* Save pointers. */ | |
996 p[LEFT_MARGIN_AREA] = row->glyphs[LEFT_MARGIN_AREA]; | |
997 p[TEXT_AREA] = row->glyphs[TEXT_AREA]; | |
998 p[RIGHT_MARGIN_AREA] = row->glyphs[RIGHT_MARGIN_AREA]; | |
999 p[LAST_AREA] = row->glyphs[LAST_AREA]; | |
1000 | |
1001 /* Clear. */ | |
1002 *row = null_row; | |
1003 | |
1004 /* Restore pointers. */ | |
1005 row->glyphs[LEFT_MARGIN_AREA] = p[LEFT_MARGIN_AREA]; | |
1006 row->glyphs[TEXT_AREA] = p[TEXT_AREA]; | |
1007 row->glyphs[RIGHT_MARGIN_AREA] = p[RIGHT_MARGIN_AREA]; | |
1008 row->glyphs[LAST_AREA] = p[LAST_AREA]; | |
30041
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1009 |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1010 #if 0 /* At some point, some bit-fields of struct glyph were not set, |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1011 which made glyphs unequal when compared with GLYPH_EQUAL_P. |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1012 Redisplay outputs such glyphs, and flickering effects were |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1013 the result. This also depended on the contents of memory |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1014 returned by xmalloc. If flickering happens again, activate |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1015 the code below If the flickering is gone with that, chances |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1016 are that the flickering has the same reason as here. */ |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1017 bzero (p[0], (char *) p[LAST_AREA] - (char *) p[0]); |
b20d72b7aa4b
(clear_glyph_row): Add debug code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
29980
diff
changeset
|
1018 #endif |
25012 | 1019 } |
1020 | |
1021 | |
1022 /* Make ROW an empty, enabled row of canonical character height, | |
1023 in window W starting at y-position Y. */ | |
1024 | |
1025 void | |
1026 blank_row (w, row, y) | |
1027 struct window *w; | |
1028 struct glyph_row *row; | |
1029 int y; | |
1030 { | |
1031 int min_y, max_y; | |
1032 | |
25546 | 1033 min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w); |
25012 | 1034 max_y = WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w); |
1035 | |
1036 clear_glyph_row (row); | |
1037 row->y = y; | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1038 row->ascent = row->phys_ascent = 0; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1039 row->height = row->phys_height = CANON_Y_UNIT (XFRAME (w->frame)); |
25012 | 1040 |
1041 if (row->y < min_y) | |
1042 row->visible_height = row->height - (min_y - row->y); | |
1043 else if (row->y + row->height > max_y) | |
1044 row->visible_height = row->height - (row->y + row->height - max_y); | |
1045 else | |
1046 row->visible_height = row->height; | |
1047 | |
1048 row->enabled_p = 1; | |
1049 } | |
1050 | |
1051 | |
1052 /* Increment buffer positions in glyph row ROW. DELTA and DELTA_BYTES | |
1053 are the amounts by which to change positions. Note that the first | |
1054 glyph of the text area of a row can have a buffer position even if | |
1055 the used count of the text area is zero. Such rows display line | |
1056 ends. */ | |
1057 | |
1058 void | |
28708
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
1059 increment_row_positions (row, delta, delta_bytes) |
25012 | 1060 struct glyph_row *row; |
1061 int delta, delta_bytes; | |
1062 { | |
1063 int area, i; | |
1064 | |
1065 /* Increment start and end positions. */ | |
1066 MATRIX_ROW_START_CHARPOS (row) += delta; | |
1067 MATRIX_ROW_START_BYTEPOS (row) += delta_bytes; | |
1068 MATRIX_ROW_END_CHARPOS (row) += delta; | |
1069 MATRIX_ROW_END_BYTEPOS (row) += delta_bytes; | |
1070 | |
1071 /* Increment positions in glyphs. */ | |
1072 for (area = 0; area < LAST_AREA; ++area) | |
1073 for (i = 0; i < row->used[area]; ++i) | |
1074 if (BUFFERP (row->glyphs[area][i].object) | |
1075 && row->glyphs[area][i].charpos > 0) | |
1076 row->glyphs[area][i].charpos += delta; | |
1077 | |
1078 /* Capture the case of rows displaying a line end. */ | |
1079 if (row->used[TEXT_AREA] == 0 | |
1080 && MATRIX_ROW_DISPLAYS_TEXT_P (row)) | |
1081 row->glyphs[TEXT_AREA]->charpos += delta; | |
1082 } | |
1083 | |
1084 | |
29336
5ccfe8a1638f
(find_glyph_row_slice, swap_glyphs_in_rows): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
28708
diff
changeset
|
1085 #if 0 |
25012 | 1086 /* Swap glyphs between two glyph rows A and B. This exchanges glyph |
1087 contents, i.e. glyph structure contents are exchanged between A and | |
1088 B without changing glyph pointers in A and B. */ | |
1089 | |
1090 static void | |
1091 swap_glyphs_in_rows (a, b) | |
1092 struct glyph_row *a, *b; | |
1093 { | |
1094 int area; | |
1095 | |
1096 for (area = 0; area < LAST_AREA; ++area) | |
1097 { | |
1098 /* Number of glyphs to swap. */ | |
1099 int max_used = max (a->used[area], b->used[area]); | |
1100 | |
1101 /* Start of glyphs in area of row A. */ | |
1102 struct glyph *glyph_a = a->glyphs[area]; | |
1103 | |
1104 /* End + 1 of glyphs in area of row A. */ | |
1105 struct glyph *glyph_a_end = a->glyphs[max_used]; | |
1106 | |
1107 /* Start of glyphs in area of row B. */ | |
1108 struct glyph *glyph_b = b->glyphs[area]; | |
1109 | |
1110 while (glyph_a < glyph_a_end) | |
1111 { | |
1112 /* Non-ISO HP/UX compiler doesn't like auto struct | |
1113 initialization. */ | |
1114 struct glyph temp; | |
1115 temp = *glyph_a; | |
1116 *glyph_a = *glyph_b; | |
1117 *glyph_b = temp; | |
1118 ++glyph_a; | |
1119 ++glyph_b; | |
314 | 1120 } |
1121 } | |
1122 } | |
25012 | 1123 |
29336
5ccfe8a1638f
(find_glyph_row_slice, swap_glyphs_in_rows): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
28708
diff
changeset
|
1124 #endif /* 0 */ |
25012 | 1125 |
1126 /* Exchange pointers to glyph memory between glyph rows A and B. */ | |
1127 | |
1128 static INLINE void | |
1129 swap_glyph_pointers (a, b) | |
1130 struct glyph_row *a, *b; | |
1131 { | |
1132 int i; | |
1133 for (i = 0; i < LAST_AREA + 1; ++i) | |
1134 { | |
1135 struct glyph *temp = a->glyphs[i]; | |
1136 a->glyphs[i] = b->glyphs[i]; | |
1137 b->glyphs[i] = temp; | |
1138 } | |
1139 } | |
1140 | |
1141 | |
1142 /* Copy glyph row structure FROM to glyph row structure TO, except | |
1143 that glyph pointers in the structures are left unchanged. */ | |
1144 | |
1145 INLINE void | |
1146 copy_row_except_pointers (to, from) | |
1147 struct glyph_row *to, *from; | |
1148 { | |
1149 struct glyph *pointers[1 + LAST_AREA]; | |
1150 | |
1151 /* Save glyph pointers of TO. */ | |
1152 bcopy (to->glyphs, pointers, sizeof to->glyphs); | |
1153 | |
1154 /* Do a structure assignment. */ | |
1155 *to = *from; | |
1156 | |
1157 /* Restore original pointers of TO. */ | |
1158 bcopy (pointers, to->glyphs, sizeof to->glyphs); | |
1159 } | |
1160 | |
1161 | |
1162 /* Copy contents of glyph row FROM to glyph row TO. Glyph pointers in | |
1163 TO and FROM are left unchanged. Glyph contents are copied from the | |
1164 glyph memory of FROM to the glyph memory of TO. Increment buffer | |
1165 positions in row TO by DELTA/ DELTA_BYTES. */ | |
1166 | |
1167 void | |
1168 copy_glyph_row_contents (to, from, delta, delta_bytes) | |
1169 struct glyph_row *to, *from; | |
1170 int delta, delta_bytes; | |
1171 { | |
1172 int area; | |
1173 | |
1174 /* This is like a structure assignment TO = FROM, except that | |
1175 glyph pointers in the rows are left unchanged. */ | |
1176 copy_row_except_pointers (to, from); | |
1177 | |
1178 /* Copy glyphs from FROM to TO. */ | |
1179 for (area = 0; area < LAST_AREA; ++area) | |
1180 if (from->used[area]) | |
1181 bcopy (from->glyphs[area], to->glyphs[area], | |
1182 from->used[area] * sizeof (struct glyph)); | |
1183 | |
1184 /* Increment buffer positions in TO by DELTA. */ | |
28708
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
1185 increment_row_positions (to, delta, delta_bytes); |
25012 | 1186 } |
1187 | |
1188 | |
1189 /* Assign glyph row FROM to glyph row TO. This works like a structure | |
1190 assignment TO = FROM, except that glyph pointers are not copied but | |
1191 exchanged between TO and FROM. Pointers must be exchanged to avoid | |
1192 a memory leak. */ | |
1193 | |
1194 static INLINE void | |
1195 assign_row (to, from) | |
1196 struct glyph_row *to, *from; | |
1197 { | |
1198 swap_glyph_pointers (to, from); | |
1199 copy_row_except_pointers (to, from); | |
1200 } | |
1201 | |
1202 | |
1203 /* Test whether the glyph memory of the glyph row WINDOW_ROW, which is | |
1204 a row in a window matrix, is a slice of the glyph memory of the | |
1205 glyph row FRAME_ROW which is a row in a frame glyph matrix. Value | |
1206 is non-zero if the glyph memory of WINDOW_ROW is part of the glyph | |
1207 memory of FRAME_ROW. */ | |
1208 | |
30323
4cd1b8fe118c
(direct_output_for_insert): Remove confusing
Gerd Moellmann <gerd@gnu.org>
parents:
30307
diff
changeset
|
1209 #ifdef GLYPH_DEBUG |
4cd1b8fe118c
(direct_output_for_insert): Remove confusing
Gerd Moellmann <gerd@gnu.org>
parents:
30307
diff
changeset
|
1210 |
25012 | 1211 static int |
1212 glyph_row_slice_p (window_row, frame_row) | |
1213 struct glyph_row *window_row, *frame_row; | |
1214 { | |
1215 struct glyph *window_glyph_start = window_row->glyphs[0]; | |
1216 struct glyph *frame_glyph_start = frame_row->glyphs[0]; | |
1217 struct glyph *frame_glyph_end = frame_row->glyphs[LAST_AREA]; | |
1218 | |
1219 return (frame_glyph_start <= window_glyph_start | |
1220 && window_glyph_start < frame_glyph_end); | |
1221 } | |
1222 | |
30323
4cd1b8fe118c
(direct_output_for_insert): Remove confusing
Gerd Moellmann <gerd@gnu.org>
parents:
30307
diff
changeset
|
1223 #endif /* GLYPH_DEBUG */ |
25012 | 1224 |
29336
5ccfe8a1638f
(find_glyph_row_slice, swap_glyphs_in_rows): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
28708
diff
changeset
|
1225 #if 0 |
5ccfe8a1638f
(find_glyph_row_slice, swap_glyphs_in_rows): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
28708
diff
changeset
|
1226 |
25012 | 1227 /* Find the row in the window glyph matrix WINDOW_MATRIX being a slice |
1228 of ROW in the frame matrix FRAME_MATRIX. Value is null if no row | |
1229 in WINDOW_MATRIX is found satisfying the condition. */ | |
1230 | |
1231 static struct glyph_row * | |
1232 find_glyph_row_slice (window_matrix, frame_matrix, row) | |
1233 struct glyph_matrix *window_matrix, *frame_matrix; | |
1234 int row; | |
1235 { | |
1236 int i; | |
1237 | |
1238 xassert (row >= 0 && row < frame_matrix->nrows); | |
1239 | |
1240 for (i = 0; i < window_matrix->nrows; ++i) | |
1241 if (glyph_row_slice_p (window_matrix->rows + i, | |
1242 frame_matrix->rows + row)) | |
1243 break; | |
1244 | |
1245 return i < window_matrix->nrows ? window_matrix->rows + i : 0; | |
1246 } | |
1247 | |
29336
5ccfe8a1638f
(find_glyph_row_slice, swap_glyphs_in_rows): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
28708
diff
changeset
|
1248 #endif /* 0 */ |
25012 | 1249 |
1250 /* Prepare ROW for display. Desired rows are cleared lazily, | |
1251 i.e. they are only marked as to be cleared by setting their | |
1252 enabled_p flag to zero. When a row is to be displayed, a prior | |
1253 call to this function really clears it. */ | |
1254 | |
1255 void | |
1256 prepare_desired_row (row) | |
1257 struct glyph_row *row; | |
1258 { | |
1259 if (!row->enabled_p) | |
1260 { | |
1261 clear_glyph_row (row); | |
1262 row->enabled_p = 1; | |
1263 } | |
1264 } | |
1265 | |
1266 | |
1267 /* Return a hash code for glyph row ROW. */ | |
1268 | |
1269 int | |
1270 line_hash_code (row) | |
1271 struct glyph_row *row; | |
1272 { | |
1273 int hash = 0; | |
1274 | |
1275 if (row->enabled_p) | |
1276 { | |
1277 if (row->inverse_p) | |
1278 { | |
1279 /* Give all highlighted lines the same hash code | |
1280 so as to encourage scrolling to leave them in place. */ | |
1281 hash = -1; | |
1282 } | |
1283 else | |
1284 { | |
1285 struct glyph *glyph = row->glyphs[TEXT_AREA]; | |
1286 struct glyph *end = glyph + row->used[TEXT_AREA]; | |
1287 | |
1288 while (glyph < end) | |
1289 { | |
26998
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
1290 int c = glyph->u.ch; |
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
1291 int face_id = glyph->face_id; |
25012 | 1292 if (must_write_spaces) |
26998
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
1293 c -= SPACEGLYPH; |
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
1294 hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c; |
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
1295 hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id; |
25012 | 1296 ++glyph; |
1297 } | |
1298 | |
1299 if (hash == 0) | |
1300 hash = 1; | |
1301 } | |
1302 } | |
1303 | |
1304 return hash; | |
1305 } | |
1306 | |
1307 | |
1308 /* Return the cost of drawing line VPOS In MATRIX. The cost equals | |
1309 the number of characters in the line. If must_write_spaces is | |
1310 zero, leading and trailing spaces are ignored. */ | |
1311 | |
1312 static unsigned int | |
1313 line_draw_cost (matrix, vpos) | |
1314 struct glyph_matrix *matrix; | |
1315 int vpos; | |
1316 { | |
1317 struct glyph_row *row = matrix->rows + vpos; | |
1318 struct glyph *beg = row->glyphs[TEXT_AREA]; | |
1319 struct glyph *end = beg + row->used[TEXT_AREA]; | |
1320 int len; | |
1321 Lisp_Object *glyph_table_base = GLYPH_TABLE_BASE; | |
1322 int glyph_table_len = GLYPH_TABLE_LENGTH; | |
1323 | |
1324 /* Ignore trailing and leading spaces if we can. */ | |
1325 if (!must_write_spaces) | |
1326 { | |
1327 /* Skip from the end over trailing spaces. */ | |
34203
e55480843a8e
(scrolling_window): Fix code inserting runs in list of all runs.
Gerd Moellmann <gerd@gnu.org>
parents:
33763
diff
changeset
|
1328 while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1))) |
25012 | 1329 --end; |
1330 | |
1331 /* All blank line. */ | |
1332 if (end == beg) | |
1333 return 0; | |
1334 | |
1335 /* Skip over leading spaces. */ | |
1336 while (CHAR_GLYPH_SPACE_P (*beg)) | |
1337 ++beg; | |
1338 } | |
1339 | |
1340 /* If we don't have a glyph-table, each glyph is one character, | |
1341 so return the number of glyphs. */ | |
1342 if (glyph_table_base == 0) | |
1343 len = end - beg; | |
1344 else | |
1345 { | |
1346 /* Otherwise, scan the glyphs and accumulate their total length | |
1347 in LEN. */ | |
1348 len = 0; | |
1349 while (beg < end) | |
1350 { | |
1351 GLYPH g = GLYPH_FROM_CHAR_GLYPH (*beg); | |
1352 | |
26998
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
1353 if (g < 0 |
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
1354 || GLYPH_SIMPLE_P (glyph_table_base, glyph_table_len, g)) |
25012 | 1355 len += 1; |
1356 else | |
1357 len += GLYPH_LENGTH (glyph_table_base, g); | |
1358 | |
1359 ++beg; | |
1360 } | |
1361 } | |
1362 | |
1363 return len; | |
1364 } | |
1365 | |
1366 | |
1367 /* Test two glyph rows A and B for equality. Value is non-zero if A | |
1368 and B have equal contents. W is the window to which the glyphs | |
1369 rows A and B belong. It is needed here to test for partial row | |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
1370 visibility. MOUSE_FACE_P non-zero means compare the mouse_face_p |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
1371 flags of A and B, too. */ |
25012 | 1372 |
1373 static INLINE int | |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
1374 row_equal_p (w, a, b, mouse_face_p) |
25012 | 1375 struct window *w; |
1376 struct glyph_row *a, *b; | |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
1377 int mouse_face_p; |
25012 | 1378 { |
1379 if (a == b) | |
1380 return 1; | |
1381 else if (a->hash != b->hash) | |
1382 return 0; | |
1383 else | |
1384 { | |
1385 struct glyph *a_glyph, *b_glyph, *a_end; | |
1386 int area; | |
1387 | |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
1388 if (mouse_face_p && a->mouse_face_p != b->mouse_face_p) |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
1389 return 0; |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
1390 |
25012 | 1391 /* Compare glyphs. */ |
1392 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) | |
1393 { | |
1394 if (a->used[area] != b->used[area]) | |
1395 return 0; | |
1396 | |
1397 a_glyph = a->glyphs[area]; | |
1398 a_end = a_glyph + a->used[area]; | |
1399 b_glyph = b->glyphs[area]; | |
1400 | |
1401 while (a_glyph < a_end | |
1402 && GLYPH_EQUAL_P (a_glyph, b_glyph)) | |
1403 ++a_glyph, ++b_glyph; | |
1404 | |
1405 if (a_glyph != a_end) | |
1406 return 0; | |
1407 } | |
1408 | |
1409 if (a->truncated_on_left_p != b->truncated_on_left_p | |
1410 || a->inverse_p != b->inverse_p | |
1411 || a->fill_line_p != b->fill_line_p | |
1412 || a->truncated_on_right_p != b->truncated_on_right_p | |
1413 || a->overlay_arrow_p != b->overlay_arrow_p | |
1414 || a->continued_p != b->continued_p | |
1415 || a->indicate_empty_line_p != b->indicate_empty_line_p | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1416 || a->overlapped_p != b->overlapped_p |
25012 | 1417 || (MATRIX_ROW_CONTINUATION_LINE_P (a) |
1418 != MATRIX_ROW_CONTINUATION_LINE_P (b)) | |
1419 /* Different partially visible characters on left margin. */ | |
1420 || a->x != b->x | |
1421 /* Different height. */ | |
1422 || a->ascent != b->ascent | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1423 || a->phys_ascent != b->phys_ascent |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1424 || a->phys_height != b->phys_height |
25012 | 1425 || a->visible_height != b->visible_height) |
1426 return 0; | |
1427 } | |
1428 | |
1429 return 1; | |
1430 } | |
1431 | |
1432 | |
314 | 1433 |
25012 | 1434 /*********************************************************************** |
1435 Glyph Pool | |
1436 | |
1437 See dispextern.h for an overall explanation of glyph pools. | |
1438 ***********************************************************************/ | |
1439 | |
1440 /* Allocate a glyph_pool structure. The structure returned is | |
1441 initialized with zeros. The global variable glyph_pool_count is | |
1442 incremented for each pool allocated. */ | |
1443 | |
1444 static struct glyph_pool * | |
1445 new_glyph_pool () | |
1446 { | |
1447 struct glyph_pool *result; | |
1448 | |
1449 /* Allocate a new glyph_pool and clear it. */ | |
1450 result = (struct glyph_pool *) xmalloc (sizeof *result); | |
1451 bzero (result, sizeof *result); | |
1452 | |
1453 /* For memory leak and double deletion checking. */ | |
1454 ++glyph_pool_count; | |
1455 | |
1456 return result; | |
1457 } | |
1458 | |
1459 | |
1460 /* Free a glyph_pool structure POOL. The function may be called with | |
1461 a null POOL pointer. The global variable glyph_pool_count is | |
1462 decremented with every pool structure freed. If this count gets | |
1463 negative, more structures were freed than allocated, i.e. one | |
1464 structure must have been freed more than once or a bogus pointer | |
1465 was passed to free_glyph_pool. */ | |
1466 | |
1467 static void | |
1468 free_glyph_pool (pool) | |
1469 struct glyph_pool *pool; | |
1470 { | |
1471 if (pool) | |
1472 { | |
1473 /* More freed than allocated? */ | |
1474 --glyph_pool_count; | |
1475 xassert (glyph_pool_count >= 0); | |
1476 | |
1477 xfree (pool->glyphs); | |
1478 xfree (pool); | |
1479 } | |
1480 } | |
1481 | |
1482 | |
1483 /* Enlarge a glyph pool POOL. MATRIX_DIM gives the number of rows and | |
1484 columns we need. This function never shrinks a pool. The only | |
1485 case in which this would make sense, would be when a frame's size | |
1486 is changed from a large value to a smaller one. But, if someone | |
1487 does it once, we can expect that he will do it again. | |
1488 | |
1489 Value is non-zero if the pool changed in a way which makes | |
1490 re-adjusting window glyph matrices necessary. */ | |
1491 | |
1492 static int | |
1493 realloc_glyph_pool (pool, matrix_dim) | |
1494 struct glyph_pool *pool; | |
1495 struct dim matrix_dim; | |
1496 { | |
1497 int needed; | |
1498 int changed_p; | |
1499 | |
1500 changed_p = (pool->glyphs == 0 | |
1501 || matrix_dim.height != pool->nrows | |
1502 || matrix_dim.width != pool->ncolumns); | |
1503 | |
1504 /* Enlarge the glyph pool. */ | |
1505 needed = matrix_dim.width * matrix_dim.height; | |
1506 if (needed > pool->nglyphs) | |
1507 { | |
1508 int size = needed * sizeof (struct glyph); | |
1509 | |
1510 if (pool->glyphs) | |
1511 pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size); | |
1512 else | |
1513 { | |
1514 pool->glyphs = (struct glyph *) xmalloc (size); | |
1515 bzero (pool->glyphs, size); | |
1516 } | |
1517 | |
1518 pool->nglyphs = needed; | |
1519 } | |
1520 | |
1521 /* Remember the number of rows and columns because (a) we use then | |
1522 to do sanity checks, and (b) the number of columns determines | |
1523 where rows in the frame matrix start---this must be available to | |
1524 determine pointers to rows of window sub-matrices. */ | |
1525 pool->nrows = matrix_dim.height; | |
1526 pool->ncolumns = matrix_dim.width; | |
1527 | |
1528 return changed_p; | |
1529 } | |
1530 | |
1531 | |
1532 | |
1533 /*********************************************************************** | |
1534 Debug Code | |
1535 ***********************************************************************/ | |
1536 | |
1537 #if GLYPH_DEBUG | |
1538 | |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1539 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1540 /* Flush standard output. This is sometimes useful to call from |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1541 the debugger. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1542 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1543 void |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1544 flush_stdout () |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1545 { |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1546 fflush (stdout); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1547 } |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1548 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1549 |
25012 | 1550 /* Check that no glyph pointers have been lost in MATRIX. If a |
1551 pointer has been lost, e.g. by using a structure assignment between | |
1552 rows, at least one pointer must occur more than once in the rows of | |
1553 MATRIX. */ | |
1554 | |
1555 void | |
1556 check_matrix_pointer_lossage (matrix) | |
1557 struct glyph_matrix *matrix; | |
1558 { | |
1559 int i, j; | |
1560 | |
1561 for (i = 0; i < matrix->nrows; ++i) | |
1562 for (j = 0; j < matrix->nrows; ++j) | |
1563 xassert (i == j | |
1564 || (matrix->rows[i].glyphs[TEXT_AREA] | |
1565 != matrix->rows[j].glyphs[TEXT_AREA])); | |
1566 } | |
1567 | |
1568 | |
1569 /* Get a pointer to glyph row ROW in MATRIX, with bounds checks. */ | |
1570 | |
1571 struct glyph_row * | |
1572 matrix_row (matrix, row) | |
1573 struct glyph_matrix *matrix; | |
1574 int row; | |
1575 { | |
1576 xassert (matrix && matrix->rows); | |
1577 xassert (row >= 0 && row < matrix->nrows); | |
1578 | |
1579 /* That's really too slow for normal testing because this function | |
1580 is called almost everywhere. Although---it's still astonishingly | |
1581 fast, so it is valuable to have for debugging purposes. */ | |
314 | 1582 #if 0 |
25012 | 1583 check_matrix_pointer_lossage (matrix); |
1584 #endif | |
1585 | |
1586 return matrix->rows + row; | |
1587 } | |
1588 | |
1589 | |
1590 #if 0 /* This function makes invalid assumptions when text is | |
1591 partially invisible. But it might come handy for debugging | |
1592 nevertheless. */ | |
1593 | |
1594 /* Check invariants that must hold for an up to date current matrix of | |
1595 window W. */ | |
1596 | |
1597 static void | |
1598 check_matrix_invariants (w) | |
314 | 1599 struct window *w; |
1600 { | |
25012 | 1601 struct glyph_matrix *matrix = w->current_matrix; |
1602 int yb = window_text_bottom_y (w); | |
1603 struct glyph_row *row = matrix->rows; | |
1604 struct glyph_row *last_text_row = NULL; | |
1605 struct buffer *saved = current_buffer; | |
1606 struct buffer *buffer = XBUFFER (w->buffer); | |
1607 int c; | |
1608 | |
1609 /* This can sometimes happen for a fresh window. */ | |
1610 if (matrix->nrows < 2) | |
1611 return; | |
1612 | |
1613 set_buffer_temp (buffer); | |
1614 | |
1615 /* Note: last row is always reserved for the mode line. */ | |
1616 while (MATRIX_ROW_DISPLAYS_TEXT_P (row) | |
1617 && MATRIX_ROW_BOTTOM_Y (row) < yb) | |
1618 { | |
1619 struct glyph_row *next = row + 1; | |
1620 | |
1621 if (MATRIX_ROW_DISPLAYS_TEXT_P (row)) | |
1622 last_text_row = row; | |
1623 | |
1624 /* Check that character and byte positions are in sync. */ | |
1625 xassert (MATRIX_ROW_START_BYTEPOS (row) | |
1626 == CHAR_TO_BYTE (MATRIX_ROW_START_CHARPOS (row))); | |
1627 | |
1628 /* CHAR_TO_BYTE aborts when invoked for a position > Z. We can | |
1629 have such a position temporarily in case of a minibuffer | |
1630 displaying something like `[Sole completion]' at its end. */ | |
1631 if (MATRIX_ROW_END_CHARPOS (row) < BUF_ZV (current_buffer)) | |
1632 xassert (MATRIX_ROW_END_BYTEPOS (row) | |
1633 == CHAR_TO_BYTE (MATRIX_ROW_END_CHARPOS (row))); | |
1634 | |
1635 /* Check that end position of `row' is equal to start position | |
1636 of next row. */ | |
1637 if (next->enabled_p && MATRIX_ROW_DISPLAYS_TEXT_P (next)) | |
1638 { | |
1639 xassert (MATRIX_ROW_END_CHARPOS (row) | |
1640 == MATRIX_ROW_START_CHARPOS (next)); | |
1641 xassert (MATRIX_ROW_END_BYTEPOS (row) | |
1642 == MATRIX_ROW_START_BYTEPOS (next)); | |
1643 } | |
1644 row = next; | |
1645 } | |
1646 | |
1647 xassert (w->current_matrix->nrows == w->desired_matrix->nrows); | |
1648 xassert (w->desired_matrix->rows != NULL); | |
1649 set_buffer_temp (saved); | |
1650 } | |
1651 | |
1652 #endif /* 0 */ | |
1653 | |
1654 #endif /* GLYPH_DEBUG != 0 */ | |
1655 | |
1656 | |
1657 | |
1658 /********************************************************************** | |
1659 Allocating/ Adjusting Glyph Matrices | |
1660 **********************************************************************/ | |
1661 | |
1662 /* Allocate glyph matrices over a window tree for a frame-based | |
1663 redisplay | |
1664 | |
1665 X and Y are column/row within the frame glyph matrix where | |
1666 sub-matrices for the window tree rooted at WINDOW must be | |
1667 allocated. CH_DIM contains the dimensions of the smallest | |
1668 character that could be used during display. DIM_ONLY_P non-zero | |
1669 means that the caller of this function is only interested in the | |
1670 result matrix dimension, and matrix adjustments should not be | |
1671 performed. | |
1672 | |
1673 The function returns the total width/height of the sub-matrices of | |
1674 the window tree. If called on a frame root window, the computation | |
1675 will take the mini-buffer window into account. | |
1676 | |
1677 *WINDOW_CHANGE_FLAGS is set to a bit mask with bits | |
1678 | |
1679 NEW_LEAF_MATRIX set if any window in the tree did not have a | |
1680 glyph matrices yet, and | |
1681 | |
1682 CHANGED_LEAF_MATRIX set if the dimension or location of a matrix of | |
1683 any window in the tree will be changed or have been changed (see | |
1684 DIM_ONLY_P). | |
1685 | |
1686 *WINDOW_CHANGE_FLAGS must be initialized by the caller of this | |
1687 function. | |
1688 | |
1689 Windows are arranged into chains of windows on the same level | |
1690 through the next fields of window structures. Such a level can be | |
1691 either a sequence of horizontally adjacent windows from left to | |
1692 right, or a sequence of vertically adjacent windows from top to | |
1693 bottom. Each window in a horizontal sequence can be either a leaf | |
1694 window or a vertical sequence; a window in a vertical sequence can | |
1695 be either a leaf or a horizontal sequence. All windows in a | |
1696 horizontal sequence have the same height, and all windows in a | |
1697 vertical sequence have the same width. | |
1698 | |
1699 This function uses, for historical reasons, a more general | |
1700 algorithm to determine glyph matrix dimensions that would be | |
1701 necessary. | |
1702 | |
1703 The matrix height of a horizontal sequence is determined by the | |
1704 maximum height of any matrix in the sequence. The matrix width of | |
1705 a horizontal sequence is computed by adding up matrix widths of | |
1706 windows in the sequence. | |
1707 | |
1708 |<------- result width ------->| | |
1709 +---------+----------+---------+ --- | |
1710 | | | | | | |
1711 | | | | | |
1712 +---------+ | | result height | |
1713 | +---------+ | |
1714 | | | | |
1715 +----------+ --- | |
1716 | |
1717 The matrix width of a vertical sequence is the maximum matrix width | |
1718 of any window in the sequence. Its height is computed by adding up | |
1719 matrix heights of windows in the sequence. | |
1720 | |
1721 |<---- result width -->| | |
1722 +---------+ --- | |
1723 | | | | |
1724 | | | | |
1725 +---------+--+ | | |
1726 | | | | |
1727 | | result height | |
1728 | | | |
1729 +------------+---------+ | | |
1730 | | | | |
1731 | | | | |
1732 +------------+---------+ --- */ | |
1733 | |
1734 /* Bit indicating that a new matrix will be allocated or has been | |
1735 allocated. */ | |
1736 | |
1737 #define NEW_LEAF_MATRIX (1 << 0) | |
1738 | |
1739 /* Bit indicating that a matrix will or has changed its location or | |
1740 size. */ | |
1741 | |
1742 #define CHANGED_LEAF_MATRIX (1 << 1) | |
1743 | |
1744 static struct dim | |
1745 allocate_matrices_for_frame_redisplay (window, x, y, ch_dim, | |
1746 dim_only_p, window_change_flags) | |
1747 Lisp_Object window; | |
1748 int x, y; | |
1749 struct dim ch_dim; | |
1750 int dim_only_p; | |
1751 int *window_change_flags; | |
1752 { | |
1753 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window))); | |
1754 int x0 = x, y0 = y; | |
1755 int wmax = 0, hmax = 0; | |
1756 struct dim total; | |
1757 struct dim dim; | |
1758 struct window *w; | |
1759 int in_horz_combination_p; | |
1760 | |
1761 /* What combination is WINDOW part of? Compute this once since the | |
1762 result is the same for all windows in the `next' chain. The | |
1763 special case of a root window (parent equal to nil) is treated | |
1764 like a vertical combination because a root window's `next' | |
1765 points to the mini-buffer window, if any, which is arranged | |
1766 vertically below other windows. */ | |
1767 in_horz_combination_p | |
1768 = (!NILP (XWINDOW (window)->parent) | |
1769 && !NILP (XWINDOW (XWINDOW (window)->parent)->hchild)); | |
1770 | |
1771 /* For WINDOW and all windows on the same level. */ | |
1772 do | |
1773 { | |
1774 w = XWINDOW (window); | |
1775 | |
1776 /* Get the dimension of the window sub-matrix for W, depending | |
1777 on whether this a combination or a leaf window. */ | |
1778 if (!NILP (w->hchild)) | |
1779 dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y, ch_dim, | |
1780 dim_only_p, | |
1781 window_change_flags); | |
1782 else if (!NILP (w->vchild)) | |
1783 dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y, ch_dim, | |
1784 dim_only_p, | |
1785 window_change_flags); | |
1786 else | |
1787 { | |
1788 /* If not already done, allocate sub-matrix structures. */ | |
1789 if (w->desired_matrix == NULL) | |
1790 { | |
1791 w->desired_matrix = new_glyph_matrix (f->desired_pool); | |
1792 w->current_matrix = new_glyph_matrix (f->current_pool); | |
1793 *window_change_flags |= NEW_LEAF_MATRIX; | |
1794 } | |
1795 | |
1796 /* Width and height MUST be chosen so that there are no | |
1797 holes in the frame matrix. */ | |
28507
b6f06a755c7d
make_number/XINT/XUINT conversions; EQ/== fixes; ==Qnil -> NILP
Ken Raeburn <raeburn@raeburn.org>
parents:
28361
diff
changeset
|
1798 dim.width = XINT (w->width); |
b6f06a755c7d
make_number/XINT/XUINT conversions; EQ/== fixes; ==Qnil -> NILP
Ken Raeburn <raeburn@raeburn.org>
parents:
28361
diff
changeset
|
1799 dim.height = XINT (w->height); |
25012 | 1800 |
1801 /* Will matrix be re-allocated? */ | |
1802 if (x != w->desired_matrix->matrix_x | |
1803 || y != w->desired_matrix->matrix_y | |
1804 || dim.width != w->desired_matrix->matrix_w | |
1805 || dim.height != w->desired_matrix->matrix_h | |
1806 || (margin_glyphs_to_reserve (w, dim.width, | |
1807 w->right_margin_width) | |
1808 != w->desired_matrix->left_margin_glyphs) | |
1809 || (margin_glyphs_to_reserve (w, dim.width, | |
1810 w->left_margin_width) | |
1811 != w->desired_matrix->right_margin_glyphs)) | |
1812 *window_change_flags |= CHANGED_LEAF_MATRIX; | |
1813 | |
1814 /* Actually change matrices, if allowed. Do not consider | |
1815 CHANGED_LEAF_MATRIX computed above here because the pool | |
1816 may have been changed which we don't now here. We trust | |
1817 that we only will be called with DIM_ONLY_P != 0 when | |
1818 necessary. */ | |
1819 if (!dim_only_p) | |
1820 { | |
1821 adjust_glyph_matrix (w, w->desired_matrix, x, y, dim); | |
1822 adjust_glyph_matrix (w, w->current_matrix, x, y, dim); | |
1823 } | |
1824 } | |
1825 | |
1826 /* If we are part of a horizontal combination, advance x for | |
1827 windows to the right of W; otherwise advance y for windows | |
1828 below W. */ | |
1829 if (in_horz_combination_p) | |
1830 x += dim.width; | |
1831 else | |
1832 y += dim.height; | |
1833 | |
1834 /* Remember maximum glyph matrix dimensions. */ | |
1835 wmax = max (wmax, dim.width); | |
1836 hmax = max (hmax, dim.height); | |
1837 | |
1838 /* Next window on same level. */ | |
1839 window = w->next; | |
1840 } | |
1841 while (!NILP (window)); | |
1842 | |
1843 /* Set `total' to the total glyph matrix dimension of this window | |
1844 level. In a vertical combination, the width is the width of the | |
1845 widest window; the height is the y we finally reached, corrected | |
1846 by the y we started with. In a horizontal combination, the total | |
1847 height is the height of the tallest window, and the width is the | |
1848 x we finally reached, corrected by the x we started with. */ | |
1849 if (in_horz_combination_p) | |
1850 { | |
1851 total.width = x - x0; | |
1852 total.height = hmax; | |
1853 } | |
1854 else | |
1855 { | |
1856 total.width = wmax; | |
1857 total.height = y - y0; | |
1858 } | |
1859 | |
1860 return total; | |
1861 } | |
1862 | |
1863 | |
1864 /* Allocate window matrices for window-based redisplay. W is the | |
1865 window whose matrices must be allocated/reallocated. CH_DIM is the | |
1866 size of the smallest character that could potentially be used on W. */ | |
1867 | |
1868 static void | |
1869 allocate_matrices_for_window_redisplay (w, ch_dim) | |
1870 struct window *w; | |
1871 struct dim ch_dim; | |
1872 { | |
1873 struct frame *f = XFRAME (w->frame); | |
1874 | |
1875 while (w) | |
314 | 1876 { |
25012 | 1877 if (!NILP (w->vchild)) |
1878 allocate_matrices_for_window_redisplay (XWINDOW (w->vchild), ch_dim); | |
1879 else if (!NILP (w->hchild)) | |
1880 allocate_matrices_for_window_redisplay (XWINDOW (w->hchild), ch_dim); | |
1881 else | |
314 | 1882 { |
25012 | 1883 /* W is a leaf window. */ |
1884 int window_pixel_width = XFLOATINT (w->width) * CANON_X_UNIT (f); | |
1885 int window_pixel_height = window_box_height (w) + abs (w->vscroll); | |
1886 struct dim dim; | |
1887 | |
1888 /* If matrices are not yet allocated, allocate them now. */ | |
1889 if (w->desired_matrix == NULL) | |
314 | 1890 { |
25012 | 1891 w->desired_matrix = new_glyph_matrix (NULL); |
1892 w->current_matrix = new_glyph_matrix (NULL); | |
314 | 1893 } |
25012 | 1894 |
1895 /* Compute number of glyphs needed in a glyph row. */ | |
1896 dim.width = (((window_pixel_width + ch_dim.width - 1) | |
1897 / ch_dim.width) | |
1898 /* 2 partially visible columns in the text area. */ | |
1899 + 2 | |
1900 /* One partially visible column at the right | |
1901 edge of each marginal area. */ | |
1902 + 1 + 1); | |
1903 | |
1904 /* Compute number of glyph rows needed. */ | |
1905 dim.height = (((window_pixel_height + ch_dim.height - 1) | |
1906 / ch_dim.height) | |
1907 /* One partially visible line at the top and | |
1908 bottom of the window. */ | |
1909 + 2 | |
1910 /* 2 for top and mode line. */ | |
1911 + 2); | |
1912 | |
1913 /* Change matrices. */ | |
1914 adjust_glyph_matrix (w, w->desired_matrix, 0, 0, dim); | |
1915 adjust_glyph_matrix (w, w->current_matrix, 0, 0, dim); | |
1916 } | |
1917 | |
1918 w = NILP (w->next) ? NULL : XWINDOW (w->next); | |
1919 } | |
1920 } | |
1921 | |
1922 | |
1923 /* Re-allocate/ re-compute glyph matrices on frame F. If F is null, | |
1924 do it for all frames; otherwise do it just for the given frame. | |
1925 This function must be called when a new frame is created, its size | |
1926 changes, or its window configuration changes. */ | |
1927 | |
1928 void | |
1929 adjust_glyphs (f) | |
1930 struct frame *f; | |
1931 { | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1932 /* Block input so that expose events and other events that access |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1933 glyph matrices are not processed while we are changing them. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1934 BLOCK_INPUT; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1935 |
25012 | 1936 if (f) |
1937 adjust_frame_glyphs (f); | |
1938 else | |
1939 { | |
1940 Lisp_Object tail, lisp_frame; | |
1941 | |
1942 FOR_EACH_FRAME (tail, lisp_frame) | |
1943 adjust_frame_glyphs (XFRAME (lisp_frame)); | |
1944 } | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1945 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
1946 UNBLOCK_INPUT; |
25012 | 1947 } |
1948 | |
1949 | |
1950 /* Adjust frame glyphs when Emacs is initialized. | |
1951 | |
1952 To be called from init_display. | |
1953 | |
1954 We need a glyph matrix because redraw will happen soon. | |
1955 Unfortunately, window sizes on selected_frame are not yet set to | |
1956 meaningful values. I believe we can assume that there are only two | |
1957 windows on the frame---the mini-buffer and the root window. Frame | |
1958 height and width seem to be correct so far. So, set the sizes of | |
1959 windows to estimated values. */ | |
1960 | |
1961 static void | |
1962 adjust_frame_glyphs_initially () | |
1963 { | |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
1964 struct frame *sf = SELECTED_FRAME (); |
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
1965 struct window *root = XWINDOW (sf->root_window); |
25012 | 1966 struct window *mini = XWINDOW (root->next); |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
1967 int frame_height = FRAME_HEIGHT (sf); |
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
1968 int frame_width = FRAME_WIDTH (sf); |
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
1969 int top_margin = FRAME_TOP_MARGIN (sf); |
25012 | 1970 |
1971 /* Do it for the root window. */ | |
1972 XSETFASTINT (root->top, top_margin); | |
1973 XSETFASTINT (root->width, frame_width); | |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
1974 set_window_height (sf->root_window, frame_height - 1 - top_margin, 0); |
25012 | 1975 |
1976 /* Do it for the mini-buffer window. */ | |
1977 XSETFASTINT (mini->top, frame_height - 1); | |
1978 XSETFASTINT (mini->width, frame_width); | |
1979 set_window_height (root->next, 1, 0); | |
1980 | |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
1981 adjust_frame_glyphs (sf); |
25012 | 1982 glyphs_initialized_initially_p = 1; |
1983 } | |
1984 | |
1985 | |
1986 /* Allocate/reallocate glyph matrices of a single frame F. */ | |
1987 | |
1988 static void | |
1989 adjust_frame_glyphs (f) | |
1990 struct frame *f; | |
1991 { | |
1992 if (FRAME_WINDOW_P (f)) | |
1993 adjust_frame_glyphs_for_window_redisplay (f); | |
1994 else | |
1995 adjust_frame_glyphs_for_frame_redisplay (f); | |
1996 | |
1997 /* Don't forget the message buffer and the buffer for | |
1998 decode_mode_spec. */ | |
1999 adjust_frame_message_buffer (f); | |
2000 adjust_decode_mode_spec_buffer (f); | |
2001 | |
2002 f->glyphs_initialized_p = 1; | |
2003 } | |
2004 | |
2005 | |
34736
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2006 /* In the window tree with root W, build current matrices of leaf |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2007 windows from the frame's current matrix. */ |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2008 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2009 static void |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2010 fake_current_matrices (window) |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2011 Lisp_Object window; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2012 { |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2013 struct window *w; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2014 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2015 for (; !NILP (window); window = w->next) |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2016 { |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2017 w = XWINDOW (window); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2018 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2019 if (!NILP (w->hchild)) |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2020 fake_current_matrices (w->hchild); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2021 else if (!NILP (w->vchild)) |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2022 fake_current_matrices (w->vchild); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2023 else |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2024 { |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2025 int i; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2026 struct frame *f = XFRAME (w->frame); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2027 struct glyph_matrix *m = w->current_matrix; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2028 struct glyph_matrix *fm = f->current_matrix; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2029 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2030 xassert (m->matrix_h == XFASTINT (w->height)); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2031 xassert (m->matrix_w == XFASTINT (w->width)); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2032 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2033 for (i = 0; i < m->matrix_h; ++i) |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2034 { |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2035 struct glyph_row *r = m->rows + i; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2036 struct glyph_row *fr = fm->rows + i + XFASTINT (w->top); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2037 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2038 xassert (r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA] |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2039 && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2040 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2041 r->enabled_p = fr->enabled_p; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2042 if (r->enabled_p) |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2043 { |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2044 r->used[LEFT_MARGIN_AREA] = m->left_margin_glyphs; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2045 r->used[RIGHT_MARGIN_AREA] = m->right_margin_glyphs; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2046 r->used[TEXT_AREA] = (m->matrix_w |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2047 - r->used[LEFT_MARGIN_AREA] |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2048 - r->used[RIGHT_MARGIN_AREA]); |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2049 r->mode_line_p = 0; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2050 r->inverse_p = fr->inverse_p; |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2051 } |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2052 } |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2053 } |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2054 } |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2055 } |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2056 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2057 |
34849
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2058 /* Save or restore the contents of frame F's current frame matrix. |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2059 SAVE_P non-zero means save it. */ |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2060 |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2061 static void |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2062 save_or_restore_current_matrix (f, save_p) |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2063 struct frame *f; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2064 int save_p; |
34736
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2065 { |
34849
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2066 struct glyph_row *from, *to, *end; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2067 |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2068 if (save_p) |
34788
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2069 { |
34849
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2070 from = f->current_matrix->rows; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2071 end = from + f->current_matrix->nrows; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2072 to = f->desired_matrix->rows; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2073 } |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2074 else |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2075 { |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2076 from = f->desired_matrix->rows; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2077 end = from + f->desired_matrix->nrows; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2078 to = f->current_matrix->rows; |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2079 } |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2080 |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2081 for (; from < end; ++from, ++to) |
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2082 { |
34788
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2083 size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2084 bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes); |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2085 to->used[TEXT_AREA] = from->used[TEXT_AREA]; |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2086 } |
34736
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2087 } |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2088 |
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2089 |
25012 | 2090 /* Allocate/reallocate glyph matrices of a single frame F for |
2091 frame-based redisplay. */ | |
2092 | |
2093 static void | |
2094 adjust_frame_glyphs_for_frame_redisplay (f) | |
2095 struct frame *f; | |
2096 { | |
2097 struct dim ch_dim; | |
2098 struct dim matrix_dim; | |
2099 int pool_changed_p; | |
2100 int window_change_flags; | |
2101 int top_window_y; | |
2102 | |
2103 if (!FRAME_LIVE_P (f)) | |
2104 return; | |
2105 | |
2106 /* Determine the smallest character in any font for F. On | |
2107 console windows, all characters have dimension (1, 1). */ | |
2108 ch_dim.width = ch_dim.height = 1; | |
2109 | |
2110 top_window_y = FRAME_TOP_MARGIN (f); | |
2111 | |
2112 /* Allocate glyph pool structures if not already done. */ | |
2113 if (f->desired_pool == NULL) | |
2114 { | |
2115 f->desired_pool = new_glyph_pool (); | |
2116 f->current_pool = new_glyph_pool (); | |
2117 } | |
2118 | |
2119 /* Allocate frames matrix structures if needed. */ | |
2120 if (f->desired_matrix == NULL) | |
2121 { | |
2122 f->desired_matrix = new_glyph_matrix (f->desired_pool); | |
2123 f->current_matrix = new_glyph_matrix (f->current_pool); | |
2124 } | |
34736
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2125 |
25012 | 2126 /* Compute window glyph matrices. (This takes the mini-buffer |
2127 window into account). The result is the size of the frame glyph | |
2128 matrix needed. The variable window_change_flags is set to a bit | |
2129 mask indicating whether new matrices will be allocated or | |
2130 existing matrices change their size or location within the frame | |
2131 matrix. */ | |
2132 window_change_flags = 0; | |
2133 matrix_dim | |
2134 = allocate_matrices_for_frame_redisplay (FRAME_ROOT_WINDOW (f), | |
2135 0, top_window_y, | |
2136 ch_dim, 1, | |
2137 &window_change_flags); | |
2138 | |
2139 /* Add in menu bar lines, if any. */ | |
2140 matrix_dim.height += top_window_y; | |
2141 | |
2142 /* Enlarge pools as necessary. */ | |
2143 pool_changed_p = realloc_glyph_pool (f->desired_pool, matrix_dim); | |
2144 realloc_glyph_pool (f->current_pool, matrix_dim); | |
2145 | |
2146 /* Set up glyph pointers within window matrices. Do this only if | |
2147 absolutely necessary since it requires a frame redraw. */ | |
2148 if (pool_changed_p || window_change_flags) | |
2149 { | |
2150 /* Do it for window matrices. */ | |
2151 allocate_matrices_for_frame_redisplay (FRAME_ROOT_WINDOW (f), | |
2152 0, top_window_y, ch_dim, 0, | |
2153 &window_change_flags); | |
2154 | |
2155 /* Size of frame matrices must equal size of frame. Note | |
2156 that we are called for X frames with window widths NOT equal | |
2157 to the frame width (from CHANGE_FRAME_SIZE_1). */ | |
2158 xassert (matrix_dim.width == FRAME_WIDTH (f) | |
2159 && matrix_dim.height == FRAME_HEIGHT (f)); | |
2160 | |
2161 /* Resize frame matrices. */ | |
2162 adjust_glyph_matrix (NULL, f->desired_matrix, 0, 0, matrix_dim); | |
34788
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2163 |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2164 /* Pointers to glyph memory in glyph rows are exchanged during |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2165 the update phase of redisplay, which means in general that a |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2166 frame's current matrix consists of pointers into both the |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2167 desired and current glyph pool of the frame. Adjusting a |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2168 matrix sets the frame matrix up so that pointers are all into |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2169 the same pool. If we want to preserve glyph contents of the |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2170 current matrix over a call to adjust_glyph_matrix, we must |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2171 make a copy of the current glyphs, and restore the current |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2172 matrix' contents from that copy. */ |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2173 if (display_completed |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2174 && !FRAME_GARBAGED_P (f) |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2175 && matrix_dim.width == f->current_matrix->matrix_w |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2176 && matrix_dim.height == f->current_matrix->matrix_h) |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2177 { |
34849
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2178 save_or_restore_current_matrix (f, 1); |
34788
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2179 adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim); |
34849
eac70be4cb58
(save_frame_matrix, restore_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34788
diff
changeset
|
2180 save_or_restore_current_matrix (f, 0); |
34788
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2181 fake_current_matrices (FRAME_ROOT_WINDOW (f)); |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2182 } |
34736
51a0fe34dfc6
(fake_current_matrices, ensure_frame_matrix): New
Gerd Moellmann <gerd@gnu.org>
parents:
34715
diff
changeset
|
2183 else |
34788
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2184 { |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2185 adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim); |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2186 SET_FRAME_GARBAGED (f); |
9512f05b60d1
(ensure_frame_matrix): Removed.
Gerd Moellmann <gerd@gnu.org>
parents:
34736
diff
changeset
|
2187 } |
25012 | 2188 } |
2189 } | |
2190 | |
2191 | |
2192 /* Allocate/reallocate glyph matrices of a single frame F for | |
2193 window-based redisplay. */ | |
2194 | |
2195 static void | |
2196 adjust_frame_glyphs_for_window_redisplay (f) | |
2197 struct frame *f; | |
2198 { | |
2199 struct dim ch_dim; | |
2200 struct window *w; | |
2201 | |
2202 xassert (FRAME_WINDOW_P (f) && FRAME_LIVE_P (f)); | |
2203 | |
2204 /* Get minimum sizes. */ | |
2205 #ifdef HAVE_WINDOW_SYSTEM | |
2206 ch_dim.width = FRAME_SMALLEST_CHAR_WIDTH (f); | |
2207 ch_dim.height = FRAME_SMALLEST_FONT_HEIGHT (f); | |
2208 #else | |
2209 ch_dim.width = ch_dim.height = 1; | |
2210 #endif | |
2211 | |
2212 /* Allocate/reallocate window matrices. */ | |
2213 allocate_matrices_for_window_redisplay (XWINDOW (FRAME_ROOT_WINDOW (f)), | |
2214 ch_dim); | |
2215 | |
2216 /* Allocate/ reallocate matrices of the dummy window used to display | |
2217 the menu bar under X when no X toolkit support is available. */ | |
2218 #ifndef USE_X_TOOLKIT | |
2219 { | |
2220 /* Allocate a dummy window if not already done. */ | |
2221 if (NILP (f->menu_bar_window)) | |
2222 { | |
2223 f->menu_bar_window = make_window (); | |
2224 w = XWINDOW (f->menu_bar_window); | |
2225 XSETFRAME (w->frame, f); | |
2226 w->pseudo_window_p = 1; | |
2227 } | |
2228 else | |
2229 w = XWINDOW (f->menu_bar_window); | |
2230 | |
2231 /* Set window dimensions to frame dimensions and allocate or | |
2232 adjust glyph matrices of W. */ | |
2233 XSETFASTINT (w->top, 0); | |
2234 XSETFASTINT (w->left, 0); | |
2235 XSETFASTINT (w->height, FRAME_MENU_BAR_LINES (f)); | |
2236 XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f)); | |
2237 allocate_matrices_for_window_redisplay (w, ch_dim); | |
2238 } | |
2239 #endif /* not USE_X_TOOLKIT */ | |
2240 | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2241 /* Allocate/ reallocate matrices of the tool bar window. If we |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2242 don't have a tool bar window yet, make one. */ |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2243 if (NILP (f->tool_bar_window)) |
25012 | 2244 { |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2245 f->tool_bar_window = make_window (); |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2246 w = XWINDOW (f->tool_bar_window); |
25012 | 2247 XSETFRAME (w->frame, f); |
2248 w->pseudo_window_p = 1; | |
2249 } | |
2250 else | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2251 w = XWINDOW (f->tool_bar_window); |
25012 | 2252 |
2253 XSETFASTINT (w->top, FRAME_MENU_BAR_LINES (f)); | |
2254 XSETFASTINT (w->left, 0); | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2255 XSETFASTINT (w->height, FRAME_TOOL_BAR_LINES (f)); |
25012 | 2256 XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f)); |
2257 allocate_matrices_for_window_redisplay (w, ch_dim); | |
2258 } | |
2259 | |
2260 | |
2261 /* Adjust/ allocate message buffer of frame F. | |
2262 | |
2263 Note that the message buffer is never freed. Since I could not | |
2264 find a free in 19.34, I assume that freeing it would be | |
2265 problematic in some way and don't do it either. | |
2266 | |
2267 (Implementation note: It should be checked if we can free it | |
2268 eventually without causing trouble). */ | |
2269 | |
2270 static void | |
2271 adjust_frame_message_buffer (f) | |
2272 struct frame *f; | |
2273 { | |
2274 int size = FRAME_MESSAGE_BUF_SIZE (f) + 1; | |
2275 | |
2276 if (FRAME_MESSAGE_BUF (f)) | |
2277 { | |
2278 char *buffer = FRAME_MESSAGE_BUF (f); | |
2279 char *new_buffer = (char *) xrealloc (buffer, size); | |
2280 FRAME_MESSAGE_BUF (f) = new_buffer; | |
2281 } | |
2282 else | |
2283 FRAME_MESSAGE_BUF (f) = (char *) xmalloc (size); | |
2284 } | |
2285 | |
2286 | |
2287 /* Re-allocate buffer for decode_mode_spec on frame F. */ | |
2288 | |
2289 static void | |
2290 adjust_decode_mode_spec_buffer (f) | |
2291 struct frame *f; | |
2292 { | |
2293 f->decode_mode_spec_buffer | |
2294 = (char *) xrealloc (f->decode_mode_spec_buffer, | |
2295 FRAME_MESSAGE_BUF_SIZE (f) + 1); | |
2296 } | |
2297 | |
2298 | |
2299 | |
2300 /********************************************************************** | |
2301 Freeing Glyph Matrices | |
2302 **********************************************************************/ | |
2303 | |
2304 /* Free glyph memory for a frame F. F may be null. This function can | |
2305 be called for the same frame more than once. The root window of | |
2306 F may be nil when this function is called. This is the case when | |
2307 the function is called when F is destroyed. */ | |
2308 | |
2309 void | |
2310 free_glyphs (f) | |
2311 struct frame *f; | |
2312 { | |
2313 if (f && f->glyphs_initialized_p) | |
2314 { | |
27968
7634011b93f3
(free_glyphs): Block input while freeing matrices.
Gerd Moellmann <gerd@gnu.org>
parents:
27855
diff
changeset
|
2315 /* Block interrupt input so that we don't get surprised by an X |
7634011b93f3
(free_glyphs): Block input while freeing matrices.
Gerd Moellmann <gerd@gnu.org>
parents:
27855
diff
changeset
|
2316 event while we're in an inconsistent state. */ |
7634011b93f3
(free_glyphs): Block input while freeing matrices.
Gerd Moellmann <gerd@gnu.org>
parents:
27855
diff
changeset
|
2317 BLOCK_INPUT; |
25012 | 2318 f->glyphs_initialized_p = 0; |
2319 | |
2320 /* Release window sub-matrices. */ | |
2321 if (!NILP (f->root_window)) | |
2322 free_window_matrices (XWINDOW (f->root_window)); | |
2323 | |
2324 /* Free the dummy window for menu bars without X toolkit and its | |
2325 glyph matrices. */ | |
2326 if (!NILP (f->menu_bar_window)) | |
2327 { | |
2328 struct window *w = XWINDOW (f->menu_bar_window); | |
2329 free_glyph_matrix (w->desired_matrix); | |
2330 free_glyph_matrix (w->current_matrix); | |
2331 w->desired_matrix = w->current_matrix = NULL; | |
2332 f->menu_bar_window = Qnil; | |
2333 } | |
2334 | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2335 /* Free the tool bar window and its glyph matrices. */ |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2336 if (!NILP (f->tool_bar_window)) |
25012 | 2337 { |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2338 struct window *w = XWINDOW (f->tool_bar_window); |
25012 | 2339 free_glyph_matrix (w->desired_matrix); |
2340 free_glyph_matrix (w->current_matrix); | |
2341 w->desired_matrix = w->current_matrix = NULL; | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
2342 f->tool_bar_window = Qnil; |
25012 | 2343 } |
2344 | |
2345 /* Release frame glyph matrices. Reset fields to zero in | |
2346 case we are called a second time. */ | |
2347 if (f->desired_matrix) | |
2348 { | |
2349 free_glyph_matrix (f->desired_matrix); | |
2350 free_glyph_matrix (f->current_matrix); | |
2351 f->desired_matrix = f->current_matrix = NULL; | |
2352 } | |
2353 | |
2354 /* Release glyph pools. */ | |
2355 if (f->desired_pool) | |
2356 { | |
2357 free_glyph_pool (f->desired_pool); | |
2358 free_glyph_pool (f->current_pool); | |
2359 f->desired_pool = f->current_pool = NULL; | |
314 | 2360 } |
27968
7634011b93f3
(free_glyphs): Block input while freeing matrices.
Gerd Moellmann <gerd@gnu.org>
parents:
27855
diff
changeset
|
2361 |
7634011b93f3
(free_glyphs): Block input while freeing matrices.
Gerd Moellmann <gerd@gnu.org>
parents:
27855
diff
changeset
|
2362 UNBLOCK_INPUT; |
314 | 2363 } |
2364 } | |
2365 | |
25012 | 2366 |
2367 /* Free glyph sub-matrices in the window tree rooted at W. This | |
2368 function may be called with a null pointer, and it may be called on | |
2369 the same tree more than once. */ | |
2370 | |
2371 void | |
2372 free_window_matrices (w) | |
2373 struct window *w; | |
2374 { | |
2375 while (w) | |
2376 { | |
2377 if (!NILP (w->hchild)) | |
2378 free_window_matrices (XWINDOW (w->hchild)); | |
2379 else if (!NILP (w->vchild)) | |
2380 free_window_matrices (XWINDOW (w->vchild)); | |
2381 else | |
2382 { | |
2383 /* This is a leaf window. Free its memory and reset fields | |
2384 to zero in case this function is called a second time for | |
2385 W. */ | |
2386 free_glyph_matrix (w->current_matrix); | |
2387 free_glyph_matrix (w->desired_matrix); | |
2388 w->current_matrix = w->desired_matrix = NULL; | |
2389 } | |
2390 | |
2391 /* Next window on same level. */ | |
2392 w = NILP (w->next) ? 0 : XWINDOW (w->next); | |
2393 } | |
2394 } | |
2395 | |
2396 | |
2397 /* Check glyph memory leaks. This function is called from | |
2398 shut_down_emacs. Note that frames are not destroyed when Emacs | |
2399 exits. We therefore free all glyph memory for all active frames | |
2400 explicitly and check that nothing is left allocated. */ | |
6620
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2401 |
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2402 void |
25012 | 2403 check_glyph_memory () |
6620
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2404 { |
25012 | 2405 Lisp_Object tail, frame; |
2406 | |
2407 /* Free glyph memory for all frames. */ | |
2408 FOR_EACH_FRAME (tail, frame) | |
2409 free_glyphs (XFRAME (frame)); | |
2410 | |
2411 /* Check that nothing is left allocated. */ | |
2412 if (glyph_matrix_count) | |
2413 abort (); | |
2414 if (glyph_pool_count) | |
2415 abort (); | |
2416 } | |
2417 | |
2418 | |
2419 | |
2420 /********************************************************************** | |
2421 Building a Frame Matrix | |
2422 **********************************************************************/ | |
2423 | |
2424 /* Most of the redisplay code works on glyph matrices attached to | |
2425 windows. This is a good solution most of the time, but it is not | |
2426 suitable for terminal code. Terminal output functions cannot rely | |
2427 on being able to set an arbitrary terminal window. Instead they | |
2428 must be provided with a view of the whole frame, i.e. the whole | |
2429 screen. We build such a view by constructing a frame matrix from | |
2430 window matrices in this section. | |
2431 | |
2432 Windows that must be updated have their must_be_update_p flag set. | |
2433 For all such windows, their desired matrix is made part of the | |
2434 desired frame matrix. For other windows, their current matrix is | |
2435 made part of the desired frame matrix. | |
2436 | |
2437 +-----------------+----------------+ | |
2438 | desired | desired | | |
2439 | | | | |
2440 +-----------------+----------------+ | |
2441 | current | | |
2442 | | | |
2443 +----------------------------------+ | |
2444 | |
2445 Desired window matrices can be made part of the frame matrix in a | |
2446 cheap way: We exploit the fact that the desired frame matrix and | |
2447 desired window matrices share their glyph memory. This is not | |
2448 possible for current window matrices. Their glyphs are copied to | |
2449 the desired frame matrix. The latter is equivalent to | |
2450 preserve_other_columns in the old redisplay. | |
2451 | |
2452 Used glyphs counters for frame matrix rows are the result of adding | |
2453 up glyph lengths of the window matrices. A line in the frame | |
2454 matrix is enabled, if a corresponding line in a window matrix is | |
2455 enabled. | |
2456 | |
2457 After building the desired frame matrix, it will be passed to | |
2458 terminal code, which will manipulate both the desired and current | |
2459 frame matrix. Changes applied to the frame's current matrix have | |
2460 to be visible in current window matrices afterwards, of course. | |
2461 | |
2462 This problem is solved like this: | |
2463 | |
2464 1. Window and frame matrices share glyphs. Window matrices are | |
2465 constructed in a way that their glyph contents ARE the glyph | |
2466 contents needed in a frame matrix. Thus, any modification of | |
2467 glyphs done in terminal code will be reflected in window matrices | |
2468 automatically. | |
2469 | |
2470 2. Exchanges of rows in a frame matrix done by terminal code are | |
2471 intercepted by hook functions so that corresponding row operations | |
2472 on window matrices can be performed. This is necessary because we | |
2473 use pointers to glyphs in glyph row structures. To satisfy the | |
2474 assumption of point 1 above that glyphs are updated implicitly in | |
2475 window matrices when they are manipulated via the frame matrix, | |
2476 window and frame matrix must of course agree where to find the | |
2477 glyphs for their rows. Possible manipulations that must be | |
2478 mirrored are assignments of rows of the desired frame matrix to the | |
2479 current frame matrix and scrolling the current frame matrix. */ | |
2480 | |
2481 /* Build frame F's desired matrix from window matrices. Only windows | |
2482 which have the flag must_be_updated_p set have to be updated. Menu | |
2483 bar lines of a frame are not covered by window matrices, so make | |
2484 sure not to touch them in this function. */ | |
2485 | |
2486 static void | |
2487 build_frame_matrix (f) | |
2488 struct frame *f; | |
2489 { | |
6620
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2490 int i; |
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2491 |
25012 | 2492 /* F must have a frame matrix when this function is called. */ |
2493 xassert (!FRAME_WINDOW_P (f)); | |
2494 | |
2495 /* Clear all rows in the frame matrix covered by window matrices. | |
2496 Menu bar lines are not covered by windows. */ | |
2497 for (i = FRAME_TOP_MARGIN (f); i < f->desired_matrix->nrows; ++i) | |
2498 clear_glyph_row (MATRIX_ROW (f->desired_matrix, i)); | |
2499 | |
2500 /* Build the matrix by walking the window tree. */ | |
2501 build_frame_matrix_from_window_tree (f->desired_matrix, | |
2502 XWINDOW (FRAME_ROOT_WINDOW (f))); | |
2503 } | |
2504 | |
2505 | |
2506 /* Walk a window tree, building a frame matrix MATRIX from window | |
2507 matrices. W is the root of a window tree. */ | |
2508 | |
2509 static void | |
2510 build_frame_matrix_from_window_tree (matrix, w) | |
2511 struct glyph_matrix *matrix; | |
2512 struct window *w; | |
2513 { | |
2514 while (w) | |
6620
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2515 { |
25012 | 2516 if (!NILP (w->hchild)) |
2517 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->hchild)); | |
2518 else if (!NILP (w->vchild)) | |
2519 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->vchild)); | |
2520 else | |
2521 build_frame_matrix_from_leaf_window (matrix, w); | |
2522 | |
2523 w = NILP (w->next) ? 0 : XWINDOW (w->next); | |
6620
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2524 } |
990d7d5095dc
(adjust_window_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6617
diff
changeset
|
2525 } |
6642
2fda5dd17356
(verify_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6627
diff
changeset
|
2526 |
25012 | 2527 |
2528 /* Add a window's matrix to a frame matrix. FRAME_MATRIX is the | |
2529 desired frame matrix built. W is a leaf window whose desired or | |
2530 current matrix is to be added to FRAME_MATRIX. W's flag | |
2531 must_be_updated_p determines which matrix it contributes to | |
2532 FRAME_MATRIX. If must_be_updated_p is non-zero, W's desired matrix | |
2533 is added to FRAME_MATRIX, otherwise W's current matrix is added. | |
2534 Adding a desired matrix means setting up used counters and such in | |
2535 frame rows, while adding a current window matrix to FRAME_MATRIX | |
2536 means copying glyphs. The latter case corresponds to | |
2537 preserve_other_columns in the old redisplay. */ | |
2538 | |
2539 static void | |
2540 build_frame_matrix_from_leaf_window (frame_matrix, w) | |
2541 struct glyph_matrix *frame_matrix; | |
6642
2fda5dd17356
(verify_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6627
diff
changeset
|
2542 struct window *w; |
2fda5dd17356
(verify_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6627
diff
changeset
|
2543 { |
25012 | 2544 struct glyph_matrix *window_matrix; |
2545 int window_y, frame_y; | |
2546 /* If non-zero, a glyph to insert at the right border of W. */ | |
2547 GLYPH right_border_glyph = 0; | |
2548 | |
2549 /* Set window_matrix to the matrix we have to add to FRAME_MATRIX. */ | |
2550 if (w->must_be_updated_p) | |
2551 { | |
2552 window_matrix = w->desired_matrix; | |
2553 | |
2554 /* Decide whether we want to add a vertical border glyph. */ | |
2555 if (!WINDOW_RIGHTMOST_P (w)) | |
2556 { | |
2557 struct Lisp_Char_Table *dp = window_display_table (w); | |
2558 right_border_glyph = (dp && INTEGERP (DISP_BORDER_GLYPH (dp)) | |
2559 ? XINT (DISP_BORDER_GLYPH (dp)) | |
2560 : '|'); | |
2561 } | |
2562 } | |
2563 else | |
2564 window_matrix = w->current_matrix; | |
2565 | |
2566 /* For all rows in the window matrix and corresponding rows in the | |
2567 frame matrix. */ | |
2568 window_y = 0; | |
2569 frame_y = window_matrix->matrix_y; | |
2570 while (window_y < window_matrix->nrows) | |
6642
2fda5dd17356
(verify_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6627
diff
changeset
|
2571 { |
25012 | 2572 struct glyph_row *frame_row = frame_matrix->rows + frame_y; |
2573 struct glyph_row *window_row = window_matrix->rows + window_y; | |
31271
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2574 int current_row_p = window_matrix == w->current_matrix; |
25012 | 2575 |
2576 /* Fill up the frame row with spaces up to the left margin of the | |
2577 window row. */ | |
2578 fill_up_frame_row_with_spaces (frame_row, window_matrix->matrix_x); | |
2579 | |
2580 /* Fill up areas in the window matrix row with spaces. */ | |
2581 fill_up_glyph_row_with_spaces (window_row); | |
31271
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2582 |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2583 /* If only part of W's desired matrix has been built, and |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2584 window_row wasn't displayed, use the corresponding current |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2585 row instead. */ |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2586 if (window_matrix == w->desired_matrix |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2587 && !window_row->enabled_p) |
6682
16ab14205588
(verify_charstarts): Handle truncation of lines.
Richard M. Stallman <rms@gnu.org>
parents:
6648
diff
changeset
|
2588 { |
31271
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2589 window_row = w->current_matrix->rows + window_y; |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2590 current_row_p = 1; |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2591 } |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2592 |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2593 if (current_row_p) |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2594 { |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2595 /* Copy window row to frame row. */ |
25012 | 2596 bcopy (window_row->glyphs[0], |
2597 frame_row->glyphs[TEXT_AREA] + window_matrix->matrix_x, | |
2598 window_matrix->matrix_w * sizeof (struct glyph)); | |
2599 } | |
2600 else | |
2601 { | |
31271
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2602 xassert (window_row->enabled_p); |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2603 |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2604 /* Only when a desired row has been displayed, we want |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2605 the corresponding frame row to be updated. */ |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2606 frame_row->enabled_p = 1; |
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2607 |
25012 | 2608 /* Maybe insert a vertical border between horizontally adjacent |
2609 windows. */ | |
2610 if (right_border_glyph) | |
2611 { | |
2612 struct glyph *border = window_row->glyphs[LAST_AREA] - 1; | |
2613 SET_CHAR_GLYPH_FROM_GLYPH (*border, right_border_glyph); | |
2614 } | |
2615 | |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2616 #if 0 /* This shouldn't be necessary. Let's check it. */ |
25012 | 2617 /* Due to hooks installed, it normally doesn't happen that |
2618 window rows and frame rows of the same matrix are out of | |
2619 sync, i.e. have a different understanding of where to | |
2620 find glyphs for the row. The following is a safety-belt | |
2621 that doesn't cost much and makes absolutely sure that | |
2622 window and frame matrices are in sync. */ | |
2623 if (!glyph_row_slice_p (window_row, frame_row)) | |
6682
16ab14205588
(verify_charstarts): Handle truncation of lines.
Richard M. Stallman <rms@gnu.org>
parents:
6648
diff
changeset
|
2624 { |
25012 | 2625 /* Find the row in the window being a slice. There |
2626 should exist one from program logic. */ | |
2627 struct glyph_row *slice_row | |
2628 = find_glyph_row_slice (window_matrix, frame_matrix, frame_y); | |
2629 xassert (slice_row != 0); | |
2630 | |
2631 /* Exchange glyphs between both window rows. */ | |
2632 swap_glyphs_in_rows (window_row, slice_row); | |
2633 | |
2634 /* Exchange pointers between both rows. */ | |
2635 swap_glyph_pointers (window_row, slice_row); | |
6682
16ab14205588
(verify_charstarts): Handle truncation of lines.
Richard M. Stallman <rms@gnu.org>
parents:
6648
diff
changeset
|
2636 } |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2637 #endif |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2638 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2639 /* Window row window_y must be a slice of frame row |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2640 frame_y. */ |
25012 | 2641 xassert (glyph_row_slice_p (window_row, frame_row)); |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2642 |
25012 | 2643 /* If rows are in sync, we don't have to copy glyphs because |
2644 frame and window share glyphs. */ | |
25241
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2645 |
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2646 #if GLYPH_DEBUG |
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2647 strcpy (w->current_matrix->method, w->desired_matrix->method); |
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2648 #endif |
25012 | 2649 } |
2650 | |
2651 /* Set number of used glyphs in the frame matrix. Since we fill | |
2652 up with spaces, and visit leaf windows from left to right it | |
2653 can be done simply. */ | |
2654 frame_row->used[TEXT_AREA] | |
2655 = window_matrix->matrix_x + window_matrix->matrix_w; | |
2656 | |
31271
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
2657 /* Or in other flags. */ |
25012 | 2658 frame_row->inverse_p |= window_row->inverse_p; |
2659 | |
2660 /* Next row. */ | |
2661 ++window_y; | |
2662 ++frame_y; | |
2663 } | |
2664 } | |
2665 | |
2666 | |
2667 /* Add spaces to a glyph row ROW in a window matrix. | |
2668 | |
2669 Each row has the form: | |
2670 | |
2671 +---------+-----------------------------+------------+ | |
2672 | left | text | right | | |
2673 +---------+-----------------------------+------------+ | |
2674 | |
2675 Left and right marginal areas are optional. This function adds | |
2676 spaces to areas so that there are no empty holes between areas. | |
2677 In other words: If the right area is not empty, the text area | |
2678 is filled up with spaces up to the right area. If the text area | |
2679 is not empty, the left area is filled up. | |
2680 | |
2681 To be called for frame-based redisplay, only. */ | |
2682 | |
2683 static void | |
2684 fill_up_glyph_row_with_spaces (row) | |
2685 struct glyph_row *row; | |
2686 { | |
2687 fill_up_glyph_row_area_with_spaces (row, LEFT_MARGIN_AREA); | |
2688 fill_up_glyph_row_area_with_spaces (row, TEXT_AREA); | |
2689 fill_up_glyph_row_area_with_spaces (row, RIGHT_MARGIN_AREA); | |
2690 } | |
2691 | |
2692 | |
2693 /* Fill area AREA of glyph row ROW with spaces. To be called for | |
2694 frame-based redisplay only. */ | |
2695 | |
2696 static void | |
2697 fill_up_glyph_row_area_with_spaces (row, area) | |
2698 struct glyph_row *row; | |
2699 int area; | |
2700 { | |
2701 if (row->glyphs[area] < row->glyphs[area + 1]) | |
2702 { | |
2703 struct glyph *end = row->glyphs[area + 1]; | |
2704 struct glyph *text = row->glyphs[area] + row->used[area]; | |
2705 | |
2706 while (text < end) | |
2707 *text++ = space_glyph; | |
2708 row->used[area] = text - row->glyphs[area]; | |
2709 } | |
2710 } | |
2711 | |
2712 | |
2713 /* Add spaces to the end of ROW in a frame matrix until index UPTO is | |
2714 reached. In frame matrices only one area, TEXT_AREA, is used. */ | |
2715 | |
2716 static void | |
2717 fill_up_frame_row_with_spaces (row, upto) | |
2718 struct glyph_row *row; | |
2719 int upto; | |
2720 { | |
2721 int i = row->used[TEXT_AREA]; | |
2722 struct glyph *glyph = row->glyphs[TEXT_AREA]; | |
2723 | |
2724 while (i < upto) | |
2725 glyph[i++] = space_glyph; | |
2726 | |
2727 row->used[TEXT_AREA] = i; | |
2728 } | |
2729 | |
2730 | |
2731 | |
2732 /********************************************************************** | |
2733 Mirroring operations on frame matrices in window matrices | |
2734 **********************************************************************/ | |
2735 | |
2736 /* Set frame being updated via frame-based redisplay to F. This | |
2737 function must be called before updates to make explicit that we are | |
2738 working on frame matrices or not. */ | |
2739 | |
2740 static INLINE void | |
2741 set_frame_matrix_frame (f) | |
2742 struct frame *f; | |
2743 { | |
2744 frame_matrix_frame = f; | |
2745 } | |
2746 | |
2747 | |
2748 /* Make sure glyph row ROW in CURRENT_MATRIX is up to date. | |
2749 DESIRED_MATRIX is the desired matrix corresponding to | |
2750 CURRENT_MATRIX. The update is done by exchanging glyph pointers | |
2751 between rows in CURRENT_MATRIX and DESIRED_MATRIX. If | |
2752 frame_matrix_frame is non-null, this indicates that the exchange is | |
2753 done in frame matrices, and that we have to perform analogous | |
2754 operations in window matrices of frame_matrix_frame. */ | |
2755 | |
2756 static INLINE void | |
2757 make_current (desired_matrix, current_matrix, row) | |
2758 struct glyph_matrix *desired_matrix, *current_matrix; | |
2759 int row; | |
2760 { | |
2761 struct glyph_row *current_row = MATRIX_ROW (current_matrix, row); | |
2762 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row); | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
2763 int mouse_face_p = current_row->mouse_face_p; |
25012 | 2764 |
2765 /* Do current_row = desired_row. This exchanges glyph pointers | |
2766 between both rows, and does a structure assignment otherwise. */ | |
2767 assign_row (current_row, desired_row); | |
2768 | |
2769 /* Enable current_row to mark it as valid. */ | |
2770 current_row->enabled_p = 1; | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
2771 current_row->mouse_face_p = mouse_face_p; |
25012 | 2772 |
2773 /* If we are called on frame matrices, perform analogous operations | |
2774 for window matrices. */ | |
2775 if (frame_matrix_frame) | |
2776 mirror_make_current (XWINDOW (frame_matrix_frame->root_window), row); | |
2777 } | |
2778 | |
2779 | |
2780 /* W is the root of a window tree. FRAME_ROW is the index of a row in | |
2781 W's frame which has been made current (by swapping pointers between | |
2782 current and desired matrix). Perform analogous operations in the | |
2783 matrices of leaf windows in the window tree rooted at W. */ | |
2784 | |
2785 static void | |
2786 mirror_make_current (w, frame_row) | |
2787 struct window *w; | |
2788 int frame_row; | |
2789 { | |
2790 while (w) | |
2791 { | |
2792 if (!NILP (w->hchild)) | |
2793 mirror_make_current (XWINDOW (w->hchild), frame_row); | |
2794 else if (!NILP (w->vchild)) | |
2795 mirror_make_current (XWINDOW (w->vchild), frame_row); | |
2796 else | |
2797 { | |
2798 /* Row relative to window W. Don't use FRAME_TO_WINDOW_VPOS | |
2799 here because the checks performed in debug mode there | |
2800 will not allow the conversion. */ | |
2801 int row = frame_row - w->desired_matrix->matrix_y; | |
2802 | |
2803 /* If FRAME_ROW is within W, assign the desired row to the | |
2804 current row (exchanging glyph pointers). */ | |
2805 if (row >= 0 && row < w->desired_matrix->matrix_h) | |
6682
16ab14205588
(verify_charstarts): Handle truncation of lines.
Richard M. Stallman <rms@gnu.org>
parents:
6648
diff
changeset
|
2806 { |
25012 | 2807 struct glyph_row *current_row |
2808 = MATRIX_ROW (w->current_matrix, row); | |
2809 struct glyph_row *desired_row | |
2810 = MATRIX_ROW (w->desired_matrix, row); | |
25241
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2811 |
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2812 if (desired_row->enabled_p) |
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2813 assign_row (current_row, desired_row); |
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2814 else |
35674d7c4136
(mirror_make_current): If desired row isn't enabled,
Gerd Moellmann <gerd@gnu.org>
parents:
25190
diff
changeset
|
2815 swap_glyph_pointers (desired_row, current_row); |
25012 | 2816 current_row->enabled_p = 1; |
6682
16ab14205588
(verify_charstarts): Handle truncation of lines.
Richard M. Stallman <rms@gnu.org>
parents:
6648
diff
changeset
|
2817 } |
16ab14205588
(verify_charstarts): Handle truncation of lines.
Richard M. Stallman <rms@gnu.org>
parents:
6648
diff
changeset
|
2818 } |
25012 | 2819 |
2820 w = NILP (w->next) ? 0 : XWINDOW (w->next); | |
6642
2fda5dd17356
(verify_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6627
diff
changeset
|
2821 } |
2fda5dd17356
(verify_charstarts): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6627
diff
changeset
|
2822 } |
25012 | 2823 |
2824 | |
2825 /* Perform row dance after scrolling. We are working on the range of | |
2826 lines UNCHANGED_AT_TOP + 1 to UNCHANGED_AT_TOP + NLINES (not | |
2827 including) in MATRIX. COPY_FROM is a vector containing, for each | |
2828 row I in the range 0 <= I < NLINES, the index of the original line | |
2829 to move to I. This index is relative to the row range, i.e. 0 <= | |
2830 index < NLINES. RETAINED_P is a vector containing zero for each | |
2831 row 0 <= I < NLINES which is empty. | |
2832 | |
2833 This function is called from do_scrolling and do_direct_scrolling. */ | |
2834 | |
2835 void | |
2836 mirrored_line_dance (matrix, unchanged_at_top, nlines, copy_from, | |
2837 retained_p) | |
2838 struct glyph_matrix *matrix; | |
2839 int unchanged_at_top, nlines; | |
2840 int *copy_from; | |
2841 char *retained_p; | |
2842 { | |
2843 /* A copy of original rows. */ | |
2844 struct glyph_row *old_rows; | |
2845 | |
2846 /* Rows to assign to. */ | |
2847 struct glyph_row *new_rows = MATRIX_ROW (matrix, unchanged_at_top); | |
2848 | |
2849 int i; | |
2850 | |
2851 /* Make a copy of the original rows. */ | |
2852 old_rows = (struct glyph_row *) alloca (nlines * sizeof *old_rows); | |
2853 bcopy (new_rows, old_rows, nlines * sizeof *old_rows); | |
2854 | |
2855 /* Assign new rows, maybe clear lines. */ | |
2856 for (i = 0; i < nlines; ++i) | |
2857 { | |
2858 int enabled_before_p = new_rows[i].enabled_p; | |
2859 | |
2860 xassert (i + unchanged_at_top < matrix->nrows); | |
2861 xassert (unchanged_at_top + copy_from[i] < matrix->nrows); | |
2862 new_rows[i] = old_rows[copy_from[i]]; | |
2863 new_rows[i].enabled_p = enabled_before_p; | |
2864 | |
2865 /* RETAINED_P is zero for empty lines. */ | |
2866 if (!retained_p[copy_from[i]]) | |
2867 new_rows[i].enabled_p = 0; | |
2868 } | |
2869 | |
2870 /* Do the same for window matrices, if MATRIX Is a frame matrix. */ | |
2871 if (frame_matrix_frame) | |
2872 mirror_line_dance (XWINDOW (frame_matrix_frame->root_window), | |
2873 unchanged_at_top, nlines, copy_from, retained_p); | |
2874 } | |
2875 | |
2876 | |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2877 /* Synchronize glyph pointers in the current matrix of window W with |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2878 the current frame matrix. W must be full-width, and be on a tty |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2879 frame. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2880 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2881 static void |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2882 sync_window_with_frame_matrix_rows (w) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2883 struct window *w; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2884 { |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2885 struct frame *f = XFRAME (w->frame); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2886 struct glyph_row *window_row, *window_row_end, *frame_row; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2887 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2888 /* Preconditions: W must be a leaf window and full-width. Its frame |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2889 must have a frame matrix. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2890 xassert (NILP (w->hchild) && NILP (w->vchild)); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2891 xassert (WINDOW_FULL_WIDTH_P (w)); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2892 xassert (!FRAME_WINDOW_P (f)); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2893 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2894 /* If W is a full-width window, glyph pointers in W's current matrix |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2895 have, by definition, to be the same as glyph pointers in the |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2896 corresponding frame matrix. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2897 window_row = w->current_matrix->rows; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2898 window_row_end = window_row + w->current_matrix->nrows; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2899 frame_row = f->current_matrix->rows + XFASTINT (w->top); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2900 while (window_row < window_row_end) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2901 { |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2902 int area; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2903 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2904 for (area = LEFT_MARGIN_AREA; area <= LAST_AREA; ++area) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2905 window_row->glyphs[area] = frame_row->glyphs[area]; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2906 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2907 ++window_row, ++frame_row; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2908 } |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2909 } |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2910 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2911 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2912 /* Return the window in the window tree rooted in W containing frame |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2913 row ROW. Value is null if none is found. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2914 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2915 struct window * |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2916 frame_row_to_window (w, row) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2917 struct window *w; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2918 int row; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2919 { |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2920 struct window *found = NULL; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2921 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2922 while (w && !found) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2923 { |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2924 if (!NILP (w->hchild)) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2925 found = frame_row_to_window (XWINDOW (w->hchild), row); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2926 else if (!NILP (w->vchild)) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2927 found = frame_row_to_window (XWINDOW (w->vchild), row); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2928 else if (row >= XFASTINT (w->top) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2929 && row < XFASTINT (w->top) + XFASTINT (w->height)) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2930 found = w; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2931 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2932 w = NILP (w->next) ? 0 : XWINDOW (w->next); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2933 } |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2934 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2935 return found; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2936 } |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2937 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2938 |
25012 | 2939 /* Perform a line dance in the window tree rooted at W, after |
2940 scrolling a frame matrix in mirrored_line_dance. | |
2941 | |
2942 We are working on the range of lines UNCHANGED_AT_TOP + 1 to | |
2943 UNCHANGED_AT_TOP + NLINES (not including) in W's frame matrix. | |
2944 COPY_FROM is a vector containing, for each row I in the range 0 <= | |
2945 I < NLINES, the index of the original line to move to I. This | |
2946 index is relative to the row range, i.e. 0 <= index < NLINES. | |
2947 RETAINED_P is a vector containing zero for each row 0 <= I < NLINES | |
2948 which is empty. */ | |
2949 | |
2950 static void | |
2951 mirror_line_dance (w, unchanged_at_top, nlines, copy_from, retained_p) | |
2952 struct window *w; | |
2953 int unchanged_at_top, nlines; | |
2954 int *copy_from; | |
2955 char *retained_p; | |
2956 { | |
2957 while (w) | |
2958 { | |
2959 if (!NILP (w->hchild)) | |
2960 mirror_line_dance (XWINDOW (w->hchild), unchanged_at_top, | |
2961 nlines, copy_from, retained_p); | |
2962 else if (!NILP (w->vchild)) | |
2963 mirror_line_dance (XWINDOW (w->vchild), unchanged_at_top, | |
2964 nlines, copy_from, retained_p); | |
2965 else | |
2966 { | |
2967 /* W is a leaf window, and we are working on its current | |
2968 matrix m. */ | |
2969 struct glyph_matrix *m = w->current_matrix; | |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2970 int i, sync_p = 0; |
25012 | 2971 struct glyph_row *old_rows; |
2972 | |
2973 /* Make a copy of the original rows of matrix m. */ | |
2974 old_rows = (struct glyph_row *) alloca (m->nrows * sizeof *old_rows); | |
2975 bcopy (m->rows, old_rows, m->nrows * sizeof *old_rows); | |
2976 | |
2977 for (i = 0; i < nlines; ++i) | |
2978 { | |
2979 /* Frame relative line assigned to. */ | |
2980 int frame_to = i + unchanged_at_top; | |
2981 | |
2982 /* Frame relative line assigned. */ | |
2983 int frame_from = copy_from[i] + unchanged_at_top; | |
2984 | |
2985 /* Window relative line assigned to. */ | |
2986 int window_to = frame_to - m->matrix_y; | |
2987 | |
2988 /* Window relative line assigned. */ | |
2989 int window_from = frame_from - m->matrix_y; | |
2990 | |
2991 /* Is assigned line inside window? */ | |
2992 int from_inside_window_p | |
2993 = window_from >= 0 && window_from < m->matrix_h; | |
2994 | |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2995 /* Is assigned to line inside window? */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2996 int to_inside_window_p |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2997 = window_to >= 0 && window_to < m->matrix_h; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2998 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2999 if (from_inside_window_p && to_inside_window_p) |
25012 | 3000 { |
3001 /* Enabled setting before assignment. */ | |
3002 int enabled_before_p; | |
3003 | |
3004 /* Do the assignment. The enabled_p flag is saved | |
3005 over the assignment because the old redisplay did | |
3006 that. */ | |
3007 enabled_before_p = m->rows[window_to].enabled_p; | |
3008 m->rows[window_to] = old_rows[window_from]; | |
3009 m->rows[window_to].enabled_p = enabled_before_p; | |
3010 | |
3011 /* If frame line is empty, window line is empty, too. */ | |
3012 if (!retained_p[copy_from[i]]) | |
3013 m->rows[window_to].enabled_p = 0; | |
3014 } | |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3015 else if (to_inside_window_p) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3016 { |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3017 /* A copy between windows. This is an infrequent |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3018 case not worth optimizing. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3019 struct frame *f = XFRAME (w->frame); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3020 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f)); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3021 struct window *w2; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3022 struct glyph_matrix *m2; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3023 int m2_from; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3024 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3025 w2 = frame_row_to_window (root, frame_to); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3026 m2 = w2->current_matrix; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3027 m2_from = frame_from - m2->matrix_y; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3028 copy_row_except_pointers (m->rows + window_to, |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3029 m2->rows + m2_from); |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3030 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3031 /* If frame line is empty, window line is empty, too. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3032 if (!retained_p[copy_from[i]]) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3033 m->rows[window_to].enabled_p = 0; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3034 sync_p = 1; |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3035 } |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3036 else if (from_inside_window_p) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3037 sync_p = 1; |
25012 | 3038 } |
27855
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3039 |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3040 /* If there was a copy between windows, make sure glyph |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3041 pointers are in sync with the frame matrix. */ |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3042 if (sync_p) |
ecfe912fd73c
(flush_stdout) [GLYPH_DEBUG]: New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3043 sync_window_with_frame_matrix_rows (w); |
25012 | 3044 |
3045 /* Check that no pointers are lost. */ | |
3046 CHECK_MATRIX (m); | |
3047 } | |
3048 | |
3049 /* Next window on same level. */ | |
3050 w = NILP (w->next) ? 0 : XWINDOW (w->next); | |
3051 } | |
3052 } | |
3053 | |
3054 | |
3055 #if GLYPH_DEBUG | |
3056 | |
3057 /* Check that window and frame matrices agree about their | |
3058 understanding where glyphs of the rows are to find. For each | |
3059 window in the window tree rooted at W, check that rows in the | |
3060 matrices of leaf window agree with their frame matrices about | |
3061 glyph pointers. */ | |
314 | 3062 |
21514 | 3063 void |
25012 | 3064 check_window_matrix_pointers (w) |
314 | 3065 struct window *w; |
3066 { | |
25012 | 3067 while (w) |
3068 { | |
3069 if (!NILP (w->hchild)) | |
3070 check_window_matrix_pointers (XWINDOW (w->hchild)); | |
3071 else if (!NILP (w->vchild)) | |
3072 check_window_matrix_pointers (XWINDOW (w->vchild)); | |
3073 else | |
3074 { | |
3075 struct frame *f = XFRAME (w->frame); | |
3076 check_matrix_pointers (w->desired_matrix, f->desired_matrix); | |
3077 check_matrix_pointers (w->current_matrix, f->current_matrix); | |
3078 } | |
3079 | |
3080 w = NILP (w->next) ? 0 : XWINDOW (w->next); | |
3081 } | |
3082 } | |
3083 | |
3084 | |
3085 /* Check that window rows are slices of frame rows. WINDOW_MATRIX is | |
3086 a window and FRAME_MATRIX is the corresponding frame matrix. For | |
3087 each row in WINDOW_MATRIX check that it's a slice of the | |
3088 corresponding frame row. If it isn't, abort. */ | |
3089 | |
3090 static void | |
3091 check_matrix_pointers (window_matrix, frame_matrix) | |
3092 struct glyph_matrix *window_matrix, *frame_matrix; | |
3093 { | |
3094 /* Row number in WINDOW_MATRIX. */ | |
3095 int i = 0; | |
3096 | |
3097 /* Row number corresponding to I in FRAME_MATRIX. */ | |
3098 int j = window_matrix->matrix_y; | |
3099 | |
3100 /* For all rows check that the row in the window matrix is a | |
3101 slice of the row in the frame matrix. If it isn't we didn't | |
3102 mirror an operation on the frame matrix correctly. */ | |
3103 while (i < window_matrix->nrows) | |
3104 { | |
3105 if (!glyph_row_slice_p (window_matrix->rows + i, | |
3106 frame_matrix->rows + j)) | |
3107 abort (); | |
3108 ++i, ++j; | |
3109 } | |
3110 } | |
3111 | |
3112 #endif /* GLYPH_DEBUG != 0 */ | |
3113 | |
3114 | |
3115 | |
3116 /********************************************************************** | |
3117 VPOS and HPOS translations | |
3118 **********************************************************************/ | |
3119 | |
3120 #if GLYPH_DEBUG | |
3121 | |
3122 /* Translate vertical position VPOS which is relative to window W to a | |
3123 vertical position relative to W's frame. */ | |
3124 | |
3125 static int | |
3126 window_to_frame_vpos (w, vpos) | |
3127 struct window *w; | |
3128 int vpos; | |
3129 { | |
3130 struct frame *f = XFRAME (w->frame); | |
3131 | |
3132 xassert (!FRAME_WINDOW_P (f)); | |
3133 xassert (vpos >= 0 && vpos <= w->desired_matrix->nrows); | |
3134 vpos += XFASTINT (w->top); | |
3135 xassert (vpos >= 0 && vpos <= FRAME_HEIGHT (f)); | |
3136 return vpos; | |
3137 } | |
3138 | |
3139 | |
3140 /* Translate horizontal position HPOS which is relative to window W to | |
3141 a vertical position relative to W's frame. */ | |
3142 | |
3143 static int | |
3144 window_to_frame_hpos (w, hpos) | |
3145 struct window *w; | |
3146 int hpos; | |
3147 { | |
3148 struct frame *f = XFRAME (w->frame); | |
3149 | |
3150 xassert (!FRAME_WINDOW_P (f)); | |
3151 hpos += XFASTINT (w->left); | |
3152 return hpos; | |
314 | 3153 } |
25012 | 3154 |
3155 #endif /* GLYPH_DEBUG */ | |
3156 | |
3157 | |
314 | 3158 |
25012 | 3159 /********************************************************************** |
3160 Redrawing Frames | |
3161 **********************************************************************/ | |
3162 | |
3163 DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, | |
3164 "Clear frame FRAME and output again what is supposed to appear on it.") | |
3165 (frame) | |
3166 Lisp_Object frame; | |
3167 { | |
3168 struct frame *f; | |
3169 | |
3170 CHECK_LIVE_FRAME (frame, 0); | |
3171 f = XFRAME (frame); | |
3172 | |
3173 /* Ignore redraw requests, if frame has no glyphs yet. | |
3174 (Implementation note: It still has to be checked why we are | |
3175 called so early here). */ | |
3176 if (!glyphs_initialized_initially_p) | |
3177 return Qnil; | |
3178 | |
3179 update_begin (f); | |
3180 if (FRAME_MSDOS_P (f)) | |
3181 set_terminal_modes (); | |
3182 clear_frame (); | |
3183 clear_current_matrices (f); | |
3184 update_end (f); | |
3185 fflush (stdout); | |
3186 windows_or_buffers_changed++; | |
3187 /* Mark all windows as inaccurate, so that every window will have | |
3188 its redisplay done. */ | |
3189 mark_window_display_accurate (FRAME_ROOT_WINDOW (f), 0); | |
3190 set_window_update_flags (XWINDOW (FRAME_ROOT_WINDOW (f)), 1); | |
3191 f->garbaged = 0; | |
3192 return Qnil; | |
3193 } | |
3194 | |
3195 | |
3196 /* Redraw frame F. This is nothing more than a call to the Lisp | |
3197 function redraw-frame. */ | |
3198 | |
3199 void | |
3200 redraw_frame (f) | |
3201 struct frame *f; | |
3202 { | |
3203 Lisp_Object frame; | |
3204 XSETFRAME (frame, f); | |
3205 Fredraw_frame (frame); | |
3206 } | |
3207 | |
3208 | |
3209 DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "", | |
3210 "Clear and redisplay all visible frames.") | |
3211 () | |
3212 { | |
3213 Lisp_Object tail, frame; | |
3214 | |
3215 FOR_EACH_FRAME (tail, frame) | |
3216 if (FRAME_VISIBLE_P (XFRAME (frame))) | |
3217 Fredraw_frame (frame); | |
3218 | |
3219 return Qnil; | |
3220 } | |
3221 | |
3222 | |
3223 /* This is used when frame_garbaged is set. Call Fredraw_frame on all | |
3224 visible frames marked as garbaged. */ | |
3225 | |
3226 void | |
3227 redraw_garbaged_frames () | |
3228 { | |
3229 Lisp_Object tail, frame; | |
3230 | |
3231 FOR_EACH_FRAME (tail, frame) | |
3232 if (FRAME_VISIBLE_P (XFRAME (frame)) | |
3233 && FRAME_GARBAGED_P (XFRAME (frame))) | |
3234 Fredraw_frame (frame); | |
3235 } | |
3236 | |
3237 | |
3238 | |
3239 /*********************************************************************** | |
3240 Direct Operations | |
3241 ***********************************************************************/ | |
3242 | |
3243 /* Try to update display and current glyph matrix directly. | |
3244 | |
3245 This function is called after a character G has been inserted into | |
3246 current_buffer. It tries to update the current glyph matrix and | |
3247 perform appropriate screen output to reflect the insertion. If it | |
3248 succeeds, the global flag redisplay_performed_directly_p will be | |
3249 set to 1, and thereby prevent the more costly general redisplay | |
3250 from running (see redisplay_internal). | |
3251 | |
3252 This function is not called for `hairy' character insertions. | |
3253 In particular, it is not called when after or before change | |
3254 functions exist, like they are used by font-lock. See keyboard.c | |
3255 for details where this function is called. */ | |
314 | 3256 |
3257 int | |
3258 direct_output_for_insert (g) | |
3259 int g; | |
3260 { | |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3261 register struct frame *f = SELECTED_FRAME (); |
25012 | 3262 struct window *w = XWINDOW (selected_window); |
3263 struct it it, it2; | |
3264 struct glyph_row *glyph_row; | |
3265 struct glyph *glyphs, *glyph, *end; | |
3266 int n; | |
3267 /* Non-null means that Redisplay of W is based on window matrices. */ | |
3268 int window_redisplay_p = FRAME_WINDOW_P (f); | |
3269 /* Non-null means we are in overwrite mode. */ | |
3270 int overwrite_p = !NILP (current_buffer->overwrite_mode); | |
3271 int added_width; | |
3272 struct text_pos pos; | |
3273 int delta, delta_bytes; | |
3274 | |
3275 /* Not done directly. */ | |
3276 redisplay_performed_directly_p = 0; | |
3277 | |
3278 /* Quickly give up for some common cases. */ | |
3279 if (cursor_in_echo_area | |
3280 /* Give up if fonts have changed. */ | |
3281 || fonts_changed_p | |
3282 /* Give up if face attributes have been changed. */ | |
3283 || face_change_count | |
3284 /* Give up if cursor position not really known. */ | |
314 | 3285 || !display_completed |
25012 | 3286 /* Give up if buffer appears in two places. */ |
314 | 3287 || buffer_shared > 1 |
34715
fc3693bea815
(direct_output_for_insert): Fix check for mini-window
Gerd Moellmann <gerd@gnu.org>
parents:
34622
diff
changeset
|
3288 /* Give up if currently displaying a message instead of the |
fc3693bea815
(direct_output_for_insert): Fix check for mini-window
Gerd Moellmann <gerd@gnu.org>
parents:
34622
diff
changeset
|
3289 minibuffer contents. */ |
fc3693bea815
(direct_output_for_insert): Fix check for mini-window
Gerd Moellmann <gerd@gnu.org>
parents:
34622
diff
changeset
|
3290 || (EQ (selected_window, minibuf_window) |
fc3693bea815
(direct_output_for_insert): Fix check for mini-window
Gerd Moellmann <gerd@gnu.org>
parents:
34622
diff
changeset
|
3291 && EQ (minibuf_window, echo_area_window)) |
25012 | 3292 /* Give up for hscrolled mini-buffer because display of the prompt |
3293 is handled specially there (see display_line). */ | |
3294 || (MINI_WINDOW_P (w) && XFASTINT (w->hscroll)) | |
3295 /* Give up if overwriting in the middle of a line. */ | |
3296 || (overwrite_p | |
3297 && PT != ZV | |
3298 && FETCH_BYTE (PT) != '\n') | |
3299 /* Give up for tabs and line ends. */ | |
3300 || g == '\t' | |
3301 || g == '\n' | |
3302 || g == '\r' | |
3303 /* Give up if unable to display the cursor in the window. */ | |
3304 || w->cursor.vpos < 0 | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3305 || (glyph_row = MATRIX_ROW (w->current_matrix, w->cursor.vpos), |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3306 /* Can't do it in a continued line because continuation |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3307 lines would change. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3308 (glyph_row->continued_p |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3309 /* Can't use this method if the line overlaps others or is |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3310 overlapped by others because these other lines would |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3311 have to be redisplayed. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3312 || glyph_row->overlapping_p |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3313 || glyph_row->overlapped_p)) |
25012 | 3314 /* Can't do it for partial width windows on terminal frames |
3315 because we can't clear to eol in such a window. */ | |
3316 || (!window_redisplay_p && !WINDOW_FULL_WIDTH_P (w))) | |
3317 return 0; | |
3318 | |
3319 /* Set up a display iterator structure for W. Glyphs will be | |
3320 produced in scratch_glyph_row. Current position is W's cursor | |
3321 position. */ | |
3322 clear_glyph_row (&scratch_glyph_row); | |
3323 SET_TEXT_POS (pos, PT, PT_BYTE); | |
28361
eccb57c44da5
(direct_output_for_insert): Use DEC_TEXT_POS
Gerd Moellmann <gerd@gnu.org>
parents:
27968
diff
changeset
|
3324 DEC_TEXT_POS (pos, !NILP (current_buffer->enable_multibyte_characters)); |
25012 | 3325 init_iterator (&it, w, CHARPOS (pos), BYTEPOS (pos), &scratch_glyph_row, |
3326 DEFAULT_FACE_ID); | |
3327 | |
3328 glyph_row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3329 if (glyph_row->mouse_face_p) |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3330 return 0; |
25012 | 3331 |
3332 /* Give up if highlighting trailing whitespace and we have trailing | |
3333 whitespace in glyph_row. We would have to remove the trailing | |
3334 whitespace face in that case. */ | |
25304
4b75c26bd356
(direct_output_for_insert): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25241
diff
changeset
|
3335 if (!NILP (Vshow_trailing_whitespace) |
25012 | 3336 && glyph_row->used[TEXT_AREA]) |
3337 { | |
3338 struct glyph *last; | |
3339 | |
3340 last = glyph_row->glyphs[TEXT_AREA] + glyph_row->used[TEXT_AREA] - 1; | |
3341 if (last->type == STRETCH_GLYPH | |
3342 || (last->type == CHAR_GLYPH | |
26998
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
3343 && last->u.ch == ' ')) |
25012 | 3344 return 0; |
3345 } | |
3346 | |
3347 /* Give up if there are overlay strings at pos. This would fail | |
3348 if the overlay string has newlines in it. */ | |
3349 if (STRINGP (it.string)) | |
3350 return 0; | |
3351 | |
3352 it.hpos = w->cursor.hpos; | |
3353 it.vpos = w->cursor.vpos; | |
3354 it.current_x = w->cursor.x + it.first_visible_x; | |
3355 it.current_y = w->cursor.y; | |
3356 it.end_charpos = PT; | |
3357 it.stop_charpos = min (PT, it.stop_charpos); | |
3358 | |
3359 /* More than one display element may be returned for PT - 1 if | |
3360 (i) it's a control character which is translated into `\003' or | |
3361 `^C', or (ii) it has a display table entry, or (iii) it's a | |
3362 combination of both. */ | |
3363 delta = delta_bytes = 0; | |
3364 while (get_next_display_element (&it)) | |
3365 { | |
3366 PRODUCE_GLYPHS (&it); | |
3367 | |
3368 /* Give up if glyph doesn't fit completely on the line. */ | |
3369 if (it.current_x >= it.last_visible_x) | |
3370 return 0; | |
3371 | |
3372 /* Give up if new glyph has different ascent or descent than | |
3373 the original row, or if it is not a character glyph. */ | |
3374 if (glyph_row->ascent != it.ascent | |
3375 || glyph_row->height != it.ascent + it.descent | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3376 || glyph_row->phys_ascent != it.phys_ascent |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3377 || glyph_row->phys_height != it.phys_ascent + it.phys_descent |
25012 | 3378 || it.what != IT_CHARACTER) |
3379 return 0; | |
3380 | |
3381 delta += 1; | |
3382 delta_bytes += it.len; | |
32468
20788c8274cd
(direct_output_for_insert): Call set_iterator_to_next
Gerd Moellmann <gerd@gnu.org>
parents:
31932
diff
changeset
|
3383 set_iterator_to_next (&it, 1); |
25012 | 3384 } |
3385 | |
3386 /* Give up if we hit the right edge of the window. We would have | |
3387 to insert truncation or continuation glyphs. */ | |
3388 added_width = it.current_x - (w->cursor.x + it.first_visible_x); | |
3389 if (glyph_row->pixel_width + added_width >= it.last_visible_x) | |
314 | 3390 return 0; |
3391 | |
25012 | 3392 /* Give up if there is a \t following in the line. */ |
3393 it2 = it; | |
3394 it2.end_charpos = ZV; | |
3395 it2.stop_charpos = min (it2.stop_charpos, ZV); | |
3396 while (get_next_display_element (&it2) | |
3397 && !ITERATOR_AT_END_OF_LINE_P (&it2)) | |
3398 { | |
3399 if (it2.c == '\t') | |
3400 return 0; | |
32468
20788c8274cd
(direct_output_for_insert): Call set_iterator_to_next
Gerd Moellmann <gerd@gnu.org>
parents:
31932
diff
changeset
|
3401 set_iterator_to_next (&it2, 1); |
25012 | 3402 } |
3403 | |
3404 /* Number of new glyphs produced. */ | |
3405 n = it.glyph_row->used[TEXT_AREA]; | |
3406 | |
3407 /* Start and end of glyphs in original row. */ | |
3408 glyphs = glyph_row->glyphs[TEXT_AREA] + w->cursor.hpos; | |
3409 end = glyph_row->glyphs[1 + TEXT_AREA]; | |
3410 | |
3411 /* Make room for new glyphs, then insert them. */ | |
3412 xassert (end - glyphs - n >= 0); | |
25781
e5579bc77d9e
(direct_output_for_insert): Cast arguments to
Gerd Moellmann <gerd@gnu.org>
parents:
25735
diff
changeset
|
3413 safe_bcopy ((char *) glyphs, (char *) (glyphs + n), |
e5579bc77d9e
(direct_output_for_insert): Cast arguments to
Gerd Moellmann <gerd@gnu.org>
parents:
25735
diff
changeset
|
3414 (end - glyphs - n) * sizeof (*end)); |
25012 | 3415 bcopy (it.glyph_row->glyphs[TEXT_AREA], glyphs, n * sizeof *glyphs); |
3416 glyph_row->used[TEXT_AREA] = min (glyph_row->used[TEXT_AREA] + n, | |
3417 end - glyph_row->glyphs[TEXT_AREA]); | |
3418 | |
3419 /* Compute new line width. */ | |
3420 glyph = glyph_row->glyphs[TEXT_AREA]; | |
3421 end = glyph + glyph_row->used[TEXT_AREA]; | |
3422 glyph_row->pixel_width = glyph_row->x; | |
3423 while (glyph < end) | |
3424 { | |
3425 glyph_row->pixel_width += glyph->pixel_width; | |
3426 ++glyph; | |
3427 } | |
3428 | |
3429 /* Increment buffer positions for glyphs following the newly | |
3430 inserted ones. */ | |
3431 for (glyph = glyphs + n; glyph < end; ++glyph) | |
26546
0f43cc91d6a5
(direct_output_for_insert): Increment glyph positions
Gerd Moellmann <gerd@gnu.org>
parents:
26499
diff
changeset
|
3432 if (glyph->charpos > 0 && BUFFERP (glyph->object)) |
25012 | 3433 glyph->charpos += delta; |
3434 | |
3435 if (MATRIX_ROW_END_CHARPOS (glyph_row) > 0) | |
3436 { | |
3437 MATRIX_ROW_END_CHARPOS (glyph_row) += delta; | |
3438 MATRIX_ROW_END_BYTEPOS (glyph_row) += delta_bytes; | |
3439 } | |
3440 | |
3441 /* Adjust positions in lines following the one we are in. */ | |
28708
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
3442 increment_matrix_positions (w->current_matrix, |
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
3443 w->cursor.vpos + 1, |
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
3444 w->current_matrix->nrows, |
4e2497e6757e
(increment_matrix_positions): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
28682
diff
changeset
|
3445 delta, delta_bytes); |
25012 | 3446 |
3447 glyph_row->contains_overlapping_glyphs_p | |
3448 |= it.glyph_row->contains_overlapping_glyphs_p; | |
3449 | |
26591
f7c7ef351f04
(direct_output_for_insert): Set glyph row's
Gerd Moellmann <gerd@gnu.org>
parents:
26546
diff
changeset
|
3450 glyph_row->displays_text_p = 1; |
f7c7ef351f04
(direct_output_for_insert): Set glyph row's
Gerd Moellmann <gerd@gnu.org>
parents:
26546
diff
changeset
|
3451 w->window_end_vpos = make_number (max (w->cursor.vpos, |
f7c7ef351f04
(direct_output_for_insert): Set glyph row's
Gerd Moellmann <gerd@gnu.org>
parents:
26546
diff
changeset
|
3452 XFASTINT (w->window_end_vpos))); |
f7c7ef351f04
(direct_output_for_insert): Set glyph row's
Gerd Moellmann <gerd@gnu.org>
parents:
26546
diff
changeset
|
3453 |
25304
4b75c26bd356
(direct_output_for_insert): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25241
diff
changeset
|
3454 if (!NILP (Vshow_trailing_whitespace)) |
25012 | 3455 highlight_trailing_whitespace (it.f, glyph_row); |
3456 | |
3457 /* Write glyphs. If at end of row, we can simply call write_glyphs. | |
3458 In the middle, we have to insert glyphs. Note that this is now | |
3459 implemented for X frames. The implementation uses updated_window | |
3460 and updated_row. */ | |
3461 updated_row = glyph_row; | |
3462 update_begin (f); | |
3463 if (rif) | |
3464 { | |
3465 rif->update_window_begin_hook (w); | |
3466 | |
3467 if (glyphs == end - n) | |
3468 rif->write_glyphs (glyphs, n); | |
3469 else | |
3470 rif->insert_glyphs (glyphs, n); | |
3471 } | |
3472 else | |
3473 { | |
3474 if (glyphs == end - n) | |
3475 write_glyphs (glyphs, n); | |
3476 else | |
3477 insert_glyphs (glyphs, n); | |
3478 } | |
3479 | |
3480 w->cursor.hpos += n; | |
3481 w->cursor.x = it.current_x - it.first_visible_x; | |
3482 xassert (w->cursor.hpos >= 0 | |
3483 && w->cursor.hpos < w->desired_matrix->matrix_w); | |
3484 | |
3485 /* How to set the cursor differs depending on whether we are | |
3486 using a frame matrix or a window matrix. Note that when | |
3487 a frame matrix is used, cursor_to expects frame coordinates, | |
3488 and the X and Y parameters are not used. */ | |
3489 if (window_redisplay_p) | |
3490 rif->cursor_to (w->cursor.vpos, w->cursor.hpos, | |
3491 w->cursor.y, w->cursor.x); | |
3492 else | |
3493 { | |
3494 int x, y; | |
3495 x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos) | |
3496 + (INTEGERP (w->left_margin_width) | |
3497 ? XFASTINT (w->left_margin_width) | |
3498 : 0)); | |
3499 y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); | |
3500 cursor_to (y, x); | |
3501 } | |
3502 | |
3503 if (rif) | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3504 rif->update_window_end_hook (w, 1, 0); |
25012 | 3505 update_end (f); |
3506 updated_row = NULL; | |
3507 fflush (stdout); | |
3508 | |
3509 TRACE ((stderr, "direct output for insert\n")); | |
3510 | |
25372
acf281b41a38
(direct_output_for_insert): Set beg_unchanged
Gerd Moellmann <gerd@gnu.org>
parents:
25345
diff
changeset
|
3511 UNCHANGED_MODIFIED = MODIFF; |
acf281b41a38
(direct_output_for_insert): Set beg_unchanged
Gerd Moellmann <gerd@gnu.org>
parents:
25345
diff
changeset
|
3512 BEG_UNCHANGED = GPT - BEG; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15896
diff
changeset
|
3513 XSETFASTINT (w->last_point, PT); |
25012 | 3514 w->last_cursor = w->cursor; |
9303
3115ae493c30
(direct_output_for_insert, direct_output_forward_char, change_frame_size,
Karl Heuer <kwzh@gnu.org>
parents:
9264
diff
changeset
|
3515 XSETFASTINT (w->last_modified, MODIFF); |
16195
e15e4bdcb8cc
(direct_output_for_insert): Set last_overlay_modified field in window.
Richard M. Stallman <rms@gnu.org>
parents:
16051
diff
changeset
|
3516 XSETFASTINT (w->last_overlay_modified, OVERLAY_MODIFF); |
314 | 3517 |
25012 | 3518 redisplay_performed_directly_p = 1; |
314 | 3519 return 1; |
3520 } | |
3521 | |
25012 | 3522 |
3523 /* Perform a direct display update for moving PT by N positions | |
3524 left or right. N < 0 means a movement backwards. This function | |
3525 is currently only called for N == 1 or N == -1. */ | |
3526 | |
314 | 3527 int |
3528 direct_output_forward_char (n) | |
3529 int n; | |
3530 { | |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3531 struct frame *f = SELECTED_FRAME (); |
25012 | 3532 struct window *w = XWINDOW (selected_window); |
3533 struct glyph_row *row; | |
3534 | |
26851
2513566d55fd
(direct_output_forward_char): Check point moving into
Kenichi Handa <handa@m17n.org>
parents:
26729
diff
changeset
|
3535 /* Give up if point moved out of or into a composition. */ |
28507
b6f06a755c7d
make_number/XINT/XUINT conversions; EQ/== fixes; ==Qnil -> NILP
Ken Raeburn <raeburn@raeburn.org>
parents:
28361
diff
changeset
|
3536 if (check_point_in_composition (current_buffer, XINT (w->last_point), |
26851
2513566d55fd
(direct_output_forward_char): Check point moving into
Kenichi Handa <handa@m17n.org>
parents:
26729
diff
changeset
|
3537 current_buffer, PT)) |
2513566d55fd
(direct_output_forward_char): Check point moving into
Kenichi Handa <handa@m17n.org>
parents:
26729
diff
changeset
|
3538 return 0; |
2513566d55fd
(direct_output_forward_char): Check point moving into
Kenichi Handa <handa@m17n.org>
parents:
26729
diff
changeset
|
3539 |
25012 | 3540 /* Give up if face attributes have been changed. */ |
3541 if (face_change_count) | |
17015
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
3542 return 0; |
25012 | 3543 |
3544 /* Give up if current matrix is not up to date or we are | |
3545 displaying a message. */ | |
3546 if (!display_completed || cursor_in_echo_area) | |
3547 return 0; | |
3548 | |
3549 /* Give up if the buffer's direction is reversed. */ | |
3550 if (!NILP (XBUFFER (w->buffer)->direction_reversed)) | |
314 | 3551 return 0; |
11096
cac0367b1794
(direct_output_forward_char): Don't use direct output at an overlay boundary.
Karl Heuer <kwzh@gnu.org>
parents:
10770
diff
changeset
|
3552 |
2794
9163e4e4752c
(direct_output_forward_char): Just give up
Richard M. Stallman <rms@gnu.org>
parents:
2778
diff
changeset
|
3553 /* 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
|
3554 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
|
3555 return 0; |
9163e4e4752c
(direct_output_forward_char): Just give up
Richard M. Stallman <rms@gnu.org>
parents:
2778
diff
changeset
|
3556 |
25304
4b75c26bd356
(direct_output_for_insert): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25241
diff
changeset
|
3557 /* Can't use direct output if highlighting trailing whitespace. */ |
4b75c26bd356
(direct_output_for_insert): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25241
diff
changeset
|
3558 if (!NILP (Vshow_trailing_whitespace)) |
4b75c26bd356
(direct_output_for_insert): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25241
diff
changeset
|
3559 return 0; |
4b75c26bd356
(direct_output_for_insert): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25241
diff
changeset
|
3560 |
25735
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3561 /* Give up if we are showing a message or just cleared the message |
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3562 because we might need to resize the echo area window. */ |
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3563 if (!NILP (echo_area_buffer[0]) || !NILP (echo_area_buffer[1])) |
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3564 return 0; |
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3565 |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
3566 /* Give up if currently displaying a message instead of the |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
3567 minibuffer contents. */ |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
3568 if (XWINDOW (minibuf_window) == w |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
3569 && EQ (minibuf_window, echo_area_window)) |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
3570 return 0; |
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
3571 |
25735
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3572 /* Give up if we don't know where the cursor is. */ |
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3573 if (w->cursor.vpos < 0) |
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3574 return 0; |
fcb92c26acf2
(direct_output_forward_char): Don't use this method
Gerd Moellmann <gerd@gnu.org>
parents:
25725
diff
changeset
|
3575 |
25012 | 3576 row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); |
3577 | |
31271
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
3578 /* Give up if PT is outside of the last known cursor row. */ |
25012 | 3579 if (PT <= MATRIX_ROW_START_BYTEPOS (row) |
3580 || PT >= MATRIX_ROW_END_BYTEPOS (row)) | |
6069
07045ca8ff19
(direct_output_forward_char): Use Fget_char_property to test for invisibility.
Karl Heuer <kwzh@gnu.org>
parents:
6068
diff
changeset
|
3581 return 0; |
4384
98605d0ea3cf
(direct_output_for_insert): Fail if character
Richard M. Stallman <rms@gnu.org>
parents:
4290
diff
changeset
|
3582 |
25012 | 3583 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); |
31271
4f0c5eecc5a6
(build_frame_matrix_from_leaf_window): If a row of a
Gerd Moellmann <gerd@gnu.org>
parents:
31093
diff
changeset
|
3584 |
25012 | 3585 w->last_cursor = w->cursor; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15896
diff
changeset
|
3586 XSETFASTINT (w->last_point, PT); |
25012 | 3587 |
3588 xassert (w->cursor.hpos >= 0 | |
3589 && w->cursor.hpos < w->desired_matrix->matrix_w); | |
3590 | |
3591 if (FRAME_WINDOW_P (f)) | |
3592 rif->cursor_to (w->cursor.vpos, w->cursor.hpos, | |
3593 w->cursor.y, w->cursor.x); | |
3594 else | |
3595 { | |
3596 int x, y; | |
3597 x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos) | |
3598 + (INTEGERP (w->left_margin_width) | |
3599 ? XFASTINT (w->left_margin_width) | |
3600 : 0)); | |
3601 y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); | |
3602 cursor_to (y, x); | |
3603 } | |
3604 | |
314 | 3605 fflush (stdout); |
25012 | 3606 redisplay_performed_directly_p = 1; |
314 | 3607 return 1; |
3608 } | |
25012 | 3609 |
3610 | |
314 | 3611 |
25012 | 3612 /*********************************************************************** |
3613 Frame Update | |
3614 ***********************************************************************/ | |
3615 | |
3616 /* Update frame F based on the data in desired matrices. | |
3617 | |
3618 If FORCE_P is non-zero, don't let redisplay be stopped by detecting | |
3619 pending input. If INHIBIT_HAIRY_ID_P is non-zero, don't try | |
3620 scrolling. | |
3621 | |
3622 Value is non-zero if redisplay was stopped due to pending input. */ | |
314 | 3623 |
3624 int | |
25012 | 3625 update_frame (f, force_p, inhibit_hairy_id_p) |
3626 struct frame *f; | |
3627 int force_p; | |
3628 int inhibit_hairy_id_p; | |
3629 { | |
3630 /* 1 means display has been paused because of pending input. */ | |
3631 int paused_p; | |
3632 struct window *root_window = XWINDOW (f->root_window); | |
3633 | |
3634 if (FRAME_WINDOW_P (f)) | |
3635 { | |
3636 /* We are working on window matrix basis. All windows whose | |
3637 flag must_be_updated_p is set have to be updated. */ | |
3638 | |
3639 /* Record that we are not working on frame matrices. */ | |
3640 set_frame_matrix_frame (NULL); | |
3641 | |
3642 /* Update all windows in the window tree of F, maybe stopping | |
3643 when pending input is detected. */ | |
3644 update_begin (f); | |
3645 | |
3646 /* Update the menu bar on X frames that don't have toolkit | |
3647 support. */ | |
3648 if (WINDOWP (f->menu_bar_window)) | |
3649 update_window (XWINDOW (f->menu_bar_window), 1); | |
3650 | |
3651 /* Update the tool-bar window, if present. */ | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
3652 if (WINDOWP (f->tool_bar_window)) |
25012 | 3653 { |
3654 Lisp_Object tem; | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
3655 struct window *w = XWINDOW (f->tool_bar_window); |
25012 | 3656 |
3657 /* Update tool-bar window. */ | |
3658 if (w->must_be_updated_p) | |
3659 { | |
3660 update_window (w, 1); | |
3661 w->must_be_updated_p = 0; | |
3662 | |
3663 /* Swap tool-bar strings. We swap because we want to | |
3664 reuse strings. */ | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
3665 tem = f->current_tool_bar_string; |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
3666 f->current_tool_bar_string = f->desired_tool_bar_string; |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
3667 f->desired_tool_bar_string = tem; |
25012 | 3668 } |
3669 } | |
3670 | |
3671 | |
3672 /* Update windows. */ | |
3673 paused_p = update_window_tree (root_window, force_p); | |
3674 update_end (f); | |
31295
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3675 |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3676 #if 0 /* This flush is a performance bottleneck under X, |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3677 and it doesn't seem to be necessary anyway. */ |
25012 | 3678 rif->flush_display (f); |
3679 #endif | |
3680 } | |
3681 else | |
3682 { | |
3683 /* We are working on frame matrix basis. Set the frame on whose | |
3684 frame matrix we operate. */ | |
3685 set_frame_matrix_frame (f); | |
3686 | |
31295
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3687 /* Build F's desired matrix from window matrices. */ |
25012 | 3688 build_frame_matrix (f); |
3689 | |
31295
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3690 /* Update the display */ |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3691 update_begin (f); |
25012 | 3692 paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p); |
31295
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3693 update_end (f); |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3694 |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3695 if (termscript) |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3696 fflush (termscript); |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3697 fflush (stdout); |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3698 |
25012 | 3699 /* Check window matrices for lost pointers. */ |
3700 IF_DEBUG (check_window_matrix_pointers (root_window)); | |
3701 } | |
3702 | |
3703 /* Reset flags indicating that a window should be updated. */ | |
3704 set_window_update_flags (root_window, 0); | |
31295
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3705 |
d4f918f0b184
(update_frame): Only set display_completed here; use
Gerd Moellmann <gerd@gnu.org>
parents:
31271
diff
changeset
|
3706 display_completed = !paused_p; |
25012 | 3707 return paused_p; |
3708 } | |
3709 | |
3710 | |
3711 | |
3712 /************************************************************************ | |
3713 Window-based updates | |
3714 ************************************************************************/ | |
3715 | |
3716 /* Perform updates in window tree rooted at W. FORCE_P non-zero means | |
3717 don't stop updating when input is pending. */ | |
3718 | |
3719 static int | |
3720 update_window_tree (w, force_p) | |
3721 struct window *w; | |
3722 int force_p; | |
3723 { | |
3724 int paused_p = 0; | |
3725 | |
3726 while (w && !paused_p) | |
3727 { | |
3728 if (!NILP (w->hchild)) | |
3729 paused_p |= update_window_tree (XWINDOW (w->hchild), force_p); | |
3730 else if (!NILP (w->vchild)) | |
3731 paused_p |= update_window_tree (XWINDOW (w->vchild), force_p); | |
3732 else if (w->must_be_updated_p) | |
3733 paused_p |= update_window (w, force_p); | |
3734 | |
3735 w = NILP (w->next) ? 0 : XWINDOW (w->next); | |
3736 } | |
3737 | |
3738 return paused_p; | |
3739 } | |
3740 | |
3741 | |
3742 /* Update window W if its flag must_be_updated_p is non-zero. If | |
3743 FORCE_P is non-zero, don't stop updating if input is pending. */ | |
3744 | |
3745 void | |
3746 update_single_window (w, force_p) | |
3747 struct window *w; | |
3748 int force_p; | |
3749 { | |
3750 if (w->must_be_updated_p) | |
3751 { | |
3752 struct frame *f = XFRAME (WINDOW_FRAME (w)); | |
3753 | |
3754 /* Record that this is not a frame-based redisplay. */ | |
3755 set_frame_matrix_frame (NULL); | |
3756 | |
3757 /* Update W. */ | |
3758 update_begin (f); | |
3759 update_window (w, force_p); | |
3760 update_end (f); | |
3761 | |
3762 /* Reset flag in W. */ | |
3763 w->must_be_updated_p = 0; | |
3764 } | |
3765 } | |
3766 | |
3767 | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3768 /* Redraw lines from the current matrix of window W that are |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3769 overlapped by other rows. YB is bottom-most y-position in W. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3770 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3771 static void |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3772 redraw_overlapped_rows (w, yb) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3773 struct window *w; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3774 int yb; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3775 { |
30165
d7ec5b3caccc
(redraw_overlapped_rows): Add missing local.
Gerd Moellmann <gerd@gnu.org>
parents:
30161
diff
changeset
|
3776 int i; |
d7ec5b3caccc
(redraw_overlapped_rows): Add missing local.
Gerd Moellmann <gerd@gnu.org>
parents:
30161
diff
changeset
|
3777 |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3778 /* If rows overlapping others have been changed, the rows being |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3779 overlapped have to be redrawn. This won't draw lines that have |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3780 already been drawn in update_window_line because overlapped_p in |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3781 desired rows is 0, so after row assignment overlapped_p in |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3782 current rows is 0. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3783 for (i = 0; i < w->current_matrix->nrows; ++i) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3784 { |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3785 struct glyph_row *row = w->current_matrix->rows + i; |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3786 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3787 if (!row->enabled_p) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3788 break; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3789 else if (row->mode_line_p) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3790 continue; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3791 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3792 if (row->overlapped_p) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3793 { |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3794 enum glyph_row_area area; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3795 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3796 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3797 { |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3798 updated_row = row; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3799 updated_area = area; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3800 rif->cursor_to (i, 0, row->y, area == TEXT_AREA ? row->x : 0); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3801 if (row->used[area]) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3802 rif->write_glyphs (row->glyphs[area], row->used[area]); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3803 rif->clear_end_of_line (-1); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3804 } |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3805 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3806 row->overlapped_p = 0; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3807 } |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3808 |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3809 if (MATRIX_ROW_BOTTOM_Y (row) >= yb) |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3810 break; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3811 } |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3812 } |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3813 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3814 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3815 /* Redraw lines from the current matrix of window W that overlap |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3816 others. YB is bottom-most y-position in W. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3817 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3818 static void |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3819 redraw_overlapping_rows (w, yb) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3820 struct window *w; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3821 int yb; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3822 { |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3823 int i, bottom_y; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3824 struct glyph_row *row; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3825 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3826 for (i = 0; i < w->current_matrix->nrows; ++i) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3827 { |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3828 row = w->current_matrix->rows + i; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3829 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3830 if (!row->enabled_p) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3831 break; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3832 else if (row->mode_line_p) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3833 continue; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3834 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3835 bottom_y = MATRIX_ROW_BOTTOM_Y (row); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3836 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3837 if (row->overlapping_p && i > 0 && bottom_y < yb) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3838 { |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3839 if (row->used[LEFT_MARGIN_AREA]) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3840 rif->fix_overlapping_area (w, row, LEFT_MARGIN_AREA); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3841 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3842 if (row->used[TEXT_AREA]) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3843 rif->fix_overlapping_area (w, row, TEXT_AREA); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3844 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3845 if (row->used[RIGHT_MARGIN_AREA]) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3846 rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA); |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3847 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3848 /* Record in neighbor rows that ROW overwrites part of their |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3849 display. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3850 if (row->phys_ascent > row->ascent && i > 0) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3851 MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3852 if ((row->phys_height - row->phys_ascent |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3853 > row->height - row->ascent) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3854 && bottom_y < yb) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3855 MATRIX_ROW (w->current_matrix, i + 1)->overlapped_p = 1; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3856 } |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3857 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3858 if (bottom_y >= yb) |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3859 break; |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3860 } |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3861 } |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3862 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3863 |
25012 | 3864 /* Update display of window W. FORCE_P non-zero means that we should |
3865 not stop when detecting pending input. */ | |
3866 | |
3867 static int | |
3868 update_window (w, force_p) | |
3869 struct window *w; | |
3870 int force_p; | |
3871 { | |
3872 struct glyph_matrix *desired_matrix = w->desired_matrix; | |
3873 int paused_p; | |
3874 int preempt_count = baud_rate / 2400 + 1; | |
3875 extern int input_pending; | |
34517
7c8d2cec3d08
(update_window): If do_mouse_tracking is non-nil,
Gerd Moellmann <gerd@gnu.org>
parents:
34279
diff
changeset
|
3876 extern Lisp_Object do_mouse_tracking; |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
3877 #if GLYPH_DEBUG |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
3878 struct frame *f = XFRAME (WINDOW_FRAME (w)); |
25012 | 3879 extern struct frame *updating_frame; |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
3880 #endif |
25012 | 3881 |
3882 /* Check that W's frame doesn't have glyph matrices. */ | |
3883 xassert (FRAME_WINDOW_P (f)); | |
3884 xassert (updating_frame != NULL); | |
3885 | |
3886 /* Check pending input the first time so that we can quickly return. */ | |
3887 if (redisplay_dont_pause) | |
3888 force_p = 1; | |
3889 else | |
3890 detect_input_pending (); | |
3891 | |
3892 /* If forced to complete the update, or if no input is pending, do | |
3893 the update. */ | |
34517
7c8d2cec3d08
(update_window): If do_mouse_tracking is non-nil,
Gerd Moellmann <gerd@gnu.org>
parents:
34279
diff
changeset
|
3894 if (force_p || !input_pending || !NILP (do_mouse_tracking)) |
25012 | 3895 { |
3896 struct glyph_row *row, *end; | |
3897 struct glyph_row *mode_line_row; | |
25546 | 3898 struct glyph_row *header_line_row = NULL; |
34622
877ed6cab304
(update_window): Detect pending input every nth line
Gerd Moellmann <gerd@gnu.org>
parents:
34517
diff
changeset
|
3899 int yb, changed_p = 0, mouse_face_overwritten_p = 0, n_updated; |
25012 | 3900 |
3901 rif->update_window_begin_hook (w); | |
3902 yb = window_text_bottom_y (w); | |
3903 | |
3904 /* If window has a top line, update it before everything else. | |
3905 Adjust y-positions of other rows by the top line height. */ | |
3906 row = desired_matrix->rows; | |
3907 end = row + desired_matrix->nrows - 1; | |
3908 if (row->mode_line_p) | |
25546 | 3909 header_line_row = row++; |
25012 | 3910 |
3911 /* Update the mode line, if necessary. */ | |
3912 mode_line_row = MATRIX_MODE_LINE_ROW (desired_matrix); | |
3913 if (mode_line_row->mode_line_p && mode_line_row->enabled_p) | |
3914 { | |
3915 mode_line_row->y = yb; | |
3916 update_window_line (w, MATRIX_ROW_VPOS (mode_line_row, | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3917 desired_matrix), |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3918 &mouse_face_overwritten_p); |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3919 changed_p = 1; |
25012 | 3920 } |
3921 | |
3922 /* Find first enabled row. Optimizations in redisplay_internal | |
3923 may lead to an update with only one row enabled. There may | |
3924 be also completely empty matrices. */ | |
3925 while (row < end && !row->enabled_p) | |
3926 ++row; | |
3927 | |
31825
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
3928 /* Try reusing part of the display by copying. */ |
25012 | 3929 if (row < end && !desired_matrix->no_scrolling_p) |
3930 { | |
25546 | 3931 int rc = scrolling_window (w, header_line_row != NULL); |
25012 | 3932 if (rc < 0) |
3933 { | |
3934 /* All rows were found to be equal. */ | |
3935 paused_p = 0; | |
3936 goto set_cursor; | |
3937 } | |
3938 else if (rc > 0) | |
3939 force_p = 1; | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3940 changed_p = 1; |
25012 | 3941 } |
3942 | |
3943 /* Update the top mode line after scrolling because a new top | |
3944 line would otherwise overwrite lines at the top of the window | |
3945 that can be scrolled. */ | |
25546 | 3946 if (header_line_row && header_line_row->enabled_p) |
25012 | 3947 { |
25546 | 3948 header_line_row->y = 0; |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3949 update_window_line (w, 0, &mouse_face_overwritten_p); |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3950 changed_p = 1; |
25012 | 3951 } |
3952 | |
3953 /* Update the rest of the lines. */ | |
34622
877ed6cab304
(update_window): Detect pending input every nth line
Gerd Moellmann <gerd@gnu.org>
parents:
34517
diff
changeset
|
3954 for (n_updated = 0; row < end && (force_p || !input_pending); ++row) |
31653
2554afbeb88d
(update_window): Make sure to make desired rows
Gerd Moellmann <gerd@gnu.org>
parents:
31295
diff
changeset
|
3955 if (row->enabled_p) |
25012 | 3956 { |
3957 int vpos = MATRIX_ROW_VPOS (row, desired_matrix); | |
3958 int i; | |
3959 | |
3960 /* We'll Have to play a little bit with when to | |
3961 detect_input_pending. If it's done too often, | |
3962 scrolling large windows with repeated scroll-up | |
3963 commands will too quickly pause redisplay. */ | |
34622
877ed6cab304
(update_window): Detect pending input every nth line
Gerd Moellmann <gerd@gnu.org>
parents:
34517
diff
changeset
|
3964 if (!force_p && ++n_updated % preempt_count == 0) |
25012 | 3965 detect_input_pending (); |
3966 | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3967 changed_p |= update_window_line (w, vpos, |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3968 &mouse_face_overwritten_p); |
25012 | 3969 |
3970 /* Mark all rows below the last visible one in the current | |
3971 matrix as invalid. This is necessary because of | |
3972 variable line heights. Consider the case of three | |
3973 successive redisplays, where the first displays 5 | |
3974 lines, the second 3 lines, and the third 5 lines again. | |
3975 If the second redisplay wouldn't mark rows in the | |
3976 current matrix invalid, the third redisplay might be | |
3977 tempted to optimize redisplay based on lines displayed | |
3978 in the first redisplay. */ | |
3979 if (MATRIX_ROW_BOTTOM_Y (row) >= yb) | |
3980 for (i = vpos + 1; i < w->current_matrix->nrows - 1; ++i) | |
3981 MATRIX_ROW (w->current_matrix, i)->enabled_p = 0; | |
3982 } | |
3983 | |
3984 /* Was display preempted? */ | |
3985 paused_p = row < end; | |
3986 | |
3987 set_cursor: | |
3988 | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
3989 /* Fix the appearance of overlapping(overlapped rows. */ |
25012 | 3990 if (!paused_p && !w->pseudo_window_p) |
3991 { | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3992 if (changed_p && rif->fix_overlapping_area) |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3993 { |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3994 redraw_overlapped_rows (w, yb); |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3995 redraw_overlapping_rows (w, yb); |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3996 } |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
3997 |
25012 | 3998 /* Make cursor visible at cursor position of W. */ |
3999 set_window_cursor_after_update (w); | |
4000 | |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4001 #if 0 /* Check that current matrix invariants are satisfied. This is |
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4002 for debugging only. See the comment of check_matrix_invariants. */ |
25012 | 4003 IF_DEBUG (check_matrix_invariants (w)); |
4004 #endif | |
4005 } | |
4006 | |
4007 #if GLYPH_DEBUG | |
4008 /* Remember the redisplay method used to display the matrix. */ | |
4009 strcpy (w->current_matrix->method, w->desired_matrix->method); | |
4010 #endif | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4011 |
25012 | 4012 /* End of update of window W. */ |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4013 rif->update_window_end_hook (w, 1, mouse_face_overwritten_p); |
25012 | 4014 } |
4015 else | |
4016 paused_p = 1; | |
4017 | |
4018 clear_glyph_matrix (desired_matrix); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4019 |
25012 | 4020 return paused_p; |
4021 } | |
4022 | |
4023 | |
4024 /* Update the display of area AREA in window W, row number VPOS. | |
4025 AREA can be either LEFT_MARGIN_AREA or RIGHT_MARGIN_AREA. */ | |
4026 | |
4027 static void | |
4028 update_marginal_area (w, area, vpos) | |
4029 struct window *w; | |
4030 int area, vpos; | |
4031 { | |
4032 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); | |
4033 | |
4034 /* Let functions in xterm.c know what area subsequent X positions | |
4035 will be relative to. */ | |
4036 updated_area = area; | |
4037 | |
4038 /* Set cursor to start of glyphs, write them, and clear to the end | |
4039 of the area. I don't think that something more sophisticated is | |
4040 necessary here, since marginal areas will not be the default. */ | |
4041 rif->cursor_to (vpos, 0, desired_row->y, 0); | |
4042 if (desired_row->used[area]) | |
4043 rif->write_glyphs (desired_row->glyphs[area], desired_row->used[area]); | |
4044 rif->clear_end_of_line (-1); | |
4045 } | |
4046 | |
4047 | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4048 /* Update the display of the text area of row VPOS in window W. |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4049 Value is non-zero if display has changed. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4050 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4051 static int |
25012 | 4052 update_text_area (w, vpos) |
4053 struct window *w; | |
4054 int vpos; | |
314 | 4055 { |
25012 | 4056 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); |
4057 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4058 int changed_p = 0; |
25012 | 4059 |
4060 /* Let functions in xterm.c know what area subsequent X positions | |
4061 will be relative to. */ | |
4062 updated_area = TEXT_AREA; | |
4063 | |
4064 /* If rows are at different X or Y, or rows have different height, | |
4065 or the current row is marked invalid, write the entire line. */ | |
4066 if (!current_row->enabled_p | |
4067 || desired_row->y != current_row->y | |
4068 || desired_row->ascent != current_row->ascent | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4069 || desired_row->phys_ascent != current_row->phys_ascent |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4070 || desired_row->phys_height != current_row->phys_height |
25012 | 4071 || desired_row->visible_height != current_row->visible_height |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4072 || current_row->overlapped_p |
30307
faf4e303bab7
(update_text_area): Write the whole row if it
Gerd Moellmann <gerd@gnu.org>
parents:
30165
diff
changeset
|
4073 || current_row->mouse_face_p |
25012 | 4074 || current_row->x != desired_row->x) |
4075 { | |
4076 rif->cursor_to (vpos, 0, desired_row->y, desired_row->x); | |
4077 | |
4078 if (desired_row->used[TEXT_AREA]) | |
4079 rif->write_glyphs (desired_row->glyphs[TEXT_AREA], | |
4080 desired_row->used[TEXT_AREA]); | |
4081 | |
4082 /* Clear to end of window. */ | |
4083 rif->clear_end_of_line (-1); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4084 changed_p = 1; |
25012 | 4085 } |
4086 else | |
4087 { | |
4088 int stop, i, x; | |
4089 struct glyph *current_glyph = current_row->glyphs[TEXT_AREA]; | |
4090 struct glyph *desired_glyph = desired_row->glyphs[TEXT_AREA]; | |
33596
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4091 int overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p; |
25012 | 4092 |
4093 /* If the desired row extends its face to the text area end, | |
4094 make sure we write at least one glyph, so that the face | |
4095 extension actually takes place. */ | |
4096 int desired_stop_pos = (desired_row->used[TEXT_AREA] | |
4097 - (MATRIX_ROW_EXTENDS_FACE_P (desired_row) | |
4098 ? 1 : 0)); | |
4099 | |
4100 stop = min (current_row->used[TEXT_AREA], desired_stop_pos); | |
4101 i = 0; | |
4102 x = desired_row->x; | |
4103 | |
4104 while (i < stop) | |
4105 { | |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4106 int can_skip_p = 1; |
33596
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4107 |
25012 | 4108 /* Skip over glyphs that both rows have in common. These |
33596
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4109 don't have to be written. We can't skip if the last |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4110 current glyph overlaps the glyph to its right. For |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4111 example, consider a current row of `if ' with the `f' in |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4112 Courier bold so that it overlaps the ` ' to its right. |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4113 If the desired row is ` ', we would skip over the space |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4114 after the `if' and there would remain a pixel from the |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4115 `f' on the screen. */ |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4116 if (overlapping_glyphs_p && i > 0) |
25012 | 4117 { |
33596
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4118 struct glyph *glyph = ¤t_row->glyphs[TEXT_AREA][i - 1]; |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4119 int left, right; |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4120 |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4121 rif->get_glyph_overhangs (glyph, XFRAME (w->frame), |
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4122 &left, &right); |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4123 can_skip_p = right == 0; |
25012 | 4124 } |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4125 |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4126 if (can_skip_p) |
25012 | 4127 { |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4128 while (i < stop |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4129 && GLYPH_EQUAL_P (desired_glyph, current_glyph)) |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4130 { |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4131 x += desired_glyph->pixel_width; |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4132 ++desired_glyph, ++current_glyph, ++i; |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4133 } |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4134 |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4135 /* Consider the case that the current row contains "xxx |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4136 ppp ggg" in italic Courier font, and the desired row |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4137 is "xxx ggg". The character `p' has lbearing, `g' |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4138 has not. The loop above will stop in front of the |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4139 first `p' in the current row. If we would start |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4140 writing glyphs there, we wouldn't erase the lbearing |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4141 of the `p'. The rest of the lbearing problem is then |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4142 taken care of by x_draw_glyphs. */ |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4143 if (overlapping_glyphs_p |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4144 && i > 0 |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4145 && i < current_row->used[TEXT_AREA] |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4146 && (current_row->used[TEXT_AREA] |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4147 != desired_row->used[TEXT_AREA])) |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4148 { |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4149 int left, right; |
33596
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4150 |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4151 rif->get_glyph_overhangs (current_glyph, XFRAME (w->frame), |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4152 &left, &right); |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4153 while (left > 0 && i > 0) |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4154 { |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4155 --i, --desired_glyph, --current_glyph; |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4156 x -= desired_glyph->pixel_width; |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4157 left -= desired_glyph->pixel_width; |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4158 } |
25012 | 4159 } |
4160 } | |
4161 | |
4162 /* Try to avoid writing the entire rest of the desired row | |
4163 by looking for a resync point. This mainly prevents | |
4164 mode line flickering in the case the mode line is in | |
4165 fixed-pitch font, which it usually will be. */ | |
4166 if (i < desired_row->used[TEXT_AREA]) | |
4167 { | |
4168 int start_x = x, start_hpos = i; | |
4169 struct glyph *start = desired_glyph; | |
4170 int current_x = x; | |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4171 int skip_first_p = !can_skip_p; |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4172 |
25012 | 4173 /* Find the next glyph that's equal again. */ |
4174 while (i < stop | |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4175 && (skip_first_p |
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4176 || !GLYPH_EQUAL_P (desired_glyph, current_glyph)) |
25012 | 4177 && x == current_x) |
4178 { | |
4179 x += desired_glyph->pixel_width; | |
4180 current_x += current_glyph->pixel_width; | |
4181 ++desired_glyph, ++current_glyph, ++i; | |
33603
6697403d3c12
(update_text_area): Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents:
33596
diff
changeset
|
4182 skip_first_p = 0; |
25012 | 4183 } |
4184 | |
4185 if (i == start_hpos || x != current_x) | |
4186 { | |
4187 i = start_hpos; | |
4188 x = start_x; | |
4189 desired_glyph = start; | |
4190 break; | |
4191 } | |
33596
680ddd4ab1f9
(update_text_area): Don't skip over equal glyphs
Gerd Moellmann <gerd@gnu.org>
parents:
33527
diff
changeset
|
4192 |
25012 | 4193 rif->cursor_to (vpos, start_hpos, desired_row->y, start_x); |
4194 rif->write_glyphs (start, i - start_hpos); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4195 changed_p = 1; |
25012 | 4196 } |
4197 } | |
4198 | |
4199 /* Write the rest. */ | |
4200 if (i < desired_row->used[TEXT_AREA]) | |
4201 { | |
4202 rif->cursor_to (vpos, i, desired_row->y, x); | |
4203 rif->write_glyphs (desired_glyph, desired_row->used[TEXT_AREA] - i); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4204 changed_p = 1; |
25012 | 4205 } |
4206 | |
4207 /* Maybe clear to end of line. */ | |
4208 if (MATRIX_ROW_EXTENDS_FACE_P (desired_row)) | |
4209 { | |
4210 /* If new row extends to the end of the text area, nothing | |
4211 has to be cleared, if and only if we did a write_glyphs | |
4212 above. This is made sure by setting desired_stop_pos | |
4213 appropriately above. */ | |
4214 xassert (i < desired_row->used[TEXT_AREA]); | |
4215 } | |
4216 else if (MATRIX_ROW_EXTENDS_FACE_P (current_row)) | |
4217 { | |
4218 /* If old row extends to the end of the text area, clear. */ | |
4219 if (i >= desired_row->used[TEXT_AREA]) | |
4220 rif->cursor_to (vpos, i, desired_row->y, | |
4221 desired_row->x + desired_row->pixel_width); | |
4222 rif->clear_end_of_line (-1); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4223 changed_p = 1; |
25012 | 4224 } |
4225 else if (desired_row->pixel_width < current_row->pixel_width) | |
4226 { | |
4227 /* Otherwise clear to the end of the old row. Everything | |
4228 after that position should be clear already. */ | |
4229 int x; | |
4230 | |
4231 if (i >= desired_row->used[TEXT_AREA]) | |
4232 rif->cursor_to (vpos, i, desired_row->y, | |
4233 desired_row->x + desired_row->pixel_width); | |
4234 | |
4235 /* If cursor is displayed at the end of the line, make sure | |
4236 it's cleared. Nowadays we don't have a phys_cursor_glyph | |
4237 with which to erase the cursor (because this method | |
4238 doesn't work with lbearing/rbearing), so we must do it | |
4239 this way. */ | |
4240 if (vpos == w->phys_cursor.vpos | |
4241 && w->phys_cursor.hpos >= desired_row->used[TEXT_AREA]) | |
4242 { | |
4243 w->phys_cursor_on_p = 0; | |
4244 x = -1; | |
4245 } | |
4246 else | |
4247 x = current_row->x + current_row->pixel_width; | |
4248 rif->clear_end_of_line (x); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4249 changed_p = 1; |
25012 | 4250 } |
4251 } | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4252 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4253 return changed_p; |
25012 | 4254 } |
4255 | |
4256 | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4257 /* Update row VPOS in window W. Value is non-zero if display has been |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4258 changed. */ |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4259 |
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4260 static int |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4261 update_window_line (w, vpos, mouse_face_overwritten_p) |
25012 | 4262 struct window *w; |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4263 int vpos, *mouse_face_overwritten_p; |
25012 | 4264 { |
4265 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); | |
4266 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4267 int changed_p = 0; |
25012 | 4268 |
4269 /* Set the row being updated. This is important to let xterm.c | |
4270 know what line height values are in effect. */ | |
4271 updated_row = desired_row; | |
4272 | |
31690
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4273 /* A row can be completely invisible in case a desired matrix was |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4274 built with a vscroll and then make_cursor_line_fully_visible shifts |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4275 the matrix. Make sure to make such rows current anyway, since |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4276 we need the correct y-position, for example, in the current matrix. */ |
31726
59b455472b56
(update_window_line): Make sure to always draw
Gerd Moellmann <gerd@gnu.org>
parents:
31690
diff
changeset
|
4277 if (desired_row->mode_line_p |
59b455472b56
(update_window_line): Make sure to always draw
Gerd Moellmann <gerd@gnu.org>
parents:
31690
diff
changeset
|
4278 || desired_row->visible_height > 0) |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4279 { |
31690
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4280 xassert (desired_row->enabled_p); |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4281 |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4282 /* Update display of the left margin area, if there is one. */ |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4283 if (!desired_row->full_width_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4284 && !NILP (w->left_margin_width)) |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4285 { |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4286 changed_p = 1; |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4287 update_marginal_area (w, LEFT_MARGIN_AREA, vpos); |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4288 } |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4289 |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4290 /* Update the display of the text area. */ |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4291 if (update_text_area (w, vpos)) |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4292 { |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4293 changed_p = 1; |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4294 if (current_row->mouse_face_p) |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4295 *mouse_face_overwritten_p = 1; |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4296 } |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4297 |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4298 /* Update display of the right margin area, if there is one. */ |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4299 if (!desired_row->full_width_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4300 && !NILP (w->right_margin_width)) |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4301 { |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4302 changed_p = 1; |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4303 update_marginal_area (w, RIGHT_MARGIN_AREA, vpos); |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4304 } |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4305 |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4306 /* Draw truncation marks etc. */ |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4307 if (!current_row->enabled_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4308 || desired_row->y != current_row->y |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4309 || desired_row->visible_height != current_row->visible_height |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4310 || desired_row->overlay_arrow_p != current_row->overlay_arrow_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4311 || desired_row->truncated_on_left_p != current_row->truncated_on_left_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4312 || desired_row->truncated_on_right_p != current_row->truncated_on_right_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4313 || desired_row->continued_p != current_row->continued_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4314 || desired_row->mode_line_p != current_row->mode_line_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4315 || (desired_row->indicate_empty_line_p |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4316 != current_row->indicate_empty_line_p) |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4317 || (MATRIX_ROW_CONTINUATION_LINE_P (desired_row) |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4318 != MATRIX_ROW_CONTINUATION_LINE_P (current_row))) |
6abff42174ea
(update_window): Move test for invisible lines
Gerd Moellmann <gerd@gnu.org>
parents:
31653
diff
changeset
|
4319 rif->after_update_window_line_hook (desired_row); |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4320 } |
25012 | 4321 |
4322 /* Update current_row from desired_row. */ | |
4323 make_current (w->desired_matrix, w->current_matrix, vpos); | |
4324 updated_row = NULL; | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4325 return changed_p; |
25012 | 4326 } |
4327 | |
4328 | |
4329 /* Set the cursor after an update of window W. This function may only | |
4330 be called from update_window. */ | |
4331 | |
4332 static void | |
4333 set_window_cursor_after_update (w) | |
4334 struct window *w; | |
4335 { | |
4336 struct frame *f = XFRAME (w->frame); | |
4337 int cx, cy, vpos, hpos; | |
4338 | |
4339 /* Not intended for frame matrix updates. */ | |
4340 xassert (FRAME_WINDOW_P (f)); | |
4341 | |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4342 if (cursor_in_echo_area |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4343 && !NILP (echo_area_buffer[0]) |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4344 /* If we are showing a message instead of the mini-buffer, |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4345 show the cursor for the message instead. */ |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4346 && XWINDOW (minibuf_window) == w |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4347 && EQ (minibuf_window, echo_area_window) |
25012 | 4348 /* These cases apply only to the frame that contains |
4349 the active mini-buffer window. */ | |
4350 && FRAME_HAS_MINIBUF_P (f) | |
4351 && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window)) | |
4352 { | |
4353 cx = cy = vpos = hpos = 0; | |
4354 | |
4355 if (cursor_in_echo_area >= 0) | |
4356 { | |
4357 /* If the mini-buffer is several lines high, find the last | |
4358 line that has any text on it. Note: either all lines | |
4359 are enabled or none. Otherwise we wouldn't be able to | |
4360 determine Y. */ | |
25190
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4361 struct glyph_row *row, *last_row; |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4362 struct glyph *glyph; |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4363 int yb = window_text_bottom_y (w); |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4364 |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4365 last_row = NULL; |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4366 for (row = MATRIX_ROW (w->current_matrix, 0); |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4367 row->enabled_p; |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4368 ++row) |
25012 | 4369 { |
25190
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4370 if (row->used[TEXT_AREA] |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4371 && row->glyphs[TEXT_AREA][0].charpos >= 0) |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4372 last_row = row; |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4373 |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4374 if (MATRIX_ROW_BOTTOM_Y (row) >= yb) |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4375 break; |
25012 | 4376 } |
25190
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4377 |
25012 | 4378 if (last_row) |
4379 { | |
25190
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4380 struct glyph *start = row->glyphs[TEXT_AREA]; |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4381 struct glyph *last = start + row->used[TEXT_AREA] - 1; |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4382 |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4383 while (last > start && last->charpos < 0) |
25190
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4384 --last; |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4385 |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4386 for (glyph = start; glyph < last; ++glyph) |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4387 { |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4388 cx += glyph->pixel_width; |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4389 ++hpos; |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4390 } |
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4391 |
25012 | 4392 cy = last_row->y; |
25190
a14edd4a5f4a
(set_window_cursor_after_update): Correct cursor
Gerd Moellmann <gerd@gnu.org>
parents:
25186
diff
changeset
|
4393 vpos = MATRIX_ROW_VPOS (last_row, w->current_matrix); |
25012 | 4394 } |
4395 } | |
4396 } | |
4397 else | |
4398 { | |
4399 cx = w->cursor.x; | |
4400 cy = w->cursor.y; | |
4401 hpos = w->cursor.hpos; | |
4402 vpos = w->cursor.vpos; | |
4403 } | |
4404 | |
4405 /* Window cursor can be out of sync for horizontally split windows. */ | |
4406 hpos = max (0, hpos); | |
4407 hpos = min (w->current_matrix->matrix_w - 1, hpos); | |
4408 vpos = max (0, vpos); | |
4409 vpos = min (w->current_matrix->nrows - 1, vpos); | |
4410 rif->cursor_to (vpos, hpos, cy, cx); | |
4411 } | |
4412 | |
4413 | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4414 /* Set WINDOW->must_be_updated_p to ON_P for all windows in the window |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4415 tree rooted at W. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4416 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4417 void |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4418 set_window_update_flags (w, on_p) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4419 struct window *w; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4420 int on_p; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4421 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4422 while (w) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4423 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4424 if (!NILP (w->hchild)) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4425 set_window_update_flags (XWINDOW (w->hchild), on_p); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4426 else if (!NILP (w->vchild)) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4427 set_window_update_flags (XWINDOW (w->vchild), on_p); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4428 else |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4429 w->must_be_updated_p = on_p; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4430 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4431 w = NILP (w->next) ? 0 : XWINDOW (w->next); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4432 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4433 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4434 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4435 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4436 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4437 /*********************************************************************** |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4438 Window-Based Scrolling |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4439 ***********************************************************************/ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4440 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4441 /* Structure describing rows in scrolling_window. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4442 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4443 struct row_entry |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4444 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4445 /* Number of occurrences of this row in desired and current matrix. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4446 int old_uses, new_uses; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4447 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4448 /* Vpos of row in new matrix. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4449 int new_line_number; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4450 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4451 /* Bucket index of this row_entry in the hash table row_table. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4452 int bucket; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4453 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4454 /* The row described by this entry. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4455 struct glyph_row *row; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4456 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4457 /* Hash collision chain. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4458 struct row_entry *next; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4459 }; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4460 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4461 /* A pool to allocate row_entry structures from, and the size of the |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4462 pool. The pool is reallocated in scrolling_window when we find |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4463 that we need a larger one. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4464 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4465 static struct row_entry *row_entry_pool; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4466 static int row_entry_pool_size; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4467 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4468 /* Index of next free entry in row_entry_pool. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4469 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4470 static int row_entry_idx; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4471 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4472 /* The hash table used during scrolling, and the table's size. This |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4473 table is used to quickly identify equal rows in the desired and |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4474 current matrix. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4475 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4476 static struct row_entry **row_table; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4477 static int row_table_size; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4478 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4479 /* Vectors of pointers to row_entry structures belonging to the |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4480 current and desired matrix, and the size of the vectors. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4481 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4482 static struct row_entry **old_lines, **new_lines; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4483 static int old_lines_size, new_lines_size; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4484 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4485 /* A pool to allocate run structures from, and its size. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4486 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4487 static struct run *run_pool; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4488 static int runs_size; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4489 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4490 /* A vector of runs of lines found during scrolling. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4491 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4492 static struct run **runs; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4493 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4494 static struct row_entry *add_row_entry P_ ((struct window *, |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4495 struct glyph_row *)); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4496 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4497 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4498 /* Add glyph row ROW to the scrolling hash table during the scrolling |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4499 of window W. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4500 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4501 static INLINE struct row_entry * |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4502 add_row_entry (w, row) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4503 struct window *w; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4504 struct glyph_row *row; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4505 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4506 struct row_entry *entry; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4507 int i = row->hash % row_table_size; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4508 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4509 entry = row_table[i]; |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
4510 while (entry && !row_equal_p (w, entry->row, row, 1)) |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4511 entry = entry->next; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4512 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4513 if (entry == NULL) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4514 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4515 entry = row_entry_pool + row_entry_idx++; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4516 entry->row = row; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4517 entry->old_uses = entry->new_uses = 0; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4518 entry->new_line_number = 0; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4519 entry->bucket = i; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4520 entry->next = row_table[i]; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4521 row_table[i] = entry; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4522 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4523 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4524 return entry; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4525 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4526 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4527 |
25012 | 4528 /* Try to reuse part of the current display of W by scrolling lines. |
25546 | 4529 HEADER_LINE_P non-zero means W has a top mode line. |
25012 | 4530 |
4531 The algorithm is taken from Communications of the ACM, Apr78 "A | |
4532 Technique for Isolating Differences Between Files." It should take | |
4533 O(N) time. | |
4534 | |
4535 A short outline of the steps of the algorithm | |
4536 | |
4537 1. Skip lines equal at the start and end of both matrices. | |
4538 | |
4539 2. Enter rows in the current and desired matrix into a symbol | |
4540 table, counting how often they appear in both matrices. | |
4541 | |
4542 3. Rows that appear exactly once in both matrices serve as anchors, | |
4543 i.e. we assume that such lines are likely to have been moved. | |
4544 | |
4545 4. Starting from anchor lines, extend regions to be scrolled both | |
4546 forward and backward. | |
4547 | |
4548 Value is | |
4549 | |
4550 -1 if all rows were found to be equal. | |
4551 0 to indicate that we did not scroll the display, or | |
4552 1 if we did scroll. */ | |
4553 | |
4554 static int | |
25546 | 4555 scrolling_window (w, header_line_p) |
25012 | 4556 struct window *w; |
25546 | 4557 int header_line_p; |
25012 | 4558 { |
4559 struct glyph_matrix *desired_matrix = w->desired_matrix; | |
4560 struct glyph_matrix *current_matrix = w->current_matrix; | |
4561 int yb = window_text_bottom_y (w); | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4562 int i, j, first_old, first_new, last_old, last_new; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4563 int nruns, nbytes, n, run_idx; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4564 struct row_entry *entry; |
25012 | 4565 |
4566 /* Skip over rows equal at the start. */ | |
31825
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4567 for (i = header_line_p ? 1 : 0; i < current_matrix->nrows - 1; ++i) |
25012 | 4568 { |
31825
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4569 struct glyph_row *d = MATRIX_ROW (desired_matrix, i); |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4570 struct glyph_row *c = MATRIX_ROW (current_matrix, i); |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4571 |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4572 if (c->enabled_p |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4573 && d->enabled_p |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4574 && c->y == d->y |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4575 && MATRIX_ROW_BOTTOM_Y (c) <= yb |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4576 && MATRIX_ROW_BOTTOM_Y (d) <= yb |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4577 && row_equal_p (w, c, d, 1)) |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4578 { |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4579 assign_row (c, d); |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4580 d->enabled_p = 0; |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4581 } |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4582 else |
62830644b967
(scrolling_window): Compare y-positions of rows
Gerd Moellmann <gerd@gnu.org>
parents:
31726
diff
changeset
|
4583 break; |
25012 | 4584 } |
4585 | |
4586 /* Give up if some rows in the desired matrix are not enabled. */ | |
4587 if (!MATRIX_ROW (desired_matrix, i)->enabled_p) | |
4588 return -1; | |
4589 | |
4590 first_old = first_new = i; | |
4591 | |
4592 /* Set last_new to the index + 1 of the last enabled row in the | |
4593 desired matrix. */ | |
4594 i = first_new + 1; | |
4595 while (i < desired_matrix->nrows - 1 | |
4596 && MATRIX_ROW (desired_matrix, i)->enabled_p | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4597 && MATRIX_ROW_BOTTOM_Y (MATRIX_ROW (desired_matrix, i)) <= yb) |
25012 | 4598 ++i; |
4599 | |
4600 if (!MATRIX_ROW (desired_matrix, i)->enabled_p) | |
4601 return 0; | |
4602 | |
4603 last_new = i; | |
4604 | |
4605 /* Set last_old to the index + 1 of the last enabled row in the | |
4606 current matrix. We don't look at the enabled flag here because | |
4607 we plan to reuse part of the display even if other parts are | |
4608 disabled. */ | |
4609 i = first_old + 1; | |
4610 while (i < current_matrix->nrows - 1 | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4611 && MATRIX_ROW_BOTTOM_Y (MATRIX_ROW (current_matrix, i)) <= yb) |
25012 | 4612 ++i; |
4613 last_old = i; | |
4614 | |
4615 /* Skip over rows equal at the bottom. */ | |
4616 i = last_new; | |
4617 j = last_old; | |
4618 while (i - 1 > first_new | |
4619 && j - 1 > first_old | |
4620 && MATRIX_ROW (current_matrix, i - 1)->enabled_p | |
4621 && (MATRIX_ROW (current_matrix, i - 1)->y | |
4622 == MATRIX_ROW (desired_matrix, j - 1)->y) | |
4623 && row_equal_p (w, | |
4624 MATRIX_ROW (desired_matrix, i - 1), | |
30152
f6270e5282da
(direct_output_forward_char): Give up if currently
Gerd Moellmann <gerd@gnu.org>
parents:
30041
diff
changeset
|
4625 MATRIX_ROW (current_matrix, j - 1), 1)) |
25012 | 4626 --i, --j; |
4627 last_new = i; | |
4628 last_old = j; | |
4629 | |
4630 /* Nothing to do if all rows are equal. */ | |
4631 if (last_new == first_new) | |
4632 return 0; | |
4633 | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4634 /* Reallocate vectors, tables etc. if necessary. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4635 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4636 if (current_matrix->nrows > old_lines_size) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4637 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4638 old_lines_size = current_matrix->nrows; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4639 nbytes = old_lines_size * sizeof *old_lines; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4640 old_lines = (struct row_entry **) xrealloc (old_lines, nbytes); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4641 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4642 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4643 if (desired_matrix->nrows > new_lines_size) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4644 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4645 new_lines_size = desired_matrix->nrows; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4646 nbytes = new_lines_size * sizeof *new_lines; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4647 new_lines = (struct row_entry **) xrealloc (new_lines, nbytes); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4648 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4649 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4650 n = desired_matrix->nrows + current_matrix->nrows; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4651 if (3 * n > row_table_size) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4652 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4653 row_table_size = next_almost_prime (3 * n); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4654 nbytes = row_table_size * sizeof *row_table; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4655 row_table = (struct row_entry **) xrealloc (row_table, nbytes); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4656 bzero (row_table, nbytes); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4657 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4658 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4659 if (n > row_entry_pool_size) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4660 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4661 row_entry_pool_size = n; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4662 nbytes = row_entry_pool_size * sizeof *row_entry_pool; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4663 row_entry_pool = (struct row_entry *) xrealloc (row_entry_pool, nbytes); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4664 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4665 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4666 if (desired_matrix->nrows > runs_size) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4667 { |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4668 runs_size = desired_matrix->nrows; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4669 nbytes = runs_size * sizeof *runs; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4670 runs = (struct run **) xrealloc (runs, nbytes); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4671 nbytes = runs_size * sizeof *run_pool; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4672 run_pool = (struct run *) xrealloc (run_pool, nbytes); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4673 } |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4674 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4675 nruns = run_idx = 0; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4676 row_entry_idx = 0; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4677 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4678 /* Add rows from the current and desired matrix to the hash table |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4679 row_hash_table to be able to find equal ones quickly. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4680 |
25012 | 4681 for (i = first_old; i < last_old; ++i) |
4682 { | |
4683 if (MATRIX_ROW (current_matrix, i)->enabled_p) | |
4684 { | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4685 entry = add_row_entry (w, MATRIX_ROW (current_matrix, i)); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4686 old_lines[i] = entry; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4687 ++entry->old_uses; |
25012 | 4688 } |
4689 else | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4690 old_lines[i] = NULL; |
25012 | 4691 } |
4692 | |
4693 for (i = first_new; i < last_new; ++i) | |
4694 { | |
4695 xassert (MATRIX_ROW_ENABLED_P (desired_matrix, i)); | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4696 entry = add_row_entry (w, MATRIX_ROW (desired_matrix, i)); |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4697 ++entry->new_uses; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4698 entry->new_line_number = i; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4699 new_lines[i] = entry; |
25012 | 4700 } |
4701 | |
4702 /* Identify moves based on lines that are unique and equal | |
4703 in both matrices. */ | |
4704 for (i = first_old; i < last_old;) | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4705 if (old_lines[i] |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4706 && old_lines[i]->old_uses == 1 |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4707 && old_lines[i]->new_uses == 1) |
25012 | 4708 { |
4709 int j, k; | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4710 int new_line = old_lines[i]->new_line_number; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4711 struct run *run = run_pool + run_idx++; |
25012 | 4712 |
4713 /* Record move. */ | |
4714 run->current_vpos = i; | |
4715 run->current_y = MATRIX_ROW (current_matrix, i)->y; | |
4716 run->desired_vpos = new_line; | |
4717 run->desired_y = MATRIX_ROW (desired_matrix, new_line)->y; | |
4718 run->nrows = 1; | |
4719 run->height = MATRIX_ROW (current_matrix, i)->height; | |
4720 | |
4721 /* Extend backward. */ | |
4722 j = i - 1; | |
4723 k = new_line - 1; | |
4724 while (j > first_old | |
4725 && k > first_new | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4726 && old_lines[j] == new_lines[k]) |
25012 | 4727 { |
4728 int h = MATRIX_ROW (current_matrix, j)->height; | |
4729 --run->current_vpos; | |
4730 --run->desired_vpos; | |
4731 ++run->nrows; | |
4732 run->height += h; | |
4733 run->desired_y -= h; | |
4734 run->current_y -= h; | |
4735 --j, --k; | |
4736 } | |
4737 | |
4738 /* Extend forward. */ | |
4739 j = i + 1; | |
4740 k = new_line + 1; | |
4741 while (j < last_old | |
4742 && k < last_new | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4743 && old_lines[j] == new_lines[k]) |
25012 | 4744 { |
4745 int h = MATRIX_ROW (current_matrix, j)->height; | |
4746 ++run->nrows; | |
4747 run->height += h; | |
4748 ++j, ++k; | |
4749 } | |
4750 | |
4751 /* Insert run into list of all runs. Order runs by copied | |
4752 pixel lines. Note that we record runs that don't have to | |
4753 be copied because they are already in place. This is done | |
4754 because we can avoid calling update_window_line in this | |
4755 case. */ | |
4756 for (j = 0; j < nruns && runs[j]->height > run->height; ++j) | |
4757 ; | |
34203
e55480843a8e
(scrolling_window): Fix code inserting runs in list of all runs.
Gerd Moellmann <gerd@gnu.org>
parents:
33763
diff
changeset
|
4758 for (k = nruns; k > j; --k) |
25012 | 4759 runs[k] = runs[k - 1]; |
4760 runs[j] = run; | |
4761 ++nruns; | |
4762 | |
4763 i += run->nrows; | |
4764 } | |
4765 else | |
4766 ++i; | |
4767 | |
4768 /* Do the moves. Do it in a way that we don't overwrite something | |
4769 we want to copy later on. This is not solvable in general | |
4770 because there is only one display and we don't have a way to | |
4771 exchange areas on this display. Example: | |
4772 | |
4773 +-----------+ +-----------+ | |
4774 | A | | B | | |
4775 +-----------+ --> +-----------+ | |
4776 | B | | A | | |
4777 +-----------+ +-----------+ | |
4778 | |
4779 Instead, prefer bigger moves, and invalidate moves that would | |
4780 copy from where we copied to. */ | |
4781 | |
4782 for (i = 0; i < nruns; ++i) | |
4783 if (runs[i]->nrows > 0) | |
4784 { | |
4785 struct run *r = runs[i]; | |
4786 | |
4787 /* Copy on the display. */ | |
4788 if (r->current_y != r->desired_y) | |
4789 { | |
4790 rif->scroll_run_hook (w, r); | |
4791 | |
4792 /* Invalidate runs that copy from where we copied to. */ | |
4793 for (j = i + 1; j < nruns; ++j) | |
4794 { | |
4795 struct run *p = runs[j]; | |
4796 | |
4797 if ((p->current_y >= r->desired_y | |
4798 && p->current_y < r->desired_y + r->height) | |
4799 || (p->current_y + p->height >= r->desired_y | |
4800 && (p->current_y + p->height | |
4801 < r->desired_y + r->height))) | |
4802 p->nrows = 0; | |
4803 } | |
4804 } | |
4805 | |
4806 /* Assign matrix rows. */ | |
4807 for (j = 0; j < r->nrows; ++j) | |
4808 { | |
4809 struct glyph_row *from, *to; | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4810 int to_overlapped_p; |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4811 |
25012 | 4812 to = MATRIX_ROW (current_matrix, r->desired_vpos + j); |
30161
8be2bf27e9ad
(make_current): Preserve the mouse_face_p flag of the
Gerd Moellmann <gerd@gnu.org>
parents:
30152
diff
changeset
|
4813 from = MATRIX_ROW (desired_matrix, r->desired_vpos + j); |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4814 to_overlapped_p = to->overlapped_p; |
25012 | 4815 assign_row (to, from); |
4816 to->enabled_p = 1, from->enabled_p = 0; | |
25186
d6c941334567
(redraw_overlapping_rows): Use flag overlapping_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25118
diff
changeset
|
4817 to->overlapped_p = to_overlapped_p; |
25012 | 4818 } |
4819 } | |
4820 | |
29980
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4821 /* Clear the hash table, for the next time. */ |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4822 for (i = 0; i < row_entry_idx; ++i) |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4823 row_table[row_entry_pool[i].bucket] = NULL; |
171ba59e1cb0
(struct row_entry): New structure.
Gerd Moellmann <gerd@gnu.org>
parents:
29687
diff
changeset
|
4824 |
25012 | 4825 /* Value is non-zero to indicate that we scrolled the display. */ |
4826 return 1; | |
4827 } | |
4828 | |
4829 | |
4830 | |
4831 /************************************************************************ | |
4832 Frame-Based Updates | |
4833 ************************************************************************/ | |
4834 | |
4835 /* Update the desired frame matrix of frame F. | |
4836 | |
4837 FORCE_P non-zero means that the update should not be stopped by | |
4838 pending input. INHIBIT_HAIRY_ID_P non-zero means that scrolling | |
4839 should not be tried. | |
4840 | |
4841 Value is non-zero if update was stopped due to pending input. */ | |
4842 | |
4843 static int | |
4844 update_frame_1 (f, force_p, inhibit_id_p) | |
4845 struct frame *f; | |
4846 int force_p; | |
4847 int inhibit_id_p; | |
4848 { | |
4849 /* Frame matrices to work on. */ | |
4850 struct glyph_matrix *current_matrix = f->current_matrix; | |
4851 struct glyph_matrix *desired_matrix = f->desired_matrix; | |
4852 int i; | |
314 | 4853 int pause; |
4854 int preempt_count = baud_rate / 2400 + 1; | |
21514 | 4855 extern int input_pending; |
25012 | 4856 |
4857 xassert (current_matrix && desired_matrix); | |
314 | 4858 |
10122
3de6776ae141
(update_frame): Call calculate_costs if baud_rate changed.
Richard M. Stallman <rms@gnu.org>
parents:
9963
diff
changeset
|
4859 if (baud_rate != FRAME_COST_BAUD_RATE (f)) |
3de6776ae141
(update_frame): Call calculate_costs if baud_rate changed.
Richard M. Stallman <rms@gnu.org>
parents:
9963
diff
changeset
|
4860 calculate_costs (f); |
3de6776ae141
(update_frame): Call calculate_costs if baud_rate changed.
Richard M. Stallman <rms@gnu.org>
parents:
9963
diff
changeset
|
4861 |
3357
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
4862 if (preempt_count <= 0) |
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
4863 preempt_count = 1; |
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
4864 |
30720
64f3338f72d8
(Qredisplay_dont_pause): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
30713
diff
changeset
|
4865 if (redisplay_dont_pause) |
64f3338f72d8
(Qredisplay_dont_pause): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
30713
diff
changeset
|
4866 force_p = 1; |
64f3338f72d8
(Qredisplay_dont_pause): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
30713
diff
changeset
|
4867 else if (!force_p && detect_input_pending ()) |
314 | 4868 { |
4869 pause = 1; | |
4870 goto do_pause; | |
4871 } | |
4872 | |
25012 | 4873 /* If we cannot insert/delete lines, it's no use trying it. */ |
314 | 4874 if (!line_ins_del_ok) |
25012 | 4875 inhibit_id_p = 1; |
7188
7da4ad9a2a8f
(update_frame): Move those assignments even farther down.
Richard M. Stallman <rms@gnu.org>
parents:
7179
diff
changeset
|
4876 |
493 | 4877 /* See if any of the desired lines are enabled; don't compute for |
25012 | 4878 i/d line if just want cursor motion. */ |
4879 for (i = 0; i < desired_matrix->nrows; i++) | |
4880 if (MATRIX_ROW_ENABLED_P (desired_matrix, i)) | |
314 | 4881 break; |
4882 | |
4883 /* Try doing i/d line, if not yet inhibited. */ | |
25012 | 4884 if (!inhibit_id_p && i < desired_matrix->nrows) |
4885 force_p |= scrolling (f); | |
314 | 4886 |
4887 /* Update the individual lines as needed. Do bottom line first. */ | |
25012 | 4888 if (MATRIX_ROW_ENABLED_P (desired_matrix, desired_matrix->nrows - 1)) |
4889 update_frame_line (f, desired_matrix->nrows - 1); | |
4890 | |
4891 /* Now update the rest of the lines. */ | |
4892 for (i = 0; i < desired_matrix->nrows - 1 && (force_p || !input_pending); i++) | |
314 | 4893 { |
25012 | 4894 if (MATRIX_ROW_ENABLED_P (desired_matrix, i)) |
314 | 4895 { |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
4896 if (FRAME_TERMCAP_P (f)) |
314 | 4897 { |
4898 /* Flush out every so many lines. | |
4899 Also flush out if likely to have more than 1k buffered | |
4900 otherwise. I'm told that some telnet connections get | |
4901 really screwed by more than 1k output at once. */ | |
4902 int outq = PENDING_OUTPUT_COUNT (stdout); | |
4903 if (outq > 900 | |
4904 || (outq > 20 && ((i - 1) % preempt_count == 0))) | |
4905 { | |
4906 fflush (stdout); | |
4907 if (preempt_count == 1) | |
4908 { | |
554 | 4909 #ifdef EMACS_OUTQSIZE |
4910 if (EMACS_OUTQSIZE (0, &outq) < 0) | |
314 | 4911 /* Probably not a tty. Ignore the error and reset |
25012 | 4912 * the outq count. */ |
314 | 4913 outq = PENDING_OUTPUT_COUNT (stdout); |
4914 #endif | |
4915 outq *= 10; | |
7530
57c2345a9002
(update_frame): Fix test of outq and baud_rate some more.
Richard M. Stallman <rms@gnu.org>
parents:
7529
diff
changeset
|
4916 if (baud_rate <= outq && baud_rate > 0) |
3357
d9523a958b3c
(update_frame): Make preempt_count positive.
Richard M. Stallman <rms@gnu.org>
parents:
3317
diff
changeset
|
4917 sleep (outq / baud_rate); |
314 | 4918 } |
4919 } | |
4920 } | |
4921 | |
16822
483e137d5384
(update_frame): Call detect_input_pending
Richard M. Stallman <rms@gnu.org>
parents:
16589
diff
changeset
|
4922 if ((i - 1) % preempt_count == 0) |
483e137d5384
(update_frame): Call detect_input_pending
Richard M. Stallman <rms@gnu.org>
parents:
16589
diff
changeset
|
4923 detect_input_pending (); |
483e137d5384
(update_frame): Call detect_input_pending
Richard M. Stallman <rms@gnu.org>
parents:
16589
diff
changeset
|
4924 |
25012 | 4925 update_frame_line (f, i); |
314 | 4926 } |
4927 } | |
25012 | 4928 |
764 | 4929 pause = (i < FRAME_HEIGHT (f) - 1) ? i : 0; |
314 | 4930 |
4931 /* Now just clean up termcap drivers and set cursor, etc. */ | |
4932 if (!pause) | |
4933 { | |
12409
6e374b28ecc3
(update_frame): Pretend cursor is in echo area
Richard M. Stallman <rms@gnu.org>
parents:
12193
diff
changeset
|
4934 if ((cursor_in_echo_area |
25012 | 4935 /* If we are showing a message instead of the mini-buffer, |
12627
c7bc7a24b1ff
(update_frame): Check that the echo area is in the frame being displayed.
Richard M. Stallman <rms@gnu.org>
parents:
12532
diff
changeset
|
4936 show the cursor for the message instead of for the |
25012 | 4937 (now hidden) mini-buffer contents. */ |
12627
c7bc7a24b1ff
(update_frame): Check that the echo area is in the frame being displayed.
Richard M. Stallman <rms@gnu.org>
parents:
12532
diff
changeset
|
4938 || (EQ (minibuf_window, selected_window) |
c7bc7a24b1ff
(update_frame): Check that the echo area is in the frame being displayed.
Richard M. Stallman <rms@gnu.org>
parents:
12532
diff
changeset
|
4939 && EQ (minibuf_window, echo_area_window) |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
4940 && !NILP (echo_area_buffer[0]))) |
12627
c7bc7a24b1ff
(update_frame): Check that the echo area is in the frame being displayed.
Richard M. Stallman <rms@gnu.org>
parents:
12532
diff
changeset
|
4941 /* These cases apply only to the frame that contains |
25012 | 4942 the active mini-buffer window. */ |
12627
c7bc7a24b1ff
(update_frame): Check that the echo area is in the frame being displayed.
Richard M. Stallman <rms@gnu.org>
parents:
12532
diff
changeset
|
4943 && FRAME_HAS_MINIBUF_P (f) |
14459
c1d25453a95f
(update_frame): Compare FRAME_MINIBUF_WINDOW(f)
Richard M. Stallman <rms@gnu.org>
parents:
14286
diff
changeset
|
4944 && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window)) |
708 | 4945 { |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4946 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
|
4947 int row, col; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4948 |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4949 if (cursor_in_echo_area < 0) |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4950 { |
25012 | 4951 /* Negative value of cursor_in_echo_area means put |
4952 cursor at beginning of line. */ | |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4953 row = top; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4954 col = 0; |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4955 } |
708 | 4956 else |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4957 { |
25012 | 4958 /* Positive value of cursor_in_echo_area means put |
4959 cursor at the end of the prompt. If the mini-buffer | |
4960 is several lines high, find the last line that has | |
4961 any text on it. */ | |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4962 row = FRAME_HEIGHT (f); |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4963 do |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4964 { |
25012 | 4965 --row; |
4966 col = 0; | |
4967 | |
4968 if (MATRIX_ROW_ENABLED_P (current_matrix, row)) | |
4969 { | |
4970 /* Frame rows are filled up with spaces that | |
4971 must be ignored here. */ | |
4972 struct glyph_row *r = MATRIX_ROW (current_matrix, | |
4973 row); | |
4974 struct glyph *start = r->glyphs[TEXT_AREA]; | |
4975 struct glyph *last = start + r->used[TEXT_AREA]; | |
4976 | |
4977 while (last > start | |
4978 && (last - 1)->charpos < 0) | |
4979 --last; | |
4980 | |
4981 col = last - start; | |
4982 } | |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4983 } |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4984 while (row > top && col == 0); |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4985 |
21757
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4986 /* Make sure COL is not out of range. */ |
21763
b685f9451792
(change_frame_size_1): Use FRAME_CURSOR_X_LIMIT.
Richard M. Stallman <rms@gnu.org>
parents:
21757
diff
changeset
|
4987 if (col >= FRAME_CURSOR_X_LIMIT (f)) |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4988 { |
21757
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4989 /* If we have another row, advance cursor into it. */ |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4990 if (row < FRAME_HEIGHT (f) - 1) |
21757
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4991 { |
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4992 col = FRAME_LEFT_SCROLL_BAR_WIDTH (f); |
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4993 row++; |
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4994 } |
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4995 /* Otherwise move it back in range. */ |
629f6df4a329
(update_frame): Move echo area cursor into range.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4996 else |
21763
b685f9451792
(change_frame_size_1): Use FRAME_CURSOR_X_LIMIT.
Richard M. Stallman <rms@gnu.org>
parents:
21757
diff
changeset
|
4997 col = FRAME_CURSOR_X_LIMIT (f) - 1; |
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4998 } |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
4999 } |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
5000 |
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
5001 cursor_to (row, col); |
708 | 5002 } |
314 | 5003 else |
25012 | 5004 { |
5005 /* We have only one cursor on terminal frames. Use it to | |
5006 display the cursor of the selected window. */ | |
5007 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
29687
5d67ef29764b
(update_frame_1): Handle case that cursor vpos is
Gerd Moellmann <gerd@gnu.org>
parents:
29437
diff
changeset
|
5008 if (w->cursor.vpos >= 0 |
5d67ef29764b
(update_frame_1): Handle case that cursor vpos is
Gerd Moellmann <gerd@gnu.org>
parents:
29437
diff
changeset
|
5009 /* The cursor vpos may be temporarily out of bounds |
5d67ef29764b
(update_frame_1): Handle case that cursor vpos is
Gerd Moellmann <gerd@gnu.org>
parents:
29437
diff
changeset
|
5010 in the following situation: There is one window, |
5d67ef29764b
(update_frame_1): Handle case that cursor vpos is
Gerd Moellmann <gerd@gnu.org>
parents:
29437
diff
changeset
|
5011 with the cursor in the lower half of it. The window |
5d67ef29764b
(update_frame_1): Handle case that cursor vpos is
Gerd Moellmann <gerd@gnu.org>
parents:
29437
diff
changeset
|
5012 is split, and a message causes a redisplay before |
5d67ef29764b
(update_frame_1): Handle case that cursor vpos is
Gerd Moellmann <gerd@gnu.org>
parents:
29437
diff
changeset
|
5013 a new cursor position has been computed. */ |
5d67ef29764b
(update_frame_1): Handle case that cursor vpos is
Gerd Moellmann <gerd@gnu.org>
parents:
29437
diff
changeset
|
5014 && w->cursor.vpos < XFASTINT (w->height)) |
25012 | 5015 { |
5016 int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos); | |
5017 int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); | |
5018 | |
5019 if (INTEGERP (w->left_margin_width)) | |
5020 x += XFASTINT (w->left_margin_width); | |
5021 | |
5022 /* x = max (min (x, FRAME_WINDOW_WIDTH (f) - 1), 0); */ | |
5023 cursor_to (y, x); | |
5024 } | |
5025 } | |
314 | 5026 } |
5027 | |
5028 do_pause: | |
5029 | |
25012 | 5030 clear_desired_matrices (f); |
314 | 5031 return pause; |
5032 } | |
5033 | |
25012 | 5034 |
5035 /* Do line insertions/deletions on frame F for frame-based redisplay. */ | |
314 | 5036 |
21514 | 5037 int |
764 | 5038 scrolling (frame) |
25012 | 5039 struct frame *frame; |
314 | 5040 { |
5041 int unchanged_at_top, unchanged_at_bottom; | |
5042 int window_size; | |
5043 int changed_lines; | |
764 | 5044 int *old_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); |
5045 int *new_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); | |
5046 int *draw_cost = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); | |
10259
48e4dfc6bb43
(scrolling): Fewer restrictions if scroll_region_ok is
Richard M. Stallman <rms@gnu.org>
parents:
10122
diff
changeset
|
5047 int *old_draw_cost = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); |
314 | 5048 register int i; |
764 | 5049 int free_at_end_vpos = FRAME_HEIGHT (frame); |
25012 | 5050 struct glyph_matrix *current_matrix = frame->current_matrix; |
5051 struct glyph_matrix *desired_matrix = frame->desired_matrix; | |
5052 | |
5053 if (!current_matrix) | |
5054 abort (); | |
5055 | |
5056 /* Compute hash codes of all the lines. Also calculate number of | |
5057 changed lines, number of unchanged lines at the beginning, and | |
5058 number of unchanged lines at the end. */ | |
314 | 5059 changed_lines = 0; |
5060 unchanged_at_top = 0; | |
764 | 5061 unchanged_at_bottom = FRAME_HEIGHT (frame); |
5062 for (i = 0; i < FRAME_HEIGHT (frame); i++) | |
314 | 5063 { |
5064 /* Give up on this scrolling if some old lines are not enabled. */ | |
25012 | 5065 if (!MATRIX_ROW_ENABLED_P (current_matrix, i)) |
314 | 5066 return 0; |
25012 | 5067 old_hash[i] = line_hash_code (MATRIX_ROW (current_matrix, i)); |
5068 if (! MATRIX_ROW_ENABLED_P (desired_matrix, i)) | |
18015
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5069 { |
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5070 /* This line cannot be redrawn, so don't let scrolling mess it. */ |
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5071 new_hash[i] = old_hash[i]; |
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5072 #define INFINITY 1000000 /* Taken from scroll.c */ |
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5073 draw_cost[i] = INFINITY; |
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5074 } |
314 | 5075 else |
18015
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5076 { |
25012 | 5077 new_hash[i] = line_hash_code (MATRIX_ROW (desired_matrix, i)); |
5078 draw_cost[i] = line_draw_cost (desired_matrix, i); | |
18015
934a44a3b34f
(scrolling): If a line is not enabled,
Richard M. Stallman <rms@gnu.org>
parents:
17961
diff
changeset
|
5079 } |
314 | 5080 |
5081 if (old_hash[i] != new_hash[i]) | |
5082 { | |
5083 changed_lines++; | |
764 | 5084 unchanged_at_bottom = FRAME_HEIGHT (frame) - i - 1; |
314 | 5085 } |
5086 else if (i == unchanged_at_top) | |
5087 unchanged_at_top++; | |
25012 | 5088 old_draw_cost[i] = line_draw_cost (current_matrix, i); |
314 | 5089 } |
5090 | |
5091 /* If changed lines are few, don't allow preemption, don't scroll. */ | |
25012 | 5092 if ((!scroll_region_ok && changed_lines < baud_rate / 2400) |
764 | 5093 || unchanged_at_bottom == FRAME_HEIGHT (frame)) |
314 | 5094 return 1; |
5095 | |
764 | 5096 window_size = (FRAME_HEIGHT (frame) - unchanged_at_top |
314 | 5097 - unchanged_at_bottom); |
5098 | |
5099 if (scroll_region_ok) | |
5100 free_at_end_vpos -= unchanged_at_bottom; | |
764 | 5101 else if (memory_below_frame) |
314 | 5102 free_at_end_vpos = -1; |
5103 | |
5104 /* If large window, fast terminal and few lines in common between | |
25012 | 5105 current frame and desired frame, don't bother with i/d calc. */ |
10259
48e4dfc6bb43
(scrolling): Fewer restrictions if scroll_region_ok is
Richard M. Stallman <rms@gnu.org>
parents:
10122
diff
changeset
|
5106 if (!scroll_region_ok && window_size >= 18 && baud_rate > 2400 |
314 | 5107 && (window_size >= |
5108 10 * scrolling_max_lines_saved (unchanged_at_top, | |
764 | 5109 FRAME_HEIGHT (frame) - unchanged_at_bottom, |
314 | 5110 old_hash, new_hash, draw_cost))) |
5111 return 0; | |
5112 | |
25012 | 5113 if (window_size < 2) |
5114 return 0; | |
5115 | |
764 | 5116 scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, |
314 | 5117 draw_cost + unchanged_at_top - 1, |
10259
48e4dfc6bb43
(scrolling): Fewer restrictions if scroll_region_ok is
Richard M. Stallman <rms@gnu.org>
parents:
10122
diff
changeset
|
5118 old_draw_cost + unchanged_at_top - 1, |
314 | 5119 old_hash + unchanged_at_top - 1, |
5120 new_hash + unchanged_at_top - 1, | |
5121 free_at_end_vpos - unchanged_at_top); | |
5122 | |
5123 return 0; | |
5124 } | |
25012 | 5125 |
5126 | |
5127 /* Count the number of blanks at the start of the vector of glyphs R | |
5128 which is LEN glyphs long. */ | |
5129 | |
5130 static int | |
5131 count_blanks (r, len) | |
5132 struct glyph *r; | |
5133 int len; | |
314 | 5134 { |
25012 | 5135 int i; |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5136 |
25012 | 5137 for (i = 0; i < len; ++i) |
5138 if (!CHAR_GLYPH_SPACE_P (r[i])) | |
5139 break; | |
5140 | |
5141 return i; | |
314 | 5142 } |
25012 | 5143 |
5144 | |
5145 /* Count the number of glyphs in common at the start of the glyph | |
5146 vectors STR1 and STR2. END1 is the end of STR1 and END2 is the end | |
5147 of STR2. Value is the number of equal glyphs equal at the start. */ | |
314 | 5148 |
5149 static int | |
25012 | 5150 count_match (str1, end1, str2, end2) |
5151 struct glyph *str1, *end1, *str2, *end2; | |
314 | 5152 { |
25012 | 5153 struct glyph *p1 = str1; |
5154 struct glyph *p2 = str2; | |
5155 | |
5156 while (p1 < end1 | |
5157 && p2 < end2 | |
26998
02e902f732d1
(line_hash_code) (direct_output_for_insert): Adjusted
Kenichi Handa <handa@m17n.org>
parents:
26902
diff
changeset
|
5158 && GLYPH_CHAR_AND_FACE_EQUAL_P (p1, p2)) |
25012 | 5159 ++p1, ++p2; |
5160 | |
5161 return p1 - str1; | |
314 | 5162 } |
5163 | |
25012 | 5164 |
314 | 5165 /* Char insertion/deletion cost vector, from term.c */ |
25012 | 5166 |
314 | 5167 extern int *char_ins_del_vector; |
16267
05ca2cb9fe0f
(make_frame_glyphs, update_line, update_frame)
Richard M. Stallman <rms@gnu.org>
parents:
16256
diff
changeset
|
5168 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WINDOW_WIDTH((f))]) |
314 | 5169 |
25012 | 5170 |
5171 /* Perform a frame-based update on line VPOS in frame FRAME. */ | |
5172 | |
314 | 5173 static void |
25012 | 5174 update_frame_line (frame, vpos) |
5175 register struct frame *frame; | |
314 | 5176 int vpos; |
5177 { | |
25012 | 5178 struct glyph *obody, *nbody, *op1, *op2, *np1, *nend; |
314 | 5179 int tem; |
5180 int osp, nsp, begmatch, endmatch, olen, nlen; | |
25012 | 5181 struct glyph_matrix *current_matrix = frame->current_matrix; |
5182 struct glyph_matrix *desired_matrix = frame->desired_matrix; | |
5183 struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos); | |
5184 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos); | |
5185 int must_write_whole_line_p; | |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5186 int write_spaces_p = must_write_spaces; |
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5187 int colored_spaces_p = (FACE_FROM_ID (frame, DEFAULT_FACE_ID)->background |
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5188 != FACE_TTY_DEFAULT_BG_COLOR); |
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5189 |
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5190 if (colored_spaces_p) |
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5191 write_spaces_p = 1; |
25012 | 5192 |
5193 if (desired_row->inverse_p | |
5194 != (current_row->enabled_p && current_row->inverse_p)) | |
314 | 5195 { |
25012 | 5196 int n = current_row->enabled_p ? current_row->used[TEXT_AREA] : 0; |
5197 change_line_highlight (desired_row->inverse_p, vpos, vpos, n); | |
5198 current_row->enabled_p = 0; | |
314 | 5199 } |
5200 else | |
25012 | 5201 reassert_line_highlight (desired_row->inverse_p, vpos); |
5202 | |
25725
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5203 /* Current row not enabled means it has unknown contents. We must |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5204 write the whole desired line in that case. */ |
25012 | 5205 must_write_whole_line_p = !current_row->enabled_p; |
5206 if (must_write_whole_line_p) | |
314 | 5207 { |
25012 | 5208 obody = 0; |
314 | 5209 olen = 0; |
5210 } | |
5211 else | |
5212 { | |
25012 | 5213 obody = MATRIX_ROW_GLYPH_START (current_matrix, vpos); |
5214 olen = current_row->used[TEXT_AREA]; | |
5215 | |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5216 if (!current_row->inverse_p) |
314 | 5217 { |
25725
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5218 /* Ignore trailing spaces, if we can. */ |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5219 if (!write_spaces_p) |
25012 | 5220 while (olen > 0 && CHAR_GLYPH_SPACE_P (obody[olen-1])) |
314 | 5221 olen--; |
5222 } | |
5223 else | |
5224 { | |
25725
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5225 /* For an inverse-video line, make sure it's filled with |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5226 spaces all the way to the frame edge so that the reverse |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5227 video extends all the way across. */ |
25012 | 5228 while (olen < FRAME_WIDTH (frame) - 1) |
5229 obody[olen++] = space_glyph; | |
314 | 5230 } |
5231 } | |
5232 | |
25012 | 5233 current_row->enabled_p = 1; |
5234 current_row->used[TEXT_AREA] = desired_row->used[TEXT_AREA]; | |
5235 current_row->inverse_p = desired_row->inverse_p; | |
5236 | |
5237 /* If desired line is empty, just clear the line. */ | |
5238 if (!desired_row->enabled_p) | |
314 | 5239 { |
5240 nlen = 0; | |
5241 goto just_erase; | |
5242 } | |
5243 | |
25012 | 5244 nbody = desired_row->glyphs[TEXT_AREA]; |
5245 nlen = desired_row->used[TEXT_AREA]; | |
5246 nend = nbody + nlen; | |
5247 | |
5248 /* If display line has unknown contents, write the whole line. */ | |
5249 if (must_write_whole_line_p) | |
5250 { | |
25725
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5251 /* Ignore spaces at the end, if we can. */ |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5252 if (!write_spaces_p) |
25313
6b4475fbef86
(update_frame_line): If writing whole line,
Gerd Moellmann <gerd@gnu.org>
parents:
25304
diff
changeset
|
5253 while (nlen > 0 && CHAR_GLYPH_SPACE_P (nbody[nlen - 1])) |
6b4475fbef86
(update_frame_line): If writing whole line,
Gerd Moellmann <gerd@gnu.org>
parents:
25304
diff
changeset
|
5254 --nlen; |
6b4475fbef86
(update_frame_line): If writing whole line,
Gerd Moellmann <gerd@gnu.org>
parents:
25304
diff
changeset
|
5255 |
25725
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5256 /* Write the contents of the desired line. */ |
25313
6b4475fbef86
(update_frame_line): If writing whole line,
Gerd Moellmann <gerd@gnu.org>
parents:
25304
diff
changeset
|
5257 if (nlen) |
25725
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5258 { |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5259 cursor_to (vpos, 0); |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5260 write_glyphs (nbody, nlen); |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5261 } |
25313
6b4475fbef86
(update_frame_line): If writing whole line,
Gerd Moellmann <gerd@gnu.org>
parents:
25304
diff
changeset
|
5262 |
25725
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5263 /* Don't call clear_end_of_line if we already wrote the whole |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5264 line. The cursor will not be at the right margin in that |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5265 case but in the line below. */ |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5266 if (nlen < FRAME_WINDOW_WIDTH (frame)) |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5267 { |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5268 cursor_to (vpos, nlen); |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5269 clear_end_of_line (FRAME_WINDOW_WIDTH (frame)); |
b7468dc89ccb
(update_frame_line): If writing whole desired line,
Gerd Moellmann <gerd@gnu.org>
parents:
25666
diff
changeset
|
5270 } |
28682
f05d48759416
(update_frame_line): When writing a whole line, make
Gerd Moellmann <gerd@gnu.org>
parents:
28507
diff
changeset
|
5271 else |
f05d48759416
(update_frame_line): When writing a whole line, make
Gerd Moellmann <gerd@gnu.org>
parents:
28507
diff
changeset
|
5272 /* Make sure we are in the right row, otherwise cursor movement |
f05d48759416
(update_frame_line): When writing a whole line, make
Gerd Moellmann <gerd@gnu.org>
parents:
28507
diff
changeset
|
5273 with cmgoto might use `ch' in the wrong row. */ |
f05d48759416
(update_frame_line): When writing a whole line, make
Gerd Moellmann <gerd@gnu.org>
parents:
28507
diff
changeset
|
5274 cursor_to (vpos, 0); |
f05d48759416
(update_frame_line): When writing a whole line, make
Gerd Moellmann <gerd@gnu.org>
parents:
28507
diff
changeset
|
5275 |
25012 | 5276 make_current (desired_matrix, current_matrix, vpos); |
5277 return; | |
5278 } | |
314 | 5279 |
5280 /* Pretend trailing spaces are not there at all, | |
5281 unless for one reason or another we must write all spaces. */ | |
25012 | 5282 if (!desired_row->inverse_p) |
314 | 5283 { |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5284 if (!write_spaces_p) |
25012 | 5285 while (nlen > 0 && CHAR_GLYPH_SPACE_P (nbody[nlen - 1])) |
314 | 5286 nlen--; |
5287 } | |
5288 else | |
5289 { | |
25012 | 5290 /* For an inverse-video line, give it extra trailing spaces all |
5291 the way to the frame edge so that the reverse video extends | |
5292 all the way across. */ | |
5293 while (nlen < FRAME_WIDTH (frame) - 1) | |
5294 nbody[nlen++] = space_glyph; | |
314 | 5295 } |
5296 | |
5297 /* If there's no i/d char, quickly do the best we can without it. */ | |
5298 if (!char_ins_del_ok) | |
5299 { | |
25012 | 5300 int i, j; |
5301 | |
5302 /* Find the first glyph in desired row that doesn't agree with | |
5303 a glyph in the current row, and write the rest from there on. */ | |
314 | 5304 for (i = 0; i < nlen; i++) |
5305 { | |
25012 | 5306 if (i >= olen || !GLYPH_EQUAL_P (nbody + i, obody + i)) |
314 | 5307 { |
25012 | 5308 /* Find the end of the run of different glyphs. */ |
5309 j = i + 1; | |
5310 while (j < nlen | |
5311 && (j >= olen | |
5312 || !GLYPH_EQUAL_P (nbody + j, obody + j) | |
5313 || CHAR_GLYPH_PADDING_P (nbody[j]))) | |
5314 ++j; | |
5315 | |
5316 /* Output this run of non-matching chars. */ | |
314 | 5317 cursor_to (vpos, i); |
25012 | 5318 write_glyphs (nbody + i, j - i); |
5319 i = j - 1; | |
314 | 5320 |
5321 /* Now find the next non-match. */ | |
5322 } | |
5323 } | |
5324 | |
5325 /* Clear the rest of the line, or the non-clear part of it. */ | |
5326 if (olen > nlen) | |
5327 { | |
5328 cursor_to (vpos, nlen); | |
5329 clear_end_of_line (olen); | |
5330 } | |
5331 | |
25012 | 5332 /* Make current row = desired row. */ |
5333 make_current (desired_matrix, current_matrix, vpos); | |
314 | 5334 return; |
5335 } | |
5336 | |
25012 | 5337 /* Here when CHAR_INS_DEL_OK != 0, i.e. we can insert or delete |
5338 characters in a row. */ | |
5339 | |
314 | 5340 if (!olen) |
5341 { | |
25012 | 5342 /* If current line is blank, skip over initial spaces, if |
5343 possible, and write the rest. */ | |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5344 if (write_spaces_p || desired_row->inverse_p) |
25012 | 5345 nsp = 0; |
5346 else | |
5347 nsp = count_blanks (nbody, nlen); | |
5348 | |
314 | 5349 if (nlen > nsp) |
5350 { | |
5351 cursor_to (vpos, nsp); | |
5352 write_glyphs (nbody + nsp, nlen - nsp); | |
5353 } | |
5354 | |
764 | 5355 /* Exchange contents between current_frame and new_frame. */ |
25012 | 5356 make_current (desired_matrix, current_matrix, vpos); |
314 | 5357 return; |
5358 } | |
5359 | |
5360 /* Compute number of leading blanks in old and new contents. */ | |
25012 | 5361 osp = count_blanks (obody, olen); |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5362 nsp = (desired_row->inverse_p || colored_spaces_p |
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5363 ? 0 |
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5364 : count_blanks (nbody, nlen)); |
25012 | 5365 |
5366 /* Compute number of matching chars starting with first non-blank. */ | |
5367 begmatch = count_match (obody + osp, obody + olen, | |
5368 nbody + nsp, nbody + nlen); | |
314 | 5369 |
5370 /* Spaces in new match implicit space past the end of old. */ | |
5371 /* A bug causing this to be a no-op was fixed in 18.29. */ | |
33101
39cd5f99c67d
(update_frame_line): Handle case where spaces in
Gerd Moellmann <gerd@gnu.org>
parents:
32752
diff
changeset
|
5372 if (!write_spaces_p && osp + begmatch == olen) |
314 | 5373 { |
5374 np1 = nbody + nsp; | |
25012 | 5375 while (np1 + begmatch < nend && CHAR_GLYPH_SPACE_P (np1[begmatch])) |
5376 ++begmatch; | |
314 | 5377 } |
5378 | |
5379 /* Avoid doing insert/delete char | |
5380 just cause number of leading spaces differs | |
25012 | 5381 when the following text does not match. */ |
314 | 5382 if (begmatch == 0 && osp != nsp) |
5383 osp = nsp = min (osp, nsp); | |
5384 | |
5385 /* Find matching characters at end of line */ | |
5386 op1 = obody + olen; | |
5387 np1 = nbody + nlen; | |
5388 op2 = op1 + begmatch - min (olen - osp, nlen - nsp); | |
25012 | 5389 while (op1 > op2 |
5390 && GLYPH_EQUAL_P (op1 - 1, np1 - 1)) | |
314 | 5391 { |
5392 op1--; | |
5393 np1--; | |
5394 } | |
5395 endmatch = obody + olen - op1; | |
5396 | |
5397 /* tem gets the distance to insert or delete. | |
5398 endmatch is how many characters we save by doing so. | |
5399 Is it worth it? */ | |
5400 | |
5401 tem = (nlen - nsp) - (olen - osp); | |
5402 if (endmatch && tem | |
764 | 5403 && (!char_ins_del_ok || endmatch <= char_ins_del_cost (frame)[tem])) |
314 | 5404 endmatch = 0; |
5405 | |
5406 /* nsp - osp is the distance to insert or delete. | |
5407 If that is nonzero, begmatch is known to be nonzero also. | |
5408 begmatch + endmatch is how much we save by doing the ins/del. | |
5409 Is it worth it? */ | |
5410 | |
5411 if (nsp != osp | |
5412 && (!char_ins_del_ok | |
764 | 5413 || begmatch + endmatch <= char_ins_del_cost (frame)[nsp - osp])) |
314 | 5414 { |
5415 begmatch = 0; | |
5416 endmatch = 0; | |
5417 osp = nsp = min (osp, nsp); | |
5418 } | |
5419 | |
5420 /* Now go through the line, inserting, writing and | |
5421 deleting as appropriate. */ | |
5422 | |
5423 if (osp > nsp) | |
5424 { | |
5425 cursor_to (vpos, nsp); | |
5426 delete_glyphs (osp - nsp); | |
5427 } | |
5428 else if (nsp > osp) | |
5429 { | |
5430 /* If going to delete chars later in line | |
5431 and insert earlier in the line, | |
5432 must delete first to avoid losing data in the insert */ | |
5433 if (endmatch && nlen < olen + nsp - osp) | |
5434 { | |
5435 cursor_to (vpos, nlen - endmatch + osp - nsp); | |
5436 delete_glyphs (olen + nsp - osp - nlen); | |
5437 olen = nlen - (nsp - osp); | |
5438 } | |
5439 cursor_to (vpos, osp); | |
25012 | 5440 insert_glyphs (0, nsp - osp); |
314 | 5441 } |
5442 olen += nsp - osp; | |
5443 | |
5444 tem = nsp + begmatch + endmatch; | |
5445 if (nlen != tem || olen != tem) | |
5446 { | |
5447 cursor_to (vpos, nsp + begmatch); | |
5448 if (!endmatch || nlen == olen) | |
5449 { | |
5450 /* If new text being written reaches right margin, | |
5451 there is no need to do clear-to-eol at the end. | |
5452 (and it would not be safe, since cursor is not | |
5453 going to be "at the margin" after the text is done) */ | |
16267
05ca2cb9fe0f
(make_frame_glyphs, update_line, update_frame)
Richard M. Stallman <rms@gnu.org>
parents:
16256
diff
changeset
|
5454 if (nlen == FRAME_WINDOW_WIDTH (frame)) |
314 | 5455 olen = 0; |
5456 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
5457 } | |
5458 else if (nlen > olen) | |
5459 { | |
17015
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5460 /* Here, we used to have the following simple code: |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5461 ---------------------------------------- |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5462 write_glyphs (nbody + nsp + begmatch, olen - tem); |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5463 insert_glyphs (nbody + nsp + begmatch + olen - tem, nlen - olen); |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5464 ---------------------------------------- |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5465 but it doesn't work if nbody[nsp + begmatch + olen - tem] |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5466 is a padding glyph. */ |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5467 int out = olen - tem; /* Columns to be overwritten originally. */ |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5468 int del; |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5469 |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5470 /* Calculate columns we can actually overwrite. */ |
25012 | 5471 while (CHAR_GLYPH_PADDING_P (nbody[nsp + begmatch + out])) out--; |
17015
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5472 write_glyphs (nbody + nsp + begmatch, out); |
25012 | 5473 /* If we left columns to be overwritten, we must delete them. */ |
17015
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5474 del = olen - tem - out; |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5475 if (del > 0) delete_glyphs (del); |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5476 /* At last, we insert columns not yet written out. */ |
fe0b3661b584
(direct_output_forward_char): #if-0-out redundant
Karl Heuer <kwzh@gnu.org>
parents:
16896
diff
changeset
|
5477 insert_glyphs (nbody + nsp + begmatch + out, nlen - olen + del); |
314 | 5478 olen = nlen; |
5479 } | |
5480 else if (olen > nlen) | |
5481 { | |
5482 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
5483 delete_glyphs (olen - nlen); | |
5484 olen = nlen; | |
5485 } | |
5486 } | |
5487 | |
5488 just_erase: | |
5489 /* If any unerased characters remain after the new line, erase them. */ | |
5490 if (olen > nlen) | |
5491 { | |
5492 cursor_to (vpos, nlen); | |
5493 clear_end_of_line (olen); | |
5494 } | |
5495 | |
764 | 5496 /* Exchange contents between current_frame and new_frame. */ |
25012 | 5497 make_current (desired_matrix, current_matrix, vpos); |
314 | 5498 } |
25012 | 5499 |
5500 | |
314 | 5501 |
25012 | 5502 /*********************************************************************** |
5503 X/Y Position -> Buffer Position | |
5504 ***********************************************************************/ | |
5505 | |
5506 /* Return the character position of the character at window relative | |
5507 pixel position (*X, *Y). *X and *Y are adjusted to character | |
5508 boundaries. */ | |
5509 | |
5510 int | |
5511 buffer_posn_from_coords (w, x, y) | |
5512 struct window *w; | |
5513 int *x, *y; | |
7810
15c0bf73737e
(Fframe_or_buffer_changed_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
7808
diff
changeset
|
5514 { |
25012 | 5515 struct it it; |
5516 struct buffer *old_current_buffer = current_buffer; | |
5517 struct text_pos startp; | |
5518 int left_area_width; | |
5519 | |
5520 current_buffer = XBUFFER (w->buffer); | |
5521 SET_TEXT_POS_FROM_MARKER (startp, w->start); | |
5522 CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp))); | |
5523 BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp))); | |
5524 start_display (&it, w, startp); | |
5525 | |
5526 left_area_width = WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH (w); | |
5527 move_it_to (&it, -1, *x + it.first_visible_x - left_area_width, *y, -1, | |
5528 MOVE_TO_X | MOVE_TO_Y); | |
5529 | |
5530 *x = it.current_x - it.first_visible_x + left_area_width; | |
5531 *y = it.current_y; | |
5532 current_buffer = old_current_buffer; | |
5533 return IT_CHARPOS (it); | |
5534 } | |
5535 | |
5536 | |
5537 /* Value is the string under window-relative coordinates X/Y in the | |
5538 mode or top line of window W, or nil if none. MODE_LINE_P non-zero | |
5539 means look at the mode line. *CHARPOS is set to the position in | |
5540 the string returned. */ | |
5541 | |
5542 Lisp_Object | |
5543 mode_line_string (w, x, y, mode_line_p, charpos) | |
5544 struct window *w; | |
30713
fee809f81f97
(mode_line_string): Declare parameter MODE_LINE_P.
Gerd Moellmann <gerd@gnu.org>
parents:
30323
diff
changeset
|
5545 int x, y, mode_line_p; |
25012 | 5546 int *charpos; |
5547 { | |
5548 struct glyph_row *row; | |
5549 struct glyph *glyph, *end; | |
5550 struct frame *f = XFRAME (w->frame); | |
5551 int x0; | |
5552 Lisp_Object string = Qnil; | |
5553 | |
5554 if (mode_line_p) | |
5555 row = MATRIX_MODE_LINE_ROW (w->current_matrix); | |
5556 else | |
25546 | 5557 row = MATRIX_HEADER_LINE_ROW (w->current_matrix); |
25012 | 5558 |
5559 if (row->mode_line_p && row->enabled_p) | |
11919
31cb053405f2
(Fframe_or_buffer_changed_p): Record frame names
Karl Heuer <kwzh@gnu.org>
parents:
11914
diff
changeset
|
5560 { |
25012 | 5561 /* The mode lines are displayed over scroll bars and bitmap |
5562 areas, and X is window-relative. Correct X by the scroll bar | |
5563 and bitmap area width. */ | |
5564 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) | |
5565 x += FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f); | |
25459
293b78b9ff60
(mode_line_string): Add FRAME_LEFT_FLAGS_AREA_WIDTH
Gerd Moellmann <gerd@gnu.org>
parents:
25385
diff
changeset
|
5566 x += FRAME_LEFT_FLAGS_AREA_WIDTH (f); |
25012 | 5567 |
5568 /* Find the glyph under X. If we find one with a string object, | |
5569 it's the one we were looking for. */ | |
5570 glyph = row->glyphs[TEXT_AREA]; | |
5571 end = glyph + row->used[TEXT_AREA]; | |
5572 for (x0 = 0; glyph < end; x0 += glyph->pixel_width, ++glyph) | |
5573 if (x >= x0 && x < x0 + glyph->pixel_width) | |
5574 { | |
5575 string = glyph->object; | |
5576 *charpos = glyph->charpos; | |
5577 break; | |
5578 } | |
7810
15c0bf73737e
(Fframe_or_buffer_changed_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
7808
diff
changeset
|
5579 } |
25012 | 5580 |
5581 return string; | |
7810
15c0bf73737e
(Fframe_or_buffer_changed_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
7808
diff
changeset
|
5582 } |
25012 | 5583 |
5584 | |
5585 /*********************************************************************** | |
5586 Changing Frame Sizes | |
5587 ***********************************************************************/ | |
314 | 5588 |
5589 #ifdef SIGWINCH | |
25012 | 5590 |
493 | 5591 SIGTYPE |
10745
a553a08f5785
(window_change_signal): Add ignored argument.
Richard M. Stallman <rms@gnu.org>
parents:
10259
diff
changeset
|
5592 window_change_signal (signalnum) /* If we don't have an argument, */ |
25012 | 5593 int signalnum; /* some compilers complain in signal calls. */ |
314 | 5594 { |
5595 int width, height; | |
31093
6da961dff718
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30720
diff
changeset
|
5596 #ifndef USE_CRT_DLL |
314 | 5597 extern int errno; |
31093
6da961dff718
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30720
diff
changeset
|
5598 #endif |
314 | 5599 int old_errno = errno; |
5600 | |
764 | 5601 get_frame_size (&width, &height); |
314 | 5602 |
764 | 5603 /* The frame size change obviously applies to a termcap-controlled |
5604 frame. Find such a frame in the list, and assume it's the only | |
314 | 5605 one (since the redisplay code always writes to stdout, not a |
764 | 5606 FILE * specified in the frame structure). Record the new size, |
314 | 5607 but don't reallocate the data structures now. Let that be done |
5608 later outside of the signal handler. */ | |
5609 | |
5610 { | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
5611 Lisp_Object tail, frame; |
314 | 5612 |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
5613 FOR_EACH_FRAME (tail, frame) |
314 | 5614 { |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
5615 if (FRAME_TERMCAP_P (XFRAME (frame))) |
314 | 5616 { |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5617 change_frame_size (XFRAME (frame), height, width, 0, 1, 0); |
314 | 5618 break; |
5619 } | |
5620 } | |
5621 } | |
5622 | |
5623 signal (SIGWINCH, window_change_signal); | |
5624 errno = old_errno; | |
5625 } | |
5626 #endif /* SIGWINCH */ | |
5627 | |
5628 | |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5629 /* Do any change in frame size that was requested by a signal. SAFE |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5630 non-zero means this function is called from a place where it is |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5631 safe to change frame sizes while a redisplay is in progress. */ |
314 | 5632 |
21514 | 5633 void |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5634 do_pending_window_change (safe) |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5635 int safe; |
314 | 5636 { |
5637 /* If window_change_signal should have run before, run it now. */ | |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5638 if (redisplaying_p && !safe) |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5639 return; |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5640 |
314 | 5641 while (delayed_size_change) |
5642 { | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
5643 Lisp_Object tail, frame; |
314 | 5644 |
5645 delayed_size_change = 0; | |
5646 | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
5647 FOR_EACH_FRAME (tail, frame) |
314 | 5648 { |
25012 | 5649 struct frame *f = XFRAME (frame); |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
5650 |
764 | 5651 int height = FRAME_NEW_HEIGHT (f); |
5652 int width = FRAME_NEW_WIDTH (f); | |
314 | 5653 |
3449
ad455da9b789
(do_pending_window_change): No need to clear
Richard M. Stallman <rms@gnu.org>
parents:
3357
diff
changeset
|
5654 if (height != 0 || width != 0) |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5655 change_frame_size (f, height, width, 0, 0, safe); |
314 | 5656 } |
5657 } | |
5658 } | |
5659 | |
5660 | |
764 | 5661 /* 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
|
5662 indicate no change is to take place. |
314 | 5663 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
5664 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
|
5665 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
|
5666 redisplay. Since this tries to resize windows, we can't call it |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5667 from a signal handler. |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5668 |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5669 SAFE non-zero means this function is called from a place where it's |
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5670 safe to change frame sizes while a redisplay is in progress. */ |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
5671 |
21514 | 5672 void |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5673 change_frame_size (f, newheight, newwidth, pretend, delay, safe) |
25012 | 5674 register struct frame *f; |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5675 int newheight, newwidth, pretend, delay, safe; |
10770
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5676 { |
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5677 Lisp_Object tail, frame; |
16881
245ba9f2781a
(change_frame_size_1): Reject new sizes if they cause overflow.
Richard M. Stallman <rms@gnu.org>
parents:
16822
diff
changeset
|
5678 |
15395
b584c2db055f
(change_frame_size, remake_frame_glyphs): Use FRAME_WINDOW_P.
Richard M. Stallman <rms@gnu.org>
parents:
15394
diff
changeset
|
5679 if (! FRAME_WINDOW_P (f)) |
10770
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5680 { |
15394
8d01f71c4797
(Fredraw_frame, remake_frame_glyphs)
Richard M. Stallman <rms@gnu.org>
parents:
15282
diff
changeset
|
5681 /* When using termcap, or on MS-DOS, all frames use |
8d01f71c4797
(Fredraw_frame, remake_frame_glyphs)
Richard M. Stallman <rms@gnu.org>
parents:
15282
diff
changeset
|
5682 the same screen, so a change in size affects all frames. */ |
10770
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5683 FOR_EACH_FRAME (tail, frame) |
15395
b584c2db055f
(change_frame_size, remake_frame_glyphs): Use FRAME_WINDOW_P.
Richard M. Stallman <rms@gnu.org>
parents:
15394
diff
changeset
|
5684 if (! FRAME_WINDOW_P (XFRAME (frame))) |
10770
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5685 change_frame_size_1 (XFRAME (frame), newheight, newwidth, |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5686 pretend, delay, safe); |
10770
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5687 } |
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5688 else |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5689 change_frame_size_1 (f, newheight, newwidth, pretend, delay, safe); |
10770
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5690 } |
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5691 |
79745e047484
(change_frame_size_1): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
10745
diff
changeset
|
5692 static void |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5693 change_frame_size_1 (f, newheight, newwidth, pretend, delay, safe) |
25012 | 5694 register struct frame *f; |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5695 int newheight, newwidth, pretend, delay, safe; |
314 | 5696 { |
16256
1ce0cb94fa68
(preserve_other_columns, preserve_my_columns): Use new
Richard M. Stallman <rms@gnu.org>
parents:
16195
diff
changeset
|
5697 int new_frame_window_width; |
19627
c6343f7a9c6c
(change_frame_size_1): Save current buffer
Richard M. Stallman <rms@gnu.org>
parents:
19063
diff
changeset
|
5698 int count = specpdl_ptr - specpdl; |
16881
245ba9f2781a
(change_frame_size_1): Reject new sizes if they cause overflow.
Richard M. Stallman <rms@gnu.org>
parents:
16822
diff
changeset
|
5699 |
314 | 5700 /* If we can't deal with the change now, queue it for later. */ |
25345
ca828f89fd6e
(do_pending_window_change): Add parameter `safe'.
Gerd Moellmann <gerd@gnu.org>
parents:
25318
diff
changeset
|
5701 if (delay || (redisplaying_p && !safe)) |
314 | 5702 { |
25012 | 5703 FRAME_NEW_HEIGHT (f) = newheight; |
5704 FRAME_NEW_WIDTH (f) = newwidth; | |
314 | 5705 delayed_size_change = 1; |
5706 return; | |
5707 } | |
5708 | |
764 | 5709 /* This size-change overrides any pending one for this frame. */ |
25012 | 5710 FRAME_NEW_HEIGHT (f) = 0; |
5711 FRAME_NEW_WIDTH (f) = 0; | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
5712 |
3449
ad455da9b789
(do_pending_window_change): No need to clear
Richard M. Stallman <rms@gnu.org>
parents:
3357
diff
changeset
|
5713 /* If an argument is zero, set it to the current value. */ |
15896
3a3c30116313
(change_frame_size_1): Clean up conditional.
Erik Naggum <erik@naggum.no>
parents:
15687
diff
changeset
|
5714 if (newheight == 0) |
25012 | 5715 newheight = FRAME_HEIGHT (f); |
15896
3a3c30116313
(change_frame_size_1): Clean up conditional.
Erik Naggum <erik@naggum.no>
parents:
15687
diff
changeset
|
5716 if (newwidth == 0) |
25012 | 5717 newwidth = FRAME_WIDTH (f); |
5718 | |
5719 /* Compute width of windows in F. | |
5720 This is the width of the frame without vertical scroll bars. */ | |
5721 new_frame_window_width = FRAME_WINDOW_WIDTH_ARG (f, newwidth); | |
16881
245ba9f2781a
(change_frame_size_1): Reject new sizes if they cause overflow.
Richard M. Stallman <rms@gnu.org>
parents:
16822
diff
changeset
|
5722 |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
5723 /* Round up to the smallest acceptable size. */ |
25012 | 5724 check_frame_size (f, &newheight, &newwidth); |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
5725 |
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
5726 /* If we're not changing the frame size, quit now. */ |
25012 | 5727 if (newheight == FRAME_HEIGHT (f) |
5728 && new_frame_window_width == FRAME_WINDOW_WIDTH (f)) | |
314 | 5729 return; |
5730 | |
15078 | 5731 BLOCK_INPUT; |
5732 | |
14286
5d42664b4e74
(change_frame_size_1) [MSDOS]: Support frame size
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5733 #ifdef MSDOS |
5d42664b4e74
(change_frame_size_1) [MSDOS]: Support frame size
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5734 /* We only can set screen dimensions to certain values supported |
5d42664b4e74
(change_frame_size_1) [MSDOS]: Support frame size
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5735 by our video hardware. Try to find the smallest size greater |
5d42664b4e74
(change_frame_size_1) [MSDOS]: Support frame size
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5736 or equal to the requested dimensions. */ |
5d42664b4e74
(change_frame_size_1) [MSDOS]: Support frame size
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5737 dos_set_window_size (&newheight, &newwidth); |
5d42664b4e74
(change_frame_size_1) [MSDOS]: Support frame size
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5738 #endif |
5d42664b4e74
(change_frame_size_1) [MSDOS]: Support frame size
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5739 |
25012 | 5740 if (newheight != FRAME_HEIGHT (f)) |
314 | 5741 { |
25012 | 5742 if (FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) |
314 | 5743 { |
25012 | 5744 /* Frame has both root and mini-buffer. */ |
5745 XSETFASTINT (XWINDOW (FRAME_ROOT_WINDOW (f))->top, | |
5746 FRAME_TOP_MARGIN (f)); | |
5747 set_window_height (FRAME_ROOT_WINDOW (f), | |
5748 (newheight | |
5749 - 1 | |
5750 - FRAME_TOP_MARGIN (f)), | |
5751 0); | |
5752 XSETFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top, | |
9303
3115ae493c30
(direct_output_for_insert, direct_output_forward_char, change_frame_size,
Karl Heuer <kwzh@gnu.org>
parents:
9264
diff
changeset
|
5753 newheight - 1); |
25012 | 5754 set_window_height (FRAME_MINIBUF_WINDOW (f), 1, 0); |
314 | 5755 } |
5756 else | |
764 | 5757 /* Frame has just one top-level window. */ |
25012 | 5758 set_window_height (FRAME_ROOT_WINDOW (f), |
5759 newheight - FRAME_TOP_MARGIN (f), 0); | |
5760 | |
5761 if (FRAME_TERMCAP_P (f) && !pretend) | |
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
5762 FrameRows = newheight; |
314 | 5763 } |
5764 | |
25012 | 5765 if (new_frame_window_width != FRAME_WINDOW_WIDTH (f)) |
314 | 5766 { |
25012 | 5767 set_window_width (FRAME_ROOT_WINDOW (f), new_frame_window_width, 0); |
5768 if (FRAME_HAS_MINIBUF_P (f)) | |
5769 set_window_width (FRAME_MINIBUF_WINDOW (f), new_frame_window_width, 0); | |
5770 | |
5771 if (FRAME_TERMCAP_P (f) && !pretend) | |
764 | 5772 FrameCols = newwidth; |
25012 | 5773 |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
5774 if (WINDOWP (f->tool_bar_window)) |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25514
diff
changeset
|
5775 XSETFASTINT (XWINDOW (f->tool_bar_window)->width, newwidth); |
314 | 5776 } |
5777 | |
25012 | 5778 FRAME_HEIGHT (f) = newheight; |
5779 SET_FRAME_WIDTH (f, newwidth); | |
5780 | |
5781 { | |
5782 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
5783 int text_area_x, text_area_y, text_area_width, text_area_height; | |
5784 | |
5785 window_box (w, TEXT_AREA, &text_area_x, &text_area_y, &text_area_width, | |
5786 &text_area_height); | |
5787 if (w->cursor.x >= text_area_x + text_area_width) | |
5788 w->cursor.hpos = w->cursor.x = 0; | |
5789 if (w->cursor.y >= text_area_y + text_area_height) | |
5790 w->cursor.vpos = w->cursor.y = 0; | |
5791 } | |
5792 | |
5793 adjust_glyphs (f); | |
5794 SET_FRAME_GARBAGED (f); | |
5795 calculate_costs (f); | |
15065 | 5796 |
5797 UNBLOCK_INPUT; | |
17282
5023bea28298
(change_frame_size_1): Call Fset_window_buffer,
Richard M. Stallman <rms@gnu.org>
parents:
17015
diff
changeset
|
5798 |
19627
c6343f7a9c6c
(change_frame_size_1): Save current buffer
Richard M. Stallman <rms@gnu.org>
parents:
19063
diff
changeset
|
5799 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
c6343f7a9c6c
(change_frame_size_1): Save current buffer
Richard M. Stallman <rms@gnu.org>
parents:
19063
diff
changeset
|
5800 |
17282
5023bea28298
(change_frame_size_1): Call Fset_window_buffer,
Richard M. Stallman <rms@gnu.org>
parents:
17015
diff
changeset
|
5801 /* This isn't quite a no-op: it runs window-configuration-change-hook. */ |
25012 | 5802 Fset_window_buffer (FRAME_SELECTED_WINDOW (f), |
5803 XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer); | |
19627
c6343f7a9c6c
(change_frame_size_1): Save current buffer
Richard M. Stallman <rms@gnu.org>
parents:
19063
diff
changeset
|
5804 |
c6343f7a9c6c
(change_frame_size_1): Save current buffer
Richard M. Stallman <rms@gnu.org>
parents:
19063
diff
changeset
|
5805 unbind_to (count, Qnil); |
314 | 5806 } |
25012 | 5807 |
5808 | |
314 | 5809 |
25012 | 5810 /*********************************************************************** |
5811 Terminal Related Lisp Functions | |
5812 ***********************************************************************/ | |
5813 | |
5814 DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript, | |
5815 1, 1, "FOpen termscript file: ", | |
5816 "Start writing all terminal output to FILE as well as the terminal.\n\ | |
5817 FILE = nil means just close any termscript file currently open.") | |
5818 (file) | |
5819 Lisp_Object file; | |
5820 { | |
5821 if (termscript != 0) fclose (termscript); | |
5822 termscript = 0; | |
5823 | |
5824 if (! NILP (file)) | |
5825 { | |
5826 file = Fexpand_file_name (file, Qnil); | |
5827 termscript = fopen (XSTRING (file)->data, "w"); | |
5828 if (termscript == 0) | |
5829 report_file_error ("Opening termscript", Fcons (file, Qnil)); | |
5830 } | |
5831 return Qnil; | |
5832 } | |
5833 | |
5834 | |
314 | 5835 DEFUN ("send-string-to-terminal", Fsend_string_to_terminal, |
5836 Ssend_string_to_terminal, 1, 1, 0, | |
5837 "Send STRING to the terminal without alteration.\n\ | |
5838 Control characters in STRING will have terminal-dependent effects.") | |
14068
a3c83dde295e
(Fsend_string_to_terminal, Fsit_for): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13526
diff
changeset
|
5839 (string) |
a3c83dde295e
(Fsend_string_to_terminal, Fsit_for): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13526
diff
changeset
|
5840 Lisp_Object string; |
314 | 5841 { |
20618
d5acac3af6e3
(Fsend_string_to_terminal): Use size_byte.
Richard M. Stallman <rms@gnu.org>
parents:
19627
diff
changeset
|
5842 /* ??? Perhaps we should do something special for multibyte strings here. */ |
14068
a3c83dde295e
(Fsend_string_to_terminal, Fsit_for): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13526
diff
changeset
|
5843 CHECK_STRING (string, 0); |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
20708
diff
changeset
|
5844 fwrite (XSTRING (string)->data, 1, STRING_BYTES (XSTRING (string)), stdout); |
314 | 5845 fflush (stdout); |
5846 if (termscript) | |
5847 { | |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
20708
diff
changeset
|
5848 fwrite (XSTRING (string)->data, 1, STRING_BYTES (XSTRING (string)), |
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
20708
diff
changeset
|
5849 termscript); |
314 | 5850 fflush (termscript); |
5851 } | |
5852 return Qnil; | |
5853 } | |
5854 | |
25012 | 5855 |
314 | 5856 DEFUN ("ding", Fding, Sding, 0, 1, 0, |
5857 "Beep, or flash the screen.\n\ | |
5858 Also, unless an argument is given,\n\ | |
5859 terminate any keyboard macro currently executing.") | |
5860 (arg) | |
5861 Lisp_Object arg; | |
5862 { | |
493 | 5863 if (!NILP (arg)) |
314 | 5864 { |
649
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
5865 if (noninteractive) |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
5866 putchar (07); |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
5867 else |
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
5868 ring_bell (); |
314 | 5869 fflush (stdout); |
5870 } | |
5871 else | |
5872 bitch_at_user (); | |
5873 | |
5874 return Qnil; | |
5875 } | |
5876 | |
21514 | 5877 void |
314 | 5878 bitch_at_user () |
5879 { | |
5880 if (noninteractive) | |
5881 putchar (07); | |
25012 | 5882 else if (!INTERACTIVE) /* Stop executing a keyboard macro. */ |
314 | 5883 error ("Keyboard macro terminated by a command ringing the bell"); |
5884 else | |
5885 ring_bell (); | |
5886 fflush (stdout); | |
5887 } | |
5888 | |
25012 | 5889 |
5890 | |
5891 /*********************************************************************** | |
5892 Sleeping, Waiting | |
5893 ***********************************************************************/ | |
5894 | |
314 | 5895 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
|
5896 "Pause, without updating display, for SECONDS seconds.\n\ |
2648 | 5897 SECONDS may be a floating-point value, meaning that you can wait for a\n\ |
5898 fraction of a second. Optional second arg MILLISECONDS specifies an\n\ | |
5899 additional wait period, in milliseconds; this may be useful if your\n\ | |
5900 Emacs was built without floating point support.\n\ | |
5901 \(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
|
5902 (seconds, milliseconds) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5903 Lisp_Object seconds, milliseconds; |
314 | 5904 { |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5905 int sec, usec; |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5906 |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5907 if (NILP (milliseconds)) |
9264
9338a124ea84
(redraw_frame, Fsleep_for, sit_for, Fsit_for): Use new accessor macros instead
Karl Heuer <kwzh@gnu.org>
parents:
8903
diff
changeset
|
5908 XSETINT (milliseconds, 0); |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5909 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5910 CHECK_NUMBER (milliseconds, 1); |
2648 | 5911 usec = XINT (milliseconds) * 1000; |
5912 | |
5913 { | |
5914 double duration = extract_float (seconds); | |
5915 sec = (int) duration; | |
5916 usec += (duration - sec) * 1000000; | |
5917 } | |
314 | 5918 |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5919 #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
|
5920 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
|
5921 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
|
5922 #endif |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5923 |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5924 /* 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
|
5925 if (usec < 0) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5926 { |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5927 /* 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
|
5928 if (-1000000 < usec) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5929 sec--, usec += 1000000; |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5930 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5931 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
|
5932 } |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5933 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5934 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
|
5935 |
14646
68fe10d1abd0
(Fsleep_for): Accept sub-second intervals.
Erik Naggum <erik@naggum.no>
parents:
14459
diff
changeset
|
5936 if (sec < 0 || (sec == 0 && usec == 0)) |
314 | 5937 return Qnil; |
5938 | |
650 | 5939 { |
5940 Lisp_Object zero; | |
5941 | |
9303
3115ae493c30
(direct_output_for_insert, direct_output_forward_char, change_frame_size,
Karl Heuer <kwzh@gnu.org>
parents:
9264
diff
changeset
|
5942 XSETFASTINT (zero, 0); |
650 | 5943 wait_reading_process_input (sec, usec, zero, 0); |
5944 } | |
587 | 5945 |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5946 /* 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
|
5947 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
|
5948 #if 0 |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
5949 /* No wait_reading_process_input */ |
314 | 5950 immediate_quit = 1; |
5951 QUIT; | |
5952 | |
5953 #ifdef VMS | |
5954 sys_sleep (sec); | |
5955 #else /* not VMS */ | |
5956 /* The reason this is done this way | |
5957 (rather than defined (H_S) && defined (H_T)) | |
5958 is because the VMS preprocessor doesn't grok `defined' */ | |
5959 #ifdef HAVE_SELECT | |
554 | 5960 EMACS_GET_TIME (end_time); |
5961 EMACS_SET_SECS_USECS (timeout, sec, usec); | |
587 | 5962 EMACS_ADD_TIME (end_time, end_time, timeout); |
554 | 5963 |
314 | 5964 while (1) |
5965 { | |
554 | 5966 EMACS_GET_TIME (timeout); |
5967 EMACS_SUB_TIME (timeout, end_time, timeout); | |
5968 if (EMACS_TIME_NEG_P (timeout) | |
5969 || !select (1, 0, 0, 0, &timeout)) | |
314 | 5970 break; |
5971 } | |
5972 #else /* not HAVE_SELECT */ | |
5973 sleep (sec); | |
5974 #endif /* HAVE_SELECT */ | |
5975 #endif /* not VMS */ | |
5976 | |
5977 immediate_quit = 0; | |
5978 #endif /* no subprocesses */ | |
5979 | |
5980 return Qnil; | |
5981 } | |
5982 | |
25012 | 5983 |
650 | 5984 /* This is just like wait_reading_process_input, except that |
5985 it does the redisplay. | |
5986 | |
5223
db2e7e6a488e
(Fsit_for): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5218
diff
changeset
|
5987 It's also much like Fsit_for, except that it can be used for |
11411
91bcce2fd486
(Fframe_or_buffer_changed_p): Ignore buffers whose names start with space.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
5988 waiting for input as well. */ |
650 | 5989 |
5990 Lisp_Object | |
17961
86ae1679df19
(sit_for): New arg initial_display.
Richard M. Stallman <rms@gnu.org>
parents:
17895
diff
changeset
|
5991 sit_for (sec, usec, reading, display, initial_display) |
86ae1679df19
(sit_for): New arg initial_display.
Richard M. Stallman <rms@gnu.org>
parents:
17895
diff
changeset
|
5992 int sec, usec, reading, display, initial_display; |
314 | 5993 { |
650 | 5994 Lisp_Object read_kbd; |
314 | 5995 |
14964
9938201005a3
(sit_for): Call swallow_events.
Richard M. Stallman <rms@gnu.org>
parents:
14903
diff
changeset
|
5996 swallow_events (display); |
9938201005a3
(sit_for): Call swallow_events.
Richard M. Stallman <rms@gnu.org>
parents:
14903
diff
changeset
|
5997 |
14757
99125e1e8bac
(sit_for): Pass DISPLAY to detect_input_pending_run_timers.
Richard M. Stallman <rms@gnu.org>
parents:
14646
diff
changeset
|
5998 if (detect_input_pending_run_timers (display)) |
314 | 5999 return Qnil; |
650 | 6000 |
17961
86ae1679df19
(sit_for): New arg initial_display.
Richard M. Stallman <rms@gnu.org>
parents:
17895
diff
changeset
|
6001 if (initial_display) |
314 | 6002 redisplay_preserve_echo_area (); |
6003 | |
673 | 6004 if (sec == 0 && usec == 0) |
6005 return Qt; | |
6006 | |
314 | 6007 #ifdef SIGIO |
1915
98ecf99d7b1a
* dispnew.c (sit_for): Pass the correct number of arguments to
Jim Blandy <jimb@redhat.com>
parents:
1872
diff
changeset
|
6008 gobble_input (0); |
650 | 6009 #endif |
6010 | |
9264
9338a124ea84
(redraw_frame, Fsleep_for, sit_for, Fsit_for): Use new accessor macros instead
Karl Heuer <kwzh@gnu.org>
parents:
8903
diff
changeset
|
6011 XSETINT (read_kbd, reading ? -1 : 1); |
650 | 6012 wait_reading_process_input (sec, usec, read_kbd, display); |
6013 | |
314 | 6014 return detect_input_pending () ? Qnil : Qt; |
6015 } | |
6016 | |
25012 | 6017 |
650 | 6018 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
|
6019 "Perform redisplay, then wait for SECONDS seconds or until input is available.\n\ |
2648 | 6020 SECONDS may be a floating-point value, meaning that you can wait for a\n\ |
6021 fraction of a second. Optional second arg MILLISECONDS specifies an\n\ | |
6022 additional wait period, in milliseconds; this may be useful if your\n\ | |
6023 Emacs was built without floating point support.\n\ | |
6024 \(Not all operating systems support waiting for a fraction of a second.)\n\ | |
14068
a3c83dde295e
(Fsend_string_to_terminal, Fsit_for): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13526
diff
changeset
|
6025 Optional third arg NODISP non-nil means don't redisplay, just wait for input.\n\ |
650 | 6026 Redisplay is preempted as always if input arrives, and does not happen\n\ |
6027 if input is available before it starts.\n\ | |
6028 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
|
6029 (seconds, milliseconds, nodisp) |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
6030 Lisp_Object seconds, milliseconds, nodisp; |
650 | 6031 { |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
6032 int sec, usec; |
650 | 6033 |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
6034 if (NILP (milliseconds)) |
9264
9338a124ea84
(redraw_frame, Fsleep_for, sit_for, Fsit_for): Use new accessor macros instead
Karl Heuer <kwzh@gnu.org>
parents:
8903
diff
changeset
|
6035 XSETINT (milliseconds, 0); |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
6036 else |
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
6037 CHECK_NUMBER (milliseconds, 1); |
2648 | 6038 usec = XINT (milliseconds) * 1000; |
6039 | |
6040 { | |
6041 double duration = extract_float (seconds); | |
6042 sec = (int) duration; | |
6043 usec += (duration - sec) * 1000000; | |
6044 } | |
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
6045 |
650 | 6046 #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
|
6047 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
|
6048 error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); |
650 | 6049 #endif |
6050 | |
17961
86ae1679df19
(sit_for): New arg initial_display.
Richard M. Stallman <rms@gnu.org>
parents:
17895
diff
changeset
|
6051 return sit_for (sec, usec, 0, NILP (nodisp), NILP (nodisp)); |
650 | 6052 } |
25012 | 6053 |
6054 | |
314 | 6055 |
25012 | 6056 /*********************************************************************** |
6057 Other Lisp Functions | |
6058 ***********************************************************************/ | |
6059 | |
6060 /* A vector of size >= 2 * NFRAMES + 3 * NBUFFERS + 1, containing the | |
6061 session's frames, frame names, buffers, buffer-read-only flags, and | |
6062 buffer-modified-flags, and a trailing sentinel (so we don't need to | |
6063 add length checks). */ | |
6064 | |
6065 static Lisp_Object frame_and_buffer_state; | |
6066 | |
6067 | |
6068 DEFUN ("frame-or-buffer-changed-p", Fframe_or_buffer_changed_p, | |
6069 Sframe_or_buffer_changed_p, 0, 0, 0, | |
6070 "Return non-nil if the frame and buffer state appears to have changed.\n\ | |
6071 The state variable is an internal vector containing all frames and buffers,\n\ | |
6072 aside from buffers whose names start with space,\n\ | |
6073 along with the buffers' read-only and modified flags, which allows a fast\n\ | |
6074 check to see whether the menu bars might need to be recomputed.\n\ | |
6075 If this function returns non-nil, it updates the internal vector to reflect\n\ | |
6076 the current state.\n") | |
6077 () | |
6078 { | |
6079 Lisp_Object tail, frame, buf; | |
6080 Lisp_Object *vecp; | |
6081 int n; | |
6082 | |
6083 vecp = XVECTOR (frame_and_buffer_state)->contents; | |
6084 FOR_EACH_FRAME (tail, frame) | |
6085 { | |
6086 if (!EQ (*vecp++, frame)) | |
6087 goto changed; | |
6088 if (!EQ (*vecp++, XFRAME (frame)->name)) | |
6089 goto changed; | |
6090 } | |
6091 /* Check that the buffer info matches. | |
6092 No need to test for the end of the vector | |
6093 because the last element of the vector is lambda | |
6094 and that will always cause a mismatch. */ | |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
6095 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) |
25012 | 6096 { |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
6097 buf = XCDR (XCAR (tail)); |
25012 | 6098 /* Ignore buffers that aren't included in buffer lists. */ |
6099 if (XSTRING (XBUFFER (buf)->name)->data[0] == ' ') | |
6100 continue; | |
6101 if (!EQ (*vecp++, buf)) | |
6102 goto changed; | |
6103 if (!EQ (*vecp++, XBUFFER (buf)->read_only)) | |
6104 goto changed; | |
6105 if (!EQ (*vecp++, Fbuffer_modified_p (buf))) | |
6106 goto changed; | |
6107 } | |
6108 /* Detect deletion of a buffer at the end of the list. */ | |
6109 if (EQ (*vecp, Qlambda)) | |
6110 return Qnil; | |
6111 changed: | |
6112 /* Start with 1 so there is room for at least one lambda at the end. */ | |
6113 n = 1; | |
6114 FOR_EACH_FRAME (tail, frame) | |
6115 n += 2; | |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
6116 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) |
25012 | 6117 n += 3; |
6118 /* Reallocate the vector if it's grown, or if it's shrunk a lot. */ | |
6119 if (n > XVECTOR (frame_and_buffer_state)->size | |
6120 || n + 20 < XVECTOR (frame_and_buffer_state)->size / 2) | |
6121 /* Add 20 extra so we grow it less often. */ | |
6122 frame_and_buffer_state = Fmake_vector (make_number (n + 20), Qlambda); | |
6123 vecp = XVECTOR (frame_and_buffer_state)->contents; | |
6124 FOR_EACH_FRAME (tail, frame) | |
6125 { | |
6126 *vecp++ = frame; | |
6127 *vecp++ = XFRAME (frame)->name; | |
6128 } | |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
6129 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) |
25012 | 6130 { |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
6131 buf = XCDR (XCAR (tail)); |
25012 | 6132 /* Ignore buffers that aren't included in buffer lists. */ |
6133 if (XSTRING (XBUFFER (buf)->name)->data[0] == ' ') | |
6134 continue; | |
6135 *vecp++ = buf; | |
6136 *vecp++ = XBUFFER (buf)->read_only; | |
6137 *vecp++ = Fbuffer_modified_p (buf); | |
6138 } | |
6139 /* Fill up the vector with lambdas (always at least one). */ | |
6140 *vecp++ = Qlambda; | |
6141 while (vecp - XVECTOR (frame_and_buffer_state)->contents | |
6142 < XVECTOR (frame_and_buffer_state)->size) | |
6143 *vecp++ = Qlambda; | |
6144 /* Make sure we didn't overflow the vector. */ | |
6145 if (vecp - XVECTOR (frame_and_buffer_state)->contents | |
6146 > XVECTOR (frame_and_buffer_state)->size) | |
6147 abort (); | |
6148 return Qt; | |
6149 } | |
6150 | |
6151 | |
6152 | |
6153 /*********************************************************************** | |
6154 Initialization | |
6155 ***********************************************************************/ | |
6156 | |
314 | 6157 char *terminal_type; |
6158 | |
25012 | 6159 /* Initialization done when Emacs fork is started, before doing stty. |
6160 Determine terminal type and set terminal_driver. Then invoke its | |
6161 decoding routine to set up variables in the terminal package. */ | |
314 | 6162 |
21514 | 6163 void |
314 | 6164 init_display () |
6165 { | |
6166 #ifdef HAVE_X_WINDOWS | |
6167 extern int display_arg; | |
6168 #endif | |
6169 | |
25012 | 6170 /* Construct the space glyph. */ |
6171 space_glyph.type = CHAR_GLYPH; | |
6172 SET_CHAR_GLYPH_FROM_GLYPH (space_glyph, ' '); | |
6173 space_glyph.charpos = -1; | |
6174 | |
314 | 6175 meta_key = 0; |
6176 inverse_video = 0; | |
6177 cursor_in_echo_area = 0; | |
6178 terminal_type = (char *) 0; | |
6179 | |
2339
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
6180 /* 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
|
6181 during startup. */ |
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
6182 Vwindow_system = Qnil; |
314 | 6183 |
2339
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
6184 /* 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
|
6185 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
|
6186 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
|
6187 using the window system. |
a302de11debf
* dispnew.c (init_display): Initialize Vwindow_system.
Jim Blandy <jimb@redhat.com>
parents:
2292
diff
changeset
|
6188 |
14125
2f222e8b06f5
(init_display): Treat null string DISPLAY var like not set.
Karl Heuer <kwzh@gnu.org>
parents:
14068
diff
changeset
|
6189 If the DISPLAY environment variable is set and nonempty, |
2f222e8b06f5
(init_display): Treat null string DISPLAY var like not set.
Karl Heuer <kwzh@gnu.org>
parents:
14068
diff
changeset
|
6190 try to use X, and die with an error message if that doesn't work. */ |
314 | 6191 |
6192 #ifdef HAVE_X_WINDOWS | |
2359
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
6193 if (! display_arg) |
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
6194 { |
14125
2f222e8b06f5
(init_display): Treat null string DISPLAY var like not set.
Karl Heuer <kwzh@gnu.org>
parents:
14068
diff
changeset
|
6195 char *display; |
2359
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
6196 #ifdef VMS |
14125
2f222e8b06f5
(init_display): Treat null string DISPLAY var like not set.
Karl Heuer <kwzh@gnu.org>
parents:
14068
diff
changeset
|
6197 display = getenv ("DECW$DISPLAY"); |
2359
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
6198 #else |
14125
2f222e8b06f5
(init_display): Treat null string DISPLAY var like not set.
Karl Heuer <kwzh@gnu.org>
parents:
14068
diff
changeset
|
6199 display = getenv ("DISPLAY"); |
2359
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
6200 #endif |
14125
2f222e8b06f5
(init_display): Treat null string DISPLAY var like not set.
Karl Heuer <kwzh@gnu.org>
parents:
14068
diff
changeset
|
6201 |
2f222e8b06f5
(init_display): Treat null string DISPLAY var like not set.
Karl Heuer <kwzh@gnu.org>
parents:
14068
diff
changeset
|
6202 display_arg = (display != 0 && *display != 0); |
2364 | 6203 } |
2359
90a5f91329f3
* dispnew.c (init_display): Get display name from environment
Jim Blandy <jimb@redhat.com>
parents:
2339
diff
changeset
|
6204 |
18774
95b4ac950a5d
(init_display): Go ahead and prepare for
Richard M. Stallman <rms@gnu.org>
parents:
18015
diff
changeset
|
6205 if (!inhibit_window_system && display_arg |
95b4ac950a5d
(init_display): Go ahead and prepare for
Richard M. Stallman <rms@gnu.org>
parents:
18015
diff
changeset
|
6206 #ifndef CANNOT_DUMP |
95b4ac950a5d
(init_display): Go ahead and prepare for
Richard M. Stallman <rms@gnu.org>
parents:
18015
diff
changeset
|
6207 && initialized |
95b4ac950a5d
(init_display): Go ahead and prepare for
Richard M. Stallman <rms@gnu.org>
parents:
18015
diff
changeset
|
6208 #endif |
95b4ac950a5d
(init_display): Go ahead and prepare for
Richard M. Stallman <rms@gnu.org>
parents:
18015
diff
changeset
|
6209 ) |
314 | 6210 { |
6211 Vwindow_system = intern ("x"); | |
6212 #ifdef HAVE_X11 | |
6213 Vwindow_system_version = make_number (11); | |
6214 #else | |
6215 Vwindow_system_version = make_number (10); | |
6216 #endif | |
15273
db889dd732a1
(init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
Karl Heuer <kwzh@gnu.org>
parents:
15078
diff
changeset
|
6217 #if defined (LINUX) && defined (HAVE_LIBNCURSES) |
db889dd732a1
(init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
Karl Heuer <kwzh@gnu.org>
parents:
15078
diff
changeset
|
6218 /* In some versions of ncurses, |
15282 | 6219 tputs crashes if we have not called tgetent. |
15273
db889dd732a1
(init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
Karl Heuer <kwzh@gnu.org>
parents:
15078
diff
changeset
|
6220 So call tgetent. */ |
db889dd732a1
(init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
Karl Heuer <kwzh@gnu.org>
parents:
15078
diff
changeset
|
6221 { char b[2044]; tgetent (b, "xterm");} |
db889dd732a1
(init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
Karl Heuer <kwzh@gnu.org>
parents:
15078
diff
changeset
|
6222 #endif |
25012 | 6223 adjust_frame_glyphs_initially (); |
314 | 6224 return; |
6225 } | |
6226 #endif /* HAVE_X_WINDOWS */ | |
6227 | |
13408
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6228 #ifdef HAVE_NTGUI |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6229 if (!inhibit_window_system) |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6230 { |
16589
ec300a10e407
(init_display) [HAVE_NTGUI]: Use w32 for window-system.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16412
diff
changeset
|
6231 Vwindow_system = intern ("w32"); |
13408
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6232 Vwindow_system_version = make_number (1); |
25012 | 6233 adjust_frame_glyphs_initially (); |
13408
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6234 return; |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6235 } |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6236 #endif /* HAVE_NTGUI */ |
7e92386e1cf7
[HAVE_NTGUI]: Include w32term.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13220
diff
changeset
|
6237 |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6238 #ifdef macintosh |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6239 if (!inhibit_window_system) |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6240 { |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6241 Vwindow_system = intern ("mac"); |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6242 Vwindow_system_version = make_number (1); |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6243 adjust_frame_glyphs_initially (); |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6244 return; |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6245 } |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6246 #endif /* macintosh */ |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32468
diff
changeset
|
6247 |
314 | 6248 /* If no window system has been specified, try to use the terminal. */ |
6249 if (! isatty (0)) | |
6250 { | |
16896
b2c51d6de440
(init_display): Use `fatal'.
Richard M. Stallman <rms@gnu.org>
parents:
16891
diff
changeset
|
6251 fatal ("standard input is not a tty"); |
314 | 6252 exit (1); |
6253 } | |
6254 | |
6255 /* Look at the TERM variable */ | |
6256 terminal_type = (char *) getenv ("TERM"); | |
6257 if (!terminal_type) | |
6258 { | |
6259 #ifdef VMS | |
6260 fprintf (stderr, "Please specify your terminal type.\n\ | |
6261 For types defined in VMS, use set term /device=TYPE.\n\ | |
6262 For types not defined in VMS, use define emacs_term \"TYPE\".\n\ | |
6263 \(The quotation marks are necessary since terminal types are lower case.)\n"); | |
6264 #else | |
6265 fprintf (stderr, "Please set the environment variable TERM; see tset(1).\n"); | |
6266 #endif | |
6267 exit (1); | |
6268 } | |
6269 | |
6270 #ifdef VMS | |
25012 | 6271 /* VMS DCL tends to up-case things, so down-case term type. |
314 | 6272 Hardly any uppercase letters in terminal types; should be none. */ |
6273 { | |
6274 char *new = (char *) xmalloc (strlen (terminal_type) + 1); | |
6275 char *p; | |
6276 | |
6277 strcpy (new, terminal_type); | |
6278 | |
6279 for (p = new; *p; p++) | |
6280 if (isupper (*p)) | |
6281 *p = tolower (*p); | |
6282 | |
6283 terminal_type = new; | |
6284 } | |
25012 | 6285 #endif /* VMS */ |
314 | 6286 |
6287 term_init (terminal_type); | |
25012 | 6288 |
16891
989845750a4d
(init_display): Check for overflow in screen size.
Richard M. Stallman <rms@gnu.org>
parents:
16881
diff
changeset
|
6289 { |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6290 struct frame *sf = SELECTED_FRAME (); |
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6291 int width = FRAME_WINDOW_WIDTH (sf); |
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6292 int height = FRAME_HEIGHT (sf); |
16891
989845750a4d
(init_display): Check for overflow in screen size.
Richard M. Stallman <rms@gnu.org>
parents:
16881
diff
changeset
|
6293 |
25012 | 6294 unsigned int total_glyphs = height * (width + 2) * sizeof (struct glyph); |
6295 | |
6296 /* If these sizes are so big they cause overflow, just ignore the | |
6297 change. It's not clear what better we could do. */ | |
6298 if (total_glyphs / sizeof (struct glyph) / height != width + 2) | |
16896
b2c51d6de440
(init_display): Use `fatal'.
Richard M. Stallman <rms@gnu.org>
parents:
16891
diff
changeset
|
6299 fatal ("screen size %dx%d too big", width, height); |
16891
989845750a4d
(init_display): Check for overflow in screen size.
Richard M. Stallman <rms@gnu.org>
parents:
16881
diff
changeset
|
6300 } |
989845750a4d
(init_display): Check for overflow in screen size.
Richard M. Stallman <rms@gnu.org>
parents:
16881
diff
changeset
|
6301 |
25012 | 6302 adjust_frame_glyphs_initially (); |
25666
063da8f6a487
(selected_frame): Make it a Lisp_Object.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6303 calculate_costs (XFRAME (selected_frame)); |
314 | 6304 |
6305 #ifdef SIGWINCH | |
6306 #ifndef CANNOT_DUMP | |
6307 if (initialized) | |
6308 #endif /* CANNOT_DUMP */ | |
6309 signal (SIGWINCH, window_change_signal); | |
6310 #endif /* SIGWINCH */ | |
25012 | 6311 |
6312 /* Set up faces of the initial terminal frame of a dumped Emacs. */ | |
6313 if (initialized | |
6314 && !noninteractive | |
25118
08ae9ffe6763
(init_display) [MSDOS]: Don't initialize frame faces,
Eli Zaretskii <eliz@gnu.org>
parents:
25012
diff
changeset
|
6315 #ifdef MSDOS |
08ae9ffe6763
(init_display) [MSDOS]: Don't initialize frame faces,
Eli Zaretskii <eliz@gnu.org>
parents:
25012
diff
changeset
|
6316 /* The MSDOS terminal turns on its ``window system'' relatively |
08ae9ffe6763
(init_display) [MSDOS]: Don't initialize frame faces,
Eli Zaretskii <eliz@gnu.org>
parents:
25012
diff
changeset
|
6317 late into the startup, so we cannot do the frame faces' |
08ae9ffe6763
(init_display) [MSDOS]: Don't initialize frame faces,
Eli Zaretskii <eliz@gnu.org>
parents:
25012
diff
changeset
|
6318 initialization just yet. It will be done later by pc-win.el |
08ae9ffe6763
(init_display) [MSDOS]: Don't initialize frame faces,
Eli Zaretskii <eliz@gnu.org>
parents:
25012
diff
changeset
|
6319 and internal_terminal_init. */ |
08ae9ffe6763
(init_display) [MSDOS]: Don't initialize frame faces,
Eli Zaretskii <eliz@gnu.org>
parents:
25012
diff
changeset
|
6320 && (strcmp (terminal_type, "internal") != 0 || inhibit_window_system) |
08ae9ffe6763
(init_display) [MSDOS]: Don't initialize frame faces,
Eli Zaretskii <eliz@gnu.org>
parents:
25012
diff
changeset
|
6321 #endif |
25012 | 6322 && NILP (Vwindow_system)) |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26591
diff
changeset
|
6323 { |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26591
diff
changeset
|
6324 /* For the initial frame, we don't have any way of knowing what |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26591
diff
changeset
|
6325 are the foreground and background colors of the terminal. */ |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26591
diff
changeset
|
6326 struct frame *sf = SELECTED_FRAME(); |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26591
diff
changeset
|
6327 |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26851
diff
changeset
|
6328 FRAME_FOREGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_FG_COLOR; |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26851
diff
changeset
|
6329 FRAME_BACKGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_BG_COLOR; |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26591
diff
changeset
|
6330 call0 (intern ("tty-set-up-initial-frame-faces")); |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26591
diff
changeset
|
6331 } |
314 | 6332 } |
25012 | 6333 |
6334 | |
314 | 6335 |
25012 | 6336 /*********************************************************************** |
6337 Blinking cursor | |
6338 ***********************************************************************/ | |
6339 | |
26280
083835afced5
(Finternal_show_cursor): Renamed from Fshow_cursor.
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
6340 DEFUN ("internal-show-cursor", Finternal_show_cursor, |
26334
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6341 Sinternal_show_cursor, 2, 2, 0, |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6342 "Set the cursor-visibility flag of WINDOW to SHOW.\n\ |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6343 WINDOW nil means use the selected window. SHOW non-nil means\n\ |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6344 show a cursor in WINDOW in the next redisplay. SHOW nil means\n\ |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6345 don't show a cursor.") |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6346 (window, show) |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6347 Lisp_Object window, show; |
25012 | 6348 { |
6349 /* Don't change cursor state while redisplaying. This could confuse | |
6350 output routines. */ | |
6351 if (!redisplaying_p) | |
6352 { | |
6353 if (NILP (window)) | |
6354 window = selected_window; | |
6355 else | |
6356 CHECK_WINDOW (window, 2); | |
6357 | |
26334
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6358 XWINDOW (window)->cursor_off_p = NILP (show); |
25012 | 6359 } |
6360 | |
6361 return Qnil; | |
6362 } | |
6363 | |
6364 | |
26334
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6365 DEFUN ("internal-show-cursor-p", Finternal_show_cursor_p, |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6366 Sinternal_show_cursor_p, 0, 1, 0, |
26499
10af169a628b
(Finternal_show_cursor_p): Fix doc string.
Dave Love <fx@gnu.org>
parents:
26334
diff
changeset
|
6367 "Value is non-nil if next redisplay will display a cursor in WINDOW.\n\ |
26334
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6368 WINDOW nil or omitted means report on the selected window.") |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6369 (window) |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6370 Lisp_Object window; |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6371 { |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6372 struct window *w; |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6373 |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6374 if (NILP (window)) |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6375 window = selected_window; |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6376 else |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6377 CHECK_WINDOW (window, 2); |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6378 |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6379 w = XWINDOW (window); |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6380 return w->cursor_off_p ? Qnil : Qt; |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6381 } |
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6382 |
25012 | 6383 |
6384 /*********************************************************************** | |
6385 Initialization | |
6386 ***********************************************************************/ | |
6387 | |
21514 | 6388 void |
314 | 6389 syms_of_display () |
6390 { | |
764 | 6391 defsubr (&Sredraw_frame); |
314 | 6392 defsubr (&Sredraw_display); |
7810
15c0bf73737e
(Fframe_or_buffer_changed_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
7808
diff
changeset
|
6393 defsubr (&Sframe_or_buffer_changed_p); |
314 | 6394 defsubr (&Sopen_termscript); |
6395 defsubr (&Sding); | |
6396 defsubr (&Ssit_for); | |
6397 defsubr (&Ssleep_for); | |
6398 defsubr (&Ssend_string_to_terminal); | |
26280
083835afced5
(Finternal_show_cursor): Renamed from Fshow_cursor.
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
6399 defsubr (&Sinternal_show_cursor); |
26334
e3a9ceb7a557
(Finternal_show_cursor): Change it to set the
Gerd Moellmann <gerd@gnu.org>
parents:
26280
diff
changeset
|
6400 defsubr (&Sinternal_show_cursor_p); |
314 | 6401 |
12186
6811992e871c
(Fframe_or_buffer_changed_p): Calculate vector size right.
Karl Heuer <kwzh@gnu.org>
parents:
11919
diff
changeset
|
6402 frame_and_buffer_state = Fmake_vector (make_number (20), Qlambda); |
7810
15c0bf73737e
(Fframe_or_buffer_changed_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
7808
diff
changeset
|
6403 staticpro (&frame_and_buffer_state); |
15c0bf73737e
(Fframe_or_buffer_changed_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
7808
diff
changeset
|
6404 |
13220
2e9014617492
(Qdisplay_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13105
diff
changeset
|
6405 Qdisplay_table = intern ("display-table"); |
2e9014617492
(Qdisplay_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13105
diff
changeset
|
6406 staticpro (&Qdisplay_table); |
30720
64f3338f72d8
(Qredisplay_dont_pause): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
30713
diff
changeset
|
6407 Qredisplay_dont_pause = intern ("redisplay-dont-pause"); |
64f3338f72d8
(Qredisplay_dont_pause): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
30713
diff
changeset
|
6408 staticpro (&Qredisplay_dont_pause); |
13220
2e9014617492
(Qdisplay_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13105
diff
changeset
|
6409 |
314 | 6410 DEFVAR_INT ("baud-rate", &baud_rate, |
7926
b87f2c705501
(syms_of_display): Make baud-rate a user var.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
6411 "*The output baud rate of the terminal.\n\ |
314 | 6412 On most systems, changing this value will affect the amount of padding\n\ |
6413 and the other strategic decisions made during redisplay."); | |
25012 | 6414 |
314 | 6415 DEFVAR_BOOL ("inverse-video", &inverse_video, |
764 | 6416 "*Non-nil means invert the entire frame display.\n\ |
314 | 6417 This means everything is in inverse video which otherwise would not be."); |
25012 | 6418 |
314 | 6419 DEFVAR_BOOL ("visible-bell", &visible_bell, |
764 | 6420 "*Non-nil means try to flash the frame to represent a bell."); |
25012 | 6421 |
314 | 6422 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter, |
764 | 6423 "*Non-nil means no need to redraw entire frame after suspending.\n\ |
314 | 6424 A non-nil value is useful if the terminal can automatically preserve\n\ |
764 | 6425 Emacs's frame display when you reenter Emacs.\n\ |
314 | 6426 It is up to you to set this variable if your terminal can do that."); |
25012 | 6427 |
314 | 6428 DEFVAR_LISP ("window-system", &Vwindow_system, |
6429 "A symbol naming the window-system under which Emacs is running\n\ | |
6430 \(such as `x'), or nil if emacs is running on an ordinary terminal."); | |
25012 | 6431 |
314 | 6432 DEFVAR_LISP ("window-system-version", &Vwindow_system_version, |
6433 "The version number of the window system in use.\n\ | |
6434 For X windows, this is 10 or 11."); | |
25012 | 6435 |
314 | 6436 DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area, |
6437 "Non-nil means put cursor in minibuffer, at end of any message there."); | |
25012 | 6438 |
314 | 6439 DEFVAR_LISP ("glyph-table", &Vglyph_table, |
764 | 6440 "Table defining how to output a glyph code to the frame.\n\ |
314 | 6441 If not nil, this is a vector indexed by glyph code to define the glyph.\n\ |
6442 Each element can be:\n\ | |
6443 integer: a glyph code which this glyph is an alias for.\n\ | |
6444 string: output this glyph using that string (not impl. in X windows).\n\ | |
6445 nil: this glyph mod 256 is char code to output,\n\ | |
6857 | 6446 and this glyph / 256 is face code for X windows (see `face-id')."); |
314 | 6447 Vglyph_table = Qnil; |
6448 | |
6449 DEFVAR_LISP ("standard-display-table", &Vstandard_display_table, | |
6450 "Display table to use for buffers that specify none.\n\ | |
6451 See `buffer-display-table' for more information."); | |
6452 Vstandard_display_table = Qnil; | |
6453 | |
25012 | 6454 DEFVAR_BOOL ("redisplay-dont-pause", &redisplay_dont_pause, |
6455 "*Non-nil means update isn't paused when input is detected."); | |
6456 redisplay_dont_pause = 0; | |
6457 | |
314 | 6458 /* Initialize `window-system', unless init_display already decided it. */ |
6459 #ifdef CANNOT_DUMP | |
6460 if (noninteractive) | |
6461 #endif | |
6462 { | |
6463 Vwindow_system = Qnil; | |
6464 Vwindow_system_version = Qnil; | |
6465 } | |
6466 } |