1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 97, 1998
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 /*#include <ctype.h>*/
31 #include "dispextern.h"
38 #include "termhooks.h"
39 #include "intervals.h"
43 #include "region-cache.h"
49 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
50 extern void set_frame_menubar ();
51 extern int pending_menu_activation
;
54 extern int interrupt_input
;
55 extern int command_loop_level
;
57 extern int minibuffer_auto_raise
;
59 extern Lisp_Object Qface
;
61 extern Lisp_Object Voverriding_local_map
;
62 extern Lisp_Object Voverriding_local_map_menu_flag
;
64 Lisp_Object Qoverriding_local_map
, Qoverriding_terminal_local_map
;
65 Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
66 Lisp_Object Qredisplay_end_trigger_functions
;
67 Lisp_Object Qinhibit_point_motion_hooks
;
69 /* Nonzero means print newline to stdout before next minibuffer message. */
71 int noninteractive_need_newline
;
73 /* Nonzero means print newline to message log before next message. */
75 static int message_log_need_newline
;
77 #define min(a, b) ((a) < (b) ? (a) : (b))
78 #define max(a, b) ((a) > (b) ? (a) : (b))
79 #define minmax(floor, val, ceil) \
80 ((val) < (floor) ? (floor) : (val) > (ceil) ? (ceil) : (val))
82 /* The buffer position of the first character appearing
83 entirely or partially on the current frame line.
84 Or zero, which disables the optimization for the current frame line. */
85 static int this_line_bufpos
;
87 /* Number of characters past the end of this line,
88 including the terminating newline */
89 static int this_line_endpos
;
91 /* The vertical position of this frame line. */
92 static int this_line_vpos
;
94 /* Hpos value for start of display on this frame line.
95 Usually zero, but negative if first character really began
97 static int this_line_start_hpos
;
99 /* Buffer that this_line variables are describing. */
100 static struct buffer
*this_line_buffer
;
102 /* Value of echo_area_glyphs when it was last acted on.
103 If this is nonzero, there is a message on the frame
104 in the minibuffer and it should be erased as soon
105 as it is no longer requested to appear. */
106 char *previous_echo_glyphs
;
108 /* Nonzero means truncate lines in all windows less wide than the frame */
109 int truncate_partial_width_windows
;
111 /* Nonzero means we have more than one non-minibuffer-only frame.
112 Not guaranteed to be accurate except while parsing frame-title-format. */
115 Lisp_Object Vglobal_mode_string
;
117 /* Marker for where to display an arrow on top of the buffer text. */
118 Lisp_Object Voverlay_arrow_position
;
120 /* String to display for the arrow. */
121 Lisp_Object Voverlay_arrow_string
;
123 /* Values of those variables at last redisplay.
124 However, if Voverlay_arrow_position is a marker,
125 last_arrow_position is its numerical position. */
126 static Lisp_Object last_arrow_position
, last_arrow_string
;
128 /* Like mode-line-format, but for the titlebar on a visible frame. */
129 Lisp_Object Vframe_title_format
;
131 /* Like mode-line-format, but for the titlebar on an iconified frame. */
132 Lisp_Object Vicon_title_format
;
134 /* List of functions to call when a window's size changes. These
135 functions get one arg, a frame on which one or more windows' sizes
137 static Lisp_Object Vwindow_size_change_functions
;
139 Lisp_Object Qmenu_bar_update_hook
;
141 /* Nonzero if overlay arrow has been displayed once in this window. */
142 static int overlay_arrow_seen
;
144 /* Nonzero if visible end of buffer has already been displayed once
145 in this window. (We need this variable in case there are overlay
146 strings that get displayed there.) */
147 static int zv_strings_seen
;
149 /* Nonzero means highlight the region even in nonselected windows. */
150 static int highlight_nonselected_windows
;
152 /* If cursor motion alone moves point off frame,
153 Try scrolling this many lines up or down if that will bring it back. */
154 static int scroll_step
;
156 /* Non-0 means scroll just far enough to bring point back on the screen,
158 static int scroll_conservatively
;
160 /* Recenter the window whenever point gets within this many lines
161 of the top or bottom of the window. */
164 /* Number of characters of overlap to show,
165 when scrolling a one-line window such as a minibuffer. */
166 static int minibuffer_scroll_overlap
;
168 /* Nonzero if try_window_id has made blank lines at window bottom
169 since the last redisplay that paused */
170 static int blank_end_of_window
;
172 /* Number of windows showing the buffer of the selected window
173 (or another buffer with the same base buffer).
174 keyboard.c refers to this. */
177 /* display_text_line sets these to the frame position (origin 0) of point,
178 whether the window is selected or not.
179 Set one to -1 first to determine whether point was found afterwards. */
181 static int cursor_vpos
;
182 static int cursor_hpos
;
184 static int debug_end_pos
;
186 /* Nonzero means display mode line highlighted */
187 int mode_line_inverse_video
;
189 static void redisplay_internal ();
190 static int message_log_check_duplicate ();
191 static void echo_area_display ();
192 void mark_window_display_accurate ();
193 static void redisplay_windows ();
194 static void redisplay_window ();
195 static void update_menu_bar ();
196 static void try_window ();
197 static int try_window_id ();
198 static struct position
*display_text_line ();
199 static void display_mode_line ();
200 static int display_mode_element ();
201 static char *decode_mode_spec ();
202 static int display_string ();
203 static void display_menu_bar ();
204 static int display_count_lines ();
206 /* Prompt to display in front of the minibuffer contents */
207 Lisp_Object minibuf_prompt
;
209 /* Width in columns of current minibuffer prompt. */
210 int minibuf_prompt_width
;
212 /* Message to display instead of minibuffer contents
213 This is what the functions error and message make,
214 and command echoing uses it as well.
215 It overrides the minibuf_prompt as well as the buffer. */
216 char *echo_area_glyphs
;
218 /* This is the length of the message in echo_area_glyphs. */
219 int echo_area_glyphs_length
;
221 /* This is the window where the echo area message was displayed.
222 It is always a minibuffer window, but it may not be the
223 same window currently active as a minibuffer. */
224 Lisp_Object echo_area_window
;
226 /* Nonzero means multibyte characters were enabled when the echo area
227 message was specified. */
228 int message_enable_multibyte
;
230 /* true iff we should redraw the mode lines on the next redisplay */
231 int update_mode_lines
;
233 /* Smallest number of characters before the gap
234 at any time since last redisplay that finished.
235 Valid for current buffer when try_window_id can be called. */
238 /* Smallest number of characters after the gap
239 at any time since last redisplay that finished.
240 Valid for current buffer when try_window_id can be called. */
243 /* MODIFF as of last redisplay that finished;
244 if it matches MODIFF, and overlay_unchanged_modified
245 matches OVERLAY_MODIFF, that means beg_unchanged and end_unchanged
246 contain no useful information */
247 int unchanged_modified
;
249 /* OVERLAY_MODIFF as of last redisplay that finished. */
250 int overlay_unchanged_modified
;
252 /* Nonzero if window sizes or contents have changed
253 since last redisplay that finished */
254 int windows_or_buffers_changed
;
256 /* Nonzero after display_mode_line if %l was used
257 and it displayed a line number. */
258 int line_number_displayed
;
260 /* Maximum buffer size for which to display line numbers. */
261 static int line_number_display_limit
;
263 /* Number of lines to keep in the message log buffer.
264 t means infinite. nil means don't log at all. */
265 Lisp_Object Vmessage_log_max
;
267 #define COERCE_MARKER(X) \
268 (MARKERP ((X)) ? Fmarker_position (X) : (X))
270 static int pos_tab_offset
P_ ((struct window
*, int, int));
272 /* Output a newline in the *Messages* buffer if "needs" one. */
275 message_log_maybe_newline ()
277 if (message_log_need_newline
)
278 message_dolog ("", 0, 1, 0);
282 /* Add a string to the message log, optionally terminated with a newline.
283 This function calls low-level routines in order to bypass text property
284 hooks, etc. which might not be safe to run.
285 MULTIBYTE, if nonzero, means interpret the contents of M as multibyte. */
288 message_dolog (m
, len
, nlflag
, multibyte
)
290 int len
, nlflag
, multibyte
;
292 if (!NILP (Vmessage_log_max
))
294 struct buffer
*oldbuf
;
295 Lisp_Object oldpoint
, oldbegv
, oldzv
;
296 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
297 int point_at_end
= 0;
299 Lisp_Object old_deactivate_mark
;
301 old_deactivate_mark
= Vdeactivate_mark
;
302 oldbuf
= current_buffer
;
303 Fset_buffer (Fget_buffer_create (build_string ("*Messages*")));
304 current_buffer
->undo_list
= Qt
;
306 oldpoint
= Fpoint_marker ();
307 oldbegv
= Fpoint_min_marker ();
308 oldzv
= Fpoint_max_marker ();
316 BEGV_BYTE
= BEG_BYTE
;
319 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
321 /* Insert the string--maybe converting multibyte to single byte
322 or vice versa, so that all the text fits the buffer. */
324 && NILP (current_buffer
->enable_multibyte_characters
))
326 int c
, i
= 0, nbytes
;
327 /* Convert a multibyte string to single-byte
328 for the *Message* buffer. */
331 c
= STRING_CHAR (m
+ i
, len
- i
);
332 i
+= XFASTINT (Fchar_bytes (make_number (c
)));
333 /* Truncate the character to its last byte--we can only hope
334 the user is happy with the character he gets,
335 since if it isn't right, there is no way to do it right. */
341 && ! NILP (current_buffer
->enable_multibyte_characters
))
344 unsigned char *msg
= (unsigned char *) m
;
345 /* Convert a single-byte string to multibyte
346 for the *Message* buffer. */
349 int c
= unibyte_char_to_multibyte (msg
[i
++]);
354 insert_1 (m
, len
, 1, 0, 0);
358 int this_bol
, this_bol_byte
, prev_bol
, prev_bol_byte
, dup
;
359 insert_1 ("\n", 1, 1, 0, 0);
361 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
, -2, 0);
363 this_bol_byte
= PT_BYTE
;
367 scan_newline (PT
, PT_BYTE
, BEG
, BEG_BYTE
, -2, 0);
369 prev_bol_byte
= PT_BYTE
;
371 dup
= message_log_check_duplicate (prev_bol
, prev_bol_byte
,
372 this_bol
, this_bol_byte
);
375 del_range_both (prev_bol
, prev_bol_byte
,
376 this_bol
, this_bol_byte
, 0);
382 /* If you change this format, don't forget to also
383 change message_log_check_duplicate. */
384 sprintf (dupstr
, " [%d times]", dup
);
385 duplen
= strlen (dupstr
);
386 TEMP_SET_PT_BOTH (Z
- 1, Z_BYTE
- 1);
387 insert_1 (dupstr
, duplen
, 1, 0, 1);
392 if (NATNUMP (Vmessage_log_max
))
394 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
,
395 -XFASTINT (Vmessage_log_max
) - 1, 0);
396 del_range_both (BEG
, BEG_BYTE
, PT
, PT_BYTE
, 0);
399 BEGV
= XMARKER (oldbegv
)->charpos
;
400 BEGV_BYTE
= marker_byte_position (oldbegv
);
409 ZV
= XMARKER (oldzv
)->charpos
;
410 ZV_BYTE
= marker_byte_position (oldzv
);
414 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
416 Fgoto_char (oldpoint
);
418 free_marker (oldpoint
);
419 free_marker (oldbegv
);
422 set_buffer_internal (oldbuf
);
423 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
424 message_log_need_newline
= !nlflag
;
425 Vdeactivate_mark
= old_deactivate_mark
;
429 /* We are at the end of the buffer after just having inserted a newline.
430 (Note: We depend on the fact we won't be crossing the gap.)
431 Check to see if the most recent message looks a lot like the previous one.
432 Return 0 if different, 1 if the new one should just replace it, or a
433 value N > 1 if we should also append " [N times]". */
436 message_log_check_duplicate (prev_bol
, prev_bol_byte
, this_bol
, this_bol_byte
)
437 int prev_bol
, this_bol
;
438 int prev_bol_byte
, this_bol_byte
;
441 int len
= Z
- 1 - this_bol
;
443 unsigned char *p1
= BUF_BYTE_ADDRESS (current_buffer
, prev_bol_byte
);
444 unsigned char *p2
= BUF_BYTE_ADDRESS (current_buffer
, this_bol_byte
);
446 for (i
= 0; i
< len
; i
++)
448 if (i
>= 3 && p1
[i
-3] == '.' && p1
[i
-2] == '.' && p1
[i
-1] == '.'
457 if (*p1
++ == ' ' && *p1
++ == '[')
460 while (*p1
>= '0' && *p1
<= '9')
461 n
= n
* 10 + *p1
++ - '0';
462 if (strncmp (p1
, " times]\n", 8) == 0)
468 /* Display an echo area message M with a specified length of LEN chars.
469 The string may include null characters. If M is 0, clear out any
470 existing message, and let the minibuffer text show through.
472 The buffer M must continue to exist until after the echo area
473 gets cleared or some other message gets displayed there.
475 Do not pass text that is stored in a Lisp string.
476 Do not pass text in a buffer that was alloca'd. */
479 message2 (m
, len
, multibyte
)
484 /* First flush out any partial line written with print. */
485 message_log_maybe_newline ();
487 message_dolog (m
, len
, 1, multibyte
);
488 message2_nolog (m
, len
, multibyte
);
492 /* The non-logging counterpart of message2. */
495 message2_nolog (m
, len
, multibyte
)
499 message_enable_multibyte
= multibyte
;
503 if (noninteractive_need_newline
)
505 noninteractive_need_newline
= 0;
507 fwrite (m
, len
, 1, stderr
);
508 if (cursor_in_echo_area
== 0)
509 fprintf (stderr
, "\n");
512 /* A null message buffer means that the frame hasn't really been
513 initialized yet. Error messages get reported properly by
514 cmd_error, so this must be just an informative message; toss it. */
515 else if (INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
517 Lisp_Object mini_window
;
520 /* Get the frame containing the minibuffer
521 that the selected frame is using. */
522 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
523 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
525 FRAME_SAMPLE_VISIBILITY (f
);
526 if (FRAME_VISIBLE_P (selected_frame
)
527 && ! FRAME_VISIBLE_P (f
))
528 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (mini_window
)));
532 echo_area_glyphs
= m
;
533 echo_area_glyphs_length
= len
;
535 if (minibuffer_auto_raise
)
536 Fraise_frame (WINDOW_FRAME (XWINDOW (mini_window
)));
539 echo_area_glyphs
= previous_echo_glyphs
= 0;
541 do_pending_window_change ();
542 echo_area_display ();
543 update_frame (f
, 1, 1);
544 do_pending_window_change ();
545 if (frame_up_to_date_hook
!= 0 && ! gc_in_progress
)
546 (*frame_up_to_date_hook
) (f
);
550 /* Display in echo area the null-terminated ASCII-only string M.
551 If M is 0, clear out any existing message,
552 and let the minibuffer text show through.
554 The string M must continue to exist until after the echo area
555 gets cleared or some other message gets displayed there.
557 Do not pass text that is stored in a Lisp string.
558 Do not pass text in a buffer that was alloca'd. */
564 message2 (m
, (m
? strlen (m
) : 0), 0);
571 message2_nolog (m
, (m
? strlen (m
) : 0), 0);
574 /* Display a message M which contains a single %s
575 which gets replaced with STRING. */
578 message_with_string (m
, string
, log
)
587 if (noninteractive_need_newline
)
589 noninteractive_need_newline
= 0;
590 fprintf (stderr
, m
, XSTRING (string
)->data
);
591 if (cursor_in_echo_area
== 0)
592 fprintf (stderr
, "\n");
596 else if (INTERACTIVE
)
598 /* The frame whose minibuffer we're going to display the message on.
599 It may be larger than the selected frame, so we need
600 to use its buffer, not the selected frame's buffer. */
601 Lisp_Object mini_window
;
604 /* Get the frame containing the minibuffer
605 that the selected frame is using. */
606 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
607 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
609 /* A null message buffer means that the frame hasn't really been
610 initialized yet. Error messages get reported properly by
611 cmd_error, so this must be just an informative message; toss it. */
612 if (FRAME_MESSAGE_BUF (f
))
616 a
[0] = (char *) XSTRING (string
)->data
;
618 len
= doprnt (FRAME_MESSAGE_BUF (f
),
619 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
622 message2 (FRAME_MESSAGE_BUF (f
), len
,
623 STRING_MULTIBYTE (string
));
625 message2_nolog (FRAME_MESSAGE_BUF (f
), len
,
626 STRING_MULTIBYTE (string
));
628 /* Print should start at the beginning of the message
630 message_buf_print
= 0;
635 /* Truncate what will be displayed in the echo area
636 the next time we display it--but don't redisplay it now. */
639 truncate_echo_area (len
)
642 /* A null message buffer means that the frame hasn't really been
643 initialized yet. Error messages get reported properly by
644 cmd_error, so this must be just an informative message; toss it. */
645 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
646 echo_area_glyphs_length
= len
;
649 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
650 zero if being used by message. */
651 int message_buf_print
;
653 /* Dump an informative message to the minibuf. If M is 0, clear out
654 any existing message, and let the minibuffer text show through. */
658 message (m
, a1
, a2
, a3
)
660 EMACS_INT a1
, a2
, a3
;
666 if (noninteractive_need_newline
)
668 noninteractive_need_newline
= 0;
669 fprintf (stderr
, m
, a1
, a2
, a3
);
670 if (cursor_in_echo_area
== 0)
671 fprintf (stderr
, "\n");
675 else if (INTERACTIVE
)
677 /* The frame whose minibuffer we're going to display the message on.
678 It may be larger than the selected frame, so we need
679 to use its buffer, not the selected frame's buffer. */
680 Lisp_Object mini_window
;
683 /* Get the frame containing the minibuffer
684 that the selected frame is using. */
685 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
686 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
688 /* A null message buffer means that the frame hasn't really been
689 initialized yet. Error messages get reported properly by
690 cmd_error, so this must be just an informative message; toss it. */
691 if (FRAME_MESSAGE_BUF (f
))
702 len
= doprnt (FRAME_MESSAGE_BUF (f
),
703 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
705 len
= doprnt (FRAME_MESSAGE_BUF (f
),
706 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3,
708 #endif /* NO_ARG_ARRAY */
710 message2 (FRAME_MESSAGE_BUF (f
), len
, 0);
715 /* Print should start at the beginning of the message
717 message_buf_print
= 0;
722 /* The non-logging version of message. */
724 message_nolog (m
, a1
, a2
, a3
)
726 EMACS_INT a1
, a2
, a3
;
728 Lisp_Object old_log_max
;
729 old_log_max
= Vmessage_log_max
;
730 Vmessage_log_max
= Qnil
;
731 message (m
, a1
, a2
, a3
);
732 Vmessage_log_max
= old_log_max
;
738 message2 (echo_area_glyphs
, echo_area_glyphs_length
,
739 ! NILP (current_buffer
->enable_multibyte_characters
));
747 Lisp_Object mini_window
;
749 /* Choose the minibuffer window for this display.
750 It is the minibuffer window used by the selected frame. */
751 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
752 /* This is the frame that window is in. */
753 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
755 if (! FRAME_VISIBLE_P (f
))
760 redraw_garbaged_frames ();
764 if (echo_area_glyphs
|| minibuf_level
== 0)
768 echo_area_window
= mini_window
;
770 vpos
= XFASTINT (XWINDOW (mini_window
)->top
);
771 get_display_line (f
, vpos
, 0);
773 /* Make sure the columns that overlap a left-hand scroll bar
775 for (i
= 0; i
< FRAME_LEFT_SCROLL_BAR_WIDTH (f
); i
++)
776 f
->desired_glyphs
->glyphs
[vpos
][i
] = SPACEGLYPH
;
778 display_string (XWINDOW (mini_window
), vpos
,
779 echo_area_glyphs
? echo_area_glyphs
: "",
780 echo_area_glyphs
? echo_area_glyphs_length
: -1,
781 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
783 FRAME_WIDTH (f
) + FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
784 message_enable_multibyte
);
786 #if 0 /* This just gets in the way. update_frame does the job. */
787 /* If desired cursor location is on this line, put it at end of text */
788 if (cursor_in_echo_area
)
789 FRAME_CURSOR_Y (f
) = vpos
;
790 if (FRAME_CURSOR_Y (f
) == vpos
)
791 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
794 /* Fill the rest of the minibuffer window with blank lines. */
799 i
< vpos
+ XFASTINT (XWINDOW (mini_window
)->height
); i
++)
801 get_display_line (f
, i
, 0);
802 /* We don't use FRAME_SCROLL_BAR_WIDTH (f) as the starting
803 hpos, because it is good to clear whatever is behind the
804 scroll bar. This does not affect the scroll bar itself. */
805 display_string (XWINDOW (mini_window
), i
,
808 0, FRAME_WIDTH (f
) + FRAME_SCROLL_BAR_WIDTH (f
),
813 else if (!EQ (mini_window
, selected_window
))
814 windows_or_buffers_changed
++;
816 if (EQ (mini_window
, selected_window
))
817 this_line_bufpos
= 0;
819 previous_echo_glyphs
= echo_area_glyphs
;
822 /* Update frame titles. */
824 #ifdef HAVE_WINDOW_SYSTEM
825 static char frame_title_buf
[512];
826 static char *frame_title_ptr
;
829 store_frame_title (str
, mincol
, maxcol
)
834 if (maxcol
< 0 || maxcol
>= sizeof(frame_title_buf
))
835 maxcol
= sizeof (frame_title_buf
);
836 limit
= &frame_title_buf
[maxcol
];
837 while (*str
!= '\0' && frame_title_ptr
< limit
)
838 *frame_title_ptr
++ = *str
++;
839 while (frame_title_ptr
< &frame_title_buf
[mincol
])
840 *frame_title_ptr
++ = ' ';
841 return frame_title_ptr
- frame_title_buf
;
845 x_consider_frame_title (frame
)
851 FRAME_PTR f
= XFRAME (frame
);
853 if (!(FRAME_WINDOW_P (f
) || FRAME_MINIBUF_ONLY_P (f
) || f
->explicit_name
))
856 /* Do we have more than one visible frame on this X display? */
860 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
862 FRAME_PTR tf
= XFRAME (XCONS (tail
)->car
);
864 if (tf
!= f
&& FRAME_KBOARD (tf
) == FRAME_KBOARD (f
)
865 && !FRAME_MINIBUF_ONLY_P (tf
)
866 && (FRAME_VISIBLE_P (tf
) || FRAME_ICONIFIED_P (tf
)))
870 multiple_frames
= CONSP (tail
);
873 obuf
= current_buffer
;
874 Fset_buffer (XWINDOW (f
->selected_window
)->buffer
);
875 fmt
= (FRAME_ICONIFIED_P (f
) ? Vicon_title_format
: Vframe_title_format
);
876 frame_title_ptr
= frame_title_buf
;
877 len
= display_mode_element (XWINDOW (f
->selected_window
), 0, 0, 0,
878 0, sizeof (frame_title_buf
), fmt
);
880 set_buffer_internal (obuf
);
881 /* Set the name only if it's changed. This avoids consing
882 in the common case where it hasn't. (If it turns out that we've
883 already wasted too much time by walking through the list with
884 display_mode_element, then we might need to optimize at a higher
886 if (! STRINGP (f
->name
) || STRING_BYTES (XSTRING (f
->name
)) != len
887 || bcmp (frame_title_buf
, XSTRING (f
->name
)->data
, len
) != 0)
888 x_implicitly_set_name (f
, make_string (frame_title_buf
, len
), Qnil
);
891 #define frame_title_ptr ((char *)0)
892 #define store_frame_title(str, mincol, maxcol) 0
895 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
896 This can call eval. */
901 register struct window
*w
= XWINDOW (selected_window
);
903 struct gcpro gcpro1
, gcpro2
;
905 all_windows
= (update_mode_lines
|| buffer_shared
> 1
906 || windows_or_buffers_changed
);
908 /* Update all frame titles based on their buffer names, etc.
909 We do this before the menu bars so that the buffer-menu
910 will show the up-to-date frame titles.
912 This used to be done after the menu bars, for a reason that
913 was stated as follows but which I do not understand:
914 "We do this after the menu bars so that the frame will first
915 create its menu bar using the name `emacs' if no other name
916 has yet been specified."
917 I think that is no longer a concern. */
918 #ifdef HAVE_WINDOW_SYSTEM
919 if (windows_or_buffers_changed
|| update_mode_lines
)
921 Lisp_Object tail
, frame
;
923 FOR_EACH_FRAME (tail
, frame
)
924 if (FRAME_VISIBLE_P (XFRAME (frame
))
925 || FRAME_ICONIFIED_P (XFRAME (frame
)))
926 x_consider_frame_title (frame
);
930 /* Update the menu bar item lists, if appropriate.
931 This has to be done before any actual redisplay
932 or generation of display lines. */
935 Lisp_Object tail
, frame
;
936 int count
= specpdl_ptr
- specpdl
;
938 record_unwind_protect (Fset_match_data
, Fmatch_data (Qnil
, Qnil
));
940 FOR_EACH_FRAME (tail
, frame
)
942 /* If a window on this frame changed size,
943 report that to the user and clear the size-change flag. */
944 if (FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)))
946 Lisp_Object functions
;
947 /* Clear flag first in case we get error below. */
948 FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)) = 0;
949 functions
= Vwindow_size_change_functions
;
950 GCPRO2 (tail
, functions
);
951 while (CONSP (functions
))
953 call1 (XCONS (functions
)->car
, frame
);
954 functions
= XCONS (functions
)->cdr
;
959 update_menu_bar (XFRAME (frame
), 0);
963 unbind_to (count
, Qnil
);
966 update_menu_bar (selected_frame
, 1);
968 /* Motif needs this. See comment in xmenu.c.
969 Turn it off when pending_menu_activation is not defined. */
971 pending_menu_activation
= 0;
975 /* Do a frame update, taking possible shortcuts into account.
976 This is the main external entry point for redisplay.
978 If the last redisplay displayed an echo area message and that
979 message is no longer requested, we clear the echo area
980 or bring back the minibuffer if that is in use.
982 Do not call eval from within this function.
983 Calls to eval after the call to echo_area_display would confuse
984 the display_line mechanism and would cause a crash.
985 Calls to eval before that point will work most of the time,
986 but can still lose, because this function
987 can be called from signal handlers; with alarms set up;
988 or with synchronous processes running.
990 See Fcall_process; if you called it from here, it could be
991 entered recursively. */
993 static int do_verify_charstarts
;
995 /* Counter is used to clear the face cache
996 no more than once ever 1000 redisplays. */
997 static int clear_face_cache_count
;
999 /* Record the previous terminal frame we displayed. */
1000 static FRAME_PTR previous_terminal_frame
;
1005 redisplay_internal (0);
1008 /* If PRESERVE_ECHO_AREA is nonzero, it means this redisplay
1009 is not in response to any user action; therefore, we should
1010 preserve the echo area. (Actually, our caller does that job.)
1011 Perhaps in the future avoid recentering windows
1012 if it is not necessary; currently that causes some problems. */
1015 redisplay_internal (preserve_echo_area
)
1016 int preserve_echo_area
;
1018 register struct window
*w
= XWINDOW (selected_window
);
1020 int must_finish
= 0;
1022 register int tlbufpos
, tlendpos
;
1023 struct position pos
;
1024 int number_of_visible_frames
;
1029 #ifdef USE_X_TOOLKIT
1030 if (popup_activated ())
1036 if (! FRAME_WINDOW_P (selected_frame
)
1037 && previous_terminal_frame
!= selected_frame
)
1039 /* Since frames on an ASCII terminal share the same display area,
1040 displaying a different frame means redisplay the whole thing. */
1041 windows_or_buffers_changed
++;
1042 SET_FRAME_GARBAGED (selected_frame
);
1043 XSETFRAME (Vterminal_frame
, selected_frame
);
1045 previous_terminal_frame
= selected_frame
;
1047 /* Set the visible flags for all frames.
1048 Do this before checking for resized or garbaged frames; they want
1049 to know if their frames are visible.
1050 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
1052 Lisp_Object tail
, frame
;
1054 number_of_visible_frames
= 0;
1056 FOR_EACH_FRAME (tail
, frame
)
1058 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1060 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1061 number_of_visible_frames
++;
1063 /* Clear out all the display lines in which we will generate the
1064 glyphs to display. */
1065 init_desired_glyphs (XFRAME (frame
));
1069 /* Notice any pending interrupt request to change frame size. */
1070 do_pending_window_change ();
1074 redraw_garbaged_frames ();
1078 prepare_menu_bars ();
1080 if (windows_or_buffers_changed
)
1081 update_mode_lines
++;
1083 /* Detect case that we need to write or remove a star in the mode line. */
1084 if ((SAVE_MODIFF
< MODIFF
) != !NILP (w
->last_had_star
))
1086 w
->update_mode_line
= Qt
;
1087 if (buffer_shared
> 1)
1088 update_mode_lines
++;
1091 /* If %c is in use, update it if needed. */
1092 if (!NILP (w
->column_number_displayed
)
1093 /* This alternative quickly identifies a common case
1094 where no change is needed. */
1095 && !(PT
== XFASTINT (w
->last_point
)
1096 && XFASTINT (w
->last_modified
) >= MODIFF
1097 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1098 && XFASTINT (w
->column_number_displayed
) != current_column ())
1099 w
->update_mode_line
= Qt
;
1101 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
1103 all_windows
= update_mode_lines
|| buffer_shared
> 1;
1105 /* If specs for an arrow have changed, do thorough redisplay
1106 to ensure we remove any arrow that should no longer exist. */
1107 if (! EQ (COERCE_MARKER (Voverlay_arrow_position
), last_arrow_position
)
1108 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
1111 /* Normally the message* functions will have already displayed and
1112 updated the echo area, but the frame may have been trashed, or
1113 the update may have been preempted, so display the echo area
1115 if (echo_area_glyphs
|| previous_echo_glyphs
)
1117 echo_area_display ();
1121 /* If showing region, and mark has changed, must redisplay whole window. */
1122 if (((!NILP (Vtransient_mark_mode
)
1123 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1124 != !NILP (w
->region_showing
))
1125 || (!NILP (w
->region_showing
)
1126 && !EQ (w
->region_showing
,
1127 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
1128 this_line_bufpos
= -1;
1130 tlbufpos
= this_line_bufpos
;
1131 tlendpos
= this_line_endpos
;
1132 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
1133 && !current_buffer
->clip_changed
1134 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
1135 && !FRAME_OBSCURED_P (XFRAME (w
->frame
))
1136 /* Make sure recorded data applies to current buffer, etc */
1137 && this_line_buffer
== current_buffer
1138 && current_buffer
== XBUFFER (w
->buffer
)
1139 && NILP (w
->force_start
)
1140 /* Point must be on the line that we have info recorded about */
1142 && PT
<= Z
- tlendpos
1143 /* All text outside that line, including its final newline,
1144 must be unchanged */
1145 && ((XFASTINT (w
->last_modified
) >= MODIFF
1146 && (XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
))
1147 || (beg_unchanged
>= tlbufpos
- 1
1149 /* If selective display, can't optimize
1150 if the changes start at the beginning of the line. */
1151 && ((INTEGERP (current_buffer
->selective_display
)
1152 && XINT (current_buffer
->selective_display
) > 0
1153 ? (beg_unchanged
>= tlbufpos
1156 && end_unchanged
>= tlendpos
1157 && Z
- GPT
>= tlendpos
)))
1159 int tlbufpos_byte
= CHAR_TO_BYTE (tlbufpos
);
1160 if (tlbufpos
> BEGV
&& FETCH_BYTE (tlbufpos_byte
- 1) != '\n'
1162 || FETCH_BYTE (tlbufpos_byte
) == '\n'))
1163 /* Former continuation line has disappeared by becoming empty */
1165 else if (XFASTINT (w
->last_modified
) < MODIFF
1166 || XFASTINT (w
->last_overlay_modified
) < OVERLAY_MODIFF
1167 || MINI_WINDOW_P (w
))
1169 /* We have to handle the case of continuation around a
1170 wide-column character (See the comment in indent.c around
1173 For instance, in the following case:
1175 -------- Insert --------
1176 K_A_N_\\ `a' K_A_N_a\ `X_' are wide-column chars.
1177 J_I_ ==> J_I_ `^^' are cursors.
1181 As we have to redraw the line above, we should goto cancel. */
1183 struct position val
;
1185 int opoint
= PT
, opoint_byte
= PT_BYTE
;
1187 scan_newline (tlbufpos
, tlbufpos_byte
, BEGV
, BEGV_BYTE
, -1, 1);
1189 val
= *compute_motion (PT
, 0,
1190 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1193 1 << (BITS_PER_SHORT
- 1),
1194 1 << (BITS_PER_SHORT
- 1),
1195 window_internal_width (w
) - 1,
1196 XINT (w
->hscroll
), 0, w
);
1197 SET_PT_BOTH (opoint
, opoint_byte
);
1198 if (val
.hpos
!= this_line_start_hpos
)
1202 overlay_arrow_seen
= 0;
1203 zv_strings_seen
= 0;
1204 display_text_line (w
, tlbufpos
, tlbufpos_byte
,
1205 this_line_vpos
, this_line_start_hpos
,
1206 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
), 0);
1207 /* If line contains point, is not continued,
1208 and ends at same distance from eob as before, we win */
1209 if (cursor_vpos
>= 0 && this_line_bufpos
1210 && this_line_endpos
== tlendpos
)
1212 /* If this is not the window's last line,
1213 we must adjust the charstarts of the lines below. */
1214 if (this_line_vpos
+ 1
1215 < XFASTINT (w
->top
) + window_internal_height (w
))
1217 int left
= WINDOW_LEFT_MARGIN (w
);
1218 int *charstart_next_line
1219 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
1222 if (Z
- tlendpos
== ZV
)
1223 /* This line ends at end of (accessible part of) buffer.
1224 There is no newline to count. */
1225 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
1227 /* This line ends in a newline.
1228 Must take account of the newline and the rest of the
1229 text that follows. */
1230 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
1232 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
1235 if (!WINDOW_FULL_WIDTH_P (w
))
1236 preserve_other_columns (w
);
1242 else if (PT
== XFASTINT (w
->last_point
)
1243 /* Make sure the cursor was last displayed
1244 in this window. Otherwise we have to reposition it. */
1245 && XINT (w
->top
) <= FRAME_CURSOR_Y (selected_frame
)
1246 && (XINT (w
->top
) + XINT (w
->height
)
1247 > FRAME_CURSOR_Y (selected_frame
)))
1251 do_pending_window_change ();
1256 /* If highlighting the region, or if the cursor is in the echo area,
1257 then we can't just move the cursor. */
1258 else if (! (!NILP (Vtransient_mark_mode
)
1259 && !NILP (current_buffer
->mark_active
))
1260 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1261 || highlight_nonselected_windows
)
1262 && NILP (w
->region_showing
)
1263 && !cursor_in_echo_area
)
1265 pos
= *compute_motion (tlbufpos
, 0,
1266 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1268 PT
, 2, - (1 << (BITS_PER_SHORT
- 1)),
1269 window_internal_width (w
) - 1,
1271 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
),
1275 int width
= window_internal_width (w
) - 1;
1276 FRAME_CURSOR_X (selected_frame
)
1277 = WINDOW_LEFT_MARGIN (w
) + minmax (0, pos
.hpos
, width
);
1278 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
1285 /* Text changed drastically or point moved off of line */
1286 cancel_line (this_line_vpos
, selected_frame
);
1289 this_line_bufpos
= 0;
1290 all_windows
|= buffer_shared
> 1;
1292 clear_face_cache_count
++;
1296 Lisp_Object tail
, frame
;
1299 /* Clear the face cache, only when we do a full redisplay
1300 and not too often either. */
1301 if (clear_face_cache_count
> 1000)
1303 clear_face_cache ();
1304 clear_face_cache_count
= 0;
1308 /* Recompute # windows showing selected buffer.
1309 This will be incremented each time such a window is displayed. */
1312 FOR_EACH_FRAME (tail
, frame
)
1314 FRAME_PTR f
= XFRAME (frame
);
1315 if (FRAME_WINDOW_P (f
) || f
== selected_frame
)
1318 /* Mark all the scroll bars to be removed; we'll redeem the ones
1319 we want when we redisplay their windows. */
1320 if (condemn_scroll_bars_hook
)
1321 (*condemn_scroll_bars_hook
) (f
);
1323 if (FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1324 redisplay_windows (FRAME_ROOT_WINDOW (f
), preserve_echo_area
);
1326 /* Any scroll bars which redisplay_windows should have nuked
1327 should now go away. */
1328 if (judge_scroll_bars_hook
)
1329 (*judge_scroll_bars_hook
) (f
);
1333 else if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1335 redisplay_window (selected_window
, 1, preserve_echo_area
);
1336 if (!WINDOW_FULL_WIDTH_P (w
))
1337 preserve_other_columns (w
);
1341 /* Prevent various kinds of signals during display update.
1342 stdio is not robust about handling signals,
1343 which can cause an apparent I/O error. */
1344 if (interrupt_input
)
1354 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1358 if (!FRAMEP (XCONS (tail
)->car
))
1361 f
= XFRAME (XCONS (tail
)->car
);
1363 if ((FRAME_WINDOW_P (f
) || f
== selected_frame
)
1364 && FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1366 pause
|= update_frame (f
, 0, 0);
1369 mark_window_display_accurate (f
->root_window
, 1);
1370 if (frame_up_to_date_hook
!= 0)
1371 (*frame_up_to_date_hook
) (f
);
1378 if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1379 pause
= update_frame (selected_frame
, 0, 0);
1383 /* We may have called echo_area_display at the top of this
1384 function. If the echo area is on another frame, that may
1385 have put text on a frame other than the selected one, so the
1386 above call to update_frame would not have caught it. Catch
1389 Lisp_Object mini_window
;
1390 FRAME_PTR mini_frame
;
1392 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
1393 mini_frame
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
1395 if (mini_frame
!= selected_frame
&& FRAME_WINDOW_P (mini_frame
))
1396 pause
|= update_frame (mini_frame
, 0, 0);
1400 /* If frame does not match, prevent doing single-line-update next time.
1401 Also, don't forget to check every line to update the arrow. */
1404 this_line_bufpos
= 0;
1405 if (!NILP (last_arrow_position
))
1407 last_arrow_position
= Qt
;
1408 last_arrow_string
= Qt
;
1410 /* If we pause after scrolling, some lines in current_frame
1411 may be null, so preserve_other_columns won't be able to
1412 preserve all the vertical-bar separators. So, avoid using it
1414 if (!WINDOW_FULL_WIDTH_P (w
))
1415 update_mode_lines
= 1;
1418 /* Now text on frame agrees with windows, so
1419 put info into the windows for partial redisplay to follow */
1423 register struct buffer
*b
= XBUFFER (w
->buffer
);
1425 blank_end_of_window
= 0;
1426 unchanged_modified
= BUF_MODIFF (b
);
1427 overlay_unchanged_modified
= BUF_OVERLAY_MODIFF (b
);
1428 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
1429 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
1431 XSETFASTINT (w
->last_point
, BUF_PT (b
));
1432 XSETFASTINT (w
->last_point_x
, FRAME_CURSOR_X (selected_frame
));
1433 XSETFASTINT (w
->last_point_y
, FRAME_CURSOR_Y (selected_frame
));
1436 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
1439 b
->clip_changed
= 0;
1440 w
->update_mode_line
= Qnil
;
1441 XSETFASTINT (w
->last_modified
, BUF_MODIFF (b
));
1442 XSETFASTINT (w
->last_overlay_modified
, BUF_OVERLAY_MODIFF (b
));
1444 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1447 /* Record if we are showing a region, so can make sure to
1448 update it fully at next redisplay. */
1449 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1450 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1451 || highlight_nonselected_windows
)
1452 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1453 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1456 w
->window_end_valid
= w
->buffer
;
1457 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1458 last_arrow_string
= Voverlay_arrow_string
;
1459 if (do_verify_charstarts
)
1460 verify_charstarts (w
);
1461 if (frame_up_to_date_hook
!= 0)
1462 (*frame_up_to_date_hook
) (selected_frame
);
1464 update_mode_lines
= 0;
1465 windows_or_buffers_changed
= 0;
1468 /* Start SIGIO interrupts coming again.
1469 Having them off during the code above
1470 makes it less likely one will discard output,
1471 but not impossible, since there might be stuff
1472 in the system buffer here.
1473 But it is much hairier to try to do anything about that. */
1475 if (interrupt_input
)
1479 /* If something has become visible now which was not before,
1480 redisplay again, so that we get them. */
1483 Lisp_Object tail
, frame
;
1486 FOR_EACH_FRAME (tail
, frame
)
1488 int this_is_visible
= 0;
1490 if (XFRAME (frame
)->visible
)
1491 this_is_visible
= 1;
1492 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1493 if (XFRAME (frame
)->visible
)
1494 this_is_visible
= 1;
1496 if (this_is_visible
)
1500 if (new_count
!= number_of_visible_frames
)
1501 windows_or_buffers_changed
++;
1504 /* Change frame size now if a change is pending. */
1505 do_pending_window_change ();
1507 /* If we just did a pending size change, or have additional
1508 visible frames, redisplay again. */
1509 if (windows_or_buffers_changed
&& !pause
)
1513 /* Redisplay, but leave alone any recent echo area message
1514 unless another message has been requested in its place.
1516 This is useful in situations where you need to redisplay but no
1517 user action has occurred, making it inappropriate for the message
1518 area to be cleared. See tracking_off and
1519 wait_reading_process_input for examples of these situations. */
1522 redisplay_preserve_echo_area ()
1524 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
1526 echo_area_glyphs
= previous_echo_glyphs
;
1527 redisplay_internal (1);
1528 echo_area_glyphs
= 0;
1531 redisplay_internal (1);
1535 mark_window_display_accurate (window
, flag
)
1539 register struct window
*w
;
1541 for (;!NILP (window
); window
= w
->next
)
1543 if (!WINDOWP (window
)) abort ();
1544 w
= XWINDOW (window
);
1546 if (!NILP (w
->buffer
))
1548 XSETFASTINT (w
->last_modified
,
1549 !flag
? 0 : BUF_MODIFF (XBUFFER (w
->buffer
)));
1550 XSETFASTINT (w
->last_overlay_modified
,
1551 !flag
? 0 : BUF_OVERLAY_MODIFF (XBUFFER (w
->buffer
)));
1553 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1556 /* Record if we are showing a region, so can make sure to
1557 update it fully at next redisplay. */
1558 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1559 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1560 || highlight_nonselected_windows
)
1561 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1562 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1566 w
->window_end_valid
= w
->buffer
;
1567 w
->update_mode_line
= Qnil
;
1568 if (!NILP (w
->buffer
) && flag
)
1569 XBUFFER (w
->buffer
)->clip_changed
= 0;
1571 if (!NILP (w
->vchild
))
1572 mark_window_display_accurate (w
->vchild
, flag
);
1573 if (!NILP (w
->hchild
))
1574 mark_window_display_accurate (w
->hchild
, flag
);
1579 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1580 last_arrow_string
= Voverlay_arrow_string
;
1584 /* t is unequal to any useful value of Voverlay_arrow_... */
1585 last_arrow_position
= Qt
;
1586 last_arrow_string
= Qt
;
1590 /* Update the menu bar item list for frame F.
1591 This has to be done before we start to fill in any display lines,
1592 because it can call eval.
1594 If SAVE_MATCH_DATA is 1, we must save and restore it here. */
1597 update_menu_bar (f
, save_match_data
)
1599 int save_match_data
;
1601 struct buffer
*old
= current_buffer
;
1603 register struct window
*w
;
1605 window
= FRAME_SELECTED_WINDOW (f
);
1606 w
= XWINDOW (window
);
1608 if (update_mode_lines
)
1609 w
->update_mode_line
= Qt
;
1611 if (FRAME_WINDOW_P (f
)
1613 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1614 FRAME_EXTERNAL_MENU_BAR (f
)
1616 FRAME_MENU_BAR_LINES (f
) > 0
1618 : FRAME_MENU_BAR_LINES (f
) > 0)
1620 /* If the user has switched buffers or windows, we need to
1621 recompute to reflect the new bindings. But we'll
1622 recompute when update_mode_lines is set too; that means
1623 that people can use force-mode-line-update to request
1624 that the menu bar be recomputed. The adverse effect on
1625 the rest of the redisplay algorithm is about the same as
1626 windows_or_buffers_changed anyway. */
1627 if (windows_or_buffers_changed
1628 || !NILP (w
->update_mode_line
)
1629 || ((BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1630 < BUF_MODIFF (XBUFFER (w
->buffer
)))
1631 != !NILP (w
->last_had_star
))
1632 || ((!NILP (Vtransient_mark_mode
)
1633 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1634 != !NILP (w
->region_showing
)))
1636 struct buffer
*prev
= current_buffer
;
1637 int count
= specpdl_ptr
- specpdl
;
1639 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1640 if (save_match_data
)
1641 record_unwind_protect (Fset_match_data
, Fmatch_data (Qnil
, Qnil
));
1642 if (NILP (Voverriding_local_map_menu_flag
))
1644 specbind (Qoverriding_terminal_local_map
, Qnil
);
1645 specbind (Qoverriding_local_map
, Qnil
);
1648 /* Run the Lucid hook. */
1649 call1 (Vrun_hooks
, Qactivate_menubar_hook
);
1650 /* If it has changed current-menubar from previous value,
1651 really recompute the menubar from the value. */
1652 if (! NILP (Vlucid_menu_bar_dirty_flag
))
1653 call0 (Qrecompute_lucid_menubar
);
1654 safe_run_hooks (Qmenu_bar_update_hook
);
1655 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
1656 /* Redisplay the menu bar in case we changed it. */
1657 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1658 if (FRAME_WINDOW_P (f
))
1659 set_frame_menubar (f
, 0, 0);
1661 /* On a terminal screen, the menu bar is an ordinary screen
1662 line, and this makes it get updated. */
1663 w
->update_mode_line
= Qt
;
1664 #else /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1665 /* In the non-toolkit version, the menu bar is an ordinary screen
1666 line, and this makes it get updated. */
1667 w
->update_mode_line
= Qt
;
1668 #endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1670 unbind_to (count
, Qnil
);
1671 set_buffer_internal_1 (prev
);
1678 /* Redisplay WINDOW and its subwindows and siblings. */
1681 redisplay_windows (window
, preserve_echo_area
)
1683 int preserve_echo_area
;
1685 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1686 redisplay_window (window
, 0, preserve_echo_area
);
1689 /* Return value in display table DP (Lisp_Char_Table *) for character
1690 C. Since a display table doesn't have any parent, we don't have to
1691 follow parent. Do not call this function directly but use the
1692 macro DISP_CHAR_VECTOR. */
1694 disp_char_vector (dp
, c
)
1695 struct Lisp_Char_Table
*dp
;
1701 if (SINGLE_BYTE_CHAR_P (c
)) return (dp
->contents
[c
]);
1703 SPLIT_NON_ASCII_CHAR (c
, code
[0], code
[1], code
[2]);
1704 if (code
[0] != CHARSET_COMPOSITION
)
1706 if (code
[1] < 32) code
[1] = -1;
1707 else if (code
[2] < 32) code
[2] = -1;
1709 /* Here, the possible range of CODE[0] (== charset ID) is
1710 128..MAX_CHARSET. Since the top level char table contains data
1711 for multibyte characters after 256th element, we must increment
1712 CODE[0] by 128 to get a correct index. */
1714 code
[3] = -1; /* anchor */
1716 for (i
= 0; code
[i
] >= 0; i
++, dp
= XCHAR_TABLE (val
))
1718 val
= dp
->contents
[code
[i
]];
1719 if (!SUB_CHAR_TABLE_P (val
))
1720 return (NILP (val
) ? dp
->defalt
: val
);
1722 /* Here, VAL is a sub char table. We return the default value of it. */
1723 return (dp
->defalt
);
1726 /* Redisplay window WINDOW and its subwindows. */
1729 redisplay_window (window
, just_this_one
, preserve_echo_area
)
1731 int just_this_one
, preserve_echo_area
;
1733 register struct window
*w
= XWINDOW (window
);
1734 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1737 int lpoint_byte
= PT_BYTE
;
1738 struct buffer
*old
= current_buffer
;
1739 register int width
= window_internal_width (w
) - 1;
1740 register int startp
, startp_byte
;
1741 register int hscroll
= XINT (w
->hscroll
);
1742 struct position pos
;
1744 int opoint_byte
= PT_BYTE
;
1746 int update_mode_line
;
1747 struct Lisp_Char_Table
*dp
= window_display_table (w
);
1748 int really_switched_buffer
= 0;
1749 int count
= specpdl_ptr
- specpdl
;
1751 if (Z
== Z_BYTE
&& lpoint
!= lpoint_byte
)
1753 if (lpoint_byte
< lpoint
)
1756 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1758 /* If this is a combination window, do its children; that's all. */
1760 if (!NILP (w
->vchild
))
1762 redisplay_windows (w
->vchild
, preserve_echo_area
);
1765 if (!NILP (w
->hchild
))
1767 redisplay_windows (w
->hchild
, preserve_echo_area
);
1770 if (NILP (w
->buffer
))
1773 specbind (Qinhibit_point_motion_hooks
, Qt
);
1775 height
= window_internal_height (w
);
1776 update_mode_line
= (!NILP (w
->update_mode_line
) || update_mode_lines
);
1777 if (XBUFFER (w
->buffer
)->clip_changed
)
1778 update_mode_line
= 1;
1780 if (MINI_WINDOW_P (w
))
1782 if (w
== XWINDOW (echo_area_window
) && echo_area_glyphs
)
1783 /* We've already displayed the echo area glyphs in this window. */
1784 goto finish_scroll_bars
;
1785 else if (w
!= XWINDOW (minibuf_window
))
1787 /* This is a minibuffer, but it's not the currently active one,
1789 int vpos
= XFASTINT (w
->top
);
1792 for (i
= 0; i
< height
; i
++)
1794 get_display_line (f
, vpos
+ i
, 0);
1795 display_string (w
, vpos
+ i
, "", 0,
1796 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
1800 goto finish_scroll_bars
;
1804 /* Otherwise set up data on this window; select its buffer and point value */
1806 if (update_mode_line
)
1807 /* Really select the buffer, for the sake of buffer-local variables. */
1809 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1810 really_switched_buffer
= 1;
1813 set_buffer_temp (XBUFFER (w
->buffer
));
1816 opoint_byte
= PT_BYTE
;
1818 if (Z
== Z_BYTE
&& opoint
!= opoint_byte
)
1820 if (opoint_byte
< opoint
)
1823 /* If %c is in mode line, update it if needed. */
1824 if (!NILP (w
->column_number_displayed
)
1825 /* This alternative quickly identifies a common case
1826 where no change is needed. */
1827 && !(PT
== XFASTINT (w
->last_point
)
1828 && XFASTINT (w
->last_modified
) >= MODIFF
1829 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1830 && XFASTINT (w
->column_number_displayed
) != current_column ())
1831 update_mode_line
= 1;
1833 /* Count number of windows showing the selected buffer.
1834 An indirect buffer counts as its base buffer. */
1838 struct buffer
*current_base
, *window_base
;
1839 current_base
= current_buffer
;
1840 window_base
= XBUFFER (XWINDOW (selected_window
)->buffer
);
1841 if (current_base
->base_buffer
)
1842 current_base
= current_base
->base_buffer
;
1843 if (window_base
->base_buffer
)
1844 window_base
= window_base
->base_buffer
;
1845 if (current_base
== window_base
)
1849 /* POINT refers normally to the selected window.
1850 For any other window, set up appropriate value. */
1852 if (!EQ (window
, selected_window
))
1854 int new_pt
= XMARKER (w
->pointm
)->charpos
;
1855 int new_pt_byte
= marker_byte_position (w
->pointm
);
1859 new_pt_byte
= BEGV_BYTE
;
1860 set_marker_both (w
->pointm
, Qnil
, BEGV
, BEGV_BYTE
);
1862 else if (new_pt
> (ZV
- 1))
1865 new_pt_byte
= ZV_BYTE
;
1866 set_marker_both (w
->pointm
, Qnil
, ZV
, ZV_BYTE
);
1868 /* We don't use SET_PT so that the point-motion hooks don't run. */
1869 TEMP_SET_PT_BOTH (new_pt
, new_pt_byte
);
1872 /* If any of the character widths specified in the display table
1873 have changed, invalidate the width run cache. It's true that this
1874 may be a bit late to catch such changes, but the rest of
1875 redisplay goes (non-fatally) haywire when the display table is
1876 changed, so why should we worry about doing any better? */
1877 if (current_buffer
->width_run_cache
)
1879 struct Lisp_Char_Table
*disptab
= buffer_display_table ();
1881 if (! disptab_matches_widthtab (disptab
,
1882 XVECTOR (current_buffer
->width_table
)))
1884 invalidate_region_cache (current_buffer
,
1885 current_buffer
->width_run_cache
,
1887 recompute_width_table (current_buffer
, disptab
);
1891 /* If window-start is screwed up, choose a new one. */
1892 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1895 startp
= marker_position (w
->start
);
1896 startp_byte
= marker_byte_position (w
->start
);
1898 /* If someone specified a new starting point but did not insist,
1899 check whether it can be used. */
1900 if (!NILP (w
->optional_new_start
)
1901 && startp
>= BEGV
&& startp
<= ZV
)
1903 w
->optional_new_start
= Qnil
;
1904 /* Check whether this start pos is usable given where point is. */
1906 pos
= *compute_motion (startp
, 0,
1907 (((EQ (window
, minibuf_window
)
1909 ? minibuf_prompt_width
: 0)
1910 + (hscroll
? 1 - hscroll
: 0)),
1913 /* BUG FIX: See the comment of
1914 Fpos_visible_in_window_p (window.c). */
1915 - (1 << (BITS_PER_SHORT
- 1)),
1917 pos_tab_offset (w
, startp
, startp_byte
), w
);
1918 /* If PT does fit on the screen, we will use this start pos,
1919 so do so by setting force_start. */
1920 if (pos
.bufpos
== PT
)
1921 w
->force_start
= Qt
;
1924 /* Handle case where place to start displaying has been specified,
1925 unless the specified location is outside the accessible range. */
1926 if (!NILP (w
->force_start
))
1928 w
->force_start
= Qnil
;
1929 /* Forget any recorded base line for line number display. */
1930 w
->base_line_number
= Qnil
;
1931 /* Redisplay the mode line. Select the buffer properly for that.
1932 Also, run the hook window-scroll-functions
1933 because we have scrolled. */
1934 /* Note, we do this after clearing force_start because
1935 if there's an error, it is better to forget about force_start
1936 than to get into an infinite loop calling the hook functions
1937 and having them get more errors. */
1938 if (!update_mode_line
1939 || ! NILP (Vwindow_scroll_functions
))
1941 Lisp_Object temp
[3];
1943 if (!really_switched_buffer
)
1945 set_buffer_temp (old
);
1946 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1948 really_switched_buffer
= 1;
1949 update_mode_line
= 1;
1950 w
->update_mode_line
= Qt
;
1951 if (! NILP (Vwindow_scroll_functions
))
1953 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
1954 make_number (startp
));
1955 startp
= marker_position (w
->start
);
1956 startp_byte
= marker_byte_position (w
->start
);
1959 XSETFASTINT (w
->last_modified
, 0);
1960 XSETFASTINT (w
->last_overlay_modified
, 0);
1961 if (startp
< BEGV
) startp
= BEGV
, startp_byte
= BEGV_BYTE
;
1962 if (startp
> ZV
) startp
= ZV
, startp
= ZV_BYTE
;
1963 try_window (window
, startp
);
1964 if (cursor_vpos
< 0)
1966 /* If point does not appear, move point so it does appear */
1967 pos
= *compute_motion (startp
, 0,
1968 (((EQ (window
, minibuf_window
)
1970 ? minibuf_prompt_width
: 0)
1971 + (hscroll
? 1 - hscroll
: 0)),
1974 - (1 << (BITS_PER_SHORT
- 1)),
1976 pos_tab_offset (w
, startp
, startp_byte
),
1978 TEMP_SET_PT_BOTH (pos
.bufpos
, pos
.bytepos
);
1979 if (w
!= XWINDOW (selected_window
))
1980 set_marker_both (w
->pointm
, Qnil
, PT
, PT_BYTE
);
1983 if (current_buffer
== old
)
1986 lpoint_byte
= PT_BYTE
;
1988 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
1989 + minmax (0, pos
.hpos
, width
));
1990 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1992 /* If we are highlighting the region,
1993 then we just changed the region, so redisplay to show it. */
1994 if (!NILP (Vtransient_mark_mode
)
1995 && !NILP (current_buffer
->mark_active
))
1997 cancel_my_columns (XWINDOW (window
));
1998 try_window (window
, startp
);
2004 /* Handle case where text has not changed, only point,
2005 and it has not moved off the frame. */
2007 /* This code is not used for minibuffer for the sake of
2008 the case of redisplaying to replace an echo area message;
2009 since in that case the minibuffer contents per se are usually unchanged.
2010 This code is of no real use in the minibuffer since
2011 the handling of this_line_bufpos, etc.,
2012 in redisplay handles the same cases. */
2014 if (XFASTINT (w
->last_modified
) >= MODIFF
2015 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
2016 && PT
>= startp
&& !current_buffer
->clip_changed
2017 && (just_this_one
|| WINDOW_FULL_WIDTH_P (w
))
2018 /* If force-mode-line-update was called, really redisplay;
2019 that's how redisplay is forced after e.g. changing
2020 buffer-invisibility-spec. */
2021 && NILP (w
->update_mode_line
)
2022 /* Can't use this case if highlighting a region. */
2023 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
2024 && NILP (w
->region_showing
)
2025 /* If end pos is out of date, scroll bar and percentage will be wrong */
2026 && INTEGERP (w
->window_end_vpos
)
2027 && XFASTINT (w
->window_end_vpos
) < XFASTINT (w
->height
)
2028 && !EQ (window
, minibuf_window
)
2029 && (!MARKERP (Voverlay_arrow_position
)
2030 || current_buffer
!= XMARKER (Voverlay_arrow_position
)->buffer
))
2032 /* All positions in this clause are relative to the window edge. */
2034 int this_scroll_margin
= scroll_margin
;
2035 int last_point_y
= XFASTINT (w
->last_point_y
) - XINT (w
->top
);
2036 int last_point_x
= (XFASTINT (w
->last_point_x
) - WINDOW_LEFT_MARGIN (w
));
2038 /* Find where PT is located now on the frame. */
2039 /* Check just_this_one as a way of verifying that the
2040 window edges have not changed. */
2041 if (PT
== XFASTINT (w
->last_point
) && just_this_one
2042 /* If CURSOR_IN_ECHO_AREA, last_point_x and last_point_y
2043 refer to the echo area and are not related to this window. */
2044 && ! cursor_in_echo_area
)
2046 pos
.hpos
= last_point_x
;
2047 pos
.vpos
= last_point_y
;
2050 else if (PT
> XFASTINT (w
->last_point
)
2051 && ! cursor_in_echo_area
2052 && XFASTINT (w
->last_point
) > startp
&& just_this_one
2053 /* We can't use this if point is in the left margin of a
2054 hscrolled window, because w->last_point_x has been
2055 clipped to the window edges. */
2056 && !(last_point_x
<= 0 && hscroll
))
2058 int last_point
= XFASTINT (w
->last_point
);
2059 int last_point_byte
= CHAR_TO_BYTE (last_point
);
2060 int tab_offset
= (pos_tab_offset (w
, last_point
, last_point_byte
)
2061 - (last_point_x
+ hscroll
- !! hscroll
));
2063 pos
= *compute_motion (last_point
, last_point_y
, last_point_x
, 0,
2065 /* BUG FIX: See the comment of
2066 Fpos_visible_in_window_p (window.c). */
2067 - (1 << (BITS_PER_SHORT
- 1)),
2074 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0), 0,
2076 /* BUG FIX: See the comment of
2077 Fpos_visible_in_window_p (window.c). */
2078 - (1 << (BITS_PER_SHORT
- 1)),
2080 pos_tab_offset (w
, startp
, startp_byte
),
2084 /* Don't use a scroll margin that is negative or too large. */
2085 if (this_scroll_margin
< 0)
2086 this_scroll_margin
= 0;
2088 if (XINT (w
->height
) < 4 * scroll_margin
)
2089 this_scroll_margin
= XINT (w
->height
) / 4;
2091 /* If point fits on the screen, and not within the scroll margin,
2093 if (pos
.vpos
< height
- this_scroll_margin
2094 && (pos
.vpos
>= this_scroll_margin
|| startp
== BEGV
))
2096 /* Ok, point is still on frame */
2097 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2099 /* These variables are supposed to be origin 1 */
2100 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
2101 + minmax (0, pos
.hpos
, width
));
2102 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
2104 /* This doesn't do the trick, because if a window to the right of
2105 this one must be redisplayed, this does nothing because there
2106 is nothing in DesiredFrame yet, and then the other window is
2107 redisplayed, making likes that are empty in this window's columns.
2108 if (WINDOW_FULL_WIDTH_P (w))
2109 preserve_my_columns (w);
2111 if (current_buffer
->clip_changed
2112 && ! NILP (Vwindow_scroll_functions
))
2113 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2114 make_number (marker_position (w
->start
)));
2118 /* Don't bother trying redisplay with same start;
2119 we already know it will lose. */
2121 /* If current starting point was originally the beginning of a line
2122 but no longer is, find a new starting point. */
2123 else if (!NILP (w
->start_at_line_beg
)
2125 || FETCH_BYTE (startp_byte
- 1) == '\n'))
2129 else if (just_this_one
&& !MINI_WINDOW_P (w
)
2131 && XFASTINT (w
->last_modified
)
2132 /* or else vmotion on first line won't work. */
2133 && ! NILP (w
->start_at_line_beg
)
2134 && ! EQ (w
->window_end_valid
, Qnil
)
2135 && do_id
&& !current_buffer
->clip_changed
2136 && !blank_end_of_window
2137 && WINDOW_FULL_WIDTH_P (w
)
2138 /* Can't use this case if highlighting a region. */
2139 && !(!NILP (Vtransient_mark_mode
)
2140 && !NILP (current_buffer
->mark_active
))
2141 /* Don't use try_window_id if newline
2142 doesn't display as the end of a line. */
2143 && !(dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, '\n')))
2144 && NILP (w
->region_showing
)
2145 && EQ (last_arrow_position
, COERCE_MARKER (Voverlay_arrow_position
))
2146 && EQ (last_arrow_string
, Voverlay_arrow_string
)
2147 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
2150 /* tem > 0 means success. tem == -1 means choose new start.
2151 tem == -2 means try again with same start,
2152 and nothing but whitespace follows the changed stuff.
2153 tem == 0 means try again with same start. */
2157 else if (startp
>= BEGV
&& startp
<= ZV
2159 /* Avoid starting at end of buffer. */
2160 #if 0 /* This change causes trouble for M-! finger & RET.
2161 It will have to be considered later. */
2162 || ! EQ (window
, selected_window
)
2163 /* Don't do the recentering if redisplay
2164 is not for no user action. */
2165 || preserve_echo_area
2168 || (XFASTINT (w
->last_modified
) >= MODIFF
2169 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)))
2171 /* Try to redisplay starting at same place as before */
2172 /* If point has not moved off frame, accept the results */
2173 try_window (window
, startp
);
2174 if (cursor_vpos
>= 0)
2176 if (!just_this_one
|| current_buffer
->clip_changed
2177 || beg_unchanged
< startp
)
2178 /* Forget any recorded base line for line number display. */
2179 w
->base_line_number
= Qnil
;
2181 if (current_buffer
->clip_changed
2182 && ! NILP (Vwindow_scroll_functions
))
2183 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2184 make_number (marker_position (w
->start
)));
2189 cancel_my_columns (w
);
2192 XSETFASTINT (w
->last_modified
, 0);
2193 XSETFASTINT (w
->last_overlay_modified
, 0);
2194 /* Redisplay the mode line. Select the buffer properly for that. */
2195 if (!update_mode_line
)
2197 if (!really_switched_buffer
)
2199 set_buffer_temp (old
);
2200 set_buffer_internal_1 (XBUFFER (w
->buffer
));
2202 update_mode_line
= 1;
2203 w
->update_mode_line
= Qt
;
2206 /* Try to scroll by specified few lines */
2208 if ((scroll_conservatively
|| scroll_step
)
2209 && !current_buffer
->clip_changed
2210 && startp
>= BEGV
&& startp
<= ZV
)
2212 int this_scroll_margin
= scroll_margin
;
2213 int scroll_margin_pos
, scroll_margin_bytepos
;
2214 int scroll_max
= scroll_step
;
2215 if (scroll_conservatively
)
2216 scroll_max
= scroll_conservatively
;
2218 /* Don't use a scroll margin that is negative or too large. */
2219 if (this_scroll_margin
< 0)
2220 this_scroll_margin
= 0;
2222 if (XINT (w
->height
) < 4 * this_scroll_margin
)
2223 this_scroll_margin
= XINT (w
->height
) / 4;
2225 scroll_margin_pos
= Z
- XFASTINT (w
->window_end_pos
);
2226 if (this_scroll_margin
)
2228 pos
= *vmotion (scroll_margin_pos
, -this_scroll_margin
, w
);
2229 scroll_margin_pos
= pos
.bufpos
;
2230 scroll_margin_bytepos
= pos
.bytepos
;
2233 scroll_margin_bytepos
= CHAR_TO_BYTE (scroll_margin_pos
);
2235 if (PT
>= scroll_margin_pos
)
2237 struct position pos
;
2238 pos
= *compute_motion (scroll_margin_pos
, 0, 0, 0,
2239 PT
, XFASTINT (w
->height
), 0,
2240 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2241 pos_tab_offset (w
, scroll_margin_pos
,
2242 scroll_margin_bytepos
),
2244 if (pos
.vpos
>= scroll_max
)
2247 pos
= *vmotion (startp
,
2248 scroll_conservatively
? pos
.vpos
+ 1 : scroll_step
,
2251 if (! NILP (Vwindow_scroll_functions
))
2253 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2254 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2255 make_number (pos
.bufpos
));
2256 pos
.bufpos
= marker_position (w
->start
);
2258 try_window (window
, pos
.bufpos
);
2259 if (cursor_vpos
>= 0)
2261 if (!just_this_one
|| current_buffer
->clip_changed
2262 || beg_unchanged
< startp
)
2263 /* Forget any recorded base line for line number display. */
2264 w
->base_line_number
= Qnil
;
2268 cancel_my_columns (w
);
2271 scroll_margin_pos
= startp
;
2272 if (this_scroll_margin
)
2274 pos
= *vmotion (scroll_margin_pos
, this_scroll_margin
, w
);
2275 scroll_margin_pos
= pos
.bufpos
;
2277 if (PT
< scroll_margin_pos
)
2279 struct position pos
;
2280 pos
= *compute_motion (PT
, 0, 0, 0,
2281 scroll_margin_pos
, XFASTINT (w
->height
), 0,
2282 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2283 pos_tab_offset (w
, PT
, PT_BYTE
),
2285 if (pos
.vpos
> scroll_max
)
2288 pos
= *vmotion (startp
,
2289 scroll_conservatively
? -pos
.vpos
: - scroll_step
,
2292 if (! NILP (Vwindow_scroll_functions
))
2294 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2295 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2296 make_number (pos
.bufpos
));
2297 pos
.bufpos
= marker_position (w
->start
);
2299 try_window (window
, pos
.bufpos
);
2300 if (cursor_vpos
>= 0)
2302 if (!just_this_one
|| current_buffer
->clip_changed
2303 || beg_unchanged
< startp
)
2304 /* Forget any recorded base line for line number display. */
2305 w
->base_line_number
= Qnil
;
2309 cancel_my_columns (w
);
2315 if (scroll_step
&& ! scroll_margin
&& !current_buffer
->clip_changed
2316 && startp
>= BEGV
&& startp
<= ZV
)
2318 if (margin_call
== 0)
2319 margin_call
= (PT
> startp
? 1 : -1);
2320 if (margin_call
> 0)
2322 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), scroll_step
, w
);
2323 if (pos
.vpos
>= height
)
2327 pos
= *vmotion (startp
, (margin_call
< 0 ? - scroll_step
: scroll_step
),
2330 if (PT
>= pos
.bufpos
)
2332 if (! NILP (Vwindow_scroll_functions
))
2334 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2335 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2336 make_number (pos
.bufpos
));
2337 pos
.bufpos
= marker_position (w
->start
);
2339 try_window (window
, pos
.bufpos
);
2340 if (cursor_vpos
>= 0)
2342 if (!just_this_one
|| current_buffer
->clip_changed
2343 || beg_unchanged
< startp
)
2344 /* Forget any recorded base line for line number display. */
2345 w
->base_line_number
= Qnil
;
2349 cancel_my_columns (w
);
2355 /* Finally, just choose place to start which centers point */
2358 /* Forget any previously recorded base line for line number display. */
2359 w
->base_line_number
= Qnil
;
2361 pos
= *vmotion (PT
, - (height
/ 2), w
);
2363 /* The minibuffer is often just one line. Ordinary scrolling
2364 gives little overlap and looks bad. So show 20 chars before point. */
2366 && (pos
.bufpos
>= PT
- minibuffer_scroll_overlap
2367 /* If we scrolled less than 1/2 line forward, we will
2368 get too much overlap, so change to the usual amount. */
2369 || pos
.bufpos
< startp
+ width
/ 2)
2370 && PT
> BEGV
+ minibuffer_scroll_overlap
2371 /* If we scrolled to an actual line boundary,
2372 that's different; don't ignore line boundaries. */
2373 && FETCH_BYTE (pos
.bytepos
- 1) != '\n')
2375 pos
.bufpos
= PT
- minibuffer_scroll_overlap
;
2376 pos
.bytepos
= CHAR_TO_BYTE (pos
.bufpos
);
2379 /* Set startp here explicitly in case that helps avoid an infinite loop
2380 in case the window-scroll-functions functions get errors. */
2381 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2382 if (! NILP (Vwindow_scroll_functions
))
2384 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2385 make_number (pos
.bufpos
));
2386 pos
.bufpos
= marker_position (w
->start
);
2387 pos
.bytepos
= marker_byte_position (w
->start
);
2389 try_window (window
, pos
.bufpos
);
2391 startp
= marker_position (w
->start
);
2392 startp_byte
= marker_byte_position (w
->start
);
2393 w
->start_at_line_beg
2394 = (startp
== BEGV
|| FETCH_BYTE (startp_byte
- 1) == '\n') ? Qt
: Qnil
;
2397 if ((update_mode_line
2398 /* If window not full width, must redo its mode line
2399 if the window to its side is being redone */
2400 || (!just_this_one
&& !WINDOW_FULL_WIDTH_P (w
))
2401 || INTEGERP (w
->base_line_pos
)
2402 || (!NILP (w
->column_number_displayed
)
2403 && XFASTINT (w
->column_number_displayed
) != current_column ()))
2404 && height
!= XFASTINT (w
->height
))
2406 FRAME_PTR oframe
= selected_frame
;
2407 if (!really_switched_buffer
)
2409 set_buffer_temp (old
);
2410 set_buffer_internal_1 (XBUFFER (w
->buffer
));
2411 really_switched_buffer
= 1;
2414 display_mode_line (w
);
2415 selected_frame
= oframe
;
2417 if (! line_number_displayed
2418 && ! BUFFERP (w
->base_line_pos
))
2420 w
->base_line_pos
= Qnil
;
2421 w
->base_line_number
= Qnil
;
2424 /* When we reach a frame's selected window, redo the frame's menu bar. */
2425 if (update_mode_line
2426 && (FRAME_WINDOW_P (f
)
2428 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2429 FRAME_EXTERNAL_MENU_BAR (f
)
2431 FRAME_MENU_BAR_LINES (f
) > 0
2433 : FRAME_MENU_BAR_LINES (f
) > 0)
2434 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
2435 display_menu_bar (w
);
2438 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2440 int start
, end
, whole
;
2442 /* Calculate the start and end positions for the current window.
2443 At some point, it would be nice to choose between scrollbars
2444 which reflect the whole buffer size, with special markers
2445 indicating narrowing, and scrollbars which reflect only the
2448 Note that minibuffers sometimes aren't displaying any text. */
2449 if (! MINI_WINDOW_P (w
)
2450 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
2453 start
= marker_position (w
->start
) - BEGV
;
2454 /* I don't think this is guaranteed to be right. For the
2455 moment, we'll pretend it is. */
2456 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
2458 if (end
< start
) end
= start
;
2459 if (whole
< (end
- start
)) whole
= end
- start
;
2462 start
= end
= whole
= 0;
2464 /* Indicate what this scroll bar ought to be displaying now. */
2465 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
2467 /* Note that we actually used the scroll bar attached to this window,
2468 so it shouldn't be deleted at the end of redisplay. */
2469 (*redeem_scroll_bar_hook
) (w
);
2472 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
2473 if (really_switched_buffer
)
2474 set_buffer_internal_1 (old
);
2476 set_buffer_temp (old
);
2477 TEMP_SET_PT_BOTH (lpoint
, lpoint_byte
);
2479 unbind_to (count
, Qnil
);
2482 /* Do full redisplay on one window, starting at position `pos'. */
2485 try_window (window
, pos
)
2489 register struct window
*w
= XWINDOW (window
);
2490 register int height
= window_internal_height (w
);
2491 register int vpos
= XFASTINT (w
->top
);
2492 register int last_text_vpos
= vpos
;
2493 FRAME_PTR f
= XFRAME (w
->frame
);
2494 int width
= window_internal_width (w
) - 1;
2495 struct position val
;
2497 /* POS should never be out of range! */
2498 if (pos
< XBUFFER (w
->buffer
)->begv
2499 || pos
> XBUFFER (w
->buffer
)->zv
)
2502 if (XMARKER (w
->start
)->charpos
!= pos
)
2503 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2506 overlay_arrow_seen
= 0;
2507 zv_strings_seen
= 0;
2508 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2509 val
.ovstring_chars_done
= 0;
2510 val
.bytepos
= marker_byte_position (w
->start
);
2511 val
.tab_offset
= pos_tab_offset (w
, pos
, val
.bytepos
);
2513 while (--height
>= 0)
2515 val
= *display_text_line (w
, pos
, val
.bytepos
, vpos
,
2516 val
.hpos
, val
.tab_offset
,
2517 val
.ovstring_chars_done
);
2518 /* The following code is omitted because we maintain tab_offset
2521 tab_offset
+= width
;
2522 if (val
.vpos
) tab_offset
= 0;
2525 if (pos
!= val
.bufpos
)
2528 #ifdef USE_TEXT_PROPERTIES
2529 Lisp_Object invis_prop
;
2530 invis_prop
= Fget_char_property (make_number (val
.bufpos
- 1),
2531 Qinvisible
, window
);
2532 invis
= TEXT_PROP_MEANS_INVISIBLE (invis_prop
);
2536 /* Next line, unless prev line ended in end of buffer with no cr */
2538 && (FETCH_BYTE (val
.bytepos
- 1) != '\n' || invis
));
2543 /* If last line is continued in middle of character,
2544 include the split character in the text considered on the frame */
2545 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2548 /* If bottom just moved off end of frame, change mode line percentage. */
2549 if (XFASTINT (w
->window_end_pos
) == 0
2551 w
->update_mode_line
= Qt
;
2553 /* Say where last char on frame will be, once redisplay is finished. */
2554 XSETFASTINT (w
->window_end_pos
, Z
- pos
);
2555 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
- XFASTINT (w
->top
));
2556 /* But that is not valid info until redisplay finishes. */
2557 w
->window_end_valid
= Qnil
;
2560 /* Try to redisplay when buffer is modified locally,
2561 computing insert/delete line to preserve text outside
2562 the bounds of the changes.
2563 Return 1 if successful, 0 if if cannot tell what to do,
2564 or -1 to tell caller to find a new window start,
2565 or -2 to tell caller to do normal redisplay with same window start. */
2568 try_window_id (window
)
2572 int opoint
, opoint_byte
;
2573 register struct window
*w
= XWINDOW (window
);
2574 register int height
= window_internal_height (w
);
2575 FRAME_PTR f
= XFRAME (w
->frame
);
2576 int top
= XFASTINT (w
->top
);
2577 int start
= marker_position (w
->start
);
2578 int width
= window_internal_width (w
) - 1;
2579 int hscroll
= XINT (w
->hscroll
);
2580 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
2583 register int i
, tem
;
2584 int last_text_vpos
= 0;
2586 int selective
= (INTEGERP (current_buffer
->selective_display
)
2587 ? XINT (current_buffer
->selective_display
)
2588 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
2589 struct position val
, bp
, ep
, xp
, pp
;
2590 int scroll_amount
= 0;
2594 int start_byte
= marker_byte_position (w
->start
);
2596 if (GPT
- BEG
< beg_unchanged
)
2597 beg_unchanged
= GPT
- BEG
;
2598 if (Z
- GPT
< end_unchanged
)
2599 end_unchanged
= Z
- GPT
;
2601 if (beg_unchanged
+ BEG
< start
)
2602 return 0; /* Give up if changes go above top of window */
2604 /* Find position before which nothing is changed. */
2605 bp
= *compute_motion (start
, 0, lmargin
, 0,
2606 min (ZV
, beg_unchanged
+ BEG
), height
,
2607 /* BUG FIX: See the comment of
2608 Fpos_visible_in_window_p (window.c). */
2609 - (1 << (BITS_PER_SHORT
- 1)),
2611 pos_tab_offset (w
, start
, start_byte
),
2613 if (bp
.vpos
>= height
)
2617 /* All changes are beyond the window end, and point is on the screen.
2618 We don't need to change the text at all.
2619 But we need to update window_end_pos to account for
2620 any change in buffer size. */
2621 bp
= *compute_motion (start
, 0, lmargin
, 0,
2623 /* BUG FIX: See the comment of
2624 Fpos_visible_in_window_p() (window.c). */
2625 - (1 << (BITS_PER_SHORT
- 1)),
2627 pos_tab_offset (w
, start
, start_byte
), w
);
2628 XSETFASTINT (w
->window_end_vpos
, height
);
2629 XSETFASTINT (w
->window_end_pos
, Z
- bp
.bufpos
);
2637 /* Find beginning of that frame line. Must display from there. */
2638 bp
= *vmotion (bp
.bufpos
, 0, w
);
2641 pos_byte
= bp
.bytepos
;
2647 /* If about to start displaying at the beginning of a continuation line,
2648 really start with previous frame line, in case it was not
2649 continued when last redisplayed */
2650 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
2652 /* Likewise if we have to worry about selective display. */
2653 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
2655 bp
= *vmotion (bp
.bufpos
, -1, w
);
2658 pos_byte
= bp
.bytepos
;
2660 val
.tab_offset
= bp
.tab_offset
; /* Update tab offset. */
2662 if (bp
.contin
&& bp
.hpos
!= lmargin
)
2664 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
2665 val
.tab_offset
= bp
.tab_offset
+ bp
.prevhpos
- width
;
2667 DEC_BOTH (pos
, pos_byte
);
2672 /* Find first visible newline after which no more is changed. */
2673 opoint
= PT
, opoint_byte
= PT_BYTE
;
2674 SET_PT (Z
- max (end_unchanged
, Z
- ZV
));
2675 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2677 while (PT
< ZV
- 1 && indented_beyond_p (PT
, PT_BYTE
, selective
))
2678 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2680 SET_PT_BOTH (opoint
, opoint_byte
);
2682 /* Compute the cursor position after that newline. */
2683 ep
= *compute_motion (pos
, vpos
, val
.hpos
, did_motion
, tem
,
2684 height
, - (1 << (BITS_PER_SHORT
- 1)),
2686 /* We have tab offset in VAL, use it. */
2689 /* If changes reach past the text available on the frame,
2690 just display rest of frame. */
2691 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
2694 stop_vpos
= ep
.vpos
;
2696 /* If no newline before ep, the line ep is on includes some changes
2697 that must be displayed. Make sure we don't stop before it. */
2698 /* Also, if changes reach all the way until ep.bufpos,
2699 it is possible that something was deleted after the
2700 newline before it, so the following line must be redrawn. */
2701 if (stop_vpos
== ep
.vpos
2702 && (ep
.bufpos
== BEGV
2703 || FETCH_BYTE (ep
.bytepos
- 1) != '\n'
2704 || ep
.bufpos
== Z
- end_unchanged
))
2705 stop_vpos
= ep
.vpos
+ 1;
2708 overlay_arrow_seen
= 0;
2709 zv_strings_seen
= 0;
2711 /* If changes do not reach to bottom of window,
2712 figure out how much to scroll the rest of the window */
2713 if (stop_vpos
< height
)
2715 /* Now determine how far up or down the rest of the window has moved */
2716 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2717 Z
- XFASTINT (w
->window_end_pos
),
2718 /* Don't care for VPOS... */
2719 1 << (BITS_PER_SHORT
- 1),
2721 1 << (BITS_PER_SHORT
- 1),
2722 width
, hscroll
, ep
.tab_offset
, w
);
2723 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
2725 /* Is everything on frame below the changes whitespace?
2726 If so, no scrolling is really necessary. */
2727 for (i
= ep
.bytepos
; i
< xp
.bytepos
; i
++)
2729 tem
= FETCH_BYTE (i
);
2730 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
2733 if (i
== xp
.bytepos
)
2736 XSETFASTINT (w
->window_end_vpos
,
2737 XFASTINT (w
->window_end_vpos
) + scroll_amount
);
2739 /* Before doing any scrolling, verify that point will be on frame. */
2740 if (PT
> ep
.bufpos
&& !(PT
<= xp
.bufpos
&& xp
.vpos
< height
))
2742 if (PT
<= xp
.bufpos
)
2744 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2745 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2747 /* We have tab offset in EP, use it. */
2752 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
, 1,
2753 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2755 /* We have tab offset in XP, use it. */
2758 if (pp
.bufpos
< PT
|| pp
.vpos
== height
)
2760 cursor_vpos
= pp
.vpos
+ top
;
2761 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, pp
.hpos
, width
);
2764 if (stop_vpos
- scroll_amount
>= height
2765 || ep
.bufpos
== xp
.bufpos
)
2767 if (scroll_amount
< 0)
2768 stop_vpos
-= scroll_amount
;
2770 /* In this path, we have altered window_end_vpos
2771 and not left it negative.
2772 We must make sure that, in case display is preempted
2773 before the frame changes to reflect what we do here,
2774 further updates will not come to try_window_id
2775 and assume the frame and window_end_vpos match. */
2776 blank_end_of_window
= 1;
2778 else if (!scroll_amount
)
2780 /* Even if we don't need to scroll, we must adjust the
2781 charstarts of subsequent lines (that we won't redisplay)
2782 according to the amount of text inserted or deleted. */
2783 int oldpos
= FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2784 int adjust
= ep
.bufpos
- oldpos
;
2785 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1, adjust
);
2787 else if (bp
.bufpos
== Z
- end_unchanged
)
2789 /* If reprinting everything is nearly as fast as scrolling,
2790 don't bother scrolling. Can happen if lines are short. */
2791 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
2792 top
+ height
- max (0, scroll_amount
),
2794 > xp
.bufpos
- bp
.bufpos
- 20)
2795 /* Return "try normal display with same window-start."
2796 Too bad we can't prevent further scroll-thinking. */
2798 /* If pure deletion, scroll up as many lines as possible.
2799 In common case of killing a line, this can save the
2800 following line from being overwritten by scrolling
2801 and therefore having to be redrawn. */
2802 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
2803 top
+ height
- max (0, scroll_amount
),
2804 scroll_amount
, bp
.bufpos
);
2809 /* scroll_frame_lines did not properly adjust subsequent
2810 lines' charstarts in the case where the text of the
2811 screen line at bp.vpos has changed.
2812 (This can happen in a deletion that ends in mid-line.)
2813 To adjust properly, we need to make things consistent
2815 So do a second adjust to make that happen.
2816 Note that stop_vpos >= ep.vpos, so it is sufficient
2817 to update the charstarts for lines at ep.vpos and below. */
2819 = FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2820 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1,
2821 ep
.bufpos
- oldstart
);
2824 else if (scroll_amount
)
2826 /* If reprinting everything is nearly as fast as scrolling,
2827 don't bother scrolling. Can happen if lines are short. */
2828 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
2829 overestimate of cost of reprinting, since xp.bufpos
2830 would end up below the bottom of the window. */
2831 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
2832 top
+ height
- max (0, scroll_amount
),
2834 > xp
.bufpos
- ep
.bufpos
- 20)
2835 /* Return "try normal display with same window-start."
2836 Too bad we can't prevent further scroll-thinking. */
2838 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
2839 top
+ height
- max (0, scroll_amount
),
2840 scroll_amount
, ep
.bufpos
);
2841 if (!tem
) stop_vpos
= height
;
2845 /* In any case, do not display past bottom of window */
2846 if (stop_vpos
>= height
)
2852 /* Handle case where pos is before w->start --
2853 can happen if part of line had been clipped and is not clipped now */
2854 if (vpos
== 0 && pos
< marker_position (w
->start
))
2855 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2857 val
.bytepos
= pos_byte
;
2859 /* Redisplay the lines where the text was changed */
2860 last_text_vpos
= vpos
;
2861 /* The following code is omitted because we maintain tab offset in
2864 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2865 /* If we are starting display in mid-character, correct tab_offset
2866 to account for passing the line that that character really starts in. */
2867 if (val
.hpos
< lmargin
)
2868 tab_offset
+= width
;
2871 while (vpos
< stop_vpos
)
2873 val
= *display_text_line (w
, pos
, val
.bytepos
, top
+ vpos
++,
2874 val
.hpos
, val
.tab_offset
,
2875 val
.ovstring_chars_done
);
2876 /* If display_text_line ran a hook and changed some text,
2877 redisplay all the way to bottom of buffer
2878 So that we show the changes. */
2879 if (old_tick
!= MODIFF
)
2881 /* The following code is omitted because we maintain tab offset
2882 in val.tab_offset. */
2884 tab_offset
+= width
;
2885 if (val
.vpos
) tab_offset
= 0;
2887 if (pos
!= val
.bufpos
)
2889 /* Next line, unless prev line ended in end of buffer with no cr */
2890 = vpos
- (val
.vpos
&& FETCH_BYTE (val
.bytepos
- 1) != '\n');
2894 /* There are two cases:
2895 1) we have displayed down to the bottom of the window
2896 2) we have scrolled lines below stop_vpos by scroll_amount */
2900 /* If last line is continued in middle of character,
2901 include the split character in the text considered on the frame */
2902 if (val
.hpos
< lmargin
)
2904 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
);
2905 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2908 /* If scrolling made blank lines at window bottom,
2909 redisplay to fill those lines */
2910 if (scroll_amount
< 0)
2912 /* Don't consider these lines for general-purpose scrolling.
2913 That will save time in the scrolling computation. */
2914 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
2917 pos_byte
= xp
.bytepos
;
2919 val
.tab_offset
= xp
.tab_offset
;
2921 { /* Display from next line */
2922 vpos
= height
+ scroll_amount
;
2926 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
2928 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
2929 val
.tab_offset
= xp
.tab_offset
+ bp
.prevhpos
- width
;
2930 DEC_BOTH (pos
, pos_byte
);
2933 blank_end_of_window
= 1;
2934 /* The following code is omitted because we maintain tab offset
2935 in val.tab_offset. */
2937 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2938 /* If we are starting display in mid-character, correct tab_offset
2939 to account for passing the line that that character starts in. */
2940 if (val
.hpos
< lmargin
)
2941 tab_offset
+= width
;
2943 val
.bytepos
= pos_byte
;
2944 while (vpos
< height
)
2946 val
= *display_text_line (w
, pos
, val
.bytepos
,
2947 top
+ vpos
++, val
.hpos
,
2948 val
.tab_offset
, val
.ovstring_chars_done
);
2949 /* The following code is omitted because we maintain tab
2950 offset in val.tab_offset. */
2952 tab_offset
+= width
;
2953 if (val
.vpos
) tab_offset
= 0;
2958 /* Here is a case where display_text_line sets cursor_vpos wrong.
2959 Make it be fixed up, below. */
2965 /* If bottom just moved off end of frame, change mode line percentage. */
2966 if (XFASTINT (w
->window_end_pos
) == 0
2968 w
->update_mode_line
= Qt
;
2970 /* Attempt to adjust end-of-text positions to new bottom line */
2973 delta
= height
- xp
.vpos
;
2975 || (delta
> 0 && xp
.bufpos
<= ZV
)
2976 || (delta
== 0 && xp
.hpos
))
2978 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), delta
, w
);
2979 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2980 XSETFASTINT (w
->window_end_vpos
,
2981 XFASTINT (w
->window_end_vpos
) + val
.vpos
);
2985 w
->window_end_valid
= Qnil
;
2987 /* If point was not in a line that was displayed, find it */
2988 if (cursor_vpos
< 0)
2991 val
= *compute_motion (start
, 0, lmargin
, 0, PT
,
2992 /* Don't care for VPOS... */
2993 1 << (BITS_PER_SHORT
- 1),
2995 1 << (BITS_PER_SHORT
- 1),
2997 pos_tab_offset (w
, start
, start_byte
),
2999 /* Admit failure if point is off frame now */
3000 if (val
.vpos
>= height
)
3002 for (vpos
= 0; vpos
< height
; vpos
++)
3003 cancel_line (vpos
+ top
, f
);
3006 cursor_vpos
= val
.vpos
+ top
;
3007 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, val
.hpos
, width
);
3010 FRAME_CURSOR_X (f
) = cursor_hpos
;
3011 FRAME_CURSOR_Y (f
) = cursor_vpos
;
3015 val
= *compute_motion (start
, 0, lmargin
, 0, ZV
,
3016 height
, - (1 << (BITS_PER_SHORT
- 1)),
3018 pos_tab_offset (w
, start
, start_byte
),
3020 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
3022 if (XFASTINT (w
->window_end_pos
)
3030 /* Copy LEN glyphs starting address FROM to the rope TO.
3031 But don't actually copy the parts that would come in before S.
3032 Value is TO, advanced past the copied data.
3033 F is the frame we are displaying in. */
3036 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
3038 register GLYPH
*to
; /* Copy to here. */
3039 register GLYPH
*s
; /* Starting point. */
3040 Lisp_Object
*from
; /* Data to copy. */
3042 int face
; /* Face to apply to glyphs which don't specify one. */
3045 register Lisp_Object
*fp
= from
;
3046 /* These cache the results of the last call to compute_glyph_face. */
3048 int last_merged
= 0;
3051 if (! FRAME_TERMCAP_P (f
))
3054 GLYPH glyph
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
3056 unsigned int c
= FAST_GLYPH_CHAR (glyph
);
3059 /* For an invalid character code, use space. */
3062 if (FAST_GLYPH_FACE (glyph
) == 0)
3063 /* If GLYPH has no face code, use FACE. */
3065 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
3066 /* If it's same as previous glyph, use same result. */
3067 facecode
= last_merged
;
3070 /* Merge this glyph's face and remember the result. */
3071 last_code
= FAST_GLYPH_FACE (glyph
);
3072 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
3076 *to
= FAST_MAKE_GLYPH (c
, facecode
);
3084 if (to
>= s
) *to
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
3091 /* Correct a glyph by replacing its specified user-level face code
3092 with a displayable computed face code. */
3095 fix_glyph (f
, glyph
, cface
)
3101 if (! FRAME_TERMCAP_P (f
))
3103 if (FAST_GLYPH_FACE (glyph
) != 0)
3104 cface
= compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
), cface
);
3105 glyph
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), cface
);
3111 /* Return the column of position POS / POS_BYTE in window W's buffer.
3112 When used on the character at the beginning of a line,
3113 starting at column 0, this says how much to subtract from
3114 the column position of any character in the line
3115 to get its horizontal position on the screen. */
3118 pos_tab_offset (w
, pos
, pos_byte
)
3120 register int pos
, pos_byte
;
3123 int opoint_byte
= PT_BYTE
;
3125 int width
= window_internal_width (w
) - 1;
3128 return MINI_WINDOW_P (w
) ? -minibuf_prompt_width
: 0;
3130 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3133 TEMP_SET_PT_BOTH (pos
, pos_byte
);
3134 col
= current_column ();
3135 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
3140 /* Display one line of window W, starting at char position START in W's buffer.
3141 START_BYTE is the corresponding byte position.
3143 Display starting at horizontal position HPOS, expressed relative to
3144 W's left edge. In situations where the text at START shouldn't
3145 start at the left margin (i.e. when the window is hscrolled, or
3146 we're continuing a line which left off in the midst of a
3147 multi-column character), HPOS should be negative; we throw away
3148 characters up 'til hpos = 0. So, HPOS must take hscrolling into
3151 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
3153 OVSTR_DONE is the number of chars of overlay before/after strings
3154 at this position which have already been processed.
3156 Display on position VPOS on the frame. It is origin 0, relative to
3157 the top of the frame, not W.
3159 Returns a STRUCT POSITION giving character to start next line with
3160 and where to display it, including a zero or negative hpos.
3161 The vpos field is not really a vpos; it is 1 unless the line is continued */
3163 struct position val_display_text_line
;
3165 static struct position
*
3166 display_text_line (w
, start
, start_byte
, vpos
, hpos
, taboffset
, ovstr_done
)
3174 register int pos
= start
;
3175 int pos_byte
= start_byte
;
3178 int pause
, limit_byte
;
3179 register unsigned char *p
;
3181 register GLYPH
*leftmargin
;
3182 register GLYPH
*p1prev
;
3183 register GLYPH
*p1start
;
3184 GLYPH
*p1_wide_column_end
= (GLYPH
*) 0;
3185 int prevpos
, prevpos_byte
;
3187 FRAME_PTR f
= XFRAME (w
->frame
);
3188 int tab_width
= XINT (current_buffer
->tab_width
);
3189 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
3190 int width
= window_internal_width (w
) - 1;
3191 struct position val
;
3192 int lastpos
, lastpos_byte
;
3194 int last_invis_skip
= 0;
3195 Lisp_Object last_invis_prop
;
3196 int hscroll
= XINT (w
->hscroll
);
3197 int truncate
= (hscroll
3198 || (truncate_partial_width_windows
3199 && !WINDOW_FULL_WIDTH_P (w
))
3200 || !NILP (current_buffer
->truncate_lines
));
3202 /* 1 if this buffer has a region to highlight. */
3203 int highlight_region
3204 = (!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
)
3205 && XMARKER (current_buffer
->mark
)->buffer
!= 0);
3206 int region_beg
, region_end
;
3208 int selective
= (INTEGERP (current_buffer
->selective_display
)
3209 ? XINT (current_buffer
->selective_display
)
3210 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
3211 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3212 register struct Lisp_Char_Table
*dp
= window_display_table (w
);
3214 Lisp_Object default_invis_vector
[3];
3215 /* Number of characters of ellipsis to display after an invisible line
3216 if it calls for an ellipsis.
3217 Note that this value can be nonzero regardless of whether
3218 selective display is enabled--you must check that separately. */
3220 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3221 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
3222 : !NILP (current_buffer
->selective_display_ellipses
) ? 3 : 0);
3223 /* This is the sequence of Lisp objects to display
3224 when there are invisible lines. */
3225 Lisp_Object
*invis_vector_contents
3226 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3227 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
3228 : default_invis_vector
);
3230 GLYPH truncator
= (dp
== 0 || !INTEGERP (DISP_TRUNC_GLYPH (dp
))
3231 || !GLYPH_CHAR_VALID_P (XINT (DISP_TRUNC_GLYPH (dp
)))
3232 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
3233 GLYPH continuer
= (dp
== 0 || !INTEGERP (DISP_CONTINUE_GLYPH (dp
))
3234 || !GLYPH_CHAR_VALID_P (XINT (DISP_CONTINUE_GLYPH (dp
)))
3235 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
3237 /* If 1, we must handle multibyte characters. */
3238 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
3239 /* Length of multibyte form of each character. */
3241 /* Glyphs generated should be set this bit mask if text must be
3242 displayed from right to left. */
3243 GLYPH rev_dir_bit
= (NILP (current_buffer
->direction_reversed
)
3244 ? 0 : GLYPH_MASK_REV_DIR
);
3246 /* The next buffer location at which the face should change, due
3247 to overlays or text property changes. */
3248 int next_face_change
;
3250 /* The next location where the `invisible' property changes, or an
3251 overlay starts or ends. */
3254 /* The face we're currently using. */
3255 int current_face
= 0;
3258 XSETFASTINT (default_invis_vector
[2], '.');
3259 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
3261 get_display_line (f
, vpos
, WINDOW_LEFT_MARGIN (w
));
3262 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3264 /* Show where to highlight the region. */
3265 if (highlight_region
3266 /* Maybe highlight only in selected window. */
3267 && (highlight_nonselected_windows
3268 || w
== XWINDOW (selected_window
)
3269 || (MINI_WINDOW_P (XWINDOW (selected_window
))
3270 && w
== XWINDOW (Vminibuf_scroll_window
))))
3272 region_beg
= marker_position (current_buffer
->mark
);
3273 if (PT
< region_beg
)
3275 region_end
= region_beg
;
3280 w
->region_showing
= Qt
;
3284 region_beg
= region_end
= -1;
3285 w
->region_showing
= Qnil
;
3288 if (MINI_WINDOW_P (w
)
3290 && vpos
== XFASTINT (w
->top
))
3292 if (! NILP (minibuf_prompt
))
3294 int old_width
= minibuf_prompt_width
;
3296 minibuf_prompt_width
3297 = (display_string (w
, vpos
, XSTRING (minibuf_prompt
)->data
,
3298 STRING_BYTES (XSTRING (minibuf_prompt
)),
3299 hpos
+ WINDOW_LEFT_MARGIN (w
),
3300 /* Display a space if we truncate. */
3303 /* Truncate the prompt a little before the
3304 margin, so user input can at least start
3305 on the first line. */
3306 (XFASTINT (w
->width
) > 10
3307 ? XFASTINT (w
->width
) - 4 : -1),
3308 STRING_MULTIBYTE (minibuf_prompt
))
3309 - hpos
- WINDOW_LEFT_MARGIN (w
));
3310 hpos
+= minibuf_prompt_width
;
3311 taboffset
-= minibuf_prompt_width
- old_width
;
3314 minibuf_prompt_width
= 0;
3317 /* If we're hscrolled at all, use compute_motion to skip over any
3318 text off the left edge of the window. compute_motion may know
3319 tricks to do this faster than we can. */
3322 struct position
*left_edge
3323 = compute_motion (pos
, vpos
, hpos
, 0,
3325 width
, hscroll
, taboffset
, w
);
3327 /* Retrieve the buffer position and column provided by
3328 compute_motion. We can't assume that the column will be
3329 zero, because you may have multi-column characters crossing
3332 compute_motion may have moved us past the screen position we
3333 requested, if we hit a multi-column character, or the end of
3334 the line. If so, back up. */
3335 if (left_edge
->vpos
> vpos
3336 || left_edge
->hpos
> 0)
3338 pos
= left_edge
->bufpos
;
3339 pos_byte
= left_edge
->bytepos
;
3340 DEC_BOTH (pos
, pos_byte
);
3341 hpos
= left_edge
->prevhpos
;
3345 pos
= left_edge
->bufpos
;
3346 pos_byte
= left_edge
->bytepos
;
3347 hpos
= left_edge
->hpos
;
3351 hpos
+= WINDOW_LEFT_MARGIN (w
);
3353 desired_glyphs
->bufp
[vpos
] = start
;
3354 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3356 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
3357 /* In case we don't ever write anything into it... */
3358 desired_glyphs
->charstarts
[vpos
][WINDOW_LEFT_MARGIN (w
)] = -1;
3359 leftmargin
= desired_glyphs
->glyphs
[vpos
] + WINDOW_LEFT_MARGIN (w
);
3360 endp
= leftmargin
+ width
;
3362 /* Arrange the overlays nicely for our purposes. Usually, we call
3363 display_text_line on only one line at a time, in which case this
3364 can't really hurt too much, or we call it on lines which appear
3365 one after another in the buffer, in which case all calls to
3366 recenter_overlay_lists but the first will be pretty cheap. */
3367 recenter_overlay_lists (current_buffer
, pos
);
3369 /* Loop generating characters.
3370 Stop at end of buffer, before newline,
3371 if reach or pass continuation column,
3372 or at face change. */
3374 limit_byte
= pos_byte
;
3375 next_face_change
= pos
;
3376 next_boundary
= pos
;
3379 prevpos_byte
= pos_byte
;
3381 /* If the window is hscrolled and point is in the invisible part of the
3382 current line beyond the left margin we can record the cursor location
3384 if (hscroll
&& start
<= PT
&& PT
< pos
&& cursor_vpos
< 0)
3387 cursor_hpos
= p1
- leftmargin
;
3396 while (pos
== next_boundary
)
3398 Lisp_Object position
, limit
, prop
, ww
;
3400 /* Display the overlay strings here, unless we're at ZV
3401 and have already displayed the appropriate strings
3402 on an earlier line. */
3403 if (pos
< ZV
|| !zv_strings_seen
++)
3406 unsigned char *ovstr
;
3407 ovlen
= overlay_strings (pos
, w
, &ovstr
);
3411 /* Skip the ones we did in a previous line. */
3412 ovstr
+= ovstr_done
;
3413 ovlen
-= ovstr_done
;
3422 c
= STRING_CHAR_AND_LENGTH (ovstr
, ovlen
, len
);
3423 ovstr
+= len
, ovlen
-= len
, ovstr_done
+= len
;
3424 charset
= CHAR_CHARSET (c
);
3425 cols
= (charset
== CHARSET_COMPOSITION
3426 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3427 : CHARSET_WIDTH (charset
));
3431 c
= *ovstr
++, ovlen
--, ovstr_done
++;
3434 g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3437 if (p1
>= leftmargin
&& p1
< endp
)
3438 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3442 /* If we did all the overlay strings
3443 and we have room for text, clear ovstr_done
3444 just for neatness' sake. */
3445 if (ovlen
== 0 && p1
< endp
)
3450 /* Did we reach point? Record the cursor location. */
3451 if (pos
== PT
&& cursor_vpos
< 0)
3454 cursor_hpos
= p1
- leftmargin
;
3460 XSETFASTINT (position
, pos
);
3461 limit
= Fnext_overlay_change (position
);
3462 #ifdef USE_TEXT_PROPERTIES
3463 /* This is just an estimate to give reasonable
3464 performance; nothing should go wrong if it is too small. */
3465 if (XFASTINT (limit
) > pos
+ 50)
3467 int limitpos
= pos
+ 50;
3468 XSETFASTINT (limit
, limitpos
);
3470 limit
= Fnext_single_property_change (position
, Qinvisible
,
3471 Fcurrent_buffer (), limit
);
3473 next_boundary
= XFASTINT (limit
);
3474 /* if the `invisible' property is set, we can skip to
3475 the next property change. */
3477 prop
= Fget_char_property (position
, Qinvisible
, ww
);
3478 if (TEXT_PROP_MEANS_INVISIBLE (prop
))
3480 if (pos
< PT
&& next_boundary
>= PT
)
3483 cursor_hpos
= p1
- leftmargin
;
3485 pos
= next_boundary
;
3486 pos_byte
= CHAR_TO_BYTE (pos
);
3487 last_invis_skip
= pos
;
3488 last_invis_prop
= prop
;
3492 /* Did we reach point? Record the cursor location. */
3493 if (pos
== PT
&& cursor_vpos
< 0)
3496 cursor_hpos
= p1
- leftmargin
;
3499 /* Did we hit the end of the visible region of the buffer?
3503 /* Update charstarts for the end of this line. */
3504 /* Do nothing if off the left edge or at the right edge. */
3505 if (p1
>= leftmargin
&& p1
+ 1 != endp
)
3507 int *p2x
= &charstart
[(p1
< leftmargin
3515 /* Figure out where (if at all) the
3516 redisplay_end_trigger-hook should run. */
3517 if (MARKERP (w
->redisplay_end_trigger
)
3518 && XMARKER (w
->redisplay_end_trigger
)->buffer
!= 0)
3519 e_t_h
= marker_position (w
->redisplay_end_trigger
);
3520 else if (INTEGERP (w
->redisplay_end_trigger
))
3521 e_t_h
= XINT (w
->redisplay_end_trigger
);
3525 /* If we've gone past the place to run a hook,
3527 if (pos
>= e_t_h
&& e_t_h
!= ZV
)
3529 Lisp_Object args
[3];
3531 args
[0] = Qredisplay_end_trigger_functions
;
3532 XSETWINDOW (args
[1], w
);
3533 XSETINT (args
[2], e_t_h
);
3535 /* Since we are *trying* to run these functions,
3536 don't try to run them again, even if they get an error. */
3537 w
->redisplay_end_trigger
= Qnil
;
3538 Frun_hook_with_args (3, args
);
3541 /* Notice if it changed the face of this character. */
3542 next_face_change
= pos
;
3546 /* Did we hit a face change? Figure out what face we should
3547 use now. We also hit this the first time through the
3548 loop, to see what face we should start with. */
3549 if (pos
>= next_face_change
3550 && (FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
)))
3552 int limit
= pos
+ 50;
3554 current_face
= compute_char_face (f
, w
, pos
,
3555 region_beg
, region_end
,
3556 &next_face_change
, limit
, 0);
3560 /* Compute the next place we need to stop
3561 and do something special; set PAUSE. */
3565 if (pos
< next_boundary
&& next_boundary
< pause
)
3566 pause
= next_boundary
;
3567 if (pos
< next_face_change
&& next_face_change
< pause
)
3568 pause
= next_face_change
;
3573 /* Wouldn't you hate to read the next line to someone over
3575 if (pos
< PT
&& PT
< pause
)
3577 if (pos
< GPT
&& GPT
< pause
)
3580 /* LIMIT_BYTE is not the same place in the buffer as PAUSE.
3581 It is a limit on valid characters.
3582 We use it to bound STRING_CHAR_AND_LENGTH. */
3583 limit_byte
= ZV_BYTE
;
3584 if (pos
< GPT
&& GPT_BYTE
< limit_byte
)
3585 limit_byte
= GPT_BYTE
;
3588 int temp
= CHAR_TO_BYTE (pos
);
3589 p
= BYTE_POS_ADDR (temp
);
3597 p1_wide_column_end
= (GLYPH
*) 0;
3600 c
= STRING_CHAR_AND_LENGTH (p
, limit_byte
- pos_byte
, len
), p
+= len
;
3603 /* Let a display table override all standard display methods. */
3604 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
3606 p1
= copy_part_of_rope (f
, p1
, leftmargin
,
3607 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3608 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3609 current_face
, rev_dir_bit
);
3611 else if (c
>= 040 && c
< 0177)
3613 if (p1
>= leftmargin
)
3614 *p1
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3620 /* Same as p1prev, but after the invis_vector_contents text
3621 (if we have that on this line). */
3622 GLYPH
*p1prev_modified
;
3626 if (last_invis_skip
== pos
3627 && TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (last_invis_prop
))
3631 && indented_beyond_p (pos
+ 1, pos_byte
+ 1, selective
))
3633 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3636 INC_BOTH (pos
, pos_byte
);
3637 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3638 pos
= PT
, pos_byte
= PT_BYTE
;
3639 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3644 SET_PT_BOTH (opoint
, opoint_byte
);
3646 if (invis
&& selective_rlen
> 0 && p1
>= leftmargin
)
3651 cs
= charstart
+ (p1
- p1start
);
3654 p1
+= selective_rlen
;
3655 if (p1
- leftmargin
> width
)
3658 #if 0 /* This needs more work; charstarts needs to record
3659 both whether a position ho;ds an ellipsis character
3660 and what buffer position it corresponds to. */
3661 csend
= charstart
+ (p1
- p1start
);
3664 /* The idea is to use p1prev_modified instead of p1prev
3665 in the loop below over p2x. */
3666 p1prev_modified
= p1
;
3669 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3670 (p1
- p1prev
), current_face
, rev_dir_bit
);
3673 /* Update charstarts for the newline that ended this line. */
3674 /* Do nothing here for a char that's entirely off the left edge
3675 or if it starts at the right edge. */
3676 if (p1
>= leftmargin
&& p1prev
!= endp
)
3678 /* Store the newline's position into charstarts
3679 for the column where the newline starts.
3680 Store -1 for the rest of the glyphs it occupies. */
3681 int *p2x
= &charstart
[(p1prev
< leftmargin
3682 ? leftmargin
: p1prev
)
3684 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3691 /* Draw the face of the newline character as extending all the
3692 way to the end of the frame line. */
3695 if (p1
< leftmargin
)
3698 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3708 if (p1
>= leftmargin
&& p1
< endp
)
3709 *p1
= MAKE_GLYPH (f
, ' ', current_face
) | rev_dir_bit
;
3712 while ((p1
- leftmargin
+ taboffset
+ hscroll
- (hscroll
> 0))
3715 else if (c
== Ctl ('M') && selective
== -1)
3717 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3718 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3719 pos
= PT
, pos_byte
= PT_BYTE
;
3720 SET_PT_BOTH (opoint
, opoint_byte
);
3722 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3724 if (selective_rlen
> 0)
3726 p1
+= selective_rlen
;
3727 if (p1
- leftmargin
> width
)
3729 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3730 (p1
- p1prev
), current_face
, rev_dir_bit
);
3733 /* Draw the face of the newline character as extending all the
3734 way to the end of the frame line. */
3737 if (p1
< leftmargin
)
3740 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3744 /* Update charstarts for the ^M that ended this line. */
3745 /* Do nothing here for a char that's entirely off the left edge
3746 or if it starts at the right edge. */
3747 if (p1
>= leftmargin
&& p1prev
!= endp
)
3749 /* Store the newline's position into charstarts
3750 for the column where the newline starts.
3751 Store -1 for the rest of the glyphs it occupies. */
3752 int *p2x
= &charstart
[(p1prev
< leftmargin
3753 ? leftmargin
: p1prev
)
3755 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3763 else if (c
< 0200 && ctl_arrow
)
3765 if (p1
>= leftmargin
)
3767 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
3768 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
3769 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3773 if (p1
>= leftmargin
&& p1
< endp
)
3774 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
) | rev_dir_bit
;
3779 /* C is a multibyte character or a character to be displayed
3781 int remaining_bytes
= len
;
3785 /* C is a multibyte character. */
3786 int charset
= CHAR_CHARSET (c
);
3787 int columns
= (charset
== CHARSET_COMPOSITION
3788 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3789 : CHARSET_WIDTH (charset
));
3790 GLYPH g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3794 if (p1
>= leftmargin
&& p1
< endp
)
3795 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3798 p1_wide_column_end
= p1
;
3799 remaining_bytes
-= CHARSET_BYTES (charset
);
3802 while (remaining_bytes
> 0)
3804 c
= *(p
- remaining_bytes
--);
3806 if (p1
>= leftmargin
&& p1
< endp
)
3809 (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
3810 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
3811 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3815 if (p1
>= leftmargin
&& p1
< endp
)
3816 *p1
= (MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
)
3819 if (p1
>= leftmargin
&& p1
< endp
)
3820 *p1
= (MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
)
3823 if (p1
>= leftmargin
&& p1
< endp
)
3824 *p1
= (MAKE_GLYPH (f
, (7 & c
) + '0', current_face
)
3831 prevpos_byte
= pos_byte
;
3835 /* Update charstarts for the character just output. */
3837 /* Do nothing here for a char that's entirely off the left edge. */
3838 if (p1
>= leftmargin
)
3840 /* Store the char's position into charstarts
3841 for the first glyph occupied by this char.
3842 Store -1 for the rest of the glyphs it occupies. */
3845 int *p2x
= &charstart
[(p1prev
< leftmargin
3846 ? leftmargin
: p1prev
)
3848 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3858 val
.hpos
= - XINT (w
->hscroll
);
3865 lastpos_byte
= pos_byte
;
3867 /* Store 0 in this charstart line for the positions where
3868 there is no character. But do leave what was recorded
3869 for the character that ended the line. */
3870 /* Add 1 in the endtest to compensate for the fact that ENDP was
3871 made from WIDTH, which is 1 less than the window's actual
3873 i
= p1
- p1start
+ 1;
3874 if (p1
< leftmargin
)
3875 i
+= leftmargin
- p1
;
3876 for (; i
< endp
- p1start
+ 1; i
++)
3879 /* Handle continuation in middle of a character */
3880 /* by backing up over it */
3883 /* Don't back up if we never actually displayed any text.
3884 This occurs when the minibuffer prompt takes up the whole line. */
3887 /* Start the next line with that same character whose
3888 character code is C and the length of multi-byte form is
3891 pos_byte
= prevpos_byte
;
3893 if (p1_wide_column_end
< endp
)
3894 /* As ENDP is not in the middle of wide-column character,
3895 we can break the line at ENDP and start from the middle
3896 column in the next line. So, adjust VAL.HPOS to skip
3897 the columns output on this line. */
3898 val
.hpos
+= p1prev
- endp
;
3901 /* We displayed a wide-column character at around ENDP.
3902 Since we can't broke it in the middle, the whole
3903 character should be driven into the next line. */
3904 /* As the result, the actual columns occupied by the
3905 text on this line is less than WIDTH. VAL.TAB_OFFSET
3906 must be adjusted. */
3907 taboffset
= taboffset
+ (p1prev
- endp
);
3908 /* Let's fill unused columns with TRUNCATOR or CONTINUER. */
3910 GLYPH g
= fix_glyph (f
, truncate
? truncator
: continuer
, 0);
3911 while (p1prev
< endp
)
3914 /* If POINT is at POS, cursor should not on this line. */
3916 lastpos_byte
= pos_byte
;
3922 /* Keep in this line everything up to the continuation column. */
3926 /* Finish deciding which character to start the next line on,
3927 and what hpos to start it at.
3928 Also set `lastpos' to the last position which counts as "on this line"
3929 for cursor-positioning. */
3933 if (FETCH_BYTE (pos_byte
) == '\n')
3935 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3937 /* If stopped due to a newline, start next line after it */
3938 SET_PT_BOTH (pos
+ 1, pos_byte
+ 1);
3941 /* Check again for hidden lines, in case the newline occurred exactly
3942 at the right margin. */
3943 while (PT
< ZV
&& selective
> 0
3944 && indented_beyond_p (PT
, PT_BYTE
, selective
))
3945 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3947 pos
= PT
, pos_byte
= PT_BYTE
;
3948 SET_PT_BOTH (opoint
, opoint_byte
);
3951 /* Stopped due to right margin of window */
3955 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3957 SET_PT_BOTH (pos
, pos_byte
);
3958 *p1
++ = fix_glyph (f
, truncator
, 0);
3959 /* Truncating => start next line after next newline,
3960 and point is on this line if it is before the newline,
3961 and skip none of first char of next line */
3963 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3964 while (PT
< ZV
&& selective
> 0
3965 && indented_beyond_p (PT
, PT_BYTE
, selective
));
3966 pos
= PT
, pos_byte
= PT_BYTE
;
3967 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
3968 SET_PT_BOTH (opoint
, opoint_byte
);
3970 lastpos
= pos
- (FETCH_BYTE (pos_byte
- 1) == '\n');
3971 lastpos_byte
= CHAR_TO_BYTE (lastpos
);
3976 *p1
++ = fix_glyph (f
, continuer
, 0);
3978 DEC_BOTH (lastpos
, lastpos_byte
);
3979 val
.tab_offset
= taboffset
+ width
;
3986 /* If point is at eol or in invisible text at eol,
3987 record its frame location now. */
3989 if (start
<= PT
&& PT
<= lastpos
&& cursor_vpos
< 0)
3992 cursor_hpos
= p1
- leftmargin
;
3995 if (cursor_vpos
== vpos
)
3997 if (cursor_hpos
< 0) cursor_hpos
= 0;
3998 if (cursor_hpos
> width
) cursor_hpos
= width
;
3999 cursor_hpos
+= WINDOW_LEFT_MARGIN (w
);
4000 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
4002 if (!(cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f
)
4003 && EQ (FRAME_MINIBUF_WINDOW (f
), minibuf_window
)))
4005 FRAME_CURSOR_Y (f
) = cursor_vpos
;
4006 FRAME_CURSOR_X (f
) = cursor_hpos
;
4009 if (w
== XWINDOW (selected_window
))
4011 /* Line is not continued and did not start
4012 in middle of character */
4013 if ((hpos
- WINDOW_LEFT_MARGIN (w
)
4014 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
4017 this_line_bufpos
= start
;
4018 this_line_buffer
= current_buffer
;
4019 this_line_vpos
= cursor_vpos
;
4020 this_line_start_hpos
= hpos
- WINDOW_LEFT_MARGIN (w
);
4021 this_line_endpos
= Z
- lastpos
;
4024 this_line_bufpos
= 0;
4029 /* If hscroll and line not empty, insert truncation-at-left marker */
4030 if (hscroll
&& lastpos
!= start
)
4032 GLYPH g
= fix_glyph (f
, truncator
, 0);
4034 if (p1
<= leftmargin
)
4035 p1
= leftmargin
+ 1;
4036 else /* MULE: it may be a wide-column character */
4038 p1prev
= leftmargin
+ 1;
4039 while (p1prev
< p1
&& *p1prev
& GLYPH_MASK_PADDING
)
4044 if (!WINDOW_RIGHTMOST_P (w
))
4047 if (p1
< leftmargin
) p1
= leftmargin
;
4048 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
4050 /* Don't draw vertical bars if we're using scroll bars. They're
4051 covered up by the scroll bars, and it's distracting to see
4052 them when the scroll bar windows are flickering around to be
4054 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
4057 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
4060 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
4061 *p1
++ = (dp
&& INTEGERP (DISP_BORDER_GLYPH (dp
))
4062 ? XINT (DISP_BORDER_GLYPH (dp
))
4065 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
4066 p1
- desired_glyphs
->glyphs
[vpos
]);
4067 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
4069 /* If the start of this line is the overlay arrow-position,
4070 then put the arrow string into the display-line. */
4072 if (MARKERP (Voverlay_arrow_position
)
4073 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
4074 && start
== marker_position (Voverlay_arrow_position
)
4075 && STRINGP (Voverlay_arrow_string
)
4076 && ! overlay_arrow_seen
)
4079 int len
= XSTRING (Voverlay_arrow_string
)->size
;
4085 /* If the arrow string has text props, obey them when displaying. */
4086 for (i
= 0, i_byte
= 0; i
< len
; )
4089 Lisp_Object face
, ilisp
;
4093 if (STRING_MULTIBYTE (Voverlay_arrow_string
))
4094 FETCH_STRING_CHAR_ADVANCE (c
, Voverlay_arrow_string
, i
, i_byte
);
4096 c
= XSTRING (Voverlay_arrow_string
)->data
[i
++];
4098 XSETFASTINT (ilisp
, i
);
4100 if (FRAME_WINDOW_P (f
))
4102 face
= Fget_text_property (ilisp
, Qface
, Voverlay_arrow_string
);
4103 newface
= compute_glyph_face_1 (f
, face
, 0);
4104 c
= FAST_MAKE_GLYPH (c
, newface
);
4106 #endif /* HAVE_FACES */
4107 leftmargin
[idx
] = c
;
4110 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
4111 arrow_end
= (leftmargin
- desired_glyphs
->glyphs
[vpos
]) + len
;
4112 if (desired_glyphs
->used
[vpos
] < arrow_end
)
4113 desired_glyphs
->used
[vpos
] = arrow_end
;
4115 overlay_arrow_seen
= 1;
4119 val
.bytepos
= pos_byte
;
4120 val
.ovstring_chars_done
= ovstr_done
;
4121 val_display_text_line
= val
;
4122 return &val_display_text_line
;
4125 /* Redisplay the menu bar in the frame for window W. */
4128 display_menu_bar (w
)
4131 Lisp_Object items
, tail
;
4132 register int vpos
= 0;
4133 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4134 int maxendcol
= FRAME_WIDTH (f
);
4139 if (!NILP (Vwindow_system
))
4143 #ifdef USE_X_TOOLKIT
4146 #endif /* USE_X_TOOLKIT */
4148 get_display_line (f
, vpos
, 0);
4150 items
= FRAME_MENU_BAR_ITEMS (f
);
4151 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 4)
4153 Lisp_Object pos
, string
;
4154 string
= XVECTOR (items
)->contents
[i
+ 1];
4158 XSETFASTINT (XVECTOR (items
)->contents
[i
+ 3], hpos
);
4160 if (hpos
< maxendcol
)
4161 hpos
= display_string (w
, vpos
,
4162 XSTRING (string
)->data
,
4163 STRING_BYTES (XSTRING (string
)),
4164 hpos
, 0, 0, hpos
, maxendcol
,
4165 STRING_MULTIBYTE (string
));
4166 /* Put a space between items. */
4167 if (hpos
< maxendcol
)
4169 int hpos1
= hpos
+ 1;
4170 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
4171 min (hpos1
, maxendcol
), maxendcol
, 0);
4175 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4176 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4178 /* Fill out the line with spaces. */
4179 if (maxendcol
> hpos
)
4180 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
, 0);
4182 /* Clear the rest of the lines allocated to the menu bar. */
4184 while (vpos
< FRAME_MENU_BAR_LINES (f
))
4185 get_display_line (f
, vpos
++, 0);
4188 /* Display the mode line for window w */
4191 display_mode_line (w
)
4194 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
4195 register int left
= WINDOW_LEFT_MARGIN (w
);
4196 register int right
= WINDOW_RIGHT_MARGIN (w
);
4197 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4199 line_number_displayed
= 0;
4200 w
->column_number_displayed
= Qnil
;
4202 get_display_line (f
, vpos
, left
);
4204 /* Temporarily make frame F's kboard the current kboard
4205 so that kboard-local variables in the mode_line_format
4206 will get the right values. */
4207 push_frame_kboard (f
);
4209 display_mode_element (w
, vpos
, left
, 0, right
, right
,
4210 current_buffer
->mode_line_format
);
4212 pop_frame_kboard ();
4214 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4216 /* Put the mode line in inverse video.
4217 Use faces if possible, since that lets us handle
4218 partial-width windows and avoid inverting the scroll bar columns. */
4220 if (! FRAME_TERMCAP_P (f
) && mode_line_inverse_video
)
4222 /* For a partial width window, explicitly set face of each glyph. */
4224 unsigned int padding
;
4225 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
4226 for (i
= left
; i
< right
; ++i
)
4228 padding
= ptr
[i
] & GLYPH_MASK_PADDING
;
4229 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1) | padding
;
4235 /* Make the mode line inverse video if the entire line
4236 is made of mode lines.
4237 I.e. if this window is full width,
4238 or if it is the child of a full width window
4239 (which implies that that window is split side-by-side
4240 and the rest of this line is mode lines of the sibling windows). */
4241 if (WINDOW_FULL_WIDTH_P (w
)
4242 || WINDOW_FULL_WIDTH_P (XWINDOW (w
->parent
)))
4243 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4246 /* Contribute ELT to the mode line for window W.
4247 How it translates into text depends on its data type.
4249 VPOS is the position of the mode line being displayed.
4251 HPOS is the position (absolute on frame) where this element's text
4252 should start. The output is truncated automatically at the right
4255 DEPTH is the depth in recursion. It is used to prevent
4256 infinite recursion here.
4258 MINENDCOL is the hpos before which the element may not end.
4259 The element is padded at the right with spaces if nec
4260 to reach this column.
4262 MAXENDCOL is the hpos past which this element may not extend.
4263 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
4264 (This is necessary to make nested padding and truncation work.)
4266 Returns the hpos of the end of the text generated by ELT.
4267 The next element will receive that value as its HPOS arg,
4268 so as to concatenate the elements. */
4271 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
4273 register int vpos
, hpos
;
4276 register int maxendcol
;
4277 register Lisp_Object elt
;
4285 switch (SWITCH_ENUM_CAST (XTYPE (elt
)))
4289 /* A string: output it and check for %-constructs within it. */
4290 register unsigned char c
;
4291 register unsigned char *this = XSTRING (elt
)->data
;
4293 while (hpos
< maxendcol
&& *this)
4295 unsigned char *last
= this;
4296 while ((c
= *this++) != '\0' && c
!= '%')
4298 if (this - 1 != last
)
4300 register int lim
= --this - last
+ hpos
;
4301 if (frame_title_ptr
)
4302 hpos
= store_frame_title (last
, hpos
, min (lim
, maxendcol
));
4304 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
4305 hpos
, min (lim
, maxendcol
),
4306 STRING_MULTIBYTE (elt
));
4310 register int minendcol
;
4311 register int spec_width
= 0;
4313 /* We can't allow -ve args due to the "%-" construct */
4314 /* Argument specifies minwidth but not maxwidth
4315 (maxwidth can be specified by
4316 (<negative-number> . <stuff>) mode-line elements) */
4318 while ((c
= *this++) >= '0' && c
<= '9')
4320 spec_width
= spec_width
* 10 + (c
- '0');
4323 minendcol
= hpos
+ spec_width
;
4324 if (minendcol
> maxendcol
)
4326 spec_width
= maxendcol
- hpos
;
4327 minendcol
= maxendcol
;
4331 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4332 spec_width
, maxendcol
,
4333 Vglobal_mode_string
);
4336 char *spec
= decode_mode_spec (w
, c
, spec_width
,
4338 if (frame_title_ptr
)
4339 hpos
= store_frame_title (spec
, minendcol
, maxendcol
);
4341 hpos
= display_string (w
, vpos
, spec
, -1,
4343 minendcol
, maxendcol
, -1);
4351 /* A symbol: process the value of the symbol recursively
4352 as if it appeared here directly. Avoid error if symbol void.
4353 Special case: if value of symbol is a string, output the string
4356 register Lisp_Object tem
;
4357 tem
= Fboundp (elt
);
4360 tem
= Fsymbol_value (elt
);
4361 /* If value is a string, output that string literally:
4362 don't check for % within it. */
4365 if (frame_title_ptr
)
4366 hpos
= store_frame_title (XSTRING (tem
)->data
,
4367 minendcol
, maxendcol
);
4369 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
4370 STRING_BYTES (XSTRING (tem
)),
4371 hpos
, 0, 1, minendcol
, maxendcol
,
4372 STRING_MULTIBYTE (tem
));
4374 /* Give up right away for nil or t. */
4375 else if (!EQ (tem
, elt
))
4376 { elt
= tem
; goto tail_recurse
; }
4383 register Lisp_Object car
, tem
;
4385 /* A cons cell: three distinct cases.
4386 If first element is a string or a cons, process all the elements
4387 and effectively concatenate them.
4388 If first element is a negative number, truncate displaying cdr to
4389 at most that many characters. If positive, pad (with spaces)
4390 to at least that many characters.
4391 If first element is a symbol, process the cadr or caddr recursively
4392 according to whether the symbol's value is non-nil or nil. */
4393 car
= XCONS (elt
)->car
;
4396 tem
= Fboundp (car
);
4397 elt
= XCONS (elt
)->cdr
;
4400 /* elt is now the cdr, and we know it is a cons cell.
4401 Use its car if CAR has a non-nil value. */
4404 tem
= Fsymbol_value (car
);
4406 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
4408 /* Symbol's value is nil (or symbol is unbound)
4409 Get the cddr of the original list
4410 and if possible find the caddr and use that. */
4411 elt
= XCONS (elt
)->cdr
;
4414 else if (!CONSP (elt
))
4416 elt
= XCONS (elt
)->car
;
4419 else if (INTEGERP (car
))
4421 register int lim
= XINT (car
);
4422 elt
= XCONS (elt
)->cdr
;
4424 /* Negative int means reduce maximum width.
4425 DO NOT change MINENDCOL here!
4426 (20 -10 . foo) should truncate foo to 10 col
4427 and then pad to 20. */
4428 maxendcol
= min (maxendcol
, hpos
- lim
);
4431 /* Padding specified. Don't let it be more than
4434 if (lim
> maxendcol
)
4436 /* If that's more padding than already wanted, queue it.
4437 But don't reduce padding already specified even if
4438 that is beyond the current truncation point. */
4439 if (lim
> minendcol
)
4444 else if (STRINGP (car
) || CONSP (car
))
4446 register int limit
= 50;
4447 /* LIMIT is to protect against circular lists. */
4448 while (CONSP (elt
) && --limit
> 0
4449 && hpos
< maxendcol
)
4451 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4454 elt
= XCONS (elt
)->cdr
;
4462 if (frame_title_ptr
)
4463 hpos
= store_frame_title ("*invalid*", minendcol
, maxendcol
);
4465 hpos
= display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
4466 minendcol
, maxendcol
, 0);
4470 if (minendcol
> hpos
)
4471 if (frame_title_ptr
)
4472 hpos
= store_frame_title ("", minendcol
, maxendcol
);
4474 hpos
= display_string (w
, vpos
, "", 0, hpos
,
4475 0, 1, minendcol
, maxendcol
, 0);
4479 /* Write a null-terminated, right justified decimal representation of
4480 the positive integer D to BUF using a minimal field width WIDTH. */
4483 pint2str (buf
, width
, d
)
4488 register char *p
= buf
;
4495 *p
++ = d
% 10 + '0';
4498 for (width
-= (int) (p
- buf
); width
> 0; --width
) *p
++ = ' ';
4508 /* Set a mnemonic character for CODING_SYSTEM (Lisp symbol) in BUF.
4509 If EOL_FLAG is 1, set also a mnemonic character for end-of-line
4510 type of CODING_SYSTEM. Return updated pointer into BUF. */
4513 decode_mode_spec_coding (coding_system
, buf
, eol_flag
)
4514 Lisp_Object coding_system
;
4519 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
4521 val
= coding_system
;
4523 if (NILP (val
)) /* Not yet decided. */
4528 *buf
++ = eol_mnemonic_undecided
;
4529 /* Don't mention EOL conversion if it isn't decided. */
4533 Lisp_Object eolvalue
;
4535 eolvalue
= Fget (coding_system
, Qeol_type
);
4537 while (!NILP (val
) && SYMBOLP (val
))
4539 val
= Fget (val
, Qcoding_system
);
4540 if (NILP (eolvalue
))
4541 eolvalue
= Fget (val
, Qeol_type
);
4545 *buf
++ = XFASTINT (XVECTOR (val
)->contents
[1]);
4549 /* The EOL conversion we are using. */
4551 /* The EOL conversion that is normal on this system. */
4553 if (NILP (eolvalue
)) /* Not yet decided. */
4554 eoltype
= eol_mnemonic_undecided
;
4555 else if (VECTORP (eolvalue
)) /* Not yet decided. */
4556 eoltype
= eol_mnemonic_undecided
;
4557 else /* INTEGERP (eolvalue) -- 0:LF, 1:CRLF, 2:CR */
4558 eoltype
= (XFASTINT (eolvalue
) == 0
4560 : (XFASTINT (eolvalue
) == 1
4561 ? eol_mnemonic_dos
: eol_mnemonic_mac
));
4563 /* Mention the EOL conversion if it is not the usual one. */
4570 /* Return a string for the output of a mode line %-spec for window W,
4571 generated by character C. SPEC_WIDTH is the field width when
4572 padding to the left (%c, %l). The value returned from this
4573 function will later be truncated to width MAXWIDTH. */
4575 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
4578 decode_mode_spec (w
, c
, spec_width
, maxwidth
)
4581 register int spec_width
;
4582 register int maxwidth
;
4585 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4586 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
4587 struct buffer
*b
= XBUFFER (w
->buffer
);
4590 if (maxwidth
> FRAME_WIDTH (f
))
4591 maxwidth
= FRAME_WIDTH (f
);
4596 if (!NILP (b
->read_only
))
4598 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4603 /* This differs from %* only for a modified read-only buffer. */
4604 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4606 if (!NILP (b
->read_only
))
4611 /* This differs from %* in ignoring read-only-ness. */
4612 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4624 if (command_loop_level
> 5)
4626 p
= decode_mode_spec_buf
;
4627 for (i
= 0; i
< command_loop_level
; i
++)
4630 return decode_mode_spec_buf
;
4638 if (command_loop_level
> 5)
4640 p
= decode_mode_spec_buf
;
4641 for (i
= 0; i
< command_loop_level
; i
++)
4644 return decode_mode_spec_buf
;
4652 if (maxwidth
< sizeof (lots_of_dashes
))
4653 return lots_of_dashes
;
4656 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
4660 return decode_mode_spec_buf
;
4666 if (maxwidth
>= 3 && STRING_BYTES (XSTRING (obj
)) > maxwidth
)
4668 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
4669 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
4670 decode_mode_spec_buf
[maxwidth
] = '\0';
4671 return decode_mode_spec_buf
;
4678 int col
= current_column ();
4679 XSETFASTINT (w
->column_number_displayed
, col
);
4680 pint2str (decode_mode_spec_buf
, spec_width
, col
);
4681 return decode_mode_spec_buf
;
4685 /* %F displays the frame name. */
4686 /* Systems that can only display a single frame at a time should
4687 NOT replace the frame name with the (constant) frame title,
4688 since then they won't be able to tell which frame is that. */
4689 if (FRAME_WINDOW_P (f
) && !NILP (f
->title
))
4690 return (char *) XSTRING (f
->title
)->data
;
4691 if (f
->explicit_name
|| ! FRAME_WINDOW_P (f
))
4692 return (char *) XSTRING (f
->name
)->data
;
4700 else if (STRINGP (obj
) && STRING_BYTES (XSTRING (obj
)) > maxwidth
)
4702 bcopy ("...", decode_mode_spec_buf
, 3);
4703 bcopy (XSTRING (obj
)->data
+ STRING_BYTES (XSTRING (obj
)) - maxwidth
+ 3,
4704 decode_mode_spec_buf
+ 3, maxwidth
- 3);
4705 return decode_mode_spec_buf
;
4712 int startpos
= XMARKER (w
->start
)->charpos
;
4713 int startpos_byte
= marker_byte_position (w
->start
);
4714 int line
, linepos
, linepos_byte
, topline
;
4717 int height
= XFASTINT (w
->height
);
4719 /* If we decided that this buffer isn't suitable for line numbers,
4720 don't forget that too fast. */
4721 if (EQ (w
->base_line_pos
, w
->buffer
))
4723 /* But do forget it, if the window shows a different buffer now. */
4724 else if (BUFFERP (w
->base_line_pos
))
4725 w
->base_line_pos
= Qnil
;
4727 /* If the buffer is very big, don't waste time. */
4728 if (BUF_ZV (b
) - BUF_BEGV (b
) > line_number_display_limit
)
4730 w
->base_line_pos
= Qnil
;
4731 w
->base_line_number
= Qnil
;
4735 if (!NILP (w
->base_line_number
)
4736 && !NILP (w
->base_line_pos
)
4737 && XFASTINT (w
->base_line_pos
) <= startpos
)
4739 line
= XFASTINT (w
->base_line_number
);
4740 linepos
= XFASTINT (w
->base_line_pos
);
4741 linepos_byte
= buf_charpos_to_bytepos (b
, linepos
);
4746 linepos
= BUF_BEGV (b
);
4747 linepos_byte
= BUF_BEGV_BYTE (b
);
4750 /* Count lines from base line to window start position. */
4751 nlines
= display_count_lines (linepos
, linepos_byte
,
4755 topline
= nlines
+ line
;
4757 /* Determine a new base line, if the old one is too close
4758 or too far away, or if we did not have one.
4759 "Too close" means it's plausible a scroll-down would
4761 if (startpos
== BUF_BEGV (b
))
4763 XSETFASTINT (w
->base_line_number
, topline
);
4764 XSETFASTINT (w
->base_line_pos
, BUF_BEGV (b
));
4766 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
4767 || linepos
== BUF_BEGV (b
))
4769 int limit
= BUF_BEGV (b
);
4770 int limit_byte
= BUF_BEGV_BYTE (b
);
4772 int distance
= (height
* 2 + 30) * 200;
4774 if (startpos
- distance
> limit
)
4776 limit
= startpos
- distance
;
4777 limit_byte
= CHAR_TO_BYTE (limit
);
4780 nlines
= display_count_lines (startpos
, startpos_byte
,
4782 - (height
* 2 + 30),
4784 /* If we couldn't find the lines we wanted within
4786 give up on line numbers for this window. */
4787 if (position
== limit_byte
&& limit
== startpos
- distance
)
4789 w
->base_line_pos
= w
->buffer
;
4790 w
->base_line_number
= Qnil
;
4794 XSETFASTINT (w
->base_line_number
, topline
- nlines
);
4795 XSETFASTINT (w
->base_line_pos
, BYTE_TO_CHAR (position
));
4798 /* Now count lines from the start pos to point. */
4799 nlines
= display_count_lines (startpos
, startpos_byte
,
4800 PT_BYTE
, PT
, &junk
);
4802 /* Record that we did display the line number. */
4803 line_number_displayed
= 1;
4805 /* Make the string to show. */
4806 pint2str (decode_mode_spec_buf
, spec_width
, topline
+ nlines
);
4807 return decode_mode_spec_buf
;
4810 char* p
= decode_mode_spec_buf
;
4811 for (spec_width
-= 2; spec_width
> 0; --spec_width
) *p
++ = ' ';
4813 return decode_mode_spec_buf
;
4823 if (BUF_BEGV (b
) > BUF_BEG (b
) || BUF_ZV (b
) < BUF_Z (b
))
4829 int pos
= marker_position (w
->start
);
4830 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4832 if (XFASTINT (w
->window_end_pos
) <= BUF_Z (b
) - BUF_ZV (b
))
4834 if (pos
<= BUF_BEGV (b
))
4839 else if (pos
<= BUF_BEGV (b
))
4843 if (total
> 1000000)
4844 /* Do it differently for a large value, to avoid overflow. */
4845 total
= ((pos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4847 total
= ((pos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4848 /* We can't normally display a 3-digit number,
4849 so get us a 2-digit number that is close. */
4852 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4853 return decode_mode_spec_buf
;
4857 /* Display percentage of size above the bottom of the screen. */
4860 int toppos
= marker_position (w
->start
);
4861 int botpos
= BUF_Z (b
) - XFASTINT (w
->window_end_pos
);
4862 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4864 if (botpos
>= BUF_ZV (b
))
4866 if (toppos
<= BUF_BEGV (b
))
4873 if (total
> 1000000)
4874 /* Do it differently for a large value, to avoid overflow. */
4875 total
= ((botpos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4877 total
= ((botpos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4878 /* We can't normally display a 3-digit number,
4879 so get us a 2-digit number that is close. */
4882 if (toppos
<= BUF_BEGV (b
))
4883 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
4885 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4886 return decode_mode_spec_buf
;
4891 /* status of process */
4892 obj
= Fget_buffer_process (w
->buffer
);
4894 return "no process";
4896 obj
= Fsymbol_name (Fprocess_status (obj
));
4900 case 't': /* indicate TEXT or BINARY */
4901 #ifdef MODE_LINE_BINARY_TEXT
4902 return MODE_LINE_BINARY_TEXT (b
);
4908 /* coding-system (not including end-of-line format) */
4910 /* coding-system (including end-of-line type) */
4912 int eol_flag
= (c
== 'Z');
4913 char *p
= decode_mode_spec_buf
;
4915 if (! FRAME_WINDOW_P (f
))
4917 /* No need to mention EOL here--the terminal never needs
4918 to do EOL conversion. */
4919 p
= decode_mode_spec_coding (keyboard_coding
.symbol
, p
, 0);
4920 p
= decode_mode_spec_coding (terminal_coding
.symbol
, p
, 0);
4922 p
= decode_mode_spec_coding (b
->buffer_file_coding_system
,
4925 #if 0 /* This proves to be annoying; I think we can do without. -- rms. */
4927 obj
= Fget_buffer_process (Fcurrent_buffer ());
4930 p
= decode_mode_spec_coding (XPROCESS (obj
)->decode_coding_system
,
4932 p
= decode_mode_spec_coding (XPROCESS (obj
)->encode_coding_system
,
4935 #endif /* subprocesses */
4938 return decode_mode_spec_buf
;
4943 return (char *) XSTRING (obj
)->data
;
4948 /* Count up to COUNT lines starting from START / START_BYTE.
4949 But don't go beyond LIMIT_BYTE.
4950 Return the number of lines thus found (always nonnegative).
4952 Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */
4955 display_count_lines (start
, start_byte
, limit_byte
, count
, byte_pos_ptr
)
4956 int start
, start_byte
, limit_byte
, count
;
4959 register unsigned char *cursor
;
4960 unsigned char *base
;
4962 register int ceiling
;
4963 register unsigned char *ceiling_addr
;
4964 int orig_count
= count
;
4966 /* If we are not in selective display mode,
4967 check only for newlines. */
4968 int selective_display
= (!NILP (current_buffer
->selective_display
)
4969 && !INTEGERP (current_buffer
->selective_display
));
4973 while (start_byte
< limit_byte
)
4975 ceiling
= BUFFER_CEILING_OF (start_byte
);
4976 ceiling
= min (limit_byte
- 1, ceiling
);
4977 ceiling_addr
= BYTE_POS_ADDR (ceiling
) + 1;
4978 base
= (cursor
= BYTE_POS_ADDR (start_byte
));
4981 if (selective_display
)
4982 while (*cursor
!= '\n' && *cursor
!= 015 && ++cursor
!= ceiling_addr
)
4985 while (*cursor
!= '\n' && ++cursor
!= ceiling_addr
)
4988 if (cursor
!= ceiling_addr
)
4992 start_byte
+= cursor
- base
+ 1;
4993 *byte_pos_ptr
= start_byte
;
4997 if (++cursor
== ceiling_addr
)
5003 start_byte
+= cursor
- base
;
5008 while (start_byte
> limit_byte
)
5010 ceiling
= BUFFER_FLOOR_OF (start_byte
- 1);
5011 ceiling
= max (limit_byte
, ceiling
);
5012 ceiling_addr
= BYTE_POS_ADDR (ceiling
) - 1;
5013 base
= (cursor
= BYTE_POS_ADDR (start_byte
- 1) + 1);
5016 if (selective_display
)
5017 while (--cursor
!= ceiling_addr
5018 && *cursor
!= '\n' && *cursor
!= 015)
5021 while (--cursor
!= ceiling_addr
&& *cursor
!= '\n')
5024 if (cursor
!= ceiling_addr
)
5028 start_byte
+= cursor
- base
+ 1;
5029 *byte_pos_ptr
= start_byte
;
5030 /* When scanning backwards, we should
5031 not count the newline posterior to which we stop. */
5032 return - orig_count
- 1;
5038 /* Here we add 1 to compensate for the last decrement
5039 of CURSOR, which took it past the valid range. */
5040 start_byte
+= cursor
- base
+ 1;
5044 *byte_pos_ptr
= limit_byte
;
5047 return - orig_count
+ count
;
5048 return orig_count
- count
;
5052 /* Display STRING on one line of window W, starting at HPOS.
5053 Display at position VPOS. Caller should have done get_display_line.
5054 If VPOS == -1, display it as the current frame's title.
5055 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
5057 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
5059 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
5060 MAXCOL is the last column ok to end at. Truncate here.
5061 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
5062 Both count from the left edge of the frame, as does HPOS.
5063 The right edge of W is an implicit maximum.
5064 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
5066 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
5067 at the place where the current window ends in this line
5068 and not display anything beyond there. Otherwise, only MAXCOL
5069 controls where to stop output.
5071 MULTIBYTE can be 0 meaning do not display multibyte chars,
5072 1 meaning do display them, or -1 meaning obey the current buffer's
5073 value of enable_multibyte_characters.
5075 Returns ending hpos. */
5078 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
5079 obey_window_width
, mincol
, maxcol
, multibyte
)
5081 unsigned char *string
;
5085 int obey_window_width
;
5092 int hscroll
= XINT (w
->hscroll
);
5093 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
5094 register GLYPH
*start
;
5095 register GLYPH
*end
;
5096 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
5097 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
5098 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
5099 int window_width
= XFASTINT (w
->width
);
5101 /* Use the standard display table, not the window's display table.
5102 We don't want the mode line in rot13. */
5103 register struct Lisp_Char_Table
*dp
= 0;
5106 if (multibyte
== -1)
5107 multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
5108 /* Now multibyte is 1 if we should display multibyte characters. */
5110 if (DISP_TABLE_P (Vstandard_display_table
))
5111 dp
= XCHAR_TABLE (Vstandard_display_table
);
5113 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
5116 start
= desired_glyphs
->glyphs
[vpos
];
5118 if (obey_window_width
)
5120 start
+= XFASTINT (w
->left
);
5121 end
= start
+ window_width
- (truncate
!= 0);
5123 if (!WINDOW_RIGHTMOST_P (w
))
5125 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
5129 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
5132 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
5137 if (! obey_window_width
5138 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
5139 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
5141 /* Store 0 in charstart for these columns. */
5142 for (i
= (hpos
>= 0 ? hpos
: 0); i
< end
- p1start
+ hpos
; i
++)
5143 desired_glyphs
->charstarts
[vpos
][i
] = 0;
5145 if (maxcol
>= 0 && mincol
> maxcol
)
5149 /* We need this value for multibyte characters. */
5150 length
= strlen (string
);
5152 /* We set truncated to 1 if we get stopped by trying to pass END
5153 (that is, trying to pass MAXCOL.) */
5162 c
= STRING_CHAR_AND_LENGTH (string
, length
, len
);
5164 c
= *string
, len
= 1;
5166 string
+= len
, length
-= len
;
5174 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
5176 p1
= copy_part_of_rope (f
, p1
, start
,
5177 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
5178 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
5181 else if (c
>= 040 && c
< 0177)
5191 if (p1
>= start
&& p1
< end
)
5195 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
5197 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
5201 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
5202 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
5203 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
5206 if (p1
>= start
&& p1
< end
)
5212 /* C is a control character or a binary byte data. */
5215 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
5216 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
5217 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
5220 if (p1
>= start
&& p1
< end
)
5221 *p1
= (c
>> 6) + '0';
5223 if (p1
>= start
&& p1
< end
)
5224 *p1
= (7 & (c
>> 3)) + '0';
5226 if (p1
>= start
&& p1
< end
)
5227 *p1
= (7 & c
) + '0';
5232 /* C is a multibyte character. */
5233 int charset
= CHAR_CHARSET (c
);
5234 int columns
= (charset
== CHARSET_COMPOSITION
5235 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
5236 : CHARSET_WIDTH (charset
));
5240 /* Since we can't show the left part of C, fill all
5241 columns with spaces. */
5242 columns
-= start
- p1
;
5251 else if (p1
+ columns
> end
)
5253 /* Since we can't show the right part of C, fill all
5254 columns with TRUNCATE if TRUNCATE is specified. */
5258 *p1
++ = fix_glyph (f
, truncate
, 0);
5259 /* And tell the line is truncated. */
5266 /* We can show the whole glyph of C. */
5269 *p1
++ = c
| GLYPH_MASK_PADDING
;
5277 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
5279 else if (mincol
>= 0)
5281 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
5287 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
5289 if (len
> desired_glyphs
->used
[vpos
])
5290 desired_glyphs
->used
[vpos
] = len
;
5291 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
5297 /* This is like a combination of memq and assq.
5298 Return 1 if PROPVAL appears as an element of LIST
5299 or as the car of an element of LIST.
5300 If PROPVAL is a list, compare each element against LIST
5301 in that way, and return 1 if any element of PROPVAL is found in LIST.
5303 This function cannot quit. */
5306 invisible_p (propval
, list
)
5307 register Lisp_Object propval
;
5310 register Lisp_Object tail
, proptail
;
5311 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5313 register Lisp_Object tem
;
5314 tem
= XCONS (tail
)->car
;
5315 if (EQ (propval
, tem
))
5317 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5320 if (CONSP (propval
))
5321 for (proptail
= propval
; CONSP (proptail
);
5322 proptail
= XCONS (proptail
)->cdr
)
5324 Lisp_Object propelt
;
5325 propelt
= XCONS (proptail
)->car
;
5326 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5328 register Lisp_Object tem
;
5329 tem
= XCONS (tail
)->car
;
5330 if (EQ (propelt
, tem
))
5332 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5339 /* Return 1 if PROPVAL appears as the car of an element of LIST
5340 and the cdr of that element is non-nil.
5341 If PROPVAL is a list, check each element of PROPVAL in that way,
5342 and the first time some element is found,
5343 return 1 if the cdr of that element is non-nil.
5345 This function cannot quit. */
5348 invisible_ellipsis_p (propval
, list
)
5349 register Lisp_Object propval
;
5352 register Lisp_Object tail
, proptail
;
5353 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5355 register Lisp_Object tem
;
5356 tem
= XCONS (tail
)->car
;
5357 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5358 return ! NILP (XCONS (tem
)->cdr
);
5360 if (CONSP (propval
))
5361 for (proptail
= propval
; CONSP (proptail
);
5362 proptail
= XCONS (proptail
)->cdr
)
5364 Lisp_Object propelt
;
5365 propelt
= XCONS (proptail
)->car
;
5366 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5368 register Lisp_Object tem
;
5369 tem
= XCONS (tail
)->car
;
5370 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5371 return ! NILP (XCONS (tem
)->cdr
);
5380 staticpro (&Qmenu_bar_update_hook
);
5381 Qmenu_bar_update_hook
= intern ("menu-bar-update-hook");
5383 staticpro (&Qoverriding_terminal_local_map
);
5384 Qoverriding_terminal_local_map
= intern ("overriding-terminal-local-map");
5386 staticpro (&Qoverriding_local_map
);
5387 Qoverriding_local_map
= intern ("overriding-local-map");
5389 staticpro (&Qwindow_scroll_functions
);
5390 Qwindow_scroll_functions
= intern ("window-scroll-functions");
5392 staticpro (&Qredisplay_end_trigger_functions
);
5393 Qredisplay_end_trigger_functions
= intern ("redisplay-end-trigger-functions");
5395 staticpro (&Qinhibit_point_motion_hooks
);
5396 Qinhibit_point_motion_hooks
= intern ("inhibit-point-motion-hooks");
5398 staticpro (&last_arrow_position
);
5399 staticpro (&last_arrow_string
);
5400 last_arrow_position
= Qnil
;
5401 last_arrow_string
= Qnil
;
5403 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
5404 "String (or mode line construct) included (normally) in `mode-line-format'.");
5405 Vglobal_mode_string
= Qnil
;
5407 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
5408 "Marker for where to display an arrow on top of the buffer text.\n\
5409 This must be the beginning of a line in order to work.\n\
5410 See also `overlay-arrow-string'.");
5411 Voverlay_arrow_position
= Qnil
;
5413 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
5414 "String to display as an arrow. See also `overlay-arrow-position'.");
5415 Voverlay_arrow_string
= Qnil
;
5417 DEFVAR_INT ("scroll-step", &scroll_step
,
5418 "*The number of lines to try scrolling a window by when point moves out.\n\
5419 If that fails to bring point back on frame, point is centered instead.\n\
5420 If this is zero, point is always centered after it moves off frame.");
5422 DEFVAR_INT ("scroll-conservatively", &scroll_conservatively
,
5423 "*Scroll up to this many lines, to bring point back on screen.");
5424 scroll_conservatively
= 0;
5426 DEFVAR_INT ("scroll-margin", &scroll_margin
,
5427 "*Number of lines of margin at the top and bottom of a window.\n\
5428 Recenter the window whenever point gets within this many lines\n\
5429 of the top or bottom of the window.");
5432 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
5434 DEFVAR_BOOL ("truncate-partial-width-windows",
5435 &truncate_partial_width_windows
,
5436 "*Non-nil means truncate lines in all windows less than full frame wide.");
5437 truncate_partial_width_windows
= 1;
5439 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
5440 "*Non-nil means use inverse video for the mode line.");
5441 mode_line_inverse_video
= 1;
5443 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
5444 "*Maximum buffer size (in characters) for line number display\n\
5445 If the buffer is bigger than this, the line number does not appear\n\
5446 in the mode line..");
5447 line_number_display_limit
= 1000000;
5449 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
5450 "*Non-nil means highlight region even in nonselected windows.");
5451 highlight_nonselected_windows
= 0;
5453 DEFVAR_BOOL ("multiple-frames", &multiple_frames
,
5454 "Non-nil if more than one frame is visible on this display.\n\
5455 Minibuffer-only frames don't count, but iconified frames do.\n\
5456 This variable is not guaranteed to be accurate except while processing\n\
5457 `frame-title-format' and `icon-title-format'.");
5459 DEFVAR_LISP ("frame-title-format", &Vframe_title_format
,
5460 "Template for displaying the titlebar of visible frames.\n\
5461 \(Assuming the window manager supports this feature.)\n\
5462 This variable has the same structure as `mode-line-format' (which see),\n\
5463 and is used only on frames for which no explicit name has been set\n\
5464 \(see `modify-frame-parameters').");
5465 DEFVAR_LISP ("icon-title-format", &Vicon_title_format
,
5466 "Template for displaying the titlebar of an iconified frame.\n\
5467 \(Assuming the window manager supports this feature.)\n\
5468 This variable has the same structure as `mode-line-format' (which see),\n\
5469 and is used only on frames for which no explicit name has been set\n\
5470 \(see `modify-frame-parameters').");
5472 = Vframe_title_format
5473 = Fcons (intern ("multiple-frames"),
5474 Fcons (build_string ("%b"),
5475 Fcons (Fcons (build_string (""),
5476 Fcons (intern ("invocation-name"),
5477 Fcons (build_string ("@"),
5478 Fcons (intern ("system-name"),
5482 DEFVAR_LISP ("message-log-max", &Vmessage_log_max
,
5483 "Maximum number of lines to keep in the message log buffer.\n\
5484 If nil, disable message logging. If t, log messages but don't truncate\n\
5485 the buffer when it becomes large.");
5486 XSETFASTINT (Vmessage_log_max
, 50);
5488 DEFVAR_LISP ("window-size-change-functions", &Vwindow_size_change_functions
,
5489 "Functions called before redisplay, if window sizes have changed.\n\
5490 The value should be a list of functions that take one argument.\n\
5491 Just before redisplay, for each frame, if any of its windows have changed\n\
5492 size since the last redisplay, or have been split or deleted,\n\
5493 all the functions in the list are called, with the frame as argument.");
5494 Vwindow_size_change_functions
= Qnil
;
5496 DEFVAR_LISP ("window-scroll-functions", &Vwindow_scroll_functions
,
5497 "List of functions to call before redisplaying a window with scrolling.\n\
5498 Each function is called with two arguments, the window\n\
5499 and its new display-start position. Note that the value of `window-end'\n\
5500 is not valid when these functions are called.");
5501 Vwindow_scroll_functions
= Qnil
;
5503 DEFVAR_INT ("minibuffer-scroll-overlap", &minibuffer_scroll_overlap
,
5504 "*Number of characters of overlap when scrolling a one-line window.\n\
5505 This commonly affects the minibuffer window, hence the name of the variable.");
5506 minibuffer_scroll_overlap
= 20;
5509 /* initialize the window system */
5513 Lisp_Object root_window
;
5514 #ifndef COMPILER_REGISTER_BUG
5516 #endif /* COMPILER_REGISTER_BUG */
5517 struct window
*mini_w
;
5519 this_line_bufpos
= 0;
5521 mini_w
= XWINDOW (minibuf_window
);
5522 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
5524 echo_area_glyphs
= 0;
5525 previous_echo_glyphs
= 0;
5527 if (!noninteractive
)
5529 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
5530 XSETFASTINT (XWINDOW (root_window
)->top
, FRAME_MENU_BAR_LINES (f
));
5531 set_window_height (root_window
,
5532 FRAME_HEIGHT (f
) - 1 - FRAME_MENU_BAR_LINES (f
),
5534 XSETFASTINT (mini_w
->top
, FRAME_HEIGHT (f
) - 1);
5535 set_window_height (minibuf_window
, 1, 0);
5537 XSETFASTINT (XWINDOW (root_window
)->width
, FRAME_WIDTH (f
));
5538 XSETFASTINT (mini_w
->width
, FRAME_WIDTH (f
));