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"
44 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
45 extern void set_frame_menubar ();
46 extern int pending_menu_activation
;
49 extern int interrupt_input
;
50 extern int command_loop_level
;
52 extern int minibuffer_auto_raise
;
54 extern Lisp_Object Qface
;
56 extern Lisp_Object Voverriding_local_map
;
57 extern Lisp_Object Voverriding_local_map_menu_flag
;
59 Lisp_Object Qoverriding_local_map
, Qoverriding_terminal_local_map
;
60 Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
61 Lisp_Object Qredisplay_end_trigger_functions
;
63 /* Nonzero means print newline to stdout before next minibuffer message. */
65 int noninteractive_need_newline
;
67 /* Nonzero means print newline to message log before next message. */
69 static int message_log_need_newline
;
71 #define min(a, b) ((a) < (b) ? (a) : (b))
72 #define max(a, b) ((a) > (b) ? (a) : (b))
73 #define minmax(floor, val, ceil) \
74 ((val) < (floor) ? (floor) : (val) > (ceil) ? (ceil) : (val))
76 /* The buffer position of the first character appearing
77 entirely or partially on the current frame line.
78 Or zero, which disables the optimization for the current frame line. */
79 static int this_line_bufpos
;
81 /* Number of characters past the end of this line,
82 including the terminating newline */
83 static int this_line_endpos
;
85 /* The vertical position of this frame line. */
86 static int this_line_vpos
;
88 /* Hpos value for start of display on this frame line.
89 Usually zero, but negative if first character really began
91 static int this_line_start_hpos
;
93 /* Buffer that this_line variables are describing. */
94 static struct buffer
*this_line_buffer
;
96 /* Value of echo_area_glyphs when it was last acted on.
97 If this is nonzero, there is a message on the frame
98 in the minibuffer and it should be erased as soon
99 as it is no longer requested to appear. */
100 char *previous_echo_glyphs
;
102 /* Nonzero means truncate lines in all windows less wide than the frame */
103 int truncate_partial_width_windows
;
105 /* Nonzero means we have more than one non-minibuffer-only frame.
106 Not guaranteed to be accurate except while parsing frame-title-format. */
109 Lisp_Object Vglobal_mode_string
;
111 /* Marker for where to display an arrow on top of the buffer text. */
112 Lisp_Object Voverlay_arrow_position
;
114 /* String to display for the arrow. */
115 Lisp_Object Voverlay_arrow_string
;
117 /* Values of those variables at last redisplay.
118 However, if Voverlay_arrow_position is a marker,
119 last_arrow_position is its numerical position. */
120 static Lisp_Object last_arrow_position
, last_arrow_string
;
122 /* Like mode-line-format, but for the titlebar on a visible frame. */
123 Lisp_Object Vframe_title_format
;
125 /* Like mode-line-format, but for the titlebar on an iconified frame. */
126 Lisp_Object Vicon_title_format
;
128 /* List of functions to call when a window's size changes. These
129 functions get one arg, a frame on which one or more windows' sizes
131 static Lisp_Object Vwindow_size_change_functions
;
133 Lisp_Object Qmenu_bar_update_hook
;
135 /* Nonzero if overlay arrow has been displayed once in this window. */
136 static int overlay_arrow_seen
;
138 /* Nonzero if visible end of buffer has already been displayed once
139 in this window. (We need this variable in case there are overlay
140 strings that get displayed there.) */
141 static int zv_strings_seen
;
143 /* Nonzero means highlight the region even in nonselected windows. */
144 static int highlight_nonselected_windows
;
146 /* If cursor motion alone moves point off frame,
147 Try scrolling this many lines up or down if that will bring it back. */
148 static int scroll_step
;
150 /* Non-0 means scroll just far enough to bring point back on the screen,
152 static int scroll_conservatively
;
154 /* Recenter the window whenever point gets within this many lines
155 of the top or bottom of the window. */
158 /* Number of characters of overlap to show,
159 when scrolling a one-line window such as a minibuffer. */
160 static int minibuffer_scroll_overlap
;
162 /* Nonzero if try_window_id has made blank lines at window bottom
163 since the last redisplay that paused */
164 static int blank_end_of_window
;
166 /* Number of windows showing the buffer of the selected window
167 (or another buffer with the same base buffer).
168 keyboard.c refers to this. */
171 /* display_text_line sets these to the frame position (origin 0) of point,
172 whether the window is selected or not.
173 Set one to -1 first to determine whether point was found afterwards. */
175 static int cursor_vpos
;
176 static int cursor_hpos
;
178 static int debug_end_pos
;
180 /* Nonzero means display mode line highlighted */
181 int mode_line_inverse_video
;
183 static void redisplay_internal ();
184 static int message_log_check_duplicate ();
185 static void echo_area_display ();
186 void mark_window_display_accurate ();
187 static void redisplay_windows ();
188 static void redisplay_window ();
189 static void update_menu_bar ();
190 static void try_window ();
191 static int try_window_id ();
192 static struct position
*display_text_line ();
193 static void display_mode_line ();
194 static int display_mode_element ();
195 static char *decode_mode_spec ();
196 static int display_string ();
197 static void display_menu_bar ();
198 static int display_count_lines ();
200 /* Prompt to display in front of the minibuffer contents */
201 Lisp_Object minibuf_prompt
;
203 /* Width in columns of current minibuffer prompt. */
204 int minibuf_prompt_width
;
206 /* Message to display instead of minibuffer contents
207 This is what the functions error and message make,
208 and command echoing uses it as well.
209 It overrides the minibuf_prompt as well as the buffer. */
210 char *echo_area_glyphs
;
212 /* This is the length of the message in echo_area_glyphs. */
213 int echo_area_glyphs_length
;
215 /* This is the window where the echo area message was displayed.
216 It is always a minibuffer window, but it may not be the
217 same window currently active as a minibuffer. */
218 Lisp_Object echo_area_window
;
220 /* Nonzero means multibyte characters were enabled when the echo area
221 message was specified. */
222 int message_enable_multibyte
;
224 /* true iff we should redraw the mode lines on the next redisplay */
225 int update_mode_lines
;
227 /* Smallest number of characters before the gap
228 at any time since last redisplay that finished.
229 Valid for current buffer when try_window_id can be called. */
232 /* Smallest number of characters after the gap
233 at any time since last redisplay that finished.
234 Valid for current buffer when try_window_id can be called. */
237 /* MODIFF as of last redisplay that finished;
238 if it matches MODIFF, and overlay_unchanged_modified
239 matches OVERLAY_MODIFF, that means beg_unchanged and end_unchanged
240 contain no useful information */
241 int unchanged_modified
;
243 /* OVERLAY_MODIFF as of last redisplay that finished. */
244 int overlay_unchanged_modified
;
246 /* Nonzero if window sizes or contents have changed
247 since last redisplay that finished */
248 int windows_or_buffers_changed
;
250 /* Nonzero after display_mode_line if %l was used
251 and it displayed a line number. */
252 int line_number_displayed
;
254 /* Maximum buffer size for which to display line numbers. */
255 static int line_number_display_limit
;
257 /* Number of lines to keep in the message log buffer.
258 t means infinite. nil means don't log at all. */
259 Lisp_Object Vmessage_log_max
;
261 #define COERCE_MARKER(X) \
262 (MARKERP ((X)) ? Fmarker_position (X) : (X))
264 static int pos_tab_offset
P_ ((struct window
*, int, int));
266 /* Output a newline in the *Messages* buffer if "needs" one. */
269 message_log_maybe_newline ()
271 if (message_log_need_newline
)
272 message_dolog ("", 0, 1, 0);
276 /* Add a string to the message log, optionally terminated with a newline.
277 This function calls low-level routines in order to bypass text property
278 hooks, etc. which might not be safe to run.
279 MULTIBYTE, if nonzero, means interpret the contents of M as multibyte. */
282 message_dolog (m
, len
, nlflag
, multibyte
)
284 int len
, nlflag
, multibyte
;
286 if (!NILP (Vmessage_log_max
))
288 struct buffer
*oldbuf
;
289 Lisp_Object oldpoint
, oldbegv
, oldzv
;
290 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
291 int point_at_end
= 0;
293 Lisp_Object old_deactivate_mark
;
295 old_deactivate_mark
= Vdeactivate_mark
;
296 oldbuf
= current_buffer
;
297 Fset_buffer (Fget_buffer_create (build_string ("*Messages*")));
298 current_buffer
->undo_list
= Qt
;
300 oldpoint
= Fpoint_marker ();
301 oldbegv
= Fpoint_min_marker ();
302 oldzv
= Fpoint_max_marker ();
310 BEGV_BYTE
= BEG_BYTE
;
313 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
315 /* Insert the string--maybe converting multibyte to single byte
316 or vice versa, so that all the text fits the buffer. */
318 && NILP (current_buffer
->enable_multibyte_characters
))
320 int c
, i
= 0, nbytes
;
321 /* Convert a multibyte string to single-byte
322 for the *Message* buffer. */
325 c
= STRING_CHAR (m
+ i
, len
- i
);
326 i
+= XFASTINT (Fchar_bytes (make_number (c
)));
327 /* Truncate the character to its last byte--we can only hope
328 the user is happy with the character he gets,
329 since if it isn't right, there is no way to do it right. */
335 && ! NILP (current_buffer
->enable_multibyte_characters
))
338 unsigned char *msg
= (unsigned char *) m
;
339 /* Convert a single-byte string to multibyte
340 for the *Message* buffer. */
343 int c
= unibyte_char_to_multibyte (msg
[i
++]);
348 insert_1 (m
, len
, 1, 0, 0);
352 int this_bol
, this_bol_byte
, prev_bol
, prev_bol_byte
, dup
;
353 insert_1 ("\n", 1, 1, 0, 0);
355 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
, -2, 0);
357 this_bol_byte
= PT_BYTE
;
361 scan_newline (PT
, PT_BYTE
, BEG
, BEG_BYTE
, -2, 0);
363 prev_bol_byte
= PT_BYTE
;
365 dup
= message_log_check_duplicate (prev_bol
, prev_bol_byte
,
366 this_bol
, this_bol_byte
);
369 del_range_both (prev_bol
, prev_bol_byte
,
370 this_bol
, this_bol_byte
, 0);
376 /* If you change this format, don't forget to also
377 change message_log_check_duplicate. */
378 sprintf (dupstr
, " [%d times]", dup
);
379 duplen
= strlen (dupstr
);
380 TEMP_SET_PT_BOTH (Z
- 1, Z_BYTE
- 1);
381 insert_1 (dupstr
, duplen
, 1, 0, 1);
386 if (NATNUMP (Vmessage_log_max
))
388 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
,
389 -XFASTINT (Vmessage_log_max
) - 1, 0);
390 del_range_both (BEG
, BEG_BYTE
, PT
, PT_BYTE
, 0);
393 BEGV
= XMARKER (oldbegv
)->charpos
;
394 BEGV_BYTE
= marker_byte_position (oldbegv
);
403 ZV
= XMARKER (oldzv
)->charpos
;
404 ZV_BYTE
= marker_byte_position (oldzv
);
408 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
410 Fgoto_char (oldpoint
);
412 free_marker (oldpoint
);
413 free_marker (oldbegv
);
416 set_buffer_internal (oldbuf
);
417 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
418 message_log_need_newline
= !nlflag
;
419 Vdeactivate_mark
= old_deactivate_mark
;
423 /* We are at the end of the buffer after just having inserted a newline.
424 (Note: We depend on the fact we won't be crossing the gap.)
425 Check to see if the most recent message looks a lot like the previous one.
426 Return 0 if different, 1 if the new one should just replace it, or a
427 value N > 1 if we should also append " [N times]". */
430 message_log_check_duplicate (prev_bol
, prev_bol_byte
, this_bol
, this_bol_byte
)
431 int prev_bol
, this_bol
;
432 int prev_bol_byte
, this_bol_byte
;
435 int len
= Z
- 1 - this_bol
;
437 unsigned char *p1
= BUF_BYTE_ADDRESS (current_buffer
, prev_bol_byte
);
438 unsigned char *p2
= BUF_BYTE_ADDRESS (current_buffer
, this_bol_byte
);
440 for (i
= 0; i
< len
; i
++)
442 if (i
>= 3 && p1
[i
-3] == '.' && p1
[i
-2] == '.' && p1
[i
-1] == '.'
451 if (*p1
++ == ' ' && *p1
++ == '[')
454 while (*p1
>= '0' && *p1
<= '9')
455 n
= n
* 10 + *p1
++ - '0';
456 if (strncmp (p1
, " times]\n", 8) == 0)
462 /* Display an echo area message M with a specified length of LEN chars.
463 The string may include null characters. If M is 0, clear out any
464 existing message, and let the minibuffer text show through.
466 The buffer M must continue to exist until after the echo area
467 gets cleared or some other message gets displayed there.
469 Do not pass text that is stored in a Lisp string.
470 Do not pass text in a buffer that was alloca'd. */
473 message2 (m
, len
, multibyte
)
478 /* First flush out any partial line written with print. */
479 message_log_maybe_newline ();
481 message_dolog (m
, len
, 1, multibyte
);
482 message2_nolog (m
, len
, multibyte
);
486 /* The non-logging counterpart of message2. */
489 message2_nolog (m
, len
, multibyte
)
493 message_enable_multibyte
= multibyte
;
497 if (noninteractive_need_newline
)
499 noninteractive_need_newline
= 0;
501 fwrite (m
, len
, 1, stderr
);
502 if (cursor_in_echo_area
== 0)
503 fprintf (stderr
, "\n");
506 /* A null message buffer means that the frame hasn't really been
507 initialized yet. Error messages get reported properly by
508 cmd_error, so this must be just an informative message; toss it. */
509 else if (INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
511 Lisp_Object mini_window
;
514 /* Get the frame containing the minibuffer
515 that the selected frame is using. */
516 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
517 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
519 FRAME_SAMPLE_VISIBILITY (f
);
520 if (FRAME_VISIBLE_P (selected_frame
)
521 && ! FRAME_VISIBLE_P (f
))
522 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (mini_window
)));
526 echo_area_glyphs
= m
;
527 echo_area_glyphs_length
= len
;
529 if (minibuffer_auto_raise
)
530 Fraise_frame (WINDOW_FRAME (XWINDOW (mini_window
)));
533 echo_area_glyphs
= previous_echo_glyphs
= 0;
535 do_pending_window_change ();
536 echo_area_display ();
537 update_frame (f
, 1, 1);
538 do_pending_window_change ();
539 if (frame_up_to_date_hook
!= 0 && ! gc_in_progress
)
540 (*frame_up_to_date_hook
) (f
);
544 /* Display in echo area the null-terminated ASCII-only string M.
545 If M is 0, clear out any existing message,
546 and let the minibuffer text show through.
548 The string M must continue to exist until after the echo area
549 gets cleared or some other message gets displayed there.
551 Do not pass text that is stored in a Lisp string.
552 Do not pass text in a buffer that was alloca'd. */
558 message2 (m
, (m
? strlen (m
) : 0), 0);
565 message2_nolog (m
, (m
? strlen (m
) : 0), 0);
568 /* Display a message M which contains a single %s
569 which gets replaced with STRING. */
572 message_with_string (m
, string
, log
)
581 if (noninteractive_need_newline
)
583 noninteractive_need_newline
= 0;
584 fprintf (stderr
, m
, XSTRING (string
)->data
);
585 if (cursor_in_echo_area
== 0)
586 fprintf (stderr
, "\n");
590 else if (INTERACTIVE
)
592 /* The frame whose minibuffer we're going to display the message on.
593 It may be larger than the selected frame, so we need
594 to use its buffer, not the selected frame's buffer. */
595 Lisp_Object mini_window
;
598 /* Get the frame containing the minibuffer
599 that the selected frame is using. */
600 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
601 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
603 /* A null message buffer means that the frame hasn't really been
604 initialized yet. Error messages get reported properly by
605 cmd_error, so this must be just an informative message; toss it. */
606 if (FRAME_MESSAGE_BUF (f
))
610 a
[0] = (char *) XSTRING (string
)->data
;
612 len
= doprnt (FRAME_MESSAGE_BUF (f
),
613 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
616 message2 (FRAME_MESSAGE_BUF (f
), len
,
617 STRING_MULTIBYTE (string
));
619 message2_nolog (FRAME_MESSAGE_BUF (f
), len
,
620 STRING_MULTIBYTE (string
));
622 /* Print should start at the beginning of the message
624 message_buf_print
= 0;
629 /* Truncate what will be displayed in the echo area
630 the next time we display it--but don't redisplay it now. */
633 truncate_echo_area (len
)
636 /* A null message buffer means that the frame hasn't really been
637 initialized yet. Error messages get reported properly by
638 cmd_error, so this must be just an informative message; toss it. */
639 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
640 echo_area_glyphs_length
= len
;
643 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
644 zero if being used by message. */
645 int message_buf_print
;
647 /* Dump an informative message to the minibuf. If M is 0, clear out
648 any existing message, and let the minibuffer text show through. */
652 message (m
, a1
, a2
, a3
)
654 EMACS_INT a1
, a2
, a3
;
660 if (noninteractive_need_newline
)
662 noninteractive_need_newline
= 0;
663 fprintf (stderr
, m
, a1
, a2
, a3
);
664 if (cursor_in_echo_area
== 0)
665 fprintf (stderr
, "\n");
669 else if (INTERACTIVE
)
671 /* The frame whose minibuffer we're going to display the message on.
672 It may be larger than the selected frame, so we need
673 to use its buffer, not the selected frame's buffer. */
674 Lisp_Object mini_window
;
677 /* Get the frame containing the minibuffer
678 that the selected frame is using. */
679 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
680 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
682 /* A null message buffer means that the frame hasn't really been
683 initialized yet. Error messages get reported properly by
684 cmd_error, so this must be just an informative message; toss it. */
685 if (FRAME_MESSAGE_BUF (f
))
696 len
= doprnt (FRAME_MESSAGE_BUF (f
),
697 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
699 len
= doprnt (FRAME_MESSAGE_BUF (f
),
700 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3,
702 #endif /* NO_ARG_ARRAY */
704 message2 (FRAME_MESSAGE_BUF (f
), len
, 0);
709 /* Print should start at the beginning of the message
711 message_buf_print
= 0;
716 /* The non-logging version of message. */
718 message_nolog (m
, a1
, a2
, a3
)
720 EMACS_INT a1
, a2
, a3
;
722 Lisp_Object old_log_max
;
723 old_log_max
= Vmessage_log_max
;
724 Vmessage_log_max
= Qnil
;
725 message (m
, a1
, a2
, a3
);
726 Vmessage_log_max
= old_log_max
;
732 message2 (echo_area_glyphs
, echo_area_glyphs_length
,
733 ! NILP (current_buffer
->enable_multibyte_characters
));
741 Lisp_Object mini_window
;
743 /* Choose the minibuffer window for this display.
744 It is the minibuffer window used by the selected frame. */
745 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
746 /* This is the frame that window is in. */
747 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
749 if (! FRAME_VISIBLE_P (f
))
754 redraw_garbaged_frames ();
758 if (echo_area_glyphs
|| minibuf_level
== 0)
762 echo_area_window
= mini_window
;
764 vpos
= XFASTINT (XWINDOW (mini_window
)->top
);
765 get_display_line (f
, vpos
, 0);
767 /* Make sure the columns that overlap a left-hand scroll bar
769 for (i
= 0; i
< FRAME_LEFT_SCROLL_BAR_WIDTH (f
); i
++)
770 f
->desired_glyphs
->glyphs
[vpos
][i
] = SPACEGLYPH
;
772 display_string (XWINDOW (mini_window
), vpos
,
773 echo_area_glyphs
? echo_area_glyphs
: "",
774 echo_area_glyphs
? echo_area_glyphs_length
: -1,
775 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
777 FRAME_WIDTH (f
) + FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
778 message_enable_multibyte
);
780 #if 0 /* This just gets in the way. update_frame does the job. */
781 /* If desired cursor location is on this line, put it at end of text */
782 if (cursor_in_echo_area
)
783 FRAME_CURSOR_Y (f
) = vpos
;
784 if (FRAME_CURSOR_Y (f
) == vpos
)
785 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
788 /* Fill the rest of the minibuffer window with blank lines. */
793 i
< vpos
+ XFASTINT (XWINDOW (mini_window
)->height
); i
++)
795 get_display_line (f
, i
, 0);
796 /* We don't use FRAME_SCROLL_BAR_WIDTH (f) as the starting
797 hpos, because it is good to clear whatever is behind the
798 scroll bar. This does not affect the scroll bar itself. */
799 display_string (XWINDOW (mini_window
), i
,
802 0, FRAME_WIDTH (f
) + FRAME_SCROLL_BAR_WIDTH (f
),
807 else if (!EQ (mini_window
, selected_window
))
808 windows_or_buffers_changed
++;
810 if (EQ (mini_window
, selected_window
))
811 this_line_bufpos
= 0;
813 previous_echo_glyphs
= echo_area_glyphs
;
816 /* Update frame titles. */
818 #ifdef HAVE_WINDOW_SYSTEM
819 static char frame_title_buf
[512];
820 static char *frame_title_ptr
;
823 store_frame_title (str
, mincol
, maxcol
)
828 if (maxcol
< 0 || maxcol
>= sizeof(frame_title_buf
))
829 maxcol
= sizeof (frame_title_buf
);
830 limit
= &frame_title_buf
[maxcol
];
831 while (*str
!= '\0' && frame_title_ptr
< limit
)
832 *frame_title_ptr
++ = *str
++;
833 while (frame_title_ptr
< &frame_title_buf
[mincol
])
834 *frame_title_ptr
++ = ' ';
835 return frame_title_ptr
- frame_title_buf
;
839 x_consider_frame_title (frame
)
845 FRAME_PTR f
= XFRAME (frame
);
847 if (!(FRAME_WINDOW_P (f
) || FRAME_MINIBUF_ONLY_P (f
) || f
->explicit_name
))
850 /* Do we have more than one visible frame on this X display? */
854 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
856 FRAME_PTR tf
= XFRAME (XCONS (tail
)->car
);
858 if (tf
!= f
&& FRAME_KBOARD (tf
) == FRAME_KBOARD (f
)
859 && !FRAME_MINIBUF_ONLY_P (tf
)
860 && (FRAME_VISIBLE_P (tf
) || FRAME_ICONIFIED_P (tf
)))
864 multiple_frames
= CONSP (tail
);
867 obuf
= current_buffer
;
868 Fset_buffer (XWINDOW (f
->selected_window
)->buffer
);
869 fmt
= (FRAME_ICONIFIED_P (f
) ? Vicon_title_format
: Vframe_title_format
);
870 frame_title_ptr
= frame_title_buf
;
871 len
= display_mode_element (XWINDOW (f
->selected_window
), 0, 0, 0,
872 0, sizeof (frame_title_buf
), fmt
);
874 set_buffer_internal (obuf
);
875 /* Set the name only if it's changed. This avoids consing
876 in the common case where it hasn't. (If it turns out that we've
877 already wasted too much time by walking through the list with
878 display_mode_element, then we might need to optimize at a higher
880 if (! STRINGP (f
->name
) || STRING_BYTES (XSTRING (f
->name
)) != len
881 || bcmp (frame_title_buf
, XSTRING (f
->name
)->data
, len
) != 0)
882 x_implicitly_set_name (f
, make_string (frame_title_buf
, len
), Qnil
);
885 #define frame_title_ptr ((char *)0)
886 #define store_frame_title(str, mincol, maxcol) 0
889 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
890 This can call eval. */
895 register struct window
*w
= XWINDOW (selected_window
);
897 struct gcpro gcpro1
, gcpro2
;
899 all_windows
= (update_mode_lines
|| buffer_shared
> 1
900 || windows_or_buffers_changed
);
902 /* Update all frame titles based on their buffer names, etc.
903 We do this before the menu bars so that the buffer-menu
904 will show the up-to-date frame titles.
906 This used to be done after the menu bars, for a reason that
907 was stated as follows but which I do not understand:
908 "We do this after the menu bars so that the frame will first
909 create its menu bar using the name `emacs' if no other name
910 has yet been specified."
911 I think that is no longer a concern. */
912 #ifdef HAVE_WINDOW_SYSTEM
913 if (windows_or_buffers_changed
|| update_mode_lines
)
915 Lisp_Object tail
, frame
;
917 FOR_EACH_FRAME (tail
, frame
)
918 if (FRAME_VISIBLE_P (XFRAME (frame
))
919 || FRAME_ICONIFIED_P (XFRAME (frame
)))
920 x_consider_frame_title (frame
);
924 /* Update the menu bar item lists, if appropriate.
925 This has to be done before any actual redisplay
926 or generation of display lines. */
929 Lisp_Object tail
, frame
;
930 int count
= specpdl_ptr
- specpdl
;
932 record_unwind_protect (Fset_match_data
, Fmatch_data (Qnil
, Qnil
));
934 FOR_EACH_FRAME (tail
, frame
)
936 /* If a window on this frame changed size,
937 report that to the user and clear the size-change flag. */
938 if (FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)))
940 Lisp_Object functions
;
941 /* Clear flag first in case we get error below. */
942 FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)) = 0;
943 functions
= Vwindow_size_change_functions
;
944 GCPRO2 (tail
, functions
);
945 while (CONSP (functions
))
947 call1 (XCONS (functions
)->car
, frame
);
948 functions
= XCONS (functions
)->cdr
;
953 update_menu_bar (XFRAME (frame
), 0);
957 unbind_to (count
, Qnil
);
960 update_menu_bar (selected_frame
, 1);
962 /* Motif needs this. See comment in xmenu.c.
963 Turn it off when pending_menu_activation is not defined. */
965 pending_menu_activation
= 0;
969 /* Do a frame update, taking possible shortcuts into account.
970 This is the main external entry point for redisplay.
972 If the last redisplay displayed an echo area message and that
973 message is no longer requested, we clear the echo area
974 or bring back the minibuffer if that is in use.
976 Do not call eval from within this function.
977 Calls to eval after the call to echo_area_display would confuse
978 the display_line mechanism and would cause a crash.
979 Calls to eval before that point will work most of the time,
980 but can still lose, because this function
981 can be called from signal handlers; with alarms set up;
982 or with synchronous processes running.
984 See Fcall_process; if you called it from here, it could be
985 entered recursively. */
987 static int do_verify_charstarts
;
989 /* Counter is used to clear the face cache
990 no more than once ever 1000 redisplays. */
991 static int clear_face_cache_count
;
993 /* Record the previous terminal frame we displayed. */
994 static FRAME_PTR previous_terminal_frame
;
999 redisplay_internal (0);
1002 /* If PRESERVE_ECHO_AREA is nonzero, it means this redisplay
1003 is not in response to any user action; therefore, we should
1004 preserve the echo area. (Actually, our caller does that job.)
1005 Perhaps in the future avoid recentering windows
1006 if it is not necessary; currently that causes some problems. */
1009 redisplay_internal (preserve_echo_area
)
1010 int preserve_echo_area
;
1012 register struct window
*w
= XWINDOW (selected_window
);
1014 int must_finish
= 0;
1016 register int tlbufpos
, tlendpos
;
1017 struct position pos
;
1018 int number_of_visible_frames
;
1023 #ifdef USE_X_TOOLKIT
1024 if (popup_activated ())
1030 if (! FRAME_WINDOW_P (selected_frame
)
1031 && previous_terminal_frame
!= selected_frame
)
1033 /* Since frames on an ASCII terminal share the same display area,
1034 displaying a different frame means redisplay the whole thing. */
1035 windows_or_buffers_changed
++;
1036 SET_FRAME_GARBAGED (selected_frame
);
1037 XSETFRAME (Vterminal_frame
, selected_frame
);
1039 previous_terminal_frame
= selected_frame
;
1041 /* Set the visible flags for all frames.
1042 Do this before checking for resized or garbaged frames; they want
1043 to know if their frames are visible.
1044 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
1046 Lisp_Object tail
, frame
;
1048 number_of_visible_frames
= 0;
1050 FOR_EACH_FRAME (tail
, frame
)
1052 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1054 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1055 number_of_visible_frames
++;
1057 /* Clear out all the display lines in which we will generate the
1058 glyphs to display. */
1059 init_desired_glyphs (XFRAME (frame
));
1063 /* Notice any pending interrupt request to change frame size. */
1064 do_pending_window_change ();
1068 redraw_garbaged_frames ();
1072 prepare_menu_bars ();
1074 if (windows_or_buffers_changed
)
1075 update_mode_lines
++;
1077 /* Detect case that we need to write or remove a star in the mode line. */
1078 if ((SAVE_MODIFF
< MODIFF
) != !NILP (w
->last_had_star
))
1080 w
->update_mode_line
= Qt
;
1081 if (buffer_shared
> 1)
1082 update_mode_lines
++;
1085 /* If %c is in use, update it if needed. */
1086 if (!NILP (w
->column_number_displayed
)
1087 /* This alternative quickly identifies a common case
1088 where no change is needed. */
1089 && !(PT
== XFASTINT (w
->last_point
)
1090 && XFASTINT (w
->last_modified
) >= MODIFF
1091 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1092 && XFASTINT (w
->column_number_displayed
) != current_column ())
1093 w
->update_mode_line
= Qt
;
1095 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
1097 all_windows
= update_mode_lines
|| buffer_shared
> 1;
1099 /* If specs for an arrow have changed, do thorough redisplay
1100 to ensure we remove any arrow that should no longer exist. */
1101 if (! EQ (COERCE_MARKER (Voverlay_arrow_position
), last_arrow_position
)
1102 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
1105 /* Normally the message* functions will have already displayed and
1106 updated the echo area, but the frame may have been trashed, or
1107 the update may have been preempted, so display the echo area
1109 if (echo_area_glyphs
|| previous_echo_glyphs
)
1111 echo_area_display ();
1115 /* If showing region, and mark has changed, must redisplay whole window. */
1116 if (((!NILP (Vtransient_mark_mode
)
1117 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1118 != !NILP (w
->region_showing
))
1119 || (!NILP (w
->region_showing
)
1120 && !EQ (w
->region_showing
,
1121 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
1122 this_line_bufpos
= -1;
1124 tlbufpos
= this_line_bufpos
;
1125 tlendpos
= this_line_endpos
;
1126 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
1127 && !current_buffer
->clip_changed
1128 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
1129 && !FRAME_OBSCURED_P (XFRAME (w
->frame
))
1130 /* Make sure recorded data applies to current buffer, etc */
1131 && this_line_buffer
== current_buffer
1132 && current_buffer
== XBUFFER (w
->buffer
)
1133 && NILP (w
->force_start
)
1134 /* Point must be on the line that we have info recorded about */
1136 && PT
<= Z
- tlendpos
1137 /* All text outside that line, including its final newline,
1138 must be unchanged */
1139 && ((XFASTINT (w
->last_modified
) >= MODIFF
1140 && (XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
))
1141 || (beg_unchanged
>= tlbufpos
- 1
1143 /* If selective display, can't optimize
1144 if the changes start at the beginning of the line. */
1145 && ((INTEGERP (current_buffer
->selective_display
)
1146 && XINT (current_buffer
->selective_display
) > 0
1147 ? (beg_unchanged
>= tlbufpos
1150 && end_unchanged
>= tlendpos
1151 && Z
- GPT
>= tlendpos
)))
1153 int tlbufpos_byte
= CHAR_TO_BYTE (tlbufpos
);
1154 if (tlbufpos
> BEGV
&& FETCH_BYTE (tlbufpos_byte
- 1) != '\n'
1156 || FETCH_BYTE (tlbufpos_byte
) == '\n'))
1157 /* Former continuation line has disappeared by becoming empty */
1159 else if (XFASTINT (w
->last_modified
) < MODIFF
1160 || XFASTINT (w
->last_overlay_modified
) < OVERLAY_MODIFF
1161 || MINI_WINDOW_P (w
))
1163 /* We have to handle the case of continuation around a
1164 wide-column character (See the comment in indent.c around
1167 For instance, in the following case:
1169 -------- Insert --------
1170 K_A_N_\\ `a' K_A_N_a\ `X_' are wide-column chars.
1171 J_I_ ==> J_I_ `^^' are cursors.
1175 As we have to redraw the line above, we should goto cancel. */
1177 struct position val
;
1179 int opoint
= PT
, opoint_byte
= PT_BYTE
;
1181 scan_newline (tlbufpos
, tlbufpos_byte
, BEGV
, BEGV_BYTE
, -1, 1);
1183 val
= *compute_motion (PT
, 0,
1184 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1187 1 << (BITS_PER_SHORT
- 1),
1188 1 << (BITS_PER_SHORT
- 1),
1189 window_internal_width (w
) - 1,
1190 XINT (w
->hscroll
), 0, w
);
1191 SET_PT_BOTH (opoint
, opoint_byte
);
1192 if (val
.hpos
!= this_line_start_hpos
)
1196 overlay_arrow_seen
= 0;
1197 zv_strings_seen
= 0;
1198 display_text_line (w
, tlbufpos
, tlbufpos_byte
,
1199 this_line_vpos
, this_line_start_hpos
,
1200 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
), 0);
1201 /* If line contains point, is not continued,
1202 and ends at same distance from eob as before, we win */
1203 if (cursor_vpos
>= 0 && this_line_bufpos
1204 && this_line_endpos
== tlendpos
)
1206 /* If this is not the window's last line,
1207 we must adjust the charstarts of the lines below. */
1208 if (this_line_vpos
+ 1
1209 < XFASTINT (w
->top
) + window_internal_height (w
))
1211 int left
= WINDOW_LEFT_MARGIN (w
);
1212 int *charstart_next_line
1213 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
1216 if (Z
- tlendpos
== ZV
)
1217 /* This line ends at end of (accessible part of) buffer.
1218 There is no newline to count. */
1219 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
1221 /* This line ends in a newline.
1222 Must take account of the newline and the rest of the
1223 text that follows. */
1224 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
1226 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
1229 if (!WINDOW_FULL_WIDTH_P (w
))
1230 preserve_other_columns (w
);
1236 else if (PT
== XFASTINT (w
->last_point
)
1237 /* Make sure the cursor was last displayed
1238 in this window. Otherwise we have to reposition it. */
1239 && XINT (w
->top
) <= FRAME_CURSOR_Y (selected_frame
)
1240 && (XINT (w
->top
) + XINT (w
->height
)
1241 > FRAME_CURSOR_Y (selected_frame
)))
1245 do_pending_window_change ();
1250 /* If highlighting the region, or if the cursor is in the echo area,
1251 then we can't just move the cursor. */
1252 else if (! (!NILP (Vtransient_mark_mode
)
1253 && !NILP (current_buffer
->mark_active
))
1254 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1255 || highlight_nonselected_windows
)
1256 && NILP (w
->region_showing
)
1257 && !cursor_in_echo_area
)
1259 pos
= *compute_motion (tlbufpos
, 0,
1260 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1262 PT
, 2, - (1 << (BITS_PER_SHORT
- 1)),
1263 window_internal_width (w
) - 1,
1265 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
),
1269 int width
= window_internal_width (w
) - 1;
1270 FRAME_CURSOR_X (selected_frame
)
1271 = WINDOW_LEFT_MARGIN (w
) + minmax (0, pos
.hpos
, width
);
1272 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
1279 /* Text changed drastically or point moved off of line */
1280 cancel_line (this_line_vpos
, selected_frame
);
1283 this_line_bufpos
= 0;
1284 all_windows
|= buffer_shared
> 1;
1286 clear_face_cache_count
++;
1290 Lisp_Object tail
, frame
;
1293 /* Clear the face cache, only when we do a full redisplay
1294 and not too often either. */
1295 if (clear_face_cache_count
> 1000)
1297 clear_face_cache ();
1298 clear_face_cache_count
= 0;
1302 /* Recompute # windows showing selected buffer.
1303 This will be incremented each time such a window is displayed. */
1306 FOR_EACH_FRAME (tail
, frame
)
1308 FRAME_PTR f
= XFRAME (frame
);
1309 if (FRAME_WINDOW_P (f
) || f
== selected_frame
)
1312 /* Mark all the scroll bars to be removed; we'll redeem the ones
1313 we want when we redisplay their windows. */
1314 if (condemn_scroll_bars_hook
)
1315 (*condemn_scroll_bars_hook
) (f
);
1317 if (FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1318 redisplay_windows (FRAME_ROOT_WINDOW (f
), preserve_echo_area
);
1320 /* Any scroll bars which redisplay_windows should have nuked
1321 should now go away. */
1322 if (judge_scroll_bars_hook
)
1323 (*judge_scroll_bars_hook
) (f
);
1327 else if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1329 redisplay_window (selected_window
, 1, preserve_echo_area
);
1330 if (!WINDOW_FULL_WIDTH_P (w
))
1331 preserve_other_columns (w
);
1335 /* Prevent various kinds of signals during display update.
1336 stdio is not robust about handling signals,
1337 which can cause an apparent I/O error. */
1338 if (interrupt_input
)
1348 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1352 if (!FRAMEP (XCONS (tail
)->car
))
1355 f
= XFRAME (XCONS (tail
)->car
);
1357 if ((FRAME_WINDOW_P (f
) || f
== selected_frame
)
1358 && FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1360 pause
|= update_frame (f
, 0, 0);
1363 mark_window_display_accurate (f
->root_window
, 1);
1364 if (frame_up_to_date_hook
!= 0)
1365 (*frame_up_to_date_hook
) (f
);
1372 if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1373 pause
= update_frame (selected_frame
, 0, 0);
1377 /* We may have called echo_area_display at the top of this
1378 function. If the echo area is on another frame, that may
1379 have put text on a frame other than the selected one, so the
1380 above call to update_frame would not have caught it. Catch
1383 Lisp_Object mini_window
;
1384 FRAME_PTR mini_frame
;
1386 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
1387 mini_frame
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
1389 if (mini_frame
!= selected_frame
&& FRAME_WINDOW_P (mini_frame
))
1390 pause
|= update_frame (mini_frame
, 0, 0);
1394 /* If frame does not match, prevent doing single-line-update next time.
1395 Also, don't forget to check every line to update the arrow. */
1398 this_line_bufpos
= 0;
1399 if (!NILP (last_arrow_position
))
1401 last_arrow_position
= Qt
;
1402 last_arrow_string
= Qt
;
1404 /* If we pause after scrolling, some lines in current_frame
1405 may be null, so preserve_other_columns won't be able to
1406 preserve all the vertical-bar separators. So, avoid using it
1408 if (!WINDOW_FULL_WIDTH_P (w
))
1409 update_mode_lines
= 1;
1412 /* Now text on frame agrees with windows, so
1413 put info into the windows for partial redisplay to follow */
1417 register struct buffer
*b
= XBUFFER (w
->buffer
);
1419 blank_end_of_window
= 0;
1420 unchanged_modified
= BUF_MODIFF (b
);
1421 overlay_unchanged_modified
= BUF_OVERLAY_MODIFF (b
);
1422 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
1423 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
1425 XSETFASTINT (w
->last_point
, BUF_PT (b
));
1426 XSETFASTINT (w
->last_point_x
, FRAME_CURSOR_X (selected_frame
));
1427 XSETFASTINT (w
->last_point_y
, FRAME_CURSOR_Y (selected_frame
));
1430 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
1433 b
->clip_changed
= 0;
1434 w
->update_mode_line
= Qnil
;
1435 XSETFASTINT (w
->last_modified
, BUF_MODIFF (b
));
1436 XSETFASTINT (w
->last_overlay_modified
, BUF_OVERLAY_MODIFF (b
));
1438 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1441 /* Record if we are showing a region, so can make sure to
1442 update it fully at next redisplay. */
1443 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1444 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1445 || highlight_nonselected_windows
)
1446 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1447 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1450 w
->window_end_valid
= w
->buffer
;
1451 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1452 last_arrow_string
= Voverlay_arrow_string
;
1453 if (do_verify_charstarts
)
1454 verify_charstarts (w
);
1455 if (frame_up_to_date_hook
!= 0)
1456 (*frame_up_to_date_hook
) (selected_frame
);
1458 update_mode_lines
= 0;
1459 windows_or_buffers_changed
= 0;
1462 /* Start SIGIO interrupts coming again.
1463 Having them off during the code above
1464 makes it less likely one will discard output,
1465 but not impossible, since there might be stuff
1466 in the system buffer here.
1467 But it is much hairier to try to do anything about that. */
1469 if (interrupt_input
)
1473 /* If something has become visible now which was not before,
1474 redisplay again, so that we get them. */
1477 Lisp_Object tail
, frame
;
1480 FOR_EACH_FRAME (tail
, frame
)
1482 int this_is_visible
= 0;
1484 if (XFRAME (frame
)->visible
)
1485 this_is_visible
= 1;
1486 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1487 if (XFRAME (frame
)->visible
)
1488 this_is_visible
= 1;
1490 if (this_is_visible
)
1494 if (new_count
!= number_of_visible_frames
)
1495 windows_or_buffers_changed
++;
1498 /* Change frame size now if a change is pending. */
1499 do_pending_window_change ();
1501 /* If we just did a pending size change, or have additional
1502 visible frames, redisplay again. */
1503 if (windows_or_buffers_changed
&& !pause
)
1507 /* Redisplay, but leave alone any recent echo area message
1508 unless another message has been requested in its place.
1510 This is useful in situations where you need to redisplay but no
1511 user action has occurred, making it inappropriate for the message
1512 area to be cleared. See tracking_off and
1513 wait_reading_process_input for examples of these situations. */
1516 redisplay_preserve_echo_area ()
1518 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
1520 echo_area_glyphs
= previous_echo_glyphs
;
1521 redisplay_internal (1);
1522 echo_area_glyphs
= 0;
1525 redisplay_internal (1);
1529 mark_window_display_accurate (window
, flag
)
1533 register struct window
*w
;
1535 for (;!NILP (window
); window
= w
->next
)
1537 if (!WINDOWP (window
)) abort ();
1538 w
= XWINDOW (window
);
1540 if (!NILP (w
->buffer
))
1542 XSETFASTINT (w
->last_modified
,
1543 !flag
? 0 : BUF_MODIFF (XBUFFER (w
->buffer
)));
1544 XSETFASTINT (w
->last_overlay_modified
,
1545 !flag
? 0 : BUF_OVERLAY_MODIFF (XBUFFER (w
->buffer
)));
1547 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1550 /* Record if we are showing a region, so can make sure to
1551 update it fully at next redisplay. */
1552 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1553 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1554 || highlight_nonselected_windows
)
1555 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1556 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1560 w
->window_end_valid
= w
->buffer
;
1561 w
->update_mode_line
= Qnil
;
1562 if (!NILP (w
->buffer
) && flag
)
1563 XBUFFER (w
->buffer
)->clip_changed
= 0;
1565 if (!NILP (w
->vchild
))
1566 mark_window_display_accurate (w
->vchild
, flag
);
1567 if (!NILP (w
->hchild
))
1568 mark_window_display_accurate (w
->hchild
, flag
);
1573 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1574 last_arrow_string
= Voverlay_arrow_string
;
1578 /* t is unequal to any useful value of Voverlay_arrow_... */
1579 last_arrow_position
= Qt
;
1580 last_arrow_string
= Qt
;
1584 /* Update the menu bar item list for frame F.
1585 This has to be done before we start to fill in any display lines,
1586 because it can call eval.
1588 If SAVE_MATCH_DATA is 1, we must save and restore it here. */
1591 update_menu_bar (f
, save_match_data
)
1593 int save_match_data
;
1595 struct buffer
*old
= current_buffer
;
1597 register struct window
*w
;
1599 window
= FRAME_SELECTED_WINDOW (f
);
1600 w
= XWINDOW (window
);
1602 if (update_mode_lines
)
1603 w
->update_mode_line
= Qt
;
1605 if (FRAME_WINDOW_P (f
)
1607 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1608 FRAME_EXTERNAL_MENU_BAR (f
)
1610 FRAME_MENU_BAR_LINES (f
) > 0
1612 : FRAME_MENU_BAR_LINES (f
) > 0)
1614 /* If the user has switched buffers or windows, we need to
1615 recompute to reflect the new bindings. But we'll
1616 recompute when update_mode_lines is set too; that means
1617 that people can use force-mode-line-update to request
1618 that the menu bar be recomputed. The adverse effect on
1619 the rest of the redisplay algorithm is about the same as
1620 windows_or_buffers_changed anyway. */
1621 if (windows_or_buffers_changed
1622 || !NILP (w
->update_mode_line
)
1623 || ((BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1624 < BUF_MODIFF (XBUFFER (w
->buffer
)))
1625 != !NILP (w
->last_had_star
))
1626 || ((!NILP (Vtransient_mark_mode
)
1627 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1628 != !NILP (w
->region_showing
)))
1630 struct buffer
*prev
= current_buffer
;
1631 int count
= specpdl_ptr
- specpdl
;
1633 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1634 if (save_match_data
)
1635 record_unwind_protect (Fset_match_data
, Fmatch_data (Qnil
, Qnil
));
1636 if (NILP (Voverriding_local_map_menu_flag
))
1638 specbind (Qoverriding_terminal_local_map
, Qnil
);
1639 specbind (Qoverriding_local_map
, Qnil
);
1642 /* Run the Lucid hook. */
1643 call1 (Vrun_hooks
, Qactivate_menubar_hook
);
1644 /* If it has changed current-menubar from previous value,
1645 really recompute the menubar from the value. */
1646 if (! NILP (Vlucid_menu_bar_dirty_flag
))
1647 call0 (Qrecompute_lucid_menubar
);
1648 safe_run_hooks (Qmenu_bar_update_hook
);
1649 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
1650 /* Redisplay the menu bar in case we changed it. */
1651 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1652 if (FRAME_WINDOW_P (f
))
1653 set_frame_menubar (f
, 0, 0);
1655 /* On a terminal screen, the menu bar is an ordinary screen
1656 line, and this makes it get updated. */
1657 w
->update_mode_line
= Qt
;
1658 #else /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1659 /* In the non-toolkit version, the menu bar is an ordinary screen
1660 line, and this makes it get updated. */
1661 w
->update_mode_line
= Qt
;
1662 #endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1664 unbind_to (count
, Qnil
);
1665 set_buffer_internal_1 (prev
);
1672 /* Redisplay WINDOW and its subwindows and siblings. */
1675 redisplay_windows (window
, preserve_echo_area
)
1677 int preserve_echo_area
;
1679 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1680 redisplay_window (window
, 0, preserve_echo_area
);
1683 /* Return value in display table DP (Lisp_Char_Table *) for character
1684 C. Since a display table doesn't have any parent, we don't have to
1685 follow parent. Do not call this function directly but use the
1686 macro DISP_CHAR_VECTOR. */
1688 disp_char_vector (dp
, c
)
1689 struct Lisp_Char_Table
*dp
;
1695 if (SINGLE_BYTE_CHAR_P (c
)) return (dp
->contents
[c
]);
1697 SPLIT_NON_ASCII_CHAR (c
, code
[0], code
[1], code
[2]);
1698 if (code
[0] != CHARSET_COMPOSITION
)
1700 if (code
[1] < 32) code
[1] = -1;
1701 else if (code
[2] < 32) code
[2] = -1;
1703 /* Here, the possible range of CODE[0] (== charset ID) is
1704 128..MAX_CHARSET. Since the top level char table contains data
1705 for multibyte characters after 256th element, we must increment
1706 CODE[0] by 128 to get a correct index. */
1708 code
[3] = -1; /* anchor */
1710 for (i
= 0; code
[i
] >= 0; i
++, dp
= XCHAR_TABLE (val
))
1712 val
= dp
->contents
[code
[i
]];
1713 if (!SUB_CHAR_TABLE_P (val
))
1714 return (NILP (val
) ? dp
->defalt
: val
);
1716 /* Here, VAL is a sub char table. We return the default value of it. */
1717 return (dp
->defalt
);
1720 /* Redisplay window WINDOW and its subwindows. */
1723 redisplay_window (window
, just_this_one
, preserve_echo_area
)
1725 int just_this_one
, preserve_echo_area
;
1727 register struct window
*w
= XWINDOW (window
);
1728 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1731 int lpoint_byte
= PT_BYTE
;
1732 struct buffer
*old
= current_buffer
;
1733 register int width
= window_internal_width (w
) - 1;
1734 register int startp
, startp_byte
;
1735 register int hscroll
= XINT (w
->hscroll
);
1736 struct position pos
;
1738 int opoint_byte
= PT_BYTE
;
1740 int update_mode_line
;
1741 struct Lisp_Char_Table
*dp
= window_display_table (w
);
1743 if (Z
== Z_BYTE
&& lpoint
!= lpoint_byte
)
1745 if (lpoint_byte
< lpoint
)
1748 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1750 /* If this is a combination window, do its children; that's all. */
1752 if (!NILP (w
->vchild
))
1754 redisplay_windows (w
->vchild
, preserve_echo_area
);
1757 if (!NILP (w
->hchild
))
1759 redisplay_windows (w
->hchild
, preserve_echo_area
);
1762 if (NILP (w
->buffer
))
1765 height
= window_internal_height (w
);
1766 update_mode_line
= (!NILP (w
->update_mode_line
) || update_mode_lines
);
1767 if (XBUFFER (w
->buffer
)->clip_changed
)
1768 update_mode_line
= 1;
1770 if (MINI_WINDOW_P (w
))
1772 if (w
== XWINDOW (echo_area_window
) && echo_area_glyphs
)
1773 /* We've already displayed the echo area glyphs in this window. */
1774 goto finish_scroll_bars
;
1775 else if (w
!= XWINDOW (minibuf_window
))
1777 /* This is a minibuffer, but it's not the currently active one,
1779 int vpos
= XFASTINT (w
->top
);
1782 for (i
= 0; i
< height
; i
++)
1784 get_display_line (f
, vpos
+ i
, 0);
1785 display_string (w
, vpos
+ i
, "", 0,
1786 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
1790 goto finish_scroll_bars
;
1794 /* Otherwise set up data on this window; select its buffer and point value */
1796 if (update_mode_line
)
1797 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1799 set_buffer_temp (XBUFFER (w
->buffer
));
1802 opoint_byte
= PT_BYTE
;
1804 if (Z
== Z_BYTE
&& opoint
!= opoint_byte
)
1806 if (opoint_byte
< opoint
)
1809 /* If %c is in mode line, update it if needed. */
1810 if (!NILP (w
->column_number_displayed
)
1811 /* This alternative quickly identifies a common case
1812 where no change is needed. */
1813 && !(PT
== XFASTINT (w
->last_point
)
1814 && XFASTINT (w
->last_modified
) >= MODIFF
1815 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1816 && XFASTINT (w
->column_number_displayed
) != current_column ())
1817 update_mode_line
= 1;
1819 /* Count number of windows showing the selected buffer.
1820 An indirect buffer counts as its base buffer. */
1824 struct buffer
*current_base
, *window_base
;
1825 current_base
= current_buffer
;
1826 window_base
= XBUFFER (XWINDOW (selected_window
)->buffer
);
1827 if (current_base
->base_buffer
)
1828 current_base
= current_base
->base_buffer
;
1829 if (window_base
->base_buffer
)
1830 window_base
= window_base
->base_buffer
;
1831 if (current_base
== window_base
)
1835 /* POINT refers normally to the selected window.
1836 For any other window, set up appropriate value. */
1838 if (!EQ (window
, selected_window
))
1840 int new_pt
= XMARKER (w
->pointm
)->charpos
;
1841 int new_pt_byte
= marker_byte_position (w
->pointm
);
1845 new_pt_byte
= BEGV_BYTE
;
1846 set_marker_both (w
->pointm
, Qnil
, BEGV
, BEGV_BYTE
);
1848 else if (new_pt
> (ZV
- 1))
1851 new_pt_byte
= ZV_BYTE
;
1852 set_marker_both (w
->pointm
, Qnil
, ZV
, ZV_BYTE
);
1854 /* We don't use SET_PT so that the point-motion hooks don't run. */
1855 TEMP_SET_PT_BOTH (new_pt
, new_pt_byte
);
1858 /* If any of the character widths specified in the display table
1859 have changed, invalidate the width run cache. It's true that this
1860 may be a bit late to catch such changes, but the rest of
1861 redisplay goes (non-fatally) haywire when the display table is
1862 changed, so why should we worry about doing any better? */
1863 if (current_buffer
->width_run_cache
)
1865 struct Lisp_Char_Table
*disptab
= buffer_display_table ();
1867 if (! disptab_matches_widthtab (disptab
,
1868 XVECTOR (current_buffer
->width_table
)))
1870 invalidate_region_cache (current_buffer
,
1871 current_buffer
->width_run_cache
,
1873 recompute_width_table (current_buffer
, disptab
);
1877 /* If window-start is screwed up, choose a new one. */
1878 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1881 startp
= marker_position (w
->start
);
1882 startp_byte
= marker_byte_position (w
->start
);
1884 /* If someone specified a new starting point but did not insist,
1885 check whether it can be used. */
1886 if (!NILP (w
->optional_new_start
))
1888 w
->optional_new_start
= Qnil
;
1889 /* Check whether this start pos is usable given where point is. */
1891 pos
= *compute_motion (startp
, 0,
1892 (((EQ (window
, minibuf_window
)
1894 ? minibuf_prompt_width
: 0)
1895 + (hscroll
? 1 - hscroll
: 0)),
1898 /* BUG FIX: See the comment of
1899 Fpos_visible_in_window_p (window.c). */
1900 - (1 << (BITS_PER_SHORT
- 1)),
1902 pos_tab_offset (w
, startp
, startp_byte
), w
);
1903 /* If PT does fit on the screen, we will use this start pos,
1904 so do so by setting force_start. */
1905 if (pos
.bufpos
== PT
)
1906 w
->force_start
= Qt
;
1909 /* Handle case where place to start displaying has been specified,
1910 unless the specified location is outside the accessible range. */
1911 if (!NILP (w
->force_start
))
1913 w
->force_start
= Qnil
;
1914 /* Forget any recorded base line for line number display. */
1915 w
->base_line_number
= Qnil
;
1916 /* Redisplay the mode line. Select the buffer properly for that.
1917 Also, run the hook window-scroll-functions
1918 because we have scrolled. */
1919 /* Note, we do this after clearing force_start because
1920 if there's an error, it is better to forget about force_start
1921 than to get into an infinite loop calling the hook functions
1922 and having them get more errors. */
1923 if (!update_mode_line
1924 || ! NILP (Vwindow_scroll_functions
))
1926 Lisp_Object temp
[3];
1928 set_buffer_temp (old
);
1929 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1930 update_mode_line
= 1;
1931 w
->update_mode_line
= Qt
;
1932 if (! NILP (Vwindow_scroll_functions
))
1934 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
1935 make_number (startp
));
1936 startp
= marker_position (w
->start
);
1939 XSETFASTINT (w
->last_modified
, 0);
1940 XSETFASTINT (w
->last_overlay_modified
, 0);
1941 if (startp
< BEGV
) startp
= BEGV
, startp_byte
= BEGV_BYTE
;
1942 if (startp
> ZV
) startp
= ZV
, startp
= ZV_BYTE
;
1943 try_window (window
, startp
);
1944 if (cursor_vpos
< 0)
1946 /* If point does not appear, move point so it does appear */
1947 pos
= *compute_motion (startp
, 0,
1948 (((EQ (window
, minibuf_window
)
1950 ? minibuf_prompt_width
: 0)
1951 + (hscroll
? 1 - hscroll
: 0)),
1954 - (1 << (BITS_PER_SHORT
- 1)),
1956 pos_tab_offset (w
, startp
, startp_byte
),
1958 TEMP_SET_PT_BOTH (pos
.bufpos
, pos
.bytepos
);
1959 if (w
!= XWINDOW (selected_window
))
1960 set_marker_both (w
->pointm
, Qnil
, PT
, PT_BYTE
);
1963 if (current_buffer
== old
)
1966 lpoint_byte
= PT_BYTE
;
1968 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
1969 + minmax (0, pos
.hpos
, width
));
1970 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1972 /* If we are highlighting the region,
1973 then we just changed the region, so redisplay to show it. */
1974 if (!NILP (Vtransient_mark_mode
)
1975 && !NILP (current_buffer
->mark_active
))
1977 cancel_my_columns (XWINDOW (window
));
1978 try_window (window
, startp
);
1984 /* Handle case where text has not changed, only point,
1985 and it has not moved off the frame. */
1987 /* This code is not used for minibuffer for the sake of
1988 the case of redisplaying to replace an echo area message;
1989 since in that case the minibuffer contents per se are usually unchanged.
1990 This code is of no real use in the minibuffer since
1991 the handling of this_line_bufpos, etc.,
1992 in redisplay handles the same cases. */
1994 if (XFASTINT (w
->last_modified
) >= MODIFF
1995 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
1996 && PT
>= startp
&& !current_buffer
->clip_changed
1997 && (just_this_one
|| WINDOW_FULL_WIDTH_P (w
))
1998 /* If force-mode-line-update was called, really redisplay;
1999 that's how redisplay is forced after e.g. changing
2000 buffer-invisibility-spec. */
2001 && NILP (w
->update_mode_line
)
2002 /* Can't use this case if highlighting a region. */
2003 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
2004 && NILP (w
->region_showing
)
2005 /* If end pos is out of date, scroll bar and percentage will be wrong */
2006 && INTEGERP (w
->window_end_vpos
)
2007 && XFASTINT (w
->window_end_vpos
) < XFASTINT (w
->height
)
2008 && !EQ (window
, minibuf_window
)
2009 && (!MARKERP (Voverlay_arrow_position
)
2010 || current_buffer
!= XMARKER (Voverlay_arrow_position
)->buffer
))
2012 /* All positions in this clause are relative to the window edge. */
2014 int this_scroll_margin
= scroll_margin
;
2015 int last_point_y
= XFASTINT (w
->last_point_y
) - XINT (w
->top
);
2016 int last_point_x
= (XFASTINT (w
->last_point_x
) - WINDOW_LEFT_MARGIN (w
));
2018 /* Find where PT is located now on the frame. */
2019 /* Check just_this_one as a way of verifying that the
2020 window edges have not changed. */
2021 if (PT
== XFASTINT (w
->last_point
) && just_this_one
)
2023 pos
.hpos
= last_point_x
;
2024 pos
.vpos
= last_point_y
;
2027 else if (PT
> XFASTINT (w
->last_point
)
2028 && XFASTINT (w
->last_point
) > startp
&& just_this_one
2029 /* We can't use this if point is in the left margin of a
2030 hscrolled window, because w->last_point_x has been
2031 clipped to the window edges. */
2032 && !(last_point_x
<= 0 && hscroll
))
2034 int last_point
= XFASTINT (w
->last_point
);
2035 int last_point_byte
= CHAR_TO_BYTE (last_point
);
2037 pos
= *compute_motion (last_point
, last_point_y
, last_point_x
, 0,
2039 /* BUG FIX: See the comment of
2040 Fpos_visible_in_window_p (window.c). */
2041 - (1 << (BITS_PER_SHORT
- 1)),
2043 pos_tab_offset (w
, last_point
, last_point_byte
),
2048 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0), 0,
2050 /* BUG FIX: See the comment of
2051 Fpos_visible_in_window_p (window.c). */
2052 - (1 << (BITS_PER_SHORT
- 1)),
2054 pos_tab_offset (w
, startp
, startp_byte
),
2058 /* Don't use a scroll margin that is negative or too large. */
2059 if (this_scroll_margin
< 0)
2060 this_scroll_margin
= 0;
2062 if (XINT (w
->height
) < 4 * scroll_margin
)
2063 this_scroll_margin
= XINT (w
->height
) / 4;
2065 /* If point fits on the screen, and not within the scroll margin,
2067 if (pos
.vpos
< height
- this_scroll_margin
2068 && (pos
.vpos
>= this_scroll_margin
|| startp
== BEGV
))
2070 /* Ok, point is still on frame */
2071 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2073 /* These variables are supposed to be origin 1 */
2074 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
2075 + minmax (0, pos
.hpos
, width
));
2076 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
2078 /* This doesn't do the trick, because if a window to the right of
2079 this one must be redisplayed, this does nothing because there
2080 is nothing in DesiredFrame yet, and then the other window is
2081 redisplayed, making likes that are empty in this window's columns.
2082 if (WINDOW_FULL_WIDTH_P (w))
2083 preserve_my_columns (w);
2085 if (current_buffer
->clip_changed
2086 && ! NILP (Vwindow_scroll_functions
))
2087 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2088 make_number (marker_position (w
->start
)));
2092 /* Don't bother trying redisplay with same start;
2093 we already know it will lose */
2095 /* If current starting point was originally the beginning of a line
2096 but no longer is, find a new starting point. */
2097 else if (!NILP (w
->start_at_line_beg
)
2099 || FETCH_BYTE (startp_byte
- 1) == '\n'))
2103 else if (just_this_one
&& !MINI_WINDOW_P (w
)
2105 && XFASTINT (w
->last_modified
)
2106 /* or else vmotion on first line won't work. */
2107 && ! NILP (w
->start_at_line_beg
)
2108 && ! EQ (w
->window_end_valid
, Qnil
)
2109 && do_id
&& !current_buffer
->clip_changed
2110 && !blank_end_of_window
2111 && WINDOW_FULL_WIDTH_P (w
)
2112 /* Can't use this case if highlighting a region. */
2113 && !(!NILP (Vtransient_mark_mode
)
2114 && !NILP (current_buffer
->mark_active
))
2115 /* Don't use try_window_id if newline
2116 doesn't display as the end of a line. */
2117 && !(dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, '\n')))
2118 && NILP (w
->region_showing
)
2119 && EQ (last_arrow_position
, COERCE_MARKER (Voverlay_arrow_position
))
2120 && EQ (last_arrow_string
, Voverlay_arrow_string
)
2121 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
2124 /* tem > 0 means success. tem == -1 means choose new start.
2125 tem == -2 means try again with same start,
2126 and nothing but whitespace follows the changed stuff.
2127 tem == 0 means try again with same start. */
2131 else if (startp
>= BEGV
&& startp
<= ZV
2133 /* Avoid starting at end of buffer. */
2134 #if 0 /* This change causes trouble for M-! finger & RET.
2135 It will have to be considered later. */
2136 || ! EQ (window
, selected_window
)
2137 /* Don't do the recentering if redisplay
2138 is not for no user action. */
2139 || preserve_echo_area
2142 || (XFASTINT (w
->last_modified
) >= MODIFF
2143 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)))
2145 /* Try to redisplay starting at same place as before */
2146 /* If point has not moved off frame, accept the results */
2147 try_window (window
, startp
);
2148 if (cursor_vpos
>= 0)
2150 if (!just_this_one
|| current_buffer
->clip_changed
2151 || beg_unchanged
< startp
)
2152 /* Forget any recorded base line for line number display. */
2153 w
->base_line_number
= Qnil
;
2155 if (current_buffer
->clip_changed
2156 && ! NILP (Vwindow_scroll_functions
))
2157 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2158 make_number (marker_position (w
->start
)));
2163 cancel_my_columns (w
);
2166 XSETFASTINT (w
->last_modified
, 0);
2167 XSETFASTINT (w
->last_overlay_modified
, 0);
2168 /* Redisplay the mode line. Select the buffer properly for that. */
2169 if (!update_mode_line
)
2171 set_buffer_temp (old
);
2172 set_buffer_internal_1 (XBUFFER (w
->buffer
));
2173 update_mode_line
= 1;
2174 w
->update_mode_line
= Qt
;
2177 /* Try to scroll by specified few lines */
2179 if (scroll_conservatively
&& !current_buffer
->clip_changed
2180 && startp
>= BEGV
&& startp
<= ZV
)
2182 int this_scroll_margin
= scroll_margin
;
2183 int scroll_margin_pos
;
2185 /* Don't use a scroll margin that is negative or too large. */
2186 if (this_scroll_margin
< 0)
2187 this_scroll_margin
= 0;
2189 if (XINT (w
->height
) < 4 * this_scroll_margin
)
2190 this_scroll_margin
= XINT (w
->height
) / 4;
2192 scroll_margin_pos
= Z
- XFASTINT (w
->window_end_pos
);
2193 if (this_scroll_margin
)
2195 pos
= *vmotion (scroll_margin_pos
, -this_scroll_margin
, w
);
2196 scroll_margin_pos
= pos
.bufpos
;
2198 if (PT
>= scroll_margin_pos
)
2200 struct position pos
;
2201 pos
= *compute_motion (scroll_margin_pos
, 0, 0, 0,
2202 PT
, XFASTINT (w
->height
), 0,
2203 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2204 pos_tab_offset (w
, startp
, startp_byte
),
2206 if (pos
.vpos
> scroll_conservatively
)
2209 pos
= *vmotion (startp
, pos
.vpos
+ 1, w
);
2211 if (! NILP (Vwindow_scroll_functions
))
2213 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2214 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2215 make_number (pos
.bufpos
));
2216 pos
.bufpos
= marker_position (w
->start
);
2218 try_window (window
, pos
.bufpos
);
2219 if (cursor_vpos
>= 0)
2221 if (!just_this_one
|| current_buffer
->clip_changed
2222 || beg_unchanged
< startp
)
2223 /* Forget any recorded base line for line number display. */
2224 w
->base_line_number
= Qnil
;
2228 cancel_my_columns (w
);
2231 scroll_margin_pos
= startp
;
2232 if (this_scroll_margin
)
2234 pos
= *vmotion (scroll_margin_pos
, this_scroll_margin
, w
);
2235 scroll_margin_pos
= pos
.bufpos
;
2237 if (PT
< scroll_margin_pos
)
2239 struct position pos
;
2240 pos
= *compute_motion (PT
, 0, 0, 0,
2241 scroll_margin_pos
, XFASTINT (w
->height
), 0,
2242 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2243 pos_tab_offset (w
, startp
, startp_byte
),
2245 if (pos
.vpos
> scroll_conservatively
)
2248 pos
= *vmotion (startp
, -pos
.vpos
, w
);
2250 if (! NILP (Vwindow_scroll_functions
))
2252 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2253 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2254 make_number (pos
.bufpos
));
2255 pos
.bufpos
= marker_position (w
->start
);
2257 try_window (window
, pos
.bufpos
);
2258 if (cursor_vpos
>= 0)
2260 if (!just_this_one
|| current_buffer
->clip_changed
2261 || beg_unchanged
< startp
)
2262 /* Forget any recorded base line for line number display. */
2263 w
->base_line_number
= Qnil
;
2267 cancel_my_columns (w
);
2272 if (scroll_step
&& !current_buffer
->clip_changed
2273 && startp
>= BEGV
&& startp
<= ZV
)
2277 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), scroll_step
, w
);
2278 if (pos
.vpos
>= height
)
2282 pos
= *vmotion (startp
, (PT
< startp
? - scroll_step
: scroll_step
), w
);
2284 if (PT
>= pos
.bufpos
)
2286 if (! NILP (Vwindow_scroll_functions
))
2288 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2289 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2290 make_number (pos
.bufpos
));
2291 pos
.bufpos
= marker_position (w
->start
);
2293 try_window (window
, pos
.bufpos
);
2294 if (cursor_vpos
>= 0)
2296 if (!just_this_one
|| current_buffer
->clip_changed
2297 || beg_unchanged
< startp
)
2298 /* Forget any recorded base line for line number display. */
2299 w
->base_line_number
= Qnil
;
2303 cancel_my_columns (w
);
2308 /* Finally, just choose place to start which centers point */
2311 /* Forget any previously recorded base line for line number display. */
2312 w
->base_line_number
= Qnil
;
2314 pos
= *vmotion (PT
, - (height
/ 2), w
);
2316 /* The minibuffer is often just one line. Ordinary scrolling
2317 gives little overlap and looks bad. So show 20 chars before point. */
2319 && (pos
.bufpos
>= PT
- minibuffer_scroll_overlap
2320 /* If we scrolled less than 1/2 line forward, we will
2321 get too much overlap, so change to the usual amount. */
2322 || pos
.bufpos
< startp
+ width
/ 2)
2323 && PT
> BEGV
+ minibuffer_scroll_overlap
2324 /* If we scrolled to an actual line boundary,
2325 that's different; don't ignore line boundaries. */
2326 && FETCH_BYTE (pos
.bytepos
- 1) != '\n')
2328 pos
.bufpos
= PT
- minibuffer_scroll_overlap
;
2329 pos
.bytepos
= CHAR_TO_BYTE (pos
.bufpos
);
2332 /* Set startp here explicitly in case that helps avoid an infinite loop
2333 in case the window-scroll-functions functions get errors. */
2334 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2335 if (! NILP (Vwindow_scroll_functions
))
2337 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2338 make_number (pos
.bufpos
));
2339 pos
.bufpos
= marker_position (w
->start
);
2340 pos
.bytepos
= marker_byte_position (w
->start
);
2342 try_window (window
, pos
.bufpos
);
2344 startp
= marker_position (w
->start
);
2345 startp_byte
= marker_byte_position (w
->start
);
2346 w
->start_at_line_beg
2347 = (startp
== BEGV
|| FETCH_BYTE (startp_byte
- 1) == '\n') ? Qt
: Qnil
;
2350 if ((update_mode_line
2351 /* If window not full width, must redo its mode line
2352 if the window to its side is being redone */
2353 || (!just_this_one
&& !WINDOW_FULL_WIDTH_P (w
))
2354 || INTEGERP (w
->base_line_pos
)
2355 || (!NILP (w
->column_number_displayed
)
2356 && XFASTINT (w
->column_number_displayed
) != current_column ()))
2357 && height
!= XFASTINT (w
->height
))
2358 display_mode_line (w
);
2359 if (! line_number_displayed
2360 && ! BUFFERP (w
->base_line_pos
))
2362 w
->base_line_pos
= Qnil
;
2363 w
->base_line_number
= Qnil
;
2366 /* When we reach a frame's selected window, redo the frame's menu bar. */
2367 if (update_mode_line
2368 && (FRAME_WINDOW_P (f
)
2370 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2371 FRAME_EXTERNAL_MENU_BAR (f
)
2373 FRAME_MENU_BAR_LINES (f
) > 0
2375 : FRAME_MENU_BAR_LINES (f
) > 0)
2376 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
2377 display_menu_bar (w
);
2380 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2382 int start
, end
, whole
;
2384 /* Calculate the start and end positions for the current window.
2385 At some point, it would be nice to choose between scrollbars
2386 which reflect the whole buffer size, with special markers
2387 indicating narrowing, and scrollbars which reflect only the
2390 Note that minibuffers sometimes aren't displaying any text. */
2391 if (! MINI_WINDOW_P (w
)
2392 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
2395 start
= marker_position (w
->start
) - BEGV
;
2396 /* I don't think this is guaranteed to be right. For the
2397 moment, we'll pretend it is. */
2398 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
2400 if (end
< start
) end
= start
;
2401 if (whole
< (end
- start
)) whole
= end
- start
;
2404 start
= end
= whole
= 0;
2406 /* Indicate what this scroll bar ought to be displaying now. */
2407 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
2409 /* Note that we actually used the scroll bar attached to this window,
2410 so it shouldn't be deleted at the end of redisplay. */
2411 (*redeem_scroll_bar_hook
) (w
);
2414 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
2415 if (update_mode_line
)
2416 set_buffer_internal_1 (old
);
2418 set_buffer_temp (old
);
2419 TEMP_SET_PT_BOTH (lpoint
, lpoint_byte
);
2422 /* Do full redisplay on one window, starting at position `pos'. */
2425 try_window (window
, pos
)
2429 register struct window
*w
= XWINDOW (window
);
2430 register int height
= window_internal_height (w
);
2431 register int vpos
= XFASTINT (w
->top
);
2432 register int last_text_vpos
= vpos
;
2433 FRAME_PTR f
= XFRAME (w
->frame
);
2434 int width
= window_internal_width (w
) - 1;
2435 struct position val
;
2437 /* POS should never be out of range! */
2438 if (pos
< XBUFFER (w
->buffer
)->begv
2439 || pos
> XBUFFER (w
->buffer
)->zv
)
2442 if (XMARKER (w
->start
)->charpos
!= pos
)
2443 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2446 overlay_arrow_seen
= 0;
2447 zv_strings_seen
= 0;
2448 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2449 val
.ovstring_chars_done
= 0;
2450 val
.bytepos
= marker_byte_position (w
->start
);
2451 val
.tab_offset
= pos_tab_offset (w
, pos
, val
.bytepos
);
2453 while (--height
>= 0)
2455 val
= *display_text_line (w
, pos
, val
.bytepos
, vpos
,
2456 val
.hpos
, val
.tab_offset
,
2457 val
.ovstring_chars_done
);
2458 /* The following code is omitted because we maintain tab_offset
2461 tab_offset
+= width
;
2462 if (val
.vpos
) tab_offset
= 0;
2465 if (pos
!= val
.bufpos
)
2468 #ifdef USE_TEXT_PROPERTIES
2469 Lisp_Object invis_prop
;
2470 invis_prop
= Fget_char_property (val
.bufpos
-1, Qinvisible
, window
);
2471 invis
= TEXT_PROP_MEANS_INVISIBLE (invis_prop
);
2475 /* Next line, unless prev line ended in end of buffer with no cr */
2477 && (FETCH_BYTE (val
.bytepos
- 1) != '\n' || invis
));
2482 /* If last line is continued in middle of character,
2483 include the split character in the text considered on the frame */
2484 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2487 /* If bottom just moved off end of frame, change mode line percentage. */
2488 if (XFASTINT (w
->window_end_pos
) == 0
2490 w
->update_mode_line
= Qt
;
2492 /* Say where last char on frame will be, once redisplay is finished. */
2493 XSETFASTINT (w
->window_end_pos
, Z
- pos
);
2494 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
- XFASTINT (w
->top
));
2495 /* But that is not valid info until redisplay finishes. */
2496 w
->window_end_valid
= Qnil
;
2499 /* Try to redisplay when buffer is modified locally,
2500 computing insert/delete line to preserve text outside
2501 the bounds of the changes.
2502 Return 1 if successful, 0 if if cannot tell what to do,
2503 or -1 to tell caller to find a new window start,
2504 or -2 to tell caller to do normal redisplay with same window start. */
2507 try_window_id (window
)
2511 int opoint
, opoint_byte
;
2512 register struct window
*w
= XWINDOW (window
);
2513 register int height
= window_internal_height (w
);
2514 FRAME_PTR f
= XFRAME (w
->frame
);
2515 int top
= XFASTINT (w
->top
);
2516 int start
= marker_position (w
->start
);
2517 int width
= window_internal_width (w
) - 1;
2518 int hscroll
= XINT (w
->hscroll
);
2519 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
2522 register int i
, tem
;
2523 int last_text_vpos
= 0;
2525 int selective
= (INTEGERP (current_buffer
->selective_display
)
2526 ? XINT (current_buffer
->selective_display
)
2527 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
2528 struct position val
, bp
, ep
, xp
, pp
;
2529 int scroll_amount
= 0;
2533 int start_byte
= marker_byte_position (w
->start
);
2535 if (GPT
- BEG
< beg_unchanged
)
2536 beg_unchanged
= GPT
- BEG
;
2537 if (Z
- GPT
< end_unchanged
)
2538 end_unchanged
= Z
- GPT
;
2540 if (beg_unchanged
+ BEG
< start
)
2541 return 0; /* Give up if changes go above top of window */
2543 /* Find position before which nothing is changed. */
2544 bp
= *compute_motion (start
, 0, lmargin
, 0,
2545 min (ZV
, beg_unchanged
+ BEG
), height
,
2546 /* BUG FIX: See the comment of
2547 Fpos_visible_in_window_p (window.c). */
2548 - (1 << (BITS_PER_SHORT
- 1)),
2550 pos_tab_offset (w
, start
, start_byte
),
2552 if (bp
.vpos
>= height
)
2556 /* All changes are beyond the window end, and point is on the screen.
2557 We don't need to change the text at all.
2558 But we need to update window_end_pos to account for
2559 any change in buffer size. */
2560 bp
= *compute_motion (start
, 0, lmargin
, 0,
2562 /* BUG FIX: See the comment of
2563 Fpos_visible_in_window_p() (window.c). */
2564 - (1 << (BITS_PER_SHORT
- 1)),
2566 pos_tab_offset (w
, start
, start_byte
), w
);
2567 XSETFASTINT (w
->window_end_vpos
, height
);
2568 XSETFASTINT (w
->window_end_pos
, Z
- bp
.bufpos
);
2576 /* Find beginning of that frame line. Must display from there. */
2577 bp
= *vmotion (bp
.bufpos
, 0, w
);
2580 pos_byte
= bp
.bytepos
;
2586 /* If about to start displaying at the beginning of a continuation line,
2587 really start with previous frame line, in case it was not
2588 continued when last redisplayed */
2589 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
2591 /* Likewise if we have to worry about selective display. */
2592 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
2594 bp
= *vmotion (bp
.bufpos
, -1, w
);
2597 pos_byte
= bp
.bytepos
;
2599 val
.tab_offset
= bp
.tab_offset
; /* Update tab offset. */
2601 if (bp
.contin
&& bp
.hpos
!= lmargin
)
2603 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
2604 val
.tab_offset
= bp
.tab_offset
+ bp
.prevhpos
- width
;
2606 DEC_BOTH (pos
, pos_byte
);
2611 /* Find first visible newline after which no more is changed. */
2612 opoint
= PT
, opoint_byte
= PT_BYTE
;
2613 SET_PT (Z
- max (end_unchanged
, Z
- ZV
));
2614 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2616 while (PT
< ZV
- 1 && indented_beyond_p (PT
, PT_BYTE
, selective
))
2617 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2619 SET_PT_BOTH (opoint
, opoint_byte
);
2621 /* Compute the cursor position after that newline. */
2622 ep
= *compute_motion (pos
, vpos
, val
.hpos
, did_motion
, tem
,
2623 height
, - (1 << (BITS_PER_SHORT
- 1)),
2625 /* We have tab offset in VAL, use it. */
2628 /* If changes reach past the text available on the frame,
2629 just display rest of frame. */
2630 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
2633 stop_vpos
= ep
.vpos
;
2635 /* If no newline before ep, the line ep is on includes some changes
2636 that must be displayed. Make sure we don't stop before it. */
2637 /* Also, if changes reach all the way until ep.bufpos,
2638 it is possible that something was deleted after the
2639 newline before it, so the following line must be redrawn. */
2640 if (stop_vpos
== ep
.vpos
2641 && (ep
.bufpos
== BEGV
2642 || FETCH_BYTE (ep
.bytepos
- 1) != '\n'
2643 || ep
.bufpos
== Z
- end_unchanged
))
2644 stop_vpos
= ep
.vpos
+ 1;
2647 overlay_arrow_seen
= 0;
2648 zv_strings_seen
= 0;
2650 /* If changes do not reach to bottom of window,
2651 figure out how much to scroll the rest of the window */
2652 if (stop_vpos
< height
)
2654 /* Now determine how far up or down the rest of the window has moved */
2655 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2656 Z
- XFASTINT (w
->window_end_pos
),
2657 /* Don't care for VPOS... */
2658 1 << (BITS_PER_SHORT
- 1),
2660 1 << (BITS_PER_SHORT
- 1),
2661 width
, hscroll
, ep
.tab_offset
, w
);
2662 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
2664 /* Is everything on frame below the changes whitespace?
2665 If so, no scrolling is really necessary. */
2666 for (i
= ep
.bytepos
; i
< xp
.bytepos
; i
++)
2668 tem
= FETCH_BYTE (i
);
2669 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
2672 if (i
== xp
.bytepos
)
2675 XSETFASTINT (w
->window_end_vpos
,
2676 XFASTINT (w
->window_end_vpos
) + scroll_amount
);
2678 /* Before doing any scrolling, verify that point will be on frame. */
2679 if (PT
> ep
.bufpos
&& !(PT
<= xp
.bufpos
&& xp
.vpos
< height
))
2681 if (PT
<= xp
.bufpos
)
2683 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2684 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2686 /* We have tab offset in EP, use it. */
2691 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
, 1,
2692 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2694 /* We have tab offset in XP, use it. */
2697 if (pp
.bufpos
< PT
|| pp
.vpos
== height
)
2699 cursor_vpos
= pp
.vpos
+ top
;
2700 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, pp
.hpos
, width
);
2703 if (stop_vpos
- scroll_amount
>= height
2704 || ep
.bufpos
== xp
.bufpos
)
2706 if (scroll_amount
< 0)
2707 stop_vpos
-= scroll_amount
;
2709 /* In this path, we have altered window_end_vpos
2710 and not left it negative.
2711 We must make sure that, in case display is preempted
2712 before the frame changes to reflect what we do here,
2713 further updates will not come to try_window_id
2714 and assume the frame and window_end_vpos match. */
2715 blank_end_of_window
= 1;
2717 else if (!scroll_amount
)
2719 /* Even if we don't need to scroll, we must adjust the
2720 charstarts of subsequent lines (that we won't redisplay)
2721 according to the amount of text inserted or deleted. */
2722 int oldpos
= FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2723 int adjust
= ep
.bufpos
- oldpos
;
2724 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1, adjust
);
2726 else if (bp
.bufpos
== Z
- end_unchanged
)
2728 /* If reprinting everything is nearly as fast as scrolling,
2729 don't bother scrolling. Can happen if lines are short. */
2730 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
2731 top
+ height
- max (0, scroll_amount
),
2733 > xp
.bufpos
- bp
.bufpos
- 20)
2734 /* Return "try normal display with same window-start."
2735 Too bad we can't prevent further scroll-thinking. */
2737 /* If pure deletion, scroll up as many lines as possible.
2738 In common case of killing a line, this can save the
2739 following line from being overwritten by scrolling
2740 and therefore having to be redrawn. */
2741 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
2742 top
+ height
- max (0, scroll_amount
),
2743 scroll_amount
, bp
.bufpos
);
2748 /* scroll_frame_lines did not properly adjust subsequent
2749 lines' charstarts in the case where the text of the
2750 screen line at bp.vpos has changed.
2751 (This can happen in a deletion that ends in mid-line.)
2752 To adjust properly, we need to make things consistent
2754 So do a second adjust to make that happen.
2755 Note that stop_vpos >= ep.vpos, so it is sufficient
2756 to update the charstarts for lines at ep.vpos and below. */
2758 = FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2759 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1,
2760 ep
.bufpos
- oldstart
);
2763 else if (scroll_amount
)
2765 /* If reprinting everything is nearly as fast as scrolling,
2766 don't bother scrolling. Can happen if lines are short. */
2767 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
2768 overestimate of cost of reprinting, since xp.bufpos
2769 would end up below the bottom of the window. */
2770 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
2771 top
+ height
- max (0, scroll_amount
),
2773 > xp
.bufpos
- ep
.bufpos
- 20)
2774 /* Return "try normal display with same window-start."
2775 Too bad we can't prevent further scroll-thinking. */
2777 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
2778 top
+ height
- max (0, scroll_amount
),
2779 scroll_amount
, ep
.bufpos
);
2780 if (!tem
) stop_vpos
= height
;
2784 /* In any case, do not display past bottom of window */
2785 if (stop_vpos
>= height
)
2791 /* Handle case where pos is before w->start --
2792 can happen if part of line had been clipped and is not clipped now */
2793 if (vpos
== 0 && pos
< marker_position (w
->start
))
2794 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2796 val
.bytepos
= pos_byte
;
2798 /* Redisplay the lines where the text was changed */
2799 last_text_vpos
= vpos
;
2800 /* The following code is omitted because we maintain tab offset in
2803 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2804 /* If we are starting display in mid-character, correct tab_offset
2805 to account for passing the line that that character really starts in. */
2806 if (val
.hpos
< lmargin
)
2807 tab_offset
+= width
;
2810 while (vpos
< stop_vpos
)
2812 val
= *display_text_line (w
, pos
, val
.bytepos
, top
+ vpos
++,
2813 val
.hpos
, val
.tab_offset
,
2814 val
.ovstring_chars_done
);
2815 /* If display_text_line ran a hook and changed some text,
2816 redisplay all the way to bottom of buffer
2817 So that we show the changes. */
2818 if (old_tick
!= MODIFF
)
2820 /* The following code is omitted because we maintain tab offset
2821 in val.tab_offset. */
2823 tab_offset
+= width
;
2824 if (val
.vpos
) tab_offset
= 0;
2826 if (pos
!= val
.bufpos
)
2828 /* Next line, unless prev line ended in end of buffer with no cr */
2829 = vpos
- (val
.vpos
&& FETCH_BYTE (val
.bytepos
- 1) != '\n');
2833 /* There are two cases:
2834 1) we have displayed down to the bottom of the window
2835 2) we have scrolled lines below stop_vpos by scroll_amount */
2839 /* If last line is continued in middle of character,
2840 include the split character in the text considered on the frame */
2841 if (val
.hpos
< lmargin
)
2843 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
);
2844 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2847 /* If scrolling made blank lines at window bottom,
2848 redisplay to fill those lines */
2849 if (scroll_amount
< 0)
2851 /* Don't consider these lines for general-purpose scrolling.
2852 That will save time in the scrolling computation. */
2853 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
2856 pos_byte
= xp
.bytepos
;
2858 val
.tab_offset
= xp
.tab_offset
;
2860 { /* Display from next line */
2861 vpos
= height
+ scroll_amount
;
2865 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
2867 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
2868 val
.tab_offset
= xp
.tab_offset
+ bp
.prevhpos
- width
;
2869 DEC_BOTH (pos
, pos_byte
);
2872 blank_end_of_window
= 1;
2873 /* The following code is omitted because we maintain tab offset
2874 in val.tab_offset. */
2876 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2877 /* If we are starting display in mid-character, correct tab_offset
2878 to account for passing the line that that character starts in. */
2879 if (val
.hpos
< lmargin
)
2880 tab_offset
+= width
;
2882 val
.bytepos
= pos_byte
;
2883 while (vpos
< height
)
2885 val
= *display_text_line (w
, pos
, val
.bytepos
,
2886 top
+ vpos
++, val
.hpos
,
2887 val
.tab_offset
, val
.ovstring_chars_done
);
2888 /* The following code is omitted because we maintain tab
2889 offset in val.tab_offset. */
2891 tab_offset
+= width
;
2892 if (val
.vpos
) tab_offset
= 0;
2897 /* Here is a case where display_text_line sets cursor_vpos wrong.
2898 Make it be fixed up, below. */
2904 /* If bottom just moved off end of frame, change mode line percentage. */
2905 if (XFASTINT (w
->window_end_pos
) == 0
2907 w
->update_mode_line
= Qt
;
2909 /* Attempt to adjust end-of-text positions to new bottom line */
2912 delta
= height
- xp
.vpos
;
2914 || (delta
> 0 && xp
.bufpos
<= ZV
)
2915 || (delta
== 0 && xp
.hpos
))
2917 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), delta
, w
);
2918 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2919 XSETFASTINT (w
->window_end_vpos
,
2920 XFASTINT (w
->window_end_vpos
) + val
.vpos
);
2924 w
->window_end_valid
= Qnil
;
2926 /* If point was not in a line that was displayed, find it */
2927 if (cursor_vpos
< 0)
2930 val
= *compute_motion (start
, 0, lmargin
, 0, PT
,
2931 /* Don't care for VPOS... */
2932 1 << (BITS_PER_SHORT
- 1),
2934 1 << (BITS_PER_SHORT
- 1),
2936 pos_tab_offset (w
, start
, start_byte
),
2938 /* Admit failure if point is off frame now */
2939 if (val
.vpos
>= height
)
2941 for (vpos
= 0; vpos
< height
; vpos
++)
2942 cancel_line (vpos
+ top
, f
);
2945 cursor_vpos
= val
.vpos
+ top
;
2946 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, val
.hpos
, width
);
2949 FRAME_CURSOR_X (f
) = cursor_hpos
;
2950 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2954 val
= *compute_motion (start
, 0, lmargin
, 0, ZV
,
2955 height
, - (1 << (BITS_PER_SHORT
- 1)),
2957 pos_tab_offset (w
, start
, start_byte
),
2959 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
2961 if (XFASTINT (w
->window_end_pos
)
2969 /* Copy LEN glyphs starting address FROM to the rope TO.
2970 But don't actually copy the parts that would come in before S.
2971 Value is TO, advanced past the copied data.
2972 F is the frame we are displaying in. */
2975 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
2977 register GLYPH
*to
; /* Copy to here. */
2978 register GLYPH
*s
; /* Starting point. */
2979 Lisp_Object
*from
; /* Data to copy. */
2981 int face
; /* Face to apply to glyphs which don't specify one. */
2984 register Lisp_Object
*fp
= from
;
2985 /* These cache the results of the last call to compute_glyph_face. */
2987 int last_merged
= 0;
2990 if (! FRAME_TERMCAP_P (f
))
2993 GLYPH glyph
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
2995 unsigned int c
= FAST_GLYPH_CHAR (glyph
);
2998 /* For an invalid character code, use space. */
3001 if (FAST_GLYPH_FACE (glyph
) == 0)
3002 /* If GLYPH has no face code, use FACE. */
3004 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
3005 /* If it's same as previous glyph, use same result. */
3006 facecode
= last_merged
;
3009 /* Merge this glyph's face and remember the result. */
3010 last_code
= FAST_GLYPH_FACE (glyph
);
3011 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
3015 *to
= FAST_MAKE_GLYPH (c
, facecode
);
3023 if (to
>= s
) *to
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
3030 /* Correct a glyph by replacing its specified user-level face code
3031 with a displayable computed face code. */
3034 fix_glyph (f
, glyph
, cface
)
3040 if (! FRAME_TERMCAP_P (f
))
3042 if (FAST_GLYPH_FACE (glyph
) != 0)
3043 cface
= compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
), cface
);
3044 glyph
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), cface
);
3050 /* Return the column of position POS / POS_BYTE in window W's buffer.
3051 The result is rounded down to a multiple of the internal width of W.
3052 This is the amount of indentation of position POS
3053 that is not visible in its horizontal position in the window. */
3056 pos_tab_offset (w
, pos
, pos_byte
)
3058 register int pos
, pos_byte
;
3061 int opoint_byte
= PT_BYTE
;
3063 int width
= window_internal_width (w
) - 1;
3066 return MINI_WINDOW_P (w
) ? -minibuf_prompt_width
: 0;
3068 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3071 TEMP_SET_PT_BOTH (pos
, pos_byte
);
3072 col
= current_column ();
3073 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
3078 /* Display one line of window W, starting at char position START in W's buffer.
3079 START_BYTE is the corresponding byte position.
3081 Display starting at horizontal position HPOS, expressed relative to
3082 W's left edge. In situations where the text at START shouldn't
3083 start at the left margin (i.e. when the window is hscrolled, or
3084 we're continuing a line which left off in the midst of a
3085 multi-column character), HPOS should be negative; we throw away
3086 characters up 'til hpos = 0. So, HPOS must take hscrolling into
3089 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
3091 OVSTR_DONE is the number of chars of overlay before/after strings
3092 at this position which have already been processed.
3094 Display on position VPOS on the frame. It is origin 0, relative to
3095 the top of the frame, not W.
3097 Returns a STRUCT POSITION giving character to start next line with
3098 and where to display it, including a zero or negative hpos.
3099 The vpos field is not really a vpos; it is 1 unless the line is continued */
3101 struct position val_display_text_line
;
3103 static struct position
*
3104 display_text_line (w
, start
, start_byte
, vpos
, hpos
, taboffset
, ovstr_done
)
3112 register int pos
= start
;
3113 int pos_byte
= start_byte
;
3116 int pause
, limit_byte
;
3117 register unsigned char *p
;
3119 register GLYPH
*leftmargin
;
3120 register GLYPH
*p1prev
;
3121 register GLYPH
*p1start
;
3122 GLYPH
*p1_wide_column_end
= (GLYPH
*) 0;
3123 int prevpos
, prevpos_byte
;
3125 FRAME_PTR f
= XFRAME (w
->frame
);
3126 int tab_width
= XINT (current_buffer
->tab_width
);
3127 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
3128 int width
= window_internal_width (w
) - 1;
3129 struct position val
;
3130 int lastpos
, lastpos_byte
;
3132 int last_invis_skip
= 0;
3133 Lisp_Object last_invis_prop
;
3134 int hscroll
= XINT (w
->hscroll
);
3135 int truncate
= (hscroll
3136 || (truncate_partial_width_windows
3137 && !WINDOW_FULL_WIDTH_P (w
))
3138 || !NILP (current_buffer
->truncate_lines
));
3140 /* 1 if this buffer has a region to highlight. */
3141 int highlight_region
3142 = (!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
)
3143 && XMARKER (current_buffer
->mark
)->buffer
!= 0);
3144 int region_beg
, region_end
;
3146 int selective
= (INTEGERP (current_buffer
->selective_display
)
3147 ? XINT (current_buffer
->selective_display
)
3148 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
3149 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3150 register struct Lisp_Char_Table
*dp
= window_display_table (w
);
3152 Lisp_Object default_invis_vector
[3];
3153 /* Number of characters of ellipsis to display after an invisible line
3154 if it calls for an ellipsis.
3155 Note that this value can be nonzero regardless of whether
3156 selective display is enabled--you must check that separately. */
3158 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3159 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
3160 : !NILP (current_buffer
->selective_display_ellipses
) ? 3 : 0);
3161 /* This is the sequence of Lisp objects to display
3162 when there are invisible lines. */
3163 Lisp_Object
*invis_vector_contents
3164 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3165 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
3166 : default_invis_vector
);
3168 GLYPH truncator
= (dp
== 0 || !INTEGERP (DISP_TRUNC_GLYPH (dp
))
3169 || !GLYPH_CHAR_VALID_P (XINT (DISP_TRUNC_GLYPH (dp
)))
3170 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
3171 GLYPH continuer
= (dp
== 0 || !INTEGERP (DISP_CONTINUE_GLYPH (dp
))
3172 || !GLYPH_CHAR_VALID_P (XINT (DISP_CONTINUE_GLYPH (dp
)))
3173 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
3175 /* If 1, we must handle multibyte characters. */
3176 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
3177 /* Length of multibyte form of each character. */
3179 /* Glyphs generated should be set this bit mask if text must be
3180 displayed from right to left. */
3181 GLYPH rev_dir_bit
= (NILP (current_buffer
->direction_reversed
)
3182 ? 0 : GLYPH_MASK_REV_DIR
);
3184 /* The next buffer location at which the face should change, due
3185 to overlays or text property changes. */
3186 int next_face_change
;
3188 /* The next location where the `invisible' property changes, or an
3189 overlay starts or ends. */
3192 /* The face we're currently using. */
3193 int current_face
= 0;
3196 XSETFASTINT (default_invis_vector
[2], '.');
3197 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
3199 get_display_line (f
, vpos
, WINDOW_LEFT_MARGIN (w
));
3200 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3202 /* Show where to highlight the region. */
3203 if (highlight_region
3204 /* Maybe highlight only in selected window. */
3205 && (highlight_nonselected_windows
3206 || w
== XWINDOW (selected_window
)
3207 || (MINI_WINDOW_P (XWINDOW (selected_window
))
3208 && w
== XWINDOW (Vminibuf_scroll_window
))))
3210 region_beg
= marker_position (current_buffer
->mark
);
3211 if (PT
< region_beg
)
3213 region_end
= region_beg
;
3218 w
->region_showing
= Qt
;
3222 region_beg
= region_end
= -1;
3223 w
->region_showing
= Qnil
;
3226 if (MINI_WINDOW_P (w
)
3228 && vpos
== XFASTINT (w
->top
))
3230 if (! NILP (minibuf_prompt
))
3232 int old_width
= minibuf_prompt_width
;
3234 minibuf_prompt_width
3235 = (display_string (w
, vpos
, XSTRING (minibuf_prompt
)->data
,
3236 STRING_BYTES (XSTRING (minibuf_prompt
)),
3237 hpos
+ WINDOW_LEFT_MARGIN (w
),
3238 /* Display a space if we truncate. */
3241 /* Truncate the prompt a little before the
3242 margin, so user input can at least start
3243 on the first line. */
3244 (XFASTINT (w
->width
) > 10
3245 ? XFASTINT (w
->width
) - 4 : -1),
3246 STRING_MULTIBYTE (minibuf_prompt
))
3247 - hpos
- WINDOW_LEFT_MARGIN (w
));
3248 hpos
+= minibuf_prompt_width
;
3249 taboffset
-= minibuf_prompt_width
- old_width
;
3252 minibuf_prompt_width
= 0;
3255 /* If we're hscrolled at all, use compute_motion to skip over any
3256 text off the left edge of the window. compute_motion may know
3257 tricks to do this faster than we can. */
3260 struct position
*left_edge
3261 = compute_motion (pos
, vpos
, hpos
, 0,
3263 width
, hscroll
, taboffset
, w
);
3265 /* Retrieve the buffer position and column provided by
3266 compute_motion. We can't assume that the column will be
3267 zero, because you may have multi-column characters crossing
3270 compute_motion may have moved us past the screen position we
3271 requested, if we hit a multi-column character, or the end of
3272 the line. If so, back up. */
3273 if (left_edge
->vpos
> vpos
3274 || left_edge
->hpos
> 0)
3276 pos
= left_edge
->bufpos
;
3277 pos_byte
= left_edge
->bytepos
;
3278 DEC_BOTH (pos
, pos_byte
);
3279 hpos
= left_edge
->prevhpos
;
3283 pos
= left_edge
->bufpos
;
3284 pos_byte
= left_edge
->bytepos
;
3285 hpos
= left_edge
->hpos
;
3289 hpos
+= WINDOW_LEFT_MARGIN (w
);
3291 desired_glyphs
->bufp
[vpos
] = start
;
3292 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3294 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
3295 /* In case we don't ever write anything into it... */
3296 desired_glyphs
->charstarts
[vpos
][WINDOW_LEFT_MARGIN (w
)] = -1;
3297 leftmargin
= desired_glyphs
->glyphs
[vpos
] + WINDOW_LEFT_MARGIN (w
);
3298 endp
= leftmargin
+ width
;
3300 /* Arrange the overlays nicely for our purposes. Usually, we call
3301 display_text_line on only one line at a time, in which case this
3302 can't really hurt too much, or we call it on lines which appear
3303 one after another in the buffer, in which case all calls to
3304 recenter_overlay_lists but the first will be pretty cheap. */
3305 recenter_overlay_lists (current_buffer
, pos
);
3307 /* Loop generating characters.
3308 Stop at end of buffer, before newline,
3309 if reach or pass continuation column,
3310 or at face change. */
3312 limit_byte
= pos_byte
;
3313 next_face_change
= pos
;
3314 next_boundary
= pos
;
3317 prevpos_byte
= pos_byte
;
3319 /* If the window is hscrolled and point is in the invisible part of the
3320 current line beyond the left margin we can record the cursor location
3322 if (hscroll
&& start
<= PT
&& PT
< pos
&& cursor_vpos
< 0)
3325 cursor_hpos
= p1
- leftmargin
;
3330 int eat_following_binary_data
;
3336 while (pos
== next_boundary
)
3338 Lisp_Object position
, limit
, prop
, ww
;
3340 /* Display the overlay strings here, unless we're at ZV
3341 and have already displayed the appropriate strings
3342 on an earlier line. */
3343 if (pos
< ZV
|| !zv_strings_seen
++)
3346 unsigned char *ovstr
;
3347 ovlen
= overlay_strings (pos
, w
, &ovstr
);
3351 /* Skip the ones we did in a previous line. */
3352 ovstr
+= ovstr_done
;
3353 ovlen
-= ovstr_done
;
3362 c
= STRING_CHAR_AND_LENGTH (ovstr
, ovlen
, len
);
3363 ovstr
+= len
, ovlen
-= len
, ovstr_done
+= len
;
3364 charset
= CHAR_CHARSET (c
);
3365 cols
= (charset
== CHARSET_COMPOSITION
3366 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3367 : CHARSET_WIDTH (charset
));
3371 c
= *ovstr
++, ovlen
--, ovstr_done
++;
3374 g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3377 if (p1
>= leftmargin
&& p1
< endp
)
3378 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3382 /* If we did all the overlay strings
3383 and we have room for text, clear ovstr_done
3384 just for neatness' sake. */
3385 if (ovlen
== 0 && p1
< endp
)
3390 /* Did we reach point? Record the cursor location. */
3391 if (pos
== PT
&& cursor_vpos
< 0)
3394 cursor_hpos
= p1
- leftmargin
;
3400 XSETFASTINT (position
, pos
);
3401 limit
= Fnext_overlay_change (position
);
3402 #ifdef USE_TEXT_PROPERTIES
3403 /* This is just an estimate to give reasonable
3404 performance; nothing should go wrong if it is too small. */
3405 if (XFASTINT (limit
) > pos
+ 50)
3407 int limitpos
= pos
+ 50;
3408 XSETFASTINT (limit
, limitpos
);
3410 limit
= Fnext_single_property_change (position
, Qinvisible
,
3411 Fcurrent_buffer (), limit
);
3413 next_boundary
= XFASTINT (limit
);
3414 /* if the `invisible' property is set, we can skip to
3415 the next property change. */
3417 prop
= Fget_char_property (position
, Qinvisible
, ww
);
3418 if (TEXT_PROP_MEANS_INVISIBLE (prop
))
3420 if (pos
< PT
&& next_boundary
>= PT
)
3423 cursor_hpos
= p1
- leftmargin
;
3425 pos
= next_boundary
;
3426 pos_byte
= CHAR_TO_BYTE (pos
);
3427 last_invis_skip
= pos
;
3428 last_invis_prop
= prop
;
3432 /* Did we reach point? Record the cursor location. */
3433 if (pos
== PT
&& cursor_vpos
< 0)
3436 cursor_hpos
= p1
- leftmargin
;
3439 /* Did we hit the end of the visible region of the buffer?
3443 /* Update charstarts for the end of this line. */
3444 /* Do nothing if off the left edge or at the right edge. */
3445 if (p1
>= leftmargin
&& p1
+ 1 != endp
)
3447 int *p2x
= &charstart
[(p1
< leftmargin
3455 /* Figure out where (if at all) the
3456 redisplay_end_trigger-hook should run. */
3457 if (MARKERP (w
->redisplay_end_trigger
)
3458 && XMARKER (w
->redisplay_end_trigger
)->buffer
!= 0)
3459 e_t_h
= marker_position (w
->redisplay_end_trigger
);
3460 else if (INTEGERP (w
->redisplay_end_trigger
))
3461 e_t_h
= XINT (w
->redisplay_end_trigger
);
3465 /* If we've gone past the place to run a hook,
3467 if (pos
>= e_t_h
&& e_t_h
!= ZV
)
3469 Lisp_Object args
[3];
3471 args
[0] = Qredisplay_end_trigger_functions
;
3472 XSETWINDOW (args
[1], w
);
3473 XSETINT (args
[2], e_t_h
);
3475 /* Since we are *trying* to run these functions,
3476 don't try to run them again, even if they get an error. */
3477 w
->redisplay_end_trigger
= Qnil
;
3478 Frun_hook_with_args (3, args
);
3481 /* Notice if it changed the face of this character. */
3482 next_face_change
= pos
;
3486 /* Did we hit a face change? Figure out what face we should
3487 use now. We also hit this the first time through the
3488 loop, to see what face we should start with. */
3489 if (pos
>= next_face_change
3490 && (FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
)))
3492 int limit
= pos
+ 50;
3494 current_face
= compute_char_face (f
, w
, pos
,
3495 region_beg
, region_end
,
3496 &next_face_change
, limit
, 0);
3500 /* Compute the next place we need to stop
3501 and do something special; set PAUSE. */
3505 if (pos
< next_boundary
&& next_boundary
< pause
)
3506 pause
= next_boundary
;
3507 if (pos
< next_face_change
&& next_face_change
< pause
)
3508 pause
= next_face_change
;
3513 /* Wouldn't you hate to read the next line to someone over
3515 if (pos
< PT
&& PT
< pause
)
3517 if (pos
< GPT
&& GPT
< pause
)
3520 /* LIMIT_BYTE is not the same place in the buffer as PAUSE.
3521 It is a limit on valid characters.
3522 We use it to bound STRING_CHAR_AND_LENGTH. */
3523 limit_byte
= ZV_BYTE
;
3524 if (pos
< GPT
&& GPT_BYTE
< limit_byte
)
3525 limit_byte
= GPT_BYTE
;
3528 int temp
= CHAR_TO_BYTE (pos
);
3529 p
= BYTE_POS_ADDR (temp
);
3537 p1_wide_column_end
= (GLYPH
*) 0;
3540 c
= STRING_CHAR_AND_LENGTH (p
, limit_byte
- pos_byte
, len
), p
+= len
;
3543 /* Let a display table override all standard display methods. */
3544 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
3546 p1
= copy_part_of_rope (f
, p1
, leftmargin
,
3547 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3548 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3549 current_face
, rev_dir_bit
);
3551 else if (c
>= 040 && c
< 0177)
3553 if (p1
>= leftmargin
)
3554 *p1
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3560 /* Same as p1prev, but after the invis_vector_contents text
3561 (if we have that on this line). */
3562 GLYPH
*p1prev_modified
;
3566 if (last_invis_skip
== pos
3567 && TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (last_invis_prop
))
3571 && indented_beyond_p (pos
+ 1, pos_byte
+ 1, selective
))
3573 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3576 INC_BOTH (pos
, pos_byte
);
3577 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3578 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3583 SET_PT_BOTH (opoint
, opoint_byte
);
3585 if (invis
&& selective_rlen
> 0 && p1
>= leftmargin
)
3590 cs
= charstart
+ (p1
- p1start
);
3593 p1
+= selective_rlen
;
3594 if (p1
- leftmargin
> width
)
3597 #if 0 /* This needs more work; charstarts needs to record
3598 both whether a position ho;ds an ellipsis character
3599 and what buffer position it corresponds to. */
3600 csend
= charstart
+ (p1
- p1start
);
3603 /* The idea is to use p1prev_modified instead of p1prev
3604 in the loop below over p2x. */
3605 p1prev_modified
= p1
;
3608 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3609 (p1
- p1prev
), current_face
, rev_dir_bit
);
3612 /* Update charstarts for the newline that ended this line. */
3613 /* Do nothing here for a char that's entirely off the left edge
3614 or if it starts at the right edge. */
3615 if (p1
>= leftmargin
&& p1prev
!= endp
)
3617 /* Store the newline's position into charstarts
3618 for the column where the newline starts.
3619 Store -1 for the rest of the glyphs it occupies. */
3620 int *p2x
= &charstart
[(p1prev
< leftmargin
3621 ? leftmargin
: p1prev
)
3623 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3630 /* Draw the face of the newline character as extending all the
3631 way to the end of the frame line. */
3634 if (p1
< leftmargin
)
3637 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3647 if (p1
>= leftmargin
&& p1
< endp
)
3648 *p1
= MAKE_GLYPH (f
, ' ', current_face
) | rev_dir_bit
;
3651 while ((p1
- leftmargin
+ taboffset
+ hscroll
- (hscroll
> 0))
3654 else if (c
== Ctl ('M') && selective
== -1)
3656 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3657 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3658 pos
= PT
, pos_byte
= PT_BYTE
;
3659 SET_PT_BOTH (opoint
, opoint_byte
);
3661 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3663 if (selective_rlen
> 0)
3665 p1
+= selective_rlen
;
3666 if (p1
- leftmargin
> width
)
3668 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3669 (p1
- p1prev
), current_face
, rev_dir_bit
);
3672 /* Draw the face of the newline character as extending all the
3673 way to the end of the frame line. */
3676 if (p1
< leftmargin
)
3679 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3683 /* Update charstarts for the ^M that ended this line. */
3684 /* Do nothing here for a char that's entirely off the left edge
3685 or if it starts at the right edge. */
3686 if (p1
>= leftmargin
&& p1prev
!= endp
)
3688 /* Store the newline's position into charstarts
3689 for the column where the newline starts.
3690 Store -1 for the rest of the glyphs it occupies. */
3691 int *p2x
= &charstart
[(p1prev
< leftmargin
3692 ? leftmargin
: p1prev
)
3694 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3702 else if (c
< 0200 && ctl_arrow
)
3704 if (p1
>= leftmargin
)
3706 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
3707 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
3708 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3712 if (p1
>= leftmargin
&& p1
< endp
)
3713 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
) | rev_dir_bit
;
3718 /* C is not a multibyte character. */
3719 eat_following_binary_data
= multibyte
&& BASE_LEADING_CODE_P (c
);
3721 label_display_binary_data
:
3723 if (p1
>= leftmargin
&& p1
< endp
)
3725 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
3726 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
3727 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3731 if (p1
>= leftmargin
&& p1
< endp
)
3732 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
) | rev_dir_bit
;
3734 if (p1
>= leftmargin
&& p1
< endp
)
3735 *p1
= (MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
)
3738 if (p1
>= leftmargin
&& p1
< endp
)
3739 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
) | rev_dir_bit
;
3741 } while (eat_following_binary_data
3742 && (pos_byte
+ len
) < limit_byte
3743 && ! CHAR_HEAD_P (*p
)
3744 && ((c
= *p
++), len
++));
3748 /* C is a multibyte character. */
3749 int charset
= CHAR_CHARSET (c
);
3750 int columns
= (charset
== CHARSET_COMPOSITION
3751 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3752 : CHARSET_WIDTH (charset
));
3753 GLYPH g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3757 if (p1
>= leftmargin
&& p1
< endp
)
3758 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3762 p1_wide_column_end
= p1
;
3763 /* Check if binary data follows it. */
3764 if (pos_byte
+ len
< limit_byte
3765 && ! CHAR_HEAD_P (*p
))
3767 eat_following_binary_data
= 1;
3770 goto label_display_binary_data
;
3775 prevpos_byte
= pos_byte
;
3779 /* Update charstarts for the character just output. */
3781 /* Do nothing here for a char that's entirely off the left edge. */
3782 if (p1
>= leftmargin
)
3784 /* Store the char's position into charstarts
3785 for the first glyph occupied by this char.
3786 Store -1 for the rest of the glyphs it occupies. */
3789 int *p2x
= &charstart
[(p1prev
< leftmargin
3790 ? leftmargin
: p1prev
)
3792 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3802 val
.hpos
= - XINT (w
->hscroll
);
3809 lastpos_byte
= pos_byte
;
3811 /* Store 0 in this charstart line for the positions where
3812 there is no character. But do leave what was recorded
3813 for the character that ended the line. */
3814 /* Add 1 in the endtest to compensate for the fact that ENDP was
3815 made from WIDTH, which is 1 less than the window's actual
3817 i
= p1
- p1start
+ 1;
3818 if (p1
< leftmargin
)
3819 i
+= leftmargin
- p1
;
3820 for (; i
< endp
- p1start
+ 1; i
++)
3823 /* Handle continuation in middle of a character */
3824 /* by backing up over it */
3827 /* Don't back up if we never actually displayed any text.
3828 This occurs when the minibuffer prompt takes up the whole line. */
3831 /* Start the next line with that same character whose
3832 character code is C and the length of multi-byte form is
3835 pos_byte
= prevpos_byte
;
3837 if (p1_wide_column_end
< endp
)
3838 /* As ENDP is not in the middle of wide-column character,
3839 we can break the line at ENDP and start from the middle
3840 column in the next line. So, adjust VAL.HPOS to skip
3841 the columns output on this line. */
3842 val
.hpos
+= p1prev
- endp
;
3845 /* We displayed a wide-column character at around ENDP.
3846 Since we can't broke it in the middle, the whole
3847 character should be driven into the next line. */
3848 /* As the result, the actual columns occupied by the
3849 text on this line is less than WIDTH. VAL.TAB_OFFSET
3850 must be adjusted. */
3851 taboffset
= taboffset
+ (p1prev
- endp
);
3852 /* Let's fill unused columns with TRUNCATOR or CONTINUER. */
3854 GLYPH g
= fix_glyph (f
, truncate
? truncator
: continuer
, 0);
3855 while (p1prev
< endp
)
3858 /* If POINT is at POS, cursor should not on this line. */
3860 lastpos_byte
= pos_byte
;
3866 /* Keep in this line everything up to the continuation column. */
3870 /* Finish deciding which character to start the next line on,
3871 and what hpos to start it at.
3872 Also set `lastpos' to the last position which counts as "on this line"
3873 for cursor-positioning. */
3877 if (FETCH_BYTE (pos_byte
) == '\n')
3879 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3881 /* If stopped due to a newline, start next line after it */
3882 SET_PT_BOTH (pos
+ 1, pos_byte
+ 1);
3885 /* Check again for hidden lines, in case the newline occurred exactly
3886 at the right margin. */
3887 while (PT
< ZV
&& selective
> 0
3888 && indented_beyond_p (PT
, PT_BYTE
, selective
))
3889 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3891 pos
= PT
, pos_byte
= PT_BYTE
;
3892 SET_PT_BOTH (opoint
, opoint_byte
);
3895 /* Stopped due to right margin of window */
3899 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3901 SET_PT_BOTH (pos
, pos_byte
);
3902 *p1
++ = fix_glyph (f
, truncator
, 0);
3903 /* Truncating => start next line after next newline,
3904 and point is on this line if it is before the newline,
3905 and skip none of first char of next line */
3907 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3908 while (PT
< ZV
&& selective
> 0
3909 && indented_beyond_p (PT
, PT_BYTE
, selective
));
3910 pos
= PT
, pos_byte
= PT_BYTE
;
3911 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
3912 SET_PT_BOTH (opoint
, opoint_byte
);
3914 lastpos
= pos
- (FETCH_BYTE (pos_byte
- 1) == '\n');
3915 lastpos_byte
= CHAR_TO_BYTE (lastpos
);
3920 *p1
++ = fix_glyph (f
, continuer
, 0);
3922 DEC_BOTH (lastpos
, lastpos_byte
);
3923 val
.tab_offset
= taboffset
+ width
;
3930 /* If point is at eol or in invisible text at eol,
3931 record its frame location now. */
3933 if (start
<= PT
&& PT
<= lastpos
&& cursor_vpos
< 0)
3936 cursor_hpos
= p1
- leftmargin
;
3939 if (cursor_vpos
== vpos
)
3941 if (cursor_hpos
< 0) cursor_hpos
= 0;
3942 if (cursor_hpos
> width
) cursor_hpos
= width
;
3943 cursor_hpos
+= WINDOW_LEFT_MARGIN (w
);
3944 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
3946 if (!(cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f
)
3947 && EQ (FRAME_MINIBUF_WINDOW (f
), minibuf_window
)))
3949 FRAME_CURSOR_Y (f
) = cursor_vpos
;
3950 FRAME_CURSOR_X (f
) = cursor_hpos
;
3953 if (w
== XWINDOW (selected_window
))
3955 /* Line is not continued and did not start
3956 in middle of character */
3957 if ((hpos
- WINDOW_LEFT_MARGIN (w
)
3958 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
3961 this_line_bufpos
= start
;
3962 this_line_buffer
= current_buffer
;
3963 this_line_vpos
= cursor_vpos
;
3964 this_line_start_hpos
= hpos
- WINDOW_LEFT_MARGIN (w
);
3965 this_line_endpos
= Z
- lastpos
;
3968 this_line_bufpos
= 0;
3973 /* If hscroll and line not empty, insert truncation-at-left marker */
3974 if (hscroll
&& lastpos
!= start
)
3976 GLYPH g
= fix_glyph (f
, truncator
, 0);
3978 if (p1
<= leftmargin
)
3979 p1
= leftmargin
+ 1;
3980 else /* MULE: it may be a wide-column character */
3982 p1prev
= leftmargin
+ 1;
3983 while (p1prev
< p1
&& *p1prev
& GLYPH_MASK_PADDING
)
3988 if (!WINDOW_RIGHTMOST_P (w
))
3991 if (p1
< leftmargin
) p1
= leftmargin
;
3992 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
3994 /* Don't draw vertical bars if we're using scroll bars. They're
3995 covered up by the scroll bars, and it's distracting to see
3996 them when the scroll bar windows are flickering around to be
3998 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
4001 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
4004 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
4005 *p1
++ = (dp
&& INTEGERP (DISP_BORDER_GLYPH (dp
))
4006 ? XINT (DISP_BORDER_GLYPH (dp
))
4009 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
4010 p1
- desired_glyphs
->glyphs
[vpos
]);
4011 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
4013 /* If the start of this line is the overlay arrow-position,
4014 then put the arrow string into the display-line. */
4016 if (MARKERP (Voverlay_arrow_position
)
4017 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
4018 && start
== marker_position (Voverlay_arrow_position
)
4019 && STRINGP (Voverlay_arrow_string
)
4020 && ! overlay_arrow_seen
)
4023 int len
= XSTRING (Voverlay_arrow_string
)->size
;
4029 if (!NULL_INTERVAL_P (XSTRING (Voverlay_arrow_string
)->intervals
))
4031 /* If the arrow string has text props, obey them when displaying. */
4032 for (i
= 0, i_byte
= 0; i
< len
; )
4035 Lisp_Object face
, ilisp
;
4038 if (STRING_MULTIBYTE (Voverlay_arrow_string
))
4039 FETCH_STRING_CHAR_ADVANCE (c
, Voverlay_arrow_string
, i
, i_byte
);
4041 c
= XSTRING (Voverlay_arrow_string
)->data
[i
++];
4043 XSETFASTINT (ilisp
, i
);
4044 face
= Fget_text_property (ilisp
, Qface
, Voverlay_arrow_string
);
4045 newface
= compute_glyph_face_1 (f
, face
, 0);
4046 leftmargin
[i
] = FAST_MAKE_GLYPH (c
, newface
);
4050 #endif /* HAVE_FACES */
4052 for (i
= 0; i
< len
; i
++)
4053 leftmargin
[i
] = p
[i
];
4056 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
4057 arrow_end
= (leftmargin
- desired_glyphs
->glyphs
[vpos
]) + len
;
4058 if (desired_glyphs
->used
[vpos
] < arrow_end
)
4059 desired_glyphs
->used
[vpos
] = arrow_end
;
4061 overlay_arrow_seen
= 1;
4065 val
.bytepos
= pos_byte
;
4066 val
.ovstring_chars_done
= ovstr_done
;
4067 val_display_text_line
= val
;
4068 return &val_display_text_line
;
4071 /* Redisplay the menu bar in the frame for window W. */
4074 display_menu_bar (w
)
4077 Lisp_Object items
, tail
;
4078 register int vpos
= 0;
4079 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4080 int maxendcol
= FRAME_WIDTH (f
);
4085 if (!NILP (Vwindow_system
))
4089 #ifdef USE_X_TOOLKIT
4092 #endif /* USE_X_TOOLKIT */
4094 get_display_line (f
, vpos
, 0);
4096 items
= FRAME_MENU_BAR_ITEMS (f
);
4097 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 4)
4099 Lisp_Object pos
, string
;
4100 string
= XVECTOR (items
)->contents
[i
+ 1];
4104 XSETFASTINT (XVECTOR (items
)->contents
[i
+ 3], hpos
);
4106 if (hpos
< maxendcol
)
4107 hpos
= display_string (w
, vpos
,
4108 XSTRING (string
)->data
,
4109 STRING_BYTES (XSTRING (string
)),
4110 hpos
, 0, 0, hpos
, maxendcol
,
4111 STRING_MULTIBYTE (string
));
4112 /* Put a space between items. */
4113 if (hpos
< maxendcol
)
4115 int hpos1
= hpos
+ 1;
4116 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
4117 min (hpos1
, maxendcol
), maxendcol
, 0);
4121 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4122 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4124 /* Fill out the line with spaces. */
4125 if (maxendcol
> hpos
)
4126 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
, 0);
4128 /* Clear the rest of the lines allocated to the menu bar. */
4130 while (vpos
< FRAME_MENU_BAR_LINES (f
))
4131 get_display_line (f
, vpos
++, 0);
4134 /* Display the mode line for window w */
4137 display_mode_line (w
)
4140 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
4141 register int left
= WINDOW_LEFT_MARGIN (w
);
4142 register int right
= WINDOW_RIGHT_MARGIN (w
);
4143 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4145 line_number_displayed
= 0;
4146 w
->column_number_displayed
= Qnil
;
4148 get_display_line (f
, vpos
, left
);
4150 /* Temporarily make frame F's kboard the current kboard
4151 so that kboard-local variables in the mode_line_format
4152 will get the right values. */
4153 push_frame_kboard (f
);
4155 display_mode_element (w
, vpos
, left
, 0, right
, right
,
4156 current_buffer
->mode_line_format
);
4158 pop_frame_kboard ();
4160 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4162 /* Put the mode line in inverse video.
4163 Use faces if possible, since that lets us handle
4164 partial-width windows and avoid inverting the scroll bar columns. */
4166 if (! FRAME_TERMCAP_P (f
) && mode_line_inverse_video
)
4168 /* For a partial width window, explicitly set face of each glyph. */
4170 unsigned int padding
;
4171 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
4172 for (i
= left
; i
< right
; ++i
)
4174 padding
= ptr
[i
] & GLYPH_MASK_PADDING
;
4175 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1) | padding
;
4181 /* Make the mode line inverse video if the entire line
4182 is made of mode lines.
4183 I.e. if this window is full width,
4184 or if it is the child of a full width window
4185 (which implies that that window is split side-by-side
4186 and the rest of this line is mode lines of the sibling windows). */
4187 if (WINDOW_FULL_WIDTH_P (w
)
4188 || WINDOW_FULL_WIDTH_P (XWINDOW (w
->parent
)))
4189 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4192 /* Contribute ELT to the mode line for window W.
4193 How it translates into text depends on its data type.
4195 VPOS is the position of the mode line being displayed.
4197 HPOS is the position (absolute on frame) where this element's text
4198 should start. The output is truncated automatically at the right
4201 DEPTH is the depth in recursion. It is used to prevent
4202 infinite recursion here.
4204 MINENDCOL is the hpos before which the element may not end.
4205 The element is padded at the right with spaces if nec
4206 to reach this column.
4208 MAXENDCOL is the hpos past which this element may not extend.
4209 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
4210 (This is necessary to make nested padding and truncation work.)
4212 Returns the hpos of the end of the text generated by ELT.
4213 The next element will receive that value as its HPOS arg,
4214 so as to concatenate the elements. */
4217 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
4219 register int vpos
, hpos
;
4222 register int maxendcol
;
4223 register Lisp_Object elt
;
4231 switch (SWITCH_ENUM_CAST (XTYPE (elt
)))
4235 /* A string: output it and check for %-constructs within it. */
4236 register unsigned char c
;
4237 register unsigned char *this = XSTRING (elt
)->data
;
4239 while (hpos
< maxendcol
&& *this)
4241 unsigned char *last
= this;
4242 while ((c
= *this++) != '\0' && c
!= '%')
4244 if (this - 1 != last
)
4246 register int lim
= --this - last
+ hpos
;
4247 if (frame_title_ptr
)
4248 hpos
= store_frame_title (last
, hpos
, min (lim
, maxendcol
));
4250 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
4251 hpos
, min (lim
, maxendcol
),
4252 STRING_MULTIBYTE (elt
));
4256 register int minendcol
;
4257 register int spec_width
= 0;
4259 /* We can't allow -ve args due to the "%-" construct */
4260 /* Argument specifies minwidth but not maxwidth
4261 (maxwidth can be specified by
4262 (<negative-number> . <stuff>) mode-line elements) */
4264 while ((c
= *this++) >= '0' && c
<= '9')
4266 spec_width
= spec_width
* 10 + (c
- '0');
4269 minendcol
= hpos
+ spec_width
;
4270 if (minendcol
> maxendcol
)
4272 spec_width
= maxendcol
- hpos
;
4273 minendcol
= maxendcol
;
4277 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4278 spec_width
, maxendcol
,
4279 Vglobal_mode_string
);
4282 char *spec
= decode_mode_spec (w
, c
, spec_width
,
4284 if (frame_title_ptr
)
4285 hpos
= store_frame_title (spec
, minendcol
, maxendcol
);
4287 hpos
= display_string (w
, vpos
, spec
, -1,
4289 minendcol
, maxendcol
, -1);
4297 /* A symbol: process the value of the symbol recursively
4298 as if it appeared here directly. Avoid error if symbol void.
4299 Special case: if value of symbol is a string, output the string
4302 register Lisp_Object tem
;
4303 tem
= Fboundp (elt
);
4306 tem
= Fsymbol_value (elt
);
4307 /* If value is a string, output that string literally:
4308 don't check for % within it. */
4311 if (frame_title_ptr
)
4312 hpos
= store_frame_title (XSTRING (tem
)->data
,
4313 minendcol
, maxendcol
);
4315 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
4316 STRING_BYTES (XSTRING (tem
)),
4317 hpos
, 0, 1, minendcol
, maxendcol
,
4318 STRING_MULTIBYTE (tem
));
4320 /* Give up right away for nil or t. */
4321 else if (!EQ (tem
, elt
))
4322 { elt
= tem
; goto tail_recurse
; }
4329 register Lisp_Object car
, tem
;
4331 /* A cons cell: three distinct cases.
4332 If first element is a string or a cons, process all the elements
4333 and effectively concatenate them.
4334 If first element is a negative number, truncate displaying cdr to
4335 at most that many characters. If positive, pad (with spaces)
4336 to at least that many characters.
4337 If first element is a symbol, process the cadr or caddr recursively
4338 according to whether the symbol's value is non-nil or nil. */
4339 car
= XCONS (elt
)->car
;
4342 tem
= Fboundp (car
);
4343 elt
= XCONS (elt
)->cdr
;
4346 /* elt is now the cdr, and we know it is a cons cell.
4347 Use its car if CAR has a non-nil value. */
4350 tem
= Fsymbol_value (car
);
4352 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
4354 /* Symbol's value is nil (or symbol is unbound)
4355 Get the cddr of the original list
4356 and if possible find the caddr and use that. */
4357 elt
= XCONS (elt
)->cdr
;
4360 else if (!CONSP (elt
))
4362 elt
= XCONS (elt
)->car
;
4365 else if (INTEGERP (car
))
4367 register int lim
= XINT (car
);
4368 elt
= XCONS (elt
)->cdr
;
4370 /* Negative int means reduce maximum width.
4371 DO NOT change MINENDCOL here!
4372 (20 -10 . foo) should truncate foo to 10 col
4373 and then pad to 20. */
4374 maxendcol
= min (maxendcol
, hpos
- lim
);
4377 /* Padding specified. Don't let it be more than
4380 if (lim
> maxendcol
)
4382 /* If that's more padding than already wanted, queue it.
4383 But don't reduce padding already specified even if
4384 that is beyond the current truncation point. */
4385 if (lim
> minendcol
)
4390 else if (STRINGP (car
) || CONSP (car
))
4392 register int limit
= 50;
4393 /* LIMIT is to protect against circular lists. */
4394 while (CONSP (elt
) && --limit
> 0
4395 && hpos
< maxendcol
)
4397 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4400 elt
= XCONS (elt
)->cdr
;
4408 if (frame_title_ptr
)
4409 hpos
= store_frame_title ("*invalid*", minendcol
, maxendcol
);
4411 hpos
= display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
4412 minendcol
, maxendcol
, 0);
4416 if (minendcol
> hpos
)
4417 if (frame_title_ptr
)
4418 hpos
= store_frame_title ("", minendcol
, maxendcol
);
4420 hpos
= display_string (w
, vpos
, "", 0, hpos
,
4421 0, 1, minendcol
, maxendcol
, 0);
4425 /* Write a null-terminated, right justified decimal representation of
4426 the positive integer D to BUF using a minimal field width WIDTH. */
4429 pint2str (buf
, width
, d
)
4434 register char *p
= buf
;
4441 *p
++ = d
% 10 + '0';
4444 for (width
-= (int) (p
- buf
); width
> 0; --width
) *p
++ = ' ';
4454 /* Set a mnemonic character for CODING_SYSTEM (Lisp symbol) in BUF.
4455 If EOL_FLAG is 1, set also a mnemonic character for end-of-line
4456 type of CODING_SYSTEM. Return updated pointer into BUF. */
4459 decode_mode_spec_coding (coding_system
, buf
, eol_flag
)
4460 Lisp_Object coding_system
;
4465 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
4467 val
= coding_system
;
4469 if (NILP (val
)) /* Not yet decided. */
4474 *buf
++ = eol_mnemonic_undecided
;
4475 /* Don't mention EOL conversion if it isn't decided. */
4479 Lisp_Object eolvalue
;
4481 eolvalue
= Fget (coding_system
, Qeol_type
);
4483 while (!NILP (val
) && SYMBOLP (val
))
4485 val
= Fget (val
, Qcoding_system
);
4486 if (NILP (eolvalue
))
4487 eolvalue
= Fget (val
, Qeol_type
);
4491 *buf
++ = XFASTINT (XVECTOR (val
)->contents
[1]);
4495 /* The EOL conversion we are using. */
4497 /* The EOL conversion that is normal on this system. */
4499 if (NILP (eolvalue
)) /* Not yet decided. */
4500 eoltype
= eol_mnemonic_undecided
;
4501 else if (VECTORP (eolvalue
)) /* Not yet decided. */
4502 eoltype
= eol_mnemonic_undecided
;
4503 else /* INTEGERP (eolvalue) -- 0:LF, 1:CRLF, 2:CR */
4504 eoltype
= (XFASTINT (eolvalue
) == 0
4506 : (XFASTINT (eolvalue
) == 1
4507 ? eol_mnemonic_dos
: eol_mnemonic_mac
));
4509 /* Mention the EOL conversion if it is not the usual one. */
4516 /* Return a string for the output of a mode line %-spec for window W,
4517 generated by character C. SPEC_WIDTH is the field width when
4518 padding to the left (%c, %l). The value returned from this
4519 function will later be truncated to width MAXWIDTH. */
4521 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
4524 decode_mode_spec (w
, c
, spec_width
, maxwidth
)
4527 register int spec_width
;
4528 register int maxwidth
;
4531 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4532 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
4533 struct buffer
*b
= XBUFFER (w
->buffer
);
4536 if (maxwidth
> FRAME_WIDTH (f
))
4537 maxwidth
= FRAME_WIDTH (f
);
4542 if (!NILP (b
->read_only
))
4544 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4549 /* This differs from %* only for a modified read-only buffer. */
4550 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4552 if (!NILP (b
->read_only
))
4557 /* This differs from %* in ignoring read-only-ness. */
4558 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4570 if (command_loop_level
> 5)
4572 p
= decode_mode_spec_buf
;
4573 for (i
= 0; i
< command_loop_level
; i
++)
4576 return decode_mode_spec_buf
;
4584 if (command_loop_level
> 5)
4586 p
= decode_mode_spec_buf
;
4587 for (i
= 0; i
< command_loop_level
; i
++)
4590 return decode_mode_spec_buf
;
4598 if (maxwidth
< sizeof (lots_of_dashes
))
4599 return lots_of_dashes
;
4602 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
4606 return decode_mode_spec_buf
;
4612 if (maxwidth
>= 3 && STRING_BYTES (XSTRING (obj
)) > maxwidth
)
4614 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
4615 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
4616 decode_mode_spec_buf
[maxwidth
] = '\0';
4617 return decode_mode_spec_buf
;
4624 int col
= current_column ();
4625 XSETFASTINT (w
->column_number_displayed
, col
);
4626 pint2str (decode_mode_spec_buf
, spec_width
, col
);
4627 return decode_mode_spec_buf
;
4631 /* %F displays the frame name. */
4632 /* Systems that can only display a single frame at a time should
4633 NOT replace the frame name with the (constant) frame title,
4634 since then they won't be able to tell which frame is that. */
4635 if (FRAME_WINDOW_P (f
) && !NILP (f
->title
))
4636 return (char *) XSTRING (f
->title
)->data
;
4637 if (f
->explicit_name
|| ! FRAME_WINDOW_P (f
))
4638 return (char *) XSTRING (f
->name
)->data
;
4646 else if (STRINGP (obj
) && STRING_BYTES (XSTRING (obj
)) > maxwidth
)
4648 bcopy ("...", decode_mode_spec_buf
, 3);
4649 bcopy (XSTRING (obj
)->data
+ STRING_BYTES (XSTRING (obj
)) - maxwidth
+ 3,
4650 decode_mode_spec_buf
+ 3, maxwidth
- 3);
4651 return decode_mode_spec_buf
;
4658 int startpos
= XMARKER (w
->start
)->charpos
;
4659 int startpos_byte
= marker_byte_position (w
->start
);
4660 int line
, linepos
, linepos_byte
, topline
;
4663 int height
= XFASTINT (w
->height
);
4665 /* If we decided that this buffer isn't suitable for line numbers,
4666 don't forget that too fast. */
4667 if (EQ (w
->base_line_pos
, w
->buffer
))
4669 /* But do forget it, if the window shows a different buffer now. */
4670 else if (BUFFERP (w
->base_line_pos
))
4671 w
->base_line_pos
= Qnil
;
4673 /* If the buffer is very big, don't waste time. */
4674 if (BUF_ZV (b
) - BUF_BEGV (b
) > line_number_display_limit
)
4676 w
->base_line_pos
= Qnil
;
4677 w
->base_line_number
= Qnil
;
4681 if (!NILP (w
->base_line_number
)
4682 && !NILP (w
->base_line_pos
)
4683 && XFASTINT (w
->base_line_pos
) <= startpos
)
4685 line
= XFASTINT (w
->base_line_number
);
4686 linepos
= XFASTINT (w
->base_line_pos
);
4687 linepos_byte
= buf_charpos_to_bytepos (b
, linepos
);
4692 linepos
= BUF_BEGV (b
);
4693 linepos_byte
= BUF_BEGV_BYTE (b
);
4696 /* Count lines from base line to window start position. */
4697 nlines
= display_count_lines (linepos
, linepos_byte
,
4701 topline
= nlines
+ line
;
4703 /* Determine a new base line, if the old one is too close
4704 or too far away, or if we did not have one.
4705 "Too close" means it's plausible a scroll-down would
4707 if (startpos
== BUF_BEGV (b
))
4709 XSETFASTINT (w
->base_line_number
, topline
);
4710 XSETFASTINT (w
->base_line_pos
, BUF_BEGV (b
));
4712 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
4713 || linepos
== BUF_BEGV (b
))
4715 int limit
= BUF_BEGV (b
);
4716 int limit_byte
= BUF_BEGV_BYTE (b
);
4718 int distance
= (height
* 2 + 30) * 200;
4720 if (startpos
- distance
> limit
)
4722 limit
= startpos
- distance
;
4723 limit_byte
= CHAR_TO_BYTE (limit
);
4726 nlines
= display_count_lines (startpos
, startpos_byte
,
4728 - (height
* 2 + 30),
4730 /* If we couldn't find the lines we wanted within
4732 give up on line numbers for this window. */
4733 if (position
== limit_byte
&& limit
== startpos
- distance
)
4735 w
->base_line_pos
= w
->buffer
;
4736 w
->base_line_number
= Qnil
;
4740 XSETFASTINT (w
->base_line_number
, topline
- nlines
);
4741 XSETFASTINT (w
->base_line_pos
, BYTE_TO_CHAR (position
));
4744 /* Now count lines from the start pos to point. */
4745 nlines
= display_count_lines (startpos
, startpos_byte
,
4746 PT_BYTE
, PT
, &junk
);
4748 /* Record that we did display the line number. */
4749 line_number_displayed
= 1;
4751 /* Make the string to show. */
4752 pint2str (decode_mode_spec_buf
, spec_width
, topline
+ nlines
);
4753 return decode_mode_spec_buf
;
4756 char* p
= decode_mode_spec_buf
;
4757 for (spec_width
-= 2; spec_width
> 0; --spec_width
) *p
++ = ' ';
4759 return decode_mode_spec_buf
;
4769 if (BUF_BEGV (b
) > BUF_BEG (b
) || BUF_ZV (b
) < BUF_Z (b
))
4775 int pos
= marker_position (w
->start
);
4776 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4778 if (XFASTINT (w
->window_end_pos
) <= BUF_Z (b
) - BUF_ZV (b
))
4780 if (pos
<= BUF_BEGV (b
))
4785 else if (pos
<= BUF_BEGV (b
))
4789 if (total
> 1000000)
4790 /* Do it differently for a large value, to avoid overflow. */
4791 total
= ((pos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4793 total
= ((pos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4794 /* We can't normally display a 3-digit number,
4795 so get us a 2-digit number that is close. */
4798 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4799 return decode_mode_spec_buf
;
4803 /* Display percentage of size above the bottom of the screen. */
4806 int toppos
= marker_position (w
->start
);
4807 int botpos
= BUF_Z (b
) - XFASTINT (w
->window_end_pos
);
4808 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4810 if (botpos
>= BUF_ZV (b
))
4812 if (toppos
<= BUF_BEGV (b
))
4819 if (total
> 1000000)
4820 /* Do it differently for a large value, to avoid overflow. */
4821 total
= ((botpos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4823 total
= ((botpos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4824 /* We can't normally display a 3-digit number,
4825 so get us a 2-digit number that is close. */
4828 if (toppos
<= BUF_BEGV (b
))
4829 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
4831 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4832 return decode_mode_spec_buf
;
4837 /* status of process */
4838 obj
= Fget_buffer_process (w
->buffer
);
4840 return "no process";
4842 obj
= Fsymbol_name (Fprocess_status (obj
));
4846 case 't': /* indicate TEXT or BINARY */
4847 #ifdef MODE_LINE_BINARY_TEXT
4848 return MODE_LINE_BINARY_TEXT (b
);
4854 /* coding-system (not including end-of-line format) */
4856 /* coding-system (including end-of-line type) */
4858 int eol_flag
= (c
== 'Z');
4859 char *p
= decode_mode_spec_buf
;
4861 if (! FRAME_WINDOW_P (f
))
4863 /* No need to mention EOL here--the terminal never needs
4864 to do EOL conversion. */
4865 p
= decode_mode_spec_coding (keyboard_coding
.symbol
, p
, 0);
4866 p
= decode_mode_spec_coding (terminal_coding
.symbol
, p
, 0);
4868 p
= decode_mode_spec_coding (b
->buffer_file_coding_system
,
4871 #if 0 /* This proves to be annoying; I think we can do without. -- rms. */
4873 obj
= Fget_buffer_process (Fcurrent_buffer ());
4876 p
= decode_mode_spec_coding (XPROCESS (obj
)->decode_coding_system
,
4878 p
= decode_mode_spec_coding (XPROCESS (obj
)->encode_coding_system
,
4881 #endif /* subprocesses */
4884 return decode_mode_spec_buf
;
4889 return (char *) XSTRING (obj
)->data
;
4894 /* Count up to COUNT lines starting from START / START_BYTE.
4895 But don't go beyond LIMIT_BYTE.
4896 Return the number of lines thus found (always nonnegative).
4898 Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */
4901 display_count_lines (start
, start_byte
, limit_byte
, count
, byte_pos_ptr
)
4902 int start
, start_byte
, limit_byte
, count
;
4905 register unsigned char *cursor
;
4906 unsigned char *base
;
4908 register int ceiling
;
4909 register unsigned char *ceiling_addr
;
4910 int orig_count
= count
;
4912 /* If we are not in selective display mode,
4913 check only for newlines. */
4914 int selective_display
= (!NILP (current_buffer
->selective_display
)
4915 && !INTEGERP (current_buffer
->selective_display
));
4919 while (start_byte
< limit_byte
)
4921 ceiling
= BUFFER_CEILING_OF (start_byte
);
4922 ceiling
= min (limit_byte
- 1, ceiling
);
4923 ceiling_addr
= BYTE_POS_ADDR (ceiling
) + 1;
4924 base
= (cursor
= BYTE_POS_ADDR (start_byte
));
4927 if (selective_display
)
4928 while (*cursor
!= '\n' && *cursor
!= 015 && ++cursor
!= ceiling_addr
)
4931 while (*cursor
!= '\n' && ++cursor
!= ceiling_addr
)
4934 if (cursor
!= ceiling_addr
)
4938 start_byte
+= cursor
- base
+ 1;
4939 *byte_pos_ptr
= start_byte
;
4943 if (++cursor
== ceiling_addr
)
4949 start_byte
+= cursor
- base
;
4954 while (start_byte
> limit_byte
)
4956 ceiling
= BUFFER_FLOOR_OF (start_byte
- 1);
4957 ceiling
= max (limit_byte
, ceiling
);
4958 ceiling_addr
= BYTE_POS_ADDR (ceiling
) - 1;
4959 base
= (cursor
= BYTE_POS_ADDR (start_byte
- 1) + 1);
4962 if (selective_display
)
4963 while (--cursor
!= ceiling_addr
4964 && *cursor
!= '\n' && *cursor
!= 015)
4967 while (--cursor
!= ceiling_addr
&& *cursor
!= '\n')
4970 if (cursor
!= ceiling_addr
)
4974 start_byte
+= cursor
- base
+ 1;
4975 *byte_pos_ptr
= start_byte
;
4976 /* When scanning backwards, we should
4977 not count the newline posterior to which we stop. */
4978 return - orig_count
- 1;
4984 /* Here we add 1 to compensate for the last decrement
4985 of CURSOR, which took it past the valid range. */
4986 start_byte
+= cursor
- base
+ 1;
4990 *byte_pos_ptr
= limit_byte
;
4993 return - orig_count
+ count
;
4994 return orig_count
- count
;
4998 /* Display STRING on one line of window W, starting at HPOS.
4999 Display at position VPOS. Caller should have done get_display_line.
5000 If VPOS == -1, display it as the current frame's title.
5001 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
5003 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
5005 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
5006 MAXCOL is the last column ok to end at. Truncate here.
5007 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
5008 Both count from the left edge of the frame, as does HPOS.
5009 The right edge of W is an implicit maximum.
5010 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
5012 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
5013 at the place where the current window ends in this line
5014 and not display anything beyond there. Otherwise, only MAXCOL
5015 controls where to stop output.
5017 MULTIBYTE can be 0 meaning do not display multibyte chars,
5018 1 meaning do display them, or -1 meaning obey the current buffer's
5019 value of enable_multibyte_characters.
5021 Returns ending hpos. */
5024 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
5025 obey_window_width
, mincol
, maxcol
, multibyte
)
5027 unsigned char *string
;
5031 int obey_window_width
;
5038 int hscroll
= XINT (w
->hscroll
);
5039 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
5040 register GLYPH
*start
;
5041 register GLYPH
*end
;
5042 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
5043 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
5044 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
5045 int window_width
= XFASTINT (w
->width
);
5047 /* Use the standard display table, not the window's display table.
5048 We don't want the mode line in rot13. */
5049 register struct Lisp_Char_Table
*dp
= 0;
5052 if (multibyte
== -1)
5053 multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
5054 /* Now multibyte is 1 if we should display multibyte characters. */
5056 if (DISP_TABLE_P (Vstandard_display_table
))
5057 dp
= XCHAR_TABLE (Vstandard_display_table
);
5059 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
5062 start
= desired_glyphs
->glyphs
[vpos
];
5064 if (obey_window_width
)
5066 start
+= XFASTINT (w
->left
);
5067 end
= start
+ window_width
- (truncate
!= 0);
5069 if (!WINDOW_RIGHTMOST_P (w
))
5071 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
5075 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
5078 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
5083 if (! obey_window_width
5084 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
5085 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
5087 /* Store 0 in charstart for these columns. */
5088 for (i
= (hpos
>= 0 ? hpos
: 0); i
< end
- p1start
+ hpos
; i
++)
5089 desired_glyphs
->charstarts
[vpos
][i
] = 0;
5091 if (maxcol
>= 0 && mincol
> maxcol
)
5095 /* We need this value for multibyte characters. */
5096 length
= strlen (string
);
5098 /* We set truncated to 1 if we get stopped by trying to pass END
5099 (that is, trying to pass MAXCOL.) */
5108 c
= STRING_CHAR_AND_LENGTH (string
, length
, len
);
5110 c
= *string
, len
= 1;
5112 string
+= len
, length
-= len
;
5120 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
5122 p1
= copy_part_of_rope (f
, p1
, start
,
5123 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
5124 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
5127 else if (c
>= 040 && c
< 0177)
5137 if (p1
>= start
&& p1
< end
)
5141 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
5143 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
5147 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
5148 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
5149 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
5152 if (p1
>= start
&& p1
< end
)
5158 /* C is a control character or a binary byte data. */
5161 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
5162 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
5163 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
5166 if (p1
>= start
&& p1
< end
)
5167 *p1
= (c
>> 6) + '0';
5169 if (p1
>= start
&& p1
< end
)
5170 *p1
= (7 & (c
>> 3)) + '0';
5172 if (p1
>= start
&& p1
< end
)
5173 *p1
= (7 & c
) + '0';
5178 /* C is a multibyte character. */
5179 int charset
= CHAR_CHARSET (c
);
5180 int columns
= (charset
== CHARSET_COMPOSITION
5181 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
5182 : CHARSET_WIDTH (charset
));
5186 /* Since we can't show the left part of C, fill all
5187 columns with spaces. */
5188 columns
-= start
- p1
;
5197 else if (p1
+ columns
> end
)
5199 /* Since we can't show the right part of C, fill all
5200 columns with TRUNCATE if TRUNCATE is specified. */
5204 *p1
++ = fix_glyph (f
, truncate
, 0);
5205 /* And tell the line is truncated. */
5212 /* We can show the whole glyph of C. */
5215 *p1
++ = c
| GLYPH_MASK_PADDING
;
5223 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
5225 else if (mincol
>= 0)
5227 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
5233 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
5235 if (len
> desired_glyphs
->used
[vpos
])
5236 desired_glyphs
->used
[vpos
] = len
;
5237 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
5243 /* This is like a combination of memq and assq.
5244 Return 1 if PROPVAL appears as an element of LIST
5245 or as the car of an element of LIST.
5246 If PROPVAL is a list, compare each element against LIST
5247 in that way, and return 1 if any element of PROPVAL is found in LIST.
5249 This function cannot quit. */
5252 invisible_p (propval
, list
)
5253 register Lisp_Object propval
;
5256 register Lisp_Object tail
, proptail
;
5257 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5259 register Lisp_Object tem
;
5260 tem
= XCONS (tail
)->car
;
5261 if (EQ (propval
, tem
))
5263 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5266 if (CONSP (propval
))
5267 for (proptail
= propval
; CONSP (proptail
);
5268 proptail
= XCONS (proptail
)->cdr
)
5270 Lisp_Object propelt
;
5271 propelt
= XCONS (proptail
)->car
;
5272 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5274 register Lisp_Object tem
;
5275 tem
= XCONS (tail
)->car
;
5276 if (EQ (propelt
, tem
))
5278 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5285 /* Return 1 if PROPVAL appears as the car of an element of LIST
5286 and the cdr of that element is non-nil.
5287 If PROPVAL is a list, check each element of PROPVAL in that way,
5288 and the first time some element is found,
5289 return 1 if the cdr of that element is non-nil.
5291 This function cannot quit. */
5294 invisible_ellipsis_p (propval
, list
)
5295 register Lisp_Object propval
;
5298 register Lisp_Object tail
, proptail
;
5299 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5301 register Lisp_Object tem
;
5302 tem
= XCONS (tail
)->car
;
5303 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5304 return ! NILP (XCONS (tem
)->cdr
);
5306 if (CONSP (propval
))
5307 for (proptail
= propval
; CONSP (proptail
);
5308 proptail
= XCONS (proptail
)->cdr
)
5310 Lisp_Object propelt
;
5311 propelt
= XCONS (proptail
)->car
;
5312 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5314 register Lisp_Object tem
;
5315 tem
= XCONS (tail
)->car
;
5316 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5317 return ! NILP (XCONS (tem
)->cdr
);
5326 staticpro (&Qmenu_bar_update_hook
);
5327 Qmenu_bar_update_hook
= intern ("menu-bar-update-hook");
5329 staticpro (&Qoverriding_terminal_local_map
);
5330 Qoverriding_terminal_local_map
= intern ("overriding-terminal-local-map");
5332 staticpro (&Qoverriding_local_map
);
5333 Qoverriding_local_map
= intern ("overriding-local-map");
5335 staticpro (&Qwindow_scroll_functions
);
5336 Qwindow_scroll_functions
= intern ("window-scroll-functions");
5338 staticpro (&Qredisplay_end_trigger_functions
);
5339 Qredisplay_end_trigger_functions
= intern ("redisplay-end-trigger-functions");
5341 staticpro (&last_arrow_position
);
5342 staticpro (&last_arrow_string
);
5343 last_arrow_position
= Qnil
;
5344 last_arrow_string
= Qnil
;
5346 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
5347 "String (or mode line construct) included (normally) in `mode-line-format'.");
5348 Vglobal_mode_string
= Qnil
;
5350 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
5351 "Marker for where to display an arrow on top of the buffer text.\n\
5352 This must be the beginning of a line in order to work.\n\
5353 See also `overlay-arrow-string'.");
5354 Voverlay_arrow_position
= Qnil
;
5356 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
5357 "String to display as an arrow. See also `overlay-arrow-position'.");
5358 Voverlay_arrow_string
= Qnil
;
5360 DEFVAR_INT ("scroll-step", &scroll_step
,
5361 "*The number of lines to try scrolling a window by when point moves out.\n\
5362 If that fails to bring point back on frame, point is centered instead.\n\
5363 If this is zero, point is always centered after it moves off frame.");
5365 DEFVAR_INT ("scroll-conservatively", &scroll_conservatively
,
5366 "*Scroll up to this many lines, to bring point back on screen.");
5367 scroll_conservatively
= 0;
5369 DEFVAR_INT ("scroll-margin", &scroll_margin
,
5370 "*Number of lines of margin at the top and bottom of a window.\n\
5371 Recenter the window whenever point gets within this many lines\n\
5372 of the top or bottom of the window.");
5375 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
5377 DEFVAR_BOOL ("truncate-partial-width-windows",
5378 &truncate_partial_width_windows
,
5379 "*Non-nil means truncate lines in all windows less than full frame wide.");
5380 truncate_partial_width_windows
= 1;
5382 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
5383 "*Non-nil means use inverse video for the mode line.");
5384 mode_line_inverse_video
= 1;
5386 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
5387 "*Maximum buffer size (in characters) for line number display\n\
5388 If the buffer is bigger than this, the line number does not appear\n\
5389 in the mode line..");
5390 line_number_display_limit
= 1000000;
5392 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
5393 "*Non-nil means highlight region even in nonselected windows.");
5394 highlight_nonselected_windows
= 0;
5396 DEFVAR_BOOL ("multiple-frames", &multiple_frames
,
5397 "Non-nil if more than one frame is visible on this display.\n\
5398 Minibuffer-only frames don't count, but iconified frames do.\n\
5399 This variable is not guaranteed to be accurate except while processing\n\
5400 `frame-title-format' and `icon-title-format'.");
5402 DEFVAR_LISP ("frame-title-format", &Vframe_title_format
,
5403 "Template for displaying the titlebar of visible frames.\n\
5404 \(Assuming the window manager supports this feature.)\n\
5405 This variable has the same structure as `mode-line-format' (which see),\n\
5406 and is used only on frames for which no explicit name has been set\n\
5407 \(see `modify-frame-parameters').");
5408 DEFVAR_LISP ("icon-title-format", &Vicon_title_format
,
5409 "Template for displaying the titlebar of an iconified frame.\n\
5410 \(Assuming the window manager supports this feature.)\n\
5411 This variable has the same structure as `mode-line-format' (which see),\n\
5412 and is used only on frames for which no explicit name has been set\n\
5413 \(see `modify-frame-parameters').");
5415 = Vframe_title_format
5416 = Fcons (intern ("multiple-frames"),
5417 Fcons (build_string ("%b"),
5418 Fcons (Fcons (build_string (""),
5419 Fcons (intern ("invocation-name"),
5420 Fcons (build_string ("@"),
5421 Fcons (intern ("system-name"),
5425 DEFVAR_LISP ("message-log-max", &Vmessage_log_max
,
5426 "Maximum number of lines to keep in the message log buffer.\n\
5427 If nil, disable message logging. If t, log messages but don't truncate\n\
5428 the buffer when it becomes large.");
5429 XSETFASTINT (Vmessage_log_max
, 50);
5431 DEFVAR_LISP ("window-size-change-functions", &Vwindow_size_change_functions
,
5432 "Functions called before redisplay, if window sizes have changed.\n\
5433 The value should be a list of functions that take one argument.\n\
5434 Just before redisplay, for each frame, if any of its windows have changed\n\
5435 size since the last redisplay, or have been split or deleted,\n\
5436 all the functions in the list are called, with the frame as argument.");
5437 Vwindow_size_change_functions
= Qnil
;
5439 DEFVAR_LISP ("window-scroll-functions", &Vwindow_scroll_functions
,
5440 "List of functions to call before redisplaying a window with scrolling.\n\
5441 Each function is called with two arguments, the window\n\
5442 and its new display-start position. Note that the value of `window-end'\n\
5443 is not valid when these functions are called.");
5444 Vwindow_scroll_functions
= Qnil
;
5446 DEFVAR_INT ("minibuffer-scroll-overlap", &minibuffer_scroll_overlap
,
5447 "*Number of characters of overlap when scrolling a one-line window.\n\
5448 This commonly affects the minibuffer window, hence the name of the variable.");
5449 minibuffer_scroll_overlap
= 20;
5452 /* initialize the window system */
5455 Lisp_Object root_window
;
5456 #ifndef COMPILER_REGISTER_BUG
5458 #endif /* COMPILER_REGISTER_BUG */
5459 struct window
*mini_w
;
5461 this_line_bufpos
= 0;
5463 mini_w
= XWINDOW (minibuf_window
);
5464 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
5466 echo_area_glyphs
= 0;
5467 previous_echo_glyphs
= 0;
5469 if (!noninteractive
)
5471 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
5472 XSETFASTINT (XWINDOW (root_window
)->top
, FRAME_MENU_BAR_LINES (f
));
5473 set_window_height (root_window
,
5474 FRAME_HEIGHT (f
) - 1 - FRAME_MENU_BAR_LINES (f
),
5476 XSETFASTINT (mini_w
->top
, FRAME_HEIGHT (f
) - 1);
5477 set_window_height (minibuf_window
, 1, 0);
5479 XSETFASTINT (XWINDOW (root_window
)->width
, FRAME_WIDTH (f
));
5480 XSETFASTINT (mini_w
->width
, FRAME_WIDTH (f
));