1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1985, 86, 87, 88, 93, 94 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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 2, or (at your option)
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.
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. */
23 /*#include <ctype.h>*/
29 #include "dispextern.h"
35 #include "termhooks.h"
36 #include "intervals.h"
39 extern void set_frame_menubar ();
42 extern int interrupt_input
;
43 extern int command_loop_level
;
45 /* Nonzero means print newline before next minibuffer message. */
47 int noninteractive_need_newline
;
49 #define min(a, b) ((a) < (b) ? (a) : (b))
50 #define max(a, b) ((a) > (b) ? (a) : (b))
52 /* The buffer position of the first character appearing
53 entirely or partially on the current frame line.
54 Or zero, which disables the optimization for the current frame line. */
55 static int this_line_bufpos
;
57 /* Number of characters past the end of this line,
58 including the terminating newline */
59 static int this_line_endpos
;
61 /* The vertical position of this frame line. */
62 static int this_line_vpos
;
64 /* Hpos value for start of display on this frame line.
65 Usually zero, but negative if first character really began
67 static int this_line_start_hpos
;
69 /* Buffer that this_line variables are describing. */
70 static struct buffer
*this_line_buffer
;
72 /* Set by try_window_id to the vpos of first of any lines
73 scrolled on to the bottom of the frame. These lines should
74 not be included in any general scroll computation. */
75 static int scroll_bottom_vpos
;
77 /* Value of echo_area_glyphs when it was last acted on.
78 If this is nonzero, there is a message on the frame
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
;
83 /* Nonzero means truncate lines in all windows less wide than the frame */
84 int truncate_partial_width_windows
;
86 Lisp_Object Vglobal_mode_string
;
88 /* Marker for where to display an arrow on top of the buffer text. */
89 Lisp_Object Voverlay_arrow_position
;
91 /* String to display for the arrow. */
92 Lisp_Object Voverlay_arrow_string
;
94 /* Values of those variables at last redisplay. */
95 static Lisp_Object last_arrow_position
, last_arrow_string
;
97 /* Nonzero if overlay arrow has been displayed once in this window. */
98 static int overlay_arrow_seen
;
100 /* Nonzero means highlight the region even in nonselected windows. */
101 static int highlight_nonselected_windows
;
103 /* If cursor motion alone moves point off frame,
104 Try scrolling this many lines up or down if that will bring it back. */
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
;
111 /* Number of windows showing the buffer of the selected window.
112 keyboard.c refers to this. */
115 /* display_text_line sets these to the frame position (origin 0) of point,
116 whether the window is selected or not.
117 Set one to -1 first to determine whether point was found afterwards. */
119 static int cursor_vpos
;
120 static int cursor_hpos
;
124 /* Nonzero means display mode line highlighted */
125 int mode_line_inverse_video
;
127 static void echo_area_display ();
128 void mark_window_display_accurate ();
129 static void redisplay_windows ();
130 static void redisplay_window ();
131 static void update_menu_bars ();
132 static void update_menu_bar ();
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 ();
141 static void display_menu_bar ();
142 static int display_count_lines ();
144 /* Prompt to display in front of the minibuffer contents */
145 char *minibuf_prompt
;
147 /* Width in columns of current minibuffer prompt. */
148 int minibuf_prompt_width
;
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
;
156 /* This is the length of the message in echo_area_glyphs. */
157 int echo_area_glyphs_length
;
159 /* true iff we should redraw the mode lines on the next redisplay */
160 int update_mode_lines
;
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. */
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. */
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
;
177 /* Nonzero if head_clip or tail_clip of current buffer has changed
178 since last redisplay that finished */
181 /* Nonzero if window sizes or contents have changed
182 since last redisplay that finished */
183 int windows_or_buffers_changed
;
185 /* Nonzero after display_mode_line if %l was used
186 and it displayed a line number. */
187 int line_number_displayed
;
189 /* Maximum buffer size for which to display line numbers. */
190 int line_number_display_limit
;
192 /* Display an echo area message M with a specified length of LEN chars.
193 The string may include null characters. If m is 0, clear out any
194 existing message, and let the minibuffer text show through.
195 Do not pass text that is stored in a Lisp string. */
204 if (noninteractive_need_newline
)
206 noninteractive_need_newline
= 0;
207 fwrite (m
, len
, 1, stderr
);
208 if (cursor_in_echo_area
== 0)
209 fprintf (stderr
, "\n");
212 /* A null message buffer means that the frame hasn't really been
213 initialized yet. Error messages get reported properly by
214 cmd_error, so this must be just an informative message; toss it. */
215 else if (INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
218 Lisp_Object minibuf_frame
;
220 choose_minibuf_frame ();
221 minibuf_frame
= WINDOW_FRAME (XWINDOW (minibuf_window
));
222 FRAME_SAMPLE_VISIBILITY (XFRAME (minibuf_frame
));
223 if (FRAME_VISIBLE_P (selected_frame
)
224 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame
)))
225 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window
)));
230 echo_area_glyphs
= m
;
231 echo_area_glyphs_length
= len
;
234 echo_area_glyphs
= previous_echo_glyphs
= 0;
236 do_pending_window_change ();
237 echo_area_display ();
238 update_frame (XFRAME (XWINDOW (minibuf_window
)->frame
), 1, 1);
239 do_pending_window_change ();
247 message2 (m
, (m
? strlen (m
) : 0));
250 /* Truncate what will be displayed in the echo area
251 the next time we display it--but don't redisplay it now. */
254 truncate_echo_area (len
)
257 /* A null message buffer means that the frame hasn't really been
258 initialized yet. Error messages get reported properly by
259 cmd_error, so this must be just an informative message; toss it. */
260 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
261 echo_area_glyphs_length
= len
;
264 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
265 zero if being used by message. */
266 int message_buf_print
;
268 /* Dump an informative message to the minibuf. If m is 0, clear out
269 any existing message, and let the minibuffer text show through. */
272 message (m
, a1
, a2
, a3
)
279 if (noninteractive_need_newline
)
281 noninteractive_need_newline
= 0;
282 fprintf (stderr
, m
, a1
, a2
, a3
);
283 if (cursor_in_echo_area
== 0)
284 fprintf (stderr
, "\n");
288 else if (INTERACTIVE
)
290 /* The frame whose minibuffer we're going to display the message on.
291 It may be larger than the selected frame, so we need
292 to use its buffer, not the selected frame's buffer. */
293 FRAME_PTR echo_frame
;
295 choose_minibuf_frame ();
296 echo_frame
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
298 echo_frame
= selected_frame
;
301 /* A null message buffer means that the frame hasn't really been
302 initialized yet. Error messages get reported properly by
303 cmd_error, so this must be just an informative message; toss it. */
304 if (FRAME_MESSAGE_BUF (echo_frame
))
315 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
316 FRAME_WIDTH (echo_frame
), m
, 0, 3, a
);
318 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
319 FRAME_WIDTH (echo_frame
), m
, 0, 3, &a1
);
320 #endif /* NO_ARG_ARRAY */
322 message2 (FRAME_MESSAGE_BUF (echo_frame
), len
);
327 /* Print should start at the beginning of the message
329 message_buf_print
= 0;
341 choose_minibuf_frame ();
344 f
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
346 if (! FRAME_VISIBLE_P (f
))
351 redraw_garbaged_frames ();
355 if (echo_area_glyphs
|| minibuf_level
== 0)
357 vpos
= XFASTINT (XWINDOW (minibuf_window
)->top
);
358 get_display_line (f
, vpos
, 0);
359 display_string (XWINDOW (minibuf_window
), vpos
,
360 echo_area_glyphs
? echo_area_glyphs
: "",
361 echo_area_glyphs
? echo_area_glyphs_length
: -1,
362 0, 0, 0, 0, FRAME_WIDTH (f
));
364 /* If desired cursor location is on this line, put it at end of text */
365 if (FRAME_CURSOR_Y (f
) == vpos
)
366 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
368 /* Fill the rest of the minibuffer window with blank lines. */
373 i
< vpos
+ XFASTINT (XWINDOW (minibuf_window
)->height
); i
++)
375 get_display_line (f
, i
, 0);
376 display_string (XWINDOW (minibuf_window
), vpos
,
377 "", 0, 0, 0, 0, 0, FRAME_WIDTH (f
));
381 else if (!EQ (minibuf_window
, selected_window
))
382 windows_or_buffers_changed
++;
384 if (EQ (minibuf_window
, selected_window
))
385 this_line_bufpos
= 0;
387 previous_echo_glyphs
= echo_area_glyphs
;
390 #ifdef HAVE_X_WINDOWS
391 /* I'm trying this out because I saw Unimpress use it, but it's
392 possible that this may mess adversely with some window managers. -jla
394 Wouldn't it be nice to use something like mode-line-format to
395 describe frame titles? -JimB */
397 /* Change the title of the frame to the name of the buffer displayed
398 in the currently selected window. Don't do this for minibuffer frames,
399 and don't do it when there's only one non-minibuffer frame. */
401 x_consider_frame_title (frame
)
404 FRAME_PTR f
= XFRAME (frame
);
406 if (FRAME_X_P (f
) && ! FRAME_MINIBUF_ONLY_P (f
))
411 if (! EQ (Fnext_frame (frame
, Qnil
), frame
))
412 title
= XBUFFER (XWINDOW (f
->selected_window
)->buffer
)->name
;
414 x_implicitly_set_name (f
, title
, Qnil
);
419 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
420 This can't be done in `redisplay' itself because it can call eval. */
425 register struct window
*w
= XWINDOW (selected_window
);
431 /* Set the visible flags for all frames.
432 Do this before checking for resized or garbaged frames; they want
433 to know if their frames are visible.
434 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
436 Lisp_Object tail
, frame
;
438 FOR_EACH_FRAME (tail
, frame
)
439 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
442 /* Notice any pending interrupt request to change frame size. */
443 do_pending_window_change ();
447 redraw_garbaged_frames ();
451 if (clip_changed
|| windows_or_buffers_changed
)
454 /* Detect case that we need to write a star in the mode line. */
455 if (XFASTINT (w
->last_modified
) < MODIFF
456 && XFASTINT (w
->last_modified
) <= current_buffer
->save_modified
)
458 w
->update_mode_line
= Qt
;
459 if (buffer_shared
> 1)
463 all_windows
= update_mode_lines
|| buffer_shared
> 1;
465 /* If specs for an arrow have changed, do thorough redisplay
466 to ensure we remove any arrow that should no longer exist. */
467 if (! EQ (Voverlay_arrow_position
, last_arrow_position
)
468 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
469 all_windows
= 1, clip_changed
= 1;
471 /* Update the menu bar item lists, if appropriate.
472 This has to be done before any actual redisplay
473 or generation of display lines. */
476 Lisp_Object tail
, frame
;
478 FOR_EACH_FRAME (tail
, frame
)
480 FRAME_PTR f
= XFRAME (frame
);
482 if (FRAME_VISIBLE_P (f
))
483 update_menu_bars (FRAME_ROOT_WINDOW (f
));
486 else if (FRAME_VISIBLE_P (selected_frame
))
487 update_menu_bar (selected_window
);
490 /* Do a frame update, taking possible shortcuts into account.
491 This is the main external entry point for redisplay.
493 If the last redisplay displayed an echo area message and that
494 message is no longer requested, we clear the echo area
495 or bring back the minibuffer if that is in use.
497 Do not call eval from within this function.
498 Calls to eval after the call to echo_area_display would confuse
499 the display_line mechanism and would cause a crash.
500 Calls to eval before that point will work most of the time,
501 but can still lose, because this function
502 can be called from signal handlers; with alarms set up;
503 or with synchronous processes running.
505 See Fcall_process; if you called it from here, it could be
506 entered recursively. */
511 register struct window
*w
= XWINDOW (selected_window
);
515 register int tlbufpos
, tlendpos
;
517 extern int input_pending
;
522 /* Set the visible flags for all frames.
523 Do this before checking for resized or garbaged frames; they want
524 to know if their frames are visible.
525 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
527 Lisp_Object tail
, frame
;
529 FOR_EACH_FRAME (tail
, frame
)
530 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
533 /* Notice any pending interrupt request to change frame size. */
534 do_pending_window_change ();
538 redraw_garbaged_frames ();
542 if (clip_changed
|| windows_or_buffers_changed
)
545 /* Detect case that we need to write a star in the mode line. */
546 if (XFASTINT (w
->last_modified
) < MODIFF
547 && XFASTINT (w
->last_modified
) <= current_buffer
->save_modified
)
549 w
->update_mode_line
= Qt
;
550 if (buffer_shared
> 1)
554 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
556 all_windows
= update_mode_lines
|| buffer_shared
> 1;
558 /* If specs for an arrow have changed, do thorough redisplay
559 to ensure we remove any arrow that should no longer exist. */
560 if (! EQ (Voverlay_arrow_position
, last_arrow_position
)
561 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
562 all_windows
= 1, clip_changed
= 1;
564 /* Normally the message* functions will have already displayed and
565 updated the echo area, but the frame may have been trashed, or
566 the update may have been preempted, so display the echo area
568 if (echo_area_glyphs
|| previous_echo_glyphs
)
570 echo_area_display ();
574 /* If showing region, and mark has changed, must redisplay whole window. */
575 if (((!NILP (Vtransient_mark_mode
)
576 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
577 != !NILP (w
->region_showing
))
578 || (!NILP (w
->region_showing
)
579 && !EQ (w
->region_showing
,
580 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
581 this_line_bufpos
= -1;
583 tlbufpos
= this_line_bufpos
;
584 tlendpos
= this_line_endpos
;
585 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
586 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
587 /* Make sure recorded data applies to current buffer, etc */
588 && this_line_buffer
== current_buffer
589 && current_buffer
== XBUFFER (w
->buffer
)
590 && NILP (w
->force_start
)
591 /* Point must be on the line that we have info recorded about */
593 && point
<= Z
- tlendpos
594 /* All text outside that line, including its final newline,
596 && (XFASTINT (w
->last_modified
) >= MODIFF
597 || (beg_unchanged
>= tlbufpos
- 1
599 /* If selective display, can't optimize
600 if the changes start at the beginning of the line. */
601 && ((XTYPE (current_buffer
->selective_display
) == Lisp_Int
602 && XINT (current_buffer
->selective_display
) > 0
603 ? (beg_unchanged
>= tlbufpos
606 && end_unchanged
>= tlendpos
607 && Z
- GPT
>= tlendpos
)))
609 if (tlbufpos
> BEGV
&& FETCH_CHAR (tlbufpos
- 1) != '\n'
611 || FETCH_CHAR (tlbufpos
) == '\n'))
612 /* Former continuation line has disappeared by becoming empty */
614 else if (XFASTINT (w
->last_modified
) < MODIFF
615 || MINI_WINDOW_P (w
))
618 overlay_arrow_seen
= 0;
619 display_text_line (w
, tlbufpos
, this_line_vpos
, this_line_start_hpos
,
620 pos_tab_offset (w
, tlbufpos
));
621 /* If line contains point, is not continued,
622 and ends at same distance from eob as before, we win */
623 if (cursor_vpos
>= 0 && this_line_bufpos
624 && this_line_endpos
== tlendpos
)
626 if (this_line_vpos
< XFASTINT (w
->top
) + window_internal_height (w
))
628 int left
= XFASTINT (w
->left
);
629 int *charstart_next_line
630 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
634 if (Z
- tlendpos
== ZV
)
635 /* This line ends at end of (accessible part of) buffer.
636 There is no newline to count. */
637 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
639 /* This line ends in a newline.
640 Must take account of the newline and the rest of the
641 text that follows. */
642 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
644 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
647 if (XFASTINT (w
->width
) != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w
))))
648 preserve_other_columns (w
);
654 else if (point
== XFASTINT (w
->last_point
))
658 do_pending_window_change ();
663 /* If highlighting the region, we can't just move the cursor. */
664 else if (! (!NILP (Vtransient_mark_mode
)
665 && !NILP (current_buffer
->mark_active
))
666 && NILP (w
->region_showing
))
668 pos
= *compute_motion (tlbufpos
, 0,
669 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
670 point
, 2, - (1 << (SHORTBITS
- 1)),
671 window_internal_width (w
) - 1,
673 pos_tab_offset (w
, tlbufpos
));
676 FRAME_CURSOR_X (selected_frame
)
677 = XFASTINT (w
->left
) + max (pos
.hpos
, 0);
678 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
685 /* Text changed drastically or point moved off of line */
686 cancel_line (this_line_vpos
, selected_frame
);
689 this_line_bufpos
= 0;
690 all_windows
|= buffer_shared
> 1;
694 Lisp_Object tail
, frame
;
696 #ifdef HAVE_X_WINDOWS
697 /* Since we're doing a thorough redisplay, we might as well
698 recompute all our display faces. */
699 clear_face_vector ();
702 /* Recompute # windows showing selected buffer.
703 This will be incremented each time such a window is displayed. */
706 FOR_EACH_FRAME (tail
, frame
)
708 FRAME_PTR f
= XFRAME (frame
);
710 /* Mark all the scroll bars to be removed; we'll redeem the ones
711 we want when we redisplay their windows. */
712 if (condemn_scroll_bars_hook
)
713 (*condemn_scroll_bars_hook
) (f
);
715 if (FRAME_VISIBLE_P (f
))
716 redisplay_windows (FRAME_ROOT_WINDOW (f
));
717 #ifdef HAVE_X_WINDOWS
718 else if (FRAME_ICONIFIED_P (f
)
719 && ! MINI_WINDOW_P (XWINDOW (f
->selected_window
)))
720 x_consider_frame_title (frame
);
723 /* Any scroll bars which redisplay_windows should have nuked
724 should now go away. */
725 if (judge_scroll_bars_hook
)
726 (*judge_scroll_bars_hook
) (f
);
729 else if (FRAME_VISIBLE_P (selected_frame
))
731 redisplay_window (selected_window
, 1);
732 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
733 preserve_other_columns (w
);
737 /* Prevent various kinds of signals during display update.
738 stdio is not robust about handling signals,
739 which can cause an apparent I/O error. */
751 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
755 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
758 f
= XFRAME (XCONS (tail
)->car
);
759 if (FRAME_VISIBLE_P (f
))
761 pause
|= update_frame (f
, 0, 0);
764 mark_window_display_accurate (f
->root_window
, 1);
765 if (frame_up_to_date_hook
!= 0)
766 (*frame_up_to_date_hook
) (f
);
772 #endif /* MULTI_FRAME */
774 if (FRAME_VISIBLE_P (selected_frame
))
775 pause
= update_frame (selected_frame
, 0, 0);
777 /* We may have called echo_area_display at the top of this
778 function. If the echo area is on another frame, that may
779 have put text on a frame other than the selected one, so the
780 above call to update_frame would not have caught it. Catch
784 = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
786 if (mini_frame
!= selected_frame
)
787 pause
|= update_frame (mini_frame
, 0, 0);
791 /* If frame does not match, prevent doing single-line-update next time.
792 Also, don't forget to check every line to update the arrow. */
795 this_line_bufpos
= 0;
796 if (!NILP (last_arrow_position
))
798 last_arrow_position
= Qt
;
799 last_arrow_string
= Qt
;
801 /* If we pause after scrolling, some lines in current_frame
802 may be null, so preserve_other_columns won't be able to
803 preserve all the vertical-bar separators. So, avoid using it
805 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
806 update_mode_lines
= 1;
809 /* Now text on frame agrees with windows, so
810 put info into the windows for partial redisplay to follow */
814 register struct buffer
*b
= XBUFFER (w
->buffer
);
816 blank_end_of_window
= 0;
818 unchanged_modified
= BUF_MODIFF (b
);
819 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
820 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
822 XFASTINT (w
->last_point
) = BUF_PT (b
);
823 XFASTINT (w
->last_point_x
) = FRAME_CURSOR_X (selected_frame
);
824 XFASTINT (w
->last_point_y
) = FRAME_CURSOR_Y (selected_frame
);
827 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
830 w
->update_mode_line
= Qnil
;
831 XFASTINT (w
->last_modified
) = BUF_MODIFF (b
);
832 w
->window_end_valid
= Qt
;
833 last_arrow_position
= Voverlay_arrow_position
;
834 last_arrow_string
= Voverlay_arrow_string
;
835 verify_charstarts (w
);
836 if (frame_up_to_date_hook
!= 0)
837 (*frame_up_to_date_hook
) (selected_frame
);
839 update_mode_lines
= 0;
840 windows_or_buffers_changed
= 0;
843 /* Start SIGIO interrupts coming again.
844 Having them off during the code above
845 makes it less likely one will discard output,
846 but not impossible, since there might be stuff
847 in the system buffer here.
848 But it is much hairier to try to do anything about that. */
854 /* Change frame size now if a change is pending. */
855 do_pending_window_change ();
858 /* Redisplay, but leave alone any recent echo area message
859 unless another message has been requested in its place.
861 This is useful in situations where you need to redisplay but no
862 user action has occurred, making it inappropriate for the message
863 area to be cleared. See tracking_off and
864 wait_reading_process_input for examples of these situations. */
866 redisplay_preserve_echo_area ()
868 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
870 echo_area_glyphs
= previous_echo_glyphs
;
872 echo_area_glyphs
= 0;
879 mark_window_display_accurate (window
, flag
)
883 register struct window
*w
;
885 for (;!NILP (window
); window
= w
->next
)
887 if (XTYPE (window
) != Lisp_Window
) abort ();
888 w
= XWINDOW (window
);
890 if (!NILP (w
->buffer
))
892 XFASTINT (w
->last_modified
)
894 : XBUFFER (w
->buffer
) == current_buffer
895 ? MODIFF
: BUF_MODIFF (XBUFFER (w
->buffer
));
897 /* Record if we are showing a region, so can make sure to
898 update it fully at next redisplay. */
899 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
900 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
901 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
905 w
->window_end_valid
= Qt
;
906 w
->update_mode_line
= Qnil
;
908 if (!NILP (w
->vchild
))
909 mark_window_display_accurate (w
->vchild
, flag
);
910 if (!NILP (w
->hchild
))
911 mark_window_display_accurate (w
->hchild
, flag
);
916 last_arrow_position
= Voverlay_arrow_position
;
917 last_arrow_string
= Voverlay_arrow_string
;
921 /* t is unequal to any useful value of Voverlay_arrow_... */
922 last_arrow_position
= Qt
;
923 last_arrow_string
= Qt
;
927 /* Update the menu bar item lists for WINDOW
928 and its subwindows and siblings.
929 This has to be done before we start to fill in any display lines,
930 because it can call eval. */
933 update_menu_bars (window
)
936 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
937 update_menu_bar (window
);
940 /* Update the menu bar item list for window WINDOW and its subwindows. */
943 update_menu_bar (window
)
946 register struct window
*w
= XWINDOW (window
);
947 struct buffer
*old
= current_buffer
;
948 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
950 /* If this is a combination window, do its children; that's all. */
952 if (!NILP (w
->vchild
))
954 update_menu_bars (w
->vchild
);
957 if (!NILP (w
->hchild
))
959 update_menu_bars (w
->hchild
);
962 if (NILP (w
->buffer
))
965 if (update_mode_lines
)
966 w
->update_mode_line
= Qt
;
968 /* When we reach a frame's selected window, redo the frame's menu bar. */
969 if (!NILP (w
->update_mode_line
)
971 && FRAME_EXTERNAL_MENU_BAR (f
)
973 && FRAME_MENU_BAR_LINES (f
) > 0
975 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
977 /* If the user has switched buffers or windows, we need to
978 recompute to reflect the new bindings. But we'll
979 recompute when update_mode_lines is set too; that means
980 that people can use force-mode-line-update to request
981 that the menu bar be recomputed. The adverse effect on
982 the rest of the redisplay algorithm is about the same as
983 windows_or_buffers_changed anyway. */
984 if (windows_or_buffers_changed
986 || (XFASTINT (w
->last_modified
) < MODIFF
987 && (XFASTINT (w
->last_modified
)
988 <= XBUFFER (w
->buffer
)->save_modified
)))
990 struct buffer
*prev
= current_buffer
;
991 current_buffer
= XBUFFER (w
->buffer
);
992 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
993 current_buffer
= prev
;
995 set_frame_menubar (f
, 0);
996 #endif /* USE_X_TOOLKIT */
1003 /* Redisplay WINDOW and its subwindows and siblings. */
1006 redisplay_windows (window
)
1009 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1010 redisplay_window (window
, 0);
1013 /* Redisplay window WINDOW and its subwindows. */
1016 redisplay_window (window
, just_this_one
)
1020 register struct window
*w
= XWINDOW (window
);
1021 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1023 register int lpoint
= point
;
1024 struct buffer
*old
= current_buffer
;
1025 register int width
= window_internal_width (w
) - 1;
1026 register int startp
;
1027 register int hscroll
= XINT (w
->hscroll
);
1028 struct position pos
;
1031 int window_needs_modeline
;
1033 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1035 /* If this is a combination window, do its children; that's all. */
1037 if (!NILP (w
->vchild
))
1039 redisplay_windows (w
->vchild
);
1042 if (!NILP (w
->hchild
))
1044 redisplay_windows (w
->hchild
);
1047 if (NILP (w
->buffer
))
1050 height
= window_internal_height (w
);
1052 if (MINI_WINDOW_P (w
))
1054 if (w
== XWINDOW (minibuf_window
))
1056 if (echo_area_glyphs
)
1057 /* We've already displayed the echo area glyphs, if any. */
1058 goto finish_scroll_bars
;
1062 /* This is a minibuffer, but it's not the currently active one, so
1064 int vpos
= XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f
))->top
);
1067 for (i
= 0; i
< height
; i
++)
1069 get_display_line (f
, vpos
+ i
, 0);
1070 display_string (w
, vpos
+ i
, "", 0, 0, 0, 1, 0, width
);
1073 goto finish_scroll_bars
;
1077 if (update_mode_lines
)
1078 w
->update_mode_line
= Qt
;
1080 /* Otherwise set up data on this window; select its buffer and point value */
1082 current_buffer
= XBUFFER (w
->buffer
);
1085 /* Count number of windows showing the selected buffer. */
1088 && current_buffer
== XBUFFER (XWINDOW (selected_window
)->buffer
))
1091 /* POINT refers normally to the selected window.
1092 For any other window, set up appropriate value. */
1094 if (!EQ (window
, selected_window
))
1096 SET_PT (marker_position (w
->pointm
));
1100 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1102 else if (point
> (ZV
- 1))
1105 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1109 /* If window-start is screwed up, choose a new one. */
1110 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1113 startp
= marker_position (w
->start
);
1115 /* Handle case where place to start displaying has been specified,
1116 unless the specified location is outside the accessible range. */
1117 if (!NILP (w
->force_start
))
1119 /* Forget any recorded base line for line number display. */
1120 w
->base_line_number
= Qnil
;
1121 w
->update_mode_line
= Qt
;
1122 w
->force_start
= Qnil
;
1123 XFASTINT (w
->last_modified
) = 0;
1124 if (startp
< BEGV
) startp
= BEGV
;
1125 if (startp
> ZV
) startp
= ZV
;
1126 try_window (window
, startp
);
1127 if (cursor_vpos
< 0)
1129 /* ??? What should happen here if highlighting a region? */
1130 /* If point does not appear, move point so it does appear */
1131 pos
= *compute_motion (startp
, 0,
1132 ((EQ (window
, minibuf_window
) && startp
== 1)
1133 ? minibuf_prompt_width
: 0)
1135 (hscroll
? 1 - hscroll
: 0),
1137 - (1 << (SHORTBITS
- 1)),
1138 width
, hscroll
, pos_tab_offset (w
, startp
));
1139 SET_PT (pos
.bufpos
);
1140 if (w
!= XWINDOW (selected_window
))
1141 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1144 if (current_buffer
== old
)
1146 FRAME_CURSOR_X (f
) = max (0, pos
.hpos
) + XFASTINT (w
->left
);
1147 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1153 /* Handle case where text has not changed, only point,
1154 and it has not moved off the frame */
1156 /* This code is not used for minibuffer for the sake of
1157 the case of redisplaying to replace an echo area message;
1158 since in that case the minibuffer contents per se are usually unchanged.
1159 This code is of no real use in the minibuffer since
1160 the handling of this_line_bufpos, etc.,
1161 in redisplay handles the same cases. */
1163 if (XFASTINT (w
->last_modified
) >= MODIFF
1164 && point
>= startp
&& !clip_changed
1165 && (just_this_one
|| XFASTINT (w
->width
) == FRAME_WIDTH (f
))
1166 /* Can't use this case if highlighting a region. */
1167 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
1168 && NILP (w
->region_showing
)
1169 && !EQ (window
, minibuf_window
))
1171 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0),
1172 point
, height
+ 1, 10000, width
, hscroll
,
1173 pos_tab_offset (w
, startp
));
1175 if (pos
.vpos
< height
)
1177 /* Ok, point is still on frame */
1178 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
1180 /* These variables are supposed to be origin 1 */
1181 FRAME_CURSOR_X (f
) = max (0, pos
.hpos
) + XFASTINT (w
->left
);
1182 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1184 /* This doesn't do the trick, because if a window to the right of
1185 this one must be redisplayed, this does nothing because there
1186 is nothing in DesiredFrame yet, and then the other window is
1187 redisplayed, making likes that are empty in this window's columns.
1188 if (XFASTINT (w->width) != FRAME_WIDTH (f))
1189 preserve_my_columns (w);
1193 /* Don't bother trying redisplay with same start;
1194 we already know it will lose */
1196 /* If current starting point was originally the beginning of a line
1197 but no longer is, find a new starting point. */
1198 else if (!NILP (w
->start_at_line_beg
)
1200 || FETCH_CHAR (startp
- 1) == '\n'))
1204 else if (just_this_one
&& !MINI_WINDOW_P (w
)
1206 && XFASTINT (w
->last_modified
)
1207 /* or else vmotion on first line won't work. */
1208 && ! NILP (w
->start_at_line_beg
)
1209 && ! EQ (w
->window_end_valid
, Qnil
)
1210 && do_id
&& !clip_changed
1211 && !blank_end_of_window
1212 && XFASTINT (w
->width
) == FRAME_WIDTH (f
)
1213 /* Can't use this case if highlighting a region. */
1214 && !(!NILP (Vtransient_mark_mode
)
1215 && !NILP (current_buffer
->mark_active
))
1216 && NILP (w
->region_showing
)
1217 && EQ (last_arrow_position
, Voverlay_arrow_position
)
1218 && EQ (last_arrow_string
, Voverlay_arrow_string
)
1219 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
1222 /* tem > 0 means success. tem == -1 means choose new start.
1223 tem == -2 means try again with same start,
1224 and nothing but whitespace follows the changed stuff.
1225 tem == 0 means try again with same start. */
1229 else if (startp
>= BEGV
&& startp
<= ZV
1230 /* Avoid starting display at end of buffer! */
1231 && (startp
< ZV
|| startp
== BEGV
1232 || (XFASTINT (w
->last_modified
) >= MODIFF
)))
1234 /* Try to redisplay starting at same place as before */
1235 /* If point has not moved off frame, accept the results */
1236 try_window (window
, startp
);
1237 if (cursor_vpos
>= 0)
1239 if (!just_this_one
|| clip_changed
|| beg_unchanged
< startp
)
1240 /* Forget any recorded base line for line number display. */
1241 w
->base_line_number
= Qnil
;
1245 cancel_my_columns (w
);
1248 XFASTINT (w
->last_modified
) = 0;
1249 w
->update_mode_line
= Qt
;
1251 /* Try to scroll by specified few lines */
1253 if (scroll_step
&& !clip_changed
)
1257 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
),
1258 scroll_step
, width
, hscroll
, window
);
1259 if (pos
.vpos
>= height
)
1263 pos
= *vmotion (startp
, point
< startp
? - scroll_step
: scroll_step
,
1264 width
, hscroll
, window
);
1266 if (point
>= pos
.bufpos
)
1268 try_window (window
, pos
.bufpos
);
1269 if (cursor_vpos
>= 0)
1271 if (!just_this_one
|| clip_changed
|| beg_unchanged
< startp
)
1272 /* Forget any recorded base line for line number display. */
1273 w
->base_line_number
= Qnil
;
1277 cancel_my_columns (w
);
1282 /* Finally, just choose place to start which centers point */
1285 /* Forget any previously recorded base line for line number display. */
1286 w
->base_line_number
= Qnil
;
1288 pos
= *vmotion (point
, - (height
/ 2), width
, hscroll
, window
);
1289 try_window (window
, pos
.bufpos
);
1291 startp
= marker_position (w
->start
);
1292 w
->start_at_line_beg
=
1293 (startp
== BEGV
|| FETCH_CHAR (startp
- 1) == '\n') ? Qt
: Qnil
;
1296 if ((!NILP (w
->update_mode_line
)
1297 /* If window not full width, must redo its mode line
1298 if the window to its side is being redone */
1299 || (!just_this_one
&& width
< FRAME_WIDTH (f
) - 1)
1300 || INTEGERP (w
->base_line_pos
))
1301 && height
!= XFASTINT (w
->height
))
1302 display_mode_line (w
);
1303 if (! line_number_displayed
1304 && ! BUFFERP (w
->base_line_pos
))
1306 w
->base_line_pos
= Qnil
;
1307 w
->base_line_number
= Qnil
;
1310 /* When we reach a frame's selected window, redo the frame's menu bar. */
1311 if (!NILP (w
->update_mode_line
)
1312 #ifdef USE_X_TOOLKIT
1313 && FRAME_EXTERNAL_MENU_BAR (f
)
1315 && FRAME_MENU_BAR_LINES (f
) > 0
1317 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
1318 display_menu_bar (w
);
1321 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1323 int start
, end
, whole
;
1325 /* Calculate the start and end positions for the current window.
1326 At some point, it would be nice to choose between scrollbars
1327 which reflect the whole buffer size, with special markers
1328 indicating narrowing, and scrollbars which reflect only the
1331 Note that minibuffers sometimes aren't displaying any text. */
1332 if (! MINI_WINDOW_P (w
)
1333 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
1336 start
= startp
- BEGV
;
1337 /* I don't think this is guaranteed to be right. For the
1338 moment, we'll pretend it is. */
1339 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
1341 if (end
< start
) end
= start
;
1342 if (whole
< (end
- start
)) whole
= end
- start
;
1345 start
= end
= whole
= 0;
1347 /* Indicate what this scroll bar ought to be displaying now. */
1348 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
1350 /* Note that we actually used the scroll bar attached to this window,
1351 so it shouldn't be deleted at the end of redisplay. */
1352 (*redeem_scroll_bar_hook
) (w
);
1356 current_buffer
= old
;
1360 /* Do full redisplay on one window, starting at position `pos'. */
1363 try_window (window
, pos
)
1367 register struct window
*w
= XWINDOW (window
);
1368 register int height
= window_internal_height (w
);
1369 register int vpos
= XFASTINT (w
->top
);
1370 register int last_text_vpos
= vpos
;
1371 int tab_offset
= pos_tab_offset (w
, pos
);
1372 FRAME_PTR f
= XFRAME (w
->frame
);
1373 int width
= window_internal_width (w
) - 1;
1374 struct position val
;
1376 Fset_marker (w
->start
, make_number (pos
), Qnil
);
1378 overlay_arrow_seen
= 0;
1379 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
1381 while (--height
>= 0)
1383 val
= *display_text_line (w
, pos
, vpos
, val
.hpos
, tab_offset
);
1384 tab_offset
+= width
;
1385 if (val
.vpos
) tab_offset
= 0;
1387 if (pos
!= val
.bufpos
)
1389 /* Next line, unless prev line ended in end of buffer with no cr */
1390 = vpos
- (val
.vpos
&& (FETCH_CHAR (val
.bufpos
- 1) != '\n'
1391 #ifdef USE_TEXT_PROPERTIES
1392 || ! NILP (Fget_char_property (val
.bufpos
-1,
1400 /* If last line is continued in middle of character,
1401 include the split character in the text considered on the frame */
1402 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
1405 /* If bottom just moved off end of frame, change mode line percentage. */
1406 if (XFASTINT (w
->window_end_pos
) == 0
1408 w
->update_mode_line
= Qt
;
1410 /* Say where last char on frame will be, once redisplay is finished. */
1411 XFASTINT (w
->window_end_pos
) = Z
- pos
;
1412 XFASTINT (w
->window_end_vpos
) = last_text_vpos
- XFASTINT (w
->top
);
1413 /* But that is not valid info until redisplay finishes. */
1414 w
->window_end_valid
= Qnil
;
1417 /* Try to redisplay when buffer is modified locally,
1418 computing insert/delete line to preserve text outside
1419 the bounds of the changes.
1420 Return 1 if successful, 0 if if cannot tell what to do,
1421 or -1 to tell caller to find a new window start,
1422 or -2 to tell caller to do normal redisplay with same window start. */
1425 try_window_id (window
)
1429 register struct window
*w
= XWINDOW (window
);
1430 register int height
= window_internal_height (w
);
1431 FRAME_PTR f
= XFRAME (w
->frame
);
1432 int top
= XFASTINT (w
->top
);
1433 int start
= marker_position (w
->start
);
1434 int width
= window_internal_width (w
) - 1;
1435 int hscroll
= XINT (w
->hscroll
);
1436 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
1438 register int i
, tem
;
1439 int last_text_vpos
= 0;
1442 = XTYPE (current_buffer
->selective_display
) == Lisp_Int
1443 ? XINT (current_buffer
->selective_display
)
1444 : !NILP (current_buffer
->selective_display
) ? -1 : 0;
1446 struct position val
, bp
, ep
, xp
, pp
;
1447 int scroll_amount
= 0;
1449 int tab_offset
, epto
;
1451 if (GPT
- BEG
< beg_unchanged
)
1452 beg_unchanged
= GPT
- BEG
;
1453 if (Z
- GPT
< end_unchanged
)
1454 end_unchanged
= Z
- GPT
;
1456 if (beg_unchanged
+ BEG
< start
)
1457 return 0; /* Give up if changes go above top of window */
1459 /* Find position before which nothing is changed. */
1460 bp
= *compute_motion (start
, 0, lmargin
,
1461 min (ZV
, beg_unchanged
+ BEG
), height
+ 1, 0,
1462 width
, hscroll
, pos_tab_offset (w
, start
));
1463 if (bp
.vpos
>= height
)
1465 if (point
< bp
.bufpos
&& !bp
.contin
)
1467 /* All changes are below the frame, and point is on the frame.
1468 We don't need to change the frame at all.
1469 But we need to update window_end_pos to account for
1470 any change in buffer size. */
1471 bp
= *compute_motion (start
, 0, lmargin
,
1473 width
, hscroll
, pos_tab_offset (w
, start
));
1474 XFASTINT (w
->window_end_vpos
) = height
;
1475 XFASTINT (w
->window_end_pos
) = Z
- bp
.bufpos
;
1483 /* Find beginning of that frame line. Must display from there. */
1484 bp
= *vmotion (bp
.bufpos
, 0, width
, hscroll
, window
);
1491 /* If about to start displaying at the beginning of a continuation line,
1492 really start with previous frame line, in case it was not
1493 continued when last redisplayed */
1494 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
1496 /* Likewise if we have to worry about selective display. */
1497 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
1499 bp
= *vmotion (bp
.bufpos
, -1, width
, hscroll
, window
);
1504 if (bp
.contin
&& bp
.hpos
!= lmargin
)
1506 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
1512 /* Find first visible newline after which no more is changed. */
1513 tem
= find_next_newline (Z
- max (end_unchanged
, Z
- ZV
), 1);
1515 while (tem
< ZV
- 1 && (indented_beyond_p (tem
, selective
)))
1516 tem
= find_next_newline (tem
, 1);
1518 /* Compute the cursor position after that newline. */
1519 ep
= *compute_motion (pos
, vpos
, val
.hpos
, tem
,
1520 height
, - (1 << (SHORTBITS
- 1)),
1521 width
, hscroll
, pos_tab_offset (w
, bp
.bufpos
));
1523 /* If changes reach past the text available on the frame,
1524 just display rest of frame. */
1525 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
1528 stop_vpos
= ep
.vpos
;
1530 /* If no newline before ep, the line ep is on includes some changes
1531 that must be displayed. Make sure we don't stop before it. */
1532 /* Also, if changes reach all the way until ep.bufpos,
1533 it is possible that something was deleted after the
1534 newline before it, so the following line must be redrawn. */
1535 if (stop_vpos
== ep
.vpos
1536 && (ep
.bufpos
== BEGV
1537 || FETCH_CHAR (ep
.bufpos
- 1) != '\n'
1538 || ep
.bufpos
== Z
- end_unchanged
))
1539 stop_vpos
= ep
.vpos
+ 1;
1542 overlay_arrow_seen
= 0;
1544 /* If changes do not reach to bottom of window,
1545 figure out how much to scroll the rest of the window */
1546 if (stop_vpos
< height
)
1548 /* Now determine how far up or down the rest of the window has moved */
1549 epto
= pos_tab_offset (w
, ep
.bufpos
);
1550 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
,
1551 Z
- XFASTINT (w
->window_end_pos
),
1552 10000, 0, width
, hscroll
, epto
);
1553 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
1555 /* Is everything on frame below the changes whitespace?
1556 If so, no scrolling is really necessary. */
1557 for (i
= ep
.bufpos
; i
< xp
.bufpos
; i
++)
1559 tem
= FETCH_CHAR (i
);
1560 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
1566 XFASTINT (w
->window_end_vpos
) += scroll_amount
;
1568 /* Before doing any scrolling, verify that point will be on frame. */
1569 if (point
> ep
.bufpos
&& !(point
<= xp
.bufpos
&& xp
.bufpos
< height
))
1571 if (point
<= xp
.bufpos
)
1573 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
,
1574 point
, height
, - (1 << (SHORTBITS
- 1)),
1575 width
, hscroll
, epto
);
1579 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
,
1580 point
, height
, - (1 << (SHORTBITS
- 1)),
1581 width
, hscroll
, pos_tab_offset (w
, xp
.bufpos
));
1583 if (pp
.bufpos
< point
|| pp
.vpos
== height
)
1585 cursor_vpos
= pp
.vpos
+ top
;
1586 cursor_hpos
= pp
.hpos
+ XFASTINT (w
->left
);
1589 if (stop_vpos
- scroll_amount
>= height
1590 || ep
.bufpos
== xp
.bufpos
)
1592 if (scroll_amount
< 0)
1593 stop_vpos
-= scroll_amount
;
1595 /* In this path, we have altered window_end_vpos
1596 and not left it negative.
1597 We must make sure that, in case display is preempted
1598 before the frame changes to reflect what we do here,
1599 further updates will not come to try_window_id
1600 and assume the frame and window_end_vpos match. */
1601 blank_end_of_window
= 1;
1603 else if (!scroll_amount
)
1605 else if (bp
.bufpos
== Z
- end_unchanged
)
1607 /* If reprinting everything is nearly as fast as scrolling,
1608 don't bother scrolling. Can happen if lines are short. */
1609 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
1610 top
+ height
- max (0, scroll_amount
),
1612 > xp
.bufpos
- bp
.bufpos
- 20)
1613 /* Return "try normal display with same window-start."
1614 Too bad we can't prevent further scroll-thinking. */
1616 /* If pure deletion, scroll up as many lines as possible.
1617 In common case of killing a line, this can save the
1618 following line from being overwritten by scrolling
1619 and therefore having to be redrawn. */
1620 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
1621 top
+ height
- max (0, scroll_amount
),
1622 scroll_amount
, bp
.bufpos
);
1623 if (!tem
) stop_vpos
= height
;
1625 else if (scroll_amount
)
1627 /* If reprinting everything is nearly as fast as scrolling,
1628 don't bother scrolling. Can happen if lines are short. */
1629 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
1630 overestimate of cost of reprinting, since xp.bufpos
1631 would end up below the bottom of the window. */
1632 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
1633 top
+ height
- max (0, scroll_amount
),
1635 > xp
.bufpos
- ep
.bufpos
- 20)
1636 /* Return "try normal display with same window-start."
1637 Too bad we can't prevent further scroll-thinking. */
1639 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
1640 top
+ height
- max (0, scroll_amount
),
1641 scroll_amount
, ep
.bufpos
);
1642 if (!tem
) stop_vpos
= height
;
1646 /* In any case, do not display past bottom of window */
1647 if (stop_vpos
>= height
)
1653 /* Handle case where pos is before w->start --
1654 can happen if part of line had been clipped and is not clipped now */
1655 if (vpos
== 0 && pos
< marker_position (w
->start
))
1656 Fset_marker (w
->start
, make_number (pos
), Qnil
);
1658 /* Redisplay the lines where the text was changed */
1659 last_text_vpos
= vpos
;
1660 tab_offset
= pos_tab_offset (w
, pos
);
1661 /* If we are starting display in mid-character, correct tab_offset
1662 to account for passing the line that that character really starts in. */
1663 if (val
.hpos
< lmargin
)
1664 tab_offset
+= width
;
1665 while (vpos
< stop_vpos
)
1667 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
1668 tab_offset
+= width
;
1669 if (val
.vpos
) tab_offset
= 0;
1670 if (pos
!= val
.bufpos
)
1672 /* Next line, unless prev line ended in end of buffer with no cr */
1673 = vpos
- (val
.vpos
&& FETCH_CHAR (val
.bufpos
- 1) != '\n');
1677 /* There are two cases:
1678 1) we have displayed down to the bottom of the window
1679 2) we have scrolled lines below stop_vpos by scroll_amount */
1683 /* If last line is continued in middle of character,
1684 include the split character in the text considered on the frame */
1685 if (val
.hpos
< lmargin
)
1687 XFASTINT (w
->window_end_vpos
) = last_text_vpos
;
1688 XFASTINT (w
->window_end_pos
) = Z
- val
.bufpos
;
1691 /* If scrolling made blank lines at window bottom,
1692 redisplay to fill those lines */
1693 if (scroll_amount
< 0)
1695 /* Don't consider these lines for general-purpose scrolling.
1696 That will save time in the scrolling computation. */
1697 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
1702 vpos
= height
+ scroll_amount
;
1703 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
1705 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
1709 blank_end_of_window
= 1;
1710 tab_offset
= pos_tab_offset (w
, pos
);
1711 /* If we are starting display in mid-character, correct tab_offset
1712 to account for passing the line that that character starts in. */
1713 if (val
.hpos
< lmargin
)
1714 tab_offset
+= width
;
1716 while (vpos
< height
)
1718 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
1719 tab_offset
+= width
;
1720 if (val
.vpos
) tab_offset
= 0;
1724 /* Here is a case where display_text_line sets cursor_vpos wrong.
1725 Make it be fixed up, below. */
1727 && xp
.bufpos
== point
)
1731 /* If bottom just moved off end of frame, change mode line percentage. */
1732 if (XFASTINT (w
->window_end_pos
) == 0
1734 w
->update_mode_line
= Qt
;
1736 /* Attempt to adjust end-of-text positions to new bottom line */
1739 delta
= height
- xp
.vpos
;
1741 || (delta
> 0 && xp
.bufpos
<= ZV
)
1742 || (delta
== 0 && xp
.hpos
))
1744 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
),
1745 delta
, width
, hscroll
, window
);
1746 XFASTINT (w
->window_end_pos
) = Z
- val
.bufpos
;
1747 XFASTINT (w
->window_end_vpos
) += val
.vpos
;
1751 w
->window_end_valid
= Qnil
;
1753 /* If point was not in a line that was displayed, find it */
1754 if (cursor_vpos
< 0)
1756 val
= *compute_motion (start
, 0, lmargin
, point
, 10000, 10000,
1757 width
, hscroll
, pos_tab_offset (w
, start
));
1758 /* Admit failure if point is off frame now */
1759 if (val
.vpos
>= height
)
1761 for (vpos
= 0; vpos
< height
; vpos
++)
1762 cancel_line (vpos
+ top
, f
);
1765 cursor_vpos
= val
.vpos
+ top
;
1766 cursor_hpos
= val
.hpos
+ XFASTINT (w
->left
);
1769 FRAME_CURSOR_X (f
) = max (0, cursor_hpos
);
1770 FRAME_CURSOR_Y (f
) = cursor_vpos
;
1774 val
= *compute_motion (start
, 0, lmargin
, ZV
,
1775 height
, - (1 << (SHORTBITS
- 1)),
1776 width
, hscroll
, pos_tab_offset (w
, start
));
1777 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
1779 if (XFASTINT (w
->window_end_pos
)
1787 /* Mark a section of BUF as modified, but only for the sake of redisplay.
1788 This is useful for recording changes to overlays.
1790 We increment the buffer's modification timestamp and set the
1791 redisplay caches (windows_or_buffers_changed, beg_unchanged, etc)
1792 as if the region of text between START and END had been modified;
1793 the redisplay code will check this against the windows' timestamps,
1794 and redraw the appropriate area of the buffer.
1796 However, if the buffer is unmodified, we bump the last-save
1797 timestamp as well, so that incrementing the timestamp doesn't fool
1798 Emacs into thinking that the buffer's text has been modified.
1800 Tweaking the timestamps shouldn't hurt the first-modification
1801 timestamps recorded in the undo records; those values aren't
1802 written until just before a real text modification is made, so they
1803 will never catch the timestamp value just before this function gets
1807 redisplay_region (buf
, start
, end
)
1817 start
= end
; end
= temp
;
1820 if (buf
!= current_buffer
)
1821 windows_or_buffers_changed
= 1;
1824 if (unchanged_modified
== MODIFF
)
1826 beg_unchanged
= start
- BEG
;
1827 end_unchanged
= Z
- end
;
1831 if (Z
- end
< end_unchanged
)
1832 end_unchanged
= Z
- end
;
1833 if (start
- BEG
< beg_unchanged
)
1834 beg_unchanged
= start
- BEG
;
1838 /* Increment the buffer's time stamp, but also increment the save
1839 and autosave timestamps, so as not to screw up that timekeeping. */
1840 if (BUF_MODIFF (buf
) == buf
->save_modified
)
1841 buf
->save_modified
++;
1842 if (BUF_MODIFF (buf
) == buf
->auto_save_modified
)
1843 buf
->auto_save_modified
++;
1845 BUF_MODIFF (buf
) ++;
1849 /* Copy LEN glyphs starting address FROM to the rope TO.
1850 But don't actually copy the parts that would come in before S.
1851 Value is TO, advanced past the copied data.
1852 F is the frame we are displaying in. */
1855 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
1857 register GLYPH
*to
; /* Copy to here. */
1858 register GLYPH
*s
; /* Starting point. */
1859 Lisp_Object
*from
; /* Data to copy. */
1861 int face
; /* Face to apply to glyphs which don't specify one. */
1864 register Lisp_Object
*fp
= from
;
1865 /* These cache the results of the last call to compute_glyph_face. */
1867 int last_merged
= 0;
1869 #ifdef HAVE_X_WINDOWS
1870 if (! FRAME_TERMCAP_P (f
))
1873 int glyph
= XFASTINT (*fp
);
1876 if (FAST_GLYPH_FACE (glyph
) == 0)
1877 /* If GLYPH has no face code, use FACE. */
1879 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
1880 /* If it's same as previous glyph, use same result. */
1881 facecode
= last_merged
;
1884 /* Merge this glyph's face and remember the result. */
1885 last_code
= FAST_GLYPH_FACE (glyph
);
1886 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
1890 *to
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), facecode
);
1898 if (to
>= s
) *to
= XFASTINT (*fp
);
1905 /* Correct a glyph by replacing its specified user-level face code
1906 with a displayable computed face code. */
1909 fix_glyph (f
, glyph
, current_face
)
1914 #ifdef HAVE_X_WINDOWS
1915 if (! FRAME_TERMCAP_P (f
) && FAST_GLYPH_FACE (glyph
) != 0)
1916 return FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
),
1917 compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
),
1923 /* Display one line of window w, starting at position START in W's buffer.
1924 Display starting at horizontal position HPOS, which is normally zero
1925 or negative. A negative value causes output up to hpos = 0 to be discarded.
1926 This is done for negative hscroll, or when this is a continuation line
1927 and the continuation occurred in the middle of a multi-column character.
1929 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
1931 Display on position VPOS on the frame. (origin 0).
1933 Returns a STRUCT POSITION giving character to start next line with
1934 and where to display it, including a zero or negative hpos.
1935 The vpos field is not really a vpos; it is 1 unless the line is continued */
1937 struct position val_display_text_line
;
1939 static struct position
*
1940 display_text_line (w
, start
, vpos
, hpos
, taboffset
)
1947 register int pos
= start
;
1952 register unsigned char *p
;
1954 register GLYPH
*startp
;
1955 register GLYPH
*p1prev
= 0;
1956 register GLYPH
*p1start
;
1958 FRAME_PTR f
= XFRAME (w
->frame
);
1959 int tab_width
= XINT (current_buffer
->tab_width
);
1960 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
1961 int width
= window_internal_width (w
) - 1;
1962 struct position val
;
1965 int hscroll
= XINT (w
->hscroll
);
1966 int truncate
= hscroll
1967 || (truncate_partial_width_windows
1968 && XFASTINT (w
->width
) < FRAME_WIDTH (f
))
1969 || !NILP (current_buffer
->truncate_lines
);
1971 /* 1 if we should highlight the region. */
1972 int highlight_region
1973 = !NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
);
1974 int region_beg
, region_end
;
1977 = XTYPE (current_buffer
->selective_display
) == Lisp_Int
1978 ? XINT (current_buffer
->selective_display
)
1979 : !NILP (current_buffer
->selective_display
) ? -1 : 0;
1980 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
1981 register struct Lisp_Vector
*dp
= window_display_table (w
);
1983 Lisp_Object default_invis_vector
[3];
1984 /* Nonzero means display something where there are invisible lines.
1985 The precise value is the number of glyphs to display. */
1987 = (selective
&& dp
&& XTYPE (DISP_INVIS_VECTOR (dp
)) == Lisp_Vector
1988 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
1989 : selective
&& !NILP (current_buffer
->selective_display_ellipses
)
1991 /* This is the sequence of Lisp objects to display
1992 when there are invisible lines. */
1993 Lisp_Object
*invis_vector_contents
1994 = (dp
&& XTYPE (DISP_INVIS_VECTOR (dp
)) == Lisp_Vector
1995 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
1996 : default_invis_vector
);
1998 GLYPH truncator
= (dp
== 0 || XTYPE (DISP_TRUNC_GLYPH (dp
)) != Lisp_Int
1999 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
2000 GLYPH continuer
= (dp
== 0 || XTYPE (DISP_CONTINUE_GLYPH (dp
)) != Lisp_Int
2001 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
2003 /* The next buffer location at which the face should change, due
2004 to overlays or text property changes. */
2005 int next_face_change
;
2007 #ifdef USE_TEXT_PROPERTIES
2008 /* The next location where the `invisible' property changes */
2012 /* The face we're currently using. */
2013 int current_face
= 0;
2016 XFASTINT (default_invis_vector
[2]) = '.';
2017 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
2019 hpos
+= XFASTINT (w
->left
);
2020 get_display_line (f
, vpos
, XFASTINT (w
->left
));
2021 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
2023 /* Show where to highlight the region. */
2024 if (highlight_region
&& XMARKER (current_buffer
->mark
)->buffer
!= 0
2025 /* Maybe highlight only in selected window. */
2026 && (highlight_nonselected_windows
2027 || w
== XWINDOW (selected_window
)))
2029 region_beg
= marker_position (current_buffer
->mark
);
2030 if (PT
< region_beg
)
2032 region_end
= region_beg
;
2037 w
->region_showing
= Qt
;
2040 region_beg
= region_end
= -1;
2042 if (MINI_WINDOW_P (w
) && start
== 1
2043 && vpos
== XFASTINT (w
->top
))
2046 hpos
= display_string (w
, vpos
, minibuf_prompt
, -1, hpos
,
2047 (!truncate
? continuer
: truncator
),
2049 minibuf_prompt_width
= hpos
;
2052 desired_glyphs
->bufp
[vpos
] = pos
;
2053 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
2055 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
2056 /* In case we don't ever write anything into it... */
2059 startp
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
2060 endp
= startp
+ width
;
2062 /* Arrange the overlays nicely for our purposes. Usually, we call
2063 display_text_line on only one line at a time, in which case this
2064 can't really hurt too much, or we call it on lines which appear
2065 one after another in the buffer, in which case all calls to
2066 recenter_overlay_lists but the first will be pretty cheap. */
2067 recenter_overlay_lists (current_buffer
, pos
);
2069 /* Loop generating characters.
2070 Stop at end of buffer, before newline,
2071 if reach or pass continuation column,
2072 or at face change. */
2074 next_face_change
= pos
;
2075 #ifdef USE_TEXT_PROPERTIES
2076 next_invisible
= pos
;
2080 /* Record which glyph starts a character,
2081 and the character position of that character. */
2082 charstart
[p1
- p1start
] = pos
;
2090 /* Did we hit the end of the visible region of the buffer?
2095 /* Did we reach point? Record the cursor location. */
2096 if (pos
== point
&& cursor_vpos
< 0)
2099 cursor_hpos
= p1
- startp
;
2102 #ifdef USE_TEXT_PROPERTIES
2103 /* if the `invisible' property is set to t, we can skip to
2104 the next property change */
2105 while (pos
== next_invisible
&& pos
< end
)
2107 Lisp_Object position
, limit
, endpos
, prop
, ww
;
2108 XFASTINT (position
) = pos
;
2109 XSET (ww
, Lisp_Window
, w
);
2110 prop
= Fget_char_property (position
, Qinvisible
, ww
);
2111 /* This is just an estimate to give reasonable
2112 performance; nothing should go wrong if it is too small. */
2113 limit
= Fnext_overlay_change (position
);
2114 if (XFASTINT (limit
) > pos
+ 50)
2115 XFASTINT (limit
) = pos
+ 50;
2116 endpos
= Fnext_single_property_change (position
, Qinvisible
,
2117 Fcurrent_buffer (), limit
);
2118 if (INTEGERP (endpos
))
2119 next_invisible
= XINT (endpos
);
2121 next_invisible
= end
;
2124 if (pos
< point
&& next_invisible
>= point
)
2127 cursor_hpos
= p1
- startp
;
2129 pos
= next_invisible
;
2136 #ifdef HAVE_X_WINDOWS
2137 /* Did we hit a face change? Figure out what face we should
2138 use now. We also hit this the first time through the
2139 loop, to see what face we should start with. */
2140 if (pos
>= next_face_change
&& FRAME_X_P (f
))
2141 current_face
= compute_char_face (f
, w
, pos
,
2142 region_beg
, region_end
,
2143 &next_face_change
, pos
+ 50, 0);
2148 #ifdef USE_TEXT_PROPERTIES
2149 if (pos
< next_invisible
&& next_invisible
< pause
)
2150 pause
= next_invisible
;
2152 if (pos
< next_face_change
&& next_face_change
< pause
)
2153 pause
= next_face_change
;
2155 /* Wouldn't you hate to read the next line to someone over
2157 if (pos
< point
&& point
< pause
)
2159 if (pos
< GPT
&& GPT
< pause
)
2162 p
= &FETCH_CHAR (pos
);
2165 if (c
>= 040 && c
< 0177
2166 && (dp
== 0 || XTYPE (DISP_CHAR_VECTOR (dp
, c
)) != Lisp_Vector
))
2169 *p1
= MAKE_GLYPH (f
, c
, current_face
);
2177 && indented_beyond_p (pos
+ 1, selective
))
2180 pos
= find_next_newline (pos
+ 1, 1);
2181 if (FETCH_CHAR (pos
- 1) == '\n')
2184 if (invis
&& selective_rlen
> 0 && p1
>= startp
)
2186 p1
+= selective_rlen
;
2187 if (p1
- startp
> width
)
2189 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2190 (p1
- p1prev
), current_face
);
2192 #ifdef HAVE_X_WINDOWS
2193 /* Draw the face of the newline character as extending all the
2194 way to the end of the frame line. */
2197 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2205 if (p1
>= startp
&& p1
< endp
)
2206 *p1
= MAKE_GLYPH (f
, ' ', current_face
);
2209 while ((p1
- startp
+ taboffset
+ hscroll
- (hscroll
> 0))
2212 else if (c
== Ctl ('M') && selective
== -1)
2214 pos
= find_next_newline (pos
, 1);
2215 if (FETCH_CHAR (pos
- 1) == '\n')
2217 if (selective_rlen
> 0)
2219 p1
+= selective_rlen
;
2220 if (p1
- startp
> width
)
2222 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2223 (p1
- p1prev
), current_face
);
2225 #ifdef HAVE_X_WINDOWS
2226 /* Draw the face of the newline character as extending all the
2227 way to the end of the frame line. */
2230 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2234 else if (dp
!= 0 && XTYPE (DISP_CHAR_VECTOR (dp
, c
)) == Lisp_Vector
)
2236 p1
= copy_part_of_rope (f
, p1
, startp
,
2237 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
2238 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
2241 else if (c
< 0200 && ctl_arrow
)
2244 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_CTRL_GLYPH (dp
)) == Lisp_Int
2245 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
2248 if (p1
>= startp
&& p1
< endp
)
2249 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
);
2255 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_ESCAPE_GLYPH (dp
)) == Lisp_Int
2256 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
2259 if (p1
>= startp
&& p1
< endp
)
2260 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
);
2262 if (p1
>= startp
&& p1
< endp
)
2263 *p1
= MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
);
2265 if (p1
>= startp
&& p1
< endp
)
2266 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
);
2270 /* For all the glyphs occupied by this character, except for the
2271 first, store -1 in charstarts. */
2274 int *p2x
= &charstart
[p1prev
- p1start
] + 1;
2275 int *p2
= &charstart
[p1
- p1start
];
2280 /* If this character took up no space,
2281 erase all mention of it from charstart. */
2282 charstart
[p1
- p1start
] = 0;
2286 val
.hpos
= - XINT (w
->hscroll
);
2294 /* Store 0 in this charstart line for the positions where
2295 there is no character. But do leave what was recorded
2296 for the character that ended the line. */
2297 /* Add 1 in the endtest to compensate for the fact that ENDP was
2298 made from WIDTH, which is 1 less than the window's actual
2300 for (i
= p1
- p1start
+ 1; i
< endp
- p1start
+ 1; i
++)
2303 /* Handle continuation in middle of a character */
2304 /* by backing up over it */
2307 /* Don't back up if we never actually displayed any text.
2308 This occurs when the minibuffer prompt takes up the whole line. */
2311 /* Start the next line with that same character */
2313 /* but at negative hpos, to skip the columns output on this line. */
2314 val
.hpos
+= p1prev
- endp
;
2317 /* Keep in this line everything up to the continuation column. */
2321 /* Finish deciding which character to start the next line on,
2322 and what hpos to start it at.
2323 Also set `lastpos' to the last position which counts as "on this line"
2324 for cursor-positioning. */
2328 if (FETCH_CHAR (pos
) == '\n')
2330 /* If stopped due to a newline, start next line after it */
2332 /* Check again for hidden lines, in case the newline occurred exactly
2333 at the right margin. */
2334 while (pos
< ZV
&& selective
> 0
2335 && indented_beyond_p (pos
, selective
))
2336 pos
= find_next_newline (pos
, 1);
2339 /* Stopped due to right margin of window */
2343 *p1
++ = fix_glyph (f
, truncator
, 0);
2344 /* Truncating => start next line after next newline,
2345 and point is on this line if it is before the newline,
2346 and skip none of first char of next line */
2348 pos
= find_next_newline (pos
, 1);
2349 while (pos
< ZV
&& selective
> 0
2350 && indented_beyond_p (pos
, selective
));
2351 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2353 lastpos
= pos
- (FETCH_CHAR (pos
- 1) == '\n');
2357 *p1
++ = fix_glyph (f
, continuer
, 0);
2364 /* If point is at eol or in invisible text at eol,
2365 record its frame location now. */
2367 if (start
<= point
&& point
<= lastpos
&& cursor_vpos
< 0)
2370 cursor_hpos
= p1
- startp
;
2373 if (cursor_vpos
== vpos
)
2375 if (cursor_hpos
< 0) cursor_hpos
= 0;
2376 if (cursor_hpos
> width
) cursor_hpos
= width
;
2377 cursor_hpos
+= XFASTINT (w
->left
);
2378 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2380 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2381 FRAME_CURSOR_X (f
) = cursor_hpos
;
2383 if (w
== XWINDOW (selected_window
))
2385 /* Line is not continued and did not start
2386 in middle of character */
2387 if ((hpos
- XFASTINT (w
->left
)
2388 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2391 this_line_bufpos
= start
;
2392 this_line_buffer
= current_buffer
;
2393 this_line_vpos
= cursor_vpos
;
2394 this_line_start_hpos
= hpos
;
2395 this_line_endpos
= Z
- lastpos
;
2398 this_line_bufpos
= 0;
2403 /* If hscroll and line not empty, insert truncation-at-left marker */
2404 if (hscroll
&& lastpos
!= start
)
2406 *startp
= fix_glyph (f
, truncator
, 0);
2411 if (XFASTINT (w
->width
) + XFASTINT (w
->left
) != FRAME_WIDTH (f
))
2414 if (p1
< startp
) p1
= startp
;
2415 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
2417 /* Don't draw vertical bars if we're using scroll bars. They're
2418 covered up by the scroll bars, and it's distracting to see
2419 them when the scroll bar windows are flickering around to be
2421 *p1
++ = (FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2424 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
2425 p1
- desired_glyphs
->glyphs
[vpos
]);
2426 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
2428 /* If the start of this line is the overlay arrow-position,
2429 then put the arrow string into the display-line. */
2431 if (XTYPE (Voverlay_arrow_position
) == Lisp_Marker
2432 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
2433 && start
== marker_position (Voverlay_arrow_position
)
2434 && XTYPE (Voverlay_arrow_string
) == Lisp_String
2435 && ! overlay_arrow_seen
)
2437 unsigned char *p
= XSTRING (Voverlay_arrow_string
)->data
;
2439 int len
= XSTRING (Voverlay_arrow_string
)->size
;
2444 for (i
= 0; i
< len
; i
++)
2447 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
2448 arrow_end
= (startp
- desired_glyphs
->glyphs
[vpos
]) + len
;
2449 if (desired_glyphs
->used
[vpos
] < arrow_end
)
2450 desired_glyphs
->used
[vpos
] = arrow_end
;
2452 overlay_arrow_seen
= 1;
2456 val_display_text_line
= val
;
2457 return &val_display_text_line
;
2460 /* Redisplay the menu bar in the frame for window W. */
2463 display_menu_bar (w
)
2466 Lisp_Object items
, tail
;
2467 register int vpos
= 0;
2468 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2469 int maxendcol
= FRAME_WIDTH (f
);
2473 #ifndef USE_X_TOOLKIT
2474 if (FRAME_MENU_BAR_LINES (f
) <= 0)
2477 get_display_line (f
, vpos
, 0);
2479 items
= FRAME_MENU_BAR_ITEMS (f
);
2480 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 3)
2482 Lisp_Object pos
, string
;
2483 string
= XVECTOR (items
)->contents
[i
+ 1];
2487 XFASTINT (XVECTOR (items
)->contents
[i
+ 2]) = hpos
;
2489 if (hpos
< maxendcol
)
2490 hpos
= display_string (XWINDOW (FRAME_ROOT_WINDOW (f
)), vpos
,
2491 XSTRING (string
)->data
,
2492 XSTRING (string
)->size
,
2493 hpos
, 0, 0, hpos
, maxendcol
);
2494 /* Put a gap of 3 spaces between items. */
2495 if (hpos
< maxendcol
)
2497 int hpos1
= hpos
+ 3;
2498 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
2499 min (hpos1
, maxendcol
), maxendcol
);
2503 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
2504 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
2506 /* Fill out the line with spaces. */
2507 if (maxendcol
> hpos
)
2508 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
);
2510 /* Clear the rest of the lines allocated to the menu bar. */
2512 while (vpos
< FRAME_MENU_BAR_LINES (f
))
2513 get_display_line (f
, vpos
++, 0);
2514 #endif /* not USE_X_TOOLKIT */
2517 /* Display the mode line for window w */
2520 display_mode_line (w
)
2523 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
2524 register int left
= XFASTINT (w
->left
);
2525 register int right
= XFASTINT (w
->width
) + left
;
2526 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2528 line_number_displayed
= 0;
2530 get_display_line (f
, vpos
, left
);
2531 display_mode_element (w
, vpos
, left
, 0, right
, right
,
2532 current_buffer
->mode_line_format
);
2533 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
2535 /* Make the mode line inverse video if the entire line
2536 is made of mode lines.
2537 I.e. if this window is full width,
2538 or if it is the child of a full width window
2539 (which implies that that window is split side-by-side
2540 and the rest of this line is mode lines of the sibling windows). */
2541 if (XFASTINT (w
->width
) == FRAME_WIDTH (f
)
2542 || XFASTINT (XWINDOW (w
->parent
)->width
) == FRAME_WIDTH (f
))
2543 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
2544 #ifdef HAVE_X_WINDOWS
2545 else if (! FRAME_TERMCAP_P (f
))
2547 /* For a partial width window, explicitly set face of each glyph. */
2549 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
2550 for (i
= left
; i
< right
; ++i
)
2551 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1);
2555 #ifdef HAVE_X_WINDOWS
2556 if (w
== XWINDOW (f
->selected_window
))
2557 x_consider_frame_title (WINDOW_FRAME (w
));
2561 /* Contribute ELT to the mode line for window W.
2562 How it translates into text depends on its data type.
2564 VPOS is the position of the mode line being displayed.
2566 HPOS is the position (absolute on frame) where this element's text
2567 should start. The output is truncated automatically at the right
2570 DEPTH is the depth in recursion. It is used to prevent
2571 infinite recursion here.
2573 MINENDCOL is the hpos before which the element may not end.
2574 The element is padded at the right with spaces if nec
2575 to reach this column.
2577 MAXENDCOL is the hpos past which this element may not extend.
2578 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
2579 (This is necessary to make nested padding and truncation work.)
2581 Returns the hpos of the end of the text generated by ELT.
2582 The next element will receive that value as its HPOS arg,
2583 so as to concatenate the elements. */
2586 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
2588 register int vpos
, hpos
;
2591 register int maxendcol
;
2592 register Lisp_Object elt
;
2600 #ifdef SWITCH_ENUM_BUG
2601 switch ((int) XTYPE (elt
))
2603 switch (XTYPE (elt
))
2608 /* A string: output it and check for %-constructs within it. */
2609 register unsigned char c
;
2610 register unsigned char *this = XSTRING (elt
)->data
;
2612 while (hpos
< maxendcol
&& *this)
2614 unsigned char *last
= this;
2615 while ((c
= *this++) != '\0' && c
!= '%')
2617 if (this - 1 != last
)
2619 register int lim
= --this - last
+ hpos
;
2620 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
2621 hpos
, min (lim
, maxendcol
));
2625 register int spec_width
= 0;
2627 /* We can't allow -ve args due to the "%-" construct */
2628 /* Argument specifies minwidth but not maxwidth
2629 (maxwidth can be specified by
2630 (<negative-number> . <stuff>) mode-line elements) */
2632 while ((c
= *this++) >= '0' && c
<= '9')
2634 spec_width
= spec_width
* 10 + (c
- '0');
2638 if (spec_width
> maxendcol
)
2639 spec_width
= maxendcol
;
2642 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
2643 spec_width
, maxendcol
,
2644 Vglobal_mode_string
);
2646 hpos
= display_string (w
, vpos
,
2647 decode_mode_spec (w
, c
,
2650 hpos
, 0, 1, spec_width
, maxendcol
);
2657 /* A symbol: process the value of the symbol recursively
2658 as if it appeared here directly. Avoid error if symbol void.
2659 Special case: if value of symbol is a string, output the string
2662 register Lisp_Object tem
;
2663 tem
= Fboundp (elt
);
2666 tem
= Fsymbol_value (elt
);
2667 /* If value is a string, output that string literally:
2668 don't check for % within it. */
2669 if (XTYPE (tem
) == Lisp_String
)
2670 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
2671 XSTRING (tem
)->size
,
2672 hpos
, 0, 1, minendcol
, maxendcol
);
2673 /* Give up right away for nil or t. */
2674 else if (!EQ (tem
, elt
))
2675 { elt
= tem
; goto tail_recurse
; }
2682 register Lisp_Object car
, tem
;
2684 /* A cons cell: three distinct cases.
2685 If first element is a string or a cons, process all the elements
2686 and effectively concatenate them.
2687 If first element is a negative number, truncate displaying cdr to
2688 at most that many characters. If positive, pad (with spaces)
2689 to at least that many characters.
2690 If first element is a symbol, process the cadr or caddr recursively
2691 according to whether the symbol's value is non-nil or nil. */
2692 car
= XCONS (elt
)->car
;
2693 if (XTYPE (car
) == Lisp_Symbol
)
2695 tem
= Fboundp (car
);
2696 elt
= XCONS (elt
)->cdr
;
2697 if (XTYPE (elt
) != Lisp_Cons
)
2699 /* elt is now the cdr, and we know it is a cons cell.
2700 Use its car if CAR has a non-nil value. */
2703 tem
= Fsymbol_value (car
);
2705 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
2707 /* Symbol's value is nil (or symbol is unbound)
2708 Get the cddr of the original list
2709 and if possible find the caddr and use that. */
2710 elt
= XCONS (elt
)->cdr
;
2713 else if (XTYPE (elt
) != Lisp_Cons
)
2715 elt
= XCONS (elt
)->car
;
2718 else if (XTYPE (car
) == Lisp_Int
)
2720 register int lim
= XINT (car
);
2721 elt
= XCONS (elt
)->cdr
;
2723 /* Negative int means reduce maximum width.
2724 DO NOT change MINENDCOL here!
2725 (20 -10 . foo) should truncate foo to 10 col
2726 and then pad to 20. */
2727 maxendcol
= min (maxendcol
, hpos
- lim
);
2730 /* Padding specified. Don't let it be more than
2733 if (lim
> maxendcol
)
2735 /* If that's more padding than already wanted, queue it.
2736 But don't reduce padding already specified even if
2737 that is beyond the current truncation point. */
2738 if (lim
> minendcol
)
2743 else if (XTYPE (car
) == Lisp_String
|| XTYPE (car
) == Lisp_Cons
)
2745 register int limit
= 50;
2746 /* LIMIT is to protect against circular lists. */
2747 while (XTYPE (elt
) == Lisp_Cons
&& --limit
> 0
2748 && hpos
< maxendcol
)
2750 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
2753 elt
= XCONS (elt
)->cdr
;
2761 return (display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
2762 minendcol
, maxendcol
));
2766 if (minendcol
> hpos
)
2767 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 1, minendcol
, maxendcol
);
2771 /* Return a string for the output of a mode line %-spec for window W,
2772 generated by character C and width MAXWIDTH. */
2774 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
2777 decode_mode_spec (w
, c
, maxwidth
)
2780 register int maxwidth
;
2783 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2784 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
2787 if (maxwidth
> FRAME_WIDTH (f
))
2788 maxwidth
= FRAME_WIDTH (f
);
2793 obj
= current_buffer
->name
;
2795 if (maxwidth
>= 3 && XSTRING (obj
)->size
> maxwidth
)
2797 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
2798 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
2799 decode_mode_spec_buf
[maxwidth
] = '\0';
2800 return decode_mode_spec_buf
;
2806 obj
= current_buffer
->filename
;
2810 else if (XTYPE (obj
) == Lisp_String
&& XSTRING (obj
)->size
> maxwidth
)
2812 bcopy ("...", decode_mode_spec_buf
, 3);
2813 bcopy (XSTRING (obj
)->data
+ XSTRING (obj
)->size
- maxwidth
+ 3,
2814 decode_mode_spec_buf
+ 3, maxwidth
- 3);
2815 return decode_mode_spec_buf
;
2822 int startpos
= marker_position (w
->start
);
2823 int line
, linepos
, topline
;
2826 int height
= XFASTINT (w
->height
);
2828 /* If we decided that this buffer isn't suitable for line numbers,
2829 don't forget that too fast. */
2830 if (EQ (w
->base_line_pos
, w
->buffer
))
2833 /* If the buffer is very big, don't waste time. */
2834 if (ZV
- BEGV
> line_number_display_limit
)
2836 w
->base_line_pos
= Qnil
;
2837 w
->base_line_number
= Qnil
;
2841 if (!NILP (w
->base_line_number
)
2842 && !NILP (w
->base_line_pos
)
2843 && XFASTINT (w
->base_line_pos
) <= marker_position (w
->start
))
2845 line
= XFASTINT (w
->base_line_number
);
2846 linepos
= XFASTINT (w
->base_line_pos
);
2854 /* Count lines from base line to window start position. */
2855 nlines
= display_count_lines (linepos
, startpos
, startpos
, &junk
);
2857 topline
= nlines
+ line
;
2859 /* Determine a new base line, if the old one is too close
2860 or too far away, or if we did not have one.
2861 "Too close" means it's plausible a scroll-down would
2863 if (startpos
== BEGV
)
2865 XFASTINT (w
->base_line_number
) = topline
;
2866 XFASTINT (w
->base_line_pos
) = BEGV
;
2868 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
2873 int distance
= (height
* 2 + 30) * 200;
2875 if (startpos
- distance
> limit
)
2876 limit
= startpos
- distance
;
2878 nlines
= display_count_lines (startpos
, limit
,
2881 /* If we couldn't find the lines we wanted within
2883 give up on line numbers for this window. */
2884 if (position
== startpos
- distance
)
2886 w
->base_line_pos
= w
->buffer
;
2887 w
->base_line_number
= Qnil
;
2891 XFASTINT (w
->base_line_number
) = topline
- nlines
;
2892 XFASTINT (w
->base_line_pos
) = position
;
2895 /* Now count lines from the start pos to point. */
2896 nlines
= display_count_lines (startpos
, PT
, PT
, &junk
);
2898 /* Record that we did display the line number. */
2899 line_number_displayed
= 1;
2901 /* Make the string to show. */
2902 sprintf (decode_mode_spec_buf
, "%d", topline
+ nlines
);
2903 return decode_mode_spec_buf
;
2908 obj
= current_buffer
->mode_name
;
2912 if (BEGV
> BEG
|| ZV
< Z
)
2917 if (!NILP (current_buffer
->read_only
))
2919 if (MODIFF
> current_buffer
->save_modified
)
2924 if (MODIFF
> current_buffer
->save_modified
)
2929 /* status of process */
2930 obj
= Fget_buffer_process (Fcurrent_buffer ());
2932 return "no process";
2934 obj
= Fsymbol_name (Fprocess_status (obj
));
2938 case 't': /* indicate TEXT or BINARY */
2940 decode_mode_spec_buf
[0]
2941 = NILP (current_buffer
->buffer_file_type
) ? "T" : "B";
2942 decode_mode_spec_buf
[1] = 0;
2943 return decode_mode_spec_buf
;
2944 #else /* not MSDOS */
2946 #endif /* not MSDOS */
2950 int pos
= marker_position (w
->start
);
2951 int total
= ZV
- BEGV
;
2953 if (XFASTINT (w
->window_end_pos
) <= Z
- ZV
)
2960 else if (pos
<= BEGV
)
2964 total
= ((pos
- BEGV
) * 100 + total
- 1) / total
;
2965 /* We can't normally display a 3-digit number,
2966 so get us a 2-digit number that is close. */
2969 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
2970 return decode_mode_spec_buf
;
2974 /* Display percentage of size above the bottom of the screen. */
2977 int toppos
= marker_position (w
->start
);
2978 int botpos
= Z
- XFASTINT (w
->window_end_pos
);
2979 int total
= ZV
- BEGV
;
2990 total
= ((botpos
- BEGV
) * 100 + total
- 1) / total
;
2991 /* We can't normally display a 3-digit number,
2992 so get us a 2-digit number that is close. */
2996 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
2998 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
2999 return decode_mode_spec_buf
;
3011 if (command_loop_level
> 5)
3013 p
= decode_mode_spec_buf
;
3014 for (i
= 0; i
< command_loop_level
; i
++)
3017 return decode_mode_spec_buf
;
3025 if (command_loop_level
> 5)
3027 p
= decode_mode_spec_buf
;
3028 for (i
= 0; i
< command_loop_level
; i
++)
3031 return decode_mode_spec_buf
;
3039 if (maxwidth
< sizeof (lots_of_dashes
))
3040 return lots_of_dashes
;
3043 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
3047 return decode_mode_spec_buf
;
3051 if (XTYPE (obj
) == Lisp_String
)
3052 return (char *) XSTRING (obj
)->data
;
3057 /* Count up to N lines starting from FROM.
3058 But don't go beyond LIMIT.
3059 Return the number of lines thus found (always positive).
3060 Store the position after what was found into *POS_PTR. */
3063 display_count_lines (from
, limit
, n
, pos_ptr
)
3076 *pos_ptr
= scan_buffer ('\n', from
, n
, &shortage
, 0);
3082 /* When scanning backwards, scan_buffer stops *after* the last newline
3083 it finds, but does count it. Compensate for that. */
3084 return - n
- shortage
- (*pos_ptr
!= limit
);
3085 return n
- shortage
;
3088 /* Display STRING on one line of window W, starting at HPOS.
3089 Display at position VPOS. Caller should have done get_display_line.
3090 If VPOS == -1, display it as the current frame's title.
3091 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
3093 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
3095 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
3096 MAXCOL is the last column ok to end at. Truncate here.
3097 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
3098 Both count from the left edge of the frame, as does HPOS.
3099 The right edge of W is an implicit maximum.
3100 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
3102 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
3103 at the place where the current window ends in this line
3104 and not display anything beyond there. Otherwise, only MAXCOL
3105 controls where to stop output.
3107 Returns ending hpos. */
3110 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
3111 obey_window_width
, mincol
, maxcol
)
3113 unsigned char *string
;
3117 int obey_window_width
;
3122 int hscroll
= XINT (w
->hscroll
);
3123 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
3124 register GLYPH
*start
;
3125 register GLYPH
*end
;
3126 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3127 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3128 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3129 int window_width
= XFASTINT (w
->width
);
3131 /* Use the standard display table, not the window's display table.
3132 We don't want the mode line in rot13. */
3133 register struct Lisp_Vector
*dp
= 0;
3136 if (XTYPE (Vstandard_display_table
) == Lisp_Vector
3137 && XVECTOR (Vstandard_display_table
)->size
== DISP_TABLE_SIZE
)
3138 dp
= XVECTOR (Vstandard_display_table
);
3140 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3143 start
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
3145 if (obey_window_width
)
3147 end
= start
+ window_width
- (truncate
!= 0);
3149 if ((window_width
+ XFASTINT (w
->left
)) != FRAME_WIDTH (f
))
3151 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3155 for (i
= 0; i
< VERTICAL_SCROLL_BAR_WIDTH
; i
++)
3163 if (! obey_window_width
3164 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
3165 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
3167 /* Store 0 in charstart for these columns. */
3168 for (i
= hpos
; i
< end
- p1start
+ hpos
; i
++)
3169 desired_glyphs
->charstarts
[vpos
][i
] = 0;
3171 if (maxcol
>= 0 && mincol
> maxcol
)
3179 /* Specified length. */
3182 /* Unspecified length (null-terminated string). */
3186 if (c
>= 040 && c
< 0177
3187 && (dp
== 0 || XTYPE (DISP_CHAR_VECTOR (dp
, c
)) != Lisp_Vector
))
3197 if (p1
>= start
&& p1
< end
)
3201 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
3203 else if (dp
!= 0 && XTYPE (DISP_CHAR_VECTOR (dp
, c
)) == Lisp_Vector
)
3205 p1
= copy_part_of_rope (f
, p1
, start
,
3206 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3207 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3210 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
3213 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_CTRL_GLYPH (dp
)) == Lisp_Int
3214 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3217 if (p1
>= start
&& p1
< end
)
3224 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_ESCAPE_GLYPH (dp
)) == Lisp_Int
3225 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3228 if (p1
>= start
&& p1
< end
)
3229 *p1
= (c
>> 6) + '0';
3231 if (p1
>= start
&& p1
< end
)
3232 *p1
= (7 & (c
>> 3)) + '0';
3234 if (p1
>= start
&& p1
< end
)
3235 *p1
= (7 & c
) + '0';
3240 if (c
&& length
> 0)
3243 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
3245 else if (mincol
>= 0)
3247 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
3253 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
3255 if (len
> desired_glyphs
->used
[vpos
])
3256 desired_glyphs
->used
[vpos
] = len
;
3257 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
3266 staticpro (&last_arrow_position
);
3267 staticpro (&last_arrow_string
);
3268 last_arrow_position
= Qnil
;
3269 last_arrow_string
= Qnil
;
3271 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
3272 "String (or mode line construct) included (normally) in `mode-line-format'.");
3273 Vglobal_mode_string
= Qnil
;
3275 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
3276 "Marker for where to display an arrow on top of the buffer text.\n\
3277 This must be the beginning of a line in order to work.\n\
3278 See also `overlay-arrow-string'.");
3279 Voverlay_arrow_position
= Qnil
;
3281 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
3282 "String to display as an arrow. See also `overlay-arrow-position'.");
3283 Voverlay_arrow_string
= Qnil
;
3285 DEFVAR_INT ("scroll-step", &scroll_step
,
3286 "*The number of lines to try scrolling a window by when point moves out.\n\
3287 If that fails to bring point back on frame, point is centered instead.\n\
3288 If this is zero, point is always centered after it moves off frame.");
3290 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
3292 DEFVAR_BOOL ("truncate-partial-width-windows",
3293 &truncate_partial_width_windows
,
3294 "*Non-nil means truncate lines in all windows less than full frame wide.");
3295 truncate_partial_width_windows
= 1;
3297 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
3298 "*Non-nil means use inverse video for the mode line.");
3299 mode_line_inverse_video
= 1;
3301 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
3302 "*Maximum buffer size for which line number should be displayed.");
3303 line_number_display_limit
= 1000000;
3305 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
3306 "*Non-nil means highlight region even in nonselected windows.");
3307 highlight_nonselected_windows
= 1;
3310 /* initialize the window system */
3313 Lisp_Object root_window
;
3314 #ifndef COMPILER_REGISTER_BUG
3316 #endif /* COMPILER_REGISTER_BUG */
3317 struct window
*mini_w
;
3319 this_line_bufpos
= 0;
3321 mini_w
= XWINDOW (minibuf_window
);
3322 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
3324 echo_area_glyphs
= 0;
3325 previous_echo_glyphs
= 0;
3327 if (!noninteractive
)
3329 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
3330 XFASTINT (XWINDOW (root_window
)->top
) = 0;
3331 set_window_height (root_window
, FRAME_HEIGHT (f
) - 1, 0);
3332 XFASTINT (mini_w
->top
) = FRAME_HEIGHT (f
) - 1;
3333 set_window_height (minibuf_window
, 1, 0);
3335 XFASTINT (XWINDOW (root_window
)->width
) = FRAME_WIDTH (f
);
3336 XFASTINT (mini_w
->width
) = FRAME_WIDTH (f
);