277
|
1 /* Display generation from window structure and buffer text.
|
5658
|
2 Copyright (C) 1985, 86, 87, 88, 93, 94 Free Software Foundation, Inc.
|
277
|
3
|
|
4 This file is part of GNU Emacs.
|
|
5
|
|
6 GNU Emacs is free software; you can redistribute it and/or modify
|
|
7 it under the terms of the GNU General Public License as published by
|
1785
|
8 the Free Software Foundation; either version 2, or (at your option)
|
277
|
9 any later version.
|
|
10
|
|
11 GNU Emacs is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 GNU General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with GNU Emacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
19
|
|
20
|
4696
|
21 #include <config.h>
|
277
|
22 #include <stdio.h>
|
|
23 /*#include <ctype.h>*/
|
|
24 #undef NULL
|
|
25 #include "lisp.h"
|
769
|
26 #include "frame.h"
|
277
|
27 #include "window.h"
|
|
28 #include "termchar.h"
|
|
29 #include "dispextern.h"
|
|
30 #include "buffer.h"
|
|
31 #include "indent.h"
|
|
32 #include "commands.h"
|
|
33 #include "macros.h"
|
|
34 #include "disptab.h"
|
1718
|
35 #include "termhooks.h"
|
4386
|
36 #include "intervals.h"
|
277
|
37
|
5658
|
38 #ifdef USE_X_TOOLKIT
|
|
39 extern void set_frame_menubar ();
|
|
40 #endif
|
|
41
|
277
|
42 extern int interrupt_input;
|
|
43 extern int command_loop_level;
|
|
44
|
|
45 /* Nonzero means print newline before next minibuffer message. */
|
|
46
|
|
47 int noninteractive_need_newline;
|
|
48
|
|
49 #define min(a, b) ((a) < (b) ? (a) : (b))
|
|
50 #define max(a, b) ((a) > (b) ? (a) : (b))
|
|
51
|
|
52 /* The buffer position of the first character appearing
|
769
|
53 entirely or partially on the current frame line.
|
|
54 Or zero, which disables the optimization for the current frame line. */
|
277
|
55 static int this_line_bufpos;
|
|
56
|
|
57 /* Number of characters past the end of this line,
|
|
58 including the terminating newline */
|
|
59 static int this_line_endpos;
|
|
60
|
769
|
61 /* The vertical position of this frame line. */
|
277
|
62 static int this_line_vpos;
|
|
63
|
769
|
64 /* Hpos value for start of display on this frame line.
|
277
|
65 Usually zero, but negative if first character really began
|
|
66 on previous line */
|
|
67 static int this_line_start_hpos;
|
|
68
|
|
69 /* Buffer that this_line variables are describing. */
|
|
70 static struct buffer *this_line_buffer;
|
|
71
|
|
72 /* Set by try_window_id to the vpos of first of any lines
|
769
|
73 scrolled on to the bottom of the frame. These lines should
|
277
|
74 not be included in any general scroll computation. */
|
|
75 static int scroll_bottom_vpos;
|
|
76
|
|
77 /* Value of echo_area_glyphs when it was last acted on.
|
769
|
78 If this is nonzero, there is a message on the frame
|
277
|
79 in the minibuffer and it should be erased as soon
|
|
80 as it is no longer requested to appear. */
|
|
81 char *previous_echo_glyphs;
|
|
82
|
769
|
83 /* Nonzero means truncate lines in all windows less wide than the frame */
|
277
|
84 int truncate_partial_width_windows;
|
|
85
|
|
86 Lisp_Object Vglobal_mode_string;
|
|
87
|
|
88 /* Marker for where to display an arrow on top of the buffer text. */
|
|
89 Lisp_Object Voverlay_arrow_position;
|
|
90
|
|
91 /* String to display for the arrow. */
|
|
92 Lisp_Object Voverlay_arrow_string;
|
|
93
|
|
94 /* Values of those variables at last redisplay. */
|
1527
|
95 static Lisp_Object last_arrow_position, last_arrow_string;
|
277
|
96
|
|
97 /* Nonzero if overlay arrow has been displayed once in this window. */
|
|
98 static int overlay_arrow_seen;
|
|
99
|
3265
|
100 /* Nonzero means highlight the region even in nonselected windows. */
|
|
101 static int highlight_nonselected_windows;
|
|
102
|
769
|
103 /* If cursor motion alone moves point off frame,
|
277
|
104 Try scrolling this many lines up or down if that will bring it back. */
|
|
105 int scroll_step;
|
|
106
|
|
107 /* Nonzero if try_window_id has made blank lines at window bottom
|
|
108 since the last redisplay that paused */
|
|
109 static int blank_end_of_window;
|
|
110
|
|
111 /* Number of windows showing the buffer of the selected window.
|
|
112 keyboard.c refers to this. */
|
|
113 int buffer_shared;
|
|
114
|
769
|
115 /* display_text_line sets these to the frame position (origin 0) of point,
|
277
|
116 whether the window is selected or not.
|
|
117 Set one to -1 first to determine whether point was found afterwards. */
|
|
118
|
|
119 static int cursor_vpos;
|
|
120 static int cursor_hpos;
|
|
121
|
|
122 int debug_end_pos;
|
|
123
|
|
124 /* Nonzero means display mode line highlighted */
|
|
125 int mode_line_inverse_video;
|
|
126
|
|
127 static void echo_area_display ();
|
|
128 void mark_window_display_accurate ();
|
|
129 static void redisplay_windows ();
|
|
130 static void redisplay_window ();
|
5230
|
131 static void update_menu_bars ();
|
|
132 static void update_menu_bar ();
|
277
|
133 static void try_window ();
|
|
134 static int try_window_id ();
|
|
135 static struct position *display_text_line ();
|
|
136 static void display_mode_line ();
|
|
137 static int display_mode_element ();
|
|
138 static char *fmodetrunc ();
|
|
139 static char *decode_mode_spec ();
|
|
140 static int display_string ();
|
2150
|
141 static void display_menu_bar ();
|
2303
|
142 static int display_count_lines ();
|
277
|
143
|
|
144 /* Prompt to display in front of the minibuffer contents */
|
|
145 char *minibuf_prompt;
|
|
146
|
|
147 /* Width in columns of current minibuffer prompt. */
|
|
148 int minibuf_prompt_width;
|
|
149
|
|
150 /* Message to display instead of minibuffer contents
|
|
151 This is what the functions error and message make,
|
|
152 and command echoing uses it as well.
|
|
153 It overrides the minibuf_prompt as well as the buffer. */
|
|
154 char *echo_area_glyphs;
|
|
155
|
5230
|
156 /* This is the length of the message in echo_area_glyphs. */
|
|
157 int echo_area_glyphs_length;
|
|
158
|
277
|
159 /* true iff we should redraw the mode lines on the next redisplay */
|
|
160 int update_mode_lines;
|
|
161
|
|
162 /* Smallest number of characters before the gap
|
|
163 at any time since last redisplay that finished.
|
|
164 Valid for current buffer when try_window_id can be called. */
|
|
165 int beg_unchanged;
|
|
166
|
|
167 /* Smallest number of characters after the gap
|
|
168 at any time since last redisplay that finished.
|
|
169 Valid for current buffer when try_window_id can be called. */
|
|
170 int end_unchanged;
|
|
171
|
|
172 /* MODIFF as of last redisplay that finished;
|
|
173 if it matches MODIFF, beg_unchanged and end_unchanged
|
|
174 contain no useful information */
|
|
175 int unchanged_modified;
|
|
176
|
|
177 /* Nonzero if head_clip or tail_clip of current buffer has changed
|
|
178 since last redisplay that finished */
|
|
179 int clip_changed;
|
|
180
|
|
181 /* Nonzero if window sizes or contents have changed
|
|
182 since last redisplay that finished */
|
|
183 int windows_or_buffers_changed;
|
|
184
|
2303
|
185 /* Nonzero after display_mode_line if %l was used
|
|
186 and it displayed a line number. */
|
|
187 int line_number_displayed;
|
|
188
|
|
189 /* Maximum buffer size for which to display line numbers. */
|
|
190 int line_number_display_limit;
|
277
|
191
|
1527
|
192 /* Specify m, a string, as a message in the minibuf. If m is 0, clear out
|
|
193 any existing message, and let the minibuffer text show through. */
|
5230
|
194
|
1527
|
195 void
|
|
196 message1 (m)
|
|
197 char *m;
|
|
198 {
|
|
199 if (noninteractive)
|
|
200 {
|
|
201 if (noninteractive_need_newline)
|
|
202 putc ('\n', stderr);
|
|
203 noninteractive_need_newline = 0;
|
2526
|
204 if (cursor_in_echo_area != 0)
|
|
205 fprintf (stderr, "%s", m);
|
|
206 else
|
|
207 fprintf (stderr, "%s\n", m);
|
1527
|
208 fflush (stderr);
|
|
209 }
|
|
210 /* A null message buffer means that the frame hasn't really been
|
|
211 initialized yet. Error messages get reported properly by
|
|
212 cmd_error, so this must be just an informative message; toss it. */
|
|
213 else if (INTERACTIVE && FRAME_MESSAGE_BUF (selected_frame))
|
|
214 {
|
|
215 #ifdef MULTI_FRAME
|
|
216 Lisp_Object minibuf_frame;
|
|
217
|
|
218 choose_minibuf_frame ();
|
|
219 minibuf_frame = WINDOW_FRAME (XWINDOW (minibuf_window));
|
1656
|
220 FRAME_SAMPLE_VISIBILITY (XFRAME (minibuf_frame));
|
1527
|
221 if (FRAME_VISIBLE_P (selected_frame)
|
|
222 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame)))
|
|
223 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window)));
|
|
224 #endif
|
|
225
|
|
226 if (m)
|
5230
|
227 {
|
|
228 echo_area_glyphs = m;
|
|
229 echo_area_glyphs_length = strlen (m);
|
|
230 }
|
|
231 else
|
|
232 echo_area_glyphs = previous_echo_glyphs = 0;
|
|
233
|
|
234 do_pending_window_change ();
|
|
235 echo_area_display ();
|
|
236 update_frame (XFRAME (XWINDOW (minibuf_window)->frame), 1, 1);
|
|
237 do_pending_window_change ();
|
|
238 }
|
|
239 }
|
|
240
|
|
241 /* Display an echo area message M with a specified length of LEN chars.
|
5883
|
242 This way, null characters can be included. Do not pass text that is
|
|
243 stored in a Lisp string. */
|
5230
|
244
|
|
245 void
|
|
246 message2 (m, len)
|
|
247 char *m;
|
|
248 int len;
|
|
249 {
|
|
250 if (noninteractive)
|
|
251 {
|
|
252 if (noninteractive_need_newline)
|
|
253 putc ('\n', stderr);
|
|
254 noninteractive_need_newline = 0;
|
|
255 fwrite (m, len, 1, stderr);
|
|
256 if (cursor_in_echo_area == 0)
|
|
257 fprintf (stderr, "\n");
|
|
258 fflush (stderr);
|
|
259 }
|
|
260 /* A null message buffer means that the frame hasn't really been
|
|
261 initialized yet. Error messages get reported properly by
|
|
262 cmd_error, so this must be just an informative message; toss it. */
|
|
263 else if (INTERACTIVE && FRAME_MESSAGE_BUF (selected_frame))
|
|
264 {
|
|
265 #ifdef MULTI_FRAME
|
|
266 Lisp_Object minibuf_frame;
|
|
267
|
|
268 choose_minibuf_frame ();
|
|
269 minibuf_frame = WINDOW_FRAME (XWINDOW (minibuf_window));
|
|
270 FRAME_SAMPLE_VISIBILITY (XFRAME (minibuf_frame));
|
|
271 if (FRAME_VISIBLE_P (selected_frame)
|
|
272 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame)))
|
|
273 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window)));
|
|
274 #endif
|
|
275
|
|
276 if (m)
|
|
277 {
|
|
278 echo_area_glyphs = m;
|
|
279 echo_area_glyphs_length = len;
|
|
280 }
|
1527
|
281 else
|
|
282 echo_area_glyphs = previous_echo_glyphs = 0;
|
|
283
|
|
284 do_pending_window_change ();
|
|
285 echo_area_display ();
|
|
286 update_frame (XFRAME (XWINDOW (minibuf_window)->frame), 1, 1);
|
|
287 do_pending_window_change ();
|
|
288 }
|
|
289 }
|
|
290
|
5658
|
291 /* Truncate what will be displayed in the echo area
|
|
292 the next time we display it--but don't redisplay it now. */
|
|
293
|
|
294 void
|
|
295 truncate_echo_area (len)
|
|
296 int len;
|
|
297 {
|
|
298 /* A null message buffer means that the frame hasn't really been
|
|
299 initialized yet. Error messages get reported properly by
|
|
300 cmd_error, so this must be just an informative message; toss it. */
|
|
301 if (!noninteractive && INTERACTIVE && FRAME_MESSAGE_BUF (selected_frame))
|
|
302 echo_area_glyphs_length = len;
|
|
303 }
|
|
304
|
769
|
305 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
|
331
|
306 zero if being used by message. */
|
|
307 int message_buf_print;
|
|
308
|
1446
|
309 /* Dump an informative message to the minibuf. If m is 0, clear out
|
|
310 any existing message, and let the minibuffer text show through. */
|
277
|
311 /* VARARGS 1 */
|
|
312 void
|
|
313 message (m, a1, a2, a3)
|
|
314 char *m;
|
|
315 {
|
|
316 if (noninteractive)
|
|
317 {
|
1446
|
318 if (m)
|
|
319 {
|
|
320 if (noninteractive_need_newline)
|
|
321 putc ('\n', stderr);
|
|
322 noninteractive_need_newline = 0;
|
|
323 fprintf (stderr, m, a1, a2, a3);
|
2526
|
324 if (cursor_in_echo_area == 0)
|
|
325 fprintf (stderr, "\n");
|
1446
|
326 fflush (stderr);
|
|
327 }
|
277
|
328 }
|
1873
|
329 else if (INTERACTIVE)
|
277
|
330 {
|
1873
|
331 /* The frame whose minibuffer we're going to display the message on.
|
|
332 It may be larger than the selected frame, so we need
|
|
333 to use its buffer, not the selected frame's buffer. */
|
|
334 FRAME_PTR echo_frame;
|
|
335 #ifdef MULTI_FRAME
|
|
336 choose_minibuf_frame ();
|
|
337 echo_frame = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window)));
|
|
338 #else
|
|
339 echo_frame = selected_frame;
|
|
340 #endif
|
277
|
341
|
1873
|
342 /* A null message buffer means that the frame hasn't really been
|
|
343 initialized yet. Error messages get reported properly by
|
|
344 cmd_error, so this must be just an informative message; toss it. */
|
|
345 if (FRAME_MESSAGE_BUF (echo_frame))
|
|
346 {
|
|
347 if (m)
|
|
348 {
|
5230
|
349 int len;
|
1873
|
350 #ifdef NO_ARG_ARRAY
|
5230
|
351 int a[3];
|
|
352 a[0] = a1;
|
|
353 a[1] = a2;
|
|
354 a[2] = a3;
|
|
355
|
|
356 len = doprnt (FRAME_MESSAGE_BUF (echo_frame),
|
|
357 FRAME_WIDTH (echo_frame), m, 0, 3, a);
|
1873
|
358 #else
|
5230
|
359 len = doprnt (FRAME_MESSAGE_BUF (echo_frame),
|
|
360 FRAME_WIDTH (echo_frame), m, 0, 3, &a1);
|
1873
|
361 #endif /* NO_ARG_ARRAY */
|
5230
|
362
|
|
363 message2 (FRAME_MESSAGE_BUF (echo_frame), len);
|
1873
|
364 }
|
|
365 else
|
|
366 message1 (0);
|
|
367
|
|
368 /* Print should start at the beginning of the message
|
|
369 buffer next time. */
|
|
370 message_buf_print = 0;
|
1446
|
371 }
|
277
|
372 }
|
|
373 }
|
|
374
|
|
375 static void
|
|
376 echo_area_display ()
|
|
377 {
|
|
378 register int vpos;
|
769
|
379 FRAME_PTR f;
|
277
|
380
|
769
|
381 #ifdef MULTI_FRAME
|
|
382 choose_minibuf_frame ();
|
1785
|
383 #endif
|
|
384
|
769
|
385 f = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window)));
|
277
|
386
|
769
|
387 if (! FRAME_VISIBLE_P (f))
|
277
|
388 return;
|
|
389
|
769
|
390 if (frame_garbaged)
|
277
|
391 {
|
3516
|
392 redraw_garbaged_frames ();
|
769
|
393 frame_garbaged = 0;
|
277
|
394 }
|
|
395
|
|
396 if (echo_area_glyphs || minibuf_level == 0)
|
|
397 {
|
|
398 vpos = XFASTINT (XWINDOW (minibuf_window)->top);
|
769
|
399 get_display_line (f, vpos, 0);
|
277
|
400 display_string (XWINDOW (minibuf_window), vpos,
|
|
401 echo_area_glyphs ? echo_area_glyphs : "",
|
5230
|
402 echo_area_glyphs ? echo_area_glyphs_length : -1,
|
5800
|
403 0, 0, 0, 0, FRAME_WIDTH (f));
|
277
|
404
|
|
405 /* If desired cursor location is on this line, put it at end of text */
|
769
|
406 if (FRAME_CURSOR_Y (f) == vpos)
|
|
407 FRAME_CURSOR_X (f) = FRAME_DESIRED_GLYPHS (f)->used[vpos];
|
727
|
408
|
|
409 /* Fill the rest of the minibuffer window with blank lines. */
|
|
410 {
|
|
411 int i;
|
|
412
|
3689
|
413 for (i = vpos + 1;
|
|
414 i < vpos + XFASTINT (XWINDOW (minibuf_window)->height); i++)
|
727
|
415 {
|
769
|
416 get_display_line (f, i, 0);
|
727
|
417 display_string (XWINDOW (minibuf_window), vpos,
|
5800
|
418 "", 0, 0, 0, 0, 0, FRAME_WIDTH (f));
|
727
|
419 }
|
|
420 }
|
277
|
421 }
|
|
422 else if (!EQ (minibuf_window, selected_window))
|
|
423 windows_or_buffers_changed++;
|
|
424
|
|
425 if (EQ (minibuf_window, selected_window))
|
|
426 this_line_bufpos = 0;
|
|
427
|
|
428 previous_echo_glyphs = echo_area_glyphs;
|
|
429 }
|
6308
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
430
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
431 #ifdef HAVE_X_WINDOWS
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
432 /* I'm trying this out because I saw Unimpress use it, but it's
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
433 possible that this may mess adversely with some window managers. -jla
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
434
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
435 Wouldn't it be nice to use something like mode-line-format to
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
436 describe frame titles? -JimB */
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
437
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
438 /* Change the title of the frame to the name of the buffer displayed
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
439 in the currently selected window. Don't do this for minibuffer frames,
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
440 and don't do it when there's only one non-minibuffer frame. */
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
441 static void
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
442 x_consider_frame_title (frame)
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
443 Lisp_Object frame;
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
444 {
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
445 FRAME_PTR f = XFRAME (frame);
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
446
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
447 if (FRAME_X_P (f) && ! FRAME_MINIBUF_ONLY_P (f))
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
448 {
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
449 Lisp_Object title = Qnil;
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
450
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
451 if (! EQ (Fnext_frame (frame, Qnil), frame))
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
452 title = XBUFFER (XWINDOW (f->selected_window)->buffer)->name;
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
453
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
454 x_implicitly_set_name (f, title, Qnil);
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
455 }
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
456 }
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
457 #endif
|
277
|
458
|
5230
|
459 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
|
|
460 This can't be done in `redisplay' itself because it can call eval. */
|
|
461
|
|
462 void
|
|
463 prepare_menu_bars ()
|
|
464 {
|
|
465 register struct window *w = XWINDOW (selected_window);
|
|
466 int all_windows;
|
|
467
|
|
468 if (noninteractive)
|
|
469 return;
|
|
470
|
|
471 /* Set the visible flags for all frames.
|
|
472 Do this before checking for resized or garbaged frames; they want
|
|
473 to know if their frames are visible.
|
|
474 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
|
|
475 {
|
|
476 Lisp_Object tail, frame;
|
|
477
|
|
478 FOR_EACH_FRAME (tail, frame)
|
|
479 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
|
|
480 }
|
|
481
|
|
482 /* Notice any pending interrupt request to change frame size. */
|
|
483 do_pending_window_change ();
|
|
484
|
|
485 if (frame_garbaged)
|
|
486 {
|
|
487 redraw_garbaged_frames ();
|
|
488 frame_garbaged = 0;
|
|
489 }
|
|
490
|
|
491 if (clip_changed || windows_or_buffers_changed)
|
|
492 update_mode_lines++;
|
|
493
|
|
494 /* Detect case that we need to write a star in the mode line. */
|
|
495 if (XFASTINT (w->last_modified) < MODIFF
|
|
496 && XFASTINT (w->last_modified) <= current_buffer->save_modified)
|
|
497 {
|
|
498 w->update_mode_line = Qt;
|
|
499 if (buffer_shared > 1)
|
|
500 update_mode_lines++;
|
|
501 }
|
|
502
|
|
503 all_windows = update_mode_lines || buffer_shared > 1;
|
|
504
|
|
505 /* If specs for an arrow have changed, do thorough redisplay
|
|
506 to ensure we remove any arrow that should no longer exist. */
|
|
507 if (! EQ (Voverlay_arrow_position, last_arrow_position)
|
|
508 || ! EQ (Voverlay_arrow_string, last_arrow_string))
|
|
509 all_windows = 1, clip_changed = 1;
|
|
510
|
|
511 /* Update the menu bar item lists, if appropriate.
|
|
512 This has to be done before any actual redisplay
|
|
513 or generation of display lines. */
|
|
514 if (all_windows)
|
|
515 {
|
|
516 Lisp_Object tail, frame;
|
|
517
|
|
518 FOR_EACH_FRAME (tail, frame)
|
|
519 {
|
|
520 FRAME_PTR f = XFRAME (frame);
|
|
521
|
|
522 if (FRAME_VISIBLE_P (f))
|
|
523 update_menu_bars (FRAME_ROOT_WINDOW (f));
|
|
524 }
|
|
525 }
|
|
526 else if (FRAME_VISIBLE_P (selected_frame))
|
|
527 update_menu_bar (selected_window);
|
|
528 }
|
|
529
|
769
|
530 /* Do a frame update, taking possible shortcuts into account.
|
277
|
531 This is the main external entry point for redisplay.
|
|
532
|
|
533 If the last redisplay displayed an echo area message and that
|
|
534 message is no longer requested, we clear the echo area
|
|
535 or bring back the minibuffer if that is in use.
|
|
536
|
5230
|
537 Do not call eval from within this function.
|
|
538 Calls to eval after the call to echo_area_display would confuse
|
|
539 the display_line mechanism and would cause a crash.
|
|
540 Calls to eval before that point will work most of the time,
|
|
541 but can still lose, because this function
|
|
542 can be called from signal handlers; with alarms set up;
|
277
|
543 or with synchronous processes running.
|
5230
|
544
|
277
|
545 See Fcall_process; if you called it from here, it could be
|
|
546 entered recursively. */
|
|
547
|
|
548 void
|
|
549 redisplay ()
|
|
550 {
|
|
551 register struct window *w = XWINDOW (selected_window);
|
|
552 register int pause;
|
|
553 int must_finish = 0;
|
|
554 int all_windows;
|
|
555 register int tlbufpos, tlendpos;
|
|
556 struct position pos;
|
|
557 extern int input_pending;
|
|
558
|
|
559 if (noninteractive)
|
|
560 return;
|
|
561
|
1656
|
562 /* Set the visible flags for all frames.
|
|
563 Do this before checking for resized or garbaged frames; they want
|
|
564 to know if their frames are visible.
|
|
565 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
|
|
566 {
|
2252
|
567 Lisp_Object tail, frame;
|
1656
|
568
|
2252
|
569 FOR_EACH_FRAME (tail, frame)
|
|
570 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
|
1656
|
571 }
|
|
572
|
769
|
573 /* Notice any pending interrupt request to change frame size. */
|
277
|
574 do_pending_window_change ();
|
|
575
|
769
|
576 if (frame_garbaged)
|
277
|
577 {
|
3516
|
578 redraw_garbaged_frames ();
|
769
|
579 frame_garbaged = 0;
|
277
|
580 }
|
|
581
|
|
582 if (clip_changed || windows_or_buffers_changed)
|
|
583 update_mode_lines++;
|
|
584
|
|
585 /* Detect case that we need to write a star in the mode line. */
|
|
586 if (XFASTINT (w->last_modified) < MODIFF
|
|
587 && XFASTINT (w->last_modified) <= current_buffer->save_modified)
|
|
588 {
|
|
589 w->update_mode_line = Qt;
|
|
590 if (buffer_shared > 1)
|
|
591 update_mode_lines++;
|
|
592 }
|
|
593
|
769
|
594 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1;
|
277
|
595
|
|
596 all_windows = update_mode_lines || buffer_shared > 1;
|
|
597
|
|
598 /* If specs for an arrow have changed, do thorough redisplay
|
|
599 to ensure we remove any arrow that should no longer exist. */
|
1527
|
600 if (! EQ (Voverlay_arrow_position, last_arrow_position)
|
|
601 || ! EQ (Voverlay_arrow_string, last_arrow_string))
|
277
|
602 all_windows = 1, clip_changed = 1;
|
|
603
|
5230
|
604 /* Normally the message* functions will have already displayed and
|
|
605 updated the echo area, but the frame may have been trashed, or
|
|
606 the update may have been preempted, so display the echo area
|
|
607 again here. */
|
|
608 if (echo_area_glyphs || previous_echo_glyphs)
|
|
609 {
|
|
610 echo_area_display ();
|
|
611 must_finish = 1;
|
|
612 }
|
|
613
|
2848
|
614 /* If showing region, and mark has changed, must redisplay whole window. */
|
|
615 if (((!NILP (Vtransient_mark_mode)
|
|
616 && !NILP (XBUFFER (w->buffer)->mark_active))
|
|
617 != !NILP (w->region_showing))
|
3937
|
618 || (!NILP (w->region_showing)
|
|
619 && !EQ (w->region_showing,
|
|
620 Fmarker_position (XBUFFER (w->buffer)->mark))))
|
2848
|
621 this_line_bufpos = -1;
|
|
622
|
277
|
623 tlbufpos = this_line_bufpos;
|
|
624 tlendpos = this_line_endpos;
|
485
|
625 if (!all_windows && tlbufpos > 0 && NILP (w->update_mode_line)
|
769
|
626 && FRAME_VISIBLE_P (XFRAME (w->frame))
|
277
|
627 /* Make sure recorded data applies to current buffer, etc */
|
|
628 && this_line_buffer == current_buffer
|
|
629 && current_buffer == XBUFFER (w->buffer)
|
485
|
630 && NILP (w->force_start)
|
277
|
631 /* Point must be on the line that we have info recorded about */
|
|
632 && point >= tlbufpos
|
|
633 && point <= Z - tlendpos
|
|
634 /* All text outside that line, including its final newline,
|
|
635 must be unchanged */
|
|
636 && (XFASTINT (w->last_modified) >= MODIFF
|
|
637 || (beg_unchanged >= tlbufpos - 1
|
|
638 && GPT >= tlbufpos
|
528
|
639 /* If selective display, can't optimize
|
|
640 if the changes start at the beginning of the line. */
|
|
641 && ((XTYPE (current_buffer->selective_display) == Lisp_Int
|
|
642 && XINT (current_buffer->selective_display) > 0
|
|
643 ? (beg_unchanged >= tlbufpos
|
|
644 && GPT > tlbufpos)
|
|
645 : 1))
|
277
|
646 && end_unchanged >= tlendpos
|
|
647 && Z - GPT >= tlendpos)))
|
|
648 {
|
|
649 if (tlbufpos > BEGV && FETCH_CHAR (tlbufpos - 1) != '\n'
|
|
650 && (tlbufpos == ZV
|
|
651 || FETCH_CHAR (tlbufpos) == '\n'))
|
|
652 /* Former continuation line has disappeared by becoming empty */
|
|
653 goto cancel;
|
|
654 else if (XFASTINT (w->last_modified) < MODIFF
|
|
655 || MINI_WINDOW_P (w))
|
|
656 {
|
|
657 cursor_vpos = -1;
|
|
658 overlay_arrow_seen = 0;
|
|
659 display_text_line (w, tlbufpos, this_line_vpos, this_line_start_hpos,
|
|
660 pos_tab_offset (w, tlbufpos));
|
|
661 /* If line contains point, is not continued,
|
|
662 and ends at same distance from eob as before, we win */
|
|
663 if (cursor_vpos >= 0 && this_line_bufpos
|
|
664 && this_line_endpos == tlendpos)
|
|
665 {
|
769
|
666 if (XFASTINT (w->width) != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w))))
|
277
|
667 preserve_other_columns (w);
|
|
668 goto update;
|
|
669 }
|
|
670 else
|
|
671 goto cancel;
|
|
672 }
|
|
673 else if (point == XFASTINT (w->last_point))
|
|
674 {
|
|
675 if (!must_finish)
|
|
676 {
|
|
677 do_pending_window_change ();
|
|
678 return;
|
|
679 }
|
|
680 goto update;
|
|
681 }
|
2848
|
682 /* If highlighting the region, we can't just move the cursor. */
|
|
683 else if (! (!NILP (Vtransient_mark_mode)
|
|
684 && !NILP (current_buffer->mark_active))
|
|
685 && NILP (w->region_showing))
|
277
|
686 {
|
|
687 pos = *compute_motion (tlbufpos, 0,
|
|
688 XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0,
|
|
689 point, 2, - (1 << (SHORTBITS - 1)),
|
1785
|
690 window_internal_width (w) - 1,
|
574
|
691 XINT (w->hscroll),
|
|
692 pos_tab_offset (w, tlbufpos));
|
277
|
693 if (pos.vpos < 1)
|
|
694 {
|
769
|
695 FRAME_CURSOR_X (selected_frame)
|
277
|
696 = XFASTINT (w->left) + max (pos.hpos, 0);
|
769
|
697 FRAME_CURSOR_Y (selected_frame) = this_line_vpos;
|
277
|
698 goto update;
|
|
699 }
|
|
700 else
|
|
701 goto cancel;
|
|
702 }
|
|
703 cancel:
|
|
704 /* Text changed drastically or point moved off of line */
|
769
|
705 cancel_line (this_line_vpos, selected_frame);
|
277
|
706 }
|
|
707
|
|
708 this_line_bufpos = 0;
|
|
709 all_windows |= buffer_shared > 1;
|
|
710
|
|
711 if (all_windows)
|
|
712 {
|
2252
|
713 Lisp_Object tail, frame;
|
277
|
714
|
2729
|
715 #ifdef HAVE_X_WINDOWS
|
|
716 /* Since we're doing a thorough redisplay, we might as well
|
|
717 recompute all our display faces. */
|
|
718 clear_face_vector ();
|
|
719 #endif
|
|
720
|
277
|
721 /* Recompute # windows showing selected buffer.
|
433
|
722 This will be incremented each time such a window is displayed. */
|
277
|
723 buffer_shared = 0;
|
|
724
|
2252
|
725 FOR_EACH_FRAME (tail, frame)
|
1718
|
726 {
|
2252
|
727 FRAME_PTR f = XFRAME (frame);
|
|
728
|
1992
|
729 /* Mark all the scroll bars to be removed; we'll redeem the ones
|
1718
|
730 we want when we redisplay their windows. */
|
1992
|
731 if (condemn_scroll_bars_hook)
|
|
732 (*condemn_scroll_bars_hook) (f);
|
1718
|
733
|
|
734 if (FRAME_VISIBLE_P (f))
|
|
735 redisplay_windows (FRAME_ROOT_WINDOW (f));
|
6308
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
736 #ifdef HAVE_X_WINDOWS
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
737 else if (FRAME_ICONIFIED_P (f))
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
738 x_consider_frame_title (frame);
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
739 #endif
|
1718
|
740
|
1992
|
741 /* Any scroll bars which redisplay_windows should have nuked
|
1718
|
742 should now go away. */
|
1992
|
743 if (judge_scroll_bars_hook)
|
|
744 (*judge_scroll_bars_hook) (f);
|
1718
|
745 }
|
277
|
746 }
|
769
|
747 else if (FRAME_VISIBLE_P (selected_frame))
|
277
|
748 {
|
|
749 redisplay_window (selected_window, 1);
|
769
|
750 if (XFASTINT (w->width) != FRAME_WIDTH (selected_frame))
|
277
|
751 preserve_other_columns (w);
|
|
752 }
|
|
753
|
|
754 update:
|
|
755 /* Prevent various kinds of signals during display update.
|
|
756 stdio is not robust about handling signals,
|
|
757 which can cause an apparent I/O error. */
|
|
758 if (interrupt_input)
|
|
759 unrequest_sigio ();
|
|
760 stop_polling ();
|
|
761
|
769
|
762 #ifdef MULTI_FRAME
|
277
|
763 if (all_windows)
|
|
764 {
|
|
765 Lisp_Object tail;
|
|
766
|
|
767 pause = 0;
|
|
768
|
769
|
769 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
|
277
|
770 {
|
769
|
771 FRAME_PTR f;
|
277
|
772
|
769
|
773 if (XTYPE (XCONS (tail)->car) != Lisp_Frame)
|
277
|
774 continue;
|
|
775
|
769
|
776 f = XFRAME (XCONS (tail)->car);
|
1718
|
777 if (FRAME_VISIBLE_P (f))
|
277
|
778 {
|
769
|
779 pause |= update_frame (f, 0, 0);
|
277
|
780 if (!pause)
|
769
|
781 mark_window_display_accurate (f->root_window, 1);
|
277
|
782 }
|
|
783 }
|
|
784 }
|
|
785 else
|
769
|
786 #endif /* MULTI_FRAME */
|
368
|
787 {
|
769
|
788 if (FRAME_VISIBLE_P (selected_frame))
|
|
789 pause = update_frame (selected_frame, 0, 0);
|
1656
|
790
|
433
|
791 /* We may have called echo_area_display at the top of this
|
769
|
792 function. If the echo area is on another frame, that may
|
|
793 have put text on a frame other than the selected one, so the
|
|
794 above call to update_frame would not have caught it. Catch
|
433
|
795 it here. */
|
|
796 {
|
769
|
797 FRAME_PTR mini_frame =
|
|
798 XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window)));
|
433
|
799
|
769
|
800 if (mini_frame != selected_frame)
|
|
801 pause |= update_frame (mini_frame, 0, 0);
|
433
|
802 }
|
368
|
803 }
|
277
|
804
|
769
|
805 /* If frame does not match, prevent doing single-line-update next time.
|
277
|
806 Also, don't forget to check every line to update the arrow. */
|
|
807 if (pause)
|
|
808 {
|
|
809 this_line_bufpos = 0;
|
485
|
810 if (!NILP (last_arrow_position))
|
277
|
811 {
|
|
812 last_arrow_position = Qt;
|
|
813 last_arrow_string = Qt;
|
|
814 }
|
769
|
815 /* If we pause after scrolling, some lines in current_frame
|
277
|
816 may be null, so preserve_other_columns won't be able to
|
|
817 preserve all the vertical-bar separators. So, avoid using it
|
|
818 in that case. */
|
769
|
819 if (XFASTINT (w->width) != FRAME_WIDTH (selected_frame))
|
277
|
820 update_mode_lines = 1;
|
|
821 }
|
|
822
|
769
|
823 /* Now text on frame agrees with windows, so
|
277
|
824 put info into the windows for partial redisplay to follow */
|
|
825
|
|
826 if (!pause)
|
|
827 {
|
|
828 register struct buffer *b = XBUFFER (w->buffer);
|
|
829
|
|
830 blank_end_of_window = 0;
|
|
831 clip_changed = 0;
|
|
832 unchanged_modified = BUF_MODIFF (b);
|
|
833 beg_unchanged = BUF_GPT (b) - BUF_BEG (b);
|
|
834 end_unchanged = BUF_Z (b) - BUF_GPT (b);
|
|
835
|
|
836 XFASTINT (w->last_point) = BUF_PT (b);
|
769
|
837 XFASTINT (w->last_point_x) = FRAME_CURSOR_X (selected_frame);
|
|
838 XFASTINT (w->last_point_y) = FRAME_CURSOR_Y (selected_frame);
|
277
|
839
|
|
840 if (all_windows)
|
1017
|
841 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame), 1);
|
277
|
842 else
|
|
843 {
|
|
844 w->update_mode_line = Qnil;
|
|
845 XFASTINT (w->last_modified) = BUF_MODIFF (b);
|
|
846 w->window_end_valid = Qt;
|
|
847 last_arrow_position = Voverlay_arrow_position;
|
|
848 last_arrow_string = Voverlay_arrow_string;
|
|
849 }
|
|
850 update_mode_lines = 0;
|
|
851 windows_or_buffers_changed = 0;
|
|
852 }
|
|
853
|
|
854 /* Start SIGIO interrupts coming again.
|
|
855 Having them off during the code above
|
|
856 makes it less likely one will discard output,
|
|
857 but not impossible, since there might be stuff
|
|
858 in the system buffer here.
|
|
859 But it is much hairier to try to do anything about that. */
|
|
860
|
|
861 if (interrupt_input)
|
|
862 request_sigio ();
|
|
863 start_polling ();
|
|
864
|
769
|
865 /* Change frame size now if a change is pending. */
|
277
|
866 do_pending_window_change ();
|
|
867 }
|
|
868
|
|
869 /* Redisplay, but leave alone any recent echo area message
|
|
870 unless another message has been requested in its place.
|
|
871
|
|
872 This is useful in situations where you need to redisplay but no
|
|
873 user action has occurred, making it inappropriate for the message
|
|
874 area to be cleared. See tracking_off and
|
|
875 wait_reading_process_input for examples of these situations. */
|
|
876
|
|
877 redisplay_preserve_echo_area ()
|
|
878 {
|
|
879 if (echo_area_glyphs == 0 && previous_echo_glyphs != 0)
|
|
880 {
|
|
881 echo_area_glyphs = previous_echo_glyphs;
|
|
882 redisplay ();
|
|
883 echo_area_glyphs = 0;
|
|
884 }
|
|
885 else
|
|
886 redisplay ();
|
|
887 }
|
|
888
|
|
889 void
|
|
890 mark_window_display_accurate (window, flag)
|
|
891 Lisp_Object window;
|
|
892 int flag;
|
|
893 {
|
|
894 register struct window *w;
|
|
895
|
485
|
896 for (;!NILP (window); window = w->next)
|
277
|
897 {
|
1527
|
898 if (XTYPE (window) != Lisp_Window) abort ();
|
277
|
899 w = XWINDOW (window);
|
|
900
|
485
|
901 if (!NILP (w->buffer))
|
2848
|
902 {
|
|
903 XFASTINT (w->last_modified)
|
|
904 = !flag ? 0
|
|
905 : XBUFFER (w->buffer) == current_buffer
|
|
906 ? MODIFF : BUF_MODIFF (XBUFFER (w->buffer));
|
|
907
|
|
908 /* Record if we are showing a region, so can make sure to
|
|
909 update it fully at next redisplay. */
|
|
910 w->region_showing = (!NILP (Vtransient_mark_mode)
|
|
911 && !NILP (XBUFFER (w->buffer)->mark_active)
|
|
912 ? Fmarker_position (XBUFFER (w->buffer)->mark)
|
|
913 : Qnil);
|
|
914 }
|
|
915
|
277
|
916 w->window_end_valid = Qt;
|
|
917 w->update_mode_line = Qnil;
|
|
918
|
485
|
919 if (!NILP (w->vchild))
|
277
|
920 mark_window_display_accurate (w->vchild, flag);
|
485
|
921 if (!NILP (w->hchild))
|
277
|
922 mark_window_display_accurate (w->hchild, flag);
|
|
923 }
|
|
924
|
|
925 if (flag)
|
|
926 {
|
|
927 last_arrow_position = Voverlay_arrow_position;
|
|
928 last_arrow_string = Voverlay_arrow_string;
|
|
929 }
|
|
930 else
|
|
931 {
|
|
932 /* t is unequal to any useful value of Voverlay_arrow_... */
|
|
933 last_arrow_position = Qt;
|
|
934 last_arrow_string = Qt;
|
|
935 }
|
|
936 }
|
|
937
|
5230
|
938 /* Update the menu bar item lists for WINDOW
|
|
939 and its subwindows and siblings.
|
|
940 This has to be done before we start to fill in any display lines,
|
|
941 because it can call eval. */
|
|
942
|
|
943 static void
|
|
944 update_menu_bars (window)
|
|
945 Lisp_Object window;
|
|
946 {
|
|
947 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
948 update_menu_bar (window, 0);
|
|
949 }
|
|
950
|
|
951 /* Update the menu bar item list for window WINDOW and its subwindows. */
|
|
952
|
|
953 static void
|
|
954 update_menu_bar (window, just_this_one)
|
|
955 Lisp_Object window;
|
|
956 int just_this_one;
|
|
957 {
|
|
958 register struct window *w = XWINDOW (window);
|
|
959 struct buffer *old = current_buffer;
|
|
960 FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
|
|
961
|
|
962 /* If this is a combination window, do its children; that's all. */
|
|
963
|
|
964 if (!NILP (w->vchild))
|
|
965 {
|
|
966 update_menu_bars (w->vchild);
|
|
967 return;
|
|
968 }
|
|
969 if (!NILP (w->hchild))
|
|
970 {
|
|
971 update_menu_bars (w->hchild);
|
|
972 return;
|
|
973 }
|
|
974 if (NILP (w->buffer))
|
|
975 abort ();
|
|
976
|
|
977 if (update_mode_lines)
|
|
978 w->update_mode_line = Qt;
|
|
979
|
|
980 /* When we reach a frame's selected window, redo the frame's menu bar. */
|
|
981 if (!NILP (w->update_mode_line)
|
5676
b5027523c90d
Wed Jan 26 12:23:12 1994 Frederic Pierresteguy (fp@mole.gnu.ai.mit.edu)
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
diff
changeset
|
982 #ifdef USE_X_TOOLKIT
|
b5027523c90d
Wed Jan 26 12:23:12 1994 Frederic Pierresteguy (fp@mole.gnu.ai.mit.edu)
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
diff
changeset
|
983 && FRAME_EXTERNAL_MENU_BAR (f)
|
b5027523c90d
Wed Jan 26 12:23:12 1994 Frederic Pierresteguy (fp@mole.gnu.ai.mit.edu)
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
diff
changeset
|
984 #else
|
5230
|
985 && FRAME_MENU_BAR_LINES (f) > 0
|
5676
b5027523c90d
Wed Jan 26 12:23:12 1994 Frederic Pierresteguy (fp@mole.gnu.ai.mit.edu)
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
diff
changeset
|
986 #endif
|
5230
|
987 && EQ (FRAME_SELECTED_WINDOW (f), window))
|
|
988 {
|
|
989 /* If the user has switched buffers or windows, we need to
|
|
990 recompute to reflect the new bindings. But we'll
|
|
991 recompute when update_mode_lines is set too; that means
|
|
992 that people can use force-mode-line-update to request
|
|
993 that the menu bar be recomputed. The adverse effect on
|
|
994 the rest of the redisplay algorithm is about the same as
|
|
995 windows_or_buffers_changed anyway. */
|
|
996 if (windows_or_buffers_changed
|
|
997 || update_mode_lines
|
|
998 || (XFASTINT (w->last_modified) < MODIFF
|
|
999 && (XFASTINT (w->last_modified)
|
|
1000 <= XBUFFER (w->buffer)->save_modified)))
|
|
1001 {
|
|
1002 struct buffer *prev = current_buffer;
|
|
1003 current_buffer = XBUFFER (w->buffer);
|
6134
|
1004 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
|
5230
|
1005 current_buffer = prev;
|
5658
|
1006 #ifdef USE_X_TOOLKIT
|
|
1007 set_frame_menubar (f);
|
|
1008 #endif /* USE_X_TOOLKIT */
|
5230
|
1009 }
|
|
1010 }
|
|
1011 }
|
|
1012
|
277
|
1013 int do_id = 1;
|
|
1014
|
5230
|
1015 /* Redisplay WINDOW and its subwindows and siblings. */
|
|
1016
|
277
|
1017 static void
|
|
1018 redisplay_windows (window)
|
|
1019 Lisp_Object window;
|
|
1020 {
|
485
|
1021 for (; !NILP (window); window = XWINDOW (window)->next)
|
277
|
1022 redisplay_window (window, 0);
|
|
1023 }
|
|
1024
|
5230
|
1025 /* Redisplay window WINDOW and its subwindows. */
|
|
1026
|
277
|
1027 static void
|
|
1028 redisplay_window (window, just_this_one)
|
|
1029 Lisp_Object window;
|
|
1030 int just_this_one;
|
|
1031 {
|
|
1032 register struct window *w = XWINDOW (window);
|
1718
|
1033 FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
|
277
|
1034 int height;
|
|
1035 register int lpoint = point;
|
|
1036 struct buffer *old = current_buffer;
|
1785
|
1037 register int width = window_internal_width (w) - 1;
|
277
|
1038 register int startp;
|
|
1039 register int hscroll = XINT (w->hscroll);
|
|
1040 struct position pos;
|
1785
|
1041 int opoint = point;
|
277
|
1042 int tem;
|
|
1043 int window_needs_modeline;
|
|
1044
|
769
|
1045 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */
|
277
|
1046
|
|
1047 /* If this is a combination window, do its children; that's all. */
|
|
1048
|
485
|
1049 if (!NILP (w->vchild))
|
277
|
1050 {
|
|
1051 redisplay_windows (w->vchild);
|
|
1052 return;
|
|
1053 }
|
485
|
1054 if (!NILP (w->hchild))
|
277
|
1055 {
|
|
1056 redisplay_windows (w->hchild);
|
|
1057 return;
|
|
1058 }
|
485
|
1059 if (NILP (w->buffer))
|
277
|
1060 abort ();
|
433
|
1061
|
|
1062 height = window_internal_height (w);
|
|
1063
|
|
1064 if (MINI_WINDOW_P (w))
|
|
1065 {
|
|
1066 if (w == XWINDOW (minibuf_window))
|
|
1067 {
|
|
1068 if (echo_area_glyphs)
|
|
1069 /* We've already displayed the echo area glyphs, if any. */
|
1992
|
1070 goto finish_scroll_bars;
|
433
|
1071 }
|
|
1072 else
|
|
1073 {
|
|
1074 /* This is a minibuffer, but it's not the currently active one, so
|
|
1075 clear it. */
|
769
|
1076 int vpos = XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top);
|
433
|
1077 int i;
|
|
1078
|
|
1079 for (i = 0; i < height; i++)
|
|
1080 {
|
769
|
1081 get_display_line (f, vpos + i, 0);
|
5800
|
1082 display_string (w, vpos + i, "", 0, 0, 0, 1, 0, width);
|
433
|
1083 }
|
|
1084
|
1992
|
1085 goto finish_scroll_bars;
|
433
|
1086 }
|
|
1087 }
|
277
|
1088
|
|
1089 if (update_mode_lines)
|
|
1090 w->update_mode_line = Qt;
|
|
1091
|
|
1092 /* Otherwise set up data on this window; select its buffer and point value */
|
|
1093
|
|
1094 current_buffer = XBUFFER (w->buffer);
|
|
1095 opoint = point;
|
|
1096
|
|
1097 /* Count number of windows showing the selected buffer. */
|
|
1098
|
|
1099 if (!just_this_one
|
|
1100 && current_buffer == XBUFFER (XWINDOW (selected_window)->buffer))
|
|
1101 buffer_shared++;
|
|
1102
|
|
1103 /* POINT refers normally to the selected window.
|
|
1104 For any other window, set up appropriate value. */
|
|
1105
|
|
1106 if (!EQ (window, selected_window))
|
|
1107 {
|
|
1108 SET_PT (marker_position (w->pointm));
|
|
1109 if (point < BEGV)
|
|
1110 {
|
485
|
1111 SET_PT (BEGV);
|
277
|
1112 Fset_marker (w->pointm, make_number (point), Qnil);
|
|
1113 }
|
|
1114 else if (point > (ZV - 1))
|
|
1115 {
|
485
|
1116 SET_PT (ZV);
|
277
|
1117 Fset_marker (w->pointm, make_number (point), Qnil);
|
|
1118 }
|
|
1119 }
|
|
1120
|
|
1121 /* If window-start is screwed up, choose a new one. */
|
|
1122 if (XMARKER (w->start)->buffer != current_buffer)
|
|
1123 goto recenter;
|
|
1124
|
|
1125 startp = marker_position (w->start);
|
|
1126
|
433
|
1127 /* Handle case where place to start displaying has been specified,
|
2303
|
1128 unless the specified location is outside the accessible range. */
|
485
|
1129 if (!NILP (w->force_start))
|
277
|
1130 {
|
2303
|
1131 /* Forget any recorded base line for line number display. */
|
|
1132 w->base_line_number = Qnil;
|
277
|
1133 w->update_mode_line = Qt;
|
|
1134 w->force_start = Qnil;
|
|
1135 XFASTINT (w->last_modified) = 0;
|
433
|
1136 if (startp < BEGV) startp = BEGV;
|
|
1137 if (startp > ZV) startp = ZV;
|
277
|
1138 try_window (window, startp);
|
|
1139 if (cursor_vpos < 0)
|
|
1140 {
|
2848
|
1141 /* ??? What should happen here if highlighting a region? */
|
277
|
1142 /* If point does not appear, move point so it does appear */
|
|
1143 pos = *compute_motion (startp, 0,
|
|
1144 ((EQ (window, minibuf_window) && startp == 1)
|
|
1145 ? minibuf_prompt_width : 0)
|
|
1146 +
|
|
1147 (hscroll ? 1 - hscroll : 0),
|
|
1148 ZV, height / 2,
|
|
1149 - (1 << (SHORTBITS - 1)),
|
|
1150 width, hscroll, pos_tab_offset (w, startp));
|
|
1151 SET_PT (pos.bufpos);
|
5230
|
1152 if (w != XWINDOW (selected_window))
|
277
|
1153 Fset_marker (w->pointm, make_number (point), Qnil);
|
|
1154 else
|
|
1155 {
|
5340
|
1156 if (current_buffer == old)
|
|
1157 lpoint = point;
|
769
|
1158 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left);
|
|
1159 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top);
|
277
|
1160 }
|
|
1161 }
|
|
1162 goto done;
|
|
1163 }
|
|
1164
|
|
1165 /* Handle case where text has not changed, only point,
|
769
|
1166 and it has not moved off the frame */
|
277
|
1167
|
|
1168 /* This code is not used for minibuffer for the sake of
|
|
1169 the case of redisplaying to replace an echo area message;
|
|
1170 since in that case the minibuffer contents per se are usually unchanged.
|
|
1171 This code is of no real use in the minibuffer since
|
|
1172 the handling of this_line_bufpos, etc.,
|
|
1173 in redisplay handles the same cases. */
|
|
1174
|
|
1175 if (XFASTINT (w->last_modified) >= MODIFF
|
|
1176 && point >= startp && !clip_changed
|
769
|
1177 && (just_this_one || XFASTINT (w->width) == FRAME_WIDTH (f))
|
2848
|
1178 /* Can't use this case if highlighting a region. */
|
|
1179 && !(!NILP (Vtransient_mark_mode) && !NILP (current_buffer->mark_active))
|
|
1180 && NILP (w->region_showing)
|
277
|
1181 && !EQ (window, minibuf_window))
|
|
1182 {
|
|
1183 pos = *compute_motion (startp, 0, (hscroll ? 1 - hscroll : 0),
|
|
1184 point, height + 1, 10000, width, hscroll,
|
|
1185 pos_tab_offset (w, startp));
|
|
1186
|
|
1187 if (pos.vpos < height)
|
|
1188 {
|
769
|
1189 /* Ok, point is still on frame */
|
|
1190 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f)))
|
277
|
1191 {
|
|
1192 /* These variables are supposed to be origin 1 */
|
769
|
1193 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left);
|
|
1194 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top);
|
277
|
1195 }
|
|
1196 /* This doesn't do the trick, because if a window to the right of
|
|
1197 this one must be redisplayed, this does nothing because there
|
769
|
1198 is nothing in DesiredFrame yet, and then the other window is
|
277
|
1199 redisplayed, making likes that are empty in this window's columns.
|
769
|
1200 if (XFASTINT (w->width) != FRAME_WIDTH (f))
|
277
|
1201 preserve_my_columns (w);
|
|
1202 */
|
|
1203 goto done;
|
|
1204 }
|
|
1205 /* Don't bother trying redisplay with same start;
|
|
1206 we already know it will lose */
|
|
1207 }
|
|
1208 /* If current starting point was originally the beginning of a line
|
|
1209 but no longer is, find a new starting point. */
|
485
|
1210 else if (!NILP (w->start_at_line_beg)
|
277
|
1211 && !(startp == BEGV
|
|
1212 || FETCH_CHAR (startp - 1) == '\n'))
|
|
1213 {
|
|
1214 goto recenter;
|
|
1215 }
|
|
1216 else if (just_this_one && !MINI_WINDOW_P (w)
|
|
1217 && point >= startp
|
|
1218 && XFASTINT (w->last_modified)
|
3648
|
1219 /* or else vmotion on first line won't work. */
|
|
1220 && ! NILP (w->start_at_line_beg)
|
277
|
1221 && ! EQ (w->window_end_valid, Qnil)
|
|
1222 && do_id && !clip_changed
|
|
1223 && !blank_end_of_window
|
769
|
1224 && XFASTINT (w->width) == FRAME_WIDTH (f)
|
2848
|
1225 /* Can't use this case if highlighting a region. */
|
|
1226 && !(!NILP (Vtransient_mark_mode)
|
|
1227 && !NILP (current_buffer->mark_active))
|
|
1228 && NILP (w->region_showing)
|
277
|
1229 && EQ (last_arrow_position, Voverlay_arrow_position)
|
|
1230 && EQ (last_arrow_string, Voverlay_arrow_string)
|
769
|
1231 && (tem = try_window_id (FRAME_SELECTED_WINDOW (f)))
|
277
|
1232 && tem != -2)
|
|
1233 {
|
|
1234 /* tem > 0 means success. tem == -1 means choose new start.
|
|
1235 tem == -2 means try again with same start,
|
|
1236 and nothing but whitespace follows the changed stuff.
|
|
1237 tem == 0 means try again with same start. */
|
|
1238 if (tem > 0)
|
|
1239 goto done;
|
|
1240 }
|
|
1241 else if (startp >= BEGV && startp <= ZV
|
|
1242 /* Avoid starting display at end of buffer! */
|
433
|
1243 && (startp < ZV || startp == BEGV
|
277
|
1244 || (XFASTINT (w->last_modified) >= MODIFF)))
|
|
1245 {
|
|
1246 /* Try to redisplay starting at same place as before */
|
769
|
1247 /* If point has not moved off frame, accept the results */
|
277
|
1248 try_window (window, startp);
|
|
1249 if (cursor_vpos >= 0)
|
2303
|
1250 {
|
|
1251 if (!just_this_one || clip_changed || beg_unchanged < startp)
|
|
1252 /* Forget any recorded base line for line number display. */
|
|
1253 w->base_line_number = Qnil;
|
|
1254 goto done;
|
|
1255 }
|
277
|
1256 else
|
|
1257 cancel_my_columns (w);
|
|
1258 }
|
|
1259
|
|
1260 XFASTINT (w->last_modified) = 0;
|
|
1261 w->update_mode_line = Qt;
|
|
1262
|
|
1263 /* Try to scroll by specified few lines */
|
|
1264
|
|
1265 if (scroll_step && !clip_changed)
|
|
1266 {
|
|
1267 if (point > startp)
|
|
1268 {
|
|
1269 pos = *vmotion (Z - XFASTINT (w->window_end_pos),
|
|
1270 scroll_step, width, hscroll, window);
|
|
1271 if (pos.vpos >= height)
|
|
1272 goto scroll_fail;
|
|
1273 }
|
|
1274
|
|
1275 pos = *vmotion (startp, point < startp ? - scroll_step : scroll_step,
|
|
1276 width, hscroll, window);
|
|
1277
|
|
1278 if (point >= pos.bufpos)
|
|
1279 {
|
|
1280 try_window (window, pos.bufpos);
|
|
1281 if (cursor_vpos >= 0)
|
2303
|
1282 {
|
|
1283 if (!just_this_one || clip_changed || beg_unchanged < startp)
|
|
1284 /* Forget any recorded base line for line number display. */
|
|
1285 w->base_line_number = Qnil;
|
|
1286 goto done;
|
|
1287 }
|
277
|
1288 else
|
|
1289 cancel_my_columns (w);
|
|
1290 }
|
|
1291 scroll_fail: ;
|
|
1292 }
|
|
1293
|
|
1294 /* Finally, just choose place to start which centers point */
|
|
1295
|
|
1296 recenter:
|
2303
|
1297 /* Forget any previously recorded base line for line number display. */
|
|
1298 w->base_line_number = Qnil;
|
|
1299
|
277
|
1300 pos = *vmotion (point, - height / 2, width, hscroll, window);
|
|
1301 try_window (window, pos.bufpos);
|
|
1302
|
|
1303 startp = marker_position (w->start);
|
|
1304 w->start_at_line_beg =
|
|
1305 (startp == BEGV || FETCH_CHAR (startp - 1) == '\n') ? Qt : Qnil;
|
|
1306
|
|
1307 done:
|
485
|
1308 if ((!NILP (w->update_mode_line)
|
2303
|
1309 /* If window not full width, must redo its mode line
|
|
1310 if the window to its side is being redone */
|
|
1311 || (!just_this_one && width < FRAME_WIDTH (f) - 1)
|
|
1312 || INTEGERP (w->base_line_pos))
|
277
|
1313 && height != XFASTINT (w->height))
|
|
1314 display_mode_line (w);
|
2303
|
1315 if (! line_number_displayed
|
|
1316 && ! BUFFERP (w->base_line_pos))
|
|
1317 {
|
|
1318 w->base_line_pos = Qnil;
|
|
1319 w->base_line_number = Qnil;
|
|
1320 }
|
277
|
1321
|
2150
|
1322 /* When we reach a frame's selected window, redo the frame's menu bar. */
|
|
1323 if (!NILP (w->update_mode_line)
|
5658
|
1324 #ifdef USE_X_TOOLKIT
|
|
1325 && FRAME_EXTERNAL_MENU_BAR (f)
|
|
1326 #else
|
2150
|
1327 && FRAME_MENU_BAR_LINES (f) > 0
|
5658
|
1328 #endif
|
2150
|
1329 && EQ (FRAME_SELECTED_WINDOW (f), window))
|
|
1330 display_menu_bar (w);
|
|
1331
|
1992
|
1332 finish_scroll_bars:
|
|
1333 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
|
1785
|
1334 {
|
|
1335 int start, end, whole;
|
|
1336
|
|
1337 /* Calculate the start and end positions for the current window.
|
2874
|
1338 At some point, it would be nice to choose between scrollbars
|
|
1339 which reflect the whole buffer size, with special markers
|
|
1340 indicating narrowing, and scrollbars which reflect only the
|
|
1341 visible region.
|
|
1342
|
1785
|
1343 Note that minibuffers sometimes aren't displaying any text. */
|
|
1344 if (! MINI_WINDOW_P (w)
|
|
1345 || (w == XWINDOW (minibuf_window) && ! echo_area_glyphs))
|
|
1346 {
|
2929
f3c44426bed2
Fix the fix to scrollbar computaaFix the fix to the fix for scrollbar computation.
Jim Blandy <jimb@redhat.com>
diff
changeset
|
1347 whole = ZV - BEGV;
|
2904
|
1348 start = startp - BEGV;
|
1785
|
1349 /* I don't think this is guaranteed to be right. For the
|
|
1350 moment, we'll pretend it is. */
|
3880
|
1351 end = (Z - XINT (w->window_end_pos)) - BEGV;
|
2874
|
1352
|
|
1353 if (end < start) end = start;
|
2929
f3c44426bed2
Fix the fix to scrollbar computaaFix the fix to the fix for scrollbar computation.
Jim Blandy <jimb@redhat.com>
diff
changeset
|
1354 if (whole < (end - start)) whole = end - start;
|
1785
|
1355 }
|
|
1356 else
|
|
1357 start = end = whole = 0;
|
|
1358
|
1992
|
1359 /* Indicate what this scroll bar ought to be displaying now. */
|
3788
|
1360 (*set_vertical_scroll_bar_hook) (w, end - start, whole, start);
|
1785
|
1361
|
1992
|
1362 /* Note that we actually used the scroll bar attached to this window,
|
1785
|
1363 so it shouldn't be deleted at the end of redisplay. */
|
1992
|
1364 (*redeem_scroll_bar_hook) (w);
|
1785
|
1365 }
|
|
1366
|
277
|
1367 SET_PT (opoint);
|
|
1368 current_buffer = old;
|
|
1369 SET_PT (lpoint);
|
|
1370 }
|
|
1371
|
|
1372 /* Do full redisplay on one window, starting at position `pos'. */
|
|
1373
|
|
1374 static void
|
|
1375 try_window (window, pos)
|
|
1376 Lisp_Object window;
|
|
1377 register int pos;
|
|
1378 {
|
|
1379 register struct window *w = XWINDOW (window);
|
|
1380 register int height = window_internal_height (w);
|
|
1381 register int vpos = XFASTINT (w->top);
|
|
1382 register int last_text_vpos = vpos;
|
|
1383 int tab_offset = pos_tab_offset (w, pos);
|
769
|
1384 FRAME_PTR f = XFRAME (w->frame);
|
1785
|
1385 int width = window_internal_width (w) - 1;
|
277
|
1386 struct position val;
|
|
1387
|
|
1388 Fset_marker (w->start, make_number (pos), Qnil);
|
|
1389 cursor_vpos = -1;
|
|
1390 overlay_arrow_seen = 0;
|
|
1391 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0;
|
|
1392
|
|
1393 while (--height >= 0)
|
|
1394 {
|
|
1395 val = *display_text_line (w, pos, vpos, val.hpos, tab_offset);
|
|
1396 tab_offset += width;
|
|
1397 if (val.vpos) tab_offset = 0;
|
|
1398 vpos++;
|
|
1399 if (pos != val.bufpos)
|
|
1400 last_text_vpos
|
|
1401 /* Next line, unless prev line ended in end of buffer with no cr */
|
4386
|
1402 = vpos - (val.vpos && (FETCH_CHAR (val.bufpos - 1) != '\n'
|
6065
ab1aef4b0e07
(try_window): Add #ifdef USE_TEXT_PROPERTIES around call to Fget_text_property.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1403 #ifdef USE_TEXT_PROPERTIES
|
6066
4ff0c5c05867
(try_window, display_text_line): Use Fget_char_property to test for invisibility.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1404 || ! NILP (Fget_char_property (val.bufpos-1,
|
4386
|
1405 Qinvisible,
|
6066
4ff0c5c05867
(try_window, display_text_line): Use Fget_char_property to test for invisibility.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1406 window))
|
6065
ab1aef4b0e07
(try_window): Add #ifdef USE_TEXT_PROPERTIES around call to Fget_text_property.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1407 #endif
|
ab1aef4b0e07
(try_window): Add #ifdef USE_TEXT_PROPERTIES around call to Fget_text_property.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1408 ));
|
277
|
1409 pos = val.bufpos;
|
|
1410 }
|
|
1411
|
|
1412 /* If last line is continued in middle of character,
|
769
|
1413 include the split character in the text considered on the frame */
|
277
|
1414 if (val.hpos < (XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0))
|
|
1415 pos++;
|
|
1416
|
769
|
1417 /* If bottom just moved off end of frame, change mode line percentage. */
|
277
|
1418 if (XFASTINT (w->window_end_pos) == 0
|
|
1419 && Z != pos)
|
|
1420 w->update_mode_line = Qt;
|
|
1421
|
769
|
1422 /* Say where last char on frame will be, once redisplay is finished. */
|
277
|
1423 XFASTINT (w->window_end_pos) = Z - pos;
|
|
1424 XFASTINT (w->window_end_vpos) = last_text_vpos - XFASTINT (w->top);
|
|
1425 /* But that is not valid info until redisplay finishes. */
|
|
1426 w->window_end_valid = Qnil;
|
|
1427 }
|
|
1428
|
|
1429 /* Try to redisplay when buffer is modified locally,
|
|
1430 computing insert/delete line to preserve text outside
|
|
1431 the bounds of the changes.
|
|
1432 Return 1 if successful, 0 if if cannot tell what to do,
|
|
1433 or -1 to tell caller to find a new window start,
|
|
1434 or -2 to tell caller to do normal redisplay with same window start. */
|
|
1435
|
|
1436 static int
|
|
1437 try_window_id (window)
|
|
1438 Lisp_Object window;
|
|
1439 {
|
|
1440 int pos;
|
|
1441 register struct window *w = XWINDOW (window);
|
|
1442 register int height = window_internal_height (w);
|
769
|
1443 FRAME_PTR f = XFRAME (w->frame);
|
277
|
1444 int top = XFASTINT (w->top);
|
|
1445 int start = marker_position (w->start);
|
1785
|
1446 int width = window_internal_width (w) - 1;
|
277
|
1447 int hscroll = XINT (w->hscroll);
|
|
1448 int lmargin = hscroll > 0 ? 1 - hscroll : 0;
|
|
1449 register int vpos;
|
|
1450 register int i, tem;
|
|
1451 int last_text_vpos = 0;
|
|
1452 int stop_vpos;
|
5942
|
1453 int selective
|
|
1454 = XTYPE (current_buffer->selective_display) == Lisp_Int
|
|
1455 ? XINT (current_buffer->selective_display)
|
|
1456 : !NILP (current_buffer->selective_display) ? -1 : 0;
|
277
|
1457
|
|
1458 struct position val, bp, ep, xp, pp;
|
|
1459 int scroll_amount = 0;
|
|
1460 int delta;
|
|
1461 int tab_offset, epto;
|
|
1462
|
|
1463 if (GPT - BEG < beg_unchanged)
|
|
1464 beg_unchanged = GPT - BEG;
|
|
1465 if (Z - GPT < end_unchanged)
|
|
1466 end_unchanged = Z - GPT;
|
|
1467
|
5739
|
1468 if (beg_unchanged + BEG < start)
|
277
|
1469 return 0; /* Give up if changes go above top of window */
|
|
1470
|
|
1471 /* Find position before which nothing is changed. */
|
|
1472 bp = *compute_motion (start, 0, lmargin,
|
5739
|
1473 min (ZV, beg_unchanged + BEG), height + 1, 0,
|
|
1474 width, hscroll, pos_tab_offset (w, start));
|
277
|
1475 if (bp.vpos >= height)
|
368
|
1476 {
|
|
1477 if (point < bp.bufpos && !bp.contin)
|
|
1478 {
|
769
|
1479 /* All changes are below the frame, and point is on the frame.
|
|
1480 We don't need to change the frame at all.
|
368
|
1481 But we need to update window_end_pos to account for
|
|
1482 any change in buffer size. */
|
371
|
1483 bp = *compute_motion (start, 0, lmargin,
|
|
1484 Z, height, 0,
|
|
1485 width, hscroll, pos_tab_offset (w, start));
|
368
|
1486 XFASTINT (w->window_end_vpos) = height;
|
|
1487 XFASTINT (w->window_end_pos) = Z - bp.bufpos;
|
|
1488 return 1;
|
|
1489 }
|
|
1490 return 0;
|
|
1491 }
|
277
|
1492
|
|
1493 vpos = bp.vpos;
|
|
1494
|
769
|
1495 /* Find beginning of that frame line. Must display from there. */
|
277
|
1496 bp = *vmotion (bp.bufpos, 0, width, hscroll, window);
|
|
1497
|
|
1498 pos = bp.bufpos;
|
|
1499 val.hpos = lmargin;
|
|
1500 if (pos < start)
|
|
1501 return -1;
|
|
1502
|
|
1503 /* If about to start displaying at the beginning of a continuation line,
|
769
|
1504 really start with previous frame line, in case it was not
|
277
|
1505 continued when last redisplayed */
|
528
|
1506 if ((bp.contin && bp.bufpos - 1 == beg_unchanged && vpos > 0)
|
|
1507 ||
|
|
1508 /* Likewise if we have to worry about selective display. */
|
5942
|
1509 (selective > 0 && bp.bufpos - 1 == beg_unchanged && vpos > 0))
|
277
|
1510 {
|
|
1511 bp = *vmotion (bp.bufpos, -1, width, hscroll, window);
|
|
1512 --vpos;
|
|
1513 pos = bp.bufpos;
|
|
1514 }
|
|
1515
|
|
1516 if (bp.contin && bp.hpos != lmargin)
|
|
1517 {
|
|
1518 val.hpos = bp.prevhpos - width + lmargin;
|
|
1519 pos--;
|
|
1520 }
|
|
1521
|
|
1522 bp.vpos = vpos;
|
|
1523
|
|
1524 /* Find first visible newline after which no more is changed. */
|
|
1525 tem = find_next_newline (Z - max (end_unchanged, Z - ZV), 1);
|
5942
|
1526 if (selective > 0)
|
|
1527 while (tem < ZV - 1 && (indented_beyond_p (tem, selective)))
|
277
|
1528 tem = find_next_newline (tem, 1);
|
|
1529
|
|
1530 /* Compute the cursor position after that newline. */
|
|
1531 ep = *compute_motion (pos, vpos, val.hpos, tem,
|
|
1532 height, - (1 << (SHORTBITS - 1)),
|
|
1533 width, hscroll, pos_tab_offset (w, bp.bufpos));
|
|
1534
|
769
|
1535 /* If changes reach past the text available on the frame,
|
|
1536 just display rest of frame. */
|
277
|
1537 if (ep.bufpos > Z - XFASTINT (w->window_end_pos))
|
|
1538 stop_vpos = height;
|
|
1539 else
|
|
1540 stop_vpos = ep.vpos;
|
|
1541
|
|
1542 /* If no newline before ep, the line ep is on includes some changes
|
|
1543 that must be displayed. Make sure we don't stop before it. */
|
|
1544 /* Also, if changes reach all the way until ep.bufpos,
|
|
1545 it is possible that something was deleted after the
|
|
1546 newline before it, so the following line must be redrawn. */
|
|
1547 if (stop_vpos == ep.vpos
|
|
1548 && (ep.bufpos == BEGV
|
|
1549 || FETCH_CHAR (ep.bufpos - 1) != '\n'
|
|
1550 || ep.bufpos == Z - end_unchanged))
|
|
1551 stop_vpos = ep.vpos + 1;
|
|
1552
|
|
1553 cursor_vpos = -1;
|
|
1554 overlay_arrow_seen = 0;
|
|
1555
|
|
1556 /* If changes do not reach to bottom of window,
|
|
1557 figure out how much to scroll the rest of the window */
|
|
1558 if (stop_vpos < height)
|
|
1559 {
|
|
1560 /* Now determine how far up or down the rest of the window has moved */
|
|
1561 epto = pos_tab_offset (w, ep.bufpos);
|
|
1562 xp = *compute_motion (ep.bufpos, ep.vpos, ep.hpos,
|
|
1563 Z - XFASTINT (w->window_end_pos),
|
|
1564 10000, 0, width, hscroll, epto);
|
|
1565 scroll_amount = xp.vpos - XFASTINT (w->window_end_vpos);
|
|
1566
|
769
|
1567 /* Is everything on frame below the changes whitespace?
|
277
|
1568 If so, no scrolling is really necessary. */
|
|
1569 for (i = ep.bufpos; i < xp.bufpos; i++)
|
|
1570 {
|
|
1571 tem = FETCH_CHAR (i);
|
|
1572 if (tem != ' ' && tem != '\n' && tem != '\t')
|
|
1573 break;
|
|
1574 }
|
|
1575 if (i == xp.bufpos)
|
|
1576 return -2;
|
|
1577
|
|
1578 XFASTINT (w->window_end_vpos) += scroll_amount;
|
|
1579
|
769
|
1580 /* Before doing any scrolling, verify that point will be on frame. */
|
277
|
1581 if (point > ep.bufpos && !(point <= xp.bufpos && xp.bufpos < height))
|
|
1582 {
|
|
1583 if (point <= xp.bufpos)
|
|
1584 {
|
|
1585 pp = *compute_motion (ep.bufpos, ep.vpos, ep.hpos,
|
|
1586 point, height, - (1 << (SHORTBITS - 1)),
|
|
1587 width, hscroll, epto);
|
|
1588 }
|
|
1589 else
|
|
1590 {
|
|
1591 pp = *compute_motion (xp.bufpos, xp.vpos, xp.hpos,
|
|
1592 point, height, - (1 << (SHORTBITS - 1)),
|
|
1593 width, hscroll, pos_tab_offset (w, xp.bufpos));
|
|
1594 }
|
|
1595 if (pp.bufpos < point || pp.vpos == height)
|
|
1596 return 0;
|
|
1597 cursor_vpos = pp.vpos + top;
|
|
1598 cursor_hpos = pp.hpos + XFASTINT (w->left);
|
|
1599 }
|
|
1600
|
|
1601 if (stop_vpos - scroll_amount >= height
|
|
1602 || ep.bufpos == xp.bufpos)
|
|
1603 {
|
|
1604 if (scroll_amount < 0)
|
|
1605 stop_vpos -= scroll_amount;
|
|
1606 scroll_amount = 0;
|
|
1607 /* In this path, we have altered window_end_vpos
|
|
1608 and not left it negative.
|
|
1609 We must make sure that, in case display is preempted
|
769
|
1610 before the frame changes to reflect what we do here,
|
277
|
1611 further updates will not come to try_window_id
|
769
|
1612 and assume the frame and window_end_vpos match. */
|
277
|
1613 blank_end_of_window = 1;
|
|
1614 }
|
|
1615 else if (!scroll_amount)
|
|
1616 {}
|
|
1617 else if (bp.bufpos == Z - end_unchanged)
|
|
1618 {
|
|
1619 /* If reprinting everything is nearly as fast as scrolling,
|
|
1620 don't bother scrolling. Can happen if lines are short. */
|
769
|
1621 if (scroll_cost (f, bp.vpos + top - scroll_amount,
|
277
|
1622 top + height - max (0, scroll_amount),
|
|
1623 scroll_amount)
|
|
1624 > xp.bufpos - bp.bufpos - 20)
|
|
1625 /* Return "try normal display with same window-start."
|
|
1626 Too bad we can't prevent further scroll-thinking. */
|
|
1627 return -2;
|
|
1628 /* If pure deletion, scroll up as many lines as possible.
|
|
1629 In common case of killing a line, this can save the
|
|
1630 following line from being overwritten by scrolling
|
|
1631 and therefore having to be redrawn. */
|
769
|
1632 tem = scroll_frame_lines (f, bp.vpos + top - scroll_amount,
|
277
|
1633 top + height - max (0, scroll_amount),
|
|
1634 scroll_amount);
|
|
1635 if (!tem) stop_vpos = height;
|
|
1636 }
|
|
1637 else if (scroll_amount)
|
|
1638 {
|
|
1639 /* If reprinting everything is nearly as fast as scrolling,
|
|
1640 don't bother scrolling. Can happen if lines are short. */
|
|
1641 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
|
|
1642 overestimate of cost of reprinting, since xp.bufpos
|
|
1643 would end up below the bottom of the window. */
|
769
|
1644 if (scroll_cost (f, ep.vpos + top - scroll_amount,
|
277
|
1645 top + height - max (0, scroll_amount),
|
|
1646 scroll_amount)
|
|
1647 > xp.bufpos - ep.bufpos - 20)
|
|
1648 /* Return "try normal display with same window-start."
|
|
1649 Too bad we can't prevent further scroll-thinking. */
|
|
1650 return -2;
|
769
|
1651 tem = scroll_frame_lines (f, ep.vpos + top - scroll_amount,
|
277
|
1652 top + height - max (0, scroll_amount),
|
|
1653 scroll_amount);
|
|
1654 if (!tem) stop_vpos = height;
|
|
1655 }
|
|
1656 }
|
|
1657
|
|
1658 /* In any case, do not display past bottom of window */
|
|
1659 if (stop_vpos >= height)
|
|
1660 {
|
|
1661 stop_vpos = height;
|
|
1662 scroll_amount = 0;
|
|
1663 }
|
|
1664
|
|
1665 /* Handle case where pos is before w->start --
|
|
1666 can happen if part of line had been clipped and is not clipped now */
|
|
1667 if (vpos == 0 && pos < marker_position (w->start))
|
|
1668 Fset_marker (w->start, make_number (pos), Qnil);
|
|
1669
|
|
1670 /* Redisplay the lines where the text was changed */
|
|
1671 last_text_vpos = vpos;
|
|
1672 tab_offset = pos_tab_offset (w, pos);
|
|
1673 /* If we are starting display in mid-character, correct tab_offset
|
|
1674 to account for passing the line that that character really starts in. */
|
|
1675 if (val.hpos < lmargin)
|
|
1676 tab_offset += width;
|
|
1677 while (vpos < stop_vpos)
|
|
1678 {
|
|
1679 val = *display_text_line (w, pos, top + vpos++, val.hpos, tab_offset);
|
|
1680 tab_offset += width;
|
|
1681 if (val.vpos) tab_offset = 0;
|
|
1682 if (pos != val.bufpos)
|
|
1683 last_text_vpos
|
|
1684 /* Next line, unless prev line ended in end of buffer with no cr */
|
|
1685 = vpos - (val.vpos && FETCH_CHAR (val.bufpos - 1) != '\n');
|
|
1686 pos = val.bufpos;
|
|
1687 }
|
|
1688
|
|
1689 /* There are two cases:
|
|
1690 1) we have displayed down to the bottom of the window
|
|
1691 2) we have scrolled lines below stop_vpos by scroll_amount */
|
|
1692
|
|
1693 if (vpos == height)
|
|
1694 {
|
|
1695 /* If last line is continued in middle of character,
|
769
|
1696 include the split character in the text considered on the frame */
|
277
|
1697 if (val.hpos < lmargin)
|
|
1698 val.bufpos++;
|
|
1699 XFASTINT (w->window_end_vpos) = last_text_vpos;
|
|
1700 XFASTINT (w->window_end_pos) = Z - val.bufpos;
|
|
1701 }
|
|
1702
|
|
1703 /* If scrolling made blank lines at window bottom,
|
|
1704 redisplay to fill those lines */
|
|
1705 if (scroll_amount < 0)
|
|
1706 {
|
|
1707 /* Don't consider these lines for general-purpose scrolling.
|
|
1708 That will save time in the scrolling computation. */
|
769
|
1709 FRAME_SCROLL_BOTTOM_VPOS (f) = xp.vpos;
|
277
|
1710 vpos = xp.vpos;
|
|
1711 pos = xp.bufpos;
|
|
1712 val.hpos = lmargin;
|
|
1713 if (pos == ZV)
|
|
1714 vpos = height + scroll_amount;
|
|
1715 else if (xp.contin && xp.hpos != lmargin)
|
|
1716 {
|
|
1717 val.hpos = xp.prevhpos - width + lmargin;
|
|
1718 pos--;
|
|
1719 }
|
|
1720
|
|
1721 blank_end_of_window = 1;
|
|
1722 tab_offset = pos_tab_offset (w, pos);
|
|
1723 /* If we are starting display in mid-character, correct tab_offset
|
|
1724 to account for passing the line that that character starts in. */
|
|
1725 if (val.hpos < lmargin)
|
|
1726 tab_offset += width;
|
|
1727
|
|
1728 while (vpos < height)
|
|
1729 {
|
|
1730 val = *display_text_line (w, pos, top + vpos++, val.hpos, tab_offset);
|
|
1731 tab_offset += width;
|
|
1732 if (val.vpos) tab_offset = 0;
|
|
1733 pos = val.bufpos;
|
|
1734 }
|
|
1735
|
|
1736 /* Here is a case where display_text_line sets cursor_vpos wrong.
|
|
1737 Make it be fixed up, below. */
|
|
1738 if (xp.bufpos == ZV
|
|
1739 && xp.bufpos == point)
|
|
1740 cursor_vpos = -1;
|
|
1741 }
|
|
1742
|
769
|
1743 /* If bottom just moved off end of frame, change mode line percentage. */
|
277
|
1744 if (XFASTINT (w->window_end_pos) == 0
|
|
1745 && Z != val.bufpos)
|
|
1746 w->update_mode_line = Qt;
|
|
1747
|
|
1748 /* Attempt to adjust end-of-text positions to new bottom line */
|
|
1749 if (scroll_amount)
|
|
1750 {
|
|
1751 delta = height - xp.vpos;
|
|
1752 if (delta < 0
|
|
1753 || (delta > 0 && xp.bufpos <= ZV)
|
|
1754 || (delta == 0 && xp.hpos))
|
|
1755 {
|
|
1756 val = *vmotion (Z - XFASTINT (w->window_end_pos),
|
|
1757 delta, width, hscroll, window);
|
|
1758 XFASTINT (w->window_end_pos) = Z - val.bufpos;
|
|
1759 XFASTINT (w->window_end_vpos) += val.vpos;
|
|
1760 }
|
|
1761 }
|
|
1762
|
|
1763 w->window_end_valid = Qnil;
|
|
1764
|
|
1765 /* If point was not in a line that was displayed, find it */
|
|
1766 if (cursor_vpos < 0)
|
|
1767 {
|
|
1768 val = *compute_motion (start, 0, lmargin, point, 10000, 10000,
|
|
1769 width, hscroll, pos_tab_offset (w, start));
|
769
|
1770 /* Admit failure if point is off frame now */
|
277
|
1771 if (val.vpos >= height)
|
|
1772 {
|
|
1773 for (vpos = 0; vpos < height; vpos++)
|
769
|
1774 cancel_line (vpos + top, f);
|
277
|
1775 return 0;
|
|
1776 }
|
|
1777 cursor_vpos = val.vpos + top;
|
|
1778 cursor_hpos = val.hpos + XFASTINT (w->left);
|
|
1779 }
|
|
1780
|
769
|
1781 FRAME_CURSOR_X (f) = max (0, cursor_hpos);
|
|
1782 FRAME_CURSOR_Y (f) = cursor_vpos;
|
277
|
1783
|
|
1784 if (debug_end_pos)
|
|
1785 {
|
|
1786 val = *compute_motion (start, 0, lmargin, ZV,
|
|
1787 height, - (1 << (SHORTBITS - 1)),
|
|
1788 width, hscroll, pos_tab_offset (w, start));
|
|
1789 if (val.vpos != XFASTINT (w->window_end_vpos))
|
|
1790 abort ();
|
|
1791 if (XFASTINT (w->window_end_pos)
|
|
1792 != Z - val.bufpos)
|
|
1793 abort ();
|
|
1794 }
|
|
1795
|
|
1796 return 1;
|
|
1797 }
|
|
1798
|
2729
|
1799 /* Mark a section of BUF as modified, but only for the sake of redisplay.
|
|
1800 This is useful for recording changes to overlays.
|
|
1801
|
|
1802 We increment the buffer's modification timestamp and set the
|
|
1803 redisplay caches (windows_or_buffers_changed, beg_unchanged, etc)
|
|
1804 as if the region of text between START and END had been modified;
|
|
1805 the redisplay code will check this against the windows' timestamps,
|
|
1806 and redraw the appropriate area of the buffer.
|
|
1807
|
|
1808 However, if the buffer is unmodified, we bump the last-save
|
|
1809 timestamp as well, so that incrementing the timestamp doesn't fool
|
|
1810 Emacs into thinking that the buffer's text has been modified.
|
|
1811
|
|
1812 Tweaking the timestamps shouldn't hurt the first-modification
|
|
1813 timestamps recorded in the undo records; those values aren't
|
|
1814 written until just before a real text modification is made, so they
|
|
1815 will never catch the timestamp value just before this function gets
|
|
1816 called. */
|
|
1817
|
|
1818 void
|
|
1819 redisplay_region (buf, start, end)
|
|
1820 struct buffer *buf;
|
|
1821 int start, end;
|
|
1822 {
|
|
1823 if (start == end)
|
|
1824 return;
|
|
1825
|
|
1826 if (start > end)
|
|
1827 {
|
|
1828 int temp = start;
|
|
1829 start = end; end = temp;
|
|
1830 }
|
|
1831
|
|
1832 if (buf != current_buffer)
|
|
1833 windows_or_buffers_changed = 1;
|
|
1834 else
|
|
1835 {
|
|
1836 if (unchanged_modified == MODIFF)
|
|
1837 {
|
|
1838 beg_unchanged = start - BEG;
|
|
1839 end_unchanged = Z - end;
|
|
1840 }
|
|
1841 else
|
|
1842 {
|
|
1843 if (Z - end < end_unchanged)
|
|
1844 end_unchanged = Z - end;
|
|
1845 if (start - BEG < beg_unchanged)
|
|
1846 beg_unchanged = start - BEG;
|
|
1847 }
|
|
1848 }
|
|
1849
|
|
1850 /* Increment the buffer's time stamp, but also increment the save
|
|
1851 and autosave timestamps, so as not to screw up that timekeeping. */
|
|
1852 if (BUF_MODIFF (buf) == buf->save_modified)
|
|
1853 buf->save_modified++;
|
|
1854 if (BUF_MODIFF (buf) == buf->auto_save_modified)
|
|
1855 buf->auto_save_modified++;
|
|
1856
|
|
1857 BUF_MODIFF (buf) ++;
|
|
1858 }
|
|
1859
|
|
1860
|
5800
|
1861 /* Copy LEN glyphs starting address FROM to the rope TO.
|
301
|
1862 But don't actually copy the parts that would come in before S.
|
5800
|
1863 Value is TO, advanced past the copied data.
|
|
1864 F is the frame we are displaying in. */
|
|
1865
|
|
1866 static GLYPH *
|
|
1867 copy_part_of_rope (f, to, s, from, len, face)
|
|
1868 FRAME_PTR f;
|
|
1869 register GLYPH *to; /* Copy to here. */
|
2065
|
1870 register GLYPH *s; /* Starting point. */
|
2766
|
1871 Lisp_Object *from; /* Data to copy. */
|
2065
|
1872 int len;
|
2766
|
1873 int face; /* Face to apply to glyphs which don't specify one. */
|
2065
|
1874 {
|
2754
|
1875 int n = len;
|
5800
|
1876 register Lisp_Object *fp = from;
|
|
1877 /* These cache the results of the last call to compute_glyph_face. */
|
|
1878 int last_code = -1;
|
|
1879 int last_merged = 0;
|
277
|
1880
|
|
1881 while (n--)
|
|
1882 {
|
5800
|
1883 int glyph = XFASTINT (*fp);
|
|
1884 int facecode;
|
|
1885
|
|
1886 if (GLYPH_FACE (glyph) == 0)
|
|
1887 /* If GLYPH has no face code, use FACE. */
|
|
1888 facecode = face;
|
|
1889 else if (GLYPH_FACE (glyph) == last_code)
|
|
1890 /* If it's same as previous glyph, use same result. */
|
|
1891 facecode = last_merged;
|
|
1892 else
|
|
1893 {
|
|
1894 /* Merge this glyph's face and remember the result. */
|
|
1895 last_code = GLYPH_FACE (glyph);
|
|
1896 last_merged = facecode = compute_glyph_face (f, last_code, face);
|
|
1897 }
|
|
1898
|
|
1899 if (to >= s) *to = MAKE_GLYPH (GLYPH_CHAR (glyph), facecode);
|
|
1900 ++to;
|
|
1901 ++fp;
|
277
|
1902 }
|
5800
|
1903 return to;
|
|
1904 }
|
|
1905
|
|
1906 /* Correct a glyph by replacing its specified user-level face code
|
|
1907 with a displayable computed face code. */
|
|
1908
|
|
1909 static GLYPH
|
|
1910 fix_glyph (f, glyph, current_face)
|
|
1911 FRAME_PTR f;
|
|
1912 GLYPH glyph;
|
|
1913 int current_face;
|
|
1914 {
|
|
1915 if (GLYPH_FACE (glyph) == 0)
|
|
1916 return glyph;
|
|
1917 return MAKE_GLYPH (GLYPH_CHAR (glyph),
|
|
1918 compute_glyph_face (f, GLYPH_FACE (glyph), current_face));
|
277
|
1919 }
|
|
1920
|
|
1921 /* Display one line of window w, starting at position START in W's buffer.
|
|
1922 Display starting at horizontal position HPOS, which is normally zero
|
|
1923 or negative. A negative value causes output up to hpos = 0 to be discarded.
|
|
1924 This is done for negative hscroll, or when this is a continuation line
|
|
1925 and the continuation occurred in the middle of a multi-column character.
|
|
1926
|
|
1927 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
|
|
1928
|
769
|
1929 Display on position VPOS on the frame. (origin 0).
|
277
|
1930
|
|
1931 Returns a STRUCT POSITION giving character to start next line with
|
|
1932 and where to display it, including a zero or negative hpos.
|
|
1933 The vpos field is not really a vpos; it is 1 unless the line is continued */
|
|
1934
|
|
1935 struct position val_display_text_line;
|
|
1936
|
|
1937 static struct position *
|
|
1938 display_text_line (w, start, vpos, hpos, taboffset)
|
|
1939 struct window *w;
|
|
1940 int start;
|
|
1941 int vpos;
|
|
1942 int hpos;
|
|
1943 int taboffset;
|
|
1944 {
|
|
1945 register int pos = start;
|
|
1946 register int c;
|
|
1947 register GLYPH *p1;
|
|
1948 int end;
|
|
1949 register int pause;
|
|
1950 register unsigned char *p;
|
|
1951 GLYPH *endp;
|
|
1952 register GLYPH *startp;
|
3586
|
1953 register GLYPH *p1prev = 0;
|
769
|
1954 FRAME_PTR f = XFRAME (w->frame);
|
277
|
1955 int tab_width = XINT (current_buffer->tab_width);
|
485
|
1956 int ctl_arrow = !NILP (current_buffer->ctl_arrow);
|
1785
|
1957 int width = window_internal_width (w) - 1;
|
277
|
1958 struct position val;
|
|
1959 int lastpos;
|
|
1960 int invis;
|
|
1961 int hscroll = XINT (w->hscroll);
|
|
1962 int truncate = hscroll
|
|
1963 || (truncate_partial_width_windows
|
769
|
1964 && XFASTINT (w->width) < FRAME_WIDTH (f))
|
485
|
1965 || !NILP (current_buffer->truncate_lines);
|
2848
|
1966
|
|
1967 /* 1 if we should highlight the region. */
|
|
1968 int highlight_region
|
|
1969 = !NILP (Vtransient_mark_mode) && !NILP (current_buffer->mark_active);
|
|
1970 int region_beg, region_end;
|
|
1971
|
277
|
1972 int selective
|
|
1973 = XTYPE (current_buffer->selective_display) == Lisp_Int
|
|
1974 ? XINT (current_buffer->selective_display)
|
485
|
1975 : !NILP (current_buffer->selective_display) ? -1 : 0;
|
769
|
1976 register struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (f);
|
277
|
1977 register struct Lisp_Vector *dp = window_display_table (w);
|
2754
|
1978
|
|
1979 Lisp_Object default_invis_vector[3];
|
|
1980 /* Nonzero means display something where there are invisible lines.
|
|
1981 The precise value is the number of glyphs to display. */
|
277
|
1982 int selective_rlen
|
2065
|
1983 = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector
|
2754
|
1984 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size
|
|
1985 : selective && !NILP (current_buffer->selective_display_ellipses)
|
|
1986 ? 3 : 0);
|
|
1987 /* This is the sequence of Lisp objects to display
|
|
1988 when there are invisible lines. */
|
|
1989 Lisp_Object *invis_vector_contents
|
|
1990 = (dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector
|
|
1991 ? XVECTOR (DISP_INVIS_VECTOR (dp))->contents
|
|
1992 : default_invis_vector);
|
|
1993
|
277
|
1994 GLYPH truncator = (dp == 0 || XTYPE (DISP_TRUNC_GLYPH (dp)) != Lisp_Int
|
5800
|
1995 ? '$' : XINT (DISP_TRUNC_GLYPH (dp)));
|
277
|
1996 GLYPH continuer = (dp == 0 || XTYPE (DISP_CONTINUE_GLYPH (dp)) != Lisp_Int
|
5800
|
1997 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp)));
|
277
|
1998
|
2729
|
1999 /* The next buffer location at which the face should change, due
|
|
2000 to overlays or text property changes. */
|
|
2001 int next_face_change;
|
|
2002
|
4386
|
2003 #ifdef USE_TEXT_PROPERTIES
|
|
2004 /* The next location where the `invisible' property changes */
|
|
2005 int next_invisible;
|
|
2006 #endif
|
|
2007
|
2729
|
2008 /* The face we're currently using. */
|
2766
|
2009 int current_face = 0;
|
2729
|
2010
|
2754
|
2011 XFASTINT (default_invis_vector[2]) = '.';
|
|
2012 default_invis_vector[0] = default_invis_vector[1] = default_invis_vector[2];
|
|
2013
|
277
|
2014 hpos += XFASTINT (w->left);
|
769
|
2015 get_display_line (f, vpos, XFASTINT (w->left));
|
2324
24cd3df6f184
(display_string, display_text_line): Allow tab_width up to 1000.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2016 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
|
277
|
2017
|
2848
|
2018 /* Show where to highlight the region. */
|
2965
|
2019 if (highlight_region && XMARKER (current_buffer->mark)->buffer != 0
|
3265
|
2020 /* Maybe highlight only in selected window. */
|
|
2021 && (highlight_nonselected_windows
|
3266
1173bc4814da
(display_text_line): Really check for just the selected window.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2022 || w == XWINDOW (selected_window)))
|
2848
|
2023 {
|
|
2024 region_beg = marker_position (current_buffer->mark);
|
|
2025 if (PT < region_beg)
|
|
2026 {
|
|
2027 region_end = region_beg;
|
|
2028 region_beg = PT;
|
|
2029 }
|
|
2030 else
|
|
2031 region_end = PT;
|
|
2032 w->region_showing = Qt;
|
|
2033 }
|
|
2034 else
|
|
2035 region_beg = region_end = -1;
|
|
2036
|
277
|
2037 if (MINI_WINDOW_P (w) && start == 1
|
|
2038 && vpos == XFASTINT (w->top))
|
|
2039 {
|
|
2040 if (minibuf_prompt)
|
5230
|
2041 hpos = display_string (w, vpos, minibuf_prompt, -1, hpos,
|
277
|
2042 (!truncate ? continuer : truncator),
|
5800
|
2043 1, -1, -1);
|
277
|
2044 minibuf_prompt_width = hpos;
|
|
2045 }
|
|
2046
|
|
2047 desired_glyphs->bufp[vpos] = pos;
|
|
2048 p1 = desired_glyphs->glyphs[vpos] + hpos;
|
|
2049 end = ZV;
|
|
2050 startp = desired_glyphs->glyphs[vpos] + XFASTINT (w->left);
|
|
2051 endp = startp + width;
|
|
2052
|
2766
|
2053 /* Arrange the overlays nicely for our purposes. Usually, we call
|
|
2054 display_text_line on only one line at a time, in which case this
|
|
2055 can't really hurt too much, or we call it on lines which appear
|
|
2056 one after another in the buffer, in which case all calls to
|
|
2057 recenter_overlay_lists but the first will be pretty cheap. */
|
|
2058 recenter_overlay_lists (current_buffer, pos);
|
|
2059
|
277
|
2060 /* Loop generating characters.
|
|
2061 Stop at end of buffer, before newline,
|
2729
|
2062 if reach or pass continuation column,
|
|
2063 or at face change. */
|
277
|
2064 pause = pos;
|
2729
|
2065 next_face_change = pos;
|
4386
|
2066 #ifdef USE_TEXT_PROPERTIES
|
|
2067 next_invisible = pos;
|
|
2068 #endif
|
277
|
2069 while (p1 < endp)
|
|
2070 {
|
|
2071 p1prev = p1;
|
2729
|
2072 if (pos >= pause)
|
277
|
2073 {
|
2729
|
2074 /* Did we hit the end of the visible region of the buffer?
|
|
2075 Stop here. */
|
|
2076 if (pos >= end)
|
277
|
2077 break;
|
2729
|
2078
|
|
2079 /* Did we reach point? Record the cursor location. */
|
277
|
2080 if (pos == point && cursor_vpos < 0)
|
|
2081 {
|
|
2082 cursor_vpos = vpos;
|
|
2083 cursor_hpos = p1 - startp;
|
|
2084 }
|
|
2085
|
4386
|
2086 #ifdef USE_TEXT_PROPERTIES
|
|
2087 /* if the `invisible' property is set to t, we can skip to
|
|
2088 the next property change */
|
|
2089 while (pos == next_invisible && pos < end)
|
|
2090 {
|
6066
4ff0c5c05867
(try_window, display_text_line): Use Fget_char_property to test for invisibility.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2091 Lisp_Object position, limit, endpos, prop, ww;
|
5082
|
2092 XFASTINT (position) = pos;
|
6066
4ff0c5c05867
(try_window, display_text_line): Use Fget_char_property to test for invisibility.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2093 XSET (ww, Lisp_Window, w);
|
4ff0c5c05867
(try_window, display_text_line): Use Fget_char_property to test for invisibility.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2094 prop = Fget_char_property (position, Qinvisible, ww);
|
5082
|
2095 /* This is just an estimate to give reasonable
|
|
2096 performance; nothing should go wrong if it is too small. */
|
6091
b634e16673ab
(display_text_line): Allow for invisible overlays in next_invisible lookahead.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2097 limit = Fnext_overlay_change (position);
|
b634e16673ab
(display_text_line): Allow for invisible overlays in next_invisible lookahead.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2098 if (XFASTINT (limit) > pos + 50)
|
b634e16673ab
(display_text_line): Allow for invisible overlays in next_invisible lookahead.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2099 XFASTINT (limit) = pos + 50;
|
b634e16673ab
(display_text_line): Allow for invisible overlays in next_invisible lookahead.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2100 endpos = Fnext_single_property_change (position, Qinvisible,
|
5082
|
2101 Fcurrent_buffer (), limit);
|
|
2102 if (INTEGERP (endpos))
|
|
2103 next_invisible = XINT (endpos);
|
|
2104 else
|
|
2105 next_invisible = end;
|
|
2106 if (! NILP (prop))
|
|
2107 {
|
|
2108 if (pos < point && next_invisible >= point)
|
|
2109 {
|
|
2110 cursor_vpos = vpos;
|
|
2111 cursor_hpos = p1 - startp;
|
|
2112 }
|
|
2113 pos = next_invisible;
|
|
2114 }
|
4386
|
2115 }
|
|
2116 if (pos >= end)
|
|
2117 break;
|
|
2118 #endif
|
|
2119
|
2742
|
2120 #ifdef HAVE_X_WINDOWS
|
2729
|
2121 /* Did we hit a face change? Figure out what face we should
|
|
2122 use now. We also hit this the first time through the
|
|
2123 loop, to see what face we should start with. */
|
4386
|
2124 if (pos >= next_face_change && FRAME_X_P (f))
|
2848
|
2125 current_face = compute_char_face (f, w, pos,
|
|
2126 region_beg, region_end,
|
5082
|
2127 &next_face_change, pos + 50);
|
2742
|
2128 #endif
|
2729
|
2129
|
2766
|
2130 pause = end;
|
|
2131
|
4386
|
2132 #ifdef USE_TEXT_PROPERTIES
|
|
2133 if (pos < next_invisible && next_invisible < pause)
|
|
2134 pause = next_invisible;
|
|
2135 #endif
|
2766
|
2136 if (pos < next_face_change && next_face_change < pause)
|
|
2137 pause = next_face_change;
|
|
2138
|
2729
|
2139 /* Wouldn't you hate to read the next line to someone over
|
|
2140 the phone? */
|
277
|
2141 if (pos < point && point < pause)
|
|
2142 pause = point;
|
|
2143 if (pos < GPT && GPT < pause)
|
|
2144 pause = GPT;
|
|
2145
|
|
2146 p = &FETCH_CHAR (pos);
|
|
2147 }
|
|
2148 c = *p++;
|
|
2149 if (c >= 040 && c < 0177
|
2065
|
2150 && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector))
|
277
|
2151 {
|
|
2152 if (p1 >= startp)
|
2766
|
2153 *p1 = MAKE_GLYPH (c, current_face);
|
277
|
2154 p1++;
|
|
2155 }
|
|
2156 else if (c == '\n')
|
|
2157 {
|
|
2158 invis = 0;
|
|
2159 while (pos < end
|
|
2160 && selective > 0
|
5942
|
2161 && indented_beyond_p (pos + 1, selective))
|
277
|
2162 {
|
|
2163 invis = 1;
|
|
2164 pos = find_next_newline (pos + 1, 1);
|
|
2165 if (FETCH_CHAR (pos - 1) == '\n')
|
|
2166 pos--;
|
|
2167 }
|
|
2168 if (invis && selective_rlen > 0 && p1 >= startp)
|
|
2169 {
|
|
2170 p1 += selective_rlen;
|
|
2171 if (p1 - startp > width)
|
|
2172 p1 = endp;
|
5800
|
2173 copy_part_of_rope (f, p1prev, p1prev, invis_vector_contents,
|
2766
|
2174 (p1 - p1prev), current_face);
|
277
|
2175 }
|
2884
|
2176 #if 1
|
|
2177 /* Draw the face of the newline character as extending all the
|
|
2178 way to the end of the frame line. */
|
|
2179 if (current_face)
|
|
2180 while (p1 < endp)
|
|
2181 *p1++ = MAKE_GLYPH (' ', current_face);
|
|
2182 #endif
|
2754
|
2183 break;
|
277
|
2184 }
|
|
2185 else if (c == '\t')
|
|
2186 {
|
|
2187 do
|
|
2188 {
|
|
2189 if (p1 >= startp && p1 < endp)
|
2766
|
2190 *p1 = MAKE_GLYPH (' ', current_face);
|
277
|
2191 p1++;
|
|
2192 }
|
|
2193 while ((p1 - startp + taboffset + hscroll - (hscroll > 0))
|
|
2194 % tab_width);
|
|
2195 }
|
368
|
2196 else if (c == Ctl ('M') && selective == -1)
|
277
|
2197 {
|
|
2198 pos = find_next_newline (pos, 1);
|
|
2199 if (FETCH_CHAR (pos - 1) == '\n')
|
|
2200 pos--;
|
|
2201 if (selective_rlen > 0)
|
|
2202 {
|
|
2203 p1 += selective_rlen;
|
|
2204 if (p1 - startp > width)
|
|
2205 p1 = endp;
|
5800
|
2206 copy_part_of_rope (f, p1prev, p1prev, invis_vector_contents,
|
2766
|
2207 (p1 - p1prev), current_face);
|
277
|
2208 }
|
2884
|
2209 #if 1
|
|
2210 /* Draw the face of the newline character as extending all the
|
|
2211 way to the end of the frame line. */
|
|
2212 if (current_face)
|
|
2213 while (p1 < endp)
|
|
2214 *p1++ = MAKE_GLYPH (' ', current_face);
|
|
2215 #endif
|
2754
|
2216 break;
|
277
|
2217 }
|
2065
|
2218 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector)
|
277
|
2219 {
|
5800
|
2220 p1 = copy_part_of_rope (f, p1, startp,
|
|
2221 XVECTOR (DISP_CHAR_VECTOR (dp, c))->contents,
|
|
2222 XVECTOR (DISP_CHAR_VECTOR (dp, c))->size,
|
|
2223 current_face);
|
277
|
2224 }
|
|
2225 else if (c < 0200 && ctl_arrow)
|
|
2226 {
|
|
2227 if (p1 >= startp)
|
5800
|
2228 *p1 = fix_glyph (f, (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int
|
|
2229 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'),
|
|
2230 current_face);
|
277
|
2231 p1++;
|
368
|
2232 if (p1 >= startp && p1 < endp)
|
2766
|
2233 *p1 = MAKE_GLYPH (c ^ 0100, current_face);
|
277
|
2234 p1++;
|
|
2235 }
|
|
2236 else
|
|
2237 {
|
|
2238 if (p1 >= startp)
|
5800
|
2239 *p1 = fix_glyph (f, (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int
|
|
2240 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'),
|
|
2241 current_face);
|
277
|
2242 p1++;
|
368
|
2243 if (p1 >= startp && p1 < endp)
|
2766
|
2244 *p1 = MAKE_GLYPH ((c >> 6) + '0', current_face);
|
2729
|
2245 p1++;
|
|
2246 if (p1 >= startp && p1 < endp)
|
2766
|
2247 *p1 = MAKE_GLYPH ((7 & (c >> 3)) + '0', current_face);
|
277
|
2248 p1++;
|
368
|
2249 if (p1 >= startp && p1 < endp)
|
2766
|
2250 *p1 = MAKE_GLYPH ((7 & c) + '0', current_face);
|
277
|
2251 p1++;
|
|
2252 }
|
2729
|
2253
|
277
|
2254 pos++;
|
|
2255 }
|
|
2256
|
|
2257 val.hpos = - XINT (w->hscroll);
|
|
2258 if (val.hpos)
|
|
2259 val.hpos++;
|
|
2260
|
|
2261 val.vpos = 1;
|
|
2262
|
|
2263 lastpos = pos;
|
|
2264
|
|
2265 /* Handle continuation in middle of a character */
|
|
2266 /* by backing up over it */
|
|
2267 if (p1 > endp)
|
|
2268 {
|
3586
|
2269 /* Don't back up if we never actually displayed any text.
|
|
2270 This occurs when the minibuffer prompt takes up the whole line. */
|
|
2271 if (p1prev)
|
|
2272 {
|
|
2273 /* Start the next line with that same character */
|
|
2274 pos--;
|
|
2275 /* but at negative hpos, to skip the columns output on this line. */
|
|
2276 val.hpos += p1prev - endp;
|
|
2277 }
|
|
2278
|
277
|
2279 /* Keep in this line everything up to the continuation column. */
|
|
2280 p1 = endp;
|
|
2281 }
|
|
2282
|
|
2283 /* Finish deciding which character to start the next line on,
|
|
2284 and what hpos to start it at.
|
|
2285 Also set `lastpos' to the last position which counts as "on this line"
|
|
2286 for cursor-positioning. */
|
|
2287
|
|
2288 if (pos < ZV)
|
|
2289 {
|
|
2290 if (FETCH_CHAR (pos) == '\n')
|
|
2291 /* If stopped due to a newline, start next line after it */
|
|
2292 pos++;
|
|
2293 else
|
|
2294 /* Stopped due to right margin of window */
|
|
2295 {
|
|
2296 if (truncate)
|
|
2297 {
|
5800
|
2298 *p1++ = fix_glyph (f, truncator, 0);
|
277
|
2299 /* Truncating => start next line after next newline,
|
|
2300 and point is on this line if it is before the newline,
|
|
2301 and skip none of first char of next line */
|
|
2302 pos = find_next_newline (pos, 1);
|
|
2303 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0;
|
|
2304
|
|
2305 lastpos = pos - (FETCH_CHAR (pos - 1) == '\n');
|
|
2306 }
|
|
2307 else
|
|
2308 {
|
5800
|
2309 *p1++ = fix_glyph (f, continuer, 0);
|
277
|
2310 val.vpos = 0;
|
|
2311 lastpos--;
|
|
2312 }
|
|
2313 }
|
|
2314 }
|
|
2315
|
|
2316 /* If point is at eol or in invisible text at eol,
|
769
|
2317 record its frame location now. */
|
277
|
2318
|
|
2319 if (start <= point && point <= lastpos && cursor_vpos < 0)
|
|
2320 {
|
|
2321 cursor_vpos = vpos;
|
|
2322 cursor_hpos = p1 - startp;
|
|
2323 }
|
|
2324
|
|
2325 if (cursor_vpos == vpos)
|
|
2326 {
|
|
2327 if (cursor_hpos < 0) cursor_hpos = 0;
|
|
2328 if (cursor_hpos > width) cursor_hpos = width;
|
|
2329 cursor_hpos += XFASTINT (w->left);
|
769
|
2330 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f)))
|
277
|
2331 {
|
769
|
2332 FRAME_CURSOR_Y (f) = cursor_vpos;
|
|
2333 FRAME_CURSOR_X (f) = cursor_hpos;
|
277
|
2334
|
|
2335 if (w == XWINDOW (selected_window))
|
|
2336 {
|
|
2337 /* Line is not continued and did not start
|
|
2338 in middle of character */
|
|
2339 if ((hpos - XFASTINT (w->left)
|
|
2340 == (XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0))
|
|
2341 && val.vpos)
|
|
2342 {
|
|
2343 this_line_bufpos = start;
|
|
2344 this_line_buffer = current_buffer;
|
|
2345 this_line_vpos = cursor_vpos;
|
|
2346 this_line_start_hpos = hpos;
|
|
2347 this_line_endpos = Z - lastpos;
|
|
2348 }
|
|
2349 else
|
|
2350 this_line_bufpos = 0;
|
|
2351 }
|
|
2352 }
|
|
2353 }
|
|
2354
|
|
2355 /* If hscroll and line not empty, insert truncation-at-left marker */
|
|
2356 if (hscroll && lastpos != start)
|
|
2357 {
|
5800
|
2358 *startp = fix_glyph (f, truncator, 0);
|
277
|
2359 if (p1 <= startp)
|
|
2360 p1 = startp + 1;
|
|
2361 }
|
|
2362
|
769
|
2363 if (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f))
|
277
|
2364 {
|
|
2365 endp++;
|
|
2366 if (p1 < startp) p1 = startp;
|
|
2367 while (p1 < endp) *p1++ = SPACEGLYPH;
|
1785
|
2368
|
1992
|
2369 /* Don't draw vertical bars if we're using scroll bars. They're
|
|
2370 covered up by the scroll bars, and it's distracting to see
|
|
2371 them when the scroll bar windows are flickering around to be
|
1785
|
2372 reconfigured. */
|
1992
|
2373 *p1++ = (FRAME_HAS_VERTICAL_SCROLL_BARS (f)
|
1785
|
2374 ? ' ' : '|');
|
277
|
2375 }
|
|
2376 desired_glyphs->used[vpos] = max (desired_glyphs->used[vpos],
|
|
2377 p1 - desired_glyphs->glyphs[vpos]);
|
|
2378 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0;
|
|
2379
|
|
2380 /* If the start of this line is the overlay arrow-position,
|
|
2381 then put the arrow string into the display-line. */
|
|
2382
|
|
2383 if (XTYPE (Voverlay_arrow_position) == Lisp_Marker
|
|
2384 && current_buffer == XMARKER (Voverlay_arrow_position)->buffer
|
|
2385 && start == marker_position (Voverlay_arrow_position)
|
|
2386 && XTYPE (Voverlay_arrow_string) == Lisp_String
|
|
2387 && ! overlay_arrow_seen)
|
|
2388 {
|
|
2389 unsigned char *p = XSTRING (Voverlay_arrow_string)->data;
|
|
2390 int i;
|
|
2391 int len = XSTRING (Voverlay_arrow_string)->size;
|
3726
|
2392 int arrow_end;
|
277
|
2393
|
1785
|
2394 if (len > width)
|
|
2395 len = width;
|
277
|
2396 for (i = 0; i < len; i++)
|
|
2397 startp[i] = p[i];
|
3726
|
2398
|
|
2399 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
|
|
2400 arrow_end = (startp - desired_glyphs->glyphs[vpos]) + len;
|
|
2401 if (desired_glyphs->used[vpos] < arrow_end)
|
|
2402 desired_glyphs->used[vpos] = arrow_end;
|
277
|
2403
|
|
2404 overlay_arrow_seen = 1;
|
|
2405 }
|
|
2406
|
|
2407 val.bufpos = pos;
|
|
2408 val_display_text_line = val;
|
|
2409 return &val_display_text_line;
|
|
2410 }
|
|
2411
|
2150
|
2412 /* Redisplay the menu bar in the frame for window W. */
|
|
2413
|
|
2414 static void
|
|
2415 display_menu_bar (w)
|
|
2416 struct window *w;
|
|
2417 {
|
|
2418 Lisp_Object items, tail;
|
|
2419 register int vpos = 0;
|
|
2420 register FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
|
|
2421 int maxendcol = FRAME_WIDTH (f);
|
|
2422 int hpos = 0;
|
6134
|
2423 int i;
|
2150
|
2424
|
5658
|
2425 #ifndef USE_X_TOOLKIT
|
2150
|
2426 if (FRAME_MENU_BAR_LINES (f) <= 0)
|
|
2427 return;
|
|
2428
|
|
2429 get_display_line (f, vpos, 0);
|
|
2430
|
6134
|
2431 items = FRAME_MENU_BAR_ITEMS (f);
|
|
2432 for (i = 0; i < XVECTOR (items)->size; i += 3)
|
2150
|
2433 {
|
6134
|
2434 Lisp_Object pos, string;
|
|
2435 string = XVECTOR (items)->contents[i + 1];
|
|
2436 if (NILP (string))
|
|
2437 break;
|
|
2438
|
|
2439 XFASTINT (XVECTOR (items)->contents[i + 2]) = hpos;
|
2150
|
2440
|
|
2441 if (hpos < maxendcol)
|
|
2442 hpos = display_string (XWINDOW (FRAME_ROOT_WINDOW (f)), vpos,
|
|
2443 XSTRING (string)->data,
|
5230
|
2444 XSTRING (string)->size,
|
5800
|
2445 hpos, 0, 0, hpos, maxendcol);
|
2189
|
2446 /* Put a gap of 3 spaces between items. */
|
|
2447 if (hpos < maxendcol)
|
|
2448 {
|
|
2449 int hpos1 = hpos + 3;
|
5800
|
2450 hpos = display_string (w, vpos, "", 0, hpos, 0, 0,
|
2189
|
2451 min (hpos1, maxendcol), maxendcol);
|
|
2452 }
|
2150
|
2453 }
|
|
2454
|
|
2455 FRAME_DESIRED_GLYPHS (f)->bufp[vpos] = 0;
|
|
2456 FRAME_DESIRED_GLYPHS (f)->highlight[vpos] = mode_line_inverse_video;
|
2189
|
2457
|
|
2458 /* Fill out the line with spaces. */
|
|
2459 if (maxendcol > hpos)
|
5800
|
2460 hpos = display_string (w, vpos, "", 0, hpos, 0, 0, maxendcol, maxendcol);
|
4423
|
2461
|
|
2462 /* Clear the rest of the lines allocated to the menu bar. */
|
|
2463 vpos++;
|
|
2464 while (vpos < FRAME_MENU_BAR_LINES (f))
|
|
2465 get_display_line (f, vpos++, 0);
|
5658
|
2466 #endif /* not USE_X_TOOLKIT */
|
2150
|
2467 }
|
|
2468
|
277
|
2469 /* Display the mode line for window w */
|
|
2470
|
|
2471 static void
|
|
2472 display_mode_line (w)
|
|
2473 struct window *w;
|
|
2474 {
|
|
2475 register int vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1;
|
|
2476 register int left = XFASTINT (w->left);
|
|
2477 register int right = XFASTINT (w->width) + left;
|
769
|
2478 register FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
|
277
|
2479
|
2303
|
2480 line_number_displayed = 0;
|
|
2481
|
769
|
2482 get_display_line (f, vpos, left);
|
277
|
2483 display_mode_element (w, vpos, left, 0, right, right,
|
|
2484 current_buffer->mode_line_format);
|
769
|
2485 FRAME_DESIRED_GLYPHS (f)->bufp[vpos] = 0;
|
277
|
2486
|
|
2487 /* Make the mode line inverse video if the entire line
|
|
2488 is made of mode lines.
|
|
2489 I.e. if this window is full width,
|
|
2490 or if it is the child of a full width window
|
|
2491 (which implies that that window is split side-by-side
|
|
2492 and the rest of this line is mode lines of the sibling windows). */
|
769
|
2493 if (XFASTINT (w->width) == FRAME_WIDTH (f)
|
|
2494 || XFASTINT (XWINDOW (w->parent)->width) == FRAME_WIDTH (f))
|
|
2495 FRAME_DESIRED_GLYPHS (f)->highlight[vpos] = mode_line_inverse_video;
|
6278
|
2496 else if (! FRAME_TERMCAP_P (f))
|
|
2497 {
|
|
2498 /* For a partial width window, explicitly set face of each glyph. */
|
|
2499 int i;
|
|
2500 GLYPH *ptr = FRAME_DESIRED_GLYPHS (f)->glyphs[vpos];
|
|
2501 for (i = left; i < right; ++i)
|
|
2502 ptr[i] = MAKE_GLYPH (GLYPH_CHAR (ptr[i]), 1);
|
|
2503 }
|
277
|
2504
|
|
2505 #ifdef HAVE_X_WINDOWS
|
6308
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2506 if (w == XWINDOW (f->selected_window))
|
f34deea7dc2c
(x_consider_frame_title): New function, extracted from display_mode_line.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2507 x_consider_frame_title (WINDOW_FRAME (w));
|
277
|
2508 #endif
|
|
2509 }
|
|
2510
|
|
2511 /* Contribute ELT to the mode line for window W.
|
|
2512 How it translates into text depends on its data type.
|
|
2513
|
|
2514 VPOS is the position of the mode line being displayed.
|
|
2515
|
769
|
2516 HPOS is the position (absolute on frame) where this element's text
|
277
|
2517 should start. The output is truncated automatically at the right
|
|
2518 edge of window W.
|
|
2519
|
|
2520 DEPTH is the depth in recursion. It is used to prevent
|
|
2521 infinite recursion here.
|
|
2522
|
|
2523 MINENDCOL is the hpos before which the element may not end.
|
|
2524 The element is padded at the right with spaces if nec
|
|
2525 to reach this column.
|
|
2526
|
|
2527 MAXENDCOL is the hpos past which this element may not extend.
|
|
2528 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
|
|
2529 (This is necessary to make nested padding and truncation work.)
|
|
2530
|
|
2531 Returns the hpos of the end of the text generated by ELT.
|
|
2532 The next element will receive that value as its HPOS arg,
|
|
2533 so as to concatenate the elements. */
|
|
2534
|
|
2535 static int
|
|
2536 display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt)
|
|
2537 struct window *w;
|
|
2538 register int vpos, hpos;
|
|
2539 int depth;
|
|
2540 int minendcol;
|
|
2541 register int maxendcol;
|
|
2542 register Lisp_Object elt;
|
|
2543 {
|
|
2544 tail_recurse:
|
|
2545 if (depth > 10)
|
|
2546 goto invalid;
|
|
2547
|
|
2548 depth++;
|
|
2549
|
|
2550 #ifdef SWITCH_ENUM_BUG
|
|
2551 switch ((int) XTYPE (elt))
|
|
2552 #else
|
|
2553 switch (XTYPE (elt))
|
|
2554 #endif
|
|
2555 {
|
|
2556 case Lisp_String:
|
|
2557 {
|
|
2558 /* A string: output it and check for %-constructs within it. */
|
|
2559 register unsigned char c;
|
|
2560 register unsigned char *this = XSTRING (elt)->data;
|
|
2561
|
|
2562 while (hpos < maxendcol && *this)
|
|
2563 {
|
|
2564 unsigned char *last = this;
|
|
2565 while ((c = *this++) != '\0' && c != '%')
|
|
2566 ;
|
|
2567 if (this - 1 != last)
|
|
2568 {
|
|
2569 register int lim = --this - last + hpos;
|
5800
|
2570 hpos = display_string (w, vpos, last, -1, hpos, 0, 1,
|
|
2571 hpos, min (lim, maxendcol));
|
277
|
2572 }
|
|
2573 else /* c == '%' */
|
|
2574 {
|
|
2575 register int spec_width = 0;
|
|
2576
|
|
2577 /* We can't allow -ve args due to the "%-" construct */
|
|
2578 /* Argument specifies minwidth but not maxwidth
|
|
2579 (maxwidth can be specified by
|
|
2580 (<negative-number> . <stuff>) mode-line elements) */
|
|
2581
|
|
2582 while ((c = *this++) >= '0' && c <= '9')
|
|
2583 {
|
|
2584 spec_width = spec_width * 10 + (c - '0');
|
|
2585 }
|
|
2586
|
|
2587 spec_width += hpos;
|
|
2588 if (spec_width > maxendcol)
|
|
2589 spec_width = maxendcol;
|
|
2590
|
|
2591 if (c == 'M')
|
|
2592 hpos = display_mode_element (w, vpos, hpos, depth,
|
|
2593 spec_width, maxendcol,
|
|
2594 Vglobal_mode_string);
|
|
2595 else if (c != 0)
|
|
2596 hpos = display_string (w, vpos,
|
|
2597 decode_mode_spec (w, c,
|
|
2598 maxendcol - hpos),
|
5230
|
2599 -1,
|
5800
|
2600 hpos, 0, 1, spec_width, maxendcol);
|
277
|
2601 }
|
|
2602 }
|
|
2603 }
|
|
2604 break;
|
|
2605
|
|
2606 case Lisp_Symbol:
|
|
2607 /* A symbol: process the value of the symbol recursively
|
|
2608 as if it appeared here directly. Avoid error if symbol void.
|
|
2609 Special case: if value of symbol is a string, output the string
|
|
2610 literally. */
|
|
2611 {
|
|
2612 register Lisp_Object tem;
|
|
2613 tem = Fboundp (elt);
|
485
|
2614 if (!NILP (tem))
|
277
|
2615 {
|
|
2616 tem = Fsymbol_value (elt);
|
|
2617 /* If value is a string, output that string literally:
|
|
2618 don't check for % within it. */
|
|
2619 if (XTYPE (tem) == Lisp_String)
|
|
2620 hpos = display_string (w, vpos, XSTRING (tem)->data,
|
5230
|
2621 XSTRING (tem)->size,
|
5800
|
2622 hpos, 0, 1, minendcol, maxendcol);
|
277
|
2623 /* Give up right away for nil or t. */
|
|
2624 else if (!EQ (tem, elt))
|
|
2625 { elt = tem; goto tail_recurse; }
|
|
2626 }
|
|
2627 }
|
|
2628 break;
|
|
2629
|
|
2630 case Lisp_Cons:
|
|
2631 {
|
|
2632 register Lisp_Object car, tem;
|
|
2633
|
|
2634 /* A cons cell: three distinct cases.
|
|
2635 If first element is a string or a cons, process all the elements
|
|
2636 and effectively concatenate them.
|
|
2637 If first element is a negative number, truncate displaying cdr to
|
|
2638 at most that many characters. If positive, pad (with spaces)
|
|
2639 to at least that many characters.
|
|
2640 If first element is a symbol, process the cadr or caddr recursively
|
|
2641 according to whether the symbol's value is non-nil or nil. */
|
|
2642 car = XCONS (elt)->car;
|
|
2643 if (XTYPE (car) == Lisp_Symbol)
|
|
2644 {
|
|
2645 tem = Fboundp (car);
|
|
2646 elt = XCONS (elt)->cdr;
|
|
2647 if (XTYPE (elt) != Lisp_Cons)
|
|
2648 goto invalid;
|
|
2649 /* elt is now the cdr, and we know it is a cons cell.
|
|
2650 Use its car if CAR has a non-nil value. */
|
485
|
2651 if (!NILP (tem))
|
277
|
2652 {
|
|
2653 tem = Fsymbol_value (car);
|
485
|
2654 if (!NILP (tem))
|
277
|
2655 { elt = XCONS (elt)->car; goto tail_recurse; }
|
|
2656 }
|
|
2657 /* Symbol's value is nil (or symbol is unbound)
|
|
2658 Get the cddr of the original list
|
|
2659 and if possible find the caddr and use that. */
|
|
2660 elt = XCONS (elt)->cdr;
|
485
|
2661 if (NILP (elt))
|
277
|
2662 break;
|
|
2663 else if (XTYPE (elt) != Lisp_Cons)
|
|
2664 goto invalid;
|
|
2665 elt = XCONS (elt)->car;
|
|
2666 goto tail_recurse;
|
|
2667 }
|
|
2668 else if (XTYPE (car) == Lisp_Int)
|
|
2669 {
|
|
2670 register int lim = XINT (car);
|
|
2671 elt = XCONS (elt)->cdr;
|
|
2672 if (lim < 0)
|
|
2673 /* Negative int means reduce maximum width.
|
|
2674 DO NOT change MINENDCOL here!
|
|
2675 (20 -10 . foo) should truncate foo to 10 col
|
|
2676 and then pad to 20. */
|
|
2677 maxendcol = min (maxendcol, hpos - lim);
|
|
2678 else if (lim > 0)
|
|
2679 {
|
|
2680 /* Padding specified. Don't let it be more than
|
|
2681 current maximum. */
|
|
2682 lim += hpos;
|
|
2683 if (lim > maxendcol)
|
|
2684 lim = maxendcol;
|
|
2685 /* If that's more padding than already wanted, queue it.
|
|
2686 But don't reduce padding already specified even if
|
|
2687 that is beyond the current truncation point. */
|
|
2688 if (lim > minendcol)
|
|
2689 minendcol = lim;
|
|
2690 }
|
|
2691 goto tail_recurse;
|
|
2692 }
|
|
2693 else if (XTYPE (car) == Lisp_String || XTYPE (car) == Lisp_Cons)
|
|
2694 {
|
|
2695 register int limit = 50;
|
|
2696 /* LIMIT is to protect against circular lists. */
|
|
2697 while (XTYPE (elt) == Lisp_Cons && --limit > 0
|
|
2698 && hpos < maxendcol)
|
|
2699 {
|
|
2700 hpos = display_mode_element (w, vpos, hpos, depth,
|
|
2701 hpos, maxendcol,
|
|
2702 XCONS (elt)->car);
|
|
2703 elt = XCONS (elt)->cdr;
|
|
2704 }
|
|
2705 }
|
|
2706 }
|
|
2707 break;
|
|
2708
|
|
2709 default:
|
|
2710 invalid:
|
5800
|
2711 return (display_string (w, vpos, "*invalid*", -1, hpos, 0, 1,
|
277
|
2712 minendcol, maxendcol));
|
|
2713 }
|
|
2714
|
|
2715 end:
|
|
2716 if (minendcol > hpos)
|
5800
|
2717 hpos = display_string (w, vpos, "", 0, hpos, 0, 1, minendcol, maxendcol);
|
277
|
2718 return hpos;
|
|
2719 }
|
|
2720
|
|
2721 /* Return a string for the output of a mode line %-spec for window W,
|
|
2722 generated by character C and width MAXWIDTH. */
|
|
2723
|
1017
|
2724 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
|
|
2725
|
277
|
2726 static char *
|
|
2727 decode_mode_spec (w, c, maxwidth)
|
|
2728 struct window *w;
|
|
2729 register char c;
|
|
2730 register int maxwidth;
|
|
2731 {
|
|
2732 Lisp_Object obj = Qnil;
|
769
|
2733 FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
|
|
2734 char *decode_mode_spec_buf = (char *) FRAME_TEMP_GLYPHS (f)->total_contents;
|
277
|
2735
|
769
|
2736 if (maxwidth > FRAME_WIDTH (f))
|
|
2737 maxwidth = FRAME_WIDTH (f);
|
277
|
2738
|
|
2739 switch (c)
|
|
2740 {
|
|
2741 case 'b':
|
|
2742 obj = current_buffer->name;
|
|
2743 #if 0
|
|
2744 if (maxwidth >= 3 && XSTRING (obj)->size > maxwidth)
|
|
2745 {
|
|
2746 bcopy (XSTRING (obj)->data, decode_mode_spec_buf, maxwidth - 1);
|
|
2747 decode_mode_spec_buf[maxwidth - 1] = '\\';
|
|
2748 decode_mode_spec_buf[maxwidth] = '\0';
|
|
2749 return decode_mode_spec_buf;
|
|
2750 }
|
|
2751 #endif
|
|
2752 break;
|
|
2753
|
|
2754 case 'f':
|
|
2755 obj = current_buffer->filename;
|
|
2756 #if 0
|
485
|
2757 if (NILP (obj))
|
277
|
2758 return "[none]";
|
|
2759 else if (XTYPE (obj) == Lisp_String && XSTRING (obj)->size > maxwidth)
|
|
2760 {
|
|
2761 bcopy ("...", decode_mode_spec_buf, 3);
|
|
2762 bcopy (XSTRING (obj)->data + XSTRING (obj)->size - maxwidth + 3,
|
|
2763 decode_mode_spec_buf + 3, maxwidth - 3);
|
|
2764 return decode_mode_spec_buf;
|
|
2765 }
|
|
2766 #endif
|
|
2767 break;
|
|
2768
|
2303
|
2769 case 'l':
|
|
2770 {
|
|
2771 int startpos = marker_position (w->start);
|
|
2772 int line, linepos, topline;
|
|
2773 int nlines, junk;
|
|
2774 Lisp_Object tem;
|
|
2775 int height = XFASTINT (w->height);
|
|
2776
|
|
2777 /* If we decided that this buffer isn't suitable for line numbers,
|
|
2778 don't forget that too fast. */
|
|
2779 if (EQ (w->base_line_pos, w->buffer))
|
|
2780 return "??";
|
|
2781
|
|
2782 /* If the buffer is very big, don't waste time. */
|
|
2783 if (ZV - BEGV > line_number_display_limit)
|
|
2784 {
|
|
2785 w->base_line_pos = Qnil;
|
|
2786 w->base_line_number = Qnil;
|
|
2787 return "??";
|
|
2788 }
|
|
2789
|
|
2790 if (!NILP (w->base_line_number)
|
|
2791 && !NILP (w->base_line_pos)
|
|
2792 && XFASTINT (w->base_line_pos) <= marker_position (w->start))
|
|
2793 {
|
|
2794 line = XFASTINT (w->base_line_number);
|
|
2795 linepos = XFASTINT (w->base_line_pos);
|
|
2796 }
|
|
2797 else
|
|
2798 {
|
|
2799 line = 1;
|
|
2800 linepos = BEGV;
|
|
2801 }
|
|
2802
|
|
2803 /* Count lines from base line to window start position. */
|
|
2804 nlines = display_count_lines (linepos, startpos, startpos, &junk);
|
|
2805
|
|
2806 topline = nlines + line;
|
|
2807
|
|
2808 /* Determine a new base line, if the old one is too close
|
|
2809 or too far away, or if we did not have one.
|
|
2810 "Too close" means it's plausible a scroll-down would
|
|
2811 go back past it. */
|
|
2812 if (startpos == BEGV)
|
|
2813 {
|
|
2814 XFASTINT (w->base_line_number) = topline;
|
|
2815 XFASTINT (w->base_line_pos) = BEGV;
|
|
2816 }
|
|
2817 else if (nlines < height + 25 || nlines > height * 3 + 50
|
|
2818 || linepos == BEGV)
|
|
2819 {
|
|
2820 int limit = BEGV;
|
|
2821 int position;
|
|
2822 int distance = (height * 2 + 30) * 200;
|
|
2823
|
|
2824 if (startpos - distance > limit)
|
|
2825 limit = startpos - distance;
|
|
2826
|
|
2827 nlines = display_count_lines (startpos, limit,
|
|
2828 -(height * 2 + 30),
|
|
2829 &position);
|
|
2830 /* If we couldn't find the lines we wanted within
|
|
2831 200 chars per line,
|
|
2832 give up on line numbers for this window. */
|
|
2833 if (position == startpos - distance)
|
|
2834 {
|
|
2835 w->base_line_pos = w->buffer;
|
|
2836 w->base_line_number = Qnil;
|
|
2837 return "??";
|
|
2838 }
|
|
2839
|
|
2840 XFASTINT (w->base_line_number) = topline - nlines;
|
|
2841 XFASTINT (w->base_line_pos) = position;
|
|
2842 }
|
|
2843
|
|
2844 /* Now count lines from the start pos to point. */
|
|
2845 nlines = display_count_lines (startpos, PT, PT, &junk);
|
|
2846
|
|
2847 /* Record that we did display the line number. */
|
|
2848 line_number_displayed = 1;
|
|
2849
|
|
2850 /* Make the string to show. */
|
|
2851 sprintf (decode_mode_spec_buf, "%d", topline + nlines);
|
|
2852 return decode_mode_spec_buf;
|
|
2853 }
|
|
2854 break;
|
|
2855
|
277
|
2856 case 'm':
|
|
2857 obj = current_buffer->mode_name;
|
|
2858 break;
|
|
2859
|
|
2860 case 'n':
|
|
2861 if (BEGV > BEG || ZV < Z)
|
|
2862 return " Narrow";
|
|
2863 break;
|
|
2864
|
|
2865 case '*':
|
485
|
2866 if (!NILP (current_buffer->read_only))
|
277
|
2867 return "%";
|
|
2868 if (MODIFF > current_buffer->save_modified)
|
|
2869 return "*";
|
|
2870 return "-";
|
|
2871
|
5936
|
2872 case '+':
|
|
2873 if (MODIFF > current_buffer->save_modified)
|
|
2874 return "*";
|
|
2875 return "-";
|
|
2876
|
277
|
2877 case 's':
|
|
2878 /* status of process */
|
|
2879 obj = Fget_buffer_process (Fcurrent_buffer ());
|
485
|
2880 if (NILP (obj))
|
277
|
2881 return "no process";
|
5658
|
2882 #ifdef subprocesses
|
277
|
2883 obj = Fsymbol_name (Fprocess_status (obj));
|
5658
|
2884 #endif
|
277
|
2885 break;
|
|
2886
|
5658
|
2887 case 't': /* indicate TEXT or BINARY */
|
|
2888 #ifdef MSDOS
|
|
2889 decode_mode_spec_buf[0]
|
|
2890 = NILP (current_buffer->buffer_file_type) ? "T" : "B";
|
|
2891 decode_mode_spec_buf[1] = 0;
|
|
2892 return decode_mode_spec_buf;
|
|
2893 #else /* not MSDOS */
|
|
2894 return "T";
|
|
2895 #endif /* not MSDOS */
|
|
2896
|
277
|
2897 case 'p':
|
|
2898 {
|
|
2899 int pos = marker_position (w->start);
|
|
2900 int total = ZV - BEGV;
|
|
2901
|
|
2902 if (XFASTINT (w->window_end_pos) <= Z - ZV)
|
|
2903 {
|
|
2904 if (pos <= BEGV)
|
|
2905 return "All";
|
|
2906 else
|
|
2907 return "Bottom";
|
|
2908 }
|
|
2909 else if (pos <= BEGV)
|
|
2910 return "Top";
|
|
2911 else
|
|
2912 {
|
|
2913 total = ((pos - BEGV) * 100 + total - 1) / total;
|
|
2914 /* We can't normally display a 3-digit number,
|
|
2915 so get us a 2-digit number that is close. */
|
|
2916 if (total == 100)
|
|
2917 total = 99;
|
|
2918 sprintf (decode_mode_spec_buf, "%2d%%", total);
|
|
2919 return decode_mode_spec_buf;
|
|
2920 }
|
|
2921 }
|
|
2922
|
5903
|
2923 /* Display percentage of size above the bottom of the screen. */
|
|
2924 case 'P':
|
|
2925 {
|
|
2926 int toppos = marker_position (w->start);
|
|
2927 int botpos = Z - XFASTINT (w->window_end_pos);
|
|
2928 int total = ZV - BEGV;
|
|
2929
|
|
2930 if (botpos >= ZV)
|
|
2931 {
|
|
2932 if (toppos <= BEGV)
|
|
2933 return "All";
|
|
2934 else
|
|
2935 return "Bottom";
|
|
2936 }
|
|
2937 else
|
|
2938 {
|
|
2939 total = ((botpos - BEGV) * 100 + total - 1) / total;
|
|
2940 /* We can't normally display a 3-digit number,
|
|
2941 so get us a 2-digit number that is close. */
|
|
2942 if (total == 100)
|
|
2943 total = 99;
|
|
2944 if (toppos <= BEGV)
|
|
2945 sprintf (decode_mode_spec_buf, "Top%2d%%", total);
|
|
2946 else
|
|
2947 sprintf (decode_mode_spec_buf, "%2d%%", total);
|
|
2948 return decode_mode_spec_buf;
|
|
2949 }
|
|
2950 }
|
|
2951
|
277
|
2952 case '%':
|
|
2953 return "%";
|
|
2954
|
|
2955 case '[':
|
|
2956 {
|
|
2957 int i;
|
|
2958 char *p;
|
|
2959
|
|
2960 if (command_loop_level > 5)
|
|
2961 return "[[[... ";
|
|
2962 p = decode_mode_spec_buf;
|
|
2963 for (i = 0; i < command_loop_level; i++)
|
|
2964 *p++ = '[';
|
|
2965 *p = 0;
|
|
2966 return decode_mode_spec_buf;
|
|
2967 }
|
|
2968
|
|
2969 case ']':
|
|
2970 {
|
|
2971 int i;
|
|
2972 char *p;
|
|
2973
|
|
2974 if (command_loop_level > 5)
|
|
2975 return " ...]]]";
|
|
2976 p = decode_mode_spec_buf;
|
|
2977 for (i = 0; i < command_loop_level; i++)
|
|
2978 *p++ = ']';
|
|
2979 *p = 0;
|
|
2980 return decode_mode_spec_buf;
|
|
2981 }
|
|
2982
|
|
2983 case '-':
|
|
2984 {
|
|
2985 register char *p;
|
|
2986 register int i;
|
|
2987
|
|
2988 if (maxwidth < sizeof (lots_of_dashes))
|
|
2989 return lots_of_dashes;
|
|
2990 else
|
|
2991 {
|
|
2992 for (p = decode_mode_spec_buf, i = maxwidth; i > 0; i--)
|
|
2993 *p++ = '-';
|
|
2994 *p = '\0';
|
|
2995 }
|
|
2996 return decode_mode_spec_buf;
|
|
2997 }
|
|
2998 }
|
|
2999
|
|
3000 if (XTYPE (obj) == Lisp_String)
|
|
3001 return (char *) XSTRING (obj)->data;
|
|
3002 else
|
|
3003 return "";
|
|
3004 }
|
2303
|
3005
|
|
3006 /* Count up to N lines starting from FROM.
|
|
3007 But don't go beyond LIMIT.
|
|
3008 Return the number of lines thus found (always positive).
|
|
3009 Store the position after what was found into *POS_PTR. */
|
|
3010
|
|
3011 static int
|
|
3012 display_count_lines (from, limit, n, pos_ptr)
|
|
3013 int from, limit, n;
|
|
3014 int *pos_ptr;
|
|
3015 {
|
|
3016 int oldbegv = BEGV;
|
|
3017 int oldzv = ZV;
|
|
3018 int shortage = 0;
|
|
3019
|
|
3020 if (limit < from)
|
|
3021 BEGV = limit;
|
|
3022 else
|
|
3023 ZV = limit;
|
|
3024
|
5800
|
3025 *pos_ptr = scan_buffer ('\n', from, n, &shortage, 0);
|
2303
|
3026
|
|
3027 ZV = oldzv;
|
|
3028 BEGV = oldbegv;
|
|
3029
|
|
3030 if (n < 0)
|
|
3031 /* When scanning backwards, scan_buffer stops *after* the last newline
|
|
3032 it finds, but does count it. Compensate for that. */
|
|
3033 return - n - shortage - (*pos_ptr != limit);
|
|
3034 return n - shortage;
|
|
3035 }
|
277
|
3036
|
|
3037 /* Display STRING on one line of window W, starting at HPOS.
|
|
3038 Display at position VPOS. Caller should have done get_display_line.
|
1017
|
3039 If VPOS == -1, display it as the current frame's title.
|
5230
|
3040 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
|
277
|
3041
|
|
3042 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
|
|
3043
|
|
3044 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
|
|
3045 MAXCOL is the last column ok to end at. Truncate here.
|
|
3046 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
|
769
|
3047 Both count from the left edge of the frame, as does HPOS.
|
277
|
3048 The right edge of W is an implicit maximum.
|
|
3049 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
|
|
3050
|
5800
|
3051 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
|
|
3052 at the place where the current window ends in this line
|
|
3053 and not display anything beyond there. Otherwise, only MAXCOL
|
|
3054 controls where to stop output.
|
|
3055
|
|
3056 Returns ending hpos. */
|
277
|
3057
|
|
3058 static int
|
5800
|
3059 display_string (w, vpos, string, length, hpos, truncate,
|
|
3060 obey_window_width, mincol, maxcol)
|
277
|
3061 struct window *w;
|
|
3062 unsigned char *string;
|
5230
|
3063 int length;
|
277
|
3064 int vpos, hpos;
|
|
3065 GLYPH truncate;
|
5800
|
3066 int obey_window_width;
|
277
|
3067 int mincol, maxcol;
|
|
3068 {
|
|
3069 register int c;
|
|
3070 register GLYPH *p1;
|
|
3071 int hscroll = XINT (w->hscroll);
|
1600
|
3072 int tab_width = XINT (XBUFFER (w->buffer)->tab_width);
|
277
|
3073 register GLYPH *start;
|
|
3074 register GLYPH *end;
|
1785
|
3075 FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
|
|
3076 struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (f);
|
277
|
3077 GLYPH *p1start = desired_glyphs->glyphs[vpos] + hpos;
|
|
3078 int window_width = XFASTINT (w->width);
|
|
3079
|
|
3080 /* Use the standard display table, not the window's display table.
|
|
3081 We don't want the mode line in rot13. */
|
|
3082 register struct Lisp_Vector *dp = 0;
|
|
3083
|
|
3084 if (XTYPE (Vstandard_display_table) == Lisp_Vector
|
|
3085 && XVECTOR (Vstandard_display_table)->size == DISP_TABLE_SIZE)
|
|
3086 dp = XVECTOR (Vstandard_display_table);
|
|
3087
|
2324
24cd3df6f184
(display_string, display_text_line): Allow tab_width up to 1000.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
3088 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
|
277
|
3089
|
|
3090 p1 = p1start;
|
|
3091 start = desired_glyphs->glyphs[vpos] + XFASTINT (w->left);
|
5800
|
3092
|
|
3093 if (obey_window_width)
|
1785
|
3094 {
|
5800
|
3095 end = start + window_width - (truncate != 0);
|
|
3096
|
|
3097 if ((window_width + XFASTINT (w->left)) != FRAME_WIDTH (f))
|
1785
|
3098 {
|
5800
|
3099 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
|
|
3100 {
|
|
3101 int i;
|
|
3102
|
|
3103 for (i = 0; i < VERTICAL_SCROLL_BAR_WIDTH; i++)
|
|
3104 *end-- = ' ';
|
|
3105 }
|
|
3106 else
|
|
3107 *end-- = '|';
|
1785
|
3108 }
|
|
3109 }
|
277
|
3110
|
5800
|
3111 if (! obey_window_width
|
|
3112 || (maxcol >= 0 && end - desired_glyphs->glyphs[vpos] > maxcol))
|
277
|
3113 end = desired_glyphs->glyphs[vpos] + maxcol;
|
5800
|
3114
|
277
|
3115 if (maxcol >= 0 && mincol > maxcol)
|
|
3116 mincol = maxcol;
|
|
3117
|
|
3118 while (p1 < end)
|
|
3119 {
|
5230
|
3120 if (length == 0)
|
|
3121 break;
|
277
|
3122 c = *string++;
|
5230
|
3123 /* Specified length. */
|
|
3124 if (length >= 0)
|
|
3125 length--;
|
|
3126 /* Unspecified length (null-terminated string). */
|
|
3127 else if (c == 0)
|
|
3128 break;
|
|
3129
|
277
|
3130 if (c >= 040 && c < 0177
|
2065
|
3131 && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector))
|
277
|
3132 {
|
|
3133 if (p1 >= start)
|
|
3134 *p1 = c;
|
|
3135 p1++;
|
|
3136 }
|
|
3137 else if (c == '\t')
|
|
3138 {
|
|
3139 do
|
|
3140 {
|
|
3141 if (p1 >= start && p1 < end)
|
|
3142 *p1 = SPACEGLYPH;
|
|
3143 p1++;
|
|
3144 }
|
|
3145 while ((p1 - start + hscroll - (hscroll > 0)) % tab_width);
|
|
3146 }
|
2065
|
3147 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector)
|
5800
|
3148 {
|
|
3149 p1 = copy_part_of_rope (f, p1, start,
|
|
3150 XVECTOR (DISP_CHAR_VECTOR (dp, c))->contents,
|
|
3151 XVECTOR (DISP_CHAR_VECTOR (dp, c))->size,
|
|
3152 0);
|
|
3153 }
|
1527
|
3154 else if (c < 0200 && ! NILP (buffer_defaults.ctl_arrow))
|
277
|
3155 {
|
|
3156 if (p1 >= start)
|
5800
|
3157 *p1 = fix_glyph (f, (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int
|
|
3158 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'),
|
|
3159 0);
|
277
|
3160 p1++;
|
368
|
3161 if (p1 >= start && p1 < end)
|
277
|
3162 *p1 = c ^ 0100;
|
|
3163 p1++;
|
|
3164 }
|
|
3165 else
|
|
3166 {
|
|
3167 if (p1 >= start)
|
5800
|
3168 *p1 = fix_glyph (f, (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int
|
|
3169 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'),
|
|
3170 0);
|
277
|
3171 p1++;
|
368
|
3172 if (p1 >= start && p1 < end)
|
277
|
3173 *p1 = (c >> 6) + '0';
|
|
3174 p1++;
|
368
|
3175 if (p1 >= start && p1 < end)
|
277
|
3176 *p1 = (7 & (c >> 3)) + '0';
|
|
3177 p1++;
|
368
|
3178 if (p1 >= start && p1 < end)
|
277
|
3179 *p1 = (7 & c) + '0';
|
|
3180 p1++;
|
|
3181 }
|
|
3182 }
|
|
3183
|
5230
|
3184 if (c && length > 0)
|
277
|
3185 {
|
|
3186 p1 = end;
|
5800
|
3187 if (truncate) *p1++ = fix_glyph (f, truncate, 0);
|
277
|
3188 }
|
|
3189 else if (mincol >= 0)
|
|
3190 {
|
|
3191 end = desired_glyphs->glyphs[vpos] + mincol;
|
|
3192 while (p1 < end)
|
|
3193 *p1++ = SPACEGLYPH;
|
|
3194 }
|
|
3195
|
|
3196 {
|
|
3197 register int len = p1 - desired_glyphs->glyphs[vpos];
|
|
3198
|
|
3199 if (len > desired_glyphs->used[vpos])
|
|
3200 desired_glyphs->used[vpos] = len;
|
|
3201 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0;
|
|
3202
|
|
3203 return len;
|
|
3204 }
|
|
3205 }
|
|
3206
|
|
3207 void
|
|
3208 syms_of_xdisp ()
|
|
3209 {
|
|
3210 staticpro (&last_arrow_position);
|
|
3211 staticpro (&last_arrow_string);
|
|
3212 last_arrow_position = Qnil;
|
|
3213 last_arrow_string = Qnil;
|
|
3214
|
|
3215 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string,
|
782
|
3216 "String (or mode line construct) included (normally) in `mode-line-format'.");
|
277
|
3217 Vglobal_mode_string = Qnil;
|
|
3218
|
|
3219 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position,
|
|
3220 "Marker for where to display an arrow on top of the buffer text.\n\
|
|
3221 This must be the beginning of a line in order to work.\n\
|
|
3222 See also `overlay-arrow-string'.");
|
|
3223 Voverlay_arrow_position = Qnil;
|
|
3224
|
|
3225 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string,
|
|
3226 "String to display as an arrow. See also `overlay-arrow-position'.");
|
|
3227 Voverlay_arrow_string = Qnil;
|
|
3228
|
|
3229 DEFVAR_INT ("scroll-step", &scroll_step,
|
|
3230 "*The number of lines to try scrolling a window by when point moves out.\n\
|
769
|
3231 If that fails to bring point back on frame, point is centered instead.\n\
|
|
3232 If this is zero, point is always centered after it moves off frame.");
|
277
|
3233
|
|
3234 DEFVAR_INT ("debug-end-pos", &debug_end_pos, "Don't ask");
|
|
3235
|
|
3236 DEFVAR_BOOL ("truncate-partial-width-windows",
|
|
3237 &truncate_partial_width_windows,
|
769
|
3238 "*Non-nil means truncate lines in all windows less than full frame wide.");
|
277
|
3239 truncate_partial_width_windows = 1;
|
|
3240
|
|
3241 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video,
|
|
3242 "*Non-nil means use inverse video for the mode line.");
|
|
3243 mode_line_inverse_video = 1;
|
2303
|
3244
|
|
3245 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit,
|
|
3246 "*Maximum buffer size for which line number should be displayed.");
|
|
3247 line_number_display_limit = 1000000;
|
3265
|
3248
|
|
3249 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows,
|
|
3250 "*Non-nil means highlight region even in nonselected windows.");
|
|
3251 highlight_nonselected_windows = 1;
|
277
|
3252 }
|
|
3253
|
|
3254 /* initialize the window system */
|
|
3255 init_xdisp ()
|
|
3256 {
|
|
3257 Lisp_Object root_window;
|
|
3258 #ifndef COMPILER_REGISTER_BUG
|
|
3259 register
|
|
3260 #endif /* COMPILER_REGISTER_BUG */
|
|
3261 struct window *mini_w;
|
|
3262
|
|
3263 this_line_bufpos = 0;
|
|
3264
|
|
3265 mini_w = XWINDOW (minibuf_window);
|
1017
|
3266 root_window = FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w)));
|
277
|
3267
|
|
3268 echo_area_glyphs = 0;
|
|
3269 previous_echo_glyphs = 0;
|
|
3270
|
|
3271 if (!noninteractive)
|
|
3272 {
|
769
|
3273 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (root_window)));
|
277
|
3274 XFASTINT (XWINDOW (root_window)->top) = 0;
|
769
|
3275 set_window_height (root_window, FRAME_HEIGHT (f) - 1, 0);
|
|
3276 XFASTINT (mini_w->top) = FRAME_HEIGHT (f) - 1;
|
277
|
3277 set_window_height (minibuf_window, 1, 0);
|
|
3278
|
769
|
3279 XFASTINT (XWINDOW (root_window)->width) = FRAME_WIDTH (f);
|
|
3280 XFASTINT (mini_w->width) = FRAME_WIDTH (f);
|
277
|
3281 }
|
|
3282 }
|