Mercurial > emacs
annotate src/xdisp.c @ 1359:96c43cee31f1
CP:: changed to cust-print- in all names.
Lots of doc fixes.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 07 Oct 1992 09:09:19 +0000 |
parents | 453c24f2bdaa |
children | 37b3c2981b40 |
rev | line source |
---|---|
277 | 1 /* Display generation from window structure and buffer text. |
574 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1992 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 | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 #include "config.h" | |
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" | |
35 | |
36 extern int interrupt_input; | |
37 extern int command_loop_level; | |
38 | |
39 /* Nonzero means print newline before next minibuffer message. */ | |
40 | |
41 int noninteractive_need_newline; | |
42 | |
43 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
44 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
45 | |
46 /* The buffer position of the first character appearing | |
769 | 47 entirely or partially on the current frame line. |
48 Or zero, which disables the optimization for the current frame line. */ | |
277 | 49 static int this_line_bufpos; |
50 | |
51 /* Number of characters past the end of this line, | |
52 including the terminating newline */ | |
53 static int this_line_endpos; | |
54 | |
769 | 55 /* The vertical position of this frame line. */ |
277 | 56 static int this_line_vpos; |
57 | |
769 | 58 /* Hpos value for start of display on this frame line. |
277 | 59 Usually zero, but negative if first character really began |
60 on previous line */ | |
61 static int this_line_start_hpos; | |
62 | |
63 /* Buffer that this_line variables are describing. */ | |
64 static struct buffer *this_line_buffer; | |
65 | |
66 /* Set by try_window_id to the vpos of first of any lines | |
769 | 67 scrolled on to the bottom of the frame. These lines should |
277 | 68 not be included in any general scroll computation. */ |
69 static int scroll_bottom_vpos; | |
70 | |
71 /* Value of echo_area_glyphs when it was last acted on. | |
769 | 72 If this is nonzero, there is a message on the frame |
277 | 73 in the minibuffer and it should be erased as soon |
74 as it is no longer requested to appear. */ | |
75 char *previous_echo_glyphs; | |
76 | |
769 | 77 /* Nonzero means truncate lines in all windows less wide than the frame */ |
277 | 78 int truncate_partial_width_windows; |
79 | |
80 Lisp_Object Vglobal_mode_string; | |
81 | |
82 /* Marker for where to display an arrow on top of the buffer text. */ | |
83 Lisp_Object Voverlay_arrow_position; | |
84 | |
85 /* String to display for the arrow. */ | |
86 Lisp_Object Voverlay_arrow_string; | |
87 | |
88 /* Values of those variables at last redisplay. */ | |
89 Lisp_Object last_arrow_position, last_arrow_string; | |
90 | |
91 /* Nonzero if overlay arrow has been displayed once in this window. */ | |
92 static int overlay_arrow_seen; | |
93 | |
769 | 94 /* If cursor motion alone moves point off frame, |
277 | 95 Try scrolling this many lines up or down if that will bring it back. */ |
96 int scroll_step; | |
97 | |
98 /* Nonzero if try_window_id has made blank lines at window bottom | |
99 since the last redisplay that paused */ | |
100 static int blank_end_of_window; | |
101 | |
102 /* Number of windows showing the buffer of the selected window. | |
103 keyboard.c refers to this. */ | |
104 int buffer_shared; | |
105 | |
769 | 106 /* display_text_line sets these to the frame position (origin 0) of point, |
277 | 107 whether the window is selected or not. |
108 Set one to -1 first to determine whether point was found afterwards. */ | |
109 | |
110 static int cursor_vpos; | |
111 static int cursor_hpos; | |
112 | |
113 int debug_end_pos; | |
114 | |
115 /* Nonzero means display mode line highlighted */ | |
116 int mode_line_inverse_video; | |
117 | |
118 static void echo_area_display (); | |
119 void mark_window_display_accurate (); | |
120 static void redisplay_windows (); | |
121 static void redisplay_window (); | |
122 static void try_window (); | |
123 static int try_window_id (); | |
124 static struct position *display_text_line (); | |
125 static void display_mode_line (); | |
126 static int display_mode_element (); | |
127 static char *fmodetrunc (); | |
128 static char *decode_mode_spec (); | |
129 static int display_string (); | |
130 | |
131 /* Prompt to display in front of the minibuffer contents */ | |
132 char *minibuf_prompt; | |
133 | |
134 /* Width in columns of current minibuffer prompt. */ | |
135 int minibuf_prompt_width; | |
136 | |
137 /* Message to display instead of minibuffer contents | |
138 This is what the functions error and message make, | |
139 and command echoing uses it as well. | |
140 It overrides the minibuf_prompt as well as the buffer. */ | |
141 char *echo_area_glyphs; | |
142 | |
143 /* true iff we should redraw the mode lines on the next redisplay */ | |
144 int update_mode_lines; | |
145 | |
146 /* Smallest number of characters before the gap | |
147 at any time since last redisplay that finished. | |
148 Valid for current buffer when try_window_id can be called. */ | |
149 int beg_unchanged; | |
150 | |
151 /* Smallest number of characters after the gap | |
152 at any time since last redisplay that finished. | |
153 Valid for current buffer when try_window_id can be called. */ | |
154 int end_unchanged; | |
155 | |
156 /* MODIFF as of last redisplay that finished; | |
157 if it matches MODIFF, beg_unchanged and end_unchanged | |
158 contain no useful information */ | |
159 int unchanged_modified; | |
160 | |
161 /* Nonzero if head_clip or tail_clip of current buffer has changed | |
162 since last redisplay that finished */ | |
163 int clip_changed; | |
164 | |
165 /* Nonzero if window sizes or contents have changed | |
166 since last redisplay that finished */ | |
167 int windows_or_buffers_changed; | |
168 | |
169 | |
769 | 170 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print; |
331 | 171 zero if being used by message. */ |
172 int message_buf_print; | |
173 | |
277 | 174 /* dump an informative message to the minibuf */ |
175 /* VARARGS 1 */ | |
176 | |
177 void | |
178 message (m, a1, a2, a3) | |
179 char *m; | |
180 { | |
181 if (noninteractive) | |
182 { | |
183 if (noninteractive_need_newline) | |
184 putc ('\n', stderr); | |
185 noninteractive_need_newline = 0; | |
186 fprintf (stderr, m, a1, a2, a3); | |
187 fprintf (stderr, "\n"); | |
188 fflush (stderr); | |
189 } | |
769 | 190 /* A null message buffer means that the frame hasn't really been |
433 | 191 initialized yet. Error messages get reported properly by |
192 cmd_error, so this must be just an informative message; toss it. */ | |
769 | 193 else if (INTERACTIVE && FRAME_MESSAGE_BUF (selected_frame)) |
277 | 194 { |
769 | 195 #ifdef MULTI_FRAME |
827 | 196 Lisp_Object minibuf_frame; |
197 | |
769 | 198 choose_minibuf_frame (); |
827 | 199 minibuf_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); |
200 if (FRAME_VISIBLE_P (selected_frame) | |
201 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame))) | |
202 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window))); | |
433 | 203 #endif |
204 | |
485 | 205 { |
277 | 206 #ifdef NO_ARG_ARRAY |
485 | 207 int a[3]; |
208 a[0] = a1; | |
209 a[1] = a2; | |
210 a[2] = a3; | |
277 | 211 |
769 | 212 doprnt (FRAME_MESSAGE_BUF (selected_frame), |
213 FRAME_WIDTH (selected_frame), m, 0, 3, a); | |
277 | 214 #else |
769 | 215 doprnt (FRAME_MESSAGE_BUF (selected_frame), |
216 FRAME_WIDTH (selected_frame), m, 0, 3, &a1); | |
368 | 217 #endif /* NO_ARG_ARRAY */ |
485 | 218 } |
277 | 219 |
769 | 220 echo_area_glyphs = FRAME_MESSAGE_BUF (selected_frame); |
331 | 221 |
222 /* Print should start at the beginning of the message | |
223 buffer next time. */ | |
224 message_buf_print = 0; | |
225 | |
277 | 226 do_pending_window_change (); |
227 echo_area_display (); | |
769 | 228 update_frame (XFRAME (XWINDOW (minibuf_window)->frame), 1, 1); |
277 | 229 do_pending_window_change (); |
230 } | |
231 } | |
232 | |
233 /* Specify m, a string, as a message in the minibuf. */ | |
234 void | |
235 message1 (m) | |
236 char *m; | |
237 { | |
238 if (noninteractive) | |
239 { | |
240 if (noninteractive_need_newline) | |
241 putc ('\n', stderr); | |
242 noninteractive_need_newline = 0; | |
243 fprintf (stderr, "%s\n", m); | |
244 fflush (stderr); | |
245 } | |
769 | 246 /* A null message buffer means that the frame hasn't really been |
433 | 247 initialized yet. Error messages get reported properly by |
248 cmd_error, so this must be just an informative message; toss it. */ | |
769 | 249 else if (INTERACTIVE && FRAME_MESSAGE_BUF (selected_frame)) |
277 | 250 { |
769 | 251 #ifdef MULTI_FRAME |
827 | 252 Lisp_Object minibuf_frame; |
253 | |
769 | 254 choose_minibuf_frame (); |
827 | 255 minibuf_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); |
256 if (FRAME_VISIBLE_P (selected_frame) | |
257 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame))) | |
258 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window))); | |
433 | 259 #endif |
260 | |
277 | 261 echo_area_glyphs = m; |
262 do_pending_window_change (); | |
263 echo_area_display (); | |
769 | 264 update_frame (XFRAME (XWINDOW (minibuf_window)->frame), 1, 1); |
277 | 265 do_pending_window_change (); |
266 } | |
267 } | |
268 | |
269 static void | |
270 echo_area_display () | |
271 { | |
272 register int vpos; | |
769 | 273 FRAME_PTR f; |
277 | 274 |
769 | 275 #ifdef MULTI_FRAME |
276 choose_minibuf_frame (); | |
277 f = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); | |
277 | 278 |
769 | 279 if (! FRAME_VISIBLE_P (f)) |
277 | 280 return; |
281 #endif | |
282 | |
769 | 283 if (frame_garbaged) |
277 | 284 { |
285 Fredraw_display (); | |
769 | 286 frame_garbaged = 0; |
277 | 287 } |
288 | |
289 if (echo_area_glyphs || minibuf_level == 0) | |
290 { | |
291 vpos = XFASTINT (XWINDOW (minibuf_window)->top); | |
769 | 292 get_display_line (f, vpos, 0); |
277 | 293 display_string (XWINDOW (minibuf_window), vpos, |
294 echo_area_glyphs ? echo_area_glyphs : "", | |
769 | 295 0, 0, 0, FRAME_WIDTH (f)); |
277 | 296 |
297 /* If desired cursor location is on this line, put it at end of text */ | |
769 | 298 if (FRAME_CURSOR_Y (f) == vpos) |
299 FRAME_CURSOR_X (f) = FRAME_DESIRED_GLYPHS (f)->used[vpos]; | |
727 | 300 |
301 /* Fill the rest of the minibuffer window with blank lines. */ | |
302 { | |
303 int i; | |
304 | |
305 for (i = vpos + 1; i < vpos + XWINDOW (minibuf_window)->height; i++) | |
306 { | |
769 | 307 get_display_line (f, i, 0); |
727 | 308 display_string (XWINDOW (minibuf_window), vpos, |
769 | 309 "", 0, 0, 0, FRAME_WIDTH (f)); |
727 | 310 } |
311 } | |
277 | 312 } |
313 else if (!EQ (minibuf_window, selected_window)) | |
314 windows_or_buffers_changed++; | |
315 | |
316 if (EQ (minibuf_window, selected_window)) | |
317 this_line_bufpos = 0; | |
318 | |
319 previous_echo_glyphs = echo_area_glyphs; | |
320 } | |
321 | |
769 | 322 /* Do a frame update, taking possible shortcuts into account. |
277 | 323 This is the main external entry point for redisplay. |
324 | |
325 If the last redisplay displayed an echo area message and that | |
326 message is no longer requested, we clear the echo area | |
327 or bring back the minibuffer if that is in use. | |
328 | |
329 Everyone would like to have a hook here to call eval, | |
330 but that cannot be done safely without a lot of changes elsewhere. | |
331 This can be called from signal handlers; with alarms set up; | |
332 or with synchronous processes running. | |
333 See the function `echo' in keyboard.c. | |
334 See Fcall_process; if you called it from here, it could be | |
335 entered recursively. */ | |
336 | |
337 void | |
338 redisplay () | |
339 { | |
340 register struct window *w = XWINDOW (selected_window); | |
341 register int pause; | |
342 int must_finish = 0; | |
343 int all_windows; | |
344 register int tlbufpos, tlendpos; | |
345 struct position pos; | |
346 extern int input_pending; | |
347 | |
348 if (noninteractive) | |
349 return; | |
350 | |
769 | 351 /* Notice any pending interrupt request to change frame size. */ |
277 | 352 do_pending_window_change (); |
353 | |
769 | 354 if (frame_garbaged) |
277 | 355 { |
356 Fredraw_display (); | |
769 | 357 frame_garbaged = 0; |
277 | 358 } |
359 | |
368 | 360 /* Normally the message* functions will have already displayed and |
769 | 361 updated the echo area, but the frame may have been trashed, or |
368 | 362 the update may have been preempted, so display the echo area |
363 again here. */ | |
277 | 364 if (echo_area_glyphs || previous_echo_glyphs) |
365 { | |
366 echo_area_display (); | |
367 must_finish = 1; | |
368 } | |
369 | |
370 if (clip_changed || windows_or_buffers_changed) | |
371 update_mode_lines++; | |
372 | |
373 /* Detect case that we need to write a star in the mode line. */ | |
374 if (XFASTINT (w->last_modified) < MODIFF | |
375 && XFASTINT (w->last_modified) <= current_buffer->save_modified) | |
376 { | |
377 w->update_mode_line = Qt; | |
378 if (buffer_shared > 1) | |
379 update_mode_lines++; | |
380 } | |
381 | |
769 | 382 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1; |
277 | 383 |
384 all_windows = update_mode_lines || buffer_shared > 1; | |
385 | |
386 /* If specs for an arrow have changed, do thorough redisplay | |
387 to ensure we remove any arrow that should no longer exist. */ | |
388 if (Voverlay_arrow_position != last_arrow_position | |
389 || Voverlay_arrow_string != last_arrow_string) | |
390 all_windows = 1, clip_changed = 1; | |
391 | |
392 tlbufpos = this_line_bufpos; | |
393 tlendpos = this_line_endpos; | |
485 | 394 if (!all_windows && tlbufpos > 0 && NILP (w->update_mode_line) |
769 | 395 && FRAME_VISIBLE_P (XFRAME (w->frame)) |
277 | 396 /* Make sure recorded data applies to current buffer, etc */ |
397 && this_line_buffer == current_buffer | |
398 && current_buffer == XBUFFER (w->buffer) | |
485 | 399 && NILP (w->force_start) |
277 | 400 /* Point must be on the line that we have info recorded about */ |
401 && point >= tlbufpos | |
402 && point <= Z - tlendpos | |
403 /* All text outside that line, including its final newline, | |
404 must be unchanged */ | |
405 && (XFASTINT (w->last_modified) >= MODIFF | |
406 || (beg_unchanged >= tlbufpos - 1 | |
407 && GPT >= tlbufpos | |
528 | 408 /* If selective display, can't optimize |
409 if the changes start at the beginning of the line. */ | |
410 && ((XTYPE (current_buffer->selective_display) == Lisp_Int | |
411 && XINT (current_buffer->selective_display) > 0 | |
412 ? (beg_unchanged >= tlbufpos | |
413 && GPT > tlbufpos) | |
414 : 1)) | |
277 | 415 && end_unchanged >= tlendpos |
416 && Z - GPT >= tlendpos))) | |
417 { | |
418 if (tlbufpos > BEGV && FETCH_CHAR (tlbufpos - 1) != '\n' | |
419 && (tlbufpos == ZV | |
420 || FETCH_CHAR (tlbufpos) == '\n')) | |
421 /* Former continuation line has disappeared by becoming empty */ | |
422 goto cancel; | |
423 else if (XFASTINT (w->last_modified) < MODIFF | |
424 || MINI_WINDOW_P (w)) | |
425 { | |
426 cursor_vpos = -1; | |
427 overlay_arrow_seen = 0; | |
428 display_text_line (w, tlbufpos, this_line_vpos, this_line_start_hpos, | |
429 pos_tab_offset (w, tlbufpos)); | |
430 /* If line contains point, is not continued, | |
431 and ends at same distance from eob as before, we win */ | |
432 if (cursor_vpos >= 0 && this_line_bufpos | |
433 && this_line_endpos == tlendpos) | |
434 { | |
769 | 435 if (XFASTINT (w->width) != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) |
277 | 436 preserve_other_columns (w); |
437 goto update; | |
438 } | |
439 else | |
440 goto cancel; | |
441 } | |
442 else if (point == XFASTINT (w->last_point)) | |
443 { | |
444 if (!must_finish) | |
445 { | |
446 do_pending_window_change (); | |
447 return; | |
448 } | |
449 goto update; | |
450 } | |
451 else | |
452 { | |
453 pos = *compute_motion (tlbufpos, 0, | |
454 XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0, | |
455 point, 2, - (1 << (SHORTBITS - 1)), | |
456 XFASTINT (w->width) - 1 | |
457 - (XFASTINT (w->width) + XFASTINT (w->left) | |
769 | 458 != FRAME_WIDTH (selected_frame)), |
574 | 459 XINT (w->hscroll), |
460 pos_tab_offset (w, tlbufpos)); | |
277 | 461 if (pos.vpos < 1) |
462 { | |
769 | 463 FRAME_CURSOR_X (selected_frame) |
277 | 464 = XFASTINT (w->left) + max (pos.hpos, 0); |
769 | 465 FRAME_CURSOR_Y (selected_frame) = this_line_vpos; |
277 | 466 goto update; |
467 } | |
468 else | |
469 goto cancel; | |
470 } | |
471 cancel: | |
472 /* Text changed drastically or point moved off of line */ | |
769 | 473 cancel_line (this_line_vpos, selected_frame); |
277 | 474 } |
475 | |
476 this_line_bufpos = 0; | |
477 all_windows |= buffer_shared > 1; | |
478 | |
479 if (all_windows) | |
480 { | |
769 | 481 #ifdef MULTI_FRAME |
277 | 482 Lisp_Object tail; |
483 | |
484 /* Recompute # windows showing selected buffer. | |
433 | 485 This will be incremented each time such a window is displayed. */ |
277 | 486 buffer_shared = 0; |
487 | |
769 | 488 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
277 | 489 { |
769 | 490 FRAME_PTR f; |
277 | 491 |
769 | 492 if (XTYPE (XCONS (tail)->car) != Lisp_Frame) |
277 | 493 continue; |
494 | |
769 | 495 f = XFRAME (XCONS (tail)->car); |
496 if (f->visible) | |
433 | 497 /* Redraw its windows. */ |
769 | 498 redisplay_windows (FRAME_ROOT_WINDOW (f)); |
277 | 499 } |
500 #else | |
769 | 501 redisplay_windows (FRAME_ROOT_WINDOW (f)); |
502 #endif /* not MULTI_FRAME */ | |
277 | 503 } |
769 | 504 else if (FRAME_VISIBLE_P (selected_frame)) |
277 | 505 { |
506 redisplay_window (selected_window, 1); | |
769 | 507 if (XFASTINT (w->width) != FRAME_WIDTH (selected_frame)) |
277 | 508 preserve_other_columns (w); |
509 } | |
510 | |
511 update: | |
512 /* Prevent various kinds of signals during display update. | |
513 stdio is not robust about handling signals, | |
514 which can cause an apparent I/O error. */ | |
515 if (interrupt_input) | |
516 unrequest_sigio (); | |
517 stop_polling (); | |
518 | |
769 | 519 #ifdef MULTI_FRAME |
277 | 520 if (all_windows) |
521 { | |
522 Lisp_Object tail; | |
523 | |
524 pause = 0; | |
525 | |
769 | 526 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
277 | 527 { |
769 | 528 FRAME_PTR f; |
277 | 529 |
769 | 530 if (XTYPE (XCONS (tail)->car) != Lisp_Frame) |
277 | 531 continue; |
532 | |
769 | 533 f = XFRAME (XCONS (tail)->car); |
534 if (f->visible) | |
277 | 535 { |
769 | 536 pause |= update_frame (f, 0, 0); |
277 | 537 if (!pause) |
769 | 538 mark_window_display_accurate (f->root_window, 1); |
277 | 539 } |
540 } | |
541 } | |
542 else | |
769 | 543 #endif /* MULTI_FRAME */ |
368 | 544 { |
769 | 545 if (FRAME_VISIBLE_P (selected_frame)) |
546 pause = update_frame (selected_frame, 0, 0); | |
547 #ifdef MULTI_FRAME | |
433 | 548 /* We may have called echo_area_display at the top of this |
769 | 549 function. If the echo area is on another frame, that may |
550 have put text on a frame other than the selected one, so the | |
551 above call to update_frame would not have caught it. Catch | |
433 | 552 it here. */ |
553 { | |
769 | 554 FRAME_PTR mini_frame = |
555 XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); | |
433 | 556 |
769 | 557 if (mini_frame != selected_frame) |
558 pause |= update_frame (mini_frame, 0, 0); | |
433 | 559 } |
368 | 560 #endif |
561 } | |
277 | 562 |
769 | 563 /* If frame does not match, prevent doing single-line-update next time. |
277 | 564 Also, don't forget to check every line to update the arrow. */ |
565 if (pause) | |
566 { | |
567 this_line_bufpos = 0; | |
485 | 568 if (!NILP (last_arrow_position)) |
277 | 569 { |
570 last_arrow_position = Qt; | |
571 last_arrow_string = Qt; | |
572 } | |
769 | 573 /* If we pause after scrolling, some lines in current_frame |
277 | 574 may be null, so preserve_other_columns won't be able to |
575 preserve all the vertical-bar separators. So, avoid using it | |
576 in that case. */ | |
769 | 577 if (XFASTINT (w->width) != FRAME_WIDTH (selected_frame)) |
277 | 578 update_mode_lines = 1; |
579 } | |
580 | |
769 | 581 /* Now text on frame agrees with windows, so |
277 | 582 put info into the windows for partial redisplay to follow */ |
583 | |
584 if (!pause) | |
585 { | |
586 register struct buffer *b = XBUFFER (w->buffer); | |
587 | |
588 blank_end_of_window = 0; | |
589 clip_changed = 0; | |
590 unchanged_modified = BUF_MODIFF (b); | |
591 beg_unchanged = BUF_GPT (b) - BUF_BEG (b); | |
592 end_unchanged = BUF_Z (b) - BUF_GPT (b); | |
593 | |
594 XFASTINT (w->last_point) = BUF_PT (b); | |
769 | 595 XFASTINT (w->last_point_x) = FRAME_CURSOR_X (selected_frame); |
596 XFASTINT (w->last_point_y) = FRAME_CURSOR_Y (selected_frame); | |
277 | 597 |
598 if (all_windows) | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
599 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame), 1); |
277 | 600 else |
601 { | |
602 w->update_mode_line = Qnil; | |
603 XFASTINT (w->last_modified) = BUF_MODIFF (b); | |
604 w->window_end_valid = Qt; | |
605 last_arrow_position = Voverlay_arrow_position; | |
606 last_arrow_string = Voverlay_arrow_string; | |
607 } | |
608 update_mode_lines = 0; | |
609 windows_or_buffers_changed = 0; | |
610 } | |
611 | |
612 /* Start SIGIO interrupts coming again. | |
613 Having them off during the code above | |
614 makes it less likely one will discard output, | |
615 but not impossible, since there might be stuff | |
616 in the system buffer here. | |
617 But it is much hairier to try to do anything about that. */ | |
618 | |
619 if (interrupt_input) | |
620 request_sigio (); | |
621 start_polling (); | |
622 | |
769 | 623 /* Change frame size now if a change is pending. */ |
277 | 624 do_pending_window_change (); |
625 } | |
626 | |
627 /* Redisplay, but leave alone any recent echo area message | |
628 unless another message has been requested in its place. | |
629 | |
630 This is useful in situations where you need to redisplay but no | |
631 user action has occurred, making it inappropriate for the message | |
632 area to be cleared. See tracking_off and | |
633 wait_reading_process_input for examples of these situations. */ | |
634 | |
635 redisplay_preserve_echo_area () | |
636 { | |
637 if (echo_area_glyphs == 0 && previous_echo_glyphs != 0) | |
638 { | |
639 echo_area_glyphs = previous_echo_glyphs; | |
640 redisplay (); | |
641 echo_area_glyphs = 0; | |
642 } | |
643 else | |
644 redisplay (); | |
645 } | |
646 | |
647 void | |
648 mark_window_display_accurate (window, flag) | |
649 Lisp_Object window; | |
650 int flag; | |
651 { | |
652 register struct window *w; | |
653 | |
485 | 654 for (;!NILP (window); window = w->next) |
277 | 655 { |
656 w = XWINDOW (window); | |
657 | |
485 | 658 if (!NILP (w->buffer)) |
277 | 659 XFASTINT (w->last_modified) |
660 = !flag ? 0 | |
661 : XBUFFER (w->buffer) == current_buffer | |
662 ? MODIFF : BUF_MODIFF (XBUFFER (w->buffer)); | |
663 w->window_end_valid = Qt; | |
664 w->update_mode_line = Qnil; | |
665 | |
485 | 666 if (!NILP (w->vchild)) |
277 | 667 mark_window_display_accurate (w->vchild, flag); |
485 | 668 if (!NILP (w->hchild)) |
277 | 669 mark_window_display_accurate (w->hchild, flag); |
670 } | |
671 | |
672 if (flag) | |
673 { | |
674 last_arrow_position = Voverlay_arrow_position; | |
675 last_arrow_string = Voverlay_arrow_string; | |
676 } | |
677 else | |
678 { | |
679 /* t is unequal to any useful value of Voverlay_arrow_... */ | |
680 last_arrow_position = Qt; | |
681 last_arrow_string = Qt; | |
682 } | |
683 } | |
684 | |
685 int do_id = 1; | |
686 | |
687 static void | |
688 redisplay_windows (window) | |
689 Lisp_Object window; | |
690 { | |
485 | 691 for (; !NILP (window); window = XWINDOW (window)->next) |
277 | 692 redisplay_window (window, 0); |
693 } | |
694 | |
695 static void | |
696 redisplay_window (window, just_this_one) | |
697 Lisp_Object window; | |
698 int just_this_one; | |
699 { | |
700 register struct window *w = XWINDOW (window); | |
769 | 701 FRAME_PTR f = XFRAME (w->frame); |
277 | 702 int height; |
703 register int lpoint = point; | |
704 struct buffer *old = current_buffer; | |
705 register int width = XFASTINT (w->width) - 1 | |
706 - (XFASTINT (w->width) + XFASTINT (w->left) | |
769 | 707 != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))); |
277 | 708 register int startp; |
709 register int hscroll = XINT (w->hscroll); | |
710 struct position pos; | |
711 int opoint; | |
712 int tem; | |
713 int window_needs_modeline; | |
714 | |
769 | 715 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
277 | 716 |
717 /* If this is a combination window, do its children; that's all. */ | |
718 | |
485 | 719 if (!NILP (w->vchild)) |
277 | 720 { |
721 redisplay_windows (w->vchild); | |
722 return; | |
723 } | |
485 | 724 if (!NILP (w->hchild)) |
277 | 725 { |
726 redisplay_windows (w->hchild); | |
727 return; | |
728 } | |
485 | 729 if (NILP (w->buffer)) |
277 | 730 abort (); |
433 | 731 |
732 height = window_internal_height (w); | |
733 | |
734 if (MINI_WINDOW_P (w)) | |
735 { | |
736 if (w == XWINDOW (minibuf_window)) | |
737 { | |
738 if (echo_area_glyphs) | |
739 /* We've already displayed the echo area glyphs, if any. */ | |
740 return; | |
741 } | |
742 else | |
743 { | |
744 /* This is a minibuffer, but it's not the currently active one, so | |
745 clear it. */ | |
769 | 746 int vpos = XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top); |
433 | 747 int i; |
748 | |
749 for (i = 0; i < height; i++) | |
750 { | |
769 | 751 get_display_line (f, vpos + i, 0); |
433 | 752 display_string (w, vpos + i, "", 0, 0, 0, width); |
753 } | |
754 | |
755 return; | |
756 } | |
757 } | |
277 | 758 |
759 if (update_mode_lines) | |
760 w->update_mode_line = Qt; | |
761 | |
762 /* Otherwise set up data on this window; select its buffer and point value */ | |
763 | |
764 current_buffer = XBUFFER (w->buffer); | |
765 opoint = point; | |
766 | |
767 /* Count number of windows showing the selected buffer. */ | |
768 | |
769 if (!just_this_one | |
770 && current_buffer == XBUFFER (XWINDOW (selected_window)->buffer)) | |
771 buffer_shared++; | |
772 | |
773 /* POINT refers normally to the selected window. | |
774 For any other window, set up appropriate value. */ | |
775 | |
776 if (!EQ (window, selected_window)) | |
777 { | |
778 SET_PT (marker_position (w->pointm)); | |
779 if (point < BEGV) | |
780 { | |
485 | 781 SET_PT (BEGV); |
277 | 782 Fset_marker (w->pointm, make_number (point), Qnil); |
783 } | |
784 else if (point > (ZV - 1)) | |
785 { | |
485 | 786 SET_PT (ZV); |
277 | 787 Fset_marker (w->pointm, make_number (point), Qnil); |
788 } | |
789 } | |
790 | |
791 /* If window-start is screwed up, choose a new one. */ | |
792 if (XMARKER (w->start)->buffer != current_buffer) | |
793 goto recenter; | |
794 | |
795 startp = marker_position (w->start); | |
796 | |
433 | 797 /* Handle case where place to start displaying has been specified, |
798 unless the specified location is outside the visible range. */ | |
485 | 799 if (!NILP (w->force_start)) |
277 | 800 { |
801 w->update_mode_line = Qt; | |
802 w->force_start = Qnil; | |
803 XFASTINT (w->last_modified) = 0; | |
433 | 804 if (startp < BEGV) startp = BEGV; |
805 if (startp > ZV) startp = ZV; | |
277 | 806 try_window (window, startp); |
807 if (cursor_vpos < 0) | |
808 { | |
809 /* If point does not appear, move point so it does appear */ | |
810 pos = *compute_motion (startp, 0, | |
811 ((EQ (window, minibuf_window) && startp == 1) | |
812 ? minibuf_prompt_width : 0) | |
813 + | |
814 (hscroll ? 1 - hscroll : 0), | |
815 ZV, height / 2, | |
816 - (1 << (SHORTBITS - 1)), | |
817 width, hscroll, pos_tab_offset (w, startp)); | |
818 SET_PT (pos.bufpos); | |
769 | 819 if (w != XWINDOW (FRAME_SELECTED_WINDOW (f))) |
277 | 820 Fset_marker (w->pointm, make_number (point), Qnil); |
821 else | |
822 { | |
823 lpoint = point; | |
769 | 824 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left); |
825 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top); | |
277 | 826 } |
827 } | |
828 goto done; | |
829 } | |
830 | |
831 /* Handle case where text has not changed, only point, | |
769 | 832 and it has not moved off the frame */ |
277 | 833 |
834 /* This code is not used for minibuffer for the sake of | |
835 the case of redisplaying to replace an echo area message; | |
836 since in that case the minibuffer contents per se are usually unchanged. | |
837 This code is of no real use in the minibuffer since | |
838 the handling of this_line_bufpos, etc., | |
839 in redisplay handles the same cases. */ | |
840 | |
841 if (XFASTINT (w->last_modified) >= MODIFF | |
842 && point >= startp && !clip_changed | |
769 | 843 && (just_this_one || XFASTINT (w->width) == FRAME_WIDTH (f)) |
277 | 844 && !EQ (window, minibuf_window)) |
845 { | |
846 pos = *compute_motion (startp, 0, (hscroll ? 1 - hscroll : 0), | |
847 point, height + 1, 10000, width, hscroll, | |
848 pos_tab_offset (w, startp)); | |
849 | |
850 if (pos.vpos < height) | |
851 { | |
769 | 852 /* Ok, point is still on frame */ |
853 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f))) | |
277 | 854 { |
855 /* These variables are supposed to be origin 1 */ | |
769 | 856 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left); |
857 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top); | |
277 | 858 } |
859 /* This doesn't do the trick, because if a window to the right of | |
860 this one must be redisplayed, this does nothing because there | |
769 | 861 is nothing in DesiredFrame yet, and then the other window is |
277 | 862 redisplayed, making likes that are empty in this window's columns. |
769 | 863 if (XFASTINT (w->width) != FRAME_WIDTH (f)) |
277 | 864 preserve_my_columns (w); |
865 */ | |
866 goto done; | |
867 } | |
868 /* Don't bother trying redisplay with same start; | |
869 we already know it will lose */ | |
870 } | |
871 /* If current starting point was originally the beginning of a line | |
872 but no longer is, find a new starting point. */ | |
485 | 873 else if (!NILP (w->start_at_line_beg) |
277 | 874 && !(startp == BEGV |
875 || FETCH_CHAR (startp - 1) == '\n')) | |
876 { | |
877 goto recenter; | |
878 } | |
879 else if (just_this_one && !MINI_WINDOW_P (w) | |
880 && point >= startp | |
881 && XFASTINT (w->last_modified) | |
882 && ! EQ (w->window_end_valid, Qnil) | |
883 && do_id && !clip_changed | |
884 && !blank_end_of_window | |
769 | 885 && XFASTINT (w->width) == FRAME_WIDTH (f) |
277 | 886 && EQ (last_arrow_position, Voverlay_arrow_position) |
887 && EQ (last_arrow_string, Voverlay_arrow_string) | |
769 | 888 && (tem = try_window_id (FRAME_SELECTED_WINDOW (f))) |
277 | 889 && tem != -2) |
890 { | |
891 /* tem > 0 means success. tem == -1 means choose new start. | |
892 tem == -2 means try again with same start, | |
893 and nothing but whitespace follows the changed stuff. | |
894 tem == 0 means try again with same start. */ | |
895 if (tem > 0) | |
896 goto done; | |
897 } | |
898 else if (startp >= BEGV && startp <= ZV | |
899 /* Avoid starting display at end of buffer! */ | |
433 | 900 && (startp < ZV || startp == BEGV |
277 | 901 || (XFASTINT (w->last_modified) >= MODIFF))) |
902 { | |
903 /* Try to redisplay starting at same place as before */ | |
769 | 904 /* If point has not moved off frame, accept the results */ |
277 | 905 try_window (window, startp); |
906 if (cursor_vpos >= 0) | |
907 goto done; | |
908 else | |
909 cancel_my_columns (w); | |
910 } | |
911 | |
912 XFASTINT (w->last_modified) = 0; | |
913 w->update_mode_line = Qt; | |
914 | |
915 /* Try to scroll by specified few lines */ | |
916 | |
917 if (scroll_step && !clip_changed) | |
918 { | |
919 if (point > startp) | |
920 { | |
921 pos = *vmotion (Z - XFASTINT (w->window_end_pos), | |
922 scroll_step, width, hscroll, window); | |
923 if (pos.vpos >= height) | |
924 goto scroll_fail; | |
925 } | |
926 | |
927 pos = *vmotion (startp, point < startp ? - scroll_step : scroll_step, | |
928 width, hscroll, window); | |
929 | |
930 if (point >= pos.bufpos) | |
931 { | |
932 try_window (window, pos.bufpos); | |
933 if (cursor_vpos >= 0) | |
934 goto done; | |
935 else | |
936 cancel_my_columns (w); | |
937 } | |
938 scroll_fail: ; | |
939 } | |
940 | |
941 /* Finally, just choose place to start which centers point */ | |
942 | |
943 recenter: | |
944 pos = *vmotion (point, - height / 2, width, hscroll, window); | |
945 try_window (window, pos.bufpos); | |
946 | |
947 startp = marker_position (w->start); | |
948 w->start_at_line_beg = | |
949 (startp == BEGV || FETCH_CHAR (startp - 1) == '\n') ? Qt : Qnil; | |
950 | |
951 done: | |
952 /* If window not full width, must redo its mode line | |
953 if the window to its side is being redone */ | |
485 | 954 if ((!NILP (w->update_mode_line) |
769 | 955 || (!just_this_one && width < FRAME_WIDTH (f) - 1)) |
277 | 956 && height != XFASTINT (w->height)) |
957 display_mode_line (w); | |
958 | |
959 SET_PT (opoint); | |
960 current_buffer = old; | |
961 SET_PT (lpoint); | |
962 } | |
963 | |
964 /* Do full redisplay on one window, starting at position `pos'. */ | |
965 | |
966 static void | |
967 try_window (window, pos) | |
968 Lisp_Object window; | |
969 register int pos; | |
970 { | |
971 register struct window *w = XWINDOW (window); | |
972 register int height = window_internal_height (w); | |
973 register int vpos = XFASTINT (w->top); | |
974 register int last_text_vpos = vpos; | |
975 int tab_offset = pos_tab_offset (w, pos); | |
769 | 976 FRAME_PTR f = XFRAME (w->frame); |
277 | 977 int width = XFASTINT (w->width) - 1 |
769 | 978 - (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)); |
277 | 979 struct position val; |
980 | |
981 Fset_marker (w->start, make_number (pos), Qnil); | |
982 cursor_vpos = -1; | |
983 overlay_arrow_seen = 0; | |
984 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0; | |
985 | |
986 while (--height >= 0) | |
987 { | |
988 val = *display_text_line (w, pos, vpos, val.hpos, tab_offset); | |
989 tab_offset += width; | |
990 if (val.vpos) tab_offset = 0; | |
991 vpos++; | |
992 if (pos != val.bufpos) | |
993 last_text_vpos | |
994 /* Next line, unless prev line ended in end of buffer with no cr */ | |
995 = vpos - (val.vpos && FETCH_CHAR (val.bufpos - 1) != '\n'); | |
996 pos = val.bufpos; | |
997 } | |
998 | |
999 /* If last line is continued in middle of character, | |
769 | 1000 include the split character in the text considered on the frame */ |
277 | 1001 if (val.hpos < (XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0)) |
1002 pos++; | |
1003 | |
769 | 1004 /* If bottom just moved off end of frame, change mode line percentage. */ |
277 | 1005 if (XFASTINT (w->window_end_pos) == 0 |
1006 && Z != pos) | |
1007 w->update_mode_line = Qt; | |
1008 | |
769 | 1009 /* Say where last char on frame will be, once redisplay is finished. */ |
277 | 1010 XFASTINT (w->window_end_pos) = Z - pos; |
1011 XFASTINT (w->window_end_vpos) = last_text_vpos - XFASTINT (w->top); | |
1012 /* But that is not valid info until redisplay finishes. */ | |
1013 w->window_end_valid = Qnil; | |
1014 } | |
1015 | |
1016 /* Try to redisplay when buffer is modified locally, | |
1017 computing insert/delete line to preserve text outside | |
1018 the bounds of the changes. | |
1019 Return 1 if successful, 0 if if cannot tell what to do, | |
1020 or -1 to tell caller to find a new window start, | |
1021 or -2 to tell caller to do normal redisplay with same window start. */ | |
1022 | |
1023 static int | |
1024 try_window_id (window) | |
1025 Lisp_Object window; | |
1026 { | |
1027 int pos; | |
1028 register struct window *w = XWINDOW (window); | |
1029 register int height = window_internal_height (w); | |
769 | 1030 FRAME_PTR f = XFRAME (w->frame); |
277 | 1031 int top = XFASTINT (w->top); |
1032 int start = marker_position (w->start); | |
1033 int width = XFASTINT (w->width) - 1 | |
769 | 1034 - (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)); |
277 | 1035 int hscroll = XINT (w->hscroll); |
1036 int lmargin = hscroll > 0 ? 1 - hscroll : 0; | |
1037 register int vpos; | |
1038 register int i, tem; | |
1039 int last_text_vpos = 0; | |
1040 int stop_vpos; | |
1041 | |
1042 struct position val, bp, ep, xp, pp; | |
1043 int scroll_amount = 0; | |
1044 int delta; | |
1045 int tab_offset, epto; | |
1046 | |
1047 if (GPT - BEG < beg_unchanged) | |
1048 beg_unchanged = GPT - BEG; | |
1049 if (Z - GPT < end_unchanged) | |
1050 end_unchanged = Z - GPT; | |
1051 | |
1052 if (beg_unchanged + 1 < start) | |
1053 return 0; /* Give up if changes go above top of window */ | |
1054 | |
1055 /* Find position before which nothing is changed. */ | |
1056 bp = *compute_motion (start, 0, lmargin, | |
371 | 1057 beg_unchanged + 1, height + 1, 0, width, hscroll, |
277 | 1058 pos_tab_offset (w, start)); |
1059 if (bp.vpos >= height) | |
368 | 1060 { |
1061 if (point < bp.bufpos && !bp.contin) | |
1062 { | |
769 | 1063 /* All changes are below the frame, and point is on the frame. |
1064 We don't need to change the frame at all. | |
368 | 1065 But we need to update window_end_pos to account for |
1066 any change in buffer size. */ | |
371 | 1067 bp = *compute_motion (start, 0, lmargin, |
1068 Z, height, 0, | |
1069 width, hscroll, pos_tab_offset (w, start)); | |
368 | 1070 XFASTINT (w->window_end_vpos) = height; |
1071 XFASTINT (w->window_end_pos) = Z - bp.bufpos; | |
1072 return 1; | |
1073 } | |
1074 return 0; | |
1075 } | |
277 | 1076 |
1077 vpos = bp.vpos; | |
1078 | |
769 | 1079 /* Find beginning of that frame line. Must display from there. */ |
277 | 1080 bp = *vmotion (bp.bufpos, 0, width, hscroll, window); |
1081 | |
1082 pos = bp.bufpos; | |
1083 val.hpos = lmargin; | |
1084 if (pos < start) | |
1085 return -1; | |
1086 | |
1087 /* If about to start displaying at the beginning of a continuation line, | |
769 | 1088 really start with previous frame line, in case it was not |
277 | 1089 continued when last redisplayed */ |
528 | 1090 if ((bp.contin && bp.bufpos - 1 == beg_unchanged && vpos > 0) |
1091 || | |
1092 /* Likewise if we have to worry about selective display. */ | |
1093 (XTYPE (current_buffer->selective_display) == Lisp_Int | |
1094 && XINT (current_buffer->selective_display) > 0 | |
1095 && bp.bufpos - 1 == beg_unchanged && vpos > 0)) | |
277 | 1096 { |
1097 bp = *vmotion (bp.bufpos, -1, width, hscroll, window); | |
1098 --vpos; | |
1099 pos = bp.bufpos; | |
1100 } | |
1101 | |
1102 if (bp.contin && bp.hpos != lmargin) | |
1103 { | |
1104 val.hpos = bp.prevhpos - width + lmargin; | |
1105 pos--; | |
1106 } | |
1107 | |
1108 bp.vpos = vpos; | |
1109 | |
1110 /* Find first visible newline after which no more is changed. */ | |
1111 tem = find_next_newline (Z - max (end_unchanged, Z - ZV), 1); | |
1112 if (XTYPE (current_buffer->selective_display) == Lisp_Int | |
1113 && XINT (current_buffer->selective_display) > 0) | |
1114 while (tem < ZV - 1 | |
1115 && (position_indentation (tem) | |
1116 >= XINT (current_buffer->selective_display))) | |
1117 tem = find_next_newline (tem, 1); | |
1118 | |
1119 /* Compute the cursor position after that newline. */ | |
1120 ep = *compute_motion (pos, vpos, val.hpos, tem, | |
1121 height, - (1 << (SHORTBITS - 1)), | |
1122 width, hscroll, pos_tab_offset (w, bp.bufpos)); | |
1123 | |
769 | 1124 /* If changes reach past the text available on the frame, |
1125 just display rest of frame. */ | |
277 | 1126 if (ep.bufpos > Z - XFASTINT (w->window_end_pos)) |
1127 stop_vpos = height; | |
1128 else | |
1129 stop_vpos = ep.vpos; | |
1130 | |
1131 /* If no newline before ep, the line ep is on includes some changes | |
1132 that must be displayed. Make sure we don't stop before it. */ | |
1133 /* Also, if changes reach all the way until ep.bufpos, | |
1134 it is possible that something was deleted after the | |
1135 newline before it, so the following line must be redrawn. */ | |
1136 if (stop_vpos == ep.vpos | |
1137 && (ep.bufpos == BEGV | |
1138 || FETCH_CHAR (ep.bufpos - 1) != '\n' | |
1139 || ep.bufpos == Z - end_unchanged)) | |
1140 stop_vpos = ep.vpos + 1; | |
1141 | |
1142 cursor_vpos = -1; | |
1143 overlay_arrow_seen = 0; | |
1144 | |
1145 /* If changes do not reach to bottom of window, | |
1146 figure out how much to scroll the rest of the window */ | |
1147 if (stop_vpos < height) | |
1148 { | |
1149 /* Now determine how far up or down the rest of the window has moved */ | |
1150 epto = pos_tab_offset (w, ep.bufpos); | |
1151 xp = *compute_motion (ep.bufpos, ep.vpos, ep.hpos, | |
1152 Z - XFASTINT (w->window_end_pos), | |
1153 10000, 0, width, hscroll, epto); | |
1154 scroll_amount = xp.vpos - XFASTINT (w->window_end_vpos); | |
1155 | |
769 | 1156 /* Is everything on frame below the changes whitespace? |
277 | 1157 If so, no scrolling is really necessary. */ |
1158 for (i = ep.bufpos; i < xp.bufpos; i++) | |
1159 { | |
1160 tem = FETCH_CHAR (i); | |
1161 if (tem != ' ' && tem != '\n' && tem != '\t') | |
1162 break; | |
1163 } | |
1164 if (i == xp.bufpos) | |
1165 return -2; | |
1166 | |
1167 XFASTINT (w->window_end_vpos) += scroll_amount; | |
1168 | |
769 | 1169 /* Before doing any scrolling, verify that point will be on frame. */ |
277 | 1170 if (point > ep.bufpos && !(point <= xp.bufpos && xp.bufpos < height)) |
1171 { | |
1172 if (point <= xp.bufpos) | |
1173 { | |
1174 pp = *compute_motion (ep.bufpos, ep.vpos, ep.hpos, | |
1175 point, height, - (1 << (SHORTBITS - 1)), | |
1176 width, hscroll, epto); | |
1177 } | |
1178 else | |
1179 { | |
1180 pp = *compute_motion (xp.bufpos, xp.vpos, xp.hpos, | |
1181 point, height, - (1 << (SHORTBITS - 1)), | |
1182 width, hscroll, pos_tab_offset (w, xp.bufpos)); | |
1183 } | |
1184 if (pp.bufpos < point || pp.vpos == height) | |
1185 return 0; | |
1186 cursor_vpos = pp.vpos + top; | |
1187 cursor_hpos = pp.hpos + XFASTINT (w->left); | |
1188 } | |
1189 | |
1190 if (stop_vpos - scroll_amount >= height | |
1191 || ep.bufpos == xp.bufpos) | |
1192 { | |
1193 if (scroll_amount < 0) | |
1194 stop_vpos -= scroll_amount; | |
1195 scroll_amount = 0; | |
1196 /* In this path, we have altered window_end_vpos | |
1197 and not left it negative. | |
1198 We must make sure that, in case display is preempted | |
769 | 1199 before the frame changes to reflect what we do here, |
277 | 1200 further updates will not come to try_window_id |
769 | 1201 and assume the frame and window_end_vpos match. */ |
277 | 1202 blank_end_of_window = 1; |
1203 } | |
1204 else if (!scroll_amount) | |
1205 {} | |
1206 else if (bp.bufpos == Z - end_unchanged) | |
1207 { | |
1208 /* If reprinting everything is nearly as fast as scrolling, | |
1209 don't bother scrolling. Can happen if lines are short. */ | |
769 | 1210 if (scroll_cost (f, bp.vpos + top - scroll_amount, |
277 | 1211 top + height - max (0, scroll_amount), |
1212 scroll_amount) | |
1213 > xp.bufpos - bp.bufpos - 20) | |
1214 /* Return "try normal display with same window-start." | |
1215 Too bad we can't prevent further scroll-thinking. */ | |
1216 return -2; | |
1217 /* If pure deletion, scroll up as many lines as possible. | |
1218 In common case of killing a line, this can save the | |
1219 following line from being overwritten by scrolling | |
1220 and therefore having to be redrawn. */ | |
769 | 1221 tem = scroll_frame_lines (f, bp.vpos + top - scroll_amount, |
277 | 1222 top + height - max (0, scroll_amount), |
1223 scroll_amount); | |
1224 if (!tem) stop_vpos = height; | |
1225 } | |
1226 else if (scroll_amount) | |
1227 { | |
1228 /* If reprinting everything is nearly as fast as scrolling, | |
1229 don't bother scrolling. Can happen if lines are short. */ | |
1230 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an | |
1231 overestimate of cost of reprinting, since xp.bufpos | |
1232 would end up below the bottom of the window. */ | |
769 | 1233 if (scroll_cost (f, ep.vpos + top - scroll_amount, |
277 | 1234 top + height - max (0, scroll_amount), |
1235 scroll_amount) | |
1236 > xp.bufpos - ep.bufpos - 20) | |
1237 /* Return "try normal display with same window-start." | |
1238 Too bad we can't prevent further scroll-thinking. */ | |
1239 return -2; | |
769 | 1240 tem = scroll_frame_lines (f, ep.vpos + top - scroll_amount, |
277 | 1241 top + height - max (0, scroll_amount), |
1242 scroll_amount); | |
1243 if (!tem) stop_vpos = height; | |
1244 } | |
1245 } | |
1246 | |
1247 /* In any case, do not display past bottom of window */ | |
1248 if (stop_vpos >= height) | |
1249 { | |
1250 stop_vpos = height; | |
1251 scroll_amount = 0; | |
1252 } | |
1253 | |
1254 /* Handle case where pos is before w->start -- | |
1255 can happen if part of line had been clipped and is not clipped now */ | |
1256 if (vpos == 0 && pos < marker_position (w->start)) | |
1257 Fset_marker (w->start, make_number (pos), Qnil); | |
1258 | |
1259 /* Redisplay the lines where the text was changed */ | |
1260 last_text_vpos = vpos; | |
1261 tab_offset = pos_tab_offset (w, pos); | |
1262 /* If we are starting display in mid-character, correct tab_offset | |
1263 to account for passing the line that that character really starts in. */ | |
1264 if (val.hpos < lmargin) | |
1265 tab_offset += width; | |
1266 while (vpos < stop_vpos) | |
1267 { | |
1268 val = *display_text_line (w, pos, top + vpos++, val.hpos, tab_offset); | |
1269 tab_offset += width; | |
1270 if (val.vpos) tab_offset = 0; | |
1271 if (pos != val.bufpos) | |
1272 last_text_vpos | |
1273 /* Next line, unless prev line ended in end of buffer with no cr */ | |
1274 = vpos - (val.vpos && FETCH_CHAR (val.bufpos - 1) != '\n'); | |
1275 pos = val.bufpos; | |
1276 } | |
1277 | |
1278 /* There are two cases: | |
1279 1) we have displayed down to the bottom of the window | |
1280 2) we have scrolled lines below stop_vpos by scroll_amount */ | |
1281 | |
1282 if (vpos == height) | |
1283 { | |
1284 /* If last line is continued in middle of character, | |
769 | 1285 include the split character in the text considered on the frame */ |
277 | 1286 if (val.hpos < lmargin) |
1287 val.bufpos++; | |
1288 XFASTINT (w->window_end_vpos) = last_text_vpos; | |
1289 XFASTINT (w->window_end_pos) = Z - val.bufpos; | |
1290 } | |
1291 | |
1292 /* If scrolling made blank lines at window bottom, | |
1293 redisplay to fill those lines */ | |
1294 if (scroll_amount < 0) | |
1295 { | |
1296 /* Don't consider these lines for general-purpose scrolling. | |
1297 That will save time in the scrolling computation. */ | |
769 | 1298 FRAME_SCROLL_BOTTOM_VPOS (f) = xp.vpos; |
277 | 1299 vpos = xp.vpos; |
1300 pos = xp.bufpos; | |
1301 val.hpos = lmargin; | |
1302 if (pos == ZV) | |
1303 vpos = height + scroll_amount; | |
1304 else if (xp.contin && xp.hpos != lmargin) | |
1305 { | |
1306 val.hpos = xp.prevhpos - width + lmargin; | |
1307 pos--; | |
1308 } | |
1309 | |
1310 blank_end_of_window = 1; | |
1311 tab_offset = pos_tab_offset (w, pos); | |
1312 /* If we are starting display in mid-character, correct tab_offset | |
1313 to account for passing the line that that character starts in. */ | |
1314 if (val.hpos < lmargin) | |
1315 tab_offset += width; | |
1316 | |
1317 while (vpos < height) | |
1318 { | |
1319 val = *display_text_line (w, pos, top + vpos++, val.hpos, tab_offset); | |
1320 tab_offset += width; | |
1321 if (val.vpos) tab_offset = 0; | |
1322 pos = val.bufpos; | |
1323 } | |
1324 | |
1325 /* Here is a case where display_text_line sets cursor_vpos wrong. | |
1326 Make it be fixed up, below. */ | |
1327 if (xp.bufpos == ZV | |
1328 && xp.bufpos == point) | |
1329 cursor_vpos = -1; | |
1330 } | |
1331 | |
769 | 1332 /* If bottom just moved off end of frame, change mode line percentage. */ |
277 | 1333 if (XFASTINT (w->window_end_pos) == 0 |
1334 && Z != val.bufpos) | |
1335 w->update_mode_line = Qt; | |
1336 | |
1337 /* Attempt to adjust end-of-text positions to new bottom line */ | |
1338 if (scroll_amount) | |
1339 { | |
1340 delta = height - xp.vpos; | |
1341 if (delta < 0 | |
1342 || (delta > 0 && xp.bufpos <= ZV) | |
1343 || (delta == 0 && xp.hpos)) | |
1344 { | |
1345 val = *vmotion (Z - XFASTINT (w->window_end_pos), | |
1346 delta, width, hscroll, window); | |
1347 XFASTINT (w->window_end_pos) = Z - val.bufpos; | |
1348 XFASTINT (w->window_end_vpos) += val.vpos; | |
1349 } | |
1350 } | |
1351 | |
1352 w->window_end_valid = Qnil; | |
1353 | |
1354 /* If point was not in a line that was displayed, find it */ | |
1355 if (cursor_vpos < 0) | |
1356 { | |
1357 val = *compute_motion (start, 0, lmargin, point, 10000, 10000, | |
1358 width, hscroll, pos_tab_offset (w, start)); | |
769 | 1359 /* Admit failure if point is off frame now */ |
277 | 1360 if (val.vpos >= height) |
1361 { | |
1362 for (vpos = 0; vpos < height; vpos++) | |
769 | 1363 cancel_line (vpos + top, f); |
277 | 1364 return 0; |
1365 } | |
1366 cursor_vpos = val.vpos + top; | |
1367 cursor_hpos = val.hpos + XFASTINT (w->left); | |
1368 } | |
1369 | |
769 | 1370 FRAME_CURSOR_X (f) = max (0, cursor_hpos); |
1371 FRAME_CURSOR_Y (f) = cursor_vpos; | |
277 | 1372 |
1373 if (debug_end_pos) | |
1374 { | |
1375 val = *compute_motion (start, 0, lmargin, ZV, | |
1376 height, - (1 << (SHORTBITS - 1)), | |
1377 width, hscroll, pos_tab_offset (w, start)); | |
1378 if (val.vpos != XFASTINT (w->window_end_vpos)) | |
1379 abort (); | |
1380 if (XFASTINT (w->window_end_pos) | |
1381 != Z - val.bufpos) | |
1382 abort (); | |
1383 } | |
1384 | |
1385 return 1; | |
1386 } | |
1387 | |
301 | 1388 /* Copy glyphs from the rope FROM to T. |
1389 But don't actually copy the parts that would come in before S. | |
277 | 1390 Value is T, advanced past the copied data. |
1391 | |
1392 Characters in FROM are grouped into units of `sizeof GLYPH' chars; | |
1393 any extra chars at the end of FROM are ignored. */ | |
1394 | |
1395 GLYPH * | |
1396 copy_rope (t, s, from) | |
1397 register GLYPH *t; /* Copy to here. */ | |
1398 register GLYPH *s; /* Starting point. */ | |
1399 Lisp_Object from; /* Data to copy; known to be a string. */ | |
1400 { | |
1401 register int n = XSTRING (from)->size / sizeof (GLYPH); | |
1402 register GLYPH *f = (GLYPH *) XSTRING (from)->data; | |
1403 | |
1404 while (n--) | |
1405 { | |
1406 if (t >= s) *t = *f; | |
1407 ++t; | |
1408 ++f; | |
1409 } | |
1410 return t; | |
1411 } | |
1412 | |
1413 /* Display one line of window w, starting at position START in W's buffer. | |
1414 Display starting at horizontal position HPOS, which is normally zero | |
1415 or negative. A negative value causes output up to hpos = 0 to be discarded. | |
1416 This is done for negative hscroll, or when this is a continuation line | |
1417 and the continuation occurred in the middle of a multi-column character. | |
1418 | |
1419 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations. | |
1420 | |
769 | 1421 Display on position VPOS on the frame. (origin 0). |
277 | 1422 |
1423 Returns a STRUCT POSITION giving character to start next line with | |
1424 and where to display it, including a zero or negative hpos. | |
1425 The vpos field is not really a vpos; it is 1 unless the line is continued */ | |
1426 | |
1427 struct position val_display_text_line; | |
1428 | |
1429 static struct position * | |
1430 display_text_line (w, start, vpos, hpos, taboffset) | |
1431 struct window *w; | |
1432 int start; | |
1433 int vpos; | |
1434 int hpos; | |
1435 int taboffset; | |
1436 { | |
1437 register int pos = start; | |
1438 register int c; | |
1439 register GLYPH *p1; | |
1440 int end; | |
1441 register int pause; | |
1442 register unsigned char *p; | |
1443 GLYPH *endp; | |
1444 register GLYPH *startp; | |
1445 register GLYPH *p1prev; | |
769 | 1446 FRAME_PTR f = XFRAME (w->frame); |
277 | 1447 int tab_width = XINT (current_buffer->tab_width); |
485 | 1448 int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
277 | 1449 int width = XFASTINT (w->width) - 1 |
769 | 1450 - (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)); |
277 | 1451 struct position val; |
1452 int lastpos; | |
1453 int invis; | |
1454 int hscroll = XINT (w->hscroll); | |
1455 int truncate = hscroll | |
1456 || (truncate_partial_width_windows | |
769 | 1457 && XFASTINT (w->width) < FRAME_WIDTH (f)) |
485 | 1458 || !NILP (current_buffer->truncate_lines); |
277 | 1459 int selective |
1460 = XTYPE (current_buffer->selective_display) == Lisp_Int | |
1461 ? XINT (current_buffer->selective_display) | |
485 | 1462 : !NILP (current_buffer->selective_display) ? -1 : 0; |
277 | 1463 #ifndef old |
485 | 1464 int selective_e = selective && !NILP (current_buffer->selective_display_ellipses); |
277 | 1465 #endif |
769 | 1466 register struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (f); |
277 | 1467 register struct Lisp_Vector *dp = window_display_table (w); |
1468 int selective_rlen | |
1469 = (selective && dp && XTYPE (DISP_INVIS_ROPE (dp)) == Lisp_String | |
1470 ? XSTRING (DISP_INVIS_ROPE (dp))->size / sizeof (GLYPH) : 0); | |
1471 GLYPH truncator = (dp == 0 || XTYPE (DISP_TRUNC_GLYPH (dp)) != Lisp_Int | |
1472 ? '$' : XINT (DISP_TRUNC_GLYPH (dp))); | |
1473 GLYPH continuer = (dp == 0 || XTYPE (DISP_CONTINUE_GLYPH (dp)) != Lisp_Int | |
1474 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp))); | |
1475 | |
1476 hpos += XFASTINT (w->left); | |
769 | 1477 get_display_line (f, vpos, XFASTINT (w->left)); |
277 | 1478 if (tab_width <= 0 || tab_width > 20) tab_width = 8; |
1479 | |
1480 if (MINI_WINDOW_P (w) && start == 1 | |
1481 && vpos == XFASTINT (w->top)) | |
1482 { | |
1483 if (minibuf_prompt) | |
1484 hpos = display_string (w, vpos, minibuf_prompt, hpos, | |
1485 (!truncate ? continuer : truncator), | |
1486 -1, -1); | |
1487 minibuf_prompt_width = hpos; | |
1488 } | |
1489 | |
1490 desired_glyphs->bufp[vpos] = pos; | |
1491 p1 = desired_glyphs->glyphs[vpos] + hpos; | |
1492 end = ZV; | |
1493 startp = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); | |
1494 endp = startp + width; | |
1495 | |
1496 /* Loop generating characters. | |
1497 Stop at end of buffer, before newline, | |
1498 or if reach or pass continuation column. */ | |
1499 | |
1500 pause = pos; | |
1501 while (p1 < endp) | |
1502 { | |
1503 p1prev = p1; | |
1504 if (pos == pause) | |
1505 { | |
1506 if (pos == end) | |
1507 break; | |
1508 if (pos == point && cursor_vpos < 0) | |
1509 { | |
1510 cursor_vpos = vpos; | |
1511 cursor_hpos = p1 - startp; | |
1512 } | |
1513 | |
1514 pause = end; | |
1515 if (pos < point && point < pause) | |
1516 pause = point; | |
1517 if (pos < GPT && GPT < pause) | |
1518 pause = GPT; | |
1519 | |
1520 p = &FETCH_CHAR (pos); | |
1521 } | |
1522 c = *p++; | |
1523 if (c >= 040 && c < 0177 | |
1524 && (dp == 0 || XTYPE (DISP_CHAR_ROPE (dp, c)) != Lisp_String)) | |
1525 { | |
1526 if (p1 >= startp) | |
1527 *p1 = c; | |
1528 p1++; | |
1529 } | |
1530 else if (c == '\n') | |
1531 { | |
1532 invis = 0; | |
1533 while (pos < end | |
1534 && selective > 0 | |
1535 && position_indentation (pos + 1) >= selective) | |
1536 { | |
1537 invis = 1; | |
1538 pos = find_next_newline (pos + 1, 1); | |
1539 if (FETCH_CHAR (pos - 1) == '\n') | |
1540 pos--; | |
1541 } | |
1542 if (invis && selective_rlen > 0 && p1 >= startp) | |
1543 { | |
1544 p1 += selective_rlen; | |
1545 if (p1 - startp > width) | |
1546 p1 = endp; | |
1547 bcopy (XSTRING (DISP_INVIS_ROPE (dp))->data, p1prev, | |
1548 (p1 - p1prev) * sizeof (GLYPH)); | |
1549 } | |
1550 break; | |
1551 } | |
1552 else if (c == '\t') | |
1553 { | |
1554 do | |
1555 { | |
1556 if (p1 >= startp && p1 < endp) | |
1557 *p1 = SPACEGLYPH; | |
1558 p1++; | |
1559 } | |
1560 while ((p1 - startp + taboffset + hscroll - (hscroll > 0)) | |
1561 % tab_width); | |
1562 } | |
368 | 1563 else if (c == Ctl ('M') && selective == -1) |
277 | 1564 { |
1565 pos = find_next_newline (pos, 1); | |
1566 if (FETCH_CHAR (pos - 1) == '\n') | |
1567 pos--; | |
1568 if (selective_rlen > 0) | |
1569 { | |
1570 p1 += selective_rlen; | |
1571 if (p1 - startp > width) | |
1572 p1 = endp; | |
1573 bcopy (XSTRING (DISP_INVIS_ROPE (dp))->data, p1prev, | |
1574 (p1 - p1prev) * sizeof (GLYPH)); | |
1575 } | |
1576 break; | |
1577 } | |
1578 else if (dp != 0 && XTYPE (DISP_CHAR_ROPE (dp, c)) == Lisp_String) | |
1579 { | |
1580 p1 = copy_rope (p1, startp, DISP_CHAR_ROPE (dp, c)); | |
1581 } | |
1582 else if (c < 0200 && ctl_arrow) | |
1583 { | |
1584 if (p1 >= startp) | |
1585 *p1 = (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int | |
1586 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'); | |
1587 p1++; | |
368 | 1588 if (p1 >= startp && p1 < endp) |
277 | 1589 *p1 = c ^ 0100; |
1590 p1++; | |
1591 } | |
1592 else | |
1593 { | |
1594 if (p1 >= startp) | |
1595 *p1 = (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int | |
1596 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'); | |
1597 p1++; | |
368 | 1598 if (p1 >= startp && p1 < endp) |
277 | 1599 *p1 = (c >> 6) + '0'; |
1600 p1++; | |
368 | 1601 if (p1 >= startp && p1 < endp) |
277 | 1602 *p1 = (7 & (c >> 3)) + '0'; |
1603 p1++; | |
368 | 1604 if (p1 >= startp && p1 < endp) |
277 | 1605 *p1 = (7 & c) + '0'; |
1606 p1++; | |
1607 } | |
1608 pos++; | |
1609 } | |
1610 | |
1611 val.hpos = - XINT (w->hscroll); | |
1612 if (val.hpos) | |
1613 val.hpos++; | |
1614 | |
1615 val.vpos = 1; | |
1616 | |
1617 lastpos = pos; | |
1618 | |
1619 /* Handle continuation in middle of a character */ | |
1620 /* by backing up over it */ | |
1621 if (p1 > endp) | |
1622 { | |
1623 /* Start the next line with that same character */ | |
1624 pos--; | |
1625 /* but at a negative hpos, to skip the columns output on this line. */ | |
1626 val.hpos += p1prev - endp; | |
1627 /* Keep in this line everything up to the continuation column. */ | |
1628 p1 = endp; | |
1629 } | |
1630 | |
1631 /* Finish deciding which character to start the next line on, | |
1632 and what hpos to start it at. | |
1633 Also set `lastpos' to the last position which counts as "on this line" | |
1634 for cursor-positioning. */ | |
1635 | |
1636 if (pos < ZV) | |
1637 { | |
1638 if (FETCH_CHAR (pos) == '\n') | |
1639 /* If stopped due to a newline, start next line after it */ | |
1640 pos++; | |
1641 else | |
1642 /* Stopped due to right margin of window */ | |
1643 { | |
1644 if (truncate) | |
1645 { | |
1646 *p1++ = truncator; | |
1647 /* Truncating => start next line after next newline, | |
1648 and point is on this line if it is before the newline, | |
1649 and skip none of first char of next line */ | |
1650 pos = find_next_newline (pos, 1); | |
1651 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0; | |
1652 | |
1653 lastpos = pos - (FETCH_CHAR (pos - 1) == '\n'); | |
1654 } | |
1655 else | |
1656 { | |
1657 *p1++ = continuer; | |
1658 val.vpos = 0; | |
1659 lastpos--; | |
1660 } | |
1661 } | |
1662 } | |
1663 | |
1664 /* If point is at eol or in invisible text at eol, | |
769 | 1665 record its frame location now. */ |
277 | 1666 |
1667 if (start <= point && point <= lastpos && cursor_vpos < 0) | |
1668 { | |
1669 cursor_vpos = vpos; | |
1670 cursor_hpos = p1 - startp; | |
1671 } | |
1672 | |
1673 if (cursor_vpos == vpos) | |
1674 { | |
1675 if (cursor_hpos < 0) cursor_hpos = 0; | |
1676 if (cursor_hpos > width) cursor_hpos = width; | |
1677 cursor_hpos += XFASTINT (w->left); | |
769 | 1678 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f))) |
277 | 1679 { |
769 | 1680 FRAME_CURSOR_Y (f) = cursor_vpos; |
1681 FRAME_CURSOR_X (f) = cursor_hpos; | |
277 | 1682 |
1683 if (w == XWINDOW (selected_window)) | |
1684 { | |
1685 /* Line is not continued and did not start | |
1686 in middle of character */ | |
1687 if ((hpos - XFASTINT (w->left) | |
1688 == (XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0)) | |
1689 && val.vpos) | |
1690 { | |
1691 this_line_bufpos = start; | |
1692 this_line_buffer = current_buffer; | |
1693 this_line_vpos = cursor_vpos; | |
1694 this_line_start_hpos = hpos; | |
1695 this_line_endpos = Z - lastpos; | |
1696 } | |
1697 else | |
1698 this_line_bufpos = 0; | |
1699 } | |
1700 } | |
1701 } | |
1702 | |
1703 /* If hscroll and line not empty, insert truncation-at-left marker */ | |
1704 if (hscroll && lastpos != start) | |
1705 { | |
1706 *startp = truncator; | |
1707 if (p1 <= startp) | |
1708 p1 = startp + 1; | |
1709 } | |
1710 | |
769 | 1711 if (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)) |
277 | 1712 { |
1713 endp++; | |
1714 if (p1 < startp) p1 = startp; | |
1715 while (p1 < endp) *p1++ = SPACEGLYPH; | |
1716 *p1++ = '|'; | |
1717 } | |
1718 desired_glyphs->used[vpos] = max (desired_glyphs->used[vpos], | |
1719 p1 - desired_glyphs->glyphs[vpos]); | |
1720 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0; | |
1721 | |
1722 /* If the start of this line is the overlay arrow-position, | |
1723 then put the arrow string into the display-line. */ | |
1724 | |
1725 if (XTYPE (Voverlay_arrow_position) == Lisp_Marker | |
1726 && current_buffer == XMARKER (Voverlay_arrow_position)->buffer | |
1727 && start == marker_position (Voverlay_arrow_position) | |
1728 && XTYPE (Voverlay_arrow_string) == Lisp_String | |
1729 && ! overlay_arrow_seen) | |
1730 { | |
1731 unsigned char *p = XSTRING (Voverlay_arrow_string)->data; | |
1732 int i; | |
1733 int len = XSTRING (Voverlay_arrow_string)->size; | |
1734 | |
1735 if (len > XFASTINT (w->width) - 1) | |
1736 len = XFASTINT (w->width) - 1; | |
1737 for (i = 0; i < len; i++) | |
1738 startp[i] = p[i]; | |
1739 if (desired_glyphs->used[vpos] < | |
1740 (len + startp - desired_glyphs->glyphs[vpos])) | |
1741 desired_glyphs->used[vpos] = len + startp - desired_glyphs->glyphs[vpos]; | |
1742 | |
1743 overlay_arrow_seen = 1; | |
1744 } | |
1745 | |
1746 val.bufpos = pos; | |
1747 val_display_text_line = val; | |
1748 return &val_display_text_line; | |
1749 } | |
1750 | |
1751 /* Display the mode line for window w */ | |
1752 | |
1753 static void | |
1754 display_mode_line (w) | |
1755 struct window *w; | |
1756 { | |
1757 register int vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1; | |
1758 register int left = XFASTINT (w->left); | |
1759 register int right = XFASTINT (w->width) + left; | |
769 | 1760 register FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
277 | 1761 |
769 | 1762 get_display_line (f, vpos, left); |
277 | 1763 display_mode_element (w, vpos, left, 0, right, right, |
1764 current_buffer->mode_line_format); | |
769 | 1765 FRAME_DESIRED_GLYPHS (f)->bufp[vpos] = 0; |
277 | 1766 |
1767 /* Make the mode line inverse video if the entire line | |
1768 is made of mode lines. | |
1769 I.e. if this window is full width, | |
1770 or if it is the child of a full width window | |
1771 (which implies that that window is split side-by-side | |
1772 and the rest of this line is mode lines of the sibling windows). */ | |
769 | 1773 if (XFASTINT (w->width) == FRAME_WIDTH (f) |
1774 || XFASTINT (XWINDOW (w->parent)->width) == FRAME_WIDTH (f)) | |
1775 FRAME_DESIRED_GLYPHS (f)->highlight[vpos] = mode_line_inverse_video; | |
277 | 1776 |
1777 #ifdef HAVE_X_WINDOWS | |
1778 /* I'm trying this out because I saw Unimpress use it, but it's | |
1124
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1779 possible that this may mess adversely with some window managers. -jla |
277 | 1780 |
1124
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1781 Wouldn't it be nice to use something like mode-line-format to |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1782 describe frame titles? -JimB */ |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1783 |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1784 /* Change the title of the frame to the name of the buffer displayed |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1785 in the currently selected window. Don't do this for minibuffer frames, |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1786 and don't do it when there's only one non-minibuffer frame. */ |
973
52267046b144
* xdisp.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
831
diff
changeset
|
1787 if (FRAME_X_P (f) |
769 | 1788 && ! FRAME_MINIBUF_ONLY_P (f) |
831 | 1789 && w == XWINDOW (f->selected_window)) |
1124
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1790 x_implicitly_set_name (f, (EQ (Fnext_frame (WINDOW_FRAME (w), Qnil), |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1791 WINDOW_FRAME (w)) |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1792 ? Qnil |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
1793 : XBUFFER (w->buffer)->name), |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
1794 Qnil); |
277 | 1795 #endif |
1796 } | |
1797 | |
1798 /* Contribute ELT to the mode line for window W. | |
1799 How it translates into text depends on its data type. | |
1800 | |
1801 VPOS is the position of the mode line being displayed. | |
1802 | |
769 | 1803 HPOS is the position (absolute on frame) where this element's text |
277 | 1804 should start. The output is truncated automatically at the right |
1805 edge of window W. | |
1806 | |
1807 DEPTH is the depth in recursion. It is used to prevent | |
1808 infinite recursion here. | |
1809 | |
1810 MINENDCOL is the hpos before which the element may not end. | |
1811 The element is padded at the right with spaces if nec | |
1812 to reach this column. | |
1813 | |
1814 MAXENDCOL is the hpos past which this element may not extend. | |
1815 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority. | |
1816 (This is necessary to make nested padding and truncation work.) | |
1817 | |
1818 Returns the hpos of the end of the text generated by ELT. | |
1819 The next element will receive that value as its HPOS arg, | |
1820 so as to concatenate the elements. */ | |
1821 | |
1822 static int | |
1823 display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt) | |
1824 struct window *w; | |
1825 register int vpos, hpos; | |
1826 int depth; | |
1827 int minendcol; | |
1828 register int maxendcol; | |
1829 register Lisp_Object elt; | |
1830 { | |
1831 tail_recurse: | |
1832 if (depth > 10) | |
1833 goto invalid; | |
1834 | |
1835 depth++; | |
1836 | |
1837 #ifdef SWITCH_ENUM_BUG | |
1838 switch ((int) XTYPE (elt)) | |
1839 #else | |
1840 switch (XTYPE (elt)) | |
1841 #endif | |
1842 { | |
1843 case Lisp_String: | |
1844 { | |
1845 /* A string: output it and check for %-constructs within it. */ | |
1846 register unsigned char c; | |
1847 register unsigned char *this = XSTRING (elt)->data; | |
1848 | |
1849 while (hpos < maxendcol && *this) | |
1850 { | |
1851 unsigned char *last = this; | |
1852 while ((c = *this++) != '\0' && c != '%') | |
1853 ; | |
1854 if (this - 1 != last) | |
1855 { | |
1856 register int lim = --this - last + hpos; | |
1857 hpos = display_string (w, vpos, last, hpos, 0, hpos, | |
1858 min (lim, maxendcol)); | |
1859 } | |
1860 else /* c == '%' */ | |
1861 { | |
1862 register int spec_width = 0; | |
1863 | |
1864 /* We can't allow -ve args due to the "%-" construct */ | |
1865 /* Argument specifies minwidth but not maxwidth | |
1866 (maxwidth can be specified by | |
1867 (<negative-number> . <stuff>) mode-line elements) */ | |
1868 | |
1869 while ((c = *this++) >= '0' && c <= '9') | |
1870 { | |
1871 spec_width = spec_width * 10 + (c - '0'); | |
1872 } | |
1873 | |
1874 spec_width += hpos; | |
1875 if (spec_width > maxendcol) | |
1876 spec_width = maxendcol; | |
1877 | |
1878 if (c == 'M') | |
1879 hpos = display_mode_element (w, vpos, hpos, depth, | |
1880 spec_width, maxendcol, | |
1881 Vglobal_mode_string); | |
1882 else if (c != 0) | |
1883 hpos = display_string (w, vpos, | |
1884 decode_mode_spec (w, c, | |
1885 maxendcol - hpos), | |
1886 hpos, 0, spec_width, maxendcol); | |
1887 } | |
1888 } | |
1889 } | |
1890 break; | |
1891 | |
1892 case Lisp_Symbol: | |
1893 /* A symbol: process the value of the symbol recursively | |
1894 as if it appeared here directly. Avoid error if symbol void. | |
1895 Special case: if value of symbol is a string, output the string | |
1896 literally. */ | |
1897 { | |
1898 register Lisp_Object tem; | |
1899 tem = Fboundp (elt); | |
485 | 1900 if (!NILP (tem)) |
277 | 1901 { |
1902 tem = Fsymbol_value (elt); | |
1903 /* If value is a string, output that string literally: | |
1904 don't check for % within it. */ | |
1905 if (XTYPE (tem) == Lisp_String) | |
1906 hpos = display_string (w, vpos, XSTRING (tem)->data, | |
1907 hpos, 0, minendcol, maxendcol); | |
1908 /* Give up right away for nil or t. */ | |
1909 else if (!EQ (tem, elt)) | |
1910 { elt = tem; goto tail_recurse; } | |
1911 } | |
1912 } | |
1913 break; | |
1914 | |
1915 case Lisp_Cons: | |
1916 { | |
1917 register Lisp_Object car, tem; | |
1918 | |
1919 /* A cons cell: three distinct cases. | |
1920 If first element is a string or a cons, process all the elements | |
1921 and effectively concatenate them. | |
1922 If first element is a negative number, truncate displaying cdr to | |
1923 at most that many characters. If positive, pad (with spaces) | |
1924 to at least that many characters. | |
1925 If first element is a symbol, process the cadr or caddr recursively | |
1926 according to whether the symbol's value is non-nil or nil. */ | |
1927 car = XCONS (elt)->car; | |
1928 if (XTYPE (car) == Lisp_Symbol) | |
1929 { | |
1930 tem = Fboundp (car); | |
1931 elt = XCONS (elt)->cdr; | |
1932 if (XTYPE (elt) != Lisp_Cons) | |
1933 goto invalid; | |
1934 /* elt is now the cdr, and we know it is a cons cell. | |
1935 Use its car if CAR has a non-nil value. */ | |
485 | 1936 if (!NILP (tem)) |
277 | 1937 { |
1938 tem = Fsymbol_value (car); | |
485 | 1939 if (!NILP (tem)) |
277 | 1940 { elt = XCONS (elt)->car; goto tail_recurse; } |
1941 } | |
1942 /* Symbol's value is nil (or symbol is unbound) | |
1943 Get the cddr of the original list | |
1944 and if possible find the caddr and use that. */ | |
1945 elt = XCONS (elt)->cdr; | |
485 | 1946 if (NILP (elt)) |
277 | 1947 break; |
1948 else if (XTYPE (elt) != Lisp_Cons) | |
1949 goto invalid; | |
1950 elt = XCONS (elt)->car; | |
1951 goto tail_recurse; | |
1952 } | |
1953 else if (XTYPE (car) == Lisp_Int) | |
1954 { | |
1955 register int lim = XINT (car); | |
1956 elt = XCONS (elt)->cdr; | |
1957 if (lim < 0) | |
1958 /* Negative int means reduce maximum width. | |
1959 DO NOT change MINENDCOL here! | |
1960 (20 -10 . foo) should truncate foo to 10 col | |
1961 and then pad to 20. */ | |
1962 maxendcol = min (maxendcol, hpos - lim); | |
1963 else if (lim > 0) | |
1964 { | |
1965 /* Padding specified. Don't let it be more than | |
1966 current maximum. */ | |
1967 lim += hpos; | |
1968 if (lim > maxendcol) | |
1969 lim = maxendcol; | |
1970 /* If that's more padding than already wanted, queue it. | |
1971 But don't reduce padding already specified even if | |
1972 that is beyond the current truncation point. */ | |
1973 if (lim > minendcol) | |
1974 minendcol = lim; | |
1975 } | |
1976 goto tail_recurse; | |
1977 } | |
1978 else if (XTYPE (car) == Lisp_String || XTYPE (car) == Lisp_Cons) | |
1979 { | |
1980 register int limit = 50; | |
1981 /* LIMIT is to protect against circular lists. */ | |
1982 while (XTYPE (elt) == Lisp_Cons && --limit > 0 | |
1983 && hpos < maxendcol) | |
1984 { | |
1985 hpos = display_mode_element (w, vpos, hpos, depth, | |
1986 hpos, maxendcol, | |
1987 XCONS (elt)->car); | |
1988 elt = XCONS (elt)->cdr; | |
1989 } | |
1990 } | |
1991 } | |
1992 break; | |
1993 | |
1994 default: | |
1995 invalid: | |
1996 return (display_string (w, vpos, "*invalid*", hpos, 0, | |
1997 minendcol, maxendcol)); | |
1998 } | |
1999 | |
2000 end: | |
2001 if (minendcol > hpos) | |
2002 hpos = display_string (w, vpos, "", hpos, 0, minendcol, -1); | |
2003 return hpos; | |
2004 } | |
2005 | |
2006 /* Return a string for the output of a mode line %-spec for window W, | |
2007 generated by character C and width MAXWIDTH. */ | |
2008 | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2009 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------"; |
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2010 |
277 | 2011 static char * |
2012 decode_mode_spec (w, c, maxwidth) | |
2013 struct window *w; | |
2014 register char c; | |
2015 register int maxwidth; | |
2016 { | |
2017 Lisp_Object obj = Qnil; | |
769 | 2018 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
2019 char *decode_mode_spec_buf = (char *) FRAME_TEMP_GLYPHS (f)->total_contents; | |
277 | 2020 |
769 | 2021 if (maxwidth > FRAME_WIDTH (f)) |
2022 maxwidth = FRAME_WIDTH (f); | |
277 | 2023 |
2024 switch (c) | |
2025 { | |
2026 case 'b': | |
2027 obj = current_buffer->name; | |
2028 #if 0 | |
2029 if (maxwidth >= 3 && XSTRING (obj)->size > maxwidth) | |
2030 { | |
2031 bcopy (XSTRING (obj)->data, decode_mode_spec_buf, maxwidth - 1); | |
2032 decode_mode_spec_buf[maxwidth - 1] = '\\'; | |
2033 decode_mode_spec_buf[maxwidth] = '\0'; | |
2034 return decode_mode_spec_buf; | |
2035 } | |
2036 #endif | |
2037 break; | |
2038 | |
2039 case 'f': | |
2040 obj = current_buffer->filename; | |
2041 #if 0 | |
485 | 2042 if (NILP (obj)) |
277 | 2043 return "[none]"; |
2044 else if (XTYPE (obj) == Lisp_String && XSTRING (obj)->size > maxwidth) | |
2045 { | |
2046 bcopy ("...", decode_mode_spec_buf, 3); | |
2047 bcopy (XSTRING (obj)->data + XSTRING (obj)->size - maxwidth + 3, | |
2048 decode_mode_spec_buf + 3, maxwidth - 3); | |
2049 return decode_mode_spec_buf; | |
2050 } | |
2051 #endif | |
2052 break; | |
2053 | |
2054 case 'm': | |
2055 obj = current_buffer->mode_name; | |
2056 break; | |
2057 | |
2058 case 'n': | |
2059 if (BEGV > BEG || ZV < Z) | |
2060 return " Narrow"; | |
2061 break; | |
2062 | |
2063 case '*': | |
485 | 2064 if (!NILP (current_buffer->read_only)) |
277 | 2065 return "%"; |
2066 if (MODIFF > current_buffer->save_modified) | |
2067 return "*"; | |
2068 return "-"; | |
2069 | |
2070 case 's': | |
2071 /* status of process */ | |
2072 obj = Fget_buffer_process (Fcurrent_buffer ()); | |
485 | 2073 if (NILP (obj)) |
277 | 2074 return "no process"; |
2075 obj = Fsymbol_name (Fprocess_status (obj)); | |
2076 break; | |
2077 | |
2078 case 'p': | |
2079 { | |
2080 int pos = marker_position (w->start); | |
2081 int total = ZV - BEGV; | |
2082 | |
2083 if (XFASTINT (w->window_end_pos) <= Z - ZV) | |
2084 { | |
2085 if (pos <= BEGV) | |
2086 return "All"; | |
2087 else | |
2088 return "Bottom"; | |
2089 } | |
2090 else if (pos <= BEGV) | |
2091 return "Top"; | |
2092 else | |
2093 { | |
2094 total = ((pos - BEGV) * 100 + total - 1) / total; | |
2095 /* We can't normally display a 3-digit number, | |
2096 so get us a 2-digit number that is close. */ | |
2097 if (total == 100) | |
2098 total = 99; | |
2099 sprintf (decode_mode_spec_buf, "%2d%%", total); | |
2100 return decode_mode_spec_buf; | |
2101 } | |
2102 } | |
2103 | |
2104 case '%': | |
2105 return "%"; | |
2106 | |
2107 case '[': | |
2108 { | |
2109 int i; | |
2110 char *p; | |
2111 | |
2112 if (command_loop_level > 5) | |
2113 return "[[[... "; | |
2114 p = decode_mode_spec_buf; | |
2115 for (i = 0; i < command_loop_level; i++) | |
2116 *p++ = '['; | |
2117 *p = 0; | |
2118 return decode_mode_spec_buf; | |
2119 } | |
2120 | |
2121 case ']': | |
2122 { | |
2123 int i; | |
2124 char *p; | |
2125 | |
2126 if (command_loop_level > 5) | |
2127 return " ...]]]"; | |
2128 p = decode_mode_spec_buf; | |
2129 for (i = 0; i < command_loop_level; i++) | |
2130 *p++ = ']'; | |
2131 *p = 0; | |
2132 return decode_mode_spec_buf; | |
2133 } | |
2134 | |
2135 case '-': | |
2136 { | |
2137 register char *p; | |
2138 register int i; | |
2139 | |
2140 if (maxwidth < sizeof (lots_of_dashes)) | |
2141 return lots_of_dashes; | |
2142 else | |
2143 { | |
2144 for (p = decode_mode_spec_buf, i = maxwidth; i > 0; i--) | |
2145 *p++ = '-'; | |
2146 *p = '\0'; | |
2147 } | |
2148 return decode_mode_spec_buf; | |
2149 } | |
2150 } | |
2151 | |
2152 if (XTYPE (obj) == Lisp_String) | |
2153 return (char *) XSTRING (obj)->data; | |
2154 else | |
2155 return ""; | |
2156 } | |
2157 | |
2158 /* Display STRING on one line of window W, starting at HPOS. | |
2159 Display at position VPOS. Caller should have done get_display_line. | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2160 If VPOS == -1, display it as the current frame's title. |
277 | 2161 |
2162 TRUNCATE is GLYPH to display at end if truncated. Zero for none. | |
2163 | |
2164 MINCOL is the first column ok to end at. (Pad with spaces to this col.) | |
2165 MAXCOL is the last column ok to end at. Truncate here. | |
2166 -1 for MINCOL or MAXCOL means no explicit minimum or maximum. | |
769 | 2167 Both count from the left edge of the frame, as does HPOS. |
277 | 2168 The right edge of W is an implicit maximum. |
2169 If TRUNCATE is nonzero, the implicit maximum is one column before the edge. | |
2170 | |
2171 Returns ending hpos */ | |
2172 | |
2173 static int | |
2174 display_string (w, vpos, string, hpos, truncate, mincol, maxcol) | |
2175 struct window *w; | |
2176 unsigned char *string; | |
2177 int vpos, hpos; | |
2178 GLYPH truncate; | |
2179 int mincol, maxcol; | |
2180 { | |
2181 register int c; | |
2182 register GLYPH *p1; | |
2183 int hscroll = XINT (w->hscroll); | |
2184 int tab_width = XINT (current_buffer->tab_width); | |
2185 register GLYPH *start; | |
2186 register GLYPH *end; | |
769 | 2187 struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (XFRAME (w->frame)); |
277 | 2188 GLYPH *p1start = desired_glyphs->glyphs[vpos] + hpos; |
2189 int window_width = XFASTINT (w->width); | |
2190 | |
2191 /* Use the standard display table, not the window's display table. | |
2192 We don't want the mode line in rot13. */ | |
2193 register struct Lisp_Vector *dp = 0; | |
2194 | |
2195 if (XTYPE (Vstandard_display_table) == Lisp_Vector | |
2196 && XVECTOR (Vstandard_display_table)->size == DISP_TABLE_SIZE) | |
2197 dp = XVECTOR (Vstandard_display_table); | |
2198 | |
2199 if (tab_width <= 0 || tab_width > 20) tab_width = 8; | |
2200 | |
2201 p1 = p1start; | |
2202 start = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); | |
2203 end = start + window_width - (truncate != 0); | |
2204 | |
2205 if ((window_width + XFASTINT (w->left)) | |
769 | 2206 != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) |
277 | 2207 *end-- = '|'; |
2208 | |
2209 if (maxcol >= 0 && end - desired_glyphs->glyphs[vpos] > maxcol) | |
2210 end = desired_glyphs->glyphs[vpos] + maxcol; | |
2211 if (maxcol >= 0 && mincol > maxcol) | |
2212 mincol = maxcol; | |
2213 | |
2214 while (p1 < end) | |
2215 { | |
2216 c = *string++; | |
2217 if (!c) break; | |
2218 if (c >= 040 && c < 0177 | |
2219 && (dp == 0 || XTYPE (DISP_CHAR_ROPE (dp, c)) != Lisp_String)) | |
2220 { | |
2221 if (p1 >= start) | |
2222 *p1 = c; | |
2223 p1++; | |
2224 } | |
2225 else if (c == '\t') | |
2226 { | |
2227 do | |
2228 { | |
2229 if (p1 >= start && p1 < end) | |
2230 *p1 = SPACEGLYPH; | |
2231 p1++; | |
2232 } | |
2233 while ((p1 - start + hscroll - (hscroll > 0)) % tab_width); | |
2234 } | |
2235 else if (dp != 0 && XTYPE (DISP_CHAR_ROPE (dp, c)) == Lisp_String) | |
2236 p1 = copy_rope (p1, start, DISP_CHAR_ROPE (dp, c)); | |
2237 else if (c < 0200 && buffer_defaults.ctl_arrow) | |
2238 { | |
2239 if (p1 >= start) | |
2240 *p1 = (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int | |
2241 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'); | |
2242 p1++; | |
368 | 2243 if (p1 >= start && p1 < end) |
277 | 2244 *p1 = c ^ 0100; |
2245 p1++; | |
2246 } | |
2247 else | |
2248 { | |
2249 if (p1 >= start) | |
2250 *p1 = (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int | |
2251 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'); | |
2252 p1++; | |
368 | 2253 if (p1 >= start && p1 < end) |
277 | 2254 *p1 = (c >> 6) + '0'; |
2255 p1++; | |
368 | 2256 if (p1 >= start && p1 < end) |
277 | 2257 *p1 = (7 & (c >> 3)) + '0'; |
2258 p1++; | |
368 | 2259 if (p1 >= start && p1 < end) |
277 | 2260 *p1 = (7 & c) + '0'; |
2261 p1++; | |
2262 } | |
2263 } | |
2264 | |
2265 if (c) | |
2266 { | |
2267 p1 = end; | |
2268 if (truncate) *p1++ = truncate; | |
2269 } | |
2270 else if (mincol >= 0) | |
2271 { | |
2272 end = desired_glyphs->glyphs[vpos] + mincol; | |
2273 while (p1 < end) | |
2274 *p1++ = SPACEGLYPH; | |
2275 } | |
2276 | |
2277 { | |
2278 register int len = p1 - desired_glyphs->glyphs[vpos]; | |
2279 | |
2280 if (len > desired_glyphs->used[vpos]) | |
2281 desired_glyphs->used[vpos] = len; | |
2282 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0; | |
2283 | |
2284 return len; | |
2285 } | |
2286 } | |
2287 | |
2288 void | |
2289 syms_of_xdisp () | |
2290 { | |
2291 staticpro (&last_arrow_position); | |
2292 staticpro (&last_arrow_string); | |
2293 last_arrow_position = Qnil; | |
2294 last_arrow_string = Qnil; | |
2295 | |
2296 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string, | |
782
a6d00bdb2b60
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
781
diff
changeset
|
2297 "String (or mode line construct) included (normally) in `mode-line-format'."); |
277 | 2298 Vglobal_mode_string = Qnil; |
2299 | |
2300 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position, | |
2301 "Marker for where to display an arrow on top of the buffer text.\n\ | |
2302 This must be the beginning of a line in order to work.\n\ | |
2303 See also `overlay-arrow-string'."); | |
2304 Voverlay_arrow_position = Qnil; | |
2305 | |
2306 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string, | |
2307 "String to display as an arrow. See also `overlay-arrow-position'."); | |
2308 Voverlay_arrow_string = Qnil; | |
2309 | |
2310 DEFVAR_INT ("scroll-step", &scroll_step, | |
2311 "*The number of lines to try scrolling a window by when point moves out.\n\ | |
769 | 2312 If that fails to bring point back on frame, point is centered instead.\n\ |
2313 If this is zero, point is always centered after it moves off frame."); | |
277 | 2314 |
2315 DEFVAR_INT ("debug-end-pos", &debug_end_pos, "Don't ask"); | |
2316 | |
2317 DEFVAR_BOOL ("truncate-partial-width-windows", | |
2318 &truncate_partial_width_windows, | |
769 | 2319 "*Non-nil means truncate lines in all windows less than full frame wide."); |
277 | 2320 truncate_partial_width_windows = 1; |
2321 | |
2322 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video, | |
2323 "*Non-nil means use inverse video for the mode line."); | |
2324 mode_line_inverse_video = 1; | |
2325 } | |
2326 | |
2327 /* initialize the window system */ | |
2328 init_xdisp () | |
2329 { | |
2330 Lisp_Object root_window; | |
2331 #ifndef COMPILER_REGISTER_BUG | |
2332 register | |
2333 #endif /* COMPILER_REGISTER_BUG */ | |
2334 struct window *mini_w; | |
2335 | |
2336 this_line_bufpos = 0; | |
2337 | |
2338 mini_w = XWINDOW (minibuf_window); | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2339 root_window = FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w))); |
277 | 2340 |
2341 echo_area_glyphs = 0; | |
2342 previous_echo_glyphs = 0; | |
2343 | |
2344 if (!noninteractive) | |
2345 { | |
769 | 2346 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (root_window))); |
277 | 2347 XFASTINT (XWINDOW (root_window)->top) = 0; |
769 | 2348 set_window_height (root_window, FRAME_HEIGHT (f) - 1, 0); |
2349 XFASTINT (mini_w->top) = FRAME_HEIGHT (f) - 1; | |
277 | 2350 set_window_height (minibuf_window, 1, 0); |
2351 | |
769 | 2352 XFASTINT (XWINDOW (root_window)->width) = FRAME_WIDTH (f); |
2353 XFASTINT (mini_w->width) = FRAME_WIDTH (f); | |
277 | 2354 } |
2355 } |