1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 1997
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 int nonascii_insert_offset
;
56 extern Lisp_Object Qface
;
58 extern Lisp_Object Voverriding_local_map
;
59 extern Lisp_Object Voverriding_local_map_menu_flag
;
61 Lisp_Object Qoverriding_local_map
, Qoverriding_terminal_local_map
;
62 Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
63 Lisp_Object Qredisplay_end_trigger_functions
;
65 /* Nonzero means print newline to stdout before next minibuffer message. */
67 int noninteractive_need_newline
;
69 /* Nonzero means print newline to message log before next message. */
71 static int message_log_need_newline
;
73 #define min(a, b) ((a) < (b) ? (a) : (b))
74 #define max(a, b) ((a) > (b) ? (a) : (b))
75 #define minmax(floor, val, ceil) \
76 ((val) < (floor) ? (floor) : (val) > (ceil) ? (ceil) : (val))
78 /* The buffer position of the first character appearing
79 entirely or partially on the current frame line.
80 Or zero, which disables the optimization for the current frame line. */
81 static int this_line_bufpos
;
83 /* Number of characters past the end of this line,
84 including the terminating newline */
85 static int this_line_endpos
;
87 /* The vertical position of this frame line. */
88 static int this_line_vpos
;
90 /* Hpos value for start of display on this frame line.
91 Usually zero, but negative if first character really began
93 static int this_line_start_hpos
;
95 /* Buffer that this_line variables are describing. */
96 static struct buffer
*this_line_buffer
;
98 /* Value of echo_area_glyphs when it was last acted on.
99 If this is nonzero, there is a message on the frame
100 in the minibuffer and it should be erased as soon
101 as it is no longer requested to appear. */
102 char *previous_echo_glyphs
;
104 /* Nonzero means truncate lines in all windows less wide than the frame */
105 int truncate_partial_width_windows
;
107 /* Nonzero means we have more than one non-minibuffer-only frame.
108 Not guaranteed to be accurate except while parsing frame-title-format. */
111 Lisp_Object Vglobal_mode_string
;
113 /* Marker for where to display an arrow on top of the buffer text. */
114 Lisp_Object Voverlay_arrow_position
;
116 /* String to display for the arrow. */
117 Lisp_Object Voverlay_arrow_string
;
119 /* Values of those variables at last redisplay.
120 However, if Voverlay_arrow_position is a marker,
121 last_arrow_position is its numerical position. */
122 static Lisp_Object last_arrow_position
, last_arrow_string
;
124 /* Like mode-line-format, but for the titlebar on a visible frame. */
125 Lisp_Object Vframe_title_format
;
127 /* Like mode-line-format, but for the titlebar on an iconified frame. */
128 Lisp_Object Vicon_title_format
;
130 /* List of functions to call when a window's size changes. These
131 functions get one arg, a frame on which one or more windows' sizes
133 static Lisp_Object Vwindow_size_change_functions
;
135 Lisp_Object Qmenu_bar_update_hook
;
137 /* Nonzero if overlay arrow has been displayed once in this window. */
138 static int overlay_arrow_seen
;
140 /* Nonzero if visible end of buffer has already been displayed once
141 in this window. (We need this variable in case there are overlay
142 strings that get displayed there.) */
143 static int zv_strings_seen
;
145 /* Nonzero means highlight the region even in nonselected windows. */
146 static int highlight_nonselected_windows
;
148 /* If cursor motion alone moves point off frame,
149 Try scrolling this many lines up or down if that will bring it back. */
150 static int scroll_step
;
152 /* Non-0 means scroll just far enough to bring point back on the screen,
154 static int scroll_conservatively
;
156 /* Recenter the window whenever point gets within this many lines
157 of the top or bottom of the window. */
160 /* Number of characters of overlap to show,
161 when scrolling a one-line window such as a minibuffer. */
162 static int minibuffer_scroll_overlap
;
164 /* Nonzero if try_window_id has made blank lines at window bottom
165 since the last redisplay that paused */
166 static int blank_end_of_window
;
168 /* Number of windows showing the buffer of the selected window
169 (or another buffer with the same base buffer).
170 keyboard.c refers to this. */
173 /* display_text_line sets these to the frame position (origin 0) of point,
174 whether the window is selected or not.
175 Set one to -1 first to determine whether point was found afterwards. */
177 static int cursor_vpos
;
178 static int cursor_hpos
;
180 static int debug_end_pos
;
182 /* Nonzero means display mode line highlighted */
183 int mode_line_inverse_video
;
185 static void redisplay_internal ();
186 static int message_log_check_duplicate ();
187 static void echo_area_display ();
188 void mark_window_display_accurate ();
189 static void redisplay_windows ();
190 static void redisplay_window ();
191 static void update_menu_bar ();
192 static void try_window ();
193 static int try_window_id ();
194 static struct position
*display_text_line ();
195 static void display_mode_line ();
196 static int display_mode_element ();
197 static char *decode_mode_spec ();
198 static int display_string ();
199 static void display_menu_bar ();
200 static int display_count_lines ();
202 /* Prompt to display in front of the minibuffer contents */
203 Lisp_Object minibuf_prompt
;
205 /* Width in columns of current minibuffer prompt. */
206 int minibuf_prompt_width
;
208 /* Message to display instead of minibuffer contents
209 This is what the functions error and message make,
210 and command echoing uses it as well.
211 It overrides the minibuf_prompt as well as the buffer. */
212 char *echo_area_glyphs
;
214 /* This is the length of the message in echo_area_glyphs. */
215 int echo_area_glyphs_length
;
217 /* This is the window where the echo area message was displayed.
218 It is always a minibuffer window, but it may not be the
219 same window currently active as a minibuffer. */
220 Lisp_Object echo_area_window
;
222 /* Nonzero means multibyte characters were enabled when the echo area
223 message was specified. */
224 int message_enable_multibyte
;
226 /* true iff we should redraw the mode lines on the next redisplay */
227 int update_mode_lines
;
229 /* Smallest number of characters before the gap
230 at any time since last redisplay that finished.
231 Valid for current buffer when try_window_id can be called. */
234 /* Smallest number of characters after the gap
235 at any time since last redisplay that finished.
236 Valid for current buffer when try_window_id can be called. */
239 /* MODIFF as of last redisplay that finished;
240 if it matches MODIFF, and overlay_unchanged_modified
241 matches OVERLAY_MODIFF, that means beg_unchanged and end_unchanged
242 contain no useful information */
243 int unchanged_modified
;
245 /* OVERLAY_MODIFF as of last redisplay that finished. */
246 int overlay_unchanged_modified
;
248 /* Nonzero if window sizes or contents have changed
249 since last redisplay that finished */
250 int windows_or_buffers_changed
;
252 /* Nonzero after display_mode_line if %l was used
253 and it displayed a line number. */
254 int line_number_displayed
;
256 /* Maximum buffer size for which to display line numbers. */
257 static int line_number_display_limit
;
259 /* Number of lines to keep in the message log buffer.
260 t means infinite. nil means don't log at all. */
261 Lisp_Object Vmessage_log_max
;
263 #define COERCE_MARKER(X) \
264 (MARKERP ((X)) ? Fmarker_position (X) : (X))
266 static int pos_tab_offset
P_ ((struct window
*, int, int));
268 /* Output a newline in the *Messages* buffer if "needs" one. */
271 message_log_maybe_newline ()
273 if (message_log_need_newline
)
274 message_dolog ("", 0, 1);
278 /* Add a string to the message log, optionally terminated with a newline.
279 This function calls low-level routines in order to bypass text property
280 hooks, etc. which might not be safe to run. */
283 message_dolog (m
, len
, nlflag
)
287 if (!NILP (Vmessage_log_max
))
289 struct buffer
*oldbuf
;
290 Lisp_Object oldpoint
, oldbegv
, oldzv
;
291 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
292 int point_at_end
= 0;
295 oldbuf
= current_buffer
;
296 Fset_buffer (Fget_buffer_create (build_string ("*Messages*")));
297 current_buffer
->undo_list
= Qt
;
299 oldpoint
= Fpoint_marker ();
300 oldbegv
= Fpoint_min_marker ();
301 oldzv
= Fpoint_max_marker ();
309 BEGV_BYTE
= BEG_BYTE
;
312 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
314 /* Insert the string--maybe converting multibyte to single byte
315 or vice versa, so that all the text fits the buffer. */
316 if (! NILP (oldbuf
->enable_multibyte_characters
)
317 && NILP (current_buffer
->enable_multibyte_characters
))
319 int c
, i
= 0, nbytes
;
320 /* Convert a multibyte string to single-byte
321 for the *Message* buffer. */
324 c
= STRING_CHAR (m
+ i
, len
- i
);
325 i
+= XFASTINT (Fchar_bytes (make_number (c
)));
326 /* Truncate the character to its last byte--we can only hope
327 the user is happy with the character he gets,
328 since if it isn't right, there is no way to do it right. */
333 else if (NILP (oldbuf
->enable_multibyte_characters
)
334 && ! NILP (current_buffer
->enable_multibyte_characters
))
337 /* Convert a single-byte string to multibyte
338 for the *Message* buffer. */
342 /* Convert non-ascii chars as if for self-insert. */
343 if (c
>= 0200 && c
<= 0377)
344 c
+= nonascii_insert_offset
;
349 insert_1 (m
, len
, 1, 0, 0);
353 int this_bol
, this_bol_byte
, prev_bol
, prev_bol_byte
, dup
;
354 insert_1 ("\n", 1, 1, 0, 0);
356 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
, -2, 0);
358 this_bol_byte
= PT_BYTE
;
362 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
, -2, 0);
364 prev_bol_byte
= PT_BYTE
;
366 dup
= message_log_check_duplicate (prev_bol
, this_bol
,
367 prev_bol_byte
, this_bol_byte
);
370 del_range_both (prev_bol
, prev_bol_byte
,
371 this_bol
, this_bol_byte
, 0);
377 /* If you change this format, don't forget to also
378 change message_log_check_duplicate. */
379 sprintf (dupstr
, " [%d times]", dup
);
380 duplen
= strlen (dupstr
);
381 TEMP_SET_PT_BOTH (Z
- 1, Z_BYTE
- 1);
382 insert_1 (dupstr
, duplen
, 1, 0, 1);
387 if (NATNUMP (Vmessage_log_max
))
389 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
,
390 -XFASTINT (Vmessage_log_max
) - 1, 0);
391 del_range_both (BEG
, BEG_BYTE
, PT
, PT_BYTE
, 0);
394 BEGV
= XMARKER (oldbegv
)->charpos
;
395 BEGV_BYTE
= marker_byte_position (oldbegv
);
404 ZV
= XMARKER (oldzv
)->charpos
;
405 ZV_BYTE
= marker_byte_position (oldzv
);
409 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
411 Fgoto_char (oldpoint
);
413 free_marker (oldpoint
);
414 free_marker (oldbegv
);
417 set_buffer_internal (oldbuf
);
418 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
419 message_log_need_newline
= !nlflag
;
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. */
477 /* First flush out any partial line written with print. */
478 message_log_maybe_newline ();
480 message_dolog (m
, len
, 1);
481 message2_nolog (m
, len
,
482 ! NILP (current_buffer
->enable_multibyte_characters
));
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 a null-terminated echo area message M. If M is 0, clear out any
545 existing message, and let the minibuffer text show through.
547 The buffer M must continue to exist until after the echo area
548 gets cleared or some other message gets displayed there.
550 Do not pass text that is stored in a Lisp string.
551 Do not pass text in a buffer that was alloca'd. */
557 message2 (m
, (m
? strlen (m
) : 0));
564 message2_nolog (m
, (m
? strlen (m
) : 0),
565 ! NILP (current_buffer
->enable_multibyte_characters
));
568 /* Truncate what will be displayed in the echo area
569 the next time we display it--but don't redisplay it now. */
572 truncate_echo_area (len
)
575 /* A null message buffer means that the frame hasn't really been
576 initialized yet. Error messages get reported properly by
577 cmd_error, so this must be just an informative message; toss it. */
578 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
579 echo_area_glyphs_length
= len
;
582 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
583 zero if being used by message. */
584 int message_buf_print
;
586 /* Dump an informative message to the minibuf. If M is 0, clear out
587 any existing message, and let the minibuffer text show through. */
591 message (m
, a1
, a2
, a3
)
593 EMACS_INT a1
, a2
, a3
;
599 if (noninteractive_need_newline
)
601 noninteractive_need_newline
= 0;
602 fprintf (stderr
, m
, a1
, a2
, a3
);
603 if (cursor_in_echo_area
== 0)
604 fprintf (stderr
, "\n");
608 else if (INTERACTIVE
)
610 /* The frame whose minibuffer we're going to display the message on.
611 It may be larger than the selected frame, so we need
612 to use its buffer, not the selected frame's buffer. */
613 Lisp_Object mini_window
;
616 /* Get the frame containing the minibuffer
617 that the selected frame is using. */
618 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
619 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
621 /* A null message buffer means that the frame hasn't really been
622 initialized yet. Error messages get reported properly by
623 cmd_error, so this must be just an informative message; toss it. */
624 if (FRAME_MESSAGE_BUF (f
))
635 len
= doprnt (FRAME_MESSAGE_BUF (f
),
636 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
638 len
= doprnt (FRAME_MESSAGE_BUF (f
),
639 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3,
641 #endif /* NO_ARG_ARRAY */
643 message2 (FRAME_MESSAGE_BUF (f
), len
);
648 /* Print should start at the beginning of the message
650 message_buf_print
= 0;
655 /* The non-logging version of message. */
657 message_nolog (m
, a1
, a2
, a3
)
659 EMACS_INT a1
, a2
, a3
;
661 Lisp_Object old_log_max
;
662 old_log_max
= Vmessage_log_max
;
663 Vmessage_log_max
= Qnil
;
664 message (m
, a1
, a2
, a3
);
665 Vmessage_log_max
= old_log_max
;
671 message2 (echo_area_glyphs
, echo_area_glyphs_length
);
679 Lisp_Object mini_window
;
681 /* Choose the minibuffer window for this display.
682 It is the minibuffer window used by the selected frame. */
683 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
684 /* This is the frame that window is in. */
685 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
687 if (! FRAME_VISIBLE_P (f
))
692 redraw_garbaged_frames ();
696 if (echo_area_glyphs
|| minibuf_level
== 0)
700 echo_area_window
= mini_window
;
702 vpos
= XFASTINT (XWINDOW (mini_window
)->top
);
703 get_display_line (f
, vpos
, 0);
705 /* Make sure the columns that overlap a left-hand scroll bar
707 for (i
= 0; i
< FRAME_LEFT_SCROLL_BAR_WIDTH (f
); i
++)
708 f
->desired_glyphs
->glyphs
[vpos
][i
] = SPACEGLYPH
;
710 display_string (XWINDOW (mini_window
), vpos
,
711 echo_area_glyphs
? echo_area_glyphs
: "",
712 echo_area_glyphs
? echo_area_glyphs_length
: -1,
713 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
715 FRAME_WIDTH (f
) + FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
716 message_enable_multibyte
);
718 #if 0 /* This just gets in the way. update_frame does the job. */
719 /* If desired cursor location is on this line, put it at end of text */
720 if (cursor_in_echo_area
)
721 FRAME_CURSOR_Y (f
) = vpos
;
722 if (FRAME_CURSOR_Y (f
) == vpos
)
723 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
726 /* Fill the rest of the minibuffer window with blank lines. */
731 i
< vpos
+ XFASTINT (XWINDOW (mini_window
)->height
); i
++)
733 get_display_line (f
, i
, 0);
734 /* We don't use FRAME_SCROLL_BAR_WIDTH (f) as the starting
735 hpos, because it is good to clear whatever is behind the
736 scroll bar. This does not affect the scroll bar itself. */
737 display_string (XWINDOW (mini_window
), i
,
740 0, FRAME_WIDTH (f
) + FRAME_SCROLL_BAR_WIDTH (f
),
745 else if (!EQ (mini_window
, selected_window
))
746 windows_or_buffers_changed
++;
748 if (EQ (mini_window
, selected_window
))
749 this_line_bufpos
= 0;
751 previous_echo_glyphs
= echo_area_glyphs
;
754 /* Update frame titles. */
756 #ifdef HAVE_WINDOW_SYSTEM
757 static char frame_title_buf
[512];
758 static char *frame_title_ptr
;
761 store_frame_title (str
, mincol
, maxcol
)
766 if (maxcol
< 0 || maxcol
>= sizeof(frame_title_buf
))
767 maxcol
= sizeof (frame_title_buf
);
768 limit
= &frame_title_buf
[maxcol
];
769 while (*str
!= '\0' && frame_title_ptr
< limit
)
770 *frame_title_ptr
++ = *str
++;
771 while (frame_title_ptr
< &frame_title_buf
[mincol
])
772 *frame_title_ptr
++ = ' ';
773 return frame_title_ptr
- frame_title_buf
;
777 x_consider_frame_title (frame
)
783 FRAME_PTR f
= XFRAME (frame
);
785 if (!(FRAME_WINDOW_P (f
) || FRAME_MINIBUF_ONLY_P (f
) || f
->explicit_name
))
788 /* Do we have more than one visible frame on this X display? */
792 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
794 FRAME_PTR tf
= XFRAME (XCONS (tail
)->car
);
796 if (tf
!= f
&& FRAME_KBOARD (tf
) == FRAME_KBOARD (f
)
797 && !FRAME_MINIBUF_ONLY_P (tf
)
798 && (FRAME_VISIBLE_P (tf
) || FRAME_ICONIFIED_P (tf
)))
802 multiple_frames
= CONSP (tail
);
805 obuf
= current_buffer
;
806 Fset_buffer (XWINDOW (f
->selected_window
)->buffer
);
807 fmt
= (FRAME_ICONIFIED_P (f
) ? Vicon_title_format
: Vframe_title_format
);
808 frame_title_ptr
= frame_title_buf
;
809 len
= display_mode_element (XWINDOW (f
->selected_window
), 0, 0, 0,
810 0, sizeof (frame_title_buf
), fmt
);
812 set_buffer_internal (obuf
);
813 /* Set the name only if it's changed. This avoids consing
814 in the common case where it hasn't. (If it turns out that we've
815 already wasted too much time by walking through the list with
816 display_mode_element, then we might need to optimize at a higher
818 if (! STRINGP (f
->name
) || XSTRING (f
->name
)->size
!= len
819 || bcmp (frame_title_buf
, XSTRING (f
->name
)->data
, len
) != 0)
820 x_implicitly_set_name (f
, make_string (frame_title_buf
, len
), Qnil
);
823 #define frame_title_ptr ((char *)0)
824 #define store_frame_title(str, mincol, maxcol) 0
827 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
828 This can call eval. */
833 register struct window
*w
= XWINDOW (selected_window
);
835 struct gcpro gcpro1
, gcpro2
;
837 all_windows
= (update_mode_lines
|| buffer_shared
> 1
838 || windows_or_buffers_changed
);
840 /* Update all frame titles based on their buffer names, etc.
841 We do this before the menu bars so that the buffer-menu
842 will show the up-to-date frame titles.
844 This used to be done after the menu bars, for a reason that
845 was stated as follows but which I do not understand:
846 "We do this after the menu bars so that the frame will first
847 create its menu bar using the name `emacs' if no other name
848 has yet been specified."
849 I think that is no longer a concern. */
850 #ifdef HAVE_WINDOW_SYSTEM
851 if (windows_or_buffers_changed
|| update_mode_lines
)
853 Lisp_Object tail
, frame
;
855 FOR_EACH_FRAME (tail
, frame
)
856 if (FRAME_VISIBLE_P (XFRAME (frame
))
857 || FRAME_ICONIFIED_P (XFRAME (frame
)))
858 x_consider_frame_title (frame
);
862 /* Update the menu bar item lists, if appropriate.
863 This has to be done before any actual redisplay
864 or generation of display lines. */
867 Lisp_Object tail
, frame
;
868 int count
= specpdl_ptr
- specpdl
;
870 record_unwind_protect (Fstore_match_data
, Fmatch_data (Qnil
, Qnil
));
872 FOR_EACH_FRAME (tail
, frame
)
874 /* If a window on this frame changed size,
875 report that to the user and clear the size-change flag. */
876 if (FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)))
878 Lisp_Object functions
;
879 /* Clear flag first in case we get error below. */
880 FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)) = 0;
881 functions
= Vwindow_size_change_functions
;
882 GCPRO2 (tail
, functions
);
883 while (CONSP (functions
))
885 call1 (XCONS (functions
)->car
, frame
);
886 functions
= XCONS (functions
)->cdr
;
891 update_menu_bar (XFRAME (frame
), 0);
895 unbind_to (count
, Qnil
);
898 update_menu_bar (selected_frame
, 1);
900 /* Motif needs this. See comment in xmenu.c.
901 Turn it off when pending_menu_activation is not defined. */
903 pending_menu_activation
= 0;
907 /* Do a frame update, taking possible shortcuts into account.
908 This is the main external entry point for redisplay.
910 If the last redisplay displayed an echo area message and that
911 message is no longer requested, we clear the echo area
912 or bring back the minibuffer if that is in use.
914 Do not call eval from within this function.
915 Calls to eval after the call to echo_area_display would confuse
916 the display_line mechanism and would cause a crash.
917 Calls to eval before that point will work most of the time,
918 but can still lose, because this function
919 can be called from signal handlers; with alarms set up;
920 or with synchronous processes running.
922 See Fcall_process; if you called it from here, it could be
923 entered recursively. */
925 static int do_verify_charstarts
;
927 /* Counter is used to clear the face cache
928 no more than once ever 1000 redisplays. */
929 static int clear_face_cache_count
;
931 /* Record the previous terminal frame we displayed. */
932 static FRAME_PTR previous_terminal_frame
;
937 redisplay_internal (0);
940 /* If PRESERVE_ECHO_AREA is nonzero, it means this redisplay
941 is not in response to any user action; therefore, we should
942 preserve the echo area. (Actually, our caller does that job.)
943 Perhaps in the future avoid recentering windows
944 if it is not necessary; currently that causes some problems. */
947 redisplay_internal (preserve_echo_area
)
948 int preserve_echo_area
;
950 register struct window
*w
= XWINDOW (selected_window
);
954 register int tlbufpos
, tlendpos
;
956 int number_of_visible_frames
;
962 if (popup_activated ())
968 if (! FRAME_WINDOW_P (selected_frame
)
969 && previous_terminal_frame
!= selected_frame
)
971 /* Since frames on an ASCII terminal share the same display area,
972 displaying a different frame means redisplay the whole thing. */
973 windows_or_buffers_changed
++;
974 SET_FRAME_GARBAGED (selected_frame
);
975 XSETFRAME (Vterminal_frame
, selected_frame
);
977 previous_terminal_frame
= selected_frame
;
979 /* Set the visible flags for all frames.
980 Do this before checking for resized or garbaged frames; they want
981 to know if their frames are visible.
982 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
984 Lisp_Object tail
, frame
;
986 number_of_visible_frames
= 0;
988 FOR_EACH_FRAME (tail
, frame
)
990 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
992 if (FRAME_VISIBLE_P (XFRAME (frame
)))
993 number_of_visible_frames
++;
995 /* Clear out all the display lines in which we will generate the
996 glyphs to display. */
997 init_desired_glyphs (XFRAME (frame
));
1001 /* Notice any pending interrupt request to change frame size. */
1002 do_pending_window_change ();
1006 redraw_garbaged_frames ();
1010 prepare_menu_bars ();
1012 if (windows_or_buffers_changed
)
1013 update_mode_lines
++;
1015 /* Detect case that we need to write or remove a star in the mode line. */
1016 if ((SAVE_MODIFF
< MODIFF
) != !NILP (w
->last_had_star
))
1018 w
->update_mode_line
= Qt
;
1019 if (buffer_shared
> 1)
1020 update_mode_lines
++;
1023 /* If %c is in use, update it if needed. */
1024 if (!NILP (w
->column_number_displayed
)
1025 /* This alternative quickly identifies a common case
1026 where no change is needed. */
1027 && !(PT
== XFASTINT (w
->last_point
)
1028 && XFASTINT (w
->last_modified
) >= MODIFF
1029 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1030 && XFASTINT (w
->column_number_displayed
) != current_column ())
1031 w
->update_mode_line
= Qt
;
1033 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
1035 all_windows
= update_mode_lines
|| buffer_shared
> 1;
1037 /* If specs for an arrow have changed, do thorough redisplay
1038 to ensure we remove any arrow that should no longer exist. */
1039 if (! EQ (COERCE_MARKER (Voverlay_arrow_position
), last_arrow_position
)
1040 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
1043 /* Normally the message* functions will have already displayed and
1044 updated the echo area, but the frame may have been trashed, or
1045 the update may have been preempted, so display the echo area
1047 if (echo_area_glyphs
|| previous_echo_glyphs
)
1049 echo_area_display ();
1053 /* If showing region, and mark has changed, must redisplay whole window. */
1054 if (((!NILP (Vtransient_mark_mode
)
1055 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1056 != !NILP (w
->region_showing
))
1057 || (!NILP (w
->region_showing
)
1058 && !EQ (w
->region_showing
,
1059 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
1060 this_line_bufpos
= -1;
1062 tlbufpos
= this_line_bufpos
;
1063 tlendpos
= this_line_endpos
;
1064 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
1065 && !current_buffer
->clip_changed
1066 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
1067 && !FRAME_OBSCURED_P (XFRAME (w
->frame
))
1068 /* Make sure recorded data applies to current buffer, etc */
1069 && this_line_buffer
== current_buffer
1070 && current_buffer
== XBUFFER (w
->buffer
)
1071 && NILP (w
->force_start
)
1072 /* Point must be on the line that we have info recorded about */
1074 && PT
<= Z
- tlendpos
1075 /* All text outside that line, including its final newline,
1076 must be unchanged */
1077 && ((XFASTINT (w
->last_modified
) >= MODIFF
1078 && (XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
))
1079 || (beg_unchanged
>= tlbufpos
- 1
1081 /* If selective display, can't optimize
1082 if the changes start at the beginning of the line. */
1083 && ((INTEGERP (current_buffer
->selective_display
)
1084 && XINT (current_buffer
->selective_display
) > 0
1085 ? (beg_unchanged
>= tlbufpos
1088 && end_unchanged
>= tlendpos
1089 && Z
- GPT
>= tlendpos
)))
1091 int tlbufpos_byte
= CHAR_TO_BYTE (tlbufpos
);
1092 if (tlbufpos
> BEGV
&& FETCH_BYTE (tlbufpos_byte
- 1) != '\n'
1094 || FETCH_BYTE (tlbufpos_byte
) == '\n'))
1095 /* Former continuation line has disappeared by becoming empty */
1097 else if (XFASTINT (w
->last_modified
) < MODIFF
1098 || XFASTINT (w
->last_overlay_modified
) < OVERLAY_MODIFF
1099 || MINI_WINDOW_P (w
))
1101 /* We have to handle the case of continuation around a
1102 wide-column character (See the comment in indent.c around
1105 For instance, in the following case:
1107 -------- Insert --------
1108 K_A_N_\\ `a' K_A_N_a\ `X_' are wide-column chars.
1109 J_I_ ==> J_I_ `^^' are cursors.
1113 As we have to redraw the line above, we should goto cancel. */
1115 struct position val
;
1117 int opoint
= PT
, opoint_byte
= PT_BYTE
;
1119 scan_newline (tlbufpos
, tlbufpos_byte
, BEGV
, BEGV_BYTE
, -1, 1);
1121 val
= *compute_motion (PT
, 0,
1122 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1125 1 << (BITS_PER_SHORT
- 1),
1126 1 << (BITS_PER_SHORT
- 1),
1127 window_internal_width (w
) - 1,
1128 XINT (w
->hscroll
), 0, w
);
1129 SET_PT_BOTH (opoint
, opoint_byte
);
1130 if (val
.hpos
!= this_line_start_hpos
)
1134 overlay_arrow_seen
= 0;
1135 zv_strings_seen
= 0;
1136 display_text_line (w
, tlbufpos
, tlbufpos_byte
,
1137 this_line_vpos
, this_line_start_hpos
,
1138 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
), 0);
1139 /* If line contains point, is not continued,
1140 and ends at same distance from eob as before, we win */
1141 if (cursor_vpos
>= 0 && this_line_bufpos
1142 && this_line_endpos
== tlendpos
)
1144 /* If this is not the window's last line,
1145 we must adjust the charstarts of the lines below. */
1146 if (this_line_vpos
+ 1
1147 < XFASTINT (w
->top
) + window_internal_height (w
))
1149 int left
= WINDOW_LEFT_MARGIN (w
);
1150 int *charstart_next_line
1151 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
1154 if (Z
- tlendpos
== ZV
)
1155 /* This line ends at end of (accessible part of) buffer.
1156 There is no newline to count. */
1157 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
1159 /* This line ends in a newline.
1160 Must take account of the newline and the rest of the
1161 text that follows. */
1162 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
1164 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
1167 if (!WINDOW_FULL_WIDTH_P (w
))
1168 preserve_other_columns (w
);
1174 else if (PT
== XFASTINT (w
->last_point
)
1175 /* Make sure the cursor was last displayed
1176 in this window. Otherwise we have to reposition it. */
1177 && XINT (w
->top
) <= FRAME_CURSOR_Y (selected_frame
)
1178 && (XINT (w
->top
) + XINT (w
->height
)
1179 > FRAME_CURSOR_Y (selected_frame
)))
1183 do_pending_window_change ();
1188 /* If highlighting the region, or if the cursor is in the echo area,
1189 then we can't just move the cursor. */
1190 else if (! (!NILP (Vtransient_mark_mode
)
1191 && !NILP (current_buffer
->mark_active
))
1192 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1193 || highlight_nonselected_windows
)
1194 && NILP (w
->region_showing
)
1195 && !cursor_in_echo_area
)
1197 pos
= *compute_motion (tlbufpos
, 0,
1198 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1200 PT
, 2, - (1 << (BITS_PER_SHORT
- 1)),
1201 window_internal_width (w
) - 1,
1203 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
),
1207 int width
= window_internal_width (w
) - 1;
1208 FRAME_CURSOR_X (selected_frame
)
1209 = WINDOW_LEFT_MARGIN (w
) + minmax (0, pos
.hpos
, width
);
1210 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
1217 /* Text changed drastically or point moved off of line */
1218 cancel_line (this_line_vpos
, selected_frame
);
1221 this_line_bufpos
= 0;
1222 all_windows
|= buffer_shared
> 1;
1224 clear_face_cache_count
++;
1228 Lisp_Object tail
, frame
;
1231 /* Clear the face cache, only when we do a full redisplay
1232 and not too often either. */
1233 if (clear_face_cache_count
> 1000)
1235 clear_face_cache ();
1236 clear_face_cache_count
= 0;
1240 /* Recompute # windows showing selected buffer.
1241 This will be incremented each time such a window is displayed. */
1244 FOR_EACH_FRAME (tail
, frame
)
1246 FRAME_PTR f
= XFRAME (frame
);
1247 if (FRAME_WINDOW_P (f
) || f
== selected_frame
)
1250 /* Mark all the scroll bars to be removed; we'll redeem the ones
1251 we want when we redisplay their windows. */
1252 if (condemn_scroll_bars_hook
)
1253 (*condemn_scroll_bars_hook
) (f
);
1255 if (FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1256 redisplay_windows (FRAME_ROOT_WINDOW (f
), preserve_echo_area
);
1258 /* Any scroll bars which redisplay_windows should have nuked
1259 should now go away. */
1260 if (judge_scroll_bars_hook
)
1261 (*judge_scroll_bars_hook
) (f
);
1265 else if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1267 redisplay_window (selected_window
, 1, preserve_echo_area
);
1268 if (!WINDOW_FULL_WIDTH_P (w
))
1269 preserve_other_columns (w
);
1273 /* Prevent various kinds of signals during display update.
1274 stdio is not robust about handling signals,
1275 which can cause an apparent I/O error. */
1276 if (interrupt_input
)
1286 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1290 if (!FRAMEP (XCONS (tail
)->car
))
1293 f
= XFRAME (XCONS (tail
)->car
);
1295 if ((FRAME_WINDOW_P (f
) || f
== selected_frame
)
1296 && FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1298 pause
|= update_frame (f
, 0, 0);
1301 mark_window_display_accurate (f
->root_window
, 1);
1302 if (frame_up_to_date_hook
!= 0)
1303 (*frame_up_to_date_hook
) (f
);
1310 if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1311 pause
= update_frame (selected_frame
, 0, 0);
1315 /* We may have called echo_area_display at the top of this
1316 function. If the echo area is on another frame, that may
1317 have put text on a frame other than the selected one, so the
1318 above call to update_frame would not have caught it. Catch
1321 Lisp_Object mini_window
;
1322 FRAME_PTR mini_frame
;
1324 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
1325 mini_frame
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
1327 if (mini_frame
!= selected_frame
&& FRAME_WINDOW_P (mini_frame
))
1328 pause
|= update_frame (mini_frame
, 0, 0);
1332 /* If frame does not match, prevent doing single-line-update next time.
1333 Also, don't forget to check every line to update the arrow. */
1336 this_line_bufpos
= 0;
1337 if (!NILP (last_arrow_position
))
1339 last_arrow_position
= Qt
;
1340 last_arrow_string
= Qt
;
1342 /* If we pause after scrolling, some lines in current_frame
1343 may be null, so preserve_other_columns won't be able to
1344 preserve all the vertical-bar separators. So, avoid using it
1346 if (!WINDOW_FULL_WIDTH_P (w
))
1347 update_mode_lines
= 1;
1350 /* Now text on frame agrees with windows, so
1351 put info into the windows for partial redisplay to follow */
1355 register struct buffer
*b
= XBUFFER (w
->buffer
);
1357 blank_end_of_window
= 0;
1358 unchanged_modified
= BUF_MODIFF (b
);
1359 overlay_unchanged_modified
= BUF_OVERLAY_MODIFF (b
);
1360 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
1361 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
1363 XSETFASTINT (w
->last_point
, BUF_PT (b
));
1364 XSETFASTINT (w
->last_point_x
, FRAME_CURSOR_X (selected_frame
));
1365 XSETFASTINT (w
->last_point_y
, FRAME_CURSOR_Y (selected_frame
));
1368 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
1371 b
->clip_changed
= 0;
1372 w
->update_mode_line
= Qnil
;
1373 XSETFASTINT (w
->last_modified
, BUF_MODIFF (b
));
1374 XSETFASTINT (w
->last_overlay_modified
, BUF_OVERLAY_MODIFF (b
));
1376 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1379 /* Record if we are showing a region, so can make sure to
1380 update it fully at next redisplay. */
1381 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1382 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1383 || highlight_nonselected_windows
)
1384 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1385 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1388 w
->window_end_valid
= w
->buffer
;
1389 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1390 last_arrow_string
= Voverlay_arrow_string
;
1391 if (do_verify_charstarts
)
1392 verify_charstarts (w
);
1393 if (frame_up_to_date_hook
!= 0)
1394 (*frame_up_to_date_hook
) (selected_frame
);
1396 update_mode_lines
= 0;
1397 windows_or_buffers_changed
= 0;
1400 /* Start SIGIO interrupts coming again.
1401 Having them off during the code above
1402 makes it less likely one will discard output,
1403 but not impossible, since there might be stuff
1404 in the system buffer here.
1405 But it is much hairier to try to do anything about that. */
1407 if (interrupt_input
)
1411 /* If something has become visible now which was not before,
1412 redisplay again, so that we get them. */
1415 Lisp_Object tail
, frame
;
1418 FOR_EACH_FRAME (tail
, frame
)
1420 int this_is_visible
= 0;
1422 if (XFRAME (frame
)->visible
)
1423 this_is_visible
= 1;
1424 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1425 if (XFRAME (frame
)->visible
)
1426 this_is_visible
= 1;
1428 if (this_is_visible
)
1432 if (new_count
!= number_of_visible_frames
)
1433 windows_or_buffers_changed
++;
1436 /* Change frame size now if a change is pending. */
1437 do_pending_window_change ();
1439 /* If we just did a pending size change, or have additional
1440 visible frames, redisplay again. */
1441 if (windows_or_buffers_changed
&& !pause
)
1445 /* Redisplay, but leave alone any recent echo area message
1446 unless another message has been requested in its place.
1448 This is useful in situations where you need to redisplay but no
1449 user action has occurred, making it inappropriate for the message
1450 area to be cleared. See tracking_off and
1451 wait_reading_process_input for examples of these situations. */
1454 redisplay_preserve_echo_area ()
1456 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
1458 echo_area_glyphs
= previous_echo_glyphs
;
1459 redisplay_internal (1);
1460 echo_area_glyphs
= 0;
1463 redisplay_internal (1);
1467 mark_window_display_accurate (window
, flag
)
1471 register struct window
*w
;
1473 for (;!NILP (window
); window
= w
->next
)
1475 if (!WINDOWP (window
)) abort ();
1476 w
= XWINDOW (window
);
1478 if (!NILP (w
->buffer
))
1480 XSETFASTINT (w
->last_modified
,
1481 !flag
? 0 : BUF_MODIFF (XBUFFER (w
->buffer
)));
1482 XSETFASTINT (w
->last_overlay_modified
,
1483 !flag
? 0 : BUF_OVERLAY_MODIFF (XBUFFER (w
->buffer
)));
1485 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1488 /* Record if we are showing a region, so can make sure to
1489 update it fully at next redisplay. */
1490 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1491 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1492 || highlight_nonselected_windows
)
1493 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1494 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1498 w
->window_end_valid
= w
->buffer
;
1499 w
->update_mode_line
= Qnil
;
1500 if (!NILP (w
->buffer
) && flag
)
1501 XBUFFER (w
->buffer
)->clip_changed
= 0;
1503 if (!NILP (w
->vchild
))
1504 mark_window_display_accurate (w
->vchild
, flag
);
1505 if (!NILP (w
->hchild
))
1506 mark_window_display_accurate (w
->hchild
, flag
);
1511 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1512 last_arrow_string
= Voverlay_arrow_string
;
1516 /* t is unequal to any useful value of Voverlay_arrow_... */
1517 last_arrow_position
= Qt
;
1518 last_arrow_string
= Qt
;
1522 /* Update the menu bar item list for frame F.
1523 This has to be done before we start to fill in any display lines,
1524 because it can call eval.
1526 If SAVE_MATCH_DATA is 1, we must save and restore it here. */
1529 update_menu_bar (f
, save_match_data
)
1531 int save_match_data
;
1533 struct buffer
*old
= current_buffer
;
1535 register struct window
*w
;
1537 window
= FRAME_SELECTED_WINDOW (f
);
1538 w
= XWINDOW (window
);
1540 if (update_mode_lines
)
1541 w
->update_mode_line
= Qt
;
1543 if (FRAME_WINDOW_P (f
)
1545 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1546 FRAME_EXTERNAL_MENU_BAR (f
)
1548 FRAME_MENU_BAR_LINES (f
) > 0
1550 : FRAME_MENU_BAR_LINES (f
) > 0)
1552 /* If the user has switched buffers or windows, we need to
1553 recompute to reflect the new bindings. But we'll
1554 recompute when update_mode_lines is set too; that means
1555 that people can use force-mode-line-update to request
1556 that the menu bar be recomputed. The adverse effect on
1557 the rest of the redisplay algorithm is about the same as
1558 windows_or_buffers_changed anyway. */
1559 if (windows_or_buffers_changed
1560 || !NILP (w
->update_mode_line
)
1561 || ((BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1562 < BUF_MODIFF (XBUFFER (w
->buffer
)))
1563 != !NILP (w
->last_had_star
))
1564 || ((!NILP (Vtransient_mark_mode
)
1565 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1566 != !NILP (w
->region_showing
)))
1568 struct buffer
*prev
= current_buffer
;
1569 int count
= specpdl_ptr
- specpdl
;
1571 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1572 if (save_match_data
)
1573 record_unwind_protect (Fstore_match_data
, Fmatch_data (Qnil
, Qnil
));
1574 if (NILP (Voverriding_local_map_menu_flag
))
1576 specbind (Qoverriding_terminal_local_map
, Qnil
);
1577 specbind (Qoverriding_local_map
, Qnil
);
1580 /* Run the Lucid hook. */
1581 call1 (Vrun_hooks
, Qactivate_menubar_hook
);
1582 /* If it has changed current-menubar from previous value,
1583 really recompute the menubar from the value. */
1584 if (! NILP (Vlucid_menu_bar_dirty_flag
))
1585 call0 (Qrecompute_lucid_menubar
);
1586 safe_run_hooks (Qmenu_bar_update_hook
);
1587 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
1588 /* Redisplay the menu bar in case we changed it. */
1589 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1590 if (FRAME_WINDOW_P (f
))
1591 set_frame_menubar (f
, 0, 0);
1593 /* On a terminal screen, the menu bar is an ordinary screen
1594 line, and this makes it get updated. */
1595 w
->update_mode_line
= Qt
;
1596 #else /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1597 /* In the non-toolkit version, the menu bar is an ordinary screen
1598 line, and this makes it get updated. */
1599 w
->update_mode_line
= Qt
;
1600 #endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1602 unbind_to (count
, Qnil
);
1603 set_buffer_internal_1 (prev
);
1610 /* Redisplay WINDOW and its subwindows and siblings. */
1613 redisplay_windows (window
, preserve_echo_area
)
1615 int preserve_echo_area
;
1617 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1618 redisplay_window (window
, 0, preserve_echo_area
);
1621 /* Return value in display table DP (Lisp_Char_Table *) for character
1622 C. Since a display table doesn't have any parent, we don't have to
1623 follow parent. Do not call this function directly but use the
1624 macro DISP_CHAR_VECTOR. */
1626 disp_char_vector (dp
, c
)
1627 struct Lisp_Char_Table
*dp
;
1633 if (SINGLE_BYTE_CHAR_P (c
)) return (dp
->contents
[c
]);
1635 SPLIT_NON_ASCII_CHAR (c
, code
[0], code
[1], code
[2]);
1636 if (code
[0] != CHARSET_COMPOSITION
)
1638 if (code
[1] < 32) code
[1] = -1;
1639 else if (code
[2] < 32) code
[2] = -1;
1641 /* Here, the possible range of CODE[0] (== charset ID) is
1642 128..MAX_CHARSET. Since the top level char table contains data
1643 for multibyte characters after 256th element, we must increment
1644 CODE[0] by 128 to get a correct index. */
1646 code
[3] = -1; /* anchor */
1648 for (i
= 0; code
[i
] >= 0; i
++, dp
= XCHAR_TABLE (val
))
1650 val
= dp
->contents
[code
[i
]];
1651 if (!SUB_CHAR_TABLE_P (val
))
1652 return (NILP (val
) ? dp
->defalt
: val
);
1654 /* Here, VAL is a sub char table. We return the default value of it. */
1655 return (dp
->defalt
);
1658 /* Redisplay window WINDOW and its subwindows. */
1661 redisplay_window (window
, just_this_one
, preserve_echo_area
)
1663 int just_this_one
, preserve_echo_area
;
1665 register struct window
*w
= XWINDOW (window
);
1666 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1669 int lpoint_byte
= PT_BYTE
;
1670 struct buffer
*old
= current_buffer
;
1671 register int width
= window_internal_width (w
) - 1;
1672 register int startp
, startp_byte
;
1673 register int hscroll
= XINT (w
->hscroll
);
1674 struct position pos
;
1676 int opoint_byte
= PT_BYTE
;
1678 int update_mode_line
;
1679 struct Lisp_Char_Table
*dp
= window_display_table (w
);
1681 if (Z
== Z_BYTE
&& lpoint
!= lpoint_byte
)
1683 if (lpoint_byte
< lpoint
)
1686 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1688 /* If this is a combination window, do its children; that's all. */
1690 if (!NILP (w
->vchild
))
1692 redisplay_windows (w
->vchild
, preserve_echo_area
);
1695 if (!NILP (w
->hchild
))
1697 redisplay_windows (w
->hchild
, preserve_echo_area
);
1700 if (NILP (w
->buffer
))
1703 height
= window_internal_height (w
);
1704 update_mode_line
= (!NILP (w
->update_mode_line
) || update_mode_lines
);
1705 if (XBUFFER (w
->buffer
)->clip_changed
)
1706 update_mode_line
= 1;
1708 if (MINI_WINDOW_P (w
))
1710 if (w
== XWINDOW (echo_area_window
) && echo_area_glyphs
)
1711 /* We've already displayed the echo area glyphs in this window. */
1712 goto finish_scroll_bars
;
1713 else if (w
!= XWINDOW (minibuf_window
))
1715 /* This is a minibuffer, but it's not the currently active one,
1717 int vpos
= XFASTINT (w
->top
);
1720 for (i
= 0; i
< height
; i
++)
1722 get_display_line (f
, vpos
+ i
, 0);
1723 display_string (w
, vpos
+ i
, "", 0,
1724 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
1728 goto finish_scroll_bars
;
1732 /* Otherwise set up data on this window; select its buffer and point value */
1734 if (update_mode_line
)
1735 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1737 set_buffer_temp (XBUFFER (w
->buffer
));
1740 opoint_byte
= PT_BYTE
;
1742 if (Z
== Z_BYTE
&& opoint
!= opoint_byte
)
1744 if (opoint_byte
< opoint
)
1747 /* If %c is in mode line, update it if needed. */
1748 if (!NILP (w
->column_number_displayed
)
1749 /* This alternative quickly identifies a common case
1750 where no change is needed. */
1751 && !(PT
== XFASTINT (w
->last_point
)
1752 && XFASTINT (w
->last_modified
) >= MODIFF
1753 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1754 && XFASTINT (w
->column_number_displayed
) != current_column ())
1755 update_mode_line
= 1;
1757 /* Count number of windows showing the selected buffer.
1758 An indirect buffer counts as its base buffer. */
1762 struct buffer
*current_base
, *window_base
;
1763 current_base
= current_buffer
;
1764 window_base
= XBUFFER (XWINDOW (selected_window
)->buffer
);
1765 if (current_base
->base_buffer
)
1766 current_base
= current_base
->base_buffer
;
1767 if (window_base
->base_buffer
)
1768 window_base
= window_base
->base_buffer
;
1769 if (current_base
== window_base
)
1773 /* POINT refers normally to the selected window.
1774 For any other window, set up appropriate value. */
1776 if (!EQ (window
, selected_window
))
1778 int new_pt
= XMARKER (w
->pointm
)->charpos
;
1779 int new_pt_byte
= marker_byte_position (w
->pointm
);
1783 new_pt_byte
= BEGV_BYTE
;
1784 set_marker_both (w
->pointm
, Qnil
, BEGV
, BEGV_BYTE
);
1786 else if (new_pt
> (ZV
- 1))
1789 new_pt_byte
= ZV_BYTE
;
1790 set_marker_both (w
->pointm
, Qnil
, ZV
, ZV_BYTE
);
1792 /* We don't use SET_PT so that the point-motion hooks don't run. */
1793 TEMP_SET_PT_BOTH (new_pt
, new_pt_byte
);
1796 /* If any of the character widths specified in the display table
1797 have changed, invalidate the width run cache. It's true that this
1798 may be a bit late to catch such changes, but the rest of
1799 redisplay goes (non-fatally) haywire when the display table is
1800 changed, so why should we worry about doing any better? */
1801 if (current_buffer
->width_run_cache
)
1803 struct Lisp_Char_Table
*disptab
= buffer_display_table ();
1805 if (! disptab_matches_widthtab (disptab
,
1806 XVECTOR (current_buffer
->width_table
)))
1808 invalidate_region_cache (current_buffer
,
1809 current_buffer
->width_run_cache
,
1811 recompute_width_table (current_buffer
, disptab
);
1815 /* If window-start is screwed up, choose a new one. */
1816 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1819 startp
= marker_position (w
->start
);
1820 startp_byte
= marker_byte_position (w
->start
);
1822 /* If someone specified a new starting point but did not insist,
1823 check whether it can be used. */
1824 if (!NILP (w
->optional_new_start
))
1826 w
->optional_new_start
= Qnil
;
1827 /* Check whether this start pos is usable given where point is. */
1829 pos
= *compute_motion (startp
, 0,
1830 (((EQ (window
, minibuf_window
)
1832 ? minibuf_prompt_width
: 0)
1833 + (hscroll
? 1 - hscroll
: 0)),
1836 /* BUG FIX: See the comment of
1837 Fpos_visible_in_window_p (window.c). */
1838 - (1 << (BITS_PER_SHORT
- 1)),
1840 pos_tab_offset (w
, startp
, startp_byte
), w
);
1841 /* If PT does fit on the screen, we will use this start pos,
1842 so do so by setting force_start. */
1843 if (pos
.bufpos
== PT
)
1844 w
->force_start
= Qt
;
1847 /* Handle case where place to start displaying has been specified,
1848 unless the specified location is outside the accessible range. */
1849 if (!NILP (w
->force_start
))
1851 w
->force_start
= Qnil
;
1852 /* Forget any recorded base line for line number display. */
1853 w
->base_line_number
= Qnil
;
1854 /* Redisplay the mode line. Select the buffer properly for that.
1855 Also, run the hook window-scroll-functions
1856 because we have scrolled. */
1857 /* Note, we do this after clearing force_start because
1858 if there's an error, it is better to forget about force_start
1859 than to get into an infinite loop calling the hook functions
1860 and having them get more errors. */
1861 if (!update_mode_line
1862 || ! NILP (Vwindow_scroll_functions
))
1864 Lisp_Object temp
[3];
1866 set_buffer_temp (old
);
1867 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1868 update_mode_line
= 1;
1869 w
->update_mode_line
= Qt
;
1870 if (! NILP (Vwindow_scroll_functions
))
1872 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
1873 make_number (startp
));
1874 startp
= marker_position (w
->start
);
1877 XSETFASTINT (w
->last_modified
, 0);
1878 XSETFASTINT (w
->last_overlay_modified
, 0);
1879 if (startp
< BEGV
) startp
= BEGV
, startp_byte
= BEGV_BYTE
;
1880 if (startp
> ZV
) startp
= ZV
, startp
= ZV_BYTE
;
1881 try_window (window
, startp
);
1882 if (cursor_vpos
< 0)
1884 /* If point does not appear, move point so it does appear */
1885 pos
= *compute_motion (startp
, 0,
1886 (((EQ (window
, minibuf_window
)
1888 ? minibuf_prompt_width
: 0)
1889 + (hscroll
? 1 - hscroll
: 0)),
1892 - (1 << (BITS_PER_SHORT
- 1)),
1894 pos_tab_offset (w
, startp
, startp_byte
),
1896 TEMP_SET_PT_BOTH (pos
.bufpos
, pos
.bytepos
);
1897 if (w
!= XWINDOW (selected_window
))
1898 set_marker_both (w
->pointm
, Qnil
, PT
, PT_BYTE
);
1901 if (current_buffer
== old
)
1904 lpoint_byte
= PT_BYTE
;
1906 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
1907 + minmax (0, pos
.hpos
, width
));
1908 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1910 /* If we are highlighting the region,
1911 then we just changed the region, so redisplay to show it. */
1912 if (!NILP (Vtransient_mark_mode
)
1913 && !NILP (current_buffer
->mark_active
))
1915 cancel_my_columns (XWINDOW (window
));
1916 try_window (window
, startp
);
1922 /* Handle case where text has not changed, only point,
1923 and it has not moved off the frame. */
1925 /* This code is not used for minibuffer for the sake of
1926 the case of redisplaying to replace an echo area message;
1927 since in that case the minibuffer contents per se are usually unchanged.
1928 This code is of no real use in the minibuffer since
1929 the handling of this_line_bufpos, etc.,
1930 in redisplay handles the same cases. */
1932 if (XFASTINT (w
->last_modified
) >= MODIFF
1933 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
1934 && PT
>= startp
&& !current_buffer
->clip_changed
1935 && (just_this_one
|| WINDOW_FULL_WIDTH_P (w
))
1936 /* If force-mode-line-update was called, really redisplay;
1937 that's how redisplay is forced after e.g. changing
1938 buffer-invisibility-spec. */
1939 && NILP (w
->update_mode_line
)
1940 /* Can't use this case if highlighting a region. */
1941 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
1942 && NILP (w
->region_showing
)
1943 /* If end pos is out of date, scroll bar and percentage will be wrong */
1944 && INTEGERP (w
->window_end_vpos
)
1945 && XFASTINT (w
->window_end_vpos
) < XFASTINT (w
->height
)
1946 && !EQ (window
, minibuf_window
)
1947 && (!MARKERP (Voverlay_arrow_position
)
1948 || current_buffer
!= XMARKER (Voverlay_arrow_position
)->buffer
))
1950 /* All positions in this clause are relative to the window edge. */
1952 int this_scroll_margin
= scroll_margin
;
1953 int last_point_y
= XFASTINT (w
->last_point_y
) - XINT (w
->top
);
1954 int last_point_x
= (XFASTINT (w
->last_point_x
) - WINDOW_LEFT_MARGIN (w
));
1956 /* Find where PT is located now on the frame. */
1957 /* Check just_this_one as a way of verifying that the
1958 window edges have not changed. */
1959 if (PT
== XFASTINT (w
->last_point
) && just_this_one
)
1961 pos
.hpos
= last_point_x
;
1962 pos
.vpos
= last_point_y
;
1965 else if (PT
> XFASTINT (w
->last_point
)
1966 && XFASTINT (w
->last_point
) > startp
&& just_this_one
1967 /* We can't use this if point is in the left margin of a
1968 hscrolled window, because w->last_point_x has been
1969 clipped to the window edges. */
1970 && !(last_point_x
<= 0 && hscroll
))
1972 pos
= *compute_motion (XFASTINT (w
->last_point
),
1973 last_point_y
, last_point_x
, 0,
1975 /* BUG FIX: See the comment of
1976 Fpos_visible_in_window_p (window.c). */
1977 - (1 << (BITS_PER_SHORT
- 1)),
1979 pos_tab_offset (w
, startp
, startp_byte
),
1984 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0), 0,
1986 /* BUG FIX: See the comment of
1987 Fpos_visible_in_window_p (window.c). */
1988 - (1 << (BITS_PER_SHORT
- 1)),
1990 pos_tab_offset (w
, startp
, startp_byte
),
1994 /* Don't use a scroll margin that is negative or too large. */
1995 if (this_scroll_margin
< 0)
1996 this_scroll_margin
= 0;
1998 if (XINT (w
->height
) < 4 * scroll_margin
)
1999 this_scroll_margin
= XINT (w
->height
) / 4;
2001 /* If point fits on the screen, and not within the scroll margin,
2003 if (pos
.vpos
< height
- this_scroll_margin
2004 && (pos
.vpos
>= this_scroll_margin
|| startp
== BEGV
))
2006 /* Ok, point is still on frame */
2007 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2009 /* These variables are supposed to be origin 1 */
2010 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
2011 + minmax (0, pos
.hpos
, width
));
2012 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
2014 /* This doesn't do the trick, because if a window to the right of
2015 this one must be redisplayed, this does nothing because there
2016 is nothing in DesiredFrame yet, and then the other window is
2017 redisplayed, making likes that are empty in this window's columns.
2018 if (WINDOW_FULL_WIDTH_P (w))
2019 preserve_my_columns (w);
2021 if (current_buffer
->clip_changed
2022 && ! NILP (Vwindow_scroll_functions
))
2023 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2024 make_number (marker_position (w
->start
)));
2028 /* Don't bother trying redisplay with same start;
2029 we already know it will lose */
2031 /* If current starting point was originally the beginning of a line
2032 but no longer is, find a new starting point. */
2033 else if (!NILP (w
->start_at_line_beg
)
2035 || FETCH_BYTE (startp_byte
- 1) == '\n'))
2039 else if (just_this_one
&& !MINI_WINDOW_P (w
)
2041 && XFASTINT (w
->last_modified
)
2042 /* or else vmotion on first line won't work. */
2043 && ! NILP (w
->start_at_line_beg
)
2044 && ! EQ (w
->window_end_valid
, Qnil
)
2045 && do_id
&& !current_buffer
->clip_changed
2046 && !blank_end_of_window
2047 && WINDOW_FULL_WIDTH_P (w
)
2048 /* Can't use this case if highlighting a region. */
2049 && !(!NILP (Vtransient_mark_mode
)
2050 && !NILP (current_buffer
->mark_active
))
2051 /* Don't use try_window_id if newline
2052 doesn't display as the end of a line. */
2053 && !(dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, '\n')))
2054 && NILP (w
->region_showing
)
2055 && EQ (last_arrow_position
, COERCE_MARKER (Voverlay_arrow_position
))
2056 && EQ (last_arrow_string
, Voverlay_arrow_string
)
2057 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
2060 /* tem > 0 means success. tem == -1 means choose new start.
2061 tem == -2 means try again with same start,
2062 and nothing but whitespace follows the changed stuff.
2063 tem == 0 means try again with same start. */
2067 else if (startp
>= BEGV
&& startp
<= ZV
2069 /* Avoid starting at end of buffer. */
2070 #if 0 /* This change causes trouble for M-! finger & RET.
2071 It will have to be considered later. */
2072 || ! EQ (window
, selected_window
)
2073 /* Don't do the recentering if redisplay
2074 is not for no user action. */
2075 || preserve_echo_area
2078 || (XFASTINT (w
->last_modified
) >= MODIFF
2079 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)))
2081 /* Try to redisplay starting at same place as before */
2082 /* If point has not moved off frame, accept the results */
2083 try_window (window
, startp
);
2084 if (cursor_vpos
>= 0)
2086 if (!just_this_one
|| current_buffer
->clip_changed
2087 || beg_unchanged
< startp
)
2088 /* Forget any recorded base line for line number display. */
2089 w
->base_line_number
= Qnil
;
2091 if (current_buffer
->clip_changed
2092 && ! NILP (Vwindow_scroll_functions
))
2093 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2094 make_number (marker_position (w
->start
)));
2099 cancel_my_columns (w
);
2102 XSETFASTINT (w
->last_modified
, 0);
2103 XSETFASTINT (w
->last_overlay_modified
, 0);
2104 /* Redisplay the mode line. Select the buffer properly for that. */
2105 if (!update_mode_line
)
2107 set_buffer_temp (old
);
2108 set_buffer_internal_1 (XBUFFER (w
->buffer
));
2109 update_mode_line
= 1;
2110 w
->update_mode_line
= Qt
;
2113 /* Try to scroll by specified few lines */
2115 if (scroll_conservatively
&& !current_buffer
->clip_changed
2116 && startp
>= BEGV
&& startp
<= ZV
)
2118 int this_scroll_margin
= scroll_margin
;
2119 int scroll_margin_pos
;
2121 /* Don't use a scroll margin that is negative or too large. */
2122 if (this_scroll_margin
< 0)
2123 this_scroll_margin
= 0;
2125 if (XINT (w
->height
) < 4 * this_scroll_margin
)
2126 this_scroll_margin
= XINT (w
->height
) / 4;
2128 scroll_margin_pos
= Z
- XFASTINT (w
->window_end_pos
);
2129 if (this_scroll_margin
)
2131 pos
= *vmotion (scroll_margin_pos
, -this_scroll_margin
, w
);
2132 scroll_margin_pos
= pos
.bufpos
;
2134 if (PT
>= scroll_margin_pos
)
2136 struct position pos
;
2137 pos
= *compute_motion (scroll_margin_pos
, 0, 0, 0,
2138 PT
, XFASTINT (w
->height
), 0,
2139 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2140 pos_tab_offset (w
, startp
, startp_byte
),
2142 if (pos
.vpos
> scroll_conservatively
)
2145 pos
= *vmotion (startp
, pos
.vpos
+ 1, w
);
2147 if (! NILP (Vwindow_scroll_functions
))
2149 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2150 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2151 make_number (pos
.bufpos
));
2152 pos
.bufpos
= marker_position (w
->start
);
2154 try_window (window
, pos
.bufpos
);
2155 if (cursor_vpos
>= 0)
2157 if (!just_this_one
|| current_buffer
->clip_changed
2158 || beg_unchanged
< startp
)
2159 /* Forget any recorded base line for line number display. */
2160 w
->base_line_number
= Qnil
;
2164 cancel_my_columns (w
);
2167 scroll_margin_pos
= startp
;
2168 if (this_scroll_margin
)
2170 pos
= *vmotion (scroll_margin_pos
, this_scroll_margin
, w
);
2171 scroll_margin_pos
= pos
.bufpos
;
2173 if (PT
< scroll_margin_pos
)
2175 struct position pos
;
2176 pos
= *compute_motion (PT
, 0, 0, 0,
2177 scroll_margin_pos
, XFASTINT (w
->height
), 0,
2178 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2179 pos_tab_offset (w
, startp
, startp_byte
),
2181 if (pos
.vpos
> scroll_conservatively
)
2184 pos
= *vmotion (startp
, -pos
.vpos
, w
);
2186 if (! NILP (Vwindow_scroll_functions
))
2188 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2189 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2190 make_number (pos
.bufpos
));
2191 pos
.bufpos
= marker_position (w
->start
);
2193 try_window (window
, pos
.bufpos
);
2194 if (cursor_vpos
>= 0)
2196 if (!just_this_one
|| current_buffer
->clip_changed
2197 || beg_unchanged
< startp
)
2198 /* Forget any recorded base line for line number display. */
2199 w
->base_line_number
= Qnil
;
2203 cancel_my_columns (w
);
2208 if (scroll_step
&& !current_buffer
->clip_changed
2209 && startp
>= BEGV
&& startp
<= ZV
)
2213 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), scroll_step
, w
);
2214 if (pos
.vpos
>= height
)
2218 pos
= *vmotion (startp
, (PT
< startp
? - scroll_step
: scroll_step
), w
);
2220 if (PT
>= pos
.bufpos
)
2222 if (! NILP (Vwindow_scroll_functions
))
2224 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2225 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2226 make_number (pos
.bufpos
));
2227 pos
.bufpos
= marker_position (w
->start
);
2229 try_window (window
, pos
.bufpos
);
2230 if (cursor_vpos
>= 0)
2232 if (!just_this_one
|| current_buffer
->clip_changed
2233 || beg_unchanged
< startp
)
2234 /* Forget any recorded base line for line number display. */
2235 w
->base_line_number
= Qnil
;
2239 cancel_my_columns (w
);
2244 /* Finally, just choose place to start which centers point */
2247 /* Forget any previously recorded base line for line number display. */
2248 w
->base_line_number
= Qnil
;
2250 pos
= *vmotion (PT
, - (height
/ 2), w
);
2252 /* The minibuffer is often just one line. Ordinary scrolling
2253 gives little overlap and looks bad. So show 20 chars before point. */
2255 && (pos
.bufpos
>= PT
- minibuffer_scroll_overlap
2256 /* If we scrolled less than 1/2 line forward, we will
2257 get too much overlap, so change to the usual amount. */
2258 || pos
.bufpos
< startp
+ width
/ 2)
2259 && PT
> BEGV
+ minibuffer_scroll_overlap
2260 /* If we scrolled to an actual line boundary,
2261 that's different; don't ignore line boundaries. */
2262 && FETCH_BYTE (pos
.bufpos
- 1) != '\n')
2263 pos
.bufpos
= PT
- minibuffer_scroll_overlap
;
2265 /* Set startp here explicitly in case that helps avoid an infinite loop
2266 in case the window-scroll-functions functions get errors. */
2267 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2268 if (! NILP (Vwindow_scroll_functions
))
2270 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2271 make_number (pos
.bufpos
));
2272 pos
.bufpos
= marker_position (w
->start
);
2274 try_window (window
, pos
.bufpos
);
2276 startp
= marker_position (w
->start
);
2277 startp_byte
= marker_byte_position (w
->start
);
2278 w
->start_at_line_beg
2279 = (startp
== BEGV
|| FETCH_BYTE (startp_byte
- 1) == '\n') ? Qt
: Qnil
;
2282 if ((update_mode_line
2283 /* If window not full width, must redo its mode line
2284 if the window to its side is being redone */
2285 || (!just_this_one
&& !WINDOW_FULL_WIDTH_P (w
))
2286 || INTEGERP (w
->base_line_pos
)
2287 || (!NILP (w
->column_number_displayed
)
2288 && XFASTINT (w
->column_number_displayed
) != current_column ()))
2289 && height
!= XFASTINT (w
->height
))
2290 display_mode_line (w
);
2291 if (! line_number_displayed
2292 && ! BUFFERP (w
->base_line_pos
))
2294 w
->base_line_pos
= Qnil
;
2295 w
->base_line_number
= Qnil
;
2298 /* When we reach a frame's selected window, redo the frame's menu bar. */
2299 if (update_mode_line
2300 && (FRAME_WINDOW_P (f
)
2302 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2303 FRAME_EXTERNAL_MENU_BAR (f
)
2305 FRAME_MENU_BAR_LINES (f
) > 0
2307 : FRAME_MENU_BAR_LINES (f
) > 0)
2308 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
2309 display_menu_bar (w
);
2312 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2314 int start
, end
, whole
;
2316 /* Calculate the start and end positions for the current window.
2317 At some point, it would be nice to choose between scrollbars
2318 which reflect the whole buffer size, with special markers
2319 indicating narrowing, and scrollbars which reflect only the
2322 Note that minibuffers sometimes aren't displaying any text. */
2323 if (! MINI_WINDOW_P (w
)
2324 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
2327 start
= marker_position (w
->start
) - BEGV
;
2328 /* I don't think this is guaranteed to be right. For the
2329 moment, we'll pretend it is. */
2330 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
2332 if (end
< start
) end
= start
;
2333 if (whole
< (end
- start
)) whole
= end
- start
;
2336 start
= end
= whole
= 0;
2338 /* Indicate what this scroll bar ought to be displaying now. */
2339 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
2341 /* Note that we actually used the scroll bar attached to this window,
2342 so it shouldn't be deleted at the end of redisplay. */
2343 (*redeem_scroll_bar_hook
) (w
);
2346 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
2347 if (update_mode_line
)
2348 set_buffer_internal_1 (old
);
2350 set_buffer_temp (old
);
2351 TEMP_SET_PT_BOTH (lpoint
, lpoint_byte
);
2354 /* Do full redisplay on one window, starting at position `pos'. */
2357 try_window (window
, pos
)
2361 register struct window
*w
= XWINDOW (window
);
2362 register int height
= window_internal_height (w
);
2363 register int vpos
= XFASTINT (w
->top
);
2364 register int last_text_vpos
= vpos
;
2365 FRAME_PTR f
= XFRAME (w
->frame
);
2366 int width
= window_internal_width (w
) - 1;
2367 struct position val
;
2369 /* POS should never be out of range! */
2370 if (pos
< XBUFFER (w
->buffer
)->begv
2371 || pos
> XBUFFER (w
->buffer
)->zv
)
2374 if (XMARKER (w
->start
)->charpos
!= pos
)
2375 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2378 overlay_arrow_seen
= 0;
2379 zv_strings_seen
= 0;
2380 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2381 val
.ovstring_chars_done
= 0;
2382 val
.bytepos
= marker_byte_position (w
->start
);
2383 val
.tab_offset
= pos_tab_offset (w
, pos
, val
.bytepos
);
2385 while (--height
>= 0)
2387 val
= *display_text_line (w
, pos
, val
.bytepos
, vpos
,
2388 val
.hpos
, val
.tab_offset
,
2389 val
.ovstring_chars_done
);
2390 /* The following code is omitted because we maintain tab_offset
2393 tab_offset
+= width
;
2394 if (val
.vpos
) tab_offset
= 0;
2397 if (pos
!= val
.bufpos
)
2400 #ifdef USE_TEXT_PROPERTIES
2401 Lisp_Object invis_prop
;
2402 invis_prop
= Fget_char_property (val
.bufpos
-1, Qinvisible
, window
);
2403 invis
= TEXT_PROP_MEANS_INVISIBLE (invis_prop
);
2407 /* Next line, unless prev line ended in end of buffer with no cr */
2409 && (FETCH_BYTE (val
.bytepos
- 1) != '\n' || invis
));
2414 /* If last line is continued in middle of character,
2415 include the split character in the text considered on the frame */
2416 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2419 /* If bottom just moved off end of frame, change mode line percentage. */
2420 if (XFASTINT (w
->window_end_pos
) == 0
2422 w
->update_mode_line
= Qt
;
2424 /* Say where last char on frame will be, once redisplay is finished. */
2425 XSETFASTINT (w
->window_end_pos
, Z
- pos
);
2426 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
- XFASTINT (w
->top
));
2427 /* But that is not valid info until redisplay finishes. */
2428 w
->window_end_valid
= Qnil
;
2431 /* Try to redisplay when buffer is modified locally,
2432 computing insert/delete line to preserve text outside
2433 the bounds of the changes.
2434 Return 1 if successful, 0 if if cannot tell what to do,
2435 or -1 to tell caller to find a new window start,
2436 or -2 to tell caller to do normal redisplay with same window start. */
2439 try_window_id (window
)
2443 int opoint
, opoint_byte
;
2444 register struct window
*w
= XWINDOW (window
);
2445 register int height
= window_internal_height (w
);
2446 FRAME_PTR f
= XFRAME (w
->frame
);
2447 int top
= XFASTINT (w
->top
);
2448 int start
= marker_position (w
->start
);
2449 int width
= window_internal_width (w
) - 1;
2450 int hscroll
= XINT (w
->hscroll
);
2451 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
2454 register int i
, tem
;
2455 int last_text_vpos
= 0;
2457 int selective
= (INTEGERP (current_buffer
->selective_display
)
2458 ? XINT (current_buffer
->selective_display
)
2459 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
2461 struct position val
, bp
, ep
, xp
, pp
;
2462 int scroll_amount
= 0;
2466 int start_byte
= marker_byte_position (w
->start
);
2468 if (GPT
- BEG
< beg_unchanged
)
2469 beg_unchanged
= GPT
- BEG
;
2470 if (Z
- GPT
< end_unchanged
)
2471 end_unchanged
= Z
- GPT
;
2473 if (beg_unchanged
+ BEG
< start
)
2474 return 0; /* Give up if changes go above top of window */
2476 /* Find position before which nothing is changed. */
2477 bp
= *compute_motion (start
, 0, lmargin
, 0,
2478 min (ZV
, beg_unchanged
+ BEG
), height
,
2479 /* BUG FIX: See the comment of
2480 Fpos_visible_in_window_p (window.c). */
2481 - (1 << (BITS_PER_SHORT
- 1)),
2483 pos_tab_offset (w
, start
, start_byte
),
2485 if (bp
.vpos
>= height
)
2489 /* All changes are beyond the window end, and point is on the screen.
2490 We don't need to change the text at all.
2491 But we need to update window_end_pos to account for
2492 any change in buffer size. */
2493 bp
= *compute_motion (start
, 0, lmargin
, 0,
2495 /* BUG FIX: See the comment of
2496 Fpos_visible_in_window_p() (window.c). */
2497 - (1 << (BITS_PER_SHORT
- 1)),
2499 pos_tab_offset (w
, start
, start_byte
), w
);
2500 XSETFASTINT (w
->window_end_vpos
, height
);
2501 XSETFASTINT (w
->window_end_pos
, Z
- bp
.bufpos
);
2509 /* Find beginning of that frame line. Must display from there. */
2510 bp
= *vmotion (bp
.bufpos
, 0, w
);
2513 pos_byte
= bp
.bytepos
;
2519 /* If about to start displaying at the beginning of a continuation line,
2520 really start with previous frame line, in case it was not
2521 continued when last redisplayed */
2522 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
2524 /* Likewise if we have to worry about selective display. */
2525 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
2527 bp
= *vmotion (bp
.bufpos
, -1, w
);
2530 pos_byte
= bp
.bytepos
;
2532 val
.tab_offset
= bp
.tab_offset
; /* Update tab offset. */
2534 if (bp
.contin
&& bp
.hpos
!= lmargin
)
2536 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
2537 val
.tab_offset
= bp
.tab_offset
+ bp
.prevhpos
- width
;
2545 /* Find first visible newline after which no more is changed. */
2546 opoint
= PT
, opoint_byte
= PT_BYTE
;
2547 SET_PT (Z
- max (end_unchanged
, Z
- ZV
));
2548 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2550 while (PT
< ZV
- 1 && indented_beyond_p (PT
, PT_BYTE
, selective
))
2551 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2553 SET_PT_BOTH (opoint
, opoint_byte
);
2555 /* Compute the cursor position after that newline. */
2556 ep
= *compute_motion (pos
, vpos
, val
.hpos
, did_motion
, tem
,
2557 height
, - (1 << (BITS_PER_SHORT
- 1)),
2559 /* We have tab offset in VAL, use it. */
2562 /* If changes reach past the text available on the frame,
2563 just display rest of frame. */
2564 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
2567 stop_vpos
= ep
.vpos
;
2569 /* If no newline before ep, the line ep is on includes some changes
2570 that must be displayed. Make sure we don't stop before it. */
2571 /* Also, if changes reach all the way until ep.bufpos,
2572 it is possible that something was deleted after the
2573 newline before it, so the following line must be redrawn. */
2574 if (stop_vpos
== ep
.vpos
2575 && (ep
.bufpos
== BEGV
2576 || FETCH_BYTE (ep
.bufpos
- 1) != '\n'
2577 || ep
.bufpos
== Z
- end_unchanged
))
2578 stop_vpos
= ep
.vpos
+ 1;
2581 overlay_arrow_seen
= 0;
2582 zv_strings_seen
= 0;
2584 /* If changes do not reach to bottom of window,
2585 figure out how much to scroll the rest of the window */
2586 if (stop_vpos
< height
)
2588 /* Now determine how far up or down the rest of the window has moved */
2589 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2590 Z
- XFASTINT (w
->window_end_pos
),
2591 /* Don't care for VPOS... */
2592 1 << (BITS_PER_SHORT
- 1),
2594 1 << (BITS_PER_SHORT
- 1),
2595 width
, hscroll
, ep
.tab_offset
, w
);
2596 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
2598 /* Is everything on frame below the changes whitespace?
2599 If so, no scrolling is really necessary. */
2600 for (i
= ep
.bufpos
; i
< xp
.bufpos
; i
++)
2602 tem
= FETCH_BYTE (i
);
2603 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
2609 XSETFASTINT (w
->window_end_vpos
,
2610 XFASTINT (w
->window_end_vpos
) + scroll_amount
);
2612 /* Before doing any scrolling, verify that point will be on frame. */
2613 if (PT
> ep
.bufpos
&& !(PT
<= xp
.bufpos
&& xp
.vpos
< height
))
2615 if (PT
<= xp
.bufpos
)
2617 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2618 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2620 /* We have tab offset in EP, use it. */
2625 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
, 1,
2626 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2628 /* We have tab offset in XP, use it. */
2631 if (pp
.bufpos
< PT
|| pp
.vpos
== height
)
2633 cursor_vpos
= pp
.vpos
+ top
;
2634 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, pp
.hpos
, width
);
2637 if (stop_vpos
- scroll_amount
>= height
2638 || ep
.bufpos
== xp
.bufpos
)
2640 if (scroll_amount
< 0)
2641 stop_vpos
-= scroll_amount
;
2643 /* In this path, we have altered window_end_vpos
2644 and not left it negative.
2645 We must make sure that, in case display is preempted
2646 before the frame changes to reflect what we do here,
2647 further updates will not come to try_window_id
2648 and assume the frame and window_end_vpos match. */
2649 blank_end_of_window
= 1;
2651 else if (!scroll_amount
)
2653 /* Even if we don't need to scroll, we must adjust the
2654 charstarts of subsequent lines (that we won't redisplay)
2655 according to the amount of text inserted or deleted. */
2656 int oldpos
= FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2657 int adjust
= ep
.bufpos
- oldpos
;
2658 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1, adjust
);
2660 else if (bp
.bufpos
== Z
- end_unchanged
)
2662 /* If reprinting everything is nearly as fast as scrolling,
2663 don't bother scrolling. Can happen if lines are short. */
2664 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
2665 top
+ height
- max (0, scroll_amount
),
2667 > xp
.bufpos
- bp
.bufpos
- 20)
2668 /* Return "try normal display with same window-start."
2669 Too bad we can't prevent further scroll-thinking. */
2671 /* If pure deletion, scroll up as many lines as possible.
2672 In common case of killing a line, this can save the
2673 following line from being overwritten by scrolling
2674 and therefore having to be redrawn. */
2675 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
2676 top
+ height
- max (0, scroll_amount
),
2677 scroll_amount
, bp
.bufpos
);
2682 /* scroll_frame_lines did not properly adjust subsequent
2683 lines' charstarts in the case where the text of the
2684 screen line at bp.vpos has changed.
2685 (This can happen in a deletion that ends in mid-line.)
2686 To adjust properly, we need to make things consistent
2688 So do a second adjust to make that happen.
2689 Note that stop_vpos >= ep.vpos, so it is sufficient
2690 to update the charstarts for lines at ep.vpos and below. */
2692 = FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2693 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1,
2694 ep
.bufpos
- oldstart
);
2697 else if (scroll_amount
)
2699 /* If reprinting everything is nearly as fast as scrolling,
2700 don't bother scrolling. Can happen if lines are short. */
2701 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
2702 overestimate of cost of reprinting, since xp.bufpos
2703 would end up below the bottom of the window. */
2704 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
2705 top
+ height
- max (0, scroll_amount
),
2707 > xp
.bufpos
- ep
.bufpos
- 20)
2708 /* Return "try normal display with same window-start."
2709 Too bad we can't prevent further scroll-thinking. */
2711 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
2712 top
+ height
- max (0, scroll_amount
),
2713 scroll_amount
, ep
.bufpos
);
2714 if (!tem
) stop_vpos
= height
;
2718 /* In any case, do not display past bottom of window */
2719 if (stop_vpos
>= height
)
2725 /* Handle case where pos is before w->start --
2726 can happen if part of line had been clipped and is not clipped now */
2727 if (vpos
== 0 && pos
< marker_position (w
->start
))
2728 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2730 val
.bytepos
= pos_byte
;
2732 /* Redisplay the lines where the text was changed */
2733 last_text_vpos
= vpos
;
2734 /* The following code is omitted because we maintain tab offset in
2737 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2738 /* If we are starting display in mid-character, correct tab_offset
2739 to account for passing the line that that character really starts in. */
2740 if (val
.hpos
< lmargin
)
2741 tab_offset
+= width
;
2744 while (vpos
< stop_vpos
)
2746 val
= *display_text_line (w
, pos
, val
.bytepos
, top
+ vpos
++,
2747 val
.hpos
, val
.tab_offset
,
2748 val
.ovstring_chars_done
);
2749 /* If display_text_line ran a hook and changed some text,
2750 redisplay all the way to bottom of buffer
2751 So that we show the changes. */
2752 if (old_tick
!= MODIFF
)
2754 /* The following code is omitted because we maintain tab offset
2755 in val.tab_offset. */
2757 tab_offset
+= width
;
2758 if (val
.vpos
) tab_offset
= 0;
2760 if (pos
!= val
.bufpos
)
2762 /* Next line, unless prev line ended in end of buffer with no cr */
2763 = vpos
- (val
.vpos
&& FETCH_BYTE (val
.bufpos
- 1) != '\n');
2767 /* There are two cases:
2768 1) we have displayed down to the bottom of the window
2769 2) we have scrolled lines below stop_vpos by scroll_amount */
2773 /* If last line is continued in middle of character,
2774 include the split character in the text considered on the frame */
2775 if (val
.hpos
< lmargin
)
2777 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
);
2778 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2781 /* If scrolling made blank lines at window bottom,
2782 redisplay to fill those lines */
2783 if (scroll_amount
< 0)
2785 /* Don't consider these lines for general-purpose scrolling.
2786 That will save time in the scrolling computation. */
2787 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
2790 pos_byte
= xp
.bytepos
;
2792 val
.tab_offset
= xp
.tab_offset
;
2794 { /* Display from next line */
2795 vpos
= height
+ scroll_amount
;
2799 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
2801 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
2802 val
.tab_offset
= xp
.tab_offset
+ bp
.prevhpos
- width
;
2807 blank_end_of_window
= 1;
2808 /* The following code is omitted because we maintain tab offset
2809 in val.tab_offset. */
2811 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2812 /* If we are starting display in mid-character, correct tab_offset
2813 to account for passing the line that that character starts in. */
2814 if (val
.hpos
< lmargin
)
2815 tab_offset
+= width
;
2818 while (vpos
< height
)
2820 val
= *display_text_line (w
, pos
, val
.bytepos
,
2821 top
+ vpos
++, val
.hpos
,
2822 val
.tab_offset
, val
.ovstring_chars_done
);
2823 /* The following code is omitted because we maintain tab
2824 offset in val.tab_offset. */
2826 tab_offset
+= width
;
2827 if (val
.vpos
) tab_offset
= 0;
2832 /* Here is a case where display_text_line sets cursor_vpos wrong.
2833 Make it be fixed up, below. */
2839 /* If bottom just moved off end of frame, change mode line percentage. */
2840 if (XFASTINT (w
->window_end_pos
) == 0
2842 w
->update_mode_line
= Qt
;
2844 /* Attempt to adjust end-of-text positions to new bottom line */
2847 delta
= height
- xp
.vpos
;
2849 || (delta
> 0 && xp
.bufpos
<= ZV
)
2850 || (delta
== 0 && xp
.hpos
))
2852 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), delta
, w
);
2853 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2854 XSETFASTINT (w
->window_end_vpos
,
2855 XFASTINT (w
->window_end_vpos
) + val
.vpos
);
2859 w
->window_end_valid
= Qnil
;
2861 /* If point was not in a line that was displayed, find it */
2862 if (cursor_vpos
< 0)
2865 val
= *compute_motion (start
, 0, lmargin
, 0, PT
,
2866 /* Don't care for VPOS... */
2867 1 << (BITS_PER_SHORT
- 1),
2869 1 << (BITS_PER_SHORT
- 1),
2871 pos_tab_offset (w
, start
, start_byte
),
2873 /* Admit failure if point is off frame now */
2874 if (val
.vpos
>= height
)
2876 for (vpos
= 0; vpos
< height
; vpos
++)
2877 cancel_line (vpos
+ top
, f
);
2880 cursor_vpos
= val
.vpos
+ top
;
2881 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, val
.hpos
, width
);
2884 FRAME_CURSOR_X (f
) = cursor_hpos
;
2885 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2889 val
= *compute_motion (start
, 0, lmargin
, 0, ZV
,
2890 height
, - (1 << (BITS_PER_SHORT
- 1)),
2892 pos_tab_offset (w
, start
, start_byte
),
2894 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
2896 if (XFASTINT (w
->window_end_pos
)
2904 /* Copy LEN glyphs starting address FROM to the rope TO.
2905 But don't actually copy the parts that would come in before S.
2906 Value is TO, advanced past the copied data.
2907 F is the frame we are displaying in. */
2910 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
2912 register GLYPH
*to
; /* Copy to here. */
2913 register GLYPH
*s
; /* Starting point. */
2914 Lisp_Object
*from
; /* Data to copy. */
2916 int face
; /* Face to apply to glyphs which don't specify one. */
2919 register Lisp_Object
*fp
= from
;
2920 /* These cache the results of the last call to compute_glyph_face. */
2922 int last_merged
= 0;
2925 if (! FRAME_TERMCAP_P (f
))
2928 GLYPH glyph
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
2930 unsigned int c
= FAST_GLYPH_CHAR (glyph
);
2933 /* For an invalid character code, use space. */
2936 if (FAST_GLYPH_FACE (glyph
) == 0)
2937 /* If GLYPH has no face code, use FACE. */
2939 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
2940 /* If it's same as previous glyph, use same result. */
2941 facecode
= last_merged
;
2944 /* Merge this glyph's face and remember the result. */
2945 last_code
= FAST_GLYPH_FACE (glyph
);
2946 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
2950 *to
= FAST_MAKE_GLYPH (c
, facecode
);
2958 if (to
>= s
) *to
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
2965 /* Correct a glyph by replacing its specified user-level face code
2966 with a displayable computed face code. */
2969 fix_glyph (f
, glyph
, cface
)
2975 if (! FRAME_TERMCAP_P (f
))
2977 if (FAST_GLYPH_FACE (glyph
) != 0)
2978 cface
= compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
), cface
);
2979 glyph
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), cface
);
2985 /* Return the column of position POS / POS_BYTE in window W's buffer.
2986 The result is rounded down to a multiple of the internal width of W.
2987 This is the amount of indentation of position POS
2988 that is not visible in its horizontal position in the window. */
2991 pos_tab_offset (w
, pos
, pos_byte
)
2993 register int pos
, pos_byte
;
2996 int opoint_byte
= PT_BYTE
;
2998 int width
= window_internal_width (w
) - 1;
3001 return MINI_WINDOW_P (w
) ? -minibuf_prompt_width
: 0;
3003 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3006 TEMP_SET_PT_BOTH (pos
, pos_byte
);
3007 col
= current_column ();
3008 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
3013 /* Display one line of window W, starting at char position START in W's buffer.
3014 START_BYTE is the corresponding byte position.
3016 Display starting at horizontal position HPOS, expressed relative to
3017 W's left edge. In situations where the text at START shouldn't
3018 start at the left margin (i.e. when the window is hscrolled, or
3019 we're continuing a line which left off in the midst of a
3020 multi-column character), HPOS should be negative; we throw away
3021 characters up 'til hpos = 0. So, HPOS must take hscrolling into
3024 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
3026 OVSTR_DONE is the number of chars of overlay before/after strings
3027 at this position which have already been processed.
3029 Display on position VPOS on the frame. It is origin 0, relative to
3030 the top of the frame, not W.
3032 Returns a STRUCT POSITION giving character to start next line with
3033 and where to display it, including a zero or negative hpos.
3034 The vpos field is not really a vpos; it is 1 unless the line is continued */
3036 struct position val_display_text_line
;
3038 static struct position
*
3039 display_text_line (w
, start
, start_byte
, vpos
, hpos
, taboffset
, ovstr_done
)
3047 register int pos
= start
;
3048 int pos_byte
= start_byte
;
3051 int pause
, limit_byte
;
3052 register unsigned char *p
;
3054 register GLYPH
*leftmargin
;
3055 register GLYPH
*p1prev
;
3056 register GLYPH
*p1start
;
3057 int prevpos
, prevpos_byte
;
3059 FRAME_PTR f
= XFRAME (w
->frame
);
3060 int tab_width
= XINT (current_buffer
->tab_width
);
3061 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
3062 int width
= window_internal_width (w
) - 1;
3063 struct position val
;
3064 int lastpos
, lastpos_byte
;
3066 int last_invis_skip
= 0;
3067 Lisp_Object last_invis_prop
;
3068 int hscroll
= XINT (w
->hscroll
);
3069 int truncate
= (hscroll
3070 || (truncate_partial_width_windows
3071 && !WINDOW_FULL_WIDTH_P (w
))
3072 || !NILP (current_buffer
->truncate_lines
));
3074 /* 1 if this buffer has a region to highlight. */
3075 int highlight_region
3076 = (!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
)
3077 && XMARKER (current_buffer
->mark
)->buffer
!= 0);
3078 int region_beg
, region_end
;
3080 int selective
= (INTEGERP (current_buffer
->selective_display
)
3081 ? XINT (current_buffer
->selective_display
)
3082 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
3083 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3084 register struct Lisp_Char_Table
*dp
= window_display_table (w
);
3086 Lisp_Object default_invis_vector
[3];
3087 /* Number of characters of ellipsis to display after an invisible line
3088 if it calls for an ellipsis.
3089 Note that this value can be nonzero regardless of whether
3090 selective display is enabled--you must check that separately. */
3092 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3093 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
3094 : !NILP (current_buffer
->selective_display_ellipses
) ? 3 : 0);
3095 /* This is the sequence of Lisp objects to display
3096 when there are invisible lines. */
3097 Lisp_Object
*invis_vector_contents
3098 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3099 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
3100 : default_invis_vector
);
3102 GLYPH truncator
= (dp
== 0 || !INTEGERP (DISP_TRUNC_GLYPH (dp
))
3103 || !GLYPH_CHAR_VALID_P (XINT (DISP_TRUNC_GLYPH (dp
)))
3104 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
3105 GLYPH continuer
= (dp
== 0 || !INTEGERP (DISP_CONTINUE_GLYPH (dp
))
3106 || !GLYPH_CHAR_VALID_P (XINT (DISP_CONTINUE_GLYPH (dp
)))
3107 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
3109 /* If 1, we must handle multibyte characters. */
3110 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
3111 /* Length of multibyte form of each character. */
3113 /* Glyphs generated should be set this bit mask if text must be
3114 displayed from right to left. */
3115 GLYPH rev_dir_bit
= (NILP (current_buffer
->direction_reversed
)
3116 ? 0 : GLYPH_MASK_REV_DIR
);
3118 /* The next buffer location at which the face should change, due
3119 to overlays or text property changes. */
3120 int next_face_change
;
3122 /* The next location where the `invisible' property changes, or an
3123 overlay starts or ends. */
3126 /* The face we're currently using. */
3127 int current_face
= 0;
3130 XSETFASTINT (default_invis_vector
[2], '.');
3131 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
3133 get_display_line (f
, vpos
, WINDOW_LEFT_MARGIN (w
));
3134 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3136 /* Show where to highlight the region. */
3137 if (highlight_region
3138 /* Maybe highlight only in selected window. */
3139 && (highlight_nonselected_windows
3140 || w
== XWINDOW (selected_window
)
3141 || (MINI_WINDOW_P (XWINDOW (selected_window
))
3142 && w
== XWINDOW (Vminibuf_scroll_window
))))
3144 region_beg
= marker_position (current_buffer
->mark
);
3145 if (PT
< region_beg
)
3147 region_end
= region_beg
;
3152 w
->region_showing
= Qt
;
3156 region_beg
= region_end
= -1;
3157 w
->region_showing
= Qnil
;
3160 if (MINI_WINDOW_P (w
)
3162 && vpos
== XFASTINT (w
->top
))
3164 if (! NILP (minibuf_prompt
))
3166 int old_width
= minibuf_prompt_width
;
3168 minibuf_prompt_width
3169 = (display_string (w
, vpos
, XSTRING (minibuf_prompt
)->data
,
3170 XSTRING (minibuf_prompt
)->size
,
3171 hpos
+ WINDOW_LEFT_MARGIN (w
),
3172 /* Display a space if we truncate. */
3175 /* Truncate the prompt a little before the
3176 margin, so user input can at least start
3177 on the first line. */
3178 (XFASTINT (w
->width
) > 10
3179 ? XFASTINT (w
->width
) - 4 : -1),
3181 - hpos
- WINDOW_LEFT_MARGIN (w
));
3182 hpos
+= minibuf_prompt_width
;
3183 taboffset
-= minibuf_prompt_width
- old_width
;
3186 minibuf_prompt_width
= 0;
3189 /* If we're hscrolled at all, use compute_motion to skip over any
3190 text off the left edge of the window. compute_motion may know
3191 tricks to do this faster than we can. */
3194 struct position
*left_edge
3195 = compute_motion (pos
, vpos
, hpos
, 0,
3197 width
, hscroll
, taboffset
, w
);
3199 /* Retrieve the buffer position and column provided by
3200 compute_motion. We can't assume that the column will be
3201 zero, because you may have multi-column characters crossing
3204 compute_motion may have moved us past the screen position we
3205 requested, if we hit a multi-column character, or the end of
3206 the line. If so, back up. */
3207 if (left_edge
->vpos
> vpos
3208 || left_edge
->hpos
> 0)
3210 pos
= left_edge
->bufpos
;
3211 /* Since this should not be a valid multibyte character, we
3212 can decrease POS by 1. */
3214 pos_byte
= left_edge
->bytepos
- 1;
3215 hpos
= left_edge
->prevhpos
;
3219 pos
= left_edge
->bufpos
;
3220 pos_byte
= left_edge
->bytepos
;
3221 hpos
= left_edge
->hpos
;
3225 hpos
+= WINDOW_LEFT_MARGIN (w
);
3227 desired_glyphs
->bufp
[vpos
] = start
;
3228 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3230 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
3231 /* In case we don't ever write anything into it... */
3232 desired_glyphs
->charstarts
[vpos
][WINDOW_LEFT_MARGIN (w
)] = -1;
3233 leftmargin
= desired_glyphs
->glyphs
[vpos
] + WINDOW_LEFT_MARGIN (w
);
3234 endp
= leftmargin
+ width
;
3236 /* Arrange the overlays nicely for our purposes. Usually, we call
3237 display_text_line on only one line at a time, in which case this
3238 can't really hurt too much, or we call it on lines which appear
3239 one after another in the buffer, in which case all calls to
3240 recenter_overlay_lists but the first will be pretty cheap. */
3241 recenter_overlay_lists (current_buffer
, pos
);
3243 /* Loop generating characters.
3244 Stop at end of buffer, before newline,
3245 if reach or pass continuation column,
3246 or at face change. */
3248 limit_byte
= pos_byte
;
3249 next_face_change
= pos
;
3250 next_boundary
= pos
;
3253 prevpos_byte
= pos_byte
;
3255 /* If the window is hscrolled and point is in the invisible part of the
3256 current line beyond the left margin we can record the cursor location
3258 if (hscroll
&& start
<= PT
&& PT
< pos
&& cursor_vpos
< 0)
3261 cursor_hpos
= p1
- leftmargin
;
3270 while (pos
== next_boundary
)
3272 Lisp_Object position
, limit
, prop
, ww
;
3274 /* Display the overlay strings here, unless we're at ZV
3275 and have already displayed the appropriate strings
3276 on an earlier line. */
3277 if (pos
< ZV
|| !zv_strings_seen
++)
3280 unsigned char *ovstr
;
3281 ovlen
= overlay_strings (pos
, w
, &ovstr
);
3285 /* Skip the ones we did in a previous line. */
3286 ovstr
+= ovstr_done
;
3287 ovlen
-= ovstr_done
;
3296 c
= STRING_CHAR_AND_LENGTH (ovstr
, ovlen
, len
);
3297 ovstr
+= len
, ovlen
-= len
, ovstr_done
+= len
;
3298 charset
= CHAR_CHARSET (c
);
3299 cols
= (charset
== CHARSET_COMPOSITION
3300 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3301 : CHARSET_WIDTH (charset
));
3305 c
= *ovstr
++, ovlen
--, ovstr_done
++;
3308 g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3311 if (p1
>= leftmargin
&& p1
< endp
)
3312 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3316 /* If we did all the overlay strings
3317 and we have room for text, clear ovstr_done
3318 just for neatness' sake. */
3319 if (ovlen
== 0 && p1
< endp
)
3324 /* Did we reach point? Record the cursor location. */
3325 if (pos
== PT
&& cursor_vpos
< 0)
3328 cursor_hpos
= p1
- leftmargin
;
3334 XSETFASTINT (position
, pos
);
3335 limit
= Fnext_overlay_change (position
);
3336 #ifdef USE_TEXT_PROPERTIES
3337 /* This is just an estimate to give reasonable
3338 performance; nothing should go wrong if it is too small. */
3339 if (XFASTINT (limit
) > pos
+ 50)
3341 int limitpos
= pos
+ 50;
3342 XSETFASTINT (limit
, limitpos
);
3344 limit
= Fnext_single_property_change (position
, Qinvisible
,
3345 Fcurrent_buffer (), limit
);
3347 next_boundary
= XFASTINT (limit
);
3348 /* if the `invisible' property is set, we can skip to
3349 the next property change. */
3351 prop
= Fget_char_property (position
, Qinvisible
, ww
);
3352 if (TEXT_PROP_MEANS_INVISIBLE (prop
))
3354 if (pos
< PT
&& next_boundary
>= PT
)
3357 cursor_hpos
= p1
- leftmargin
;
3359 pos
= next_boundary
;
3360 last_invis_skip
= pos
;
3361 last_invis_prop
= prop
;
3365 /* Did we reach point? Record the cursor location. */
3366 if (pos
== PT
&& cursor_vpos
< 0)
3369 cursor_hpos
= p1
- leftmargin
;
3372 /* Did we hit the end of the visible region of the buffer?
3376 /* Update charstarts for the end of this line. */
3377 /* Do nothing if off the left edge or at the right edge. */
3378 if (p1
>= leftmargin
&& p1
+ 1 != endp
)
3380 int *p2x
= &charstart
[(p1
< leftmargin
3388 /* Figure out where (if at all) the
3389 redisplay_end_trigger-hook should run. */
3390 if (MARKERP (w
->redisplay_end_trigger
)
3391 && XMARKER (w
->redisplay_end_trigger
)->buffer
!= 0)
3392 e_t_h
= marker_position (w
->redisplay_end_trigger
);
3393 else if (INTEGERP (w
->redisplay_end_trigger
))
3394 e_t_h
= XINT (w
->redisplay_end_trigger
);
3398 /* If we've gone past the place to run a hook,
3400 if (pos
>= e_t_h
&& e_t_h
!= ZV
)
3402 Lisp_Object args
[3];
3404 args
[0] = Qredisplay_end_trigger_functions
;
3405 XSETWINDOW (args
[1], w
);
3406 XSETINT (args
[2], e_t_h
);
3408 /* Since we are *trying* to run these functions,
3409 don't try to run them again, even if they get an error. */
3410 w
->redisplay_end_trigger
= Qnil
;
3411 Frun_hook_with_args (3, args
);
3414 /* Notice if it changed the face of this character. */
3415 next_face_change
= pos
;
3419 /* Did we hit a face change? Figure out what face we should
3420 use now. We also hit this the first time through the
3421 loop, to see what face we should start with. */
3422 if (pos
>= next_face_change
3423 && (FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
)))
3425 int limit
= pos
+ 50;
3427 current_face
= compute_char_face (f
, w
, pos
,
3428 region_beg
, region_end
,
3429 &next_face_change
, limit
, 0);
3433 /* Compute the next place we need to stop
3434 and do something special; set PAUSE. */
3438 if (pos
< next_boundary
&& next_boundary
< pause
)
3439 pause
= next_boundary
;
3440 if (pos
< next_face_change
&& next_face_change
< pause
)
3441 pause
= next_face_change
;
3446 /* Wouldn't you hate to read the next line to someone over
3448 if (pos
< PT
&& PT
< pause
)
3450 if (pos
< GPT
&& GPT
< pause
)
3453 /* LIMIT_BYTE is not the same place in the buffer as PAUSE.
3454 It is a limit on valid characters.
3455 We use it to bound STRING_CHAR_AND_LENGTH. */
3456 limit_byte
= ZV_BYTE
;
3457 if (pos
< GPT
&& GPT_BYTE
< limit_byte
)
3458 limit_byte
= GPT_BYTE
;
3461 int temp
= CHAR_TO_BYTE (pos
);
3462 p
= BYTE_POS_ADDR (temp
);
3472 c
= STRING_CHAR_AND_LENGTH (p
, limit_byte
- pos_byte
, len
), p
+= len
;
3475 /* Let a display table override all standard display methods. */
3476 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
3478 p1
= copy_part_of_rope (f
, p1
, leftmargin
,
3479 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3480 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3481 current_face
, rev_dir_bit
);
3483 else if (c
>= 040 && c
< 0177)
3485 if (p1
>= leftmargin
)
3486 *p1
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3492 /* Same as p1prev, but after the invis_vector_contents text
3493 (if we have that on this line). */
3494 GLYPH
*p1prev_modified
;
3498 if (last_invis_skip
== pos
3499 && TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (last_invis_prop
))
3503 && indented_beyond_p (pos
+ 1, pos_byte
+ 1, selective
))
3505 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3508 if (! NILP (current_buffer
->enable_multibyte_characters
))
3509 INC_BOTH (pos
, pos_byte
);
3512 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3513 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3518 SET_PT_BOTH (opoint
, opoint_byte
);
3520 if (invis
&& selective_rlen
> 0 && p1
>= leftmargin
)
3525 cs
= charstart
+ (p1
- p1start
);
3528 p1
+= selective_rlen
;
3529 if (p1
- leftmargin
> width
)
3532 #if 0 /* This needs more work; charstarts needs to record
3533 both whether a position ho;ds an ellipsis character
3534 and what buffer position it corresponds to. */
3535 csend
= charstart
+ (p1
- p1start
);
3538 /* The idea is to use p1prev_modified instead of p1prev
3539 in the loop below over p2x. */
3540 p1prev_modified
= p1
;
3543 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3544 (p1
- p1prev
), current_face
, rev_dir_bit
);
3547 /* Update charstarts for the newline that ended this line. */
3548 /* Do nothing here for a char that's entirely off the left edge
3549 or if it starts at the right edge. */
3550 if (p1
>= leftmargin
&& p1prev
!= endp
)
3552 /* Store the newline's position into charstarts
3553 for the column where the newline starts.
3554 Store -1 for the rest of the glyphs it occupies. */
3555 int *p2x
= &charstart
[(p1prev
< leftmargin
3556 ? leftmargin
: p1prev
)
3558 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3565 /* Draw the face of the newline character as extending all the
3566 way to the end of the frame line. */
3569 if (p1
< leftmargin
)
3572 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3582 if (p1
>= leftmargin
&& p1
< endp
)
3583 *p1
= MAKE_GLYPH (f
, ' ', current_face
) | rev_dir_bit
;
3586 while ((p1
- leftmargin
+ taboffset
+ hscroll
- (hscroll
> 0))
3589 else if (c
== Ctl ('M') && selective
== -1)
3591 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3592 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3593 pos
= PT
, pos_byte
= PT_BYTE
;
3594 SET_PT_BOTH (opoint
, opoint_byte
);
3596 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3598 if (selective_rlen
> 0)
3600 p1
+= selective_rlen
;
3601 if (p1
- leftmargin
> width
)
3603 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3604 (p1
- p1prev
), current_face
, rev_dir_bit
);
3607 /* Draw the face of the newline character as extending all the
3608 way to the end of the frame line. */
3611 if (p1
< leftmargin
)
3614 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3618 /* Update charstarts for the ^M that ended this line. */
3619 /* Do nothing here for a char that's entirely off the left edge
3620 or if it starts at the right edge. */
3621 if (p1
>= leftmargin
&& p1prev
!= endp
)
3623 /* Store the newline's position into charstarts
3624 for the column where the newline starts.
3625 Store -1 for the rest of the glyphs it occupies. */
3626 int *p2x
= &charstart
[(p1prev
< leftmargin
3627 ? leftmargin
: p1prev
)
3629 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3637 else if (c
< 0200 && ctl_arrow
)
3639 if (p1
>= leftmargin
)
3641 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
3642 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
3643 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3647 if (p1
>= leftmargin
&& p1
< endp
)
3648 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
) | rev_dir_bit
;
3653 /* C is not a multibyte character. */
3654 if (p1
>= leftmargin
)
3656 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
3657 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
3658 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3662 if (p1
>= leftmargin
&& p1
< endp
)
3663 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
) | rev_dir_bit
;
3665 if (p1
>= leftmargin
&& p1
< endp
)
3666 *p1
= (MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
)
3669 if (p1
>= leftmargin
&& p1
< endp
)
3670 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
) | rev_dir_bit
;
3675 /* C is a multibyte character. */
3676 int charset
= CHAR_CHARSET (c
);
3677 int columns
= (charset
== CHARSET_COMPOSITION
3678 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3679 : CHARSET_WIDTH (charset
));
3680 GLYPH g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3684 if (p1
>= leftmargin
&& p1
< endp
)
3685 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3691 prevpos_byte
= pos_byte
;
3695 /* Update charstarts for the character just output. */
3697 /* Do nothing here for a char that's entirely off the left edge. */
3698 if (p1
>= leftmargin
)
3700 /* Store the char's position into charstarts
3701 for the first glyph occupied by this char.
3702 Store -1 for the rest of the glyphs it occupies. */
3705 int *p2x
= &charstart
[(p1prev
< leftmargin
3706 ? leftmargin
: p1prev
)
3708 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3718 val
.hpos
= - XINT (w
->hscroll
);
3725 lastpos_byte
= pos_byte
;
3727 /* Store 0 in this charstart line for the positions where
3728 there is no character. But do leave what was recorded
3729 for the character that ended the line. */
3730 /* Add 1 in the endtest to compensate for the fact that ENDP was
3731 made from WIDTH, which is 1 less than the window's actual
3733 i
= p1
- p1start
+ 1;
3734 if (p1
< leftmargin
)
3735 i
+= leftmargin
- p1
;
3736 for (; i
< endp
- p1start
+ 1; i
++)
3739 /* Handle continuation in middle of a character */
3740 /* by backing up over it */
3743 /* Don't back up if we never actually displayed any text.
3744 This occurs when the minibuffer prompt takes up the whole line. */
3747 /* Start the next line with that same character whose
3748 character code is C and the length of multi-byte form is
3751 pos_byte
= prevpos_byte
;
3754 /* C is not a multi-byte character. We can break it and
3755 start from the middle column in the next line. So,
3756 adjust VAL.HPOS to skip the columns output on this
3758 val
.hpos
+= p1prev
- endp
;
3761 /* C is a multibyte character. Since we can't broke it
3762 in the middle, the whole character should be driven
3763 into the next line. */
3764 /* As the result, the actual columns occupied by the
3765 text on this line is less than WIDTH. VAL.TAB_OFFSET
3766 must be adjusted. */
3767 taboffset
= taboffset
+ (p1prev
- endp
);
3768 /* Let's fill unused columns with TRUNCATOR or CONTINUER. */
3770 GLYPH g
= fix_glyph (f
, truncate
? truncator
: continuer
, 0);
3771 while (p1prev
< endp
)
3774 /* If POINT is at POS, cursor should not on this line. */
3776 lastpos_byte
= pos_byte
;
3782 /* Keep in this line everything up to the continuation column. */
3786 /* Finish deciding which character to start the next line on,
3787 and what hpos to start it at.
3788 Also set `lastpos' to the last position which counts as "on this line"
3789 for cursor-positioning. */
3793 if (FETCH_BYTE (pos_byte
) == '\n')
3795 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3797 /* If stopped due to a newline, start next line after it */
3798 SET_PT_BOTH (pos
+ 1, pos_byte
+ 1);
3801 /* Check again for hidden lines, in case the newline occurred exactly
3802 at the right margin. */
3803 while (PT
< ZV
&& selective
> 0
3804 && indented_beyond_p (PT
, PT_BYTE
, selective
))
3805 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3807 pos
= PT
, pos_byte
= PT_BYTE
;
3808 SET_PT_BOTH (opoint
, opoint_byte
);
3811 /* Stopped due to right margin of window */
3815 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3817 SET_PT_BOTH (pos
, pos_byte
);
3818 *p1
++ = fix_glyph (f
, truncator
, 0);
3819 /* Truncating => start next line after next newline,
3820 and point is on this line if it is before the newline,
3821 and skip none of first char of next line */
3823 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3824 while (PT
< ZV
&& selective
> 0
3825 && indented_beyond_p (PT
, PT_BYTE
, selective
));
3826 pos
= PT
, pos_byte
= PT_BYTE
;
3827 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
3828 SET_PT_BOTH (opoint
, opoint_byte
);
3830 lastpos
= pos
- (FETCH_BYTE (pos_byte
- 1) == '\n');
3831 lastpos_byte
= CHAR_TO_BYTE (lastpos
);
3836 *p1
++ = fix_glyph (f
, continuer
, 0);
3839 DEC_POS (lastpos_byte
);
3840 val
.tab_offset
= taboffset
+ width
;
3847 /* If point is at eol or in invisible text at eol,
3848 record its frame location now. */
3850 if (start
<= PT
&& PT
<= lastpos
&& cursor_vpos
< 0)
3853 cursor_hpos
= p1
- leftmargin
;
3856 if (cursor_vpos
== vpos
)
3858 if (cursor_hpos
< 0) cursor_hpos
= 0;
3859 if (cursor_hpos
> width
) cursor_hpos
= width
;
3860 cursor_hpos
+= WINDOW_LEFT_MARGIN (w
);
3861 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
3863 if (!(cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f
)
3864 && EQ (FRAME_MINIBUF_WINDOW (f
), minibuf_window
)))
3866 FRAME_CURSOR_Y (f
) = cursor_vpos
;
3867 FRAME_CURSOR_X (f
) = cursor_hpos
;
3870 if (w
== XWINDOW (selected_window
))
3872 /* Line is not continued and did not start
3873 in middle of character */
3874 if ((hpos
- WINDOW_LEFT_MARGIN (w
)
3875 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
3878 this_line_bufpos
= start
;
3879 this_line_buffer
= current_buffer
;
3880 this_line_vpos
= cursor_vpos
;
3881 this_line_start_hpos
= hpos
- WINDOW_LEFT_MARGIN (w
);
3882 this_line_endpos
= Z
- lastpos
;
3885 this_line_bufpos
= 0;
3890 /* If hscroll and line not empty, insert truncation-at-left marker */
3891 if (hscroll
&& lastpos
!= start
)
3893 GLYPH g
= fix_glyph (f
, truncator
, 0);
3895 if (p1
<= leftmargin
)
3896 p1
= leftmargin
+ 1;
3897 else /* MULE: it may be a wide-column character */
3899 p1prev
= leftmargin
+ 1;
3900 while (p1prev
< p1
&& *p1prev
& GLYPH_MASK_PADDING
)
3905 if (!WINDOW_RIGHTMOST_P (w
))
3908 if (p1
< leftmargin
) p1
= leftmargin
;
3909 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
3911 /* Don't draw vertical bars if we're using scroll bars. They're
3912 covered up by the scroll bars, and it's distracting to see
3913 them when the scroll bar windows are flickering around to be
3915 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3918 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
3921 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3922 *p1
++ = (dp
&& INTEGERP (DISP_BORDER_GLYPH (dp
))
3923 ? XINT (DISP_BORDER_GLYPH (dp
))
3926 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
3927 p1
- desired_glyphs
->glyphs
[vpos
]);
3928 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
3930 /* If the start of this line is the overlay arrow-position,
3931 then put the arrow string into the display-line. */
3933 if (MARKERP (Voverlay_arrow_position
)
3934 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
3935 && start
== marker_position (Voverlay_arrow_position
)
3936 && STRINGP (Voverlay_arrow_string
)
3937 && ! overlay_arrow_seen
)
3939 unsigned char *p
= XSTRING (Voverlay_arrow_string
)->data
;
3941 int len
= XSTRING (Voverlay_arrow_string
)->size
;
3947 if (!NULL_INTERVAL_P (XSTRING (Voverlay_arrow_string
)->intervals
))
3949 /* If the arrow string has text props, obey them when displaying. */
3950 for (i
= 0; i
< len
; i
++)
3953 Lisp_Object face
, ilisp
;
3956 XSETFASTINT (ilisp
, i
);
3957 face
= Fget_text_property (ilisp
, Qface
, Voverlay_arrow_string
);
3958 newface
= compute_glyph_face_1 (f
, face
, 0);
3959 leftmargin
[i
] = FAST_MAKE_GLYPH (c
, newface
);
3963 #endif /* HAVE_FACES */
3965 for (i
= 0; i
< len
; i
++)
3966 leftmargin
[i
] = p
[i
];
3969 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
3970 arrow_end
= (leftmargin
- desired_glyphs
->glyphs
[vpos
]) + len
;
3971 if (desired_glyphs
->used
[vpos
] < arrow_end
)
3972 desired_glyphs
->used
[vpos
] = arrow_end
;
3974 overlay_arrow_seen
= 1;
3978 val
.bytepos
= pos_byte
;
3979 val
.ovstring_chars_done
= ovstr_done
;
3980 val_display_text_line
= val
;
3981 return &val_display_text_line
;
3984 /* Redisplay the menu bar in the frame for window W. */
3987 display_menu_bar (w
)
3990 Lisp_Object items
, tail
;
3991 register int vpos
= 0;
3992 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3993 int maxendcol
= FRAME_WIDTH (f
) + WINDOW_LEFT_MARGIN (w
);
3998 if (!NILP (Vwindow_system
))
4002 #ifdef USE_X_TOOLKIT
4005 #endif /* USE_X_TOOLKIT */
4007 get_display_line (f
, vpos
, 0);
4009 items
= FRAME_MENU_BAR_ITEMS (f
);
4010 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 4)
4012 Lisp_Object pos
, string
;
4013 string
= XVECTOR (items
)->contents
[i
+ 1];
4017 XSETFASTINT (XVECTOR (items
)->contents
[i
+ 3], hpos
);
4019 if (hpos
< maxendcol
)
4020 hpos
= display_string (w
, vpos
,
4021 XSTRING (string
)->data
,
4022 XSTRING (string
)->size
,
4023 hpos
, 0, 0, hpos
, maxendcol
, -1);
4024 /* Put a space between items. */
4025 if (hpos
< maxendcol
)
4027 int hpos1
= hpos
+ 1;
4028 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
4029 min (hpos1
, maxendcol
), maxendcol
, 0);
4033 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4034 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4036 /* Fill out the line with spaces. */
4037 if (maxendcol
> hpos
)
4038 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
, 0);
4040 /* Clear the rest of the lines allocated to the menu bar. */
4042 while (vpos
< FRAME_MENU_BAR_LINES (f
))
4043 get_display_line (f
, vpos
++, 0);
4046 /* Display the mode line for window w */
4049 display_mode_line (w
)
4052 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
4053 register int left
= WINDOW_LEFT_MARGIN (w
);
4054 register int right
= WINDOW_RIGHT_MARGIN (w
);
4055 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4057 line_number_displayed
= 0;
4058 w
->column_number_displayed
= Qnil
;
4060 get_display_line (f
, vpos
, left
);
4062 /* Temporarily make frame F's kboard the current kboard
4063 so that kboard-local variables in the mode_line_format
4064 will get the right values. */
4065 push_frame_kboard (f
);
4067 display_mode_element (w
, vpos
, left
, 0, right
, right
,
4068 current_buffer
->mode_line_format
);
4070 pop_frame_kboard ();
4072 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4074 /* Put the mode line in inverse video.
4075 Use faces if possible, since that lets us handle
4076 partial-width windows and avoid inverting the scroll bar columns. */
4078 if (! FRAME_TERMCAP_P (f
) && mode_line_inverse_video
)
4080 /* For a partial width window, explicitly set face of each glyph. */
4082 unsigned int padding
;
4083 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
4084 for (i
= left
; i
< right
; ++i
)
4086 padding
= ptr
[i
] & GLYPH_MASK_PADDING
;
4087 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1) | padding
;
4093 /* Make the mode line inverse video if the entire line
4094 is made of mode lines.
4095 I.e. if this window is full width,
4096 or if it is the child of a full width window
4097 (which implies that that window is split side-by-side
4098 and the rest of this line is mode lines of the sibling windows). */
4099 if (WINDOW_FULL_WIDTH_P (w
)
4100 || WINDOW_FULL_WIDTH_P (XWINDOW (w
->parent
)))
4101 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4104 /* Contribute ELT to the mode line for window W.
4105 How it translates into text depends on its data type.
4107 VPOS is the position of the mode line being displayed.
4109 HPOS is the position (absolute on frame) where this element's text
4110 should start. The output is truncated automatically at the right
4113 DEPTH is the depth in recursion. It is used to prevent
4114 infinite recursion here.
4116 MINENDCOL is the hpos before which the element may not end.
4117 The element is padded at the right with spaces if nec
4118 to reach this column.
4120 MAXENDCOL is the hpos past which this element may not extend.
4121 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
4122 (This is necessary to make nested padding and truncation work.)
4124 Returns the hpos of the end of the text generated by ELT.
4125 The next element will receive that value as its HPOS arg,
4126 so as to concatenate the elements. */
4129 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
4131 register int vpos
, hpos
;
4134 register int maxendcol
;
4135 register Lisp_Object elt
;
4143 switch (SWITCH_ENUM_CAST (XTYPE (elt
)))
4147 /* A string: output it and check for %-constructs within it. */
4148 register unsigned char c
;
4149 register unsigned char *this = XSTRING (elt
)->data
;
4151 while (hpos
< maxendcol
&& *this)
4153 unsigned char *last
= this;
4154 while ((c
= *this++) != '\0' && c
!= '%')
4156 if (this - 1 != last
)
4158 register int lim
= --this - last
+ hpos
;
4159 if (frame_title_ptr
)
4160 hpos
= store_frame_title (last
, hpos
, min (lim
, maxendcol
));
4162 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
4163 hpos
, min (lim
, maxendcol
), -1);
4167 register int minendcol
;
4168 register int spec_width
= 0;
4170 /* We can't allow -ve args due to the "%-" construct */
4171 /* Argument specifies minwidth but not maxwidth
4172 (maxwidth can be specified by
4173 (<negative-number> . <stuff>) mode-line elements) */
4175 while ((c
= *this++) >= '0' && c
<= '9')
4177 spec_width
= spec_width
* 10 + (c
- '0');
4180 minendcol
= hpos
+ spec_width
;
4181 if (minendcol
> maxendcol
)
4183 spec_width
= maxendcol
- hpos
;
4184 minendcol
= maxendcol
;
4188 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4189 spec_width
, maxendcol
,
4190 Vglobal_mode_string
);
4193 char *spec
= decode_mode_spec (w
, c
, spec_width
,
4195 if (frame_title_ptr
)
4196 hpos
= store_frame_title (spec
, minendcol
, maxendcol
);
4198 hpos
= display_string (w
, vpos
, spec
, -1,
4200 minendcol
, maxendcol
, -1);
4208 /* A symbol: process the value of the symbol recursively
4209 as if it appeared here directly. Avoid error if symbol void.
4210 Special case: if value of symbol is a string, output the string
4213 register Lisp_Object tem
;
4214 tem
= Fboundp (elt
);
4217 tem
= Fsymbol_value (elt
);
4218 /* If value is a string, output that string literally:
4219 don't check for % within it. */
4222 if (frame_title_ptr
)
4223 hpos
= store_frame_title (XSTRING (tem
)->data
,
4224 minendcol
, maxendcol
);
4226 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
4227 XSTRING (tem
)->size
,
4228 hpos
, 0, 1, minendcol
, maxendcol
, -1);
4230 /* Give up right away for nil or t. */
4231 else if (!EQ (tem
, elt
))
4232 { elt
= tem
; goto tail_recurse
; }
4239 register Lisp_Object car
, tem
;
4241 /* A cons cell: three distinct cases.
4242 If first element is a string or a cons, process all the elements
4243 and effectively concatenate them.
4244 If first element is a negative number, truncate displaying cdr to
4245 at most that many characters. If positive, pad (with spaces)
4246 to at least that many characters.
4247 If first element is a symbol, process the cadr or caddr recursively
4248 according to whether the symbol's value is non-nil or nil. */
4249 car
= XCONS (elt
)->car
;
4252 tem
= Fboundp (car
);
4253 elt
= XCONS (elt
)->cdr
;
4256 /* elt is now the cdr, and we know it is a cons cell.
4257 Use its car if CAR has a non-nil value. */
4260 tem
= Fsymbol_value (car
);
4262 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
4264 /* Symbol's value is nil (or symbol is unbound)
4265 Get the cddr of the original list
4266 and if possible find the caddr and use that. */
4267 elt
= XCONS (elt
)->cdr
;
4270 else if (!CONSP (elt
))
4272 elt
= XCONS (elt
)->car
;
4275 else if (INTEGERP (car
))
4277 register int lim
= XINT (car
);
4278 elt
= XCONS (elt
)->cdr
;
4280 /* Negative int means reduce maximum width.
4281 DO NOT change MINENDCOL here!
4282 (20 -10 . foo) should truncate foo to 10 col
4283 and then pad to 20. */
4284 maxendcol
= min (maxendcol
, hpos
- lim
);
4287 /* Padding specified. Don't let it be more than
4290 if (lim
> maxendcol
)
4292 /* If that's more padding than already wanted, queue it.
4293 But don't reduce padding already specified even if
4294 that is beyond the current truncation point. */
4295 if (lim
> minendcol
)
4300 else if (STRINGP (car
) || CONSP (car
))
4302 register int limit
= 50;
4303 /* LIMIT is to protect against circular lists. */
4304 while (CONSP (elt
) && --limit
> 0
4305 && hpos
< maxendcol
)
4307 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4310 elt
= XCONS (elt
)->cdr
;
4318 if (frame_title_ptr
)
4319 hpos
= store_frame_title ("*invalid*", minendcol
, maxendcol
);
4321 hpos
= display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
4322 minendcol
, maxendcol
, 0);
4326 if (minendcol
> hpos
)
4327 if (frame_title_ptr
)
4328 hpos
= store_frame_title ("", minendcol
, maxendcol
);
4330 hpos
= display_string (w
, vpos
, "", 0, hpos
,
4331 0, 1, minendcol
, maxendcol
, 0);
4335 /* Write a null-terminated, right justified decimal representation of
4336 the positive integer D to BUF using a minimal field width WIDTH. */
4339 pint2str (buf
, width
, d
)
4344 register char *p
= buf
;
4351 *p
++ = d
% 10 + '0';
4354 for (width
-= (int) (p
- buf
); width
> 0; --width
) *p
++ = ' ';
4364 /* Set a mnemonic character for CODING_SYSTEM (Lisp symbol) in BUF.
4365 If EOL_FLAG is 1, set also a mnemonic character for end-of-line
4366 type of CODING_SYSTEM. Return updated pointer into BUF. */
4369 decode_mode_spec_coding (coding_system
, buf
, eol_flag
)
4370 Lisp_Object coding_system
;
4375 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
4377 val
= coding_system
;
4379 if (NILP (val
)) /* Not yet decided. */
4384 *buf
++ = eol_mnemonic_undecided
;
4385 /* Don't mention EOL conversion if it isn't decided. */
4389 Lisp_Object eolvalue
;
4391 eolvalue
= Fget (coding_system
, Qeol_type
);
4393 while (!NILP (val
) && SYMBOLP (val
))
4395 val
= Fget (val
, Qcoding_system
);
4396 if (NILP (eolvalue
))
4397 eolvalue
= Fget (val
, Qeol_type
);
4401 *buf
++ = XFASTINT (XVECTOR (val
)->contents
[1]);
4405 /* The EOL conversion we are using. */
4407 /* The EOL conversion that is normal on this system. */
4409 if (NILP (eolvalue
)) /* Not yet decided. */
4410 eoltype
= eol_mnemonic_undecided
;
4411 else if (VECTORP (eolvalue
)) /* Not yet decided. */
4412 eoltype
= eol_mnemonic_undecided
;
4413 else /* INTEGERP (eolvalue) -- 0:LF, 1:CRLF, 2:CR */
4414 eoltype
= (XFASTINT (eolvalue
) == 0
4416 : (XFASTINT (eolvalue
) == 1
4417 ? eol_mnemonic_dos
: eol_mnemonic_mac
));
4419 /* Mention the EOL conversion if it is not the usual one. */
4426 /* Return a string for the output of a mode line %-spec for window W,
4427 generated by character C. SPEC_WIDTH is the field width when
4428 padding to the left (%c, %l). The value returned from this
4429 function will later be truncated to width MAXWIDTH. */
4431 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
4434 decode_mode_spec (w
, c
, spec_width
, maxwidth
)
4437 register int spec_width
;
4438 register int maxwidth
;
4441 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4442 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
4443 struct buffer
*b
= XBUFFER (w
->buffer
);
4446 if (maxwidth
> FRAME_WIDTH (f
))
4447 maxwidth
= FRAME_WIDTH (f
);
4452 if (!NILP (b
->read_only
))
4454 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4459 /* This differs from %* only for a modified read-only buffer. */
4460 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4462 if (!NILP (b
->read_only
))
4467 /* This differs from %* in ignoring read-only-ness. */
4468 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4480 if (command_loop_level
> 5)
4482 p
= decode_mode_spec_buf
;
4483 for (i
= 0; i
< command_loop_level
; i
++)
4486 return decode_mode_spec_buf
;
4494 if (command_loop_level
> 5)
4496 p
= decode_mode_spec_buf
;
4497 for (i
= 0; i
< command_loop_level
; i
++)
4500 return decode_mode_spec_buf
;
4508 if (maxwidth
< sizeof (lots_of_dashes
))
4509 return lots_of_dashes
;
4512 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
4516 return decode_mode_spec_buf
;
4522 if (maxwidth
>= 3 && XSTRING (obj
)->size
> maxwidth
)
4524 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
4525 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
4526 decode_mode_spec_buf
[maxwidth
] = '\0';
4527 return decode_mode_spec_buf
;
4534 int col
= current_column ();
4535 XSETFASTINT (w
->column_number_displayed
, col
);
4536 pint2str (decode_mode_spec_buf
, spec_width
, col
);
4537 return decode_mode_spec_buf
;
4541 /* %F displays the frame name. */
4542 /* Systems that can only display a single frame at a time should
4543 NOT replace the frame name with the (constant) frame title,
4544 since then they won't be able to tell which frame is that. */
4545 if (FRAME_WINDOW_P (f
) && !NILP (f
->title
))
4546 return (char *) XSTRING (f
->title
)->data
;
4547 if (f
->explicit_name
|| ! FRAME_WINDOW_P (f
))
4548 return (char *) XSTRING (f
->name
)->data
;
4556 else if (STRINGP (obj
) && XSTRING (obj
)->size
> maxwidth
)
4558 bcopy ("...", decode_mode_spec_buf
, 3);
4559 bcopy (XSTRING (obj
)->data
+ XSTRING (obj
)->size
- maxwidth
+ 3,
4560 decode_mode_spec_buf
+ 3, maxwidth
- 3);
4561 return decode_mode_spec_buf
;
4568 int startpos
= XMARKER (w
->start
)->charpos
;
4569 int startpos_byte
= marker_byte_position (w
->start
);
4570 int line
, linepos
, linepos_byte
, topline
;
4573 int height
= XFASTINT (w
->height
);
4575 /* If we decided that this buffer isn't suitable for line numbers,
4576 don't forget that too fast. */
4577 if (EQ (w
->base_line_pos
, w
->buffer
))
4579 /* But do forget it, if the window shows a different buffer now. */
4580 else if (BUFFERP (w
->base_line_pos
))
4581 w
->base_line_pos
= Qnil
;
4583 /* If the buffer is very big, don't waste time. */
4584 if (BUF_ZV (b
) - BUF_BEGV (b
) > line_number_display_limit
)
4586 w
->base_line_pos
= Qnil
;
4587 w
->base_line_number
= Qnil
;
4591 if (!NILP (w
->base_line_number
)
4592 && !NILP (w
->base_line_pos
)
4593 && XFASTINT (w
->base_line_pos
) <= startpos
)
4595 line
= XFASTINT (w
->base_line_number
);
4596 linepos
= XFASTINT (w
->base_line_pos
);
4597 linepos_byte
= buf_charpos_to_bytepos (b
, linepos
);
4602 linepos
= BUF_BEGV (b
);
4603 linepos_byte
= BUF_BEGV_BYTE (b
);
4606 /* Count lines from base line to window start position. */
4607 nlines
= display_count_lines (linepos
, linepos_byte
,
4611 topline
= nlines
+ line
;
4613 /* Determine a new base line, if the old one is too close
4614 or too far away, or if we did not have one.
4615 "Too close" means it's plausible a scroll-down would
4617 if (startpos
== BUF_BEGV (b
))
4619 XSETFASTINT (w
->base_line_number
, topline
);
4620 XSETFASTINT (w
->base_line_pos
, BUF_BEGV (b
));
4622 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
4623 || linepos
== BUF_BEGV (b
))
4625 int limit
= BUF_BEGV (b
);
4626 int limit_byte
= BUF_BEGV_BYTE (b
);
4628 int distance
= (height
* 2 + 30) * 200;
4630 if (startpos
- distance
> limit
)
4632 limit
= startpos
- distance
;
4633 limit_byte
= CHAR_TO_BYTE (limit
);
4636 nlines
= display_count_lines (startpos
, startpos_byte
,
4638 - (height
* 2 + 30),
4640 /* If we couldn't find the lines we wanted within
4642 give up on line numbers for this window. */
4643 if (position
== limit_byte
&& limit
== startpos
- distance
)
4645 w
->base_line_pos
= w
->buffer
;
4646 w
->base_line_number
= Qnil
;
4650 XSETFASTINT (w
->base_line_number
, topline
- nlines
);
4651 XSETFASTINT (w
->base_line_pos
, BYTE_TO_CHAR (position
));
4654 /* Now count lines from the start pos to point. */
4655 nlines
= display_count_lines (startpos
, startpos_byte
,
4656 PT_BYTE
, PT
, &junk
);
4658 /* Record that we did display the line number. */
4659 line_number_displayed
= 1;
4661 /* Make the string to show. */
4662 pint2str (decode_mode_spec_buf
, spec_width
, topline
+ nlines
);
4663 return decode_mode_spec_buf
;
4666 char* p
= decode_mode_spec_buf
;
4667 for (spec_width
-= 2; spec_width
> 0; --spec_width
) *p
++ = ' ';
4669 return decode_mode_spec_buf
;
4679 if (BUF_BEGV (b
) > BUF_BEG (b
) || BUF_ZV (b
) < BUF_Z (b
))
4685 int pos
= marker_position (w
->start
);
4686 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4688 if (XFASTINT (w
->window_end_pos
) <= BUF_Z (b
) - BUF_ZV (b
))
4690 if (pos
<= BUF_BEGV (b
))
4695 else if (pos
<= BUF_BEGV (b
))
4699 if (total
> 1000000)
4700 /* Do it differently for a large value, to avoid overflow. */
4701 total
= ((pos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4703 total
= ((pos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4704 /* We can't normally display a 3-digit number,
4705 so get us a 2-digit number that is close. */
4708 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4709 return decode_mode_spec_buf
;
4713 /* Display percentage of size above the bottom of the screen. */
4716 int toppos
= marker_position (w
->start
);
4717 int botpos
= BUF_Z (b
) - XFASTINT (w
->window_end_pos
);
4718 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4720 if (botpos
>= BUF_ZV (b
))
4722 if (toppos
<= BUF_BEGV (b
))
4729 if (total
> 1000000)
4730 /* Do it differently for a large value, to avoid overflow. */
4731 total
= ((botpos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4733 total
= ((botpos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4734 /* We can't normally display a 3-digit number,
4735 so get us a 2-digit number that is close. */
4738 if (toppos
<= BUF_BEGV (b
))
4739 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
4741 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4742 return decode_mode_spec_buf
;
4747 /* status of process */
4748 obj
= Fget_buffer_process (w
->buffer
);
4750 return "no process";
4752 obj
= Fsymbol_name (Fprocess_status (obj
));
4756 case 't': /* indicate TEXT or BINARY */
4757 #ifdef MODE_LINE_BINARY_TEXT
4758 return MODE_LINE_BINARY_TEXT (b
);
4764 /* coding-system (not including end-of-line format) */
4766 /* coding-system (including end-of-line type) */
4768 int eol_flag
= (c
== 'Z');
4769 char *p
= decode_mode_spec_buf
;
4771 if (! FRAME_WINDOW_P (f
))
4773 /* No need to mention EOL here--the terminal never needs
4774 to do EOL conversion. */
4775 p
= decode_mode_spec_coding (keyboard_coding
.symbol
, p
, 0);
4776 p
= decode_mode_spec_coding (terminal_coding
.symbol
, p
, 0);
4778 p
= decode_mode_spec_coding (b
->buffer_file_coding_system
,
4781 #if 0 /* This proves to be annoying; I think we can do without. -- rms. */
4783 obj
= Fget_buffer_process (Fcurrent_buffer ());
4786 p
= decode_mode_spec_coding (XPROCESS (obj
)->decode_coding_system
,
4788 p
= decode_mode_spec_coding (XPROCESS (obj
)->encode_coding_system
,
4791 #endif /* subprocesses */
4794 return decode_mode_spec_buf
;
4799 return (char *) XSTRING (obj
)->data
;
4804 /* Count up to COUNT lines starting from START / START_BYTE.
4805 But don't go beyond LIMIT_BYTE.
4806 Return the number of lines thus found (always nonnegative).
4808 Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */
4811 display_count_lines (start
, start_byte
, limit_byte
, count
, byte_pos_ptr
)
4812 int start
, start_byte
, limit_byte
, count
;
4815 register unsigned char *cursor
;
4816 unsigned char *base
;
4818 register int ceiling
;
4819 register unsigned char *ceiling_addr
;
4820 int orig_count
= count
;
4822 /* If we are not in selective display mode,
4823 check only for newlines. */
4824 int selective_display
= (!NILP (current_buffer
->selective_display
)
4825 && !INTEGERP (current_buffer
->selective_display
));
4829 while (start_byte
< limit_byte
)
4831 ceiling
= BUFFER_CEILING_OF (start_byte
);
4832 ceiling
= min (limit_byte
- 1, ceiling
);
4833 ceiling_addr
= BYTE_POS_ADDR (ceiling
) + 1;
4834 base
= (cursor
= BYTE_POS_ADDR (start_byte
));
4837 if (selective_display
)
4838 while (*cursor
!= '\n' && *cursor
!= 015 && ++cursor
!= ceiling_addr
)
4841 while (*cursor
!= '\n' && ++cursor
!= ceiling_addr
)
4844 if (cursor
!= ceiling_addr
)
4848 start_byte
+= cursor
- base
+ 1;
4849 *byte_pos_ptr
= start_byte
;
4853 if (++cursor
== ceiling_addr
)
4859 start_byte
+= cursor
- base
;
4864 while (start_byte
> limit_byte
)
4866 ceiling
= BUFFER_FLOOR_OF (start_byte
- 1);
4867 ceiling
= max (limit_byte
, ceiling
);
4868 ceiling_addr
= BYTE_POS_ADDR (ceiling
) - 1;
4869 base
= (cursor
= BYTE_POS_ADDR (start_byte
- 1) + 1);
4872 if (selective_display
)
4873 while (--cursor
!= ceiling_addr
4874 && *cursor
!= '\n' && *cursor
!= 015)
4877 while (--cursor
!= ceiling_addr
&& *cursor
!= '\n')
4880 if (cursor
!= ceiling_addr
)
4884 start_byte
+= cursor
- base
+ 1;
4885 *byte_pos_ptr
= start_byte
;
4886 /* When scanning backwards, we should
4887 not count the newline posterior to which we stop. */
4888 return - orig_count
- 1;
4894 /* Here we add 1 to compensate for the last decrement
4895 of CURSOR, which took it past the valid range. */
4896 start_byte
+= cursor
- base
+ 1;
4900 *byte_pos_ptr
= limit_byte
;
4903 return - orig_count
+ count
;
4904 return orig_count
- count
;
4908 /* Display STRING on one line of window W, starting at HPOS.
4909 Display at position VPOS. Caller should have done get_display_line.
4910 If VPOS == -1, display it as the current frame's title.
4911 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
4913 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
4915 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
4916 MAXCOL is the last column ok to end at. Truncate here.
4917 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
4918 Both count from the left edge of the frame, as does HPOS.
4919 The right edge of W is an implicit maximum.
4920 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
4922 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
4923 at the place where the current window ends in this line
4924 and not display anything beyond there. Otherwise, only MAXCOL
4925 controls where to stop output.
4927 MULTIBYTE can be 0 meaning do not display multibyte chars,
4928 1 meaning do display them, or -1 meaning obey the current buffer's
4929 value of enable_multibyte_characters.
4931 Returns ending hpos. */
4934 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
4935 obey_window_width
, mincol
, maxcol
, multibyte
)
4937 unsigned char *string
;
4941 int obey_window_width
;
4948 int hscroll
= XINT (w
->hscroll
);
4949 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
4950 register GLYPH
*start
;
4951 register GLYPH
*end
;
4952 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4953 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
4954 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
4955 int window_width
= XFASTINT (w
->width
);
4957 /* Use the standard display table, not the window's display table.
4958 We don't want the mode line in rot13. */
4959 register struct Lisp_Char_Table
*dp
= 0;
4962 if (multibyte
== -1)
4963 multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
4964 /* Now multibyte is 1 if we should display multibyte characters. */
4966 if (DISP_TABLE_P (Vstandard_display_table
))
4967 dp
= XCHAR_TABLE (Vstandard_display_table
);
4969 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
4972 start
= desired_glyphs
->glyphs
[vpos
];
4974 if (obey_window_width
)
4976 start
+= XFASTINT (w
->left
);
4977 end
= start
+ window_width
- (truncate
!= 0);
4979 if (!WINDOW_RIGHTMOST_P (w
))
4981 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
4985 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
4988 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
4993 if (! obey_window_width
4994 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
4995 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
4997 /* Store 0 in charstart for these columns. */
4998 for (i
= (hpos
>= 0 ? hpos
: 0); i
< end
- p1start
+ hpos
; i
++)
4999 desired_glyphs
->charstarts
[vpos
][i
] = 0;
5001 if (maxcol
>= 0 && mincol
> maxcol
)
5005 /* We need this value for multibyte characters. */
5006 length
= strlen (string
);
5008 /* We set truncated to 1 if we get stopped by trying to pass END
5009 (that is, trying to pass MAXCOL.) */
5018 c
= STRING_CHAR_AND_LENGTH (string
, length
, len
);
5020 c
= *string
, len
= 1;
5022 string
+= len
, length
-= len
;
5030 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
5032 p1
= copy_part_of_rope (f
, p1
, start
,
5033 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
5034 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
5037 else if (c
>= 040 && c
< 0177)
5047 if (p1
>= start
&& p1
< end
)
5051 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
5053 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
5057 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
5058 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
5059 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
5062 if (p1
>= start
&& p1
< end
)
5068 /* C is a control character or a binary byte data. */
5071 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
5072 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
5073 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
5076 if (p1
>= start
&& p1
< end
)
5077 *p1
= (c
>> 6) + '0';
5079 if (p1
>= start
&& p1
< end
)
5080 *p1
= (7 & (c
>> 3)) + '0';
5082 if (p1
>= start
&& p1
< end
)
5083 *p1
= (7 & c
) + '0';
5088 /* C is a multibyte character. */
5089 int charset
= CHAR_CHARSET (c
);
5090 int columns
= (charset
== CHARSET_COMPOSITION
5091 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
5092 : CHARSET_WIDTH (charset
));
5096 /* Since we can't show the left part of C, fill all
5097 columns with spaces. */
5098 columns
-= start
- p1
;
5107 else if (p1
+ columns
> end
)
5109 /* Since we can't show the right part of C, fill all
5110 columns with TRUNCATE if TRUNCATE is specified. */
5114 *p1
++ = fix_glyph (f
, truncate
, 0);
5115 /* And tell the line is truncated. */
5122 /* We can show the whole glyph of C. */
5125 *p1
++ = c
| GLYPH_MASK_PADDING
;
5133 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
5135 else if (mincol
>= 0)
5137 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
5143 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
5145 if (len
> desired_glyphs
->used
[vpos
])
5146 desired_glyphs
->used
[vpos
] = len
;
5147 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
5153 /* This is like a combination of memq and assq.
5154 Return 1 if PROPVAL appears as an element of LIST
5155 or as the car of an element of LIST.
5156 If PROPVAL is a list, compare each element against LIST
5157 in that way, and return 1 if any element of PROPVAL is found in LIST.
5159 This function cannot quit. */
5162 invisible_p (propval
, list
)
5163 register Lisp_Object propval
;
5166 register Lisp_Object tail
, proptail
;
5167 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5169 register Lisp_Object tem
;
5170 tem
= XCONS (tail
)->car
;
5171 if (EQ (propval
, tem
))
5173 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5176 if (CONSP (propval
))
5177 for (proptail
= propval
; CONSP (proptail
);
5178 proptail
= XCONS (proptail
)->cdr
)
5180 Lisp_Object propelt
;
5181 propelt
= XCONS (proptail
)->car
;
5182 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5184 register Lisp_Object tem
;
5185 tem
= XCONS (tail
)->car
;
5186 if (EQ (propelt
, tem
))
5188 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5195 /* Return 1 if PROPVAL appears as the car of an element of LIST
5196 and the cdr of that element is non-nil.
5197 If PROPVAL is a list, check each element of PROPVAL in that way,
5198 and the first time some element is found,
5199 return 1 if the cdr of that element is non-nil.
5201 This function cannot quit. */
5204 invisible_ellipsis_p (propval
, list
)
5205 register Lisp_Object propval
;
5208 register Lisp_Object tail
, proptail
;
5209 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5211 register Lisp_Object tem
;
5212 tem
= XCONS (tail
)->car
;
5213 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5214 return ! NILP (XCONS (tem
)->cdr
);
5216 if (CONSP (propval
))
5217 for (proptail
= propval
; CONSP (proptail
);
5218 proptail
= XCONS (proptail
)->cdr
)
5220 Lisp_Object propelt
;
5221 propelt
= XCONS (proptail
)->car
;
5222 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5224 register Lisp_Object tem
;
5225 tem
= XCONS (tail
)->car
;
5226 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5227 return ! NILP (XCONS (tem
)->cdr
);
5236 staticpro (&Qmenu_bar_update_hook
);
5237 Qmenu_bar_update_hook
= intern ("menu-bar-update-hook");
5239 staticpro (&Qoverriding_terminal_local_map
);
5240 Qoverriding_terminal_local_map
= intern ("overriding-terminal-local-map");
5242 staticpro (&Qoverriding_local_map
);
5243 Qoverriding_local_map
= intern ("overriding-local-map");
5245 staticpro (&Qwindow_scroll_functions
);
5246 Qwindow_scroll_functions
= intern ("window-scroll-functions");
5248 staticpro (&Qredisplay_end_trigger_functions
);
5249 Qredisplay_end_trigger_functions
= intern ("redisplay-end-trigger-functions");
5251 staticpro (&last_arrow_position
);
5252 staticpro (&last_arrow_string
);
5253 last_arrow_position
= Qnil
;
5254 last_arrow_string
= Qnil
;
5256 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
5257 "String (or mode line construct) included (normally) in `mode-line-format'.");
5258 Vglobal_mode_string
= Qnil
;
5260 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
5261 "Marker for where to display an arrow on top of the buffer text.\n\
5262 This must be the beginning of a line in order to work.\n\
5263 See also `overlay-arrow-string'.");
5264 Voverlay_arrow_position
= Qnil
;
5266 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
5267 "String to display as an arrow. See also `overlay-arrow-position'.");
5268 Voverlay_arrow_string
= Qnil
;
5270 DEFVAR_INT ("scroll-step", &scroll_step
,
5271 "*The number of lines to try scrolling a window by when point moves out.\n\
5272 If that fails to bring point back on frame, point is centered instead.\n\
5273 If this is zero, point is always centered after it moves off frame.");
5275 DEFVAR_INT ("scroll-conservatively", &scroll_conservatively
,
5276 "*Scroll up to this many lines, to bring point back on screen.");
5277 scroll_conservatively
= 0;
5279 DEFVAR_INT ("scroll-margin", &scroll_margin
,
5280 "*Number of lines of margin at the top and bottom of a window.\n\
5281 Recenter the window whenever point gets within this many lines\n\
5282 of the top or bottom of the window.");
5285 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
5287 DEFVAR_BOOL ("truncate-partial-width-windows",
5288 &truncate_partial_width_windows
,
5289 "*Non-nil means truncate lines in all windows less than full frame wide.");
5290 truncate_partial_width_windows
= 1;
5292 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
5293 "*Non-nil means use inverse video for the mode line.");
5294 mode_line_inverse_video
= 1;
5296 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
5297 "*Maximum buffer size for which line number should be displayed.");
5298 line_number_display_limit
= 1000000;
5300 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
5301 "*Non-nil means highlight region even in nonselected windows.");
5302 highlight_nonselected_windows
= 0;
5304 DEFVAR_BOOL ("multiple-frames", &multiple_frames
,
5305 "Non-nil if more than one frame is visible on this display.\n\
5306 Minibuffer-only frames don't count, but iconified frames do.\n\
5307 This variable is not guaranteed to be accurate except while processing\n\
5308 `frame-title-format' and `icon-title-format'.");
5310 DEFVAR_LISP ("frame-title-format", &Vframe_title_format
,
5311 "Template for displaying the titlebar of visible frames.\n\
5312 \(Assuming the window manager supports this feature.)\n\
5313 This variable has the same structure as `mode-line-format' (which see),\n\
5314 and is used only on frames for which no explicit name has been set\n\
5315 \(see `modify-frame-parameters').");
5316 DEFVAR_LISP ("icon-title-format", &Vicon_title_format
,
5317 "Template for displaying the titlebar of an iconified frame.\n\
5318 \(Assuming the window manager supports this feature.)\n\
5319 This variable has the same structure as `mode-line-format' (which see),\n\
5320 and is used only on frames for which no explicit name has been set\n\
5321 \(see `modify-frame-parameters').");
5323 = Vframe_title_format
5324 = Fcons (intern ("multiple-frames"),
5325 Fcons (build_string ("%b"),
5326 Fcons (Fcons (build_string (""),
5327 Fcons (intern ("invocation-name"),
5328 Fcons (build_string ("@"),
5329 Fcons (intern ("system-name"),
5333 DEFVAR_LISP ("message-log-max", &Vmessage_log_max
,
5334 "Maximum number of lines to keep in the message log buffer.\n\
5335 If nil, disable message logging. If t, log messages but don't truncate\n\
5336 the buffer when it becomes large.");
5337 XSETFASTINT (Vmessage_log_max
, 50);
5339 DEFVAR_LISP ("window-size-change-functions", &Vwindow_size_change_functions
,
5340 "Functions called before redisplay, if window sizes have changed.\n\
5341 The value should be a list of functions that take one argument.\n\
5342 Just before redisplay, for each frame, if any of its windows have changed\n\
5343 size since the last redisplay, or have been split or deleted,\n\
5344 all the functions in the list are called, with the frame as argument.");
5345 Vwindow_size_change_functions
= Qnil
;
5347 DEFVAR_LISP ("window-scroll-functions", &Vwindow_scroll_functions
,
5348 "List of functions to call before redisplaying a window with scrolling.\n\
5349 Each function is called with two arguments, the window\n\
5350 and its new display-start position. Note that the value of `window-end'\n\
5351 is not valid when these functions are called.");
5352 Vwindow_scroll_functions
= Qnil
;
5354 DEFVAR_INT ("minibuffer-scroll-overlap", &minibuffer_scroll_overlap
,
5355 "*Number of characters of overlap when scrolling a one-line window.\n\
5356 This commonly affects the minibuffer window, hence the name of the variable.");
5357 minibuffer_scroll_overlap
= 20;
5360 /* initialize the window system */
5363 Lisp_Object root_window
;
5364 #ifndef COMPILER_REGISTER_BUG
5366 #endif /* COMPILER_REGISTER_BUG */
5367 struct window
*mini_w
;
5369 this_line_bufpos
= 0;
5371 mini_w
= XWINDOW (minibuf_window
);
5372 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
5374 echo_area_glyphs
= 0;
5375 previous_echo_glyphs
= 0;
5377 if (!noninteractive
)
5379 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
5380 XSETFASTINT (XWINDOW (root_window
)->top
, FRAME_MENU_BAR_LINES (f
));
5381 set_window_height (root_window
,
5382 FRAME_HEIGHT (f
) - 1 - FRAME_MENU_BAR_LINES (f
),
5384 XSETFASTINT (mini_w
->top
, FRAME_HEIGHT (f
) - 1);
5385 set_window_height (minibuf_window
, 1, 0);
5387 XSETFASTINT (XWINDOW (root_window
)->width
, FRAME_WIDTH (f
));
5388 XSETFASTINT (mini_w
->width
, FRAME_WIDTH (f
));