1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 97, 1998
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 /*#include <ctype.h>*/
31 #include "dispextern.h"
38 #include "termhooks.h"
39 #include "intervals.h"
44 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
45 extern void set_frame_menubar ();
46 extern int pending_menu_activation
;
49 extern int interrupt_input
;
50 extern int command_loop_level
;
52 extern int minibuffer_auto_raise
;
54 extern Lisp_Object Qface
;
56 extern Lisp_Object Voverriding_local_map
;
57 extern Lisp_Object Voverriding_local_map_menu_flag
;
59 Lisp_Object Qoverriding_local_map
, Qoverriding_terminal_local_map
;
60 Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
61 Lisp_Object Qredisplay_end_trigger_functions
;
63 /* Nonzero means print newline to stdout before next minibuffer message. */
65 int noninteractive_need_newline
;
67 /* Nonzero means print newline to message log before next message. */
69 static int message_log_need_newline
;
71 #define min(a, b) ((a) < (b) ? (a) : (b))
72 #define max(a, b) ((a) > (b) ? (a) : (b))
73 #define minmax(floor, val, ceil) \
74 ((val) < (floor) ? (floor) : (val) > (ceil) ? (ceil) : (val))
76 /* The buffer position of the first character appearing
77 entirely or partially on the current frame line.
78 Or zero, which disables the optimization for the current frame line. */
79 static int this_line_bufpos
;
81 /* Number of characters past the end of this line,
82 including the terminating newline */
83 static int this_line_endpos
;
85 /* The vertical position of this frame line. */
86 static int this_line_vpos
;
88 /* Hpos value for start of display on this frame line.
89 Usually zero, but negative if first character really began
91 static int this_line_start_hpos
;
93 /* Buffer that this_line variables are describing. */
94 static struct buffer
*this_line_buffer
;
96 /* Value of echo_area_glyphs when it was last acted on.
97 If this is nonzero, there is a message on the frame
98 in the minibuffer and it should be erased as soon
99 as it is no longer requested to appear. */
100 char *previous_echo_glyphs
;
102 /* Nonzero means truncate lines in all windows less wide than the frame */
103 int truncate_partial_width_windows
;
105 /* Nonzero means we have more than one non-minibuffer-only frame.
106 Not guaranteed to be accurate except while parsing frame-title-format. */
109 Lisp_Object Vglobal_mode_string
;
111 /* Marker for where to display an arrow on top of the buffer text. */
112 Lisp_Object Voverlay_arrow_position
;
114 /* String to display for the arrow. */
115 Lisp_Object Voverlay_arrow_string
;
117 /* Values of those variables at last redisplay.
118 However, if Voverlay_arrow_position is a marker,
119 last_arrow_position is its numerical position. */
120 static Lisp_Object last_arrow_position
, last_arrow_string
;
122 /* Like mode-line-format, but for the titlebar on a visible frame. */
123 Lisp_Object Vframe_title_format
;
125 /* Like mode-line-format, but for the titlebar on an iconified frame. */
126 Lisp_Object Vicon_title_format
;
128 /* List of functions to call when a window's size changes. These
129 functions get one arg, a frame on which one or more windows' sizes
131 static Lisp_Object Vwindow_size_change_functions
;
133 Lisp_Object Qmenu_bar_update_hook
;
135 /* Nonzero if overlay arrow has been displayed once in this window. */
136 static int overlay_arrow_seen
;
138 /* Nonzero if visible end of buffer has already been displayed once
139 in this window. (We need this variable in case there are overlay
140 strings that get displayed there.) */
141 static int zv_strings_seen
;
143 /* Nonzero means highlight the region even in nonselected windows. */
144 static int highlight_nonselected_windows
;
146 /* If cursor motion alone moves point off frame,
147 Try scrolling this many lines up or down if that will bring it back. */
148 static int scroll_step
;
150 /* Non-0 means scroll just far enough to bring point back on the screen,
152 static int scroll_conservatively
;
154 /* Recenter the window whenever point gets within this many lines
155 of the top or bottom of the window. */
158 /* Number of characters of overlap to show,
159 when scrolling a one-line window such as a minibuffer. */
160 static int minibuffer_scroll_overlap
;
162 /* Nonzero if try_window_id has made blank lines at window bottom
163 since the last redisplay that paused */
164 static int blank_end_of_window
;
166 /* Number of windows showing the buffer of the selected window
167 (or another buffer with the same base buffer).
168 keyboard.c refers to this. */
171 /* display_text_line sets these to the frame position (origin 0) of point,
172 whether the window is selected or not.
173 Set one to -1 first to determine whether point was found afterwards. */
175 static int cursor_vpos
;
176 static int cursor_hpos
;
178 static int debug_end_pos
;
180 /* Nonzero means display mode line highlighted */
181 int mode_line_inverse_video
;
183 static void redisplay_internal ();
184 static int message_log_check_duplicate ();
185 static void echo_area_display ();
186 void mark_window_display_accurate ();
187 static void redisplay_windows ();
188 static void redisplay_window ();
189 static void update_menu_bar ();
190 static void try_window ();
191 static int try_window_id ();
192 static struct position
*display_text_line ();
193 static void display_mode_line ();
194 static int display_mode_element ();
195 static char *decode_mode_spec ();
196 static int display_string ();
197 static void display_menu_bar ();
198 static int display_count_lines ();
200 /* Prompt to display in front of the minibuffer contents */
201 Lisp_Object minibuf_prompt
;
203 /* Width in columns of current minibuffer prompt. */
204 int minibuf_prompt_width
;
206 /* Message to display instead of minibuffer contents
207 This is what the functions error and message make,
208 and command echoing uses it as well.
209 It overrides the minibuf_prompt as well as the buffer. */
210 char *echo_area_glyphs
;
212 /* This is the length of the message in echo_area_glyphs. */
213 int echo_area_glyphs_length
;
215 /* This is the window where the echo area message was displayed.
216 It is always a minibuffer window, but it may not be the
217 same window currently active as a minibuffer. */
218 Lisp_Object echo_area_window
;
220 /* Nonzero means multibyte characters were enabled when the echo area
221 message was specified. */
222 int message_enable_multibyte
;
224 /* true iff we should redraw the mode lines on the next redisplay */
225 int update_mode_lines
;
227 /* Smallest number of characters before the gap
228 at any time since last redisplay that finished.
229 Valid for current buffer when try_window_id can be called. */
232 /* Smallest number of characters after the gap
233 at any time since last redisplay that finished.
234 Valid for current buffer when try_window_id can be called. */
237 /* MODIFF as of last redisplay that finished;
238 if it matches MODIFF, and overlay_unchanged_modified
239 matches OVERLAY_MODIFF, that means beg_unchanged and end_unchanged
240 contain no useful information */
241 int unchanged_modified
;
243 /* OVERLAY_MODIFF as of last redisplay that finished. */
244 int overlay_unchanged_modified
;
246 /* Nonzero if window sizes or contents have changed
247 since last redisplay that finished */
248 int windows_or_buffers_changed
;
250 /* Nonzero after display_mode_line if %l was used
251 and it displayed a line number. */
252 int line_number_displayed
;
254 /* Maximum buffer size for which to display line numbers. */
255 static int line_number_display_limit
;
257 /* Number of lines to keep in the message log buffer.
258 t means infinite. nil means don't log at all. */
259 Lisp_Object Vmessage_log_max
;
261 #define COERCE_MARKER(X) \
262 (MARKERP ((X)) ? Fmarker_position (X) : (X))
264 static int pos_tab_offset
P_ ((struct window
*, int, int));
266 /* Output a newline in the *Messages* buffer if "needs" one. */
269 message_log_maybe_newline ()
271 if (message_log_need_newline
)
272 message_dolog ("", 0, 1, 0);
276 /* Add a string to the message log, optionally terminated with a newline.
277 This function calls low-level routines in order to bypass text property
278 hooks, etc. which might not be safe to run.
279 MULTIBYTE, if nonzero, means interpret the contents of M as multibyte. */
282 message_dolog (m
, len
, nlflag
, multibyte
)
284 int len
, nlflag
, multibyte
;
286 if (!NILP (Vmessage_log_max
))
288 struct buffer
*oldbuf
;
289 Lisp_Object oldpoint
, oldbegv
, oldzv
;
290 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
291 int point_at_end
= 0;
294 oldbuf
= current_buffer
;
295 Fset_buffer (Fget_buffer_create (build_string ("*Messages*")));
296 current_buffer
->undo_list
= Qt
;
298 oldpoint
= Fpoint_marker ();
299 oldbegv
= Fpoint_min_marker ();
300 oldzv
= Fpoint_max_marker ();
308 BEGV_BYTE
= BEG_BYTE
;
311 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
313 /* Insert the string--maybe converting multibyte to single byte
314 or vice versa, so that all the text fits the buffer. */
316 && NILP (current_buffer
->enable_multibyte_characters
))
318 int c
, i
= 0, nbytes
;
319 /* Convert a multibyte string to single-byte
320 for the *Message* buffer. */
323 c
= STRING_CHAR (m
+ i
, len
- i
);
324 i
+= XFASTINT (Fchar_bytes (make_number (c
)));
325 /* Truncate the character to its last byte--we can only hope
326 the user is happy with the character he gets,
327 since if it isn't right, there is no way to do it right. */
333 && ! NILP (current_buffer
->enable_multibyte_characters
))
336 /* Convert a single-byte string to multibyte
337 for the *Message* buffer. */
340 int c
= unibyte_char_to_multibyte (m
[i
++]);
345 insert_1 (m
, len
, 1, 0, 0);
349 int this_bol
, this_bol_byte
, prev_bol
, prev_bol_byte
, dup
;
350 insert_1 ("\n", 1, 1, 0, 0);
352 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
, -2, 0);
354 this_bol_byte
= PT_BYTE
;
358 scan_newline (PT
, PT_BYTE
, BEG
, BEG_BYTE
, -2, 0);
360 prev_bol_byte
= PT_BYTE
;
362 dup
= message_log_check_duplicate (prev_bol
, this_bol
,
363 prev_bol_byte
, this_bol_byte
);
366 del_range_both (prev_bol
, prev_bol_byte
,
367 this_bol
, this_bol_byte
, 0);
373 /* If you change this format, don't forget to also
374 change message_log_check_duplicate. */
375 sprintf (dupstr
, " [%d times]", dup
);
376 duplen
= strlen (dupstr
);
377 TEMP_SET_PT_BOTH (Z
- 1, Z_BYTE
- 1);
378 insert_1 (dupstr
, duplen
, 1, 0, 1);
383 if (NATNUMP (Vmessage_log_max
))
385 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
,
386 -XFASTINT (Vmessage_log_max
) - 1, 0);
387 del_range_both (BEG
, BEG_BYTE
, PT
, PT_BYTE
, 0);
390 BEGV
= XMARKER (oldbegv
)->charpos
;
391 BEGV_BYTE
= marker_byte_position (oldbegv
);
400 ZV
= XMARKER (oldzv
)->charpos
;
401 ZV_BYTE
= marker_byte_position (oldzv
);
405 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
407 Fgoto_char (oldpoint
);
409 free_marker (oldpoint
);
410 free_marker (oldbegv
);
413 set_buffer_internal (oldbuf
);
414 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
415 message_log_need_newline
= !nlflag
;
419 /* We are at the end of the buffer after just having inserted a newline.
420 (Note: We depend on the fact we won't be crossing the gap.)
421 Check to see if the most recent message looks a lot like the previous one.
422 Return 0 if different, 1 if the new one should just replace it, or a
423 value N > 1 if we should also append " [N times]". */
426 message_log_check_duplicate (prev_bol
, prev_bol_byte
, this_bol
, this_bol_byte
)
427 int prev_bol
, this_bol
;
428 int prev_bol_byte
, this_bol_byte
;
431 int len
= Z
- 1 - this_bol
;
433 unsigned char *p1
= BUF_BYTE_ADDRESS (current_buffer
, prev_bol_byte
);
434 unsigned char *p2
= BUF_BYTE_ADDRESS (current_buffer
, this_bol_byte
);
436 for (i
= 0; i
< len
; i
++)
438 if (i
>= 3 && p1
[i
-3] == '.' && p1
[i
-2] == '.' && p1
[i
-1] == '.'
447 if (*p1
++ == ' ' && *p1
++ == '[')
450 while (*p1
>= '0' && *p1
<= '9')
451 n
= n
* 10 + *p1
++ - '0';
452 if (strncmp (p1
, " times]\n", 8) == 0)
458 /* Display an echo area message M with a specified length of LEN chars.
459 The string may include null characters. If M is 0, clear out any
460 existing message, and let the minibuffer text show through.
462 The buffer M must continue to exist until after the echo area
463 gets cleared or some other message gets displayed there.
465 Do not pass text that is stored in a Lisp string.
466 Do not pass text in a buffer that was alloca'd. */
469 message2 (m
, len
, multibyte
)
474 /* First flush out any partial line written with print. */
475 message_log_maybe_newline ();
477 message_dolog (m
, len
, 1, multibyte
);
478 message2_nolog (m
, len
, multibyte
);
482 /* The non-logging counterpart of message2. */
485 message2_nolog (m
, len
, multibyte
)
489 message_enable_multibyte
= multibyte
;
493 if (noninteractive_need_newline
)
495 noninteractive_need_newline
= 0;
497 fwrite (m
, len
, 1, stderr
);
498 if (cursor_in_echo_area
== 0)
499 fprintf (stderr
, "\n");
502 /* A null message buffer means that the frame hasn't really been
503 initialized yet. Error messages get reported properly by
504 cmd_error, so this must be just an informative message; toss it. */
505 else if (INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
507 Lisp_Object mini_window
;
510 /* Get the frame containing the minibuffer
511 that the selected frame is using. */
512 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
513 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
515 FRAME_SAMPLE_VISIBILITY (f
);
516 if (FRAME_VISIBLE_P (selected_frame
)
517 && ! FRAME_VISIBLE_P (f
))
518 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (mini_window
)));
522 echo_area_glyphs
= m
;
523 echo_area_glyphs_length
= len
;
525 if (minibuffer_auto_raise
)
526 Fraise_frame (WINDOW_FRAME (XWINDOW (mini_window
)));
529 echo_area_glyphs
= previous_echo_glyphs
= 0;
531 do_pending_window_change ();
532 echo_area_display ();
533 update_frame (f
, 1, 1);
534 do_pending_window_change ();
535 if (frame_up_to_date_hook
!= 0 && ! gc_in_progress
)
536 (*frame_up_to_date_hook
) (f
);
540 /* Display in echo area the null-terminated ASCII-only string M.
541 If M is 0, clear out any existing message,
542 and let the minibuffer text show through.
544 The string M must continue to exist until after the echo area
545 gets cleared or some other message gets displayed there.
547 Do not pass text that is stored in a Lisp string.
548 Do not pass text in a buffer that was alloca'd. */
554 message2 (m
, (m
? strlen (m
) : 0), 0);
561 message2_nolog (m
, (m
? strlen (m
) : 0), 0);
564 /* Display a message M which contains a single %s
565 which gets replaced with STRING. */
568 message_with_string (m
, string
, log
)
577 if (noninteractive_need_newline
)
579 noninteractive_need_newline
= 0;
580 fprintf (stderr
, m
, XSTRING (string
)->data
);
581 if (cursor_in_echo_area
== 0)
582 fprintf (stderr
, "\n");
586 else if (INTERACTIVE
)
588 /* The frame whose minibuffer we're going to display the message on.
589 It may be larger than the selected frame, so we need
590 to use its buffer, not the selected frame's buffer. */
591 Lisp_Object mini_window
;
594 /* Get the frame containing the minibuffer
595 that the selected frame is using. */
596 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
597 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
599 /* A null message buffer means that the frame hasn't really been
600 initialized yet. Error messages get reported properly by
601 cmd_error, so this must be just an informative message; toss it. */
602 if (FRAME_MESSAGE_BUF (f
))
606 a
[0] = (char *) XSTRING (string
)->data
;
608 len
= doprnt (FRAME_MESSAGE_BUF (f
),
609 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
612 message2 (FRAME_MESSAGE_BUF (f
), len
,
613 STRING_MULTIBYTE (string
));
615 message2_nolog (FRAME_MESSAGE_BUF (f
), len
,
616 STRING_MULTIBYTE (string
));
618 /* Print should start at the beginning of the message
620 message_buf_print
= 0;
625 /* Truncate what will be displayed in the echo area
626 the next time we display it--but don't redisplay it now. */
629 truncate_echo_area (len
)
632 /* A null message buffer means that the frame hasn't really been
633 initialized yet. Error messages get reported properly by
634 cmd_error, so this must be just an informative message; toss it. */
635 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
636 echo_area_glyphs_length
= len
;
639 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
640 zero if being used by message. */
641 int message_buf_print
;
643 /* Dump an informative message to the minibuf. If M is 0, clear out
644 any existing message, and let the minibuffer text show through. */
648 message (m
, a1
, a2
, a3
)
650 EMACS_INT a1
, a2
, a3
;
656 if (noninteractive_need_newline
)
658 noninteractive_need_newline
= 0;
659 fprintf (stderr
, m
, a1
, a2
, a3
);
660 if (cursor_in_echo_area
== 0)
661 fprintf (stderr
, "\n");
665 else if (INTERACTIVE
)
667 /* The frame whose minibuffer we're going to display the message on.
668 It may be larger than the selected frame, so we need
669 to use its buffer, not the selected frame's buffer. */
670 Lisp_Object mini_window
;
673 /* Get the frame containing the minibuffer
674 that the selected frame is using. */
675 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
676 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
678 /* A null message buffer means that the frame hasn't really been
679 initialized yet. Error messages get reported properly by
680 cmd_error, so this must be just an informative message; toss it. */
681 if (FRAME_MESSAGE_BUF (f
))
692 len
= doprnt (FRAME_MESSAGE_BUF (f
),
693 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
695 len
= doprnt (FRAME_MESSAGE_BUF (f
),
696 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3,
698 #endif /* NO_ARG_ARRAY */
700 message2 (FRAME_MESSAGE_BUF (f
), len
, 0);
705 /* Print should start at the beginning of the message
707 message_buf_print
= 0;
712 /* The non-logging version of message. */
714 message_nolog (m
, a1
, a2
, a3
)
716 EMACS_INT a1
, a2
, a3
;
718 Lisp_Object old_log_max
;
719 old_log_max
= Vmessage_log_max
;
720 Vmessage_log_max
= Qnil
;
721 message (m
, a1
, a2
, a3
);
722 Vmessage_log_max
= old_log_max
;
728 message2 (echo_area_glyphs
, echo_area_glyphs_length
,
729 ! NILP (current_buffer
->enable_multibyte_characters
));
737 Lisp_Object mini_window
;
739 /* Choose the minibuffer window for this display.
740 It is the minibuffer window used by the selected frame. */
741 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
742 /* This is the frame that window is in. */
743 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
745 if (! FRAME_VISIBLE_P (f
))
750 redraw_garbaged_frames ();
754 if (echo_area_glyphs
|| minibuf_level
== 0)
758 echo_area_window
= mini_window
;
760 vpos
= XFASTINT (XWINDOW (mini_window
)->top
);
761 get_display_line (f
, vpos
, 0);
763 /* Make sure the columns that overlap a left-hand scroll bar
765 for (i
= 0; i
< FRAME_LEFT_SCROLL_BAR_WIDTH (f
); i
++)
766 f
->desired_glyphs
->glyphs
[vpos
][i
] = SPACEGLYPH
;
768 display_string (XWINDOW (mini_window
), vpos
,
769 echo_area_glyphs
? echo_area_glyphs
: "",
770 echo_area_glyphs
? echo_area_glyphs_length
: -1,
771 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
773 FRAME_WIDTH (f
) + FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
774 message_enable_multibyte
);
776 #if 0 /* This just gets in the way. update_frame does the job. */
777 /* If desired cursor location is on this line, put it at end of text */
778 if (cursor_in_echo_area
)
779 FRAME_CURSOR_Y (f
) = vpos
;
780 if (FRAME_CURSOR_Y (f
) == vpos
)
781 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
784 /* Fill the rest of the minibuffer window with blank lines. */
789 i
< vpos
+ XFASTINT (XWINDOW (mini_window
)->height
); i
++)
791 get_display_line (f
, i
, 0);
792 /* We don't use FRAME_SCROLL_BAR_WIDTH (f) as the starting
793 hpos, because it is good to clear whatever is behind the
794 scroll bar. This does not affect the scroll bar itself. */
795 display_string (XWINDOW (mini_window
), i
,
798 0, FRAME_WIDTH (f
) + FRAME_SCROLL_BAR_WIDTH (f
),
803 else if (!EQ (mini_window
, selected_window
))
804 windows_or_buffers_changed
++;
806 if (EQ (mini_window
, selected_window
))
807 this_line_bufpos
= 0;
809 previous_echo_glyphs
= echo_area_glyphs
;
812 /* Update frame titles. */
814 #ifdef HAVE_WINDOW_SYSTEM
815 static char frame_title_buf
[512];
816 static char *frame_title_ptr
;
819 store_frame_title (str
, mincol
, maxcol
)
824 if (maxcol
< 0 || maxcol
>= sizeof(frame_title_buf
))
825 maxcol
= sizeof (frame_title_buf
);
826 limit
= &frame_title_buf
[maxcol
];
827 while (*str
!= '\0' && frame_title_ptr
< limit
)
828 *frame_title_ptr
++ = *str
++;
829 while (frame_title_ptr
< &frame_title_buf
[mincol
])
830 *frame_title_ptr
++ = ' ';
831 return frame_title_ptr
- frame_title_buf
;
835 x_consider_frame_title (frame
)
841 FRAME_PTR f
= XFRAME (frame
);
843 if (!(FRAME_WINDOW_P (f
) || FRAME_MINIBUF_ONLY_P (f
) || f
->explicit_name
))
846 /* Do we have more than one visible frame on this X display? */
850 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
852 FRAME_PTR tf
= XFRAME (XCONS (tail
)->car
);
854 if (tf
!= f
&& FRAME_KBOARD (tf
) == FRAME_KBOARD (f
)
855 && !FRAME_MINIBUF_ONLY_P (tf
)
856 && (FRAME_VISIBLE_P (tf
) || FRAME_ICONIFIED_P (tf
)))
860 multiple_frames
= CONSP (tail
);
863 obuf
= current_buffer
;
864 Fset_buffer (XWINDOW (f
->selected_window
)->buffer
);
865 fmt
= (FRAME_ICONIFIED_P (f
) ? Vicon_title_format
: Vframe_title_format
);
866 frame_title_ptr
= frame_title_buf
;
867 len
= display_mode_element (XWINDOW (f
->selected_window
), 0, 0, 0,
868 0, sizeof (frame_title_buf
), fmt
);
870 set_buffer_internal (obuf
);
871 /* Set the name only if it's changed. This avoids consing
872 in the common case where it hasn't. (If it turns out that we've
873 already wasted too much time by walking through the list with
874 display_mode_element, then we might need to optimize at a higher
876 if (! STRINGP (f
->name
) || XSTRING (f
->name
)->size_byte
!= len
877 || bcmp (frame_title_buf
, XSTRING (f
->name
)->data
, len
) != 0)
878 x_implicitly_set_name (f
, make_string (frame_title_buf
, len
), Qnil
);
881 #define frame_title_ptr ((char *)0)
882 #define store_frame_title(str, mincol, maxcol) 0
885 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
886 This can call eval. */
891 register struct window
*w
= XWINDOW (selected_window
);
893 struct gcpro gcpro1
, gcpro2
;
895 all_windows
= (update_mode_lines
|| buffer_shared
> 1
896 || windows_or_buffers_changed
);
898 /* Update all frame titles based on their buffer names, etc.
899 We do this before the menu bars so that the buffer-menu
900 will show the up-to-date frame titles.
902 This used to be done after the menu bars, for a reason that
903 was stated as follows but which I do not understand:
904 "We do this after the menu bars so that the frame will first
905 create its menu bar using the name `emacs' if no other name
906 has yet been specified."
907 I think that is no longer a concern. */
908 #ifdef HAVE_WINDOW_SYSTEM
909 if (windows_or_buffers_changed
|| update_mode_lines
)
911 Lisp_Object tail
, frame
;
913 FOR_EACH_FRAME (tail
, frame
)
914 if (FRAME_VISIBLE_P (XFRAME (frame
))
915 || FRAME_ICONIFIED_P (XFRAME (frame
)))
916 x_consider_frame_title (frame
);
920 /* Update the menu bar item lists, if appropriate.
921 This has to be done before any actual redisplay
922 or generation of display lines. */
925 Lisp_Object tail
, frame
;
926 int count
= specpdl_ptr
- specpdl
;
928 record_unwind_protect (Fstore_match_data
, Fmatch_data (Qnil
, Qnil
));
930 FOR_EACH_FRAME (tail
, frame
)
932 /* If a window on this frame changed size,
933 report that to the user and clear the size-change flag. */
934 if (FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)))
936 Lisp_Object functions
;
937 /* Clear flag first in case we get error below. */
938 FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)) = 0;
939 functions
= Vwindow_size_change_functions
;
940 GCPRO2 (tail
, functions
);
941 while (CONSP (functions
))
943 call1 (XCONS (functions
)->car
, frame
);
944 functions
= XCONS (functions
)->cdr
;
949 update_menu_bar (XFRAME (frame
), 0);
953 unbind_to (count
, Qnil
);
956 update_menu_bar (selected_frame
, 1);
958 /* Motif needs this. See comment in xmenu.c.
959 Turn it off when pending_menu_activation is not defined. */
961 pending_menu_activation
= 0;
965 /* Do a frame update, taking possible shortcuts into account.
966 This is the main external entry point for redisplay.
968 If the last redisplay displayed an echo area message and that
969 message is no longer requested, we clear the echo area
970 or bring back the minibuffer if that is in use.
972 Do not call eval from within this function.
973 Calls to eval after the call to echo_area_display would confuse
974 the display_line mechanism and would cause a crash.
975 Calls to eval before that point will work most of the time,
976 but can still lose, because this function
977 can be called from signal handlers; with alarms set up;
978 or with synchronous processes running.
980 See Fcall_process; if you called it from here, it could be
981 entered recursively. */
983 static int do_verify_charstarts
;
985 /* Counter is used to clear the face cache
986 no more than once ever 1000 redisplays. */
987 static int clear_face_cache_count
;
989 /* Record the previous terminal frame we displayed. */
990 static FRAME_PTR previous_terminal_frame
;
995 redisplay_internal (0);
998 /* If PRESERVE_ECHO_AREA is nonzero, it means this redisplay
999 is not in response to any user action; therefore, we should
1000 preserve the echo area. (Actually, our caller does that job.)
1001 Perhaps in the future avoid recentering windows
1002 if it is not necessary; currently that causes some problems. */
1005 redisplay_internal (preserve_echo_area
)
1006 int preserve_echo_area
;
1008 register struct window
*w
= XWINDOW (selected_window
);
1010 int must_finish
= 0;
1012 register int tlbufpos
, tlendpos
;
1013 struct position pos
;
1014 int number_of_visible_frames
;
1019 #ifdef USE_X_TOOLKIT
1020 if (popup_activated ())
1026 if (! FRAME_WINDOW_P (selected_frame
)
1027 && previous_terminal_frame
!= selected_frame
)
1029 /* Since frames on an ASCII terminal share the same display area,
1030 displaying a different frame means redisplay the whole thing. */
1031 windows_or_buffers_changed
++;
1032 SET_FRAME_GARBAGED (selected_frame
);
1033 XSETFRAME (Vterminal_frame
, selected_frame
);
1035 previous_terminal_frame
= selected_frame
;
1037 /* Set the visible flags for all frames.
1038 Do this before checking for resized or garbaged frames; they want
1039 to know if their frames are visible.
1040 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
1042 Lisp_Object tail
, frame
;
1044 number_of_visible_frames
= 0;
1046 FOR_EACH_FRAME (tail
, frame
)
1048 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1050 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1051 number_of_visible_frames
++;
1053 /* Clear out all the display lines in which we will generate the
1054 glyphs to display. */
1055 init_desired_glyphs (XFRAME (frame
));
1059 /* Notice any pending interrupt request to change frame size. */
1060 do_pending_window_change ();
1064 redraw_garbaged_frames ();
1068 prepare_menu_bars ();
1070 if (windows_or_buffers_changed
)
1071 update_mode_lines
++;
1073 /* Detect case that we need to write or remove a star in the mode line. */
1074 if ((SAVE_MODIFF
< MODIFF
) != !NILP (w
->last_had_star
))
1076 w
->update_mode_line
= Qt
;
1077 if (buffer_shared
> 1)
1078 update_mode_lines
++;
1081 /* If %c is in use, update it if needed. */
1082 if (!NILP (w
->column_number_displayed
)
1083 /* This alternative quickly identifies a common case
1084 where no change is needed. */
1085 && !(PT
== XFASTINT (w
->last_point
)
1086 && XFASTINT (w
->last_modified
) >= MODIFF
1087 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1088 && XFASTINT (w
->column_number_displayed
) != current_column ())
1089 w
->update_mode_line
= Qt
;
1091 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
1093 all_windows
= update_mode_lines
|| buffer_shared
> 1;
1095 /* If specs for an arrow have changed, do thorough redisplay
1096 to ensure we remove any arrow that should no longer exist. */
1097 if (! EQ (COERCE_MARKER (Voverlay_arrow_position
), last_arrow_position
)
1098 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
1101 /* Normally the message* functions will have already displayed and
1102 updated the echo area, but the frame may have been trashed, or
1103 the update may have been preempted, so display the echo area
1105 if (echo_area_glyphs
|| previous_echo_glyphs
)
1107 echo_area_display ();
1111 /* If showing region, and mark has changed, must redisplay whole window. */
1112 if (((!NILP (Vtransient_mark_mode
)
1113 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1114 != !NILP (w
->region_showing
))
1115 || (!NILP (w
->region_showing
)
1116 && !EQ (w
->region_showing
,
1117 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
1118 this_line_bufpos
= -1;
1120 tlbufpos
= this_line_bufpos
;
1121 tlendpos
= this_line_endpos
;
1122 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
1123 && !current_buffer
->clip_changed
1124 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
1125 && !FRAME_OBSCURED_P (XFRAME (w
->frame
))
1126 /* Make sure recorded data applies to current buffer, etc */
1127 && this_line_buffer
== current_buffer
1128 && current_buffer
== XBUFFER (w
->buffer
)
1129 && NILP (w
->force_start
)
1130 /* Point must be on the line that we have info recorded about */
1132 && PT
<= Z
- tlendpos
1133 /* All text outside that line, including its final newline,
1134 must be unchanged */
1135 && ((XFASTINT (w
->last_modified
) >= MODIFF
1136 && (XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
))
1137 || (beg_unchanged
>= tlbufpos
- 1
1139 /* If selective display, can't optimize
1140 if the changes start at the beginning of the line. */
1141 && ((INTEGERP (current_buffer
->selective_display
)
1142 && XINT (current_buffer
->selective_display
) > 0
1143 ? (beg_unchanged
>= tlbufpos
1146 && end_unchanged
>= tlendpos
1147 && Z
- GPT
>= tlendpos
)))
1149 int tlbufpos_byte
= CHAR_TO_BYTE (tlbufpos
);
1150 if (tlbufpos
> BEGV
&& FETCH_BYTE (tlbufpos_byte
- 1) != '\n'
1152 || FETCH_BYTE (tlbufpos_byte
) == '\n'))
1153 /* Former continuation line has disappeared by becoming empty */
1155 else if (XFASTINT (w
->last_modified
) < MODIFF
1156 || XFASTINT (w
->last_overlay_modified
) < OVERLAY_MODIFF
1157 || MINI_WINDOW_P (w
))
1159 /* We have to handle the case of continuation around a
1160 wide-column character (See the comment in indent.c around
1163 For instance, in the following case:
1165 -------- Insert --------
1166 K_A_N_\\ `a' K_A_N_a\ `X_' are wide-column chars.
1167 J_I_ ==> J_I_ `^^' are cursors.
1171 As we have to redraw the line above, we should goto cancel. */
1173 struct position val
;
1175 int opoint
= PT
, opoint_byte
= PT_BYTE
;
1177 scan_newline (tlbufpos
, tlbufpos_byte
, BEGV
, BEGV_BYTE
, -1, 1);
1179 val
= *compute_motion (PT
, 0,
1180 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1183 1 << (BITS_PER_SHORT
- 1),
1184 1 << (BITS_PER_SHORT
- 1),
1185 window_internal_width (w
) - 1,
1186 XINT (w
->hscroll
), 0, w
);
1187 SET_PT_BOTH (opoint
, opoint_byte
);
1188 if (val
.hpos
!= this_line_start_hpos
)
1192 overlay_arrow_seen
= 0;
1193 zv_strings_seen
= 0;
1194 display_text_line (w
, tlbufpos
, tlbufpos_byte
,
1195 this_line_vpos
, this_line_start_hpos
,
1196 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
), 0);
1197 /* If line contains point, is not continued,
1198 and ends at same distance from eob as before, we win */
1199 if (cursor_vpos
>= 0 && this_line_bufpos
1200 && this_line_endpos
== tlendpos
)
1202 /* If this is not the window's last line,
1203 we must adjust the charstarts of the lines below. */
1204 if (this_line_vpos
+ 1
1205 < XFASTINT (w
->top
) + window_internal_height (w
))
1207 int left
= WINDOW_LEFT_MARGIN (w
);
1208 int *charstart_next_line
1209 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
1212 if (Z
- tlendpos
== ZV
)
1213 /* This line ends at end of (accessible part of) buffer.
1214 There is no newline to count. */
1215 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
1217 /* This line ends in a newline.
1218 Must take account of the newline and the rest of the
1219 text that follows. */
1220 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
1222 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
1225 if (!WINDOW_FULL_WIDTH_P (w
))
1226 preserve_other_columns (w
);
1232 else if (PT
== XFASTINT (w
->last_point
)
1233 /* Make sure the cursor was last displayed
1234 in this window. Otherwise we have to reposition it. */
1235 && XINT (w
->top
) <= FRAME_CURSOR_Y (selected_frame
)
1236 && (XINT (w
->top
) + XINT (w
->height
)
1237 > FRAME_CURSOR_Y (selected_frame
)))
1241 do_pending_window_change ();
1246 /* If highlighting the region, or if the cursor is in the echo area,
1247 then we can't just move the cursor. */
1248 else if (! (!NILP (Vtransient_mark_mode
)
1249 && !NILP (current_buffer
->mark_active
))
1250 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1251 || highlight_nonselected_windows
)
1252 && NILP (w
->region_showing
)
1253 && !cursor_in_echo_area
)
1255 pos
= *compute_motion (tlbufpos
, 0,
1256 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1258 PT
, 2, - (1 << (BITS_PER_SHORT
- 1)),
1259 window_internal_width (w
) - 1,
1261 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
),
1265 int width
= window_internal_width (w
) - 1;
1266 FRAME_CURSOR_X (selected_frame
)
1267 = WINDOW_LEFT_MARGIN (w
) + minmax (0, pos
.hpos
, width
);
1268 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
1275 /* Text changed drastically or point moved off of line */
1276 cancel_line (this_line_vpos
, selected_frame
);
1279 this_line_bufpos
= 0;
1280 all_windows
|= buffer_shared
> 1;
1282 clear_face_cache_count
++;
1286 Lisp_Object tail
, frame
;
1289 /* Clear the face cache, only when we do a full redisplay
1290 and not too often either. */
1291 if (clear_face_cache_count
> 1000)
1293 clear_face_cache ();
1294 clear_face_cache_count
= 0;
1298 /* Recompute # windows showing selected buffer.
1299 This will be incremented each time such a window is displayed. */
1302 FOR_EACH_FRAME (tail
, frame
)
1304 FRAME_PTR f
= XFRAME (frame
);
1305 if (FRAME_WINDOW_P (f
) || f
== selected_frame
)
1308 /* Mark all the scroll bars to be removed; we'll redeem the ones
1309 we want when we redisplay their windows. */
1310 if (condemn_scroll_bars_hook
)
1311 (*condemn_scroll_bars_hook
) (f
);
1313 if (FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1314 redisplay_windows (FRAME_ROOT_WINDOW (f
), preserve_echo_area
);
1316 /* Any scroll bars which redisplay_windows should have nuked
1317 should now go away. */
1318 if (judge_scroll_bars_hook
)
1319 (*judge_scroll_bars_hook
) (f
);
1323 else if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1325 redisplay_window (selected_window
, 1, preserve_echo_area
);
1326 if (!WINDOW_FULL_WIDTH_P (w
))
1327 preserve_other_columns (w
);
1331 /* Prevent various kinds of signals during display update.
1332 stdio is not robust about handling signals,
1333 which can cause an apparent I/O error. */
1334 if (interrupt_input
)
1344 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1348 if (!FRAMEP (XCONS (tail
)->car
))
1351 f
= XFRAME (XCONS (tail
)->car
);
1353 if ((FRAME_WINDOW_P (f
) || f
== selected_frame
)
1354 && FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1356 pause
|= update_frame (f
, 0, 0);
1359 mark_window_display_accurate (f
->root_window
, 1);
1360 if (frame_up_to_date_hook
!= 0)
1361 (*frame_up_to_date_hook
) (f
);
1368 if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1369 pause
= update_frame (selected_frame
, 0, 0);
1373 /* We may have called echo_area_display at the top of this
1374 function. If the echo area is on another frame, that may
1375 have put text on a frame other than the selected one, so the
1376 above call to update_frame would not have caught it. Catch
1379 Lisp_Object mini_window
;
1380 FRAME_PTR mini_frame
;
1382 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
1383 mini_frame
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
1385 if (mini_frame
!= selected_frame
&& FRAME_WINDOW_P (mini_frame
))
1386 pause
|= update_frame (mini_frame
, 0, 0);
1390 /* If frame does not match, prevent doing single-line-update next time.
1391 Also, don't forget to check every line to update the arrow. */
1394 this_line_bufpos
= 0;
1395 if (!NILP (last_arrow_position
))
1397 last_arrow_position
= Qt
;
1398 last_arrow_string
= Qt
;
1400 /* If we pause after scrolling, some lines in current_frame
1401 may be null, so preserve_other_columns won't be able to
1402 preserve all the vertical-bar separators. So, avoid using it
1404 if (!WINDOW_FULL_WIDTH_P (w
))
1405 update_mode_lines
= 1;
1408 /* Now text on frame agrees with windows, so
1409 put info into the windows for partial redisplay to follow */
1413 register struct buffer
*b
= XBUFFER (w
->buffer
);
1415 blank_end_of_window
= 0;
1416 unchanged_modified
= BUF_MODIFF (b
);
1417 overlay_unchanged_modified
= BUF_OVERLAY_MODIFF (b
);
1418 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
1419 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
1421 XSETFASTINT (w
->last_point
, BUF_PT (b
));
1422 XSETFASTINT (w
->last_point_x
, FRAME_CURSOR_X (selected_frame
));
1423 XSETFASTINT (w
->last_point_y
, FRAME_CURSOR_Y (selected_frame
));
1426 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
1429 b
->clip_changed
= 0;
1430 w
->update_mode_line
= Qnil
;
1431 XSETFASTINT (w
->last_modified
, BUF_MODIFF (b
));
1432 XSETFASTINT (w
->last_overlay_modified
, BUF_OVERLAY_MODIFF (b
));
1434 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1437 /* Record if we are showing a region, so can make sure to
1438 update it fully at next redisplay. */
1439 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1440 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1441 || highlight_nonselected_windows
)
1442 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1443 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1446 w
->window_end_valid
= w
->buffer
;
1447 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1448 last_arrow_string
= Voverlay_arrow_string
;
1449 if (do_verify_charstarts
)
1450 verify_charstarts (w
);
1451 if (frame_up_to_date_hook
!= 0)
1452 (*frame_up_to_date_hook
) (selected_frame
);
1454 update_mode_lines
= 0;
1455 windows_or_buffers_changed
= 0;
1458 /* Start SIGIO interrupts coming again.
1459 Having them off during the code above
1460 makes it less likely one will discard output,
1461 but not impossible, since there might be stuff
1462 in the system buffer here.
1463 But it is much hairier to try to do anything about that. */
1465 if (interrupt_input
)
1469 /* If something has become visible now which was not before,
1470 redisplay again, so that we get them. */
1473 Lisp_Object tail
, frame
;
1476 FOR_EACH_FRAME (tail
, frame
)
1478 int this_is_visible
= 0;
1480 if (XFRAME (frame
)->visible
)
1481 this_is_visible
= 1;
1482 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1483 if (XFRAME (frame
)->visible
)
1484 this_is_visible
= 1;
1486 if (this_is_visible
)
1490 if (new_count
!= number_of_visible_frames
)
1491 windows_or_buffers_changed
++;
1494 /* Change frame size now if a change is pending. */
1495 do_pending_window_change ();
1497 /* If we just did a pending size change, or have additional
1498 visible frames, redisplay again. */
1499 if (windows_or_buffers_changed
&& !pause
)
1503 /* Redisplay, but leave alone any recent echo area message
1504 unless another message has been requested in its place.
1506 This is useful in situations where you need to redisplay but no
1507 user action has occurred, making it inappropriate for the message
1508 area to be cleared. See tracking_off and
1509 wait_reading_process_input for examples of these situations. */
1512 redisplay_preserve_echo_area ()
1514 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
1516 echo_area_glyphs
= previous_echo_glyphs
;
1517 redisplay_internal (1);
1518 echo_area_glyphs
= 0;
1521 redisplay_internal (1);
1525 mark_window_display_accurate (window
, flag
)
1529 register struct window
*w
;
1531 for (;!NILP (window
); window
= w
->next
)
1533 if (!WINDOWP (window
)) abort ();
1534 w
= XWINDOW (window
);
1536 if (!NILP (w
->buffer
))
1538 XSETFASTINT (w
->last_modified
,
1539 !flag
? 0 : BUF_MODIFF (XBUFFER (w
->buffer
)));
1540 XSETFASTINT (w
->last_overlay_modified
,
1541 !flag
? 0 : BUF_OVERLAY_MODIFF (XBUFFER (w
->buffer
)));
1543 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1546 /* Record if we are showing a region, so can make sure to
1547 update it fully at next redisplay. */
1548 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1549 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1550 || highlight_nonselected_windows
)
1551 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1552 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1556 w
->window_end_valid
= w
->buffer
;
1557 w
->update_mode_line
= Qnil
;
1558 if (!NILP (w
->buffer
) && flag
)
1559 XBUFFER (w
->buffer
)->clip_changed
= 0;
1561 if (!NILP (w
->vchild
))
1562 mark_window_display_accurate (w
->vchild
, flag
);
1563 if (!NILP (w
->hchild
))
1564 mark_window_display_accurate (w
->hchild
, flag
);
1569 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1570 last_arrow_string
= Voverlay_arrow_string
;
1574 /* t is unequal to any useful value of Voverlay_arrow_... */
1575 last_arrow_position
= Qt
;
1576 last_arrow_string
= Qt
;
1580 /* Update the menu bar item list for frame F.
1581 This has to be done before we start to fill in any display lines,
1582 because it can call eval.
1584 If SAVE_MATCH_DATA is 1, we must save and restore it here. */
1587 update_menu_bar (f
, save_match_data
)
1589 int save_match_data
;
1591 struct buffer
*old
= current_buffer
;
1593 register struct window
*w
;
1595 window
= FRAME_SELECTED_WINDOW (f
);
1596 w
= XWINDOW (window
);
1598 if (update_mode_lines
)
1599 w
->update_mode_line
= Qt
;
1601 if (FRAME_WINDOW_P (f
)
1603 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1604 FRAME_EXTERNAL_MENU_BAR (f
)
1606 FRAME_MENU_BAR_LINES (f
) > 0
1608 : FRAME_MENU_BAR_LINES (f
) > 0)
1610 /* If the user has switched buffers or windows, we need to
1611 recompute to reflect the new bindings. But we'll
1612 recompute when update_mode_lines is set too; that means
1613 that people can use force-mode-line-update to request
1614 that the menu bar be recomputed. The adverse effect on
1615 the rest of the redisplay algorithm is about the same as
1616 windows_or_buffers_changed anyway. */
1617 if (windows_or_buffers_changed
1618 || !NILP (w
->update_mode_line
)
1619 || ((BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1620 < BUF_MODIFF (XBUFFER (w
->buffer
)))
1621 != !NILP (w
->last_had_star
))
1622 || ((!NILP (Vtransient_mark_mode
)
1623 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1624 != !NILP (w
->region_showing
)))
1626 struct buffer
*prev
= current_buffer
;
1627 int count
= specpdl_ptr
- specpdl
;
1629 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1630 if (save_match_data
)
1631 record_unwind_protect (Fstore_match_data
, Fmatch_data (Qnil
, Qnil
));
1632 if (NILP (Voverriding_local_map_menu_flag
))
1634 specbind (Qoverriding_terminal_local_map
, Qnil
);
1635 specbind (Qoverriding_local_map
, Qnil
);
1638 /* Run the Lucid hook. */
1639 call1 (Vrun_hooks
, Qactivate_menubar_hook
);
1640 /* If it has changed current-menubar from previous value,
1641 really recompute the menubar from the value. */
1642 if (! NILP (Vlucid_menu_bar_dirty_flag
))
1643 call0 (Qrecompute_lucid_menubar
);
1644 safe_run_hooks (Qmenu_bar_update_hook
);
1645 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
1646 /* Redisplay the menu bar in case we changed it. */
1647 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1648 if (FRAME_WINDOW_P (f
))
1649 set_frame_menubar (f
, 0, 0);
1651 /* On a terminal screen, the menu bar is an ordinary screen
1652 line, and this makes it get updated. */
1653 w
->update_mode_line
= Qt
;
1654 #else /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1655 /* In the non-toolkit version, the menu bar is an ordinary screen
1656 line, and this makes it get updated. */
1657 w
->update_mode_line
= Qt
;
1658 #endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1660 unbind_to (count
, Qnil
);
1661 set_buffer_internal_1 (prev
);
1668 /* Redisplay WINDOW and its subwindows and siblings. */
1671 redisplay_windows (window
, preserve_echo_area
)
1673 int preserve_echo_area
;
1675 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1676 redisplay_window (window
, 0, preserve_echo_area
);
1679 /* Return value in display table DP (Lisp_Char_Table *) for character
1680 C. Since a display table doesn't have any parent, we don't have to
1681 follow parent. Do not call this function directly but use the
1682 macro DISP_CHAR_VECTOR. */
1684 disp_char_vector (dp
, c
)
1685 struct Lisp_Char_Table
*dp
;
1691 if (SINGLE_BYTE_CHAR_P (c
)) return (dp
->contents
[c
]);
1693 SPLIT_NON_ASCII_CHAR (c
, code
[0], code
[1], code
[2]);
1694 if (code
[0] != CHARSET_COMPOSITION
)
1696 if (code
[1] < 32) code
[1] = -1;
1697 else if (code
[2] < 32) code
[2] = -1;
1699 /* Here, the possible range of CODE[0] (== charset ID) is
1700 128..MAX_CHARSET. Since the top level char table contains data
1701 for multibyte characters after 256th element, we must increment
1702 CODE[0] by 128 to get a correct index. */
1704 code
[3] = -1; /* anchor */
1706 for (i
= 0; code
[i
] >= 0; i
++, dp
= XCHAR_TABLE (val
))
1708 val
= dp
->contents
[code
[i
]];
1709 if (!SUB_CHAR_TABLE_P (val
))
1710 return (NILP (val
) ? dp
->defalt
: val
);
1712 /* Here, VAL is a sub char table. We return the default value of it. */
1713 return (dp
->defalt
);
1716 /* Redisplay window WINDOW and its subwindows. */
1719 redisplay_window (window
, just_this_one
, preserve_echo_area
)
1721 int just_this_one
, preserve_echo_area
;
1723 register struct window
*w
= XWINDOW (window
);
1724 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1727 int lpoint_byte
= PT_BYTE
;
1728 struct buffer
*old
= current_buffer
;
1729 register int width
= window_internal_width (w
) - 1;
1730 register int startp
, startp_byte
;
1731 register int hscroll
= XINT (w
->hscroll
);
1732 struct position pos
;
1734 int opoint_byte
= PT_BYTE
;
1736 int update_mode_line
;
1737 struct Lisp_Char_Table
*dp
= window_display_table (w
);
1739 if (Z
== Z_BYTE
&& lpoint
!= lpoint_byte
)
1741 if (lpoint_byte
< lpoint
)
1744 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1746 /* If this is a combination window, do its children; that's all. */
1748 if (!NILP (w
->vchild
))
1750 redisplay_windows (w
->vchild
, preserve_echo_area
);
1753 if (!NILP (w
->hchild
))
1755 redisplay_windows (w
->hchild
, preserve_echo_area
);
1758 if (NILP (w
->buffer
))
1761 height
= window_internal_height (w
);
1762 update_mode_line
= (!NILP (w
->update_mode_line
) || update_mode_lines
);
1763 if (XBUFFER (w
->buffer
)->clip_changed
)
1764 update_mode_line
= 1;
1766 if (MINI_WINDOW_P (w
))
1768 if (w
== XWINDOW (echo_area_window
) && echo_area_glyphs
)
1769 /* We've already displayed the echo area glyphs in this window. */
1770 goto finish_scroll_bars
;
1771 else if (w
!= XWINDOW (minibuf_window
))
1773 /* This is a minibuffer, but it's not the currently active one,
1775 int vpos
= XFASTINT (w
->top
);
1778 for (i
= 0; i
< height
; i
++)
1780 get_display_line (f
, vpos
+ i
, 0);
1781 display_string (w
, vpos
+ i
, "", 0,
1782 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
1786 goto finish_scroll_bars
;
1790 /* Otherwise set up data on this window; select its buffer and point value */
1792 if (update_mode_line
)
1793 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1795 set_buffer_temp (XBUFFER (w
->buffer
));
1798 opoint_byte
= PT_BYTE
;
1800 if (Z
== Z_BYTE
&& opoint
!= opoint_byte
)
1802 if (opoint_byte
< opoint
)
1805 /* If %c is in mode line, update it if needed. */
1806 if (!NILP (w
->column_number_displayed
)
1807 /* This alternative quickly identifies a common case
1808 where no change is needed. */
1809 && !(PT
== XFASTINT (w
->last_point
)
1810 && XFASTINT (w
->last_modified
) >= MODIFF
1811 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1812 && XFASTINT (w
->column_number_displayed
) != current_column ())
1813 update_mode_line
= 1;
1815 /* Count number of windows showing the selected buffer.
1816 An indirect buffer counts as its base buffer. */
1820 struct buffer
*current_base
, *window_base
;
1821 current_base
= current_buffer
;
1822 window_base
= XBUFFER (XWINDOW (selected_window
)->buffer
);
1823 if (current_base
->base_buffer
)
1824 current_base
= current_base
->base_buffer
;
1825 if (window_base
->base_buffer
)
1826 window_base
= window_base
->base_buffer
;
1827 if (current_base
== window_base
)
1831 /* POINT refers normally to the selected window.
1832 For any other window, set up appropriate value. */
1834 if (!EQ (window
, selected_window
))
1836 int new_pt
= XMARKER (w
->pointm
)->charpos
;
1837 int new_pt_byte
= marker_byte_position (w
->pointm
);
1841 new_pt_byte
= BEGV_BYTE
;
1842 set_marker_both (w
->pointm
, Qnil
, BEGV
, BEGV_BYTE
);
1844 else if (new_pt
> (ZV
- 1))
1847 new_pt_byte
= ZV_BYTE
;
1848 set_marker_both (w
->pointm
, Qnil
, ZV
, ZV_BYTE
);
1850 /* We don't use SET_PT so that the point-motion hooks don't run. */
1851 TEMP_SET_PT_BOTH (new_pt
, new_pt_byte
);
1854 /* If any of the character widths specified in the display table
1855 have changed, invalidate the width run cache. It's true that this
1856 may be a bit late to catch such changes, but the rest of
1857 redisplay goes (non-fatally) haywire when the display table is
1858 changed, so why should we worry about doing any better? */
1859 if (current_buffer
->width_run_cache
)
1861 struct Lisp_Char_Table
*disptab
= buffer_display_table ();
1863 if (! disptab_matches_widthtab (disptab
,
1864 XVECTOR (current_buffer
->width_table
)))
1866 invalidate_region_cache (current_buffer
,
1867 current_buffer
->width_run_cache
,
1869 recompute_width_table (current_buffer
, disptab
);
1873 /* If window-start is screwed up, choose a new one. */
1874 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1877 startp
= marker_position (w
->start
);
1878 startp_byte
= marker_byte_position (w
->start
);
1880 /* If someone specified a new starting point but did not insist,
1881 check whether it can be used. */
1882 if (!NILP (w
->optional_new_start
))
1884 w
->optional_new_start
= Qnil
;
1885 /* Check whether this start pos is usable given where point is. */
1887 pos
= *compute_motion (startp
, 0,
1888 (((EQ (window
, minibuf_window
)
1890 ? minibuf_prompt_width
: 0)
1891 + (hscroll
? 1 - hscroll
: 0)),
1894 /* BUG FIX: See the comment of
1895 Fpos_visible_in_window_p (window.c). */
1896 - (1 << (BITS_PER_SHORT
- 1)),
1898 pos_tab_offset (w
, startp
, startp_byte
), w
);
1899 /* If PT does fit on the screen, we will use this start pos,
1900 so do so by setting force_start. */
1901 if (pos
.bufpos
== PT
)
1902 w
->force_start
= Qt
;
1905 /* Handle case where place to start displaying has been specified,
1906 unless the specified location is outside the accessible range. */
1907 if (!NILP (w
->force_start
))
1909 w
->force_start
= Qnil
;
1910 /* Forget any recorded base line for line number display. */
1911 w
->base_line_number
= Qnil
;
1912 /* Redisplay the mode line. Select the buffer properly for that.
1913 Also, run the hook window-scroll-functions
1914 because we have scrolled. */
1915 /* Note, we do this after clearing force_start because
1916 if there's an error, it is better to forget about force_start
1917 than to get into an infinite loop calling the hook functions
1918 and having them get more errors. */
1919 if (!update_mode_line
1920 || ! NILP (Vwindow_scroll_functions
))
1922 Lisp_Object temp
[3];
1924 set_buffer_temp (old
);
1925 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1926 update_mode_line
= 1;
1927 w
->update_mode_line
= Qt
;
1928 if (! NILP (Vwindow_scroll_functions
))
1930 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
1931 make_number (startp
));
1932 startp
= marker_position (w
->start
);
1935 XSETFASTINT (w
->last_modified
, 0);
1936 XSETFASTINT (w
->last_overlay_modified
, 0);
1937 if (startp
< BEGV
) startp
= BEGV
, startp_byte
= BEGV_BYTE
;
1938 if (startp
> ZV
) startp
= ZV
, startp
= ZV_BYTE
;
1939 try_window (window
, startp
);
1940 if (cursor_vpos
< 0)
1942 /* If point does not appear, move point so it does appear */
1943 pos
= *compute_motion (startp
, 0,
1944 (((EQ (window
, minibuf_window
)
1946 ? minibuf_prompt_width
: 0)
1947 + (hscroll
? 1 - hscroll
: 0)),
1950 - (1 << (BITS_PER_SHORT
- 1)),
1952 pos_tab_offset (w
, startp
, startp_byte
),
1954 TEMP_SET_PT_BOTH (pos
.bufpos
, pos
.bytepos
);
1955 if (w
!= XWINDOW (selected_window
))
1956 set_marker_both (w
->pointm
, Qnil
, PT
, PT_BYTE
);
1959 if (current_buffer
== old
)
1962 lpoint_byte
= PT_BYTE
;
1964 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
1965 + minmax (0, pos
.hpos
, width
));
1966 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1968 /* If we are highlighting the region,
1969 then we just changed the region, so redisplay to show it. */
1970 if (!NILP (Vtransient_mark_mode
)
1971 && !NILP (current_buffer
->mark_active
))
1973 cancel_my_columns (XWINDOW (window
));
1974 try_window (window
, startp
);
1980 /* Handle case where text has not changed, only point,
1981 and it has not moved off the frame. */
1983 /* This code is not used for minibuffer for the sake of
1984 the case of redisplaying to replace an echo area message;
1985 since in that case the minibuffer contents per se are usually unchanged.
1986 This code is of no real use in the minibuffer since
1987 the handling of this_line_bufpos, etc.,
1988 in redisplay handles the same cases. */
1990 if (XFASTINT (w
->last_modified
) >= MODIFF
1991 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
1992 && PT
>= startp
&& !current_buffer
->clip_changed
1993 && (just_this_one
|| WINDOW_FULL_WIDTH_P (w
))
1994 /* If force-mode-line-update was called, really redisplay;
1995 that's how redisplay is forced after e.g. changing
1996 buffer-invisibility-spec. */
1997 && NILP (w
->update_mode_line
)
1998 /* Can't use this case if highlighting a region. */
1999 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
2000 && NILP (w
->region_showing
)
2001 /* If end pos is out of date, scroll bar and percentage will be wrong */
2002 && INTEGERP (w
->window_end_vpos
)
2003 && XFASTINT (w
->window_end_vpos
) < XFASTINT (w
->height
)
2004 && !EQ (window
, minibuf_window
)
2005 && (!MARKERP (Voverlay_arrow_position
)
2006 || current_buffer
!= XMARKER (Voverlay_arrow_position
)->buffer
))
2008 /* All positions in this clause are relative to the window edge. */
2010 int this_scroll_margin
= scroll_margin
;
2011 int last_point_y
= XFASTINT (w
->last_point_y
) - XINT (w
->top
);
2012 int last_point_x
= (XFASTINT (w
->last_point_x
) - WINDOW_LEFT_MARGIN (w
));
2014 /* Find where PT is located now on the frame. */
2015 /* Check just_this_one as a way of verifying that the
2016 window edges have not changed. */
2017 if (PT
== XFASTINT (w
->last_point
) && just_this_one
)
2019 pos
.hpos
= last_point_x
;
2020 pos
.vpos
= last_point_y
;
2023 else if (PT
> XFASTINT (w
->last_point
)
2024 && XFASTINT (w
->last_point
) > startp
&& just_this_one
2025 /* We can't use this if point is in the left margin of a
2026 hscrolled window, because w->last_point_x has been
2027 clipped to the window edges. */
2028 && !(last_point_x
<= 0 && hscroll
))
2030 pos
= *compute_motion (XFASTINT (w
->last_point
),
2031 last_point_y
, last_point_x
, 0,
2033 /* BUG FIX: See the comment of
2034 Fpos_visible_in_window_p (window.c). */
2035 - (1 << (BITS_PER_SHORT
- 1)),
2037 pos_tab_offset (w
, startp
, startp_byte
),
2042 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0), 0,
2044 /* BUG FIX: See the comment of
2045 Fpos_visible_in_window_p (window.c). */
2046 - (1 << (BITS_PER_SHORT
- 1)),
2048 pos_tab_offset (w
, startp
, startp_byte
),
2052 /* Don't use a scroll margin that is negative or too large. */
2053 if (this_scroll_margin
< 0)
2054 this_scroll_margin
= 0;
2056 if (XINT (w
->height
) < 4 * scroll_margin
)
2057 this_scroll_margin
= XINT (w
->height
) / 4;
2059 /* If point fits on the screen, and not within the scroll margin,
2061 if (pos
.vpos
< height
- this_scroll_margin
2062 && (pos
.vpos
>= this_scroll_margin
|| startp
== BEGV
))
2064 /* Ok, point is still on frame */
2065 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2067 /* These variables are supposed to be origin 1 */
2068 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
2069 + minmax (0, pos
.hpos
, width
));
2070 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
2072 /* This doesn't do the trick, because if a window to the right of
2073 this one must be redisplayed, this does nothing because there
2074 is nothing in DesiredFrame yet, and then the other window is
2075 redisplayed, making likes that are empty in this window's columns.
2076 if (WINDOW_FULL_WIDTH_P (w))
2077 preserve_my_columns (w);
2079 if (current_buffer
->clip_changed
2080 && ! NILP (Vwindow_scroll_functions
))
2081 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2082 make_number (marker_position (w
->start
)));
2086 /* Don't bother trying redisplay with same start;
2087 we already know it will lose */
2089 /* If current starting point was originally the beginning of a line
2090 but no longer is, find a new starting point. */
2091 else if (!NILP (w
->start_at_line_beg
)
2093 || FETCH_BYTE (startp_byte
- 1) == '\n'))
2097 else if (just_this_one
&& !MINI_WINDOW_P (w
)
2099 && XFASTINT (w
->last_modified
)
2100 /* or else vmotion on first line won't work. */
2101 && ! NILP (w
->start_at_line_beg
)
2102 && ! EQ (w
->window_end_valid
, Qnil
)
2103 && do_id
&& !current_buffer
->clip_changed
2104 && !blank_end_of_window
2105 && WINDOW_FULL_WIDTH_P (w
)
2106 /* Can't use this case if highlighting a region. */
2107 && !(!NILP (Vtransient_mark_mode
)
2108 && !NILP (current_buffer
->mark_active
))
2109 /* Don't use try_window_id if newline
2110 doesn't display as the end of a line. */
2111 && !(dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, '\n')))
2112 && NILP (w
->region_showing
)
2113 && EQ (last_arrow_position
, COERCE_MARKER (Voverlay_arrow_position
))
2114 && EQ (last_arrow_string
, Voverlay_arrow_string
)
2115 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
2118 /* tem > 0 means success. tem == -1 means choose new start.
2119 tem == -2 means try again with same start,
2120 and nothing but whitespace follows the changed stuff.
2121 tem == 0 means try again with same start. */
2125 else if (startp
>= BEGV
&& startp
<= ZV
2127 /* Avoid starting at end of buffer. */
2128 #if 0 /* This change causes trouble for M-! finger & RET.
2129 It will have to be considered later. */
2130 || ! EQ (window
, selected_window
)
2131 /* Don't do the recentering if redisplay
2132 is not for no user action. */
2133 || preserve_echo_area
2136 || (XFASTINT (w
->last_modified
) >= MODIFF
2137 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)))
2139 /* Try to redisplay starting at same place as before */
2140 /* If point has not moved off frame, accept the results */
2141 try_window (window
, startp
);
2142 if (cursor_vpos
>= 0)
2144 if (!just_this_one
|| current_buffer
->clip_changed
2145 || beg_unchanged
< startp
)
2146 /* Forget any recorded base line for line number display. */
2147 w
->base_line_number
= Qnil
;
2149 if (current_buffer
->clip_changed
2150 && ! NILP (Vwindow_scroll_functions
))
2151 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2152 make_number (marker_position (w
->start
)));
2157 cancel_my_columns (w
);
2160 XSETFASTINT (w
->last_modified
, 0);
2161 XSETFASTINT (w
->last_overlay_modified
, 0);
2162 /* Redisplay the mode line. Select the buffer properly for that. */
2163 if (!update_mode_line
)
2165 set_buffer_temp (old
);
2166 set_buffer_internal_1 (XBUFFER (w
->buffer
));
2167 update_mode_line
= 1;
2168 w
->update_mode_line
= Qt
;
2171 /* Try to scroll by specified few lines */
2173 if (scroll_conservatively
&& !current_buffer
->clip_changed
2174 && startp
>= BEGV
&& startp
<= ZV
)
2176 int this_scroll_margin
= scroll_margin
;
2177 int scroll_margin_pos
;
2179 /* Don't use a scroll margin that is negative or too large. */
2180 if (this_scroll_margin
< 0)
2181 this_scroll_margin
= 0;
2183 if (XINT (w
->height
) < 4 * this_scroll_margin
)
2184 this_scroll_margin
= XINT (w
->height
) / 4;
2186 scroll_margin_pos
= Z
- XFASTINT (w
->window_end_pos
);
2187 if (this_scroll_margin
)
2189 pos
= *vmotion (scroll_margin_pos
, -this_scroll_margin
, w
);
2190 scroll_margin_pos
= pos
.bufpos
;
2192 if (PT
>= scroll_margin_pos
)
2194 struct position pos
;
2195 pos
= *compute_motion (scroll_margin_pos
, 0, 0, 0,
2196 PT
, XFASTINT (w
->height
), 0,
2197 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2198 pos_tab_offset (w
, startp
, startp_byte
),
2200 if (pos
.vpos
> scroll_conservatively
)
2203 pos
= *vmotion (startp
, pos
.vpos
+ 1, w
);
2205 if (! NILP (Vwindow_scroll_functions
))
2207 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2208 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2209 make_number (pos
.bufpos
));
2210 pos
.bufpos
= marker_position (w
->start
);
2212 try_window (window
, pos
.bufpos
);
2213 if (cursor_vpos
>= 0)
2215 if (!just_this_one
|| current_buffer
->clip_changed
2216 || beg_unchanged
< startp
)
2217 /* Forget any recorded base line for line number display. */
2218 w
->base_line_number
= Qnil
;
2222 cancel_my_columns (w
);
2225 scroll_margin_pos
= startp
;
2226 if (this_scroll_margin
)
2228 pos
= *vmotion (scroll_margin_pos
, this_scroll_margin
, w
);
2229 scroll_margin_pos
= pos
.bufpos
;
2231 if (PT
< scroll_margin_pos
)
2233 struct position pos
;
2234 pos
= *compute_motion (PT
, 0, 0, 0,
2235 scroll_margin_pos
, XFASTINT (w
->height
), 0,
2236 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2237 pos_tab_offset (w
, startp
, startp_byte
),
2239 if (pos
.vpos
> scroll_conservatively
)
2242 pos
= *vmotion (startp
, -pos
.vpos
, w
);
2244 if (! NILP (Vwindow_scroll_functions
))
2246 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2247 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2248 make_number (pos
.bufpos
));
2249 pos
.bufpos
= marker_position (w
->start
);
2251 try_window (window
, pos
.bufpos
);
2252 if (cursor_vpos
>= 0)
2254 if (!just_this_one
|| current_buffer
->clip_changed
2255 || beg_unchanged
< startp
)
2256 /* Forget any recorded base line for line number display. */
2257 w
->base_line_number
= Qnil
;
2261 cancel_my_columns (w
);
2266 if (scroll_step
&& !current_buffer
->clip_changed
2267 && startp
>= BEGV
&& startp
<= ZV
)
2271 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), scroll_step
, w
);
2272 if (pos
.vpos
>= height
)
2276 pos
= *vmotion (startp
, (PT
< startp
? - scroll_step
: scroll_step
), w
);
2278 if (PT
>= pos
.bufpos
)
2280 if (! NILP (Vwindow_scroll_functions
))
2282 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2283 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2284 make_number (pos
.bufpos
));
2285 pos
.bufpos
= marker_position (w
->start
);
2287 try_window (window
, pos
.bufpos
);
2288 if (cursor_vpos
>= 0)
2290 if (!just_this_one
|| current_buffer
->clip_changed
2291 || beg_unchanged
< startp
)
2292 /* Forget any recorded base line for line number display. */
2293 w
->base_line_number
= Qnil
;
2297 cancel_my_columns (w
);
2302 /* Finally, just choose place to start which centers point */
2305 /* Forget any previously recorded base line for line number display. */
2306 w
->base_line_number
= Qnil
;
2308 pos
= *vmotion (PT
, - (height
/ 2), w
);
2310 /* The minibuffer is often just one line. Ordinary scrolling
2311 gives little overlap and looks bad. So show 20 chars before point. */
2313 && (pos
.bufpos
>= PT
- minibuffer_scroll_overlap
2314 /* If we scrolled less than 1/2 line forward, we will
2315 get too much overlap, so change to the usual amount. */
2316 || pos
.bufpos
< startp
+ width
/ 2)
2317 && PT
> BEGV
+ minibuffer_scroll_overlap
2318 /* If we scrolled to an actual line boundary,
2319 that's different; don't ignore line boundaries. */
2320 && FETCH_BYTE (pos
.bufpos
- 1) != '\n')
2322 pos
.bufpos
= PT
- minibuffer_scroll_overlap
;
2323 pos
.bytepos
= CHAR_TO_BYTE (pos
.bufpos
);
2326 /* Set startp here explicitly in case that helps avoid an infinite loop
2327 in case the window-scroll-functions functions get errors. */
2328 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2329 if (! NILP (Vwindow_scroll_functions
))
2331 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2332 make_number (pos
.bufpos
));
2333 pos
.bufpos
= marker_position (w
->start
);
2334 pos
.bytepos
= marker_byte_position (w
->start
);
2336 try_window (window
, pos
.bufpos
);
2338 startp
= marker_position (w
->start
);
2339 startp_byte
= marker_byte_position (w
->start
);
2340 w
->start_at_line_beg
2341 = (startp
== BEGV
|| FETCH_BYTE (startp_byte
- 1) == '\n') ? Qt
: Qnil
;
2344 if ((update_mode_line
2345 /* If window not full width, must redo its mode line
2346 if the window to its side is being redone */
2347 || (!just_this_one
&& !WINDOW_FULL_WIDTH_P (w
))
2348 || INTEGERP (w
->base_line_pos
)
2349 || (!NILP (w
->column_number_displayed
)
2350 && XFASTINT (w
->column_number_displayed
) != current_column ()))
2351 && height
!= XFASTINT (w
->height
))
2352 display_mode_line (w
);
2353 if (! line_number_displayed
2354 && ! BUFFERP (w
->base_line_pos
))
2356 w
->base_line_pos
= Qnil
;
2357 w
->base_line_number
= Qnil
;
2360 /* When we reach a frame's selected window, redo the frame's menu bar. */
2361 if (update_mode_line
2362 && (FRAME_WINDOW_P (f
)
2364 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2365 FRAME_EXTERNAL_MENU_BAR (f
)
2367 FRAME_MENU_BAR_LINES (f
) > 0
2369 : FRAME_MENU_BAR_LINES (f
) > 0)
2370 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
2371 display_menu_bar (w
);
2374 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2376 int start
, end
, whole
;
2378 /* Calculate the start and end positions for the current window.
2379 At some point, it would be nice to choose between scrollbars
2380 which reflect the whole buffer size, with special markers
2381 indicating narrowing, and scrollbars which reflect only the
2384 Note that minibuffers sometimes aren't displaying any text. */
2385 if (! MINI_WINDOW_P (w
)
2386 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
2389 start
= marker_position (w
->start
) - BEGV
;
2390 /* I don't think this is guaranteed to be right. For the
2391 moment, we'll pretend it is. */
2392 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
2394 if (end
< start
) end
= start
;
2395 if (whole
< (end
- start
)) whole
= end
- start
;
2398 start
= end
= whole
= 0;
2400 /* Indicate what this scroll bar ought to be displaying now. */
2401 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
2403 /* Note that we actually used the scroll bar attached to this window,
2404 so it shouldn't be deleted at the end of redisplay. */
2405 (*redeem_scroll_bar_hook
) (w
);
2408 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
2409 if (update_mode_line
)
2410 set_buffer_internal_1 (old
);
2412 set_buffer_temp (old
);
2413 TEMP_SET_PT_BOTH (lpoint
, lpoint_byte
);
2416 /* Do full redisplay on one window, starting at position `pos'. */
2419 try_window (window
, pos
)
2423 register struct window
*w
= XWINDOW (window
);
2424 register int height
= window_internal_height (w
);
2425 register int vpos
= XFASTINT (w
->top
);
2426 register int last_text_vpos
= vpos
;
2427 FRAME_PTR f
= XFRAME (w
->frame
);
2428 int width
= window_internal_width (w
) - 1;
2429 struct position val
;
2431 /* POS should never be out of range! */
2432 if (pos
< XBUFFER (w
->buffer
)->begv
2433 || pos
> XBUFFER (w
->buffer
)->zv
)
2436 if (XMARKER (w
->start
)->charpos
!= pos
)
2437 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2440 overlay_arrow_seen
= 0;
2441 zv_strings_seen
= 0;
2442 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2443 val
.ovstring_chars_done
= 0;
2444 val
.bytepos
= marker_byte_position (w
->start
);
2445 val
.tab_offset
= pos_tab_offset (w
, pos
, val
.bytepos
);
2447 while (--height
>= 0)
2449 val
= *display_text_line (w
, pos
, val
.bytepos
, vpos
,
2450 val
.hpos
, val
.tab_offset
,
2451 val
.ovstring_chars_done
);
2452 /* The following code is omitted because we maintain tab_offset
2455 tab_offset
+= width
;
2456 if (val
.vpos
) tab_offset
= 0;
2459 if (pos
!= val
.bufpos
)
2462 #ifdef USE_TEXT_PROPERTIES
2463 Lisp_Object invis_prop
;
2464 invis_prop
= Fget_char_property (val
.bufpos
-1, Qinvisible
, window
);
2465 invis
= TEXT_PROP_MEANS_INVISIBLE (invis_prop
);
2469 /* Next line, unless prev line ended in end of buffer with no cr */
2471 && (FETCH_BYTE (val
.bytepos
- 1) != '\n' || invis
));
2476 /* If last line is continued in middle of character,
2477 include the split character in the text considered on the frame */
2478 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2481 /* If bottom just moved off end of frame, change mode line percentage. */
2482 if (XFASTINT (w
->window_end_pos
) == 0
2484 w
->update_mode_line
= Qt
;
2486 /* Say where last char on frame will be, once redisplay is finished. */
2487 XSETFASTINT (w
->window_end_pos
, Z
- pos
);
2488 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
- XFASTINT (w
->top
));
2489 /* But that is not valid info until redisplay finishes. */
2490 w
->window_end_valid
= Qnil
;
2493 /* Try to redisplay when buffer is modified locally,
2494 computing insert/delete line to preserve text outside
2495 the bounds of the changes.
2496 Return 1 if successful, 0 if if cannot tell what to do,
2497 or -1 to tell caller to find a new window start,
2498 or -2 to tell caller to do normal redisplay with same window start. */
2501 try_window_id (window
)
2505 int opoint
, opoint_byte
;
2506 register struct window
*w
= XWINDOW (window
);
2507 register int height
= window_internal_height (w
);
2508 FRAME_PTR f
= XFRAME (w
->frame
);
2509 int top
= XFASTINT (w
->top
);
2510 int start
= marker_position (w
->start
);
2511 int width
= window_internal_width (w
) - 1;
2512 int hscroll
= XINT (w
->hscroll
);
2513 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
2516 register int i
, tem
;
2517 int last_text_vpos
= 0;
2519 int selective
= (INTEGERP (current_buffer
->selective_display
)
2520 ? XINT (current_buffer
->selective_display
)
2521 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
2523 struct position val
, bp
, ep
, xp
, pp
;
2524 int scroll_amount
= 0;
2528 int start_byte
= marker_byte_position (w
->start
);
2530 if (GPT
- BEG
< beg_unchanged
)
2531 beg_unchanged
= GPT
- BEG
;
2532 if (Z
- GPT
< end_unchanged
)
2533 end_unchanged
= Z
- GPT
;
2535 if (beg_unchanged
+ BEG
< start
)
2536 return 0; /* Give up if changes go above top of window */
2538 /* Find position before which nothing is changed. */
2539 bp
= *compute_motion (start
, 0, lmargin
, 0,
2540 min (ZV
, beg_unchanged
+ BEG
), height
,
2541 /* BUG FIX: See the comment of
2542 Fpos_visible_in_window_p (window.c). */
2543 - (1 << (BITS_PER_SHORT
- 1)),
2545 pos_tab_offset (w
, start
, start_byte
),
2547 if (bp
.vpos
>= height
)
2551 /* All changes are beyond the window end, and point is on the screen.
2552 We don't need to change the text at all.
2553 But we need to update window_end_pos to account for
2554 any change in buffer size. */
2555 bp
= *compute_motion (start
, 0, lmargin
, 0,
2557 /* BUG FIX: See the comment of
2558 Fpos_visible_in_window_p() (window.c). */
2559 - (1 << (BITS_PER_SHORT
- 1)),
2561 pos_tab_offset (w
, start
, start_byte
), w
);
2562 XSETFASTINT (w
->window_end_vpos
, height
);
2563 XSETFASTINT (w
->window_end_pos
, Z
- bp
.bufpos
);
2571 /* Find beginning of that frame line. Must display from there. */
2572 bp
= *vmotion (bp
.bufpos
, 0, w
);
2575 pos_byte
= bp
.bytepos
;
2581 /* If about to start displaying at the beginning of a continuation line,
2582 really start with previous frame line, in case it was not
2583 continued when last redisplayed */
2584 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
2586 /* Likewise if we have to worry about selective display. */
2587 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
2589 bp
= *vmotion (bp
.bufpos
, -1, w
);
2592 pos_byte
= bp
.bytepos
;
2594 val
.tab_offset
= bp
.tab_offset
; /* Update tab offset. */
2596 if (bp
.contin
&& bp
.hpos
!= lmargin
)
2598 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
2599 val
.tab_offset
= bp
.tab_offset
+ bp
.prevhpos
- width
;
2607 /* Find first visible newline after which no more is changed. */
2608 opoint
= PT
, opoint_byte
= PT_BYTE
;
2609 SET_PT (Z
- max (end_unchanged
, Z
- ZV
));
2610 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2612 while (PT
< ZV
- 1 && indented_beyond_p (PT
, PT_BYTE
, selective
))
2613 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2615 SET_PT_BOTH (opoint
, opoint_byte
);
2617 /* Compute the cursor position after that newline. */
2618 ep
= *compute_motion (pos
, vpos
, val
.hpos
, did_motion
, tem
,
2619 height
, - (1 << (BITS_PER_SHORT
- 1)),
2621 /* We have tab offset in VAL, use it. */
2624 /* If changes reach past the text available on the frame,
2625 just display rest of frame. */
2626 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
2629 stop_vpos
= ep
.vpos
;
2631 /* If no newline before ep, the line ep is on includes some changes
2632 that must be displayed. Make sure we don't stop before it. */
2633 /* Also, if changes reach all the way until ep.bufpos,
2634 it is possible that something was deleted after the
2635 newline before it, so the following line must be redrawn. */
2636 if (stop_vpos
== ep
.vpos
2637 && (ep
.bufpos
== BEGV
2638 || FETCH_BYTE (ep
.bufpos
- 1) != '\n'
2639 || ep
.bufpos
== Z
- end_unchanged
))
2640 stop_vpos
= ep
.vpos
+ 1;
2643 overlay_arrow_seen
= 0;
2644 zv_strings_seen
= 0;
2646 /* If changes do not reach to bottom of window,
2647 figure out how much to scroll the rest of the window */
2648 if (stop_vpos
< height
)
2650 /* Now determine how far up or down the rest of the window has moved */
2651 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2652 Z
- XFASTINT (w
->window_end_pos
),
2653 /* Don't care for VPOS... */
2654 1 << (BITS_PER_SHORT
- 1),
2656 1 << (BITS_PER_SHORT
- 1),
2657 width
, hscroll
, ep
.tab_offset
, w
);
2658 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
2660 /* Is everything on frame below the changes whitespace?
2661 If so, no scrolling is really necessary. */
2662 for (i
= ep
.bufpos
; i
< xp
.bufpos
; i
++)
2664 tem
= FETCH_BYTE (i
);
2665 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
2671 XSETFASTINT (w
->window_end_vpos
,
2672 XFASTINT (w
->window_end_vpos
) + scroll_amount
);
2674 /* Before doing any scrolling, verify that point will be on frame. */
2675 if (PT
> ep
.bufpos
&& !(PT
<= xp
.bufpos
&& xp
.vpos
< height
))
2677 if (PT
<= xp
.bufpos
)
2679 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2680 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2682 /* We have tab offset in EP, use it. */
2687 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
, 1,
2688 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2690 /* We have tab offset in XP, use it. */
2693 if (pp
.bufpos
< PT
|| pp
.vpos
== height
)
2695 cursor_vpos
= pp
.vpos
+ top
;
2696 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, pp
.hpos
, width
);
2699 if (stop_vpos
- scroll_amount
>= height
2700 || ep
.bufpos
== xp
.bufpos
)
2702 if (scroll_amount
< 0)
2703 stop_vpos
-= scroll_amount
;
2705 /* In this path, we have altered window_end_vpos
2706 and not left it negative.
2707 We must make sure that, in case display is preempted
2708 before the frame changes to reflect what we do here,
2709 further updates will not come to try_window_id
2710 and assume the frame and window_end_vpos match. */
2711 blank_end_of_window
= 1;
2713 else if (!scroll_amount
)
2715 /* Even if we don't need to scroll, we must adjust the
2716 charstarts of subsequent lines (that we won't redisplay)
2717 according to the amount of text inserted or deleted. */
2718 int oldpos
= FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2719 int adjust
= ep
.bufpos
- oldpos
;
2720 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1, adjust
);
2722 else if (bp
.bufpos
== Z
- end_unchanged
)
2724 /* If reprinting everything is nearly as fast as scrolling,
2725 don't bother scrolling. Can happen if lines are short. */
2726 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
2727 top
+ height
- max (0, scroll_amount
),
2729 > xp
.bufpos
- bp
.bufpos
- 20)
2730 /* Return "try normal display with same window-start."
2731 Too bad we can't prevent further scroll-thinking. */
2733 /* If pure deletion, scroll up as many lines as possible.
2734 In common case of killing a line, this can save the
2735 following line from being overwritten by scrolling
2736 and therefore having to be redrawn. */
2737 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
2738 top
+ height
- max (0, scroll_amount
),
2739 scroll_amount
, bp
.bufpos
);
2744 /* scroll_frame_lines did not properly adjust subsequent
2745 lines' charstarts in the case where the text of the
2746 screen line at bp.vpos has changed.
2747 (This can happen in a deletion that ends in mid-line.)
2748 To adjust properly, we need to make things consistent
2750 So do a second adjust to make that happen.
2751 Note that stop_vpos >= ep.vpos, so it is sufficient
2752 to update the charstarts for lines at ep.vpos and below. */
2754 = FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2755 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1,
2756 ep
.bufpos
- oldstart
);
2759 else if (scroll_amount
)
2761 /* If reprinting everything is nearly as fast as scrolling,
2762 don't bother scrolling. Can happen if lines are short. */
2763 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
2764 overestimate of cost of reprinting, since xp.bufpos
2765 would end up below the bottom of the window. */
2766 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
2767 top
+ height
- max (0, scroll_amount
),
2769 > xp
.bufpos
- ep
.bufpos
- 20)
2770 /* Return "try normal display with same window-start."
2771 Too bad we can't prevent further scroll-thinking. */
2773 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
2774 top
+ height
- max (0, scroll_amount
),
2775 scroll_amount
, ep
.bufpos
);
2776 if (!tem
) stop_vpos
= height
;
2780 /* In any case, do not display past bottom of window */
2781 if (stop_vpos
>= height
)
2787 /* Handle case where pos is before w->start --
2788 can happen if part of line had been clipped and is not clipped now */
2789 if (vpos
== 0 && pos
< marker_position (w
->start
))
2790 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2792 val
.bytepos
= pos_byte
;
2794 /* Redisplay the lines where the text was changed */
2795 last_text_vpos
= vpos
;
2796 /* The following code is omitted because we maintain tab offset in
2799 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2800 /* If we are starting display in mid-character, correct tab_offset
2801 to account for passing the line that that character really starts in. */
2802 if (val
.hpos
< lmargin
)
2803 tab_offset
+= width
;
2806 while (vpos
< stop_vpos
)
2808 val
= *display_text_line (w
, pos
, val
.bytepos
, top
+ vpos
++,
2809 val
.hpos
, val
.tab_offset
,
2810 val
.ovstring_chars_done
);
2811 /* If display_text_line ran a hook and changed some text,
2812 redisplay all the way to bottom of buffer
2813 So that we show the changes. */
2814 if (old_tick
!= MODIFF
)
2816 /* The following code is omitted because we maintain tab offset
2817 in val.tab_offset. */
2819 tab_offset
+= width
;
2820 if (val
.vpos
) tab_offset
= 0;
2822 if (pos
!= val
.bufpos
)
2824 /* Next line, unless prev line ended in end of buffer with no cr */
2825 = vpos
- (val
.vpos
&& FETCH_BYTE (val
.bufpos
- 1) != '\n');
2829 /* There are two cases:
2830 1) we have displayed down to the bottom of the window
2831 2) we have scrolled lines below stop_vpos by scroll_amount */
2835 /* If last line is continued in middle of character,
2836 include the split character in the text considered on the frame */
2837 if (val
.hpos
< lmargin
)
2839 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
);
2840 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2843 /* If scrolling made blank lines at window bottom,
2844 redisplay to fill those lines */
2845 if (scroll_amount
< 0)
2847 /* Don't consider these lines for general-purpose scrolling.
2848 That will save time in the scrolling computation. */
2849 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
2852 pos_byte
= xp
.bytepos
;
2854 val
.tab_offset
= xp
.tab_offset
;
2856 { /* Display from next line */
2857 vpos
= height
+ scroll_amount
;
2861 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
2863 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
2864 val
.tab_offset
= xp
.tab_offset
+ bp
.prevhpos
- width
;
2869 blank_end_of_window
= 1;
2870 /* The following code is omitted because we maintain tab offset
2871 in val.tab_offset. */
2873 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2874 /* If we are starting display in mid-character, correct tab_offset
2875 to account for passing the line that that character starts in. */
2876 if (val
.hpos
< lmargin
)
2877 tab_offset
+= width
;
2880 while (vpos
< height
)
2882 val
= *display_text_line (w
, pos
, val
.bytepos
,
2883 top
+ vpos
++, val
.hpos
,
2884 val
.tab_offset
, val
.ovstring_chars_done
);
2885 /* The following code is omitted because we maintain tab
2886 offset in val.tab_offset. */
2888 tab_offset
+= width
;
2889 if (val
.vpos
) tab_offset
= 0;
2894 /* Here is a case where display_text_line sets cursor_vpos wrong.
2895 Make it be fixed up, below. */
2901 /* If bottom just moved off end of frame, change mode line percentage. */
2902 if (XFASTINT (w
->window_end_pos
) == 0
2904 w
->update_mode_line
= Qt
;
2906 /* Attempt to adjust end-of-text positions to new bottom line */
2909 delta
= height
- xp
.vpos
;
2911 || (delta
> 0 && xp
.bufpos
<= ZV
)
2912 || (delta
== 0 && xp
.hpos
))
2914 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), delta
, w
);
2915 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2916 XSETFASTINT (w
->window_end_vpos
,
2917 XFASTINT (w
->window_end_vpos
) + val
.vpos
);
2921 w
->window_end_valid
= Qnil
;
2923 /* If point was not in a line that was displayed, find it */
2924 if (cursor_vpos
< 0)
2927 val
= *compute_motion (start
, 0, lmargin
, 0, PT
,
2928 /* Don't care for VPOS... */
2929 1 << (BITS_PER_SHORT
- 1),
2931 1 << (BITS_PER_SHORT
- 1),
2933 pos_tab_offset (w
, start
, start_byte
),
2935 /* Admit failure if point is off frame now */
2936 if (val
.vpos
>= height
)
2938 for (vpos
= 0; vpos
< height
; vpos
++)
2939 cancel_line (vpos
+ top
, f
);
2942 cursor_vpos
= val
.vpos
+ top
;
2943 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, val
.hpos
, width
);
2946 FRAME_CURSOR_X (f
) = cursor_hpos
;
2947 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2951 val
= *compute_motion (start
, 0, lmargin
, 0, ZV
,
2952 height
, - (1 << (BITS_PER_SHORT
- 1)),
2954 pos_tab_offset (w
, start
, start_byte
),
2956 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
2958 if (XFASTINT (w
->window_end_pos
)
2966 /* Copy LEN glyphs starting address FROM to the rope TO.
2967 But don't actually copy the parts that would come in before S.
2968 Value is TO, advanced past the copied data.
2969 F is the frame we are displaying in. */
2972 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
2974 register GLYPH
*to
; /* Copy to here. */
2975 register GLYPH
*s
; /* Starting point. */
2976 Lisp_Object
*from
; /* Data to copy. */
2978 int face
; /* Face to apply to glyphs which don't specify one. */
2981 register Lisp_Object
*fp
= from
;
2982 /* These cache the results of the last call to compute_glyph_face. */
2984 int last_merged
= 0;
2987 if (! FRAME_TERMCAP_P (f
))
2990 GLYPH glyph
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
2992 unsigned int c
= FAST_GLYPH_CHAR (glyph
);
2995 /* For an invalid character code, use space. */
2998 if (FAST_GLYPH_FACE (glyph
) == 0)
2999 /* If GLYPH has no face code, use FACE. */
3001 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
3002 /* If it's same as previous glyph, use same result. */
3003 facecode
= last_merged
;
3006 /* Merge this glyph's face and remember the result. */
3007 last_code
= FAST_GLYPH_FACE (glyph
);
3008 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
3012 *to
= FAST_MAKE_GLYPH (c
, facecode
);
3020 if (to
>= s
) *to
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
3027 /* Correct a glyph by replacing its specified user-level face code
3028 with a displayable computed face code. */
3031 fix_glyph (f
, glyph
, cface
)
3037 if (! FRAME_TERMCAP_P (f
))
3039 if (FAST_GLYPH_FACE (glyph
) != 0)
3040 cface
= compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
), cface
);
3041 glyph
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), cface
);
3047 /* Return the column of position POS / POS_BYTE in window W's buffer.
3048 The result is rounded down to a multiple of the internal width of W.
3049 This is the amount of indentation of position POS
3050 that is not visible in its horizontal position in the window. */
3053 pos_tab_offset (w
, pos
, pos_byte
)
3055 register int pos
, pos_byte
;
3058 int opoint_byte
= PT_BYTE
;
3060 int width
= window_internal_width (w
) - 1;
3063 return MINI_WINDOW_P (w
) ? -minibuf_prompt_width
: 0;
3065 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3068 TEMP_SET_PT_BOTH (pos
, pos_byte
);
3069 col
= current_column ();
3070 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
3075 /* Display one line of window W, starting at char position START in W's buffer.
3076 START_BYTE is the corresponding byte position.
3078 Display starting at horizontal position HPOS, expressed relative to
3079 W's left edge. In situations where the text at START shouldn't
3080 start at the left margin (i.e. when the window is hscrolled, or
3081 we're continuing a line which left off in the midst of a
3082 multi-column character), HPOS should be negative; we throw away
3083 characters up 'til hpos = 0. So, HPOS must take hscrolling into
3086 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
3088 OVSTR_DONE is the number of chars of overlay before/after strings
3089 at this position which have already been processed.
3091 Display on position VPOS on the frame. It is origin 0, relative to
3092 the top of the frame, not W.
3094 Returns a STRUCT POSITION giving character to start next line with
3095 and where to display it, including a zero or negative hpos.
3096 The vpos field is not really a vpos; it is 1 unless the line is continued */
3098 struct position val_display_text_line
;
3100 static struct position
*
3101 display_text_line (w
, start
, start_byte
, vpos
, hpos
, taboffset
, ovstr_done
)
3109 register int pos
= start
;
3110 int pos_byte
= start_byte
;
3113 int pause
, limit_byte
;
3114 register unsigned char *p
;
3116 register GLYPH
*leftmargin
;
3117 register GLYPH
*p1prev
;
3118 register GLYPH
*p1start
;
3119 int prevpos
, prevpos_byte
;
3121 FRAME_PTR f
= XFRAME (w
->frame
);
3122 int tab_width
= XINT (current_buffer
->tab_width
);
3123 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
3124 int width
= window_internal_width (w
) - 1;
3125 struct position val
;
3126 int lastpos
, lastpos_byte
;
3128 int last_invis_skip
= 0;
3129 Lisp_Object last_invis_prop
;
3130 int hscroll
= XINT (w
->hscroll
);
3131 int truncate
= (hscroll
3132 || (truncate_partial_width_windows
3133 && !WINDOW_FULL_WIDTH_P (w
))
3134 || !NILP (current_buffer
->truncate_lines
));
3136 /* 1 if this buffer has a region to highlight. */
3137 int highlight_region
3138 = (!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
)
3139 && XMARKER (current_buffer
->mark
)->buffer
!= 0);
3140 int region_beg
, region_end
;
3142 int selective
= (INTEGERP (current_buffer
->selective_display
)
3143 ? XINT (current_buffer
->selective_display
)
3144 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
3145 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3146 register struct Lisp_Char_Table
*dp
= window_display_table (w
);
3148 Lisp_Object default_invis_vector
[3];
3149 /* Number of characters of ellipsis to display after an invisible line
3150 if it calls for an ellipsis.
3151 Note that this value can be nonzero regardless of whether
3152 selective display is enabled--you must check that separately. */
3154 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3155 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
3156 : !NILP (current_buffer
->selective_display_ellipses
) ? 3 : 0);
3157 /* This is the sequence of Lisp objects to display
3158 when there are invisible lines. */
3159 Lisp_Object
*invis_vector_contents
3160 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3161 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
3162 : default_invis_vector
);
3164 GLYPH truncator
= (dp
== 0 || !INTEGERP (DISP_TRUNC_GLYPH (dp
))
3165 || !GLYPH_CHAR_VALID_P (XINT (DISP_TRUNC_GLYPH (dp
)))
3166 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
3167 GLYPH continuer
= (dp
== 0 || !INTEGERP (DISP_CONTINUE_GLYPH (dp
))
3168 || !GLYPH_CHAR_VALID_P (XINT (DISP_CONTINUE_GLYPH (dp
)))
3169 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
3171 /* If 1, we must handle multibyte characters. */
3172 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
3173 /* Length of multibyte form of each character. */
3175 /* Glyphs generated should be set this bit mask if text must be
3176 displayed from right to left. */
3177 GLYPH rev_dir_bit
= (NILP (current_buffer
->direction_reversed
)
3178 ? 0 : GLYPH_MASK_REV_DIR
);
3180 /* The next buffer location at which the face should change, due
3181 to overlays or text property changes. */
3182 int next_face_change
;
3184 /* The next location where the `invisible' property changes, or an
3185 overlay starts or ends. */
3188 /* The face we're currently using. */
3189 int current_face
= 0;
3192 XSETFASTINT (default_invis_vector
[2], '.');
3193 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
3195 get_display_line (f
, vpos
, WINDOW_LEFT_MARGIN (w
));
3196 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3198 /* Show where to highlight the region. */
3199 if (highlight_region
3200 /* Maybe highlight only in selected window. */
3201 && (highlight_nonselected_windows
3202 || w
== XWINDOW (selected_window
)
3203 || (MINI_WINDOW_P (XWINDOW (selected_window
))
3204 && w
== XWINDOW (Vminibuf_scroll_window
))))
3206 region_beg
= marker_position (current_buffer
->mark
);
3207 if (PT
< region_beg
)
3209 region_end
= region_beg
;
3214 w
->region_showing
= Qt
;
3218 region_beg
= region_end
= -1;
3219 w
->region_showing
= Qnil
;
3222 if (MINI_WINDOW_P (w
)
3224 && vpos
== XFASTINT (w
->top
))
3226 if (! NILP (minibuf_prompt
))
3228 int old_width
= minibuf_prompt_width
;
3230 minibuf_prompt_width
3231 = (display_string (w
, vpos
, XSTRING (minibuf_prompt
)->data
,
3232 XSTRING (minibuf_prompt
)->size_byte
,
3233 hpos
+ WINDOW_LEFT_MARGIN (w
),
3234 /* Display a space if we truncate. */
3237 /* Truncate the prompt a little before the
3238 margin, so user input can at least start
3239 on the first line. */
3240 (XFASTINT (w
->width
) > 10
3241 ? XFASTINT (w
->width
) - 4 : -1),
3242 STRING_MULTIBYTE (minibuf_prompt
))
3243 - hpos
- WINDOW_LEFT_MARGIN (w
));
3244 hpos
+= minibuf_prompt_width
;
3245 taboffset
-= minibuf_prompt_width
- old_width
;
3248 minibuf_prompt_width
= 0;
3251 /* If we're hscrolled at all, use compute_motion to skip over any
3252 text off the left edge of the window. compute_motion may know
3253 tricks to do this faster than we can. */
3256 struct position
*left_edge
3257 = compute_motion (pos
, vpos
, hpos
, 0,
3259 width
, hscroll
, taboffset
, w
);
3261 /* Retrieve the buffer position and column provided by
3262 compute_motion. We can't assume that the column will be
3263 zero, because you may have multi-column characters crossing
3266 compute_motion may have moved us past the screen position we
3267 requested, if we hit a multi-column character, or the end of
3268 the line. If so, back up. */
3269 if (left_edge
->vpos
> vpos
3270 || left_edge
->hpos
> 0)
3272 pos
= left_edge
->bufpos
;
3273 /* Since this should not be a valid multibyte character, we
3274 can decrease POS by 1. */
3276 pos_byte
= left_edge
->bytepos
- 1;
3277 hpos
= left_edge
->prevhpos
;
3281 pos
= left_edge
->bufpos
;
3282 pos_byte
= left_edge
->bytepos
;
3283 hpos
= left_edge
->hpos
;
3287 hpos
+= WINDOW_LEFT_MARGIN (w
);
3289 desired_glyphs
->bufp
[vpos
] = start
;
3290 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3292 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
3293 /* In case we don't ever write anything into it... */
3294 desired_glyphs
->charstarts
[vpos
][WINDOW_LEFT_MARGIN (w
)] = -1;
3295 leftmargin
= desired_glyphs
->glyphs
[vpos
] + WINDOW_LEFT_MARGIN (w
);
3296 endp
= leftmargin
+ width
;
3298 /* Arrange the overlays nicely for our purposes. Usually, we call
3299 display_text_line on only one line at a time, in which case this
3300 can't really hurt too much, or we call it on lines which appear
3301 one after another in the buffer, in which case all calls to
3302 recenter_overlay_lists but the first will be pretty cheap. */
3303 recenter_overlay_lists (current_buffer
, pos
);
3305 /* Loop generating characters.
3306 Stop at end of buffer, before newline,
3307 if reach or pass continuation column,
3308 or at face change. */
3310 limit_byte
= pos_byte
;
3311 next_face_change
= pos
;
3312 next_boundary
= pos
;
3315 prevpos_byte
= pos_byte
;
3317 /* If the window is hscrolled and point is in the invisible part of the
3318 current line beyond the left margin we can record the cursor location
3320 if (hscroll
&& start
<= PT
&& PT
< pos
&& cursor_vpos
< 0)
3323 cursor_hpos
= p1
- leftmargin
;
3332 while (pos
== next_boundary
)
3334 Lisp_Object position
, limit
, prop
, ww
;
3336 /* Display the overlay strings here, unless we're at ZV
3337 and have already displayed the appropriate strings
3338 on an earlier line. */
3339 if (pos
< ZV
|| !zv_strings_seen
++)
3342 unsigned char *ovstr
;
3343 ovlen
= overlay_strings (pos
, w
, &ovstr
);
3347 /* Skip the ones we did in a previous line. */
3348 ovstr
+= ovstr_done
;
3349 ovlen
-= ovstr_done
;
3358 c
= STRING_CHAR_AND_LENGTH (ovstr
, ovlen
, len
);
3359 ovstr
+= len
, ovlen
-= len
, ovstr_done
+= len
;
3360 charset
= CHAR_CHARSET (c
);
3361 cols
= (charset
== CHARSET_COMPOSITION
3362 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3363 : CHARSET_WIDTH (charset
));
3367 c
= *ovstr
++, ovlen
--, ovstr_done
++;
3370 g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3373 if (p1
>= leftmargin
&& p1
< endp
)
3374 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3378 /* If we did all the overlay strings
3379 and we have room for text, clear ovstr_done
3380 just for neatness' sake. */
3381 if (ovlen
== 0 && p1
< endp
)
3386 /* Did we reach point? Record the cursor location. */
3387 if (pos
== PT
&& cursor_vpos
< 0)
3390 cursor_hpos
= p1
- leftmargin
;
3396 XSETFASTINT (position
, pos
);
3397 limit
= Fnext_overlay_change (position
);
3398 #ifdef USE_TEXT_PROPERTIES
3399 /* This is just an estimate to give reasonable
3400 performance; nothing should go wrong if it is too small. */
3401 if (XFASTINT (limit
) > pos
+ 50)
3403 int limitpos
= pos
+ 50;
3404 XSETFASTINT (limit
, limitpos
);
3406 limit
= Fnext_single_property_change (position
, Qinvisible
,
3407 Fcurrent_buffer (), limit
);
3409 next_boundary
= XFASTINT (limit
);
3410 /* if the `invisible' property is set, we can skip to
3411 the next property change. */
3413 prop
= Fget_char_property (position
, Qinvisible
, ww
);
3414 if (TEXT_PROP_MEANS_INVISIBLE (prop
))
3416 if (pos
< PT
&& next_boundary
>= PT
)
3419 cursor_hpos
= p1
- leftmargin
;
3421 pos
= next_boundary
;
3422 pos_byte
= CHAR_TO_BYTE (pos
);
3423 last_invis_skip
= pos
;
3424 last_invis_prop
= prop
;
3428 /* Did we reach point? Record the cursor location. */
3429 if (pos
== PT
&& cursor_vpos
< 0)
3432 cursor_hpos
= p1
- leftmargin
;
3435 /* Did we hit the end of the visible region of the buffer?
3439 /* Update charstarts for the end of this line. */
3440 /* Do nothing if off the left edge or at the right edge. */
3441 if (p1
>= leftmargin
&& p1
+ 1 != endp
)
3443 int *p2x
= &charstart
[(p1
< leftmargin
3451 /* Figure out where (if at all) the
3452 redisplay_end_trigger-hook should run. */
3453 if (MARKERP (w
->redisplay_end_trigger
)
3454 && XMARKER (w
->redisplay_end_trigger
)->buffer
!= 0)
3455 e_t_h
= marker_position (w
->redisplay_end_trigger
);
3456 else if (INTEGERP (w
->redisplay_end_trigger
))
3457 e_t_h
= XINT (w
->redisplay_end_trigger
);
3461 /* If we've gone past the place to run a hook,
3463 if (pos
>= e_t_h
&& e_t_h
!= ZV
)
3465 Lisp_Object args
[3];
3467 args
[0] = Qredisplay_end_trigger_functions
;
3468 XSETWINDOW (args
[1], w
);
3469 XSETINT (args
[2], e_t_h
);
3471 /* Since we are *trying* to run these functions,
3472 don't try to run them again, even if they get an error. */
3473 w
->redisplay_end_trigger
= Qnil
;
3474 Frun_hook_with_args (3, args
);
3477 /* Notice if it changed the face of this character. */
3478 next_face_change
= pos
;
3482 /* Did we hit a face change? Figure out what face we should
3483 use now. We also hit this the first time through the
3484 loop, to see what face we should start with. */
3485 if (pos
>= next_face_change
3486 && (FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
)))
3488 int limit
= pos
+ 50;
3490 current_face
= compute_char_face (f
, w
, pos
,
3491 region_beg
, region_end
,
3492 &next_face_change
, limit
, 0);
3496 /* Compute the next place we need to stop
3497 and do something special; set PAUSE. */
3501 if (pos
< next_boundary
&& next_boundary
< pause
)
3502 pause
= next_boundary
;
3503 if (pos
< next_face_change
&& next_face_change
< pause
)
3504 pause
= next_face_change
;
3509 /* Wouldn't you hate to read the next line to someone over
3511 if (pos
< PT
&& PT
< pause
)
3513 if (pos
< GPT
&& GPT
< pause
)
3516 /* LIMIT_BYTE is not the same place in the buffer as PAUSE.
3517 It is a limit on valid characters.
3518 We use it to bound STRING_CHAR_AND_LENGTH. */
3519 limit_byte
= ZV_BYTE
;
3520 if (pos
< GPT
&& GPT_BYTE
< limit_byte
)
3521 limit_byte
= GPT_BYTE
;
3524 int temp
= CHAR_TO_BYTE (pos
);
3525 p
= BYTE_POS_ADDR (temp
);
3535 c
= STRING_CHAR_AND_LENGTH (p
, limit_byte
- pos_byte
, len
), p
+= len
;
3538 /* Let a display table override all standard display methods. */
3539 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
3541 p1
= copy_part_of_rope (f
, p1
, leftmargin
,
3542 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3543 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3544 current_face
, rev_dir_bit
);
3546 else if (c
>= 040 && c
< 0177)
3548 if (p1
>= leftmargin
)
3549 *p1
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3555 /* Same as p1prev, but after the invis_vector_contents text
3556 (if we have that on this line). */
3557 GLYPH
*p1prev_modified
;
3561 if (last_invis_skip
== pos
3562 && TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (last_invis_prop
))
3566 && indented_beyond_p (pos
+ 1, pos_byte
+ 1, selective
))
3568 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3571 if (! NILP (current_buffer
->enable_multibyte_characters
))
3572 INC_BOTH (pos
, pos_byte
);
3575 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3576 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3581 SET_PT_BOTH (opoint
, opoint_byte
);
3583 if (invis
&& selective_rlen
> 0 && p1
>= leftmargin
)
3588 cs
= charstart
+ (p1
- p1start
);
3591 p1
+= selective_rlen
;
3592 if (p1
- leftmargin
> width
)
3595 #if 0 /* This needs more work; charstarts needs to record
3596 both whether a position ho;ds an ellipsis character
3597 and what buffer position it corresponds to. */
3598 csend
= charstart
+ (p1
- p1start
);
3601 /* The idea is to use p1prev_modified instead of p1prev
3602 in the loop below over p2x. */
3603 p1prev_modified
= p1
;
3606 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3607 (p1
- p1prev
), current_face
, rev_dir_bit
);
3610 /* Update charstarts for the newline that ended this line. */
3611 /* Do nothing here for a char that's entirely off the left edge
3612 or if it starts at the right edge. */
3613 if (p1
>= leftmargin
&& p1prev
!= endp
)
3615 /* Store the newline's position into charstarts
3616 for the column where the newline starts.
3617 Store -1 for the rest of the glyphs it occupies. */
3618 int *p2x
= &charstart
[(p1prev
< leftmargin
3619 ? leftmargin
: p1prev
)
3621 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3628 /* Draw the face of the newline character as extending all the
3629 way to the end of the frame line. */
3632 if (p1
< leftmargin
)
3635 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3645 if (p1
>= leftmargin
&& p1
< endp
)
3646 *p1
= MAKE_GLYPH (f
, ' ', current_face
) | rev_dir_bit
;
3649 while ((p1
- leftmargin
+ taboffset
+ hscroll
- (hscroll
> 0))
3652 else if (c
== Ctl ('M') && selective
== -1)
3654 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3655 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3656 pos
= PT
, pos_byte
= PT_BYTE
;
3657 SET_PT_BOTH (opoint
, opoint_byte
);
3659 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3661 if (selective_rlen
> 0)
3663 p1
+= selective_rlen
;
3664 if (p1
- leftmargin
> width
)
3666 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3667 (p1
- p1prev
), current_face
, rev_dir_bit
);
3670 /* Draw the face of the newline character as extending all the
3671 way to the end of the frame line. */
3674 if (p1
< leftmargin
)
3677 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3681 /* Update charstarts for the ^M that ended this line. */
3682 /* Do nothing here for a char that's entirely off the left edge
3683 or if it starts at the right edge. */
3684 if (p1
>= leftmargin
&& p1prev
!= endp
)
3686 /* Store the newline's position into charstarts
3687 for the column where the newline starts.
3688 Store -1 for the rest of the glyphs it occupies. */
3689 int *p2x
= &charstart
[(p1prev
< leftmargin
3690 ? leftmargin
: p1prev
)
3692 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3700 else if (c
< 0200 && ctl_arrow
)
3702 if (p1
>= leftmargin
)
3704 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
3705 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
3706 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3710 if (p1
>= leftmargin
&& p1
< endp
)
3711 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
) | rev_dir_bit
;
3716 /* C is not a multibyte character. */
3717 if (p1
>= leftmargin
)
3719 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
3720 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
3721 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3725 if (p1
>= leftmargin
&& p1
< endp
)
3726 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
) | rev_dir_bit
;
3728 if (p1
>= leftmargin
&& p1
< endp
)
3729 *p1
= (MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
)
3732 if (p1
>= leftmargin
&& p1
< endp
)
3733 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
) | rev_dir_bit
;
3738 /* C is a multibyte character. */
3739 int charset
= CHAR_CHARSET (c
);
3740 int columns
= (charset
== CHARSET_COMPOSITION
3741 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3742 : CHARSET_WIDTH (charset
));
3743 GLYPH g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3747 if (p1
>= leftmargin
&& p1
< endp
)
3748 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3754 prevpos_byte
= pos_byte
;
3758 /* Update charstarts for the character just output. */
3760 /* Do nothing here for a char that's entirely off the left edge. */
3761 if (p1
>= leftmargin
)
3763 /* Store the char's position into charstarts
3764 for the first glyph occupied by this char.
3765 Store -1 for the rest of the glyphs it occupies. */
3768 int *p2x
= &charstart
[(p1prev
< leftmargin
3769 ? leftmargin
: p1prev
)
3771 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3781 val
.hpos
= - XINT (w
->hscroll
);
3788 lastpos_byte
= pos_byte
;
3790 /* Store 0 in this charstart line for the positions where
3791 there is no character. But do leave what was recorded
3792 for the character that ended the line. */
3793 /* Add 1 in the endtest to compensate for the fact that ENDP was
3794 made from WIDTH, which is 1 less than the window's actual
3796 i
= p1
- p1start
+ 1;
3797 if (p1
< leftmargin
)
3798 i
+= leftmargin
- p1
;
3799 for (; i
< endp
- p1start
+ 1; i
++)
3802 /* Handle continuation in middle of a character */
3803 /* by backing up over it */
3806 /* Don't back up if we never actually displayed any text.
3807 This occurs when the minibuffer prompt takes up the whole line. */
3810 /* Start the next line with that same character whose
3811 character code is C and the length of multi-byte form is
3814 pos_byte
= prevpos_byte
;
3817 /* C is not a multi-byte character. We can break it and
3818 start from the middle column in the next line. So,
3819 adjust VAL.HPOS to skip the columns output on this
3821 val
.hpos
+= p1prev
- endp
;
3824 /* C is a multibyte character. Since we can't broke it
3825 in the middle, the whole character should be driven
3826 into the next line. */
3827 /* As the result, the actual columns occupied by the
3828 text on this line is less than WIDTH. VAL.TAB_OFFSET
3829 must be adjusted. */
3830 taboffset
= taboffset
+ (p1prev
- endp
);
3831 /* Let's fill unused columns with TRUNCATOR or CONTINUER. */
3833 GLYPH g
= fix_glyph (f
, truncate
? truncator
: continuer
, 0);
3834 while (p1prev
< endp
)
3837 /* If POINT is at POS, cursor should not on this line. */
3839 lastpos_byte
= pos_byte
;
3845 /* Keep in this line everything up to the continuation column. */
3849 /* Finish deciding which character to start the next line on,
3850 and what hpos to start it at.
3851 Also set `lastpos' to the last position which counts as "on this line"
3852 for cursor-positioning. */
3856 if (FETCH_BYTE (pos_byte
) == '\n')
3858 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3860 /* If stopped due to a newline, start next line after it */
3861 SET_PT_BOTH (pos
+ 1, pos_byte
+ 1);
3864 /* Check again for hidden lines, in case the newline occurred exactly
3865 at the right margin. */
3866 while (PT
< ZV
&& selective
> 0
3867 && indented_beyond_p (PT
, PT_BYTE
, selective
))
3868 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3870 pos
= PT
, pos_byte
= PT_BYTE
;
3871 SET_PT_BOTH (opoint
, opoint_byte
);
3874 /* Stopped due to right margin of window */
3878 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3880 SET_PT_BOTH (pos
, pos_byte
);
3881 *p1
++ = fix_glyph (f
, truncator
, 0);
3882 /* Truncating => start next line after next newline,
3883 and point is on this line if it is before the newline,
3884 and skip none of first char of next line */
3886 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3887 while (PT
< ZV
&& selective
> 0
3888 && indented_beyond_p (PT
, PT_BYTE
, selective
));
3889 pos
= PT
, pos_byte
= PT_BYTE
;
3890 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
3891 SET_PT_BOTH (opoint
, opoint_byte
);
3893 lastpos
= pos
- (FETCH_BYTE (pos_byte
- 1) == '\n');
3894 lastpos_byte
= CHAR_TO_BYTE (lastpos
);
3899 *p1
++ = fix_glyph (f
, continuer
, 0);
3902 DEC_POS (lastpos_byte
);
3903 val
.tab_offset
= taboffset
+ width
;
3910 /* If point is at eol or in invisible text at eol,
3911 record its frame location now. */
3913 if (start
<= PT
&& PT
<= lastpos
&& cursor_vpos
< 0)
3916 cursor_hpos
= p1
- leftmargin
;
3919 if (cursor_vpos
== vpos
)
3921 if (cursor_hpos
< 0) cursor_hpos
= 0;
3922 if (cursor_hpos
> width
) cursor_hpos
= width
;
3923 cursor_hpos
+= WINDOW_LEFT_MARGIN (w
);
3924 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
3926 if (!(cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f
)
3927 && EQ (FRAME_MINIBUF_WINDOW (f
), minibuf_window
)))
3929 FRAME_CURSOR_Y (f
) = cursor_vpos
;
3930 FRAME_CURSOR_X (f
) = cursor_hpos
;
3933 if (w
== XWINDOW (selected_window
))
3935 /* Line is not continued and did not start
3936 in middle of character */
3937 if ((hpos
- WINDOW_LEFT_MARGIN (w
)
3938 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
3941 this_line_bufpos
= start
;
3942 this_line_buffer
= current_buffer
;
3943 this_line_vpos
= cursor_vpos
;
3944 this_line_start_hpos
= hpos
- WINDOW_LEFT_MARGIN (w
);
3945 this_line_endpos
= Z
- lastpos
;
3948 this_line_bufpos
= 0;
3953 /* If hscroll and line not empty, insert truncation-at-left marker */
3954 if (hscroll
&& lastpos
!= start
)
3956 GLYPH g
= fix_glyph (f
, truncator
, 0);
3958 if (p1
<= leftmargin
)
3959 p1
= leftmargin
+ 1;
3960 else /* MULE: it may be a wide-column character */
3962 p1prev
= leftmargin
+ 1;
3963 while (p1prev
< p1
&& *p1prev
& GLYPH_MASK_PADDING
)
3968 if (!WINDOW_RIGHTMOST_P (w
))
3971 if (p1
< leftmargin
) p1
= leftmargin
;
3972 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
3974 /* Don't draw vertical bars if we're using scroll bars. They're
3975 covered up by the scroll bars, and it's distracting to see
3976 them when the scroll bar windows are flickering around to be
3978 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3981 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
3984 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3985 *p1
++ = (dp
&& INTEGERP (DISP_BORDER_GLYPH (dp
))
3986 ? XINT (DISP_BORDER_GLYPH (dp
))
3989 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
3990 p1
- desired_glyphs
->glyphs
[vpos
]);
3991 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
3993 /* If the start of this line is the overlay arrow-position,
3994 then put the arrow string into the display-line. */
3996 if (MARKERP (Voverlay_arrow_position
)
3997 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
3998 && start
== marker_position (Voverlay_arrow_position
)
3999 && STRINGP (Voverlay_arrow_string
)
4000 && ! overlay_arrow_seen
)
4003 int len
= XSTRING (Voverlay_arrow_string
)->size
;
4009 if (!NULL_INTERVAL_P (XSTRING (Voverlay_arrow_string
)->intervals
))
4011 /* If the arrow string has text props, obey them when displaying. */
4012 for (i
= 0, i_byte
= 0; i
< len
; )
4015 Lisp_Object face
, ilisp
;
4018 if (STRING_MULTIBYTE (Voverlay_arrow_string
))
4019 FETCH_STRING_CHAR_ADVANCE (c
, Voverlay_arrow_string
, i
, i_byte
);
4021 c
= XSTRING (Voverlay_arrow_string
)->data
[i
++];
4023 XSETFASTINT (ilisp
, i
);
4024 face
= Fget_text_property (ilisp
, Qface
, Voverlay_arrow_string
);
4025 newface
= compute_glyph_face_1 (f
, face
, 0);
4026 leftmargin
[i
] = FAST_MAKE_GLYPH (c
, newface
);
4030 #endif /* HAVE_FACES */
4032 for (i
= 0; i
< len
; i
++)
4033 leftmargin
[i
] = p
[i
];
4036 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
4037 arrow_end
= (leftmargin
- desired_glyphs
->glyphs
[vpos
]) + len
;
4038 if (desired_glyphs
->used
[vpos
] < arrow_end
)
4039 desired_glyphs
->used
[vpos
] = arrow_end
;
4041 overlay_arrow_seen
= 1;
4045 val
.bytepos
= pos_byte
;
4046 val
.ovstring_chars_done
= ovstr_done
;
4047 val_display_text_line
= val
;
4048 return &val_display_text_line
;
4051 /* Redisplay the menu bar in the frame for window W. */
4054 display_menu_bar (w
)
4057 Lisp_Object items
, tail
;
4058 register int vpos
= 0;
4059 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4060 int maxendcol
= FRAME_WIDTH (f
);
4065 if (!NILP (Vwindow_system
))
4069 #ifdef USE_X_TOOLKIT
4072 #endif /* USE_X_TOOLKIT */
4074 get_display_line (f
, vpos
, 0);
4076 items
= FRAME_MENU_BAR_ITEMS (f
);
4077 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 4)
4079 Lisp_Object pos
, string
;
4080 string
= XVECTOR (items
)->contents
[i
+ 1];
4084 XSETFASTINT (XVECTOR (items
)->contents
[i
+ 3], hpos
);
4086 if (hpos
< maxendcol
)
4087 hpos
= display_string (w
, vpos
,
4088 XSTRING (string
)->data
,
4089 XSTRING (string
)->size_byte
,
4090 hpos
, 0, 0, hpos
, maxendcol
,
4091 STRING_MULTIBYTE (string
));
4092 /* Put a space between items. */
4093 if (hpos
< maxendcol
)
4095 int hpos1
= hpos
+ 1;
4096 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
4097 min (hpos1
, maxendcol
), maxendcol
, 0);
4101 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4102 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4104 /* Fill out the line with spaces. */
4105 if (maxendcol
> hpos
)
4106 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
, 0);
4108 /* Clear the rest of the lines allocated to the menu bar. */
4110 while (vpos
< FRAME_MENU_BAR_LINES (f
))
4111 get_display_line (f
, vpos
++, 0);
4114 /* Display the mode line for window w */
4117 display_mode_line (w
)
4120 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
4121 register int left
= WINDOW_LEFT_MARGIN (w
);
4122 register int right
= WINDOW_RIGHT_MARGIN (w
);
4123 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4125 line_number_displayed
= 0;
4126 w
->column_number_displayed
= Qnil
;
4128 get_display_line (f
, vpos
, left
);
4130 /* Temporarily make frame F's kboard the current kboard
4131 so that kboard-local variables in the mode_line_format
4132 will get the right values. */
4133 push_frame_kboard (f
);
4135 display_mode_element (w
, vpos
, left
, 0, right
, right
,
4136 current_buffer
->mode_line_format
);
4138 pop_frame_kboard ();
4140 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4142 /* Put the mode line in inverse video.
4143 Use faces if possible, since that lets us handle
4144 partial-width windows and avoid inverting the scroll bar columns. */
4146 if (! FRAME_TERMCAP_P (f
) && mode_line_inverse_video
)
4148 /* For a partial width window, explicitly set face of each glyph. */
4150 unsigned int padding
;
4151 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
4152 for (i
= left
; i
< right
; ++i
)
4154 padding
= ptr
[i
] & GLYPH_MASK_PADDING
;
4155 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1) | padding
;
4161 /* Make the mode line inverse video if the entire line
4162 is made of mode lines.
4163 I.e. if this window is full width,
4164 or if it is the child of a full width window
4165 (which implies that that window is split side-by-side
4166 and the rest of this line is mode lines of the sibling windows). */
4167 if (WINDOW_FULL_WIDTH_P (w
)
4168 || WINDOW_FULL_WIDTH_P (XWINDOW (w
->parent
)))
4169 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4172 /* Contribute ELT to the mode line for window W.
4173 How it translates into text depends on its data type.
4175 VPOS is the position of the mode line being displayed.
4177 HPOS is the position (absolute on frame) where this element's text
4178 should start. The output is truncated automatically at the right
4181 DEPTH is the depth in recursion. It is used to prevent
4182 infinite recursion here.
4184 MINENDCOL is the hpos before which the element may not end.
4185 The element is padded at the right with spaces if nec
4186 to reach this column.
4188 MAXENDCOL is the hpos past which this element may not extend.
4189 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
4190 (This is necessary to make nested padding and truncation work.)
4192 Returns the hpos of the end of the text generated by ELT.
4193 The next element will receive that value as its HPOS arg,
4194 so as to concatenate the elements. */
4197 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
4199 register int vpos
, hpos
;
4202 register int maxendcol
;
4203 register Lisp_Object elt
;
4211 switch (SWITCH_ENUM_CAST (XTYPE (elt
)))
4215 /* A string: output it and check for %-constructs within it. */
4216 register unsigned char c
;
4217 register unsigned char *this = XSTRING (elt
)->data
;
4219 while (hpos
< maxendcol
&& *this)
4221 unsigned char *last
= this;
4222 while ((c
= *this++) != '\0' && c
!= '%')
4224 if (this - 1 != last
)
4226 register int lim
= --this - last
+ hpos
;
4227 if (frame_title_ptr
)
4228 hpos
= store_frame_title (last
, hpos
, min (lim
, maxendcol
));
4230 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
4231 hpos
, min (lim
, maxendcol
),
4232 STRING_MULTIBYTE (elt
));
4236 register int minendcol
;
4237 register int spec_width
= 0;
4239 /* We can't allow -ve args due to the "%-" construct */
4240 /* Argument specifies minwidth but not maxwidth
4241 (maxwidth can be specified by
4242 (<negative-number> . <stuff>) mode-line elements) */
4244 while ((c
= *this++) >= '0' && c
<= '9')
4246 spec_width
= spec_width
* 10 + (c
- '0');
4249 minendcol
= hpos
+ spec_width
;
4250 if (minendcol
> maxendcol
)
4252 spec_width
= maxendcol
- hpos
;
4253 minendcol
= maxendcol
;
4257 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4258 spec_width
, maxendcol
,
4259 Vglobal_mode_string
);
4262 char *spec
= decode_mode_spec (w
, c
, spec_width
,
4264 if (frame_title_ptr
)
4265 hpos
= store_frame_title (spec
, minendcol
, maxendcol
);
4267 hpos
= display_string (w
, vpos
, spec
, -1,
4269 minendcol
, maxendcol
, -1);
4277 /* A symbol: process the value of the symbol recursively
4278 as if it appeared here directly. Avoid error if symbol void.
4279 Special case: if value of symbol is a string, output the string
4282 register Lisp_Object tem
;
4283 tem
= Fboundp (elt
);
4286 tem
= Fsymbol_value (elt
);
4287 /* If value is a string, output that string literally:
4288 don't check for % within it. */
4291 if (frame_title_ptr
)
4292 hpos
= store_frame_title (XSTRING (tem
)->data
,
4293 minendcol
, maxendcol
);
4295 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
4296 XSTRING (tem
)->size_byte
,
4297 hpos
, 0, 1, minendcol
, maxendcol
,
4298 STRING_MULTIBYTE (tem
));
4300 /* Give up right away for nil or t. */
4301 else if (!EQ (tem
, elt
))
4302 { elt
= tem
; goto tail_recurse
; }
4309 register Lisp_Object car
, tem
;
4311 /* A cons cell: three distinct cases.
4312 If first element is a string or a cons, process all the elements
4313 and effectively concatenate them.
4314 If first element is a negative number, truncate displaying cdr to
4315 at most that many characters. If positive, pad (with spaces)
4316 to at least that many characters.
4317 If first element is a symbol, process the cadr or caddr recursively
4318 according to whether the symbol's value is non-nil or nil. */
4319 car
= XCONS (elt
)->car
;
4322 tem
= Fboundp (car
);
4323 elt
= XCONS (elt
)->cdr
;
4326 /* elt is now the cdr, and we know it is a cons cell.
4327 Use its car if CAR has a non-nil value. */
4330 tem
= Fsymbol_value (car
);
4332 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
4334 /* Symbol's value is nil (or symbol is unbound)
4335 Get the cddr of the original list
4336 and if possible find the caddr and use that. */
4337 elt
= XCONS (elt
)->cdr
;
4340 else if (!CONSP (elt
))
4342 elt
= XCONS (elt
)->car
;
4345 else if (INTEGERP (car
))
4347 register int lim
= XINT (car
);
4348 elt
= XCONS (elt
)->cdr
;
4350 /* Negative int means reduce maximum width.
4351 DO NOT change MINENDCOL here!
4352 (20 -10 . foo) should truncate foo to 10 col
4353 and then pad to 20. */
4354 maxendcol
= min (maxendcol
, hpos
- lim
);
4357 /* Padding specified. Don't let it be more than
4360 if (lim
> maxendcol
)
4362 /* If that's more padding than already wanted, queue it.
4363 But don't reduce padding already specified even if
4364 that is beyond the current truncation point. */
4365 if (lim
> minendcol
)
4370 else if (STRINGP (car
) || CONSP (car
))
4372 register int limit
= 50;
4373 /* LIMIT is to protect against circular lists. */
4374 while (CONSP (elt
) && --limit
> 0
4375 && hpos
< maxendcol
)
4377 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4380 elt
= XCONS (elt
)->cdr
;
4388 if (frame_title_ptr
)
4389 hpos
= store_frame_title ("*invalid*", minendcol
, maxendcol
);
4391 hpos
= display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
4392 minendcol
, maxendcol
, 0);
4396 if (minendcol
> hpos
)
4397 if (frame_title_ptr
)
4398 hpos
= store_frame_title ("", minendcol
, maxendcol
);
4400 hpos
= display_string (w
, vpos
, "", 0, hpos
,
4401 0, 1, minendcol
, maxendcol
, 0);
4405 /* Write a null-terminated, right justified decimal representation of
4406 the positive integer D to BUF using a minimal field width WIDTH. */
4409 pint2str (buf
, width
, d
)
4414 register char *p
= buf
;
4421 *p
++ = d
% 10 + '0';
4424 for (width
-= (int) (p
- buf
); width
> 0; --width
) *p
++ = ' ';
4434 /* Set a mnemonic character for CODING_SYSTEM (Lisp symbol) in BUF.
4435 If EOL_FLAG is 1, set also a mnemonic character for end-of-line
4436 type of CODING_SYSTEM. Return updated pointer into BUF. */
4439 decode_mode_spec_coding (coding_system
, buf
, eol_flag
)
4440 Lisp_Object coding_system
;
4445 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
4447 val
= coding_system
;
4449 if (NILP (val
)) /* Not yet decided. */
4454 *buf
++ = eol_mnemonic_undecided
;
4455 /* Don't mention EOL conversion if it isn't decided. */
4459 Lisp_Object eolvalue
;
4461 eolvalue
= Fget (coding_system
, Qeol_type
);
4463 while (!NILP (val
) && SYMBOLP (val
))
4465 val
= Fget (val
, Qcoding_system
);
4466 if (NILP (eolvalue
))
4467 eolvalue
= Fget (val
, Qeol_type
);
4471 *buf
++ = XFASTINT (XVECTOR (val
)->contents
[1]);
4475 /* The EOL conversion we are using. */
4477 /* The EOL conversion that is normal on this system. */
4479 if (NILP (eolvalue
)) /* Not yet decided. */
4480 eoltype
= eol_mnemonic_undecided
;
4481 else if (VECTORP (eolvalue
)) /* Not yet decided. */
4482 eoltype
= eol_mnemonic_undecided
;
4483 else /* INTEGERP (eolvalue) -- 0:LF, 1:CRLF, 2:CR */
4484 eoltype
= (XFASTINT (eolvalue
) == 0
4486 : (XFASTINT (eolvalue
) == 1
4487 ? eol_mnemonic_dos
: eol_mnemonic_mac
));
4489 /* Mention the EOL conversion if it is not the usual one. */
4496 /* Return a string for the output of a mode line %-spec for window W,
4497 generated by character C. SPEC_WIDTH is the field width when
4498 padding to the left (%c, %l). The value returned from this
4499 function will later be truncated to width MAXWIDTH. */
4501 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
4504 decode_mode_spec (w
, c
, spec_width
, maxwidth
)
4507 register int spec_width
;
4508 register int maxwidth
;
4511 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4512 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
4513 struct buffer
*b
= XBUFFER (w
->buffer
);
4516 if (maxwidth
> FRAME_WIDTH (f
))
4517 maxwidth
= FRAME_WIDTH (f
);
4522 if (!NILP (b
->read_only
))
4524 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4529 /* This differs from %* only for a modified read-only buffer. */
4530 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4532 if (!NILP (b
->read_only
))
4537 /* This differs from %* in ignoring read-only-ness. */
4538 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4550 if (command_loop_level
> 5)
4552 p
= decode_mode_spec_buf
;
4553 for (i
= 0; i
< command_loop_level
; i
++)
4556 return decode_mode_spec_buf
;
4564 if (command_loop_level
> 5)
4566 p
= decode_mode_spec_buf
;
4567 for (i
= 0; i
< command_loop_level
; i
++)
4570 return decode_mode_spec_buf
;
4578 if (maxwidth
< sizeof (lots_of_dashes
))
4579 return lots_of_dashes
;
4582 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
4586 return decode_mode_spec_buf
;
4592 if (maxwidth
>= 3 && XSTRING (obj
)->size_byte
> maxwidth
)
4594 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
4595 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
4596 decode_mode_spec_buf
[maxwidth
] = '\0';
4597 return decode_mode_spec_buf
;
4604 int col
= current_column ();
4605 XSETFASTINT (w
->column_number_displayed
, col
);
4606 pint2str (decode_mode_spec_buf
, spec_width
, col
);
4607 return decode_mode_spec_buf
;
4611 /* %F displays the frame name. */
4612 /* Systems that can only display a single frame at a time should
4613 NOT replace the frame name with the (constant) frame title,
4614 since then they won't be able to tell which frame is that. */
4615 if (FRAME_WINDOW_P (f
) && !NILP (f
->title
))
4616 return (char *) XSTRING (f
->title
)->data
;
4617 if (f
->explicit_name
|| ! FRAME_WINDOW_P (f
))
4618 return (char *) XSTRING (f
->name
)->data
;
4626 else if (STRINGP (obj
) && XSTRING (obj
)->size_byte
> maxwidth
)
4628 bcopy ("...", decode_mode_spec_buf
, 3);
4629 bcopy (XSTRING (obj
)->data
+ XSTRING (obj
)->size_byte
- maxwidth
+ 3,
4630 decode_mode_spec_buf
+ 3, maxwidth
- 3);
4631 return decode_mode_spec_buf
;
4638 int startpos
= XMARKER (w
->start
)->charpos
;
4639 int startpos_byte
= marker_byte_position (w
->start
);
4640 int line
, linepos
, linepos_byte
, topline
;
4643 int height
= XFASTINT (w
->height
);
4645 /* If we decided that this buffer isn't suitable for line numbers,
4646 don't forget that too fast. */
4647 if (EQ (w
->base_line_pos
, w
->buffer
))
4649 /* But do forget it, if the window shows a different buffer now. */
4650 else if (BUFFERP (w
->base_line_pos
))
4651 w
->base_line_pos
= Qnil
;
4653 /* If the buffer is very big, don't waste time. */
4654 if (BUF_ZV (b
) - BUF_BEGV (b
) > line_number_display_limit
)
4656 w
->base_line_pos
= Qnil
;
4657 w
->base_line_number
= Qnil
;
4661 if (!NILP (w
->base_line_number
)
4662 && !NILP (w
->base_line_pos
)
4663 && XFASTINT (w
->base_line_pos
) <= startpos
)
4665 line
= XFASTINT (w
->base_line_number
);
4666 linepos
= XFASTINT (w
->base_line_pos
);
4667 linepos_byte
= buf_charpos_to_bytepos (b
, linepos
);
4672 linepos
= BUF_BEGV (b
);
4673 linepos_byte
= BUF_BEGV_BYTE (b
);
4676 /* Count lines from base line to window start position. */
4677 nlines
= display_count_lines (linepos
, linepos_byte
,
4681 topline
= nlines
+ line
;
4683 /* Determine a new base line, if the old one is too close
4684 or too far away, or if we did not have one.
4685 "Too close" means it's plausible a scroll-down would
4687 if (startpos
== BUF_BEGV (b
))
4689 XSETFASTINT (w
->base_line_number
, topline
);
4690 XSETFASTINT (w
->base_line_pos
, BUF_BEGV (b
));
4692 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
4693 || linepos
== BUF_BEGV (b
))
4695 int limit
= BUF_BEGV (b
);
4696 int limit_byte
= BUF_BEGV_BYTE (b
);
4698 int distance
= (height
* 2 + 30) * 200;
4700 if (startpos
- distance
> limit
)
4702 limit
= startpos
- distance
;
4703 limit_byte
= CHAR_TO_BYTE (limit
);
4706 nlines
= display_count_lines (startpos
, startpos_byte
,
4708 - (height
* 2 + 30),
4710 /* If we couldn't find the lines we wanted within
4712 give up on line numbers for this window. */
4713 if (position
== limit_byte
&& limit
== startpos
- distance
)
4715 w
->base_line_pos
= w
->buffer
;
4716 w
->base_line_number
= Qnil
;
4720 XSETFASTINT (w
->base_line_number
, topline
- nlines
);
4721 XSETFASTINT (w
->base_line_pos
, BYTE_TO_CHAR (position
));
4724 /* Now count lines from the start pos to point. */
4725 nlines
= display_count_lines (startpos
, startpos_byte
,
4726 PT_BYTE
, PT
, &junk
);
4728 /* Record that we did display the line number. */
4729 line_number_displayed
= 1;
4731 /* Make the string to show. */
4732 pint2str (decode_mode_spec_buf
, spec_width
, topline
+ nlines
);
4733 return decode_mode_spec_buf
;
4736 char* p
= decode_mode_spec_buf
;
4737 for (spec_width
-= 2; spec_width
> 0; --spec_width
) *p
++ = ' ';
4739 return decode_mode_spec_buf
;
4749 if (BUF_BEGV (b
) > BUF_BEG (b
) || BUF_ZV (b
) < BUF_Z (b
))
4755 int pos
= marker_position (w
->start
);
4756 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4758 if (XFASTINT (w
->window_end_pos
) <= BUF_Z (b
) - BUF_ZV (b
))
4760 if (pos
<= BUF_BEGV (b
))
4765 else if (pos
<= BUF_BEGV (b
))
4769 if (total
> 1000000)
4770 /* Do it differently for a large value, to avoid overflow. */
4771 total
= ((pos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4773 total
= ((pos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4774 /* We can't normally display a 3-digit number,
4775 so get us a 2-digit number that is close. */
4778 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4779 return decode_mode_spec_buf
;
4783 /* Display percentage of size above the bottom of the screen. */
4786 int toppos
= marker_position (w
->start
);
4787 int botpos
= BUF_Z (b
) - XFASTINT (w
->window_end_pos
);
4788 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4790 if (botpos
>= BUF_ZV (b
))
4792 if (toppos
<= BUF_BEGV (b
))
4799 if (total
> 1000000)
4800 /* Do it differently for a large value, to avoid overflow. */
4801 total
= ((botpos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4803 total
= ((botpos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4804 /* We can't normally display a 3-digit number,
4805 so get us a 2-digit number that is close. */
4808 if (toppos
<= BUF_BEGV (b
))
4809 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
4811 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4812 return decode_mode_spec_buf
;
4817 /* status of process */
4818 obj
= Fget_buffer_process (w
->buffer
);
4820 return "no process";
4822 obj
= Fsymbol_name (Fprocess_status (obj
));
4826 case 't': /* indicate TEXT or BINARY */
4827 #ifdef MODE_LINE_BINARY_TEXT
4828 return MODE_LINE_BINARY_TEXT (b
);
4834 /* coding-system (not including end-of-line format) */
4836 /* coding-system (including end-of-line type) */
4838 int eol_flag
= (c
== 'Z');
4839 char *p
= decode_mode_spec_buf
;
4841 if (! FRAME_WINDOW_P (f
))
4843 /* No need to mention EOL here--the terminal never needs
4844 to do EOL conversion. */
4845 p
= decode_mode_spec_coding (keyboard_coding
.symbol
, p
, 0);
4846 p
= decode_mode_spec_coding (terminal_coding
.symbol
, p
, 0);
4848 p
= decode_mode_spec_coding (b
->buffer_file_coding_system
,
4851 #if 0 /* This proves to be annoying; I think we can do without. -- rms. */
4853 obj
= Fget_buffer_process (Fcurrent_buffer ());
4856 p
= decode_mode_spec_coding (XPROCESS (obj
)->decode_coding_system
,
4858 p
= decode_mode_spec_coding (XPROCESS (obj
)->encode_coding_system
,
4861 #endif /* subprocesses */
4864 return decode_mode_spec_buf
;
4869 return (char *) XSTRING (obj
)->data
;
4874 /* Count up to COUNT lines starting from START / START_BYTE.
4875 But don't go beyond LIMIT_BYTE.
4876 Return the number of lines thus found (always nonnegative).
4878 Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */
4881 display_count_lines (start
, start_byte
, limit_byte
, count
, byte_pos_ptr
)
4882 int start
, start_byte
, limit_byte
, count
;
4885 register unsigned char *cursor
;
4886 unsigned char *base
;
4888 register int ceiling
;
4889 register unsigned char *ceiling_addr
;
4890 int orig_count
= count
;
4892 /* If we are not in selective display mode,
4893 check only for newlines. */
4894 int selective_display
= (!NILP (current_buffer
->selective_display
)
4895 && !INTEGERP (current_buffer
->selective_display
));
4899 while (start_byte
< limit_byte
)
4901 ceiling
= BUFFER_CEILING_OF (start_byte
);
4902 ceiling
= min (limit_byte
- 1, ceiling
);
4903 ceiling_addr
= BYTE_POS_ADDR (ceiling
) + 1;
4904 base
= (cursor
= BYTE_POS_ADDR (start_byte
));
4907 if (selective_display
)
4908 while (*cursor
!= '\n' && *cursor
!= 015 && ++cursor
!= ceiling_addr
)
4911 while (*cursor
!= '\n' && ++cursor
!= ceiling_addr
)
4914 if (cursor
!= ceiling_addr
)
4918 start_byte
+= cursor
- base
+ 1;
4919 *byte_pos_ptr
= start_byte
;
4923 if (++cursor
== ceiling_addr
)
4929 start_byte
+= cursor
- base
;
4934 while (start_byte
> limit_byte
)
4936 ceiling
= BUFFER_FLOOR_OF (start_byte
- 1);
4937 ceiling
= max (limit_byte
, ceiling
);
4938 ceiling_addr
= BYTE_POS_ADDR (ceiling
) - 1;
4939 base
= (cursor
= BYTE_POS_ADDR (start_byte
- 1) + 1);
4942 if (selective_display
)
4943 while (--cursor
!= ceiling_addr
4944 && *cursor
!= '\n' && *cursor
!= 015)
4947 while (--cursor
!= ceiling_addr
&& *cursor
!= '\n')
4950 if (cursor
!= ceiling_addr
)
4954 start_byte
+= cursor
- base
+ 1;
4955 *byte_pos_ptr
= start_byte
;
4956 /* When scanning backwards, we should
4957 not count the newline posterior to which we stop. */
4958 return - orig_count
- 1;
4964 /* Here we add 1 to compensate for the last decrement
4965 of CURSOR, which took it past the valid range. */
4966 start_byte
+= cursor
- base
+ 1;
4970 *byte_pos_ptr
= limit_byte
;
4973 return - orig_count
+ count
;
4974 return orig_count
- count
;
4978 /* Display STRING on one line of window W, starting at HPOS.
4979 Display at position VPOS. Caller should have done get_display_line.
4980 If VPOS == -1, display it as the current frame's title.
4981 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
4983 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
4985 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
4986 MAXCOL is the last column ok to end at. Truncate here.
4987 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
4988 Both count from the left edge of the frame, as does HPOS.
4989 The right edge of W is an implicit maximum.
4990 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
4992 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
4993 at the place where the current window ends in this line
4994 and not display anything beyond there. Otherwise, only MAXCOL
4995 controls where to stop output.
4997 MULTIBYTE can be 0 meaning do not display multibyte chars,
4998 1 meaning do display them, or -1 meaning obey the current buffer's
4999 value of enable_multibyte_characters.
5001 Returns ending hpos. */
5004 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
5005 obey_window_width
, mincol
, maxcol
, multibyte
)
5007 unsigned char *string
;
5011 int obey_window_width
;
5018 int hscroll
= XINT (w
->hscroll
);
5019 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
5020 register GLYPH
*start
;
5021 register GLYPH
*end
;
5022 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
5023 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
5024 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
5025 int window_width
= XFASTINT (w
->width
);
5027 /* Use the standard display table, not the window's display table.
5028 We don't want the mode line in rot13. */
5029 register struct Lisp_Char_Table
*dp
= 0;
5032 if (multibyte
== -1)
5033 multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
5034 /* Now multibyte is 1 if we should display multibyte characters. */
5036 if (DISP_TABLE_P (Vstandard_display_table
))
5037 dp
= XCHAR_TABLE (Vstandard_display_table
);
5039 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
5042 start
= desired_glyphs
->glyphs
[vpos
];
5044 if (obey_window_width
)
5046 start
+= XFASTINT (w
->left
);
5047 end
= start
+ window_width
- (truncate
!= 0);
5049 if (!WINDOW_RIGHTMOST_P (w
))
5051 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
5055 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
5058 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
5063 if (! obey_window_width
5064 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
5065 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
5067 /* Store 0 in charstart for these columns. */
5068 for (i
= (hpos
>= 0 ? hpos
: 0); i
< end
- p1start
+ hpos
; i
++)
5069 desired_glyphs
->charstarts
[vpos
][i
] = 0;
5071 if (maxcol
>= 0 && mincol
> maxcol
)
5075 /* We need this value for multibyte characters. */
5076 length
= strlen (string
);
5078 /* We set truncated to 1 if we get stopped by trying to pass END
5079 (that is, trying to pass MAXCOL.) */
5088 c
= STRING_CHAR_AND_LENGTH (string
, length
, len
);
5090 c
= *string
, len
= 1;
5092 string
+= len
, length
-= len
;
5100 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
5102 p1
= copy_part_of_rope (f
, p1
, start
,
5103 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
5104 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
5107 else if (c
>= 040 && c
< 0177)
5117 if (p1
>= start
&& p1
< end
)
5121 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
5123 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
5127 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
5128 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
5129 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
5132 if (p1
>= start
&& p1
< end
)
5138 /* C is a control character or a binary byte data. */
5141 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
5142 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
5143 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
5146 if (p1
>= start
&& p1
< end
)
5147 *p1
= (c
>> 6) + '0';
5149 if (p1
>= start
&& p1
< end
)
5150 *p1
= (7 & (c
>> 3)) + '0';
5152 if (p1
>= start
&& p1
< end
)
5153 *p1
= (7 & c
) + '0';
5158 /* C is a multibyte character. */
5159 int charset
= CHAR_CHARSET (c
);
5160 int columns
= (charset
== CHARSET_COMPOSITION
5161 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
5162 : CHARSET_WIDTH (charset
));
5166 /* Since we can't show the left part of C, fill all
5167 columns with spaces. */
5168 columns
-= start
- p1
;
5177 else if (p1
+ columns
> end
)
5179 /* Since we can't show the right part of C, fill all
5180 columns with TRUNCATE if TRUNCATE is specified. */
5184 *p1
++ = fix_glyph (f
, truncate
, 0);
5185 /* And tell the line is truncated. */
5192 /* We can show the whole glyph of C. */
5195 *p1
++ = c
| GLYPH_MASK_PADDING
;
5203 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
5205 else if (mincol
>= 0)
5207 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
5213 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
5215 if (len
> desired_glyphs
->used
[vpos
])
5216 desired_glyphs
->used
[vpos
] = len
;
5217 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
5223 /* This is like a combination of memq and assq.
5224 Return 1 if PROPVAL appears as an element of LIST
5225 or as the car of an element of LIST.
5226 If PROPVAL is a list, compare each element against LIST
5227 in that way, and return 1 if any element of PROPVAL is found in LIST.
5229 This function cannot quit. */
5232 invisible_p (propval
, list
)
5233 register Lisp_Object propval
;
5236 register Lisp_Object tail
, proptail
;
5237 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5239 register Lisp_Object tem
;
5240 tem
= XCONS (tail
)->car
;
5241 if (EQ (propval
, tem
))
5243 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5246 if (CONSP (propval
))
5247 for (proptail
= propval
; CONSP (proptail
);
5248 proptail
= XCONS (proptail
)->cdr
)
5250 Lisp_Object propelt
;
5251 propelt
= XCONS (proptail
)->car
;
5252 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5254 register Lisp_Object tem
;
5255 tem
= XCONS (tail
)->car
;
5256 if (EQ (propelt
, tem
))
5258 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5265 /* Return 1 if PROPVAL appears as the car of an element of LIST
5266 and the cdr of that element is non-nil.
5267 If PROPVAL is a list, check each element of PROPVAL in that way,
5268 and the first time some element is found,
5269 return 1 if the cdr of that element is non-nil.
5271 This function cannot quit. */
5274 invisible_ellipsis_p (propval
, list
)
5275 register Lisp_Object propval
;
5278 register Lisp_Object tail
, proptail
;
5279 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5281 register Lisp_Object tem
;
5282 tem
= XCONS (tail
)->car
;
5283 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5284 return ! NILP (XCONS (tem
)->cdr
);
5286 if (CONSP (propval
))
5287 for (proptail
= propval
; CONSP (proptail
);
5288 proptail
= XCONS (proptail
)->cdr
)
5290 Lisp_Object propelt
;
5291 propelt
= XCONS (proptail
)->car
;
5292 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5294 register Lisp_Object tem
;
5295 tem
= XCONS (tail
)->car
;
5296 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5297 return ! NILP (XCONS (tem
)->cdr
);
5306 staticpro (&Qmenu_bar_update_hook
);
5307 Qmenu_bar_update_hook
= intern ("menu-bar-update-hook");
5309 staticpro (&Qoverriding_terminal_local_map
);
5310 Qoverriding_terminal_local_map
= intern ("overriding-terminal-local-map");
5312 staticpro (&Qoverriding_local_map
);
5313 Qoverriding_local_map
= intern ("overriding-local-map");
5315 staticpro (&Qwindow_scroll_functions
);
5316 Qwindow_scroll_functions
= intern ("window-scroll-functions");
5318 staticpro (&Qredisplay_end_trigger_functions
);
5319 Qredisplay_end_trigger_functions
= intern ("redisplay-end-trigger-functions");
5321 staticpro (&last_arrow_position
);
5322 staticpro (&last_arrow_string
);
5323 last_arrow_position
= Qnil
;
5324 last_arrow_string
= Qnil
;
5326 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
5327 "String (or mode line construct) included (normally) in `mode-line-format'.");
5328 Vglobal_mode_string
= Qnil
;
5330 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
5331 "Marker for where to display an arrow on top of the buffer text.\n\
5332 This must be the beginning of a line in order to work.\n\
5333 See also `overlay-arrow-string'.");
5334 Voverlay_arrow_position
= Qnil
;
5336 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
5337 "String to display as an arrow. See also `overlay-arrow-position'.");
5338 Voverlay_arrow_string
= Qnil
;
5340 DEFVAR_INT ("scroll-step", &scroll_step
,
5341 "*The number of lines to try scrolling a window by when point moves out.\n\
5342 If that fails to bring point back on frame, point is centered instead.\n\
5343 If this is zero, point is always centered after it moves off frame.");
5345 DEFVAR_INT ("scroll-conservatively", &scroll_conservatively
,
5346 "*Scroll up to this many lines, to bring point back on screen.");
5347 scroll_conservatively
= 0;
5349 DEFVAR_INT ("scroll-margin", &scroll_margin
,
5350 "*Number of lines of margin at the top and bottom of a window.\n\
5351 Recenter the window whenever point gets within this many lines\n\
5352 of the top or bottom of the window.");
5355 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
5357 DEFVAR_BOOL ("truncate-partial-width-windows",
5358 &truncate_partial_width_windows
,
5359 "*Non-nil means truncate lines in all windows less than full frame wide.");
5360 truncate_partial_width_windows
= 1;
5362 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
5363 "*Non-nil means use inverse video for the mode line.");
5364 mode_line_inverse_video
= 1;
5366 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
5367 "*Maximum buffer size for which line number should be displayed.");
5368 line_number_display_limit
= 1000000;
5370 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
5371 "*Non-nil means highlight region even in nonselected windows.");
5372 highlight_nonselected_windows
= 0;
5374 DEFVAR_BOOL ("multiple-frames", &multiple_frames
,
5375 "Non-nil if more than one frame is visible on this display.\n\
5376 Minibuffer-only frames don't count, but iconified frames do.\n\
5377 This variable is not guaranteed to be accurate except while processing\n\
5378 `frame-title-format' and `icon-title-format'.");
5380 DEFVAR_LISP ("frame-title-format", &Vframe_title_format
,
5381 "Template for displaying the titlebar of visible frames.\n\
5382 \(Assuming the window manager supports this feature.)\n\
5383 This variable has the same structure as `mode-line-format' (which see),\n\
5384 and is used only on frames for which no explicit name has been set\n\
5385 \(see `modify-frame-parameters').");
5386 DEFVAR_LISP ("icon-title-format", &Vicon_title_format
,
5387 "Template for displaying the titlebar of an iconified frame.\n\
5388 \(Assuming the window manager supports this feature.)\n\
5389 This variable has the same structure as `mode-line-format' (which see),\n\
5390 and is used only on frames for which no explicit name has been set\n\
5391 \(see `modify-frame-parameters').");
5393 = Vframe_title_format
5394 = Fcons (intern ("multiple-frames"),
5395 Fcons (build_string ("%b"),
5396 Fcons (Fcons (build_string (""),
5397 Fcons (intern ("invocation-name"),
5398 Fcons (build_string ("@"),
5399 Fcons (intern ("system-name"),
5403 DEFVAR_LISP ("message-log-max", &Vmessage_log_max
,
5404 "Maximum number of lines to keep in the message log buffer.\n\
5405 If nil, disable message logging. If t, log messages but don't truncate\n\
5406 the buffer when it becomes large.");
5407 XSETFASTINT (Vmessage_log_max
, 50);
5409 DEFVAR_LISP ("window-size-change-functions", &Vwindow_size_change_functions
,
5410 "Functions called before redisplay, if window sizes have changed.\n\
5411 The value should be a list of functions that take one argument.\n\
5412 Just before redisplay, for each frame, if any of its windows have changed\n\
5413 size since the last redisplay, or have been split or deleted,\n\
5414 all the functions in the list are called, with the frame as argument.");
5415 Vwindow_size_change_functions
= Qnil
;
5417 DEFVAR_LISP ("window-scroll-functions", &Vwindow_scroll_functions
,
5418 "List of functions to call before redisplaying a window with scrolling.\n\
5419 Each function is called with two arguments, the window\n\
5420 and its new display-start position. Note that the value of `window-end'\n\
5421 is not valid when these functions are called.");
5422 Vwindow_scroll_functions
= Qnil
;
5424 DEFVAR_INT ("minibuffer-scroll-overlap", &minibuffer_scroll_overlap
,
5425 "*Number of characters of overlap when scrolling a one-line window.\n\
5426 This commonly affects the minibuffer window, hence the name of the variable.");
5427 minibuffer_scroll_overlap
= 20;
5430 /* initialize the window system */
5433 Lisp_Object root_window
;
5434 #ifndef COMPILER_REGISTER_BUG
5436 #endif /* COMPILER_REGISTER_BUG */
5437 struct window
*mini_w
;
5439 this_line_bufpos
= 0;
5441 mini_w
= XWINDOW (minibuf_window
);
5442 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
5444 echo_area_glyphs
= 0;
5445 previous_echo_glyphs
= 0;
5447 if (!noninteractive
)
5449 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
5450 XSETFASTINT (XWINDOW (root_window
)->top
, FRAME_MENU_BAR_LINES (f
));
5451 set_window_height (root_window
,
5452 FRAME_HEIGHT (f
) - 1 - FRAME_MENU_BAR_LINES (f
),
5454 XSETFASTINT (mini_w
->top
, FRAME_HEIGHT (f
) - 1);
5455 set_window_height (minibuf_window
, 1, 0);
5457 XSETFASTINT (XWINDOW (root_window
)->width
, FRAME_WIDTH (f
));
5458 XSETFASTINT (mini_w
->width
, FRAME_WIDTH (f
));