1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 1997
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 /*#include <ctype.h>*/
31 #include "dispextern.h"
38 #include "termhooks.h"
39 #include "intervals.h"
44 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
45 extern void set_frame_menubar ();
46 extern int pending_menu_activation
;
49 extern int interrupt_input
;
50 extern int command_loop_level
;
52 extern int minibuffer_auto_raise
;
54 extern int nonascii_insert_offset
;
56 extern Lisp_Object Qface
;
58 extern Lisp_Object Voverriding_local_map
;
59 extern Lisp_Object Voverriding_local_map_menu_flag
;
61 Lisp_Object Qoverriding_local_map
, Qoverriding_terminal_local_map
;
62 Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
63 Lisp_Object Qredisplay_end_trigger_functions
;
65 /* Nonzero means print newline to stdout before next minibuffer message. */
67 int noninteractive_need_newline
;
69 /* Nonzero means print newline to message log before next message. */
71 static int message_log_need_newline
;
73 #define min(a, b) ((a) < (b) ? (a) : (b))
74 #define max(a, b) ((a) > (b) ? (a) : (b))
75 #define minmax(floor, val, ceil) \
76 ((val) < (floor) ? (floor) : (val) > (ceil) ? (ceil) : (val))
78 /* The buffer position of the first character appearing
79 entirely or partially on the current frame line.
80 Or zero, which disables the optimization for the current frame line. */
81 static int this_line_bufpos
;
83 /* Number of characters past the end of this line,
84 including the terminating newline */
85 static int this_line_endpos
;
87 /* The vertical position of this frame line. */
88 static int this_line_vpos
;
90 /* Hpos value for start of display on this frame line.
91 Usually zero, but negative if first character really began
93 static int this_line_start_hpos
;
95 /* Buffer that this_line variables are describing. */
96 static struct buffer
*this_line_buffer
;
98 /* Value of echo_area_glyphs when it was last acted on.
99 If this is nonzero, there is a message on the frame
100 in the minibuffer and it should be erased as soon
101 as it is no longer requested to appear. */
102 char *previous_echo_glyphs
;
104 /* Nonzero means truncate lines in all windows less wide than the frame */
105 int truncate_partial_width_windows
;
107 /* Nonzero means we have more than one non-minibuffer-only frame.
108 Not guaranteed to be accurate except while parsing frame-title-format. */
111 Lisp_Object Vglobal_mode_string
;
113 /* Marker for where to display an arrow on top of the buffer text. */
114 Lisp_Object Voverlay_arrow_position
;
116 /* String to display for the arrow. */
117 Lisp_Object Voverlay_arrow_string
;
119 /* Values of those variables at last redisplay.
120 However, if Voverlay_arrow_position is a marker,
121 last_arrow_position is its numerical position. */
122 static Lisp_Object last_arrow_position
, last_arrow_string
;
124 /* Like mode-line-format, but for the titlebar on a visible frame. */
125 Lisp_Object Vframe_title_format
;
127 /* Like mode-line-format, but for the titlebar on an iconified frame. */
128 Lisp_Object Vicon_title_format
;
130 /* List of functions to call when a window's size changes. These
131 functions get one arg, a frame on which one or more windows' sizes
133 static Lisp_Object Vwindow_size_change_functions
;
135 Lisp_Object Qmenu_bar_update_hook
;
137 /* Nonzero if overlay arrow has been displayed once in this window. */
138 static int overlay_arrow_seen
;
140 /* Nonzero if visible end of buffer has already been displayed once
141 in this window. (We need this variable in case there are overlay
142 strings that get displayed there.) */
143 static int zv_strings_seen
;
145 /* Nonzero means highlight the region even in nonselected windows. */
146 static int highlight_nonselected_windows
;
148 /* If cursor motion alone moves point off frame,
149 Try scrolling this many lines up or down if that will bring it back. */
150 static int scroll_step
;
152 /* Non-0 means scroll just far enough to bring point back on the screen,
154 static int scroll_conservatively
;
156 /* Recenter the window whenever point gets within this many lines
157 of the top or bottom of the window. */
160 /* Number of characters of overlap to show,
161 when scrolling a one-line window such as a minibuffer. */
162 static int minibuffer_scroll_overlap
;
164 /* Nonzero if try_window_id has made blank lines at window bottom
165 since the last redisplay that paused */
166 static int blank_end_of_window
;
168 /* Number of windows showing the buffer of the selected window
169 (or another buffer with the same base buffer).
170 keyboard.c refers to this. */
173 /* display_text_line sets these to the frame position (origin 0) of point,
174 whether the window is selected or not.
175 Set one to -1 first to determine whether point was found afterwards. */
177 static int cursor_vpos
;
178 static int cursor_hpos
;
180 static int debug_end_pos
;
182 /* Nonzero means display mode line highlighted */
183 int mode_line_inverse_video
;
185 static void redisplay_internal ();
186 static int message_log_check_duplicate ();
187 static void echo_area_display ();
188 void mark_window_display_accurate ();
189 static void redisplay_windows ();
190 static void redisplay_window ();
191 static void update_menu_bar ();
192 static void try_window ();
193 static int try_window_id ();
194 static struct position
*display_text_line ();
195 static void display_mode_line ();
196 static int display_mode_element ();
197 static char *decode_mode_spec ();
198 static int display_string ();
199 static void display_menu_bar ();
200 static int display_count_lines ();
202 /* Prompt to display in front of the minibuffer contents */
203 Lisp_Object minibuf_prompt
;
205 /* Width in columns of current minibuffer prompt. */
206 int minibuf_prompt_width
;
208 /* Message to display instead of minibuffer contents
209 This is what the functions error and message make,
210 and command echoing uses it as well.
211 It overrides the minibuf_prompt as well as the buffer. */
212 char *echo_area_glyphs
;
214 /* This is the length of the message in echo_area_glyphs. */
215 int echo_area_glyphs_length
;
217 /* This is the window where the echo area message was displayed.
218 It is always a minibuffer window, but it may not be the
219 same window currently active as a minibuffer. */
220 Lisp_Object echo_area_window
;
222 /* Nonzero means multibyte characters were enabled when the echo area
223 message was specified. */
224 int message_enable_multibyte
;
226 /* true iff we should redraw the mode lines on the next redisplay */
227 int update_mode_lines
;
229 /* Smallest number of characters before the gap
230 at any time since last redisplay that finished.
231 Valid for current buffer when try_window_id can be called. */
234 /* Smallest number of characters after the gap
235 at any time since last redisplay that finished.
236 Valid for current buffer when try_window_id can be called. */
239 /* MODIFF as of last redisplay that finished;
240 if it matches MODIFF, and overlay_unchanged_modified
241 matches OVERLAY_MODIFF, that means beg_unchanged and end_unchanged
242 contain no useful information */
243 int unchanged_modified
;
245 /* OVERLAY_MODIFF as of last redisplay that finished. */
246 int overlay_unchanged_modified
;
248 /* Nonzero if window sizes or contents have changed
249 since last redisplay that finished */
250 int windows_or_buffers_changed
;
252 /* Nonzero after display_mode_line if %l was used
253 and it displayed a line number. */
254 int line_number_displayed
;
256 /* Maximum buffer size for which to display line numbers. */
257 static int line_number_display_limit
;
259 /* Number of lines to keep in the message log buffer.
260 t means infinite. nil means don't log at all. */
261 Lisp_Object Vmessage_log_max
;
263 #define COERCE_MARKER(X) \
264 (MARKERP ((X)) ? Fmarker_position (X) : (X))
266 static int pos_tab_offset
P_ ((struct window
*, int, int));
268 /* Output a newline in the *Messages* buffer if "needs" one. */
271 message_log_maybe_newline ()
273 if (message_log_need_newline
)
274 message_dolog ("", 0, 1, 0);
278 /* Add a string to the message log, optionally terminated with a newline.
279 This function calls low-level routines in order to bypass text property
280 hooks, etc. which might not be safe to run.
281 MULTIBYTE, if nonzero, means interpret the contents of M as multibyte. */
284 message_dolog (m
, len
, nlflag
, multibyte
)
286 int len
, nlflag
, multibyte
;
288 if (!NILP (Vmessage_log_max
))
290 struct buffer
*oldbuf
;
291 Lisp_Object oldpoint
, oldbegv
, oldzv
;
292 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
293 int point_at_end
= 0;
296 oldbuf
= current_buffer
;
297 Fset_buffer (Fget_buffer_create (build_string ("*Messages*")));
298 current_buffer
->undo_list
= Qt
;
300 oldpoint
= Fpoint_marker ();
301 oldbegv
= Fpoint_min_marker ();
302 oldzv
= Fpoint_max_marker ();
310 BEGV_BYTE
= BEG_BYTE
;
313 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
315 /* Insert the string--maybe converting multibyte to single byte
316 or vice versa, so that all the text fits the buffer. */
318 && NILP (current_buffer
->enable_multibyte_characters
))
320 int c
, i
= 0, nbytes
;
321 /* Convert a multibyte string to single-byte
322 for the *Message* buffer. */
325 c
= STRING_CHAR (m
+ i
, len
- i
);
326 i
+= XFASTINT (Fchar_bytes (make_number (c
)));
327 /* Truncate the character to its last byte--we can only hope
328 the user is happy with the character he gets,
329 since if it isn't right, there is no way to do it right. */
335 && ! NILP (current_buffer
->enable_multibyte_characters
))
338 /* Convert a single-byte string to multibyte
339 for the *Message* buffer. */
343 /* Convert non-ascii chars as if for self-insert. */
344 if (c
>= 0200 && c
<= 0377)
345 c
+= nonascii_insert_offset
;
350 insert_1 (m
, len
, 1, 0, 0);
354 int this_bol
, this_bol_byte
, prev_bol
, prev_bol_byte
, dup
;
355 insert_1 ("\n", 1, 1, 0, 0);
357 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
, -2, 0);
359 this_bol_byte
= PT_BYTE
;
363 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
, -2, 0);
365 prev_bol_byte
= PT_BYTE
;
367 dup
= message_log_check_duplicate (prev_bol
, this_bol
,
368 prev_bol_byte
, this_bol_byte
);
371 del_range_both (prev_bol
, prev_bol_byte
,
372 this_bol
, this_bol_byte
, 0);
378 /* If you change this format, don't forget to also
379 change message_log_check_duplicate. */
380 sprintf (dupstr
, " [%d times]", dup
);
381 duplen
= strlen (dupstr
);
382 TEMP_SET_PT_BOTH (Z
- 1, Z_BYTE
- 1);
383 insert_1 (dupstr
, duplen
, 1, 0, 1);
388 if (NATNUMP (Vmessage_log_max
))
390 scan_newline (Z
, Z_BYTE
, BEG
, BEG_BYTE
,
391 -XFASTINT (Vmessage_log_max
) - 1, 0);
392 del_range_both (BEG
, BEG_BYTE
, PT
, PT_BYTE
, 0);
395 BEGV
= XMARKER (oldbegv
)->charpos
;
396 BEGV_BYTE
= marker_byte_position (oldbegv
);
405 ZV
= XMARKER (oldzv
)->charpos
;
406 ZV_BYTE
= marker_byte_position (oldzv
);
410 TEMP_SET_PT_BOTH (Z
, Z_BYTE
);
412 Fgoto_char (oldpoint
);
414 free_marker (oldpoint
);
415 free_marker (oldbegv
);
418 set_buffer_internal (oldbuf
);
419 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
420 message_log_need_newline
= !nlflag
;
424 /* We are at the end of the buffer after just having inserted a newline.
425 (Note: We depend on the fact we won't be crossing the gap.)
426 Check to see if the most recent message looks a lot like the previous one.
427 Return 0 if different, 1 if the new one should just replace it, or a
428 value N > 1 if we should also append " [N times]". */
431 message_log_check_duplicate (prev_bol
, prev_bol_byte
, this_bol
, this_bol_byte
)
432 int prev_bol
, this_bol
;
433 int prev_bol_byte
, this_bol_byte
;
436 int len
= Z
- 1 - this_bol
;
438 unsigned char *p1
= BUF_BYTE_ADDRESS (current_buffer
, prev_bol_byte
);
439 unsigned char *p2
= BUF_BYTE_ADDRESS (current_buffer
, this_bol_byte
);
441 for (i
= 0; i
< len
; i
++)
443 if (i
>= 3 && p1
[i
-3] == '.' && p1
[i
-2] == '.' && p1
[i
-1] == '.'
452 if (*p1
++ == ' ' && *p1
++ == '[')
455 while (*p1
>= '0' && *p1
<= '9')
456 n
= n
* 10 + *p1
++ - '0';
457 if (strncmp (p1
, " times]\n", 8) == 0)
463 /* Display an echo area message M with a specified length of LEN chars.
464 The string may include null characters. If M is 0, clear out any
465 existing message, and let the minibuffer text show through.
467 The buffer M must continue to exist until after the echo area
468 gets cleared or some other message gets displayed there.
470 Do not pass text that is stored in a Lisp string.
471 Do not pass text in a buffer that was alloca'd. */
474 message2 (m
, len
, multibyte
)
479 /* First flush out any partial line written with print. */
480 message_log_maybe_newline ();
482 message_dolog (m
, len
, 1, multibyte
);
483 message2_nolog (m
, len
, multibyte
);
487 /* The non-logging counterpart of message2. */
490 message2_nolog (m
, len
, multibyte
)
494 message_enable_multibyte
= multibyte
;
498 if (noninteractive_need_newline
)
500 noninteractive_need_newline
= 0;
502 fwrite (m
, len
, 1, stderr
);
503 if (cursor_in_echo_area
== 0)
504 fprintf (stderr
, "\n");
507 /* A null message buffer means that the frame hasn't really been
508 initialized yet. Error messages get reported properly by
509 cmd_error, so this must be just an informative message; toss it. */
510 else if (INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
512 Lisp_Object mini_window
;
515 /* Get the frame containing the minibuffer
516 that the selected frame is using. */
517 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
518 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
520 FRAME_SAMPLE_VISIBILITY (f
);
521 if (FRAME_VISIBLE_P (selected_frame
)
522 && ! FRAME_VISIBLE_P (f
))
523 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (mini_window
)));
527 echo_area_glyphs
= m
;
528 echo_area_glyphs_length
= len
;
530 if (minibuffer_auto_raise
)
531 Fraise_frame (WINDOW_FRAME (XWINDOW (mini_window
)));
534 echo_area_glyphs
= previous_echo_glyphs
= 0;
536 do_pending_window_change ();
537 echo_area_display ();
538 update_frame (f
, 1, 1);
539 do_pending_window_change ();
540 if (frame_up_to_date_hook
!= 0 && ! gc_in_progress
)
541 (*frame_up_to_date_hook
) (f
);
545 /* Display in echo area the null-terminated ASCII-only string M.
546 If M is 0, clear out any existing message,
547 and let the minibuffer text show through.
549 The string M must continue to exist until after the echo area
550 gets cleared or some other message gets displayed there.
552 Do not pass text that is stored in a Lisp string.
553 Do not pass text in a buffer that was alloca'd. */
559 message2 (m
, (m
? strlen (m
) : 0), 0);
566 message2_nolog (m
, (m
? strlen (m
) : 0), 0);
569 /* Display a message M which contains a single %s
570 which gets replaced with STRING. */
573 message_with_string (m
, string
, log
)
582 if (noninteractive_need_newline
)
584 noninteractive_need_newline
= 0;
585 fprintf (stderr
, m
, XSTRING (string
)->data
);
586 if (cursor_in_echo_area
== 0)
587 fprintf (stderr
, "\n");
591 else if (INTERACTIVE
)
593 /* The frame whose minibuffer we're going to display the message on.
594 It may be larger than the selected frame, so we need
595 to use its buffer, not the selected frame's buffer. */
596 Lisp_Object mini_window
;
599 /* Get the frame containing the minibuffer
600 that the selected frame is using. */
601 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
602 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
604 /* A null message buffer means that the frame hasn't really been
605 initialized yet. Error messages get reported properly by
606 cmd_error, so this must be just an informative message; toss it. */
607 if (FRAME_MESSAGE_BUF (f
))
611 a
[0] = (char *) XSTRING (string
)->data
;
613 len
= doprnt (FRAME_MESSAGE_BUF (f
),
614 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
617 message2 (FRAME_MESSAGE_BUF (f
), len
,
618 STRING_MULTIBYTE (string
));
620 message2_nolog (FRAME_MESSAGE_BUF (f
), len
,
621 STRING_MULTIBYTE (string
));
623 /* Print should start at the beginning of the message
625 message_buf_print
= 0;
630 /* Truncate what will be displayed in the echo area
631 the next time we display it--but don't redisplay it now. */
634 truncate_echo_area (len
)
637 /* A null message buffer means that the frame hasn't really been
638 initialized yet. Error messages get reported properly by
639 cmd_error, so this must be just an informative message; toss it. */
640 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
641 echo_area_glyphs_length
= len
;
644 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
645 zero if being used by message. */
646 int message_buf_print
;
648 /* Dump an informative message to the minibuf. If M is 0, clear out
649 any existing message, and let the minibuffer text show through. */
653 message (m
, a1
, a2
, a3
)
655 EMACS_INT a1
, a2
, a3
;
661 if (noninteractive_need_newline
)
663 noninteractive_need_newline
= 0;
664 fprintf (stderr
, m
, a1
, a2
, a3
);
665 if (cursor_in_echo_area
== 0)
666 fprintf (stderr
, "\n");
670 else if (INTERACTIVE
)
672 /* The frame whose minibuffer we're going to display the message on.
673 It may be larger than the selected frame, so we need
674 to use its buffer, not the selected frame's buffer. */
675 Lisp_Object mini_window
;
678 /* Get the frame containing the minibuffer
679 that the selected frame is using. */
680 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
681 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
683 /* A null message buffer means that the frame hasn't really been
684 initialized yet. Error messages get reported properly by
685 cmd_error, so this must be just an informative message; toss it. */
686 if (FRAME_MESSAGE_BUF (f
))
697 len
= doprnt (FRAME_MESSAGE_BUF (f
),
698 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3, a
);
700 len
= doprnt (FRAME_MESSAGE_BUF (f
),
701 FRAME_MESSAGE_BUF_SIZE (f
), m
, (char *)0, 3,
703 #endif /* NO_ARG_ARRAY */
705 message2 (FRAME_MESSAGE_BUF (f
), len
, 0);
710 /* Print should start at the beginning of the message
712 message_buf_print
= 0;
717 /* The non-logging version of message. */
719 message_nolog (m
, a1
, a2
, a3
)
721 EMACS_INT a1
, a2
, a3
;
723 Lisp_Object old_log_max
;
724 old_log_max
= Vmessage_log_max
;
725 Vmessage_log_max
= Qnil
;
726 message (m
, a1
, a2
, a3
);
727 Vmessage_log_max
= old_log_max
;
733 message2 (echo_area_glyphs
, echo_area_glyphs_length
,
734 ! NILP (current_buffer
->enable_multibyte_characters
));
742 Lisp_Object mini_window
;
744 /* Choose the minibuffer window for this display.
745 It is the minibuffer window used by the selected frame. */
746 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
747 /* This is the frame that window is in. */
748 f
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
750 if (! FRAME_VISIBLE_P (f
))
755 redraw_garbaged_frames ();
759 if (echo_area_glyphs
|| minibuf_level
== 0)
763 echo_area_window
= mini_window
;
765 vpos
= XFASTINT (XWINDOW (mini_window
)->top
);
766 get_display_line (f
, vpos
, 0);
768 /* Make sure the columns that overlap a left-hand scroll bar
770 for (i
= 0; i
< FRAME_LEFT_SCROLL_BAR_WIDTH (f
); i
++)
771 f
->desired_glyphs
->glyphs
[vpos
][i
] = SPACEGLYPH
;
773 display_string (XWINDOW (mini_window
), vpos
,
774 echo_area_glyphs
? echo_area_glyphs
: "",
775 echo_area_glyphs
? echo_area_glyphs_length
: -1,
776 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
778 FRAME_WIDTH (f
) + FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
779 message_enable_multibyte
);
781 #if 0 /* This just gets in the way. update_frame does the job. */
782 /* If desired cursor location is on this line, put it at end of text */
783 if (cursor_in_echo_area
)
784 FRAME_CURSOR_Y (f
) = vpos
;
785 if (FRAME_CURSOR_Y (f
) == vpos
)
786 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
789 /* Fill the rest of the minibuffer window with blank lines. */
794 i
< vpos
+ XFASTINT (XWINDOW (mini_window
)->height
); i
++)
796 get_display_line (f
, i
, 0);
797 /* We don't use FRAME_SCROLL_BAR_WIDTH (f) as the starting
798 hpos, because it is good to clear whatever is behind the
799 scroll bar. This does not affect the scroll bar itself. */
800 display_string (XWINDOW (mini_window
), i
,
803 0, FRAME_WIDTH (f
) + FRAME_SCROLL_BAR_WIDTH (f
),
808 else if (!EQ (mini_window
, selected_window
))
809 windows_or_buffers_changed
++;
811 if (EQ (mini_window
, selected_window
))
812 this_line_bufpos
= 0;
814 previous_echo_glyphs
= echo_area_glyphs
;
817 /* Update frame titles. */
819 #ifdef HAVE_WINDOW_SYSTEM
820 static char frame_title_buf
[512];
821 static char *frame_title_ptr
;
824 store_frame_title (str
, mincol
, maxcol
)
829 if (maxcol
< 0 || maxcol
>= sizeof(frame_title_buf
))
830 maxcol
= sizeof (frame_title_buf
);
831 limit
= &frame_title_buf
[maxcol
];
832 while (*str
!= '\0' && frame_title_ptr
< limit
)
833 *frame_title_ptr
++ = *str
++;
834 while (frame_title_ptr
< &frame_title_buf
[mincol
])
835 *frame_title_ptr
++ = ' ';
836 return frame_title_ptr
- frame_title_buf
;
840 x_consider_frame_title (frame
)
846 FRAME_PTR f
= XFRAME (frame
);
848 if (!(FRAME_WINDOW_P (f
) || FRAME_MINIBUF_ONLY_P (f
) || f
->explicit_name
))
851 /* Do we have more than one visible frame on this X display? */
855 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
857 FRAME_PTR tf
= XFRAME (XCONS (tail
)->car
);
859 if (tf
!= f
&& FRAME_KBOARD (tf
) == FRAME_KBOARD (f
)
860 && !FRAME_MINIBUF_ONLY_P (tf
)
861 && (FRAME_VISIBLE_P (tf
) || FRAME_ICONIFIED_P (tf
)))
865 multiple_frames
= CONSP (tail
);
868 obuf
= current_buffer
;
869 Fset_buffer (XWINDOW (f
->selected_window
)->buffer
);
870 fmt
= (FRAME_ICONIFIED_P (f
) ? Vicon_title_format
: Vframe_title_format
);
871 frame_title_ptr
= frame_title_buf
;
872 len
= display_mode_element (XWINDOW (f
->selected_window
), 0, 0, 0,
873 0, sizeof (frame_title_buf
), fmt
);
875 set_buffer_internal (obuf
);
876 /* Set the name only if it's changed. This avoids consing
877 in the common case where it hasn't. (If it turns out that we've
878 already wasted too much time by walking through the list with
879 display_mode_element, then we might need to optimize at a higher
881 if (! STRINGP (f
->name
) || XSTRING (f
->name
)->size_byte
!= len
882 || bcmp (frame_title_buf
, XSTRING (f
->name
)->data
, len
) != 0)
883 x_implicitly_set_name (f
, make_string (frame_title_buf
, len
), Qnil
);
886 #define frame_title_ptr ((char *)0)
887 #define store_frame_title(str, mincol, maxcol) 0
890 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
891 This can call eval. */
896 register struct window
*w
= XWINDOW (selected_window
);
898 struct gcpro gcpro1
, gcpro2
;
900 all_windows
= (update_mode_lines
|| buffer_shared
> 1
901 || windows_or_buffers_changed
);
903 /* Update all frame titles based on their buffer names, etc.
904 We do this before the menu bars so that the buffer-menu
905 will show the up-to-date frame titles.
907 This used to be done after the menu bars, for a reason that
908 was stated as follows but which I do not understand:
909 "We do this after the menu bars so that the frame will first
910 create its menu bar using the name `emacs' if no other name
911 has yet been specified."
912 I think that is no longer a concern. */
913 #ifdef HAVE_WINDOW_SYSTEM
914 if (windows_or_buffers_changed
|| update_mode_lines
)
916 Lisp_Object tail
, frame
;
918 FOR_EACH_FRAME (tail
, frame
)
919 if (FRAME_VISIBLE_P (XFRAME (frame
))
920 || FRAME_ICONIFIED_P (XFRAME (frame
)))
921 x_consider_frame_title (frame
);
925 /* Update the menu bar item lists, if appropriate.
926 This has to be done before any actual redisplay
927 or generation of display lines. */
930 Lisp_Object tail
, frame
;
931 int count
= specpdl_ptr
- specpdl
;
933 record_unwind_protect (Fstore_match_data
, Fmatch_data (Qnil
, Qnil
));
935 FOR_EACH_FRAME (tail
, frame
)
937 /* If a window on this frame changed size,
938 report that to the user and clear the size-change flag. */
939 if (FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)))
941 Lisp_Object functions
;
942 /* Clear flag first in case we get error below. */
943 FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)) = 0;
944 functions
= Vwindow_size_change_functions
;
945 GCPRO2 (tail
, functions
);
946 while (CONSP (functions
))
948 call1 (XCONS (functions
)->car
, frame
);
949 functions
= XCONS (functions
)->cdr
;
954 update_menu_bar (XFRAME (frame
), 0);
958 unbind_to (count
, Qnil
);
961 update_menu_bar (selected_frame
, 1);
963 /* Motif needs this. See comment in xmenu.c.
964 Turn it off when pending_menu_activation is not defined. */
966 pending_menu_activation
= 0;
970 /* Do a frame update, taking possible shortcuts into account.
971 This is the main external entry point for redisplay.
973 If the last redisplay displayed an echo area message and that
974 message is no longer requested, we clear the echo area
975 or bring back the minibuffer if that is in use.
977 Do not call eval from within this function.
978 Calls to eval after the call to echo_area_display would confuse
979 the display_line mechanism and would cause a crash.
980 Calls to eval before that point will work most of the time,
981 but can still lose, because this function
982 can be called from signal handlers; with alarms set up;
983 or with synchronous processes running.
985 See Fcall_process; if you called it from here, it could be
986 entered recursively. */
988 static int do_verify_charstarts
;
990 /* Counter is used to clear the face cache
991 no more than once ever 1000 redisplays. */
992 static int clear_face_cache_count
;
994 /* Record the previous terminal frame we displayed. */
995 static FRAME_PTR previous_terminal_frame
;
1000 redisplay_internal (0);
1003 /* If PRESERVE_ECHO_AREA is nonzero, it means this redisplay
1004 is not in response to any user action; therefore, we should
1005 preserve the echo area. (Actually, our caller does that job.)
1006 Perhaps in the future avoid recentering windows
1007 if it is not necessary; currently that causes some problems. */
1010 redisplay_internal (preserve_echo_area
)
1011 int preserve_echo_area
;
1013 register struct window
*w
= XWINDOW (selected_window
);
1015 int must_finish
= 0;
1017 register int tlbufpos
, tlendpos
;
1018 struct position pos
;
1019 int number_of_visible_frames
;
1024 #ifdef USE_X_TOOLKIT
1025 if (popup_activated ())
1031 if (! FRAME_WINDOW_P (selected_frame
)
1032 && previous_terminal_frame
!= selected_frame
)
1034 /* Since frames on an ASCII terminal share the same display area,
1035 displaying a different frame means redisplay the whole thing. */
1036 windows_or_buffers_changed
++;
1037 SET_FRAME_GARBAGED (selected_frame
);
1038 XSETFRAME (Vterminal_frame
, selected_frame
);
1040 previous_terminal_frame
= selected_frame
;
1042 /* Set the visible flags for all frames.
1043 Do this before checking for resized or garbaged frames; they want
1044 to know if their frames are visible.
1045 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
1047 Lisp_Object tail
, frame
;
1049 number_of_visible_frames
= 0;
1051 FOR_EACH_FRAME (tail
, frame
)
1053 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1055 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1056 number_of_visible_frames
++;
1058 /* Clear out all the display lines in which we will generate the
1059 glyphs to display. */
1060 init_desired_glyphs (XFRAME (frame
));
1064 /* Notice any pending interrupt request to change frame size. */
1065 do_pending_window_change ();
1069 redraw_garbaged_frames ();
1073 prepare_menu_bars ();
1075 if (windows_or_buffers_changed
)
1076 update_mode_lines
++;
1078 /* Detect case that we need to write or remove a star in the mode line. */
1079 if ((SAVE_MODIFF
< MODIFF
) != !NILP (w
->last_had_star
))
1081 w
->update_mode_line
= Qt
;
1082 if (buffer_shared
> 1)
1083 update_mode_lines
++;
1086 /* If %c is in use, update it if needed. */
1087 if (!NILP (w
->column_number_displayed
)
1088 /* This alternative quickly identifies a common case
1089 where no change is needed. */
1090 && !(PT
== XFASTINT (w
->last_point
)
1091 && XFASTINT (w
->last_modified
) >= MODIFF
1092 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1093 && XFASTINT (w
->column_number_displayed
) != current_column ())
1094 w
->update_mode_line
= Qt
;
1096 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
1098 all_windows
= update_mode_lines
|| buffer_shared
> 1;
1100 /* If specs for an arrow have changed, do thorough redisplay
1101 to ensure we remove any arrow that should no longer exist. */
1102 if (! EQ (COERCE_MARKER (Voverlay_arrow_position
), last_arrow_position
)
1103 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
1106 /* Normally the message* functions will have already displayed and
1107 updated the echo area, but the frame may have been trashed, or
1108 the update may have been preempted, so display the echo area
1110 if (echo_area_glyphs
|| previous_echo_glyphs
)
1112 echo_area_display ();
1116 /* If showing region, and mark has changed, must redisplay whole window. */
1117 if (((!NILP (Vtransient_mark_mode
)
1118 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1119 != !NILP (w
->region_showing
))
1120 || (!NILP (w
->region_showing
)
1121 && !EQ (w
->region_showing
,
1122 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
1123 this_line_bufpos
= -1;
1125 tlbufpos
= this_line_bufpos
;
1126 tlendpos
= this_line_endpos
;
1127 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
1128 && !current_buffer
->clip_changed
1129 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
1130 && !FRAME_OBSCURED_P (XFRAME (w
->frame
))
1131 /* Make sure recorded data applies to current buffer, etc */
1132 && this_line_buffer
== current_buffer
1133 && current_buffer
== XBUFFER (w
->buffer
)
1134 && NILP (w
->force_start
)
1135 /* Point must be on the line that we have info recorded about */
1137 && PT
<= Z
- tlendpos
1138 /* All text outside that line, including its final newline,
1139 must be unchanged */
1140 && ((XFASTINT (w
->last_modified
) >= MODIFF
1141 && (XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
))
1142 || (beg_unchanged
>= tlbufpos
- 1
1144 /* If selective display, can't optimize
1145 if the changes start at the beginning of the line. */
1146 && ((INTEGERP (current_buffer
->selective_display
)
1147 && XINT (current_buffer
->selective_display
) > 0
1148 ? (beg_unchanged
>= tlbufpos
1151 && end_unchanged
>= tlendpos
1152 && Z
- GPT
>= tlendpos
)))
1154 int tlbufpos_byte
= CHAR_TO_BYTE (tlbufpos
);
1155 if (tlbufpos
> BEGV
&& FETCH_BYTE (tlbufpos_byte
- 1) != '\n'
1157 || FETCH_BYTE (tlbufpos_byte
) == '\n'))
1158 /* Former continuation line has disappeared by becoming empty */
1160 else if (XFASTINT (w
->last_modified
) < MODIFF
1161 || XFASTINT (w
->last_overlay_modified
) < OVERLAY_MODIFF
1162 || MINI_WINDOW_P (w
))
1164 /* We have to handle the case of continuation around a
1165 wide-column character (See the comment in indent.c around
1168 For instance, in the following case:
1170 -------- Insert --------
1171 K_A_N_\\ `a' K_A_N_a\ `X_' are wide-column chars.
1172 J_I_ ==> J_I_ `^^' are cursors.
1176 As we have to redraw the line above, we should goto cancel. */
1178 struct position val
;
1180 int opoint
= PT
, opoint_byte
= PT_BYTE
;
1182 scan_newline (tlbufpos
, tlbufpos_byte
, BEGV
, BEGV_BYTE
, -1, 1);
1184 val
= *compute_motion (PT
, 0,
1185 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1188 1 << (BITS_PER_SHORT
- 1),
1189 1 << (BITS_PER_SHORT
- 1),
1190 window_internal_width (w
) - 1,
1191 XINT (w
->hscroll
), 0, w
);
1192 SET_PT_BOTH (opoint
, opoint_byte
);
1193 if (val
.hpos
!= this_line_start_hpos
)
1197 overlay_arrow_seen
= 0;
1198 zv_strings_seen
= 0;
1199 display_text_line (w
, tlbufpos
, tlbufpos_byte
,
1200 this_line_vpos
, this_line_start_hpos
,
1201 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
), 0);
1202 /* If line contains point, is not continued,
1203 and ends at same distance from eob as before, we win */
1204 if (cursor_vpos
>= 0 && this_line_bufpos
1205 && this_line_endpos
== tlendpos
)
1207 /* If this is not the window's last line,
1208 we must adjust the charstarts of the lines below. */
1209 if (this_line_vpos
+ 1
1210 < XFASTINT (w
->top
) + window_internal_height (w
))
1212 int left
= WINDOW_LEFT_MARGIN (w
);
1213 int *charstart_next_line
1214 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
1217 if (Z
- tlendpos
== ZV
)
1218 /* This line ends at end of (accessible part of) buffer.
1219 There is no newline to count. */
1220 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
1222 /* This line ends in a newline.
1223 Must take account of the newline and the rest of the
1224 text that follows. */
1225 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
1227 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
1230 if (!WINDOW_FULL_WIDTH_P (w
))
1231 preserve_other_columns (w
);
1237 else if (PT
== XFASTINT (w
->last_point
)
1238 /* Make sure the cursor was last displayed
1239 in this window. Otherwise we have to reposition it. */
1240 && XINT (w
->top
) <= FRAME_CURSOR_Y (selected_frame
)
1241 && (XINT (w
->top
) + XINT (w
->height
)
1242 > FRAME_CURSOR_Y (selected_frame
)))
1246 do_pending_window_change ();
1251 /* If highlighting the region, or if the cursor is in the echo area,
1252 then we can't just move the cursor. */
1253 else if (! (!NILP (Vtransient_mark_mode
)
1254 && !NILP (current_buffer
->mark_active
))
1255 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1256 || highlight_nonselected_windows
)
1257 && NILP (w
->region_showing
)
1258 && !cursor_in_echo_area
)
1260 pos
= *compute_motion (tlbufpos
, 0,
1261 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
1263 PT
, 2, - (1 << (BITS_PER_SHORT
- 1)),
1264 window_internal_width (w
) - 1,
1266 pos_tab_offset (w
, tlbufpos
, tlbufpos_byte
),
1270 int width
= window_internal_width (w
) - 1;
1271 FRAME_CURSOR_X (selected_frame
)
1272 = WINDOW_LEFT_MARGIN (w
) + minmax (0, pos
.hpos
, width
);
1273 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
1280 /* Text changed drastically or point moved off of line */
1281 cancel_line (this_line_vpos
, selected_frame
);
1284 this_line_bufpos
= 0;
1285 all_windows
|= buffer_shared
> 1;
1287 clear_face_cache_count
++;
1291 Lisp_Object tail
, frame
;
1294 /* Clear the face cache, only when we do a full redisplay
1295 and not too often either. */
1296 if (clear_face_cache_count
> 1000)
1298 clear_face_cache ();
1299 clear_face_cache_count
= 0;
1303 /* Recompute # windows showing selected buffer.
1304 This will be incremented each time such a window is displayed. */
1307 FOR_EACH_FRAME (tail
, frame
)
1309 FRAME_PTR f
= XFRAME (frame
);
1310 if (FRAME_WINDOW_P (f
) || f
== selected_frame
)
1313 /* Mark all the scroll bars to be removed; we'll redeem the ones
1314 we want when we redisplay their windows. */
1315 if (condemn_scroll_bars_hook
)
1316 (*condemn_scroll_bars_hook
) (f
);
1318 if (FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1319 redisplay_windows (FRAME_ROOT_WINDOW (f
), preserve_echo_area
);
1321 /* Any scroll bars which redisplay_windows should have nuked
1322 should now go away. */
1323 if (judge_scroll_bars_hook
)
1324 (*judge_scroll_bars_hook
) (f
);
1328 else if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1330 redisplay_window (selected_window
, 1, preserve_echo_area
);
1331 if (!WINDOW_FULL_WIDTH_P (w
))
1332 preserve_other_columns (w
);
1336 /* Prevent various kinds of signals during display update.
1337 stdio is not robust about handling signals,
1338 which can cause an apparent I/O error. */
1339 if (interrupt_input
)
1349 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1353 if (!FRAMEP (XCONS (tail
)->car
))
1356 f
= XFRAME (XCONS (tail
)->car
);
1358 if ((FRAME_WINDOW_P (f
) || f
== selected_frame
)
1359 && FRAME_VISIBLE_P (f
) && !FRAME_OBSCURED_P (f
))
1361 pause
|= update_frame (f
, 0, 0);
1364 mark_window_display_accurate (f
->root_window
, 1);
1365 if (frame_up_to_date_hook
!= 0)
1366 (*frame_up_to_date_hook
) (f
);
1373 if (FRAME_VISIBLE_P (selected_frame
) && !FRAME_OBSCURED_P (selected_frame
))
1374 pause
= update_frame (selected_frame
, 0, 0);
1378 /* We may have called echo_area_display at the top of this
1379 function. If the echo area is on another frame, that may
1380 have put text on a frame other than the selected one, so the
1381 above call to update_frame would not have caught it. Catch
1384 Lisp_Object mini_window
;
1385 FRAME_PTR mini_frame
;
1387 mini_window
= FRAME_MINIBUF_WINDOW (selected_frame
);
1388 mini_frame
= XFRAME (WINDOW_FRAME (XWINDOW (mini_window
)));
1390 if (mini_frame
!= selected_frame
&& FRAME_WINDOW_P (mini_frame
))
1391 pause
|= update_frame (mini_frame
, 0, 0);
1395 /* If frame does not match, prevent doing single-line-update next time.
1396 Also, don't forget to check every line to update the arrow. */
1399 this_line_bufpos
= 0;
1400 if (!NILP (last_arrow_position
))
1402 last_arrow_position
= Qt
;
1403 last_arrow_string
= Qt
;
1405 /* If we pause after scrolling, some lines in current_frame
1406 may be null, so preserve_other_columns won't be able to
1407 preserve all the vertical-bar separators. So, avoid using it
1409 if (!WINDOW_FULL_WIDTH_P (w
))
1410 update_mode_lines
= 1;
1413 /* Now text on frame agrees with windows, so
1414 put info into the windows for partial redisplay to follow */
1418 register struct buffer
*b
= XBUFFER (w
->buffer
);
1420 blank_end_of_window
= 0;
1421 unchanged_modified
= BUF_MODIFF (b
);
1422 overlay_unchanged_modified
= BUF_OVERLAY_MODIFF (b
);
1423 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
1424 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
1426 XSETFASTINT (w
->last_point
, BUF_PT (b
));
1427 XSETFASTINT (w
->last_point_x
, FRAME_CURSOR_X (selected_frame
));
1428 XSETFASTINT (w
->last_point_y
, FRAME_CURSOR_Y (selected_frame
));
1431 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
1434 b
->clip_changed
= 0;
1435 w
->update_mode_line
= Qnil
;
1436 XSETFASTINT (w
->last_modified
, BUF_MODIFF (b
));
1437 XSETFASTINT (w
->last_overlay_modified
, BUF_OVERLAY_MODIFF (b
));
1439 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1442 /* Record if we are showing a region, so can make sure to
1443 update it fully at next redisplay. */
1444 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1445 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1446 || highlight_nonselected_windows
)
1447 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1448 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1451 w
->window_end_valid
= w
->buffer
;
1452 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1453 last_arrow_string
= Voverlay_arrow_string
;
1454 if (do_verify_charstarts
)
1455 verify_charstarts (w
);
1456 if (frame_up_to_date_hook
!= 0)
1457 (*frame_up_to_date_hook
) (selected_frame
);
1459 update_mode_lines
= 0;
1460 windows_or_buffers_changed
= 0;
1463 /* Start SIGIO interrupts coming again.
1464 Having them off during the code above
1465 makes it less likely one will discard output,
1466 but not impossible, since there might be stuff
1467 in the system buffer here.
1468 But it is much hairier to try to do anything about that. */
1470 if (interrupt_input
)
1474 /* If something has become visible now which was not before,
1475 redisplay again, so that we get them. */
1478 Lisp_Object tail
, frame
;
1481 FOR_EACH_FRAME (tail
, frame
)
1483 int this_is_visible
= 0;
1485 if (XFRAME (frame
)->visible
)
1486 this_is_visible
= 1;
1487 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1488 if (XFRAME (frame
)->visible
)
1489 this_is_visible
= 1;
1491 if (this_is_visible
)
1495 if (new_count
!= number_of_visible_frames
)
1496 windows_or_buffers_changed
++;
1499 /* Change frame size now if a change is pending. */
1500 do_pending_window_change ();
1502 /* If we just did a pending size change, or have additional
1503 visible frames, redisplay again. */
1504 if (windows_or_buffers_changed
&& !pause
)
1508 /* Redisplay, but leave alone any recent echo area message
1509 unless another message has been requested in its place.
1511 This is useful in situations where you need to redisplay but no
1512 user action has occurred, making it inappropriate for the message
1513 area to be cleared. See tracking_off and
1514 wait_reading_process_input for examples of these situations. */
1517 redisplay_preserve_echo_area ()
1519 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
1521 echo_area_glyphs
= previous_echo_glyphs
;
1522 redisplay_internal (1);
1523 echo_area_glyphs
= 0;
1526 redisplay_internal (1);
1530 mark_window_display_accurate (window
, flag
)
1534 register struct window
*w
;
1536 for (;!NILP (window
); window
= w
->next
)
1538 if (!WINDOWP (window
)) abort ();
1539 w
= XWINDOW (window
);
1541 if (!NILP (w
->buffer
))
1543 XSETFASTINT (w
->last_modified
,
1544 !flag
? 0 : BUF_MODIFF (XBUFFER (w
->buffer
)));
1545 XSETFASTINT (w
->last_overlay_modified
,
1546 !flag
? 0 : BUF_OVERLAY_MODIFF (XBUFFER (w
->buffer
)));
1548 = (BUF_MODIFF (XBUFFER (w
->buffer
)) > BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1551 /* Record if we are showing a region, so can make sure to
1552 update it fully at next redisplay. */
1553 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1554 && (w
== XWINDOW (current_buffer
->last_selected_window
)
1555 || highlight_nonselected_windows
)
1556 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1557 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1561 w
->window_end_valid
= w
->buffer
;
1562 w
->update_mode_line
= Qnil
;
1563 if (!NILP (w
->buffer
) && flag
)
1564 XBUFFER (w
->buffer
)->clip_changed
= 0;
1566 if (!NILP (w
->vchild
))
1567 mark_window_display_accurate (w
->vchild
, flag
);
1568 if (!NILP (w
->hchild
))
1569 mark_window_display_accurate (w
->hchild
, flag
);
1574 last_arrow_position
= COERCE_MARKER (Voverlay_arrow_position
);
1575 last_arrow_string
= Voverlay_arrow_string
;
1579 /* t is unequal to any useful value of Voverlay_arrow_... */
1580 last_arrow_position
= Qt
;
1581 last_arrow_string
= Qt
;
1585 /* Update the menu bar item list for frame F.
1586 This has to be done before we start to fill in any display lines,
1587 because it can call eval.
1589 If SAVE_MATCH_DATA is 1, we must save and restore it here. */
1592 update_menu_bar (f
, save_match_data
)
1594 int save_match_data
;
1596 struct buffer
*old
= current_buffer
;
1598 register struct window
*w
;
1600 window
= FRAME_SELECTED_WINDOW (f
);
1601 w
= XWINDOW (window
);
1603 if (update_mode_lines
)
1604 w
->update_mode_line
= Qt
;
1606 if (FRAME_WINDOW_P (f
)
1608 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1609 FRAME_EXTERNAL_MENU_BAR (f
)
1611 FRAME_MENU_BAR_LINES (f
) > 0
1613 : FRAME_MENU_BAR_LINES (f
) > 0)
1615 /* If the user has switched buffers or windows, we need to
1616 recompute to reflect the new bindings. But we'll
1617 recompute when update_mode_lines is set too; that means
1618 that people can use force-mode-line-update to request
1619 that the menu bar be recomputed. The adverse effect on
1620 the rest of the redisplay algorithm is about the same as
1621 windows_or_buffers_changed anyway. */
1622 if (windows_or_buffers_changed
1623 || !NILP (w
->update_mode_line
)
1624 || ((BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))
1625 < BUF_MODIFF (XBUFFER (w
->buffer
)))
1626 != !NILP (w
->last_had_star
))
1627 || ((!NILP (Vtransient_mark_mode
)
1628 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1629 != !NILP (w
->region_showing
)))
1631 struct buffer
*prev
= current_buffer
;
1632 int count
= specpdl_ptr
- specpdl
;
1634 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1635 if (save_match_data
)
1636 record_unwind_protect (Fstore_match_data
, Fmatch_data (Qnil
, Qnil
));
1637 if (NILP (Voverriding_local_map_menu_flag
))
1639 specbind (Qoverriding_terminal_local_map
, Qnil
);
1640 specbind (Qoverriding_local_map
, Qnil
);
1643 /* Run the Lucid hook. */
1644 call1 (Vrun_hooks
, Qactivate_menubar_hook
);
1645 /* If it has changed current-menubar from previous value,
1646 really recompute the menubar from the value. */
1647 if (! NILP (Vlucid_menu_bar_dirty_flag
))
1648 call0 (Qrecompute_lucid_menubar
);
1649 safe_run_hooks (Qmenu_bar_update_hook
);
1650 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
1651 /* Redisplay the menu bar in case we changed it. */
1652 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1653 if (FRAME_WINDOW_P (f
))
1654 set_frame_menubar (f
, 0, 0);
1656 /* On a terminal screen, the menu bar is an ordinary screen
1657 line, and this makes it get updated. */
1658 w
->update_mode_line
= Qt
;
1659 #else /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1660 /* In the non-toolkit version, the menu bar is an ordinary screen
1661 line, and this makes it get updated. */
1662 w
->update_mode_line
= Qt
;
1663 #endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI) */
1665 unbind_to (count
, Qnil
);
1666 set_buffer_internal_1 (prev
);
1673 /* Redisplay WINDOW and its subwindows and siblings. */
1676 redisplay_windows (window
, preserve_echo_area
)
1678 int preserve_echo_area
;
1680 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1681 redisplay_window (window
, 0, preserve_echo_area
);
1684 /* Return value in display table DP (Lisp_Char_Table *) for character
1685 C. Since a display table doesn't have any parent, we don't have to
1686 follow parent. Do not call this function directly but use the
1687 macro DISP_CHAR_VECTOR. */
1689 disp_char_vector (dp
, c
)
1690 struct Lisp_Char_Table
*dp
;
1696 if (SINGLE_BYTE_CHAR_P (c
)) return (dp
->contents
[c
]);
1698 SPLIT_NON_ASCII_CHAR (c
, code
[0], code
[1], code
[2]);
1699 if (code
[0] != CHARSET_COMPOSITION
)
1701 if (code
[1] < 32) code
[1] = -1;
1702 else if (code
[2] < 32) code
[2] = -1;
1704 /* Here, the possible range of CODE[0] (== charset ID) is
1705 128..MAX_CHARSET. Since the top level char table contains data
1706 for multibyte characters after 256th element, we must increment
1707 CODE[0] by 128 to get a correct index. */
1709 code
[3] = -1; /* anchor */
1711 for (i
= 0; code
[i
] >= 0; i
++, dp
= XCHAR_TABLE (val
))
1713 val
= dp
->contents
[code
[i
]];
1714 if (!SUB_CHAR_TABLE_P (val
))
1715 return (NILP (val
) ? dp
->defalt
: val
);
1717 /* Here, VAL is a sub char table. We return the default value of it. */
1718 return (dp
->defalt
);
1721 /* Redisplay window WINDOW and its subwindows. */
1724 redisplay_window (window
, just_this_one
, preserve_echo_area
)
1726 int just_this_one
, preserve_echo_area
;
1728 register struct window
*w
= XWINDOW (window
);
1729 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1732 int lpoint_byte
= PT_BYTE
;
1733 struct buffer
*old
= current_buffer
;
1734 register int width
= window_internal_width (w
) - 1;
1735 register int startp
, startp_byte
;
1736 register int hscroll
= XINT (w
->hscroll
);
1737 struct position pos
;
1739 int opoint_byte
= PT_BYTE
;
1741 int update_mode_line
;
1742 struct Lisp_Char_Table
*dp
= window_display_table (w
);
1744 if (Z
== Z_BYTE
&& lpoint
!= lpoint_byte
)
1746 if (lpoint_byte
< lpoint
)
1749 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1751 /* If this is a combination window, do its children; that's all. */
1753 if (!NILP (w
->vchild
))
1755 redisplay_windows (w
->vchild
, preserve_echo_area
);
1758 if (!NILP (w
->hchild
))
1760 redisplay_windows (w
->hchild
, preserve_echo_area
);
1763 if (NILP (w
->buffer
))
1766 height
= window_internal_height (w
);
1767 update_mode_line
= (!NILP (w
->update_mode_line
) || update_mode_lines
);
1768 if (XBUFFER (w
->buffer
)->clip_changed
)
1769 update_mode_line
= 1;
1771 if (MINI_WINDOW_P (w
))
1773 if (w
== XWINDOW (echo_area_window
) && echo_area_glyphs
)
1774 /* We've already displayed the echo area glyphs in this window. */
1775 goto finish_scroll_bars
;
1776 else if (w
!= XWINDOW (minibuf_window
))
1778 /* This is a minibuffer, but it's not the currently active one,
1780 int vpos
= XFASTINT (w
->top
);
1783 for (i
= 0; i
< height
; i
++)
1785 get_display_line (f
, vpos
+ i
, 0);
1786 display_string (w
, vpos
+ i
, "", 0,
1787 FRAME_LEFT_SCROLL_BAR_WIDTH (f
),
1791 goto finish_scroll_bars
;
1795 /* Otherwise set up data on this window; select its buffer and point value */
1797 if (update_mode_line
)
1798 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1800 set_buffer_temp (XBUFFER (w
->buffer
));
1803 opoint_byte
= PT_BYTE
;
1805 if (Z
== Z_BYTE
&& opoint
!= opoint_byte
)
1807 if (opoint_byte
< opoint
)
1810 /* If %c is in mode line, update it if needed. */
1811 if (!NILP (w
->column_number_displayed
)
1812 /* This alternative quickly identifies a common case
1813 where no change is needed. */
1814 && !(PT
== XFASTINT (w
->last_point
)
1815 && XFASTINT (w
->last_modified
) >= MODIFF
1816 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)
1817 && XFASTINT (w
->column_number_displayed
) != current_column ())
1818 update_mode_line
= 1;
1820 /* Count number of windows showing the selected buffer.
1821 An indirect buffer counts as its base buffer. */
1825 struct buffer
*current_base
, *window_base
;
1826 current_base
= current_buffer
;
1827 window_base
= XBUFFER (XWINDOW (selected_window
)->buffer
);
1828 if (current_base
->base_buffer
)
1829 current_base
= current_base
->base_buffer
;
1830 if (window_base
->base_buffer
)
1831 window_base
= window_base
->base_buffer
;
1832 if (current_base
== window_base
)
1836 /* POINT refers normally to the selected window.
1837 For any other window, set up appropriate value. */
1839 if (!EQ (window
, selected_window
))
1841 int new_pt
= XMARKER (w
->pointm
)->charpos
;
1842 int new_pt_byte
= marker_byte_position (w
->pointm
);
1846 new_pt_byte
= BEGV_BYTE
;
1847 set_marker_both (w
->pointm
, Qnil
, BEGV
, BEGV_BYTE
);
1849 else if (new_pt
> (ZV
- 1))
1852 new_pt_byte
= ZV_BYTE
;
1853 set_marker_both (w
->pointm
, Qnil
, ZV
, ZV_BYTE
);
1855 /* We don't use SET_PT so that the point-motion hooks don't run. */
1856 TEMP_SET_PT_BOTH (new_pt
, new_pt_byte
);
1859 /* If any of the character widths specified in the display table
1860 have changed, invalidate the width run cache. It's true that this
1861 may be a bit late to catch such changes, but the rest of
1862 redisplay goes (non-fatally) haywire when the display table is
1863 changed, so why should we worry about doing any better? */
1864 if (current_buffer
->width_run_cache
)
1866 struct Lisp_Char_Table
*disptab
= buffer_display_table ();
1868 if (! disptab_matches_widthtab (disptab
,
1869 XVECTOR (current_buffer
->width_table
)))
1871 invalidate_region_cache (current_buffer
,
1872 current_buffer
->width_run_cache
,
1874 recompute_width_table (current_buffer
, disptab
);
1878 /* If window-start is screwed up, choose a new one. */
1879 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1882 startp
= marker_position (w
->start
);
1883 startp_byte
= marker_byte_position (w
->start
);
1885 /* If someone specified a new starting point but did not insist,
1886 check whether it can be used. */
1887 if (!NILP (w
->optional_new_start
))
1889 w
->optional_new_start
= Qnil
;
1890 /* Check whether this start pos is usable given where point is. */
1892 pos
= *compute_motion (startp
, 0,
1893 (((EQ (window
, minibuf_window
)
1895 ? minibuf_prompt_width
: 0)
1896 + (hscroll
? 1 - hscroll
: 0)),
1899 /* BUG FIX: See the comment of
1900 Fpos_visible_in_window_p (window.c). */
1901 - (1 << (BITS_PER_SHORT
- 1)),
1903 pos_tab_offset (w
, startp
, startp_byte
), w
);
1904 /* If PT does fit on the screen, we will use this start pos,
1905 so do so by setting force_start. */
1906 if (pos
.bufpos
== PT
)
1907 w
->force_start
= Qt
;
1910 /* Handle case where place to start displaying has been specified,
1911 unless the specified location is outside the accessible range. */
1912 if (!NILP (w
->force_start
))
1914 w
->force_start
= Qnil
;
1915 /* Forget any recorded base line for line number display. */
1916 w
->base_line_number
= Qnil
;
1917 /* Redisplay the mode line. Select the buffer properly for that.
1918 Also, run the hook window-scroll-functions
1919 because we have scrolled. */
1920 /* Note, we do this after clearing force_start because
1921 if there's an error, it is better to forget about force_start
1922 than to get into an infinite loop calling the hook functions
1923 and having them get more errors. */
1924 if (!update_mode_line
1925 || ! NILP (Vwindow_scroll_functions
))
1927 Lisp_Object temp
[3];
1929 set_buffer_temp (old
);
1930 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1931 update_mode_line
= 1;
1932 w
->update_mode_line
= Qt
;
1933 if (! NILP (Vwindow_scroll_functions
))
1935 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
1936 make_number (startp
));
1937 startp
= marker_position (w
->start
);
1940 XSETFASTINT (w
->last_modified
, 0);
1941 XSETFASTINT (w
->last_overlay_modified
, 0);
1942 if (startp
< BEGV
) startp
= BEGV
, startp_byte
= BEGV_BYTE
;
1943 if (startp
> ZV
) startp
= ZV
, startp
= ZV_BYTE
;
1944 try_window (window
, startp
);
1945 if (cursor_vpos
< 0)
1947 /* If point does not appear, move point so it does appear */
1948 pos
= *compute_motion (startp
, 0,
1949 (((EQ (window
, minibuf_window
)
1951 ? minibuf_prompt_width
: 0)
1952 + (hscroll
? 1 - hscroll
: 0)),
1955 - (1 << (BITS_PER_SHORT
- 1)),
1957 pos_tab_offset (w
, startp
, startp_byte
),
1959 TEMP_SET_PT_BOTH (pos
.bufpos
, pos
.bytepos
);
1960 if (w
!= XWINDOW (selected_window
))
1961 set_marker_both (w
->pointm
, Qnil
, PT
, PT_BYTE
);
1964 if (current_buffer
== old
)
1967 lpoint_byte
= PT_BYTE
;
1969 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
1970 + minmax (0, pos
.hpos
, width
));
1971 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1973 /* If we are highlighting the region,
1974 then we just changed the region, so redisplay to show it. */
1975 if (!NILP (Vtransient_mark_mode
)
1976 && !NILP (current_buffer
->mark_active
))
1978 cancel_my_columns (XWINDOW (window
));
1979 try_window (window
, startp
);
1985 /* Handle case where text has not changed, only point,
1986 and it has not moved off the frame. */
1988 /* This code is not used for minibuffer for the sake of
1989 the case of redisplaying to replace an echo area message;
1990 since in that case the minibuffer contents per se are usually unchanged.
1991 This code is of no real use in the minibuffer since
1992 the handling of this_line_bufpos, etc.,
1993 in redisplay handles the same cases. */
1995 if (XFASTINT (w
->last_modified
) >= MODIFF
1996 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
1997 && PT
>= startp
&& !current_buffer
->clip_changed
1998 && (just_this_one
|| WINDOW_FULL_WIDTH_P (w
))
1999 /* If force-mode-line-update was called, really redisplay;
2000 that's how redisplay is forced after e.g. changing
2001 buffer-invisibility-spec. */
2002 && NILP (w
->update_mode_line
)
2003 /* Can't use this case if highlighting a region. */
2004 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
2005 && NILP (w
->region_showing
)
2006 /* If end pos is out of date, scroll bar and percentage will be wrong */
2007 && INTEGERP (w
->window_end_vpos
)
2008 && XFASTINT (w
->window_end_vpos
) < XFASTINT (w
->height
)
2009 && !EQ (window
, minibuf_window
)
2010 && (!MARKERP (Voverlay_arrow_position
)
2011 || current_buffer
!= XMARKER (Voverlay_arrow_position
)->buffer
))
2013 /* All positions in this clause are relative to the window edge. */
2015 int this_scroll_margin
= scroll_margin
;
2016 int last_point_y
= XFASTINT (w
->last_point_y
) - XINT (w
->top
);
2017 int last_point_x
= (XFASTINT (w
->last_point_x
) - WINDOW_LEFT_MARGIN (w
));
2019 /* Find where PT is located now on the frame. */
2020 /* Check just_this_one as a way of verifying that the
2021 window edges have not changed. */
2022 if (PT
== XFASTINT (w
->last_point
) && just_this_one
)
2024 pos
.hpos
= last_point_x
;
2025 pos
.vpos
= last_point_y
;
2028 else if (PT
> XFASTINT (w
->last_point
)
2029 && XFASTINT (w
->last_point
) > startp
&& just_this_one
2030 /* We can't use this if point is in the left margin of a
2031 hscrolled window, because w->last_point_x has been
2032 clipped to the window edges. */
2033 && !(last_point_x
<= 0 && hscroll
))
2035 pos
= *compute_motion (XFASTINT (w
->last_point
),
2036 last_point_y
, last_point_x
, 0,
2038 /* BUG FIX: See the comment of
2039 Fpos_visible_in_window_p (window.c). */
2040 - (1 << (BITS_PER_SHORT
- 1)),
2042 pos_tab_offset (w
, startp
, startp_byte
),
2047 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0), 0,
2049 /* BUG FIX: See the comment of
2050 Fpos_visible_in_window_p (window.c). */
2051 - (1 << (BITS_PER_SHORT
- 1)),
2053 pos_tab_offset (w
, startp
, startp_byte
),
2057 /* Don't use a scroll margin that is negative or too large. */
2058 if (this_scroll_margin
< 0)
2059 this_scroll_margin
= 0;
2061 if (XINT (w
->height
) < 4 * scroll_margin
)
2062 this_scroll_margin
= XINT (w
->height
) / 4;
2064 /* If point fits on the screen, and not within the scroll margin,
2066 if (pos
.vpos
< height
- this_scroll_margin
2067 && (pos
.vpos
>= this_scroll_margin
|| startp
== BEGV
))
2069 /* Ok, point is still on frame */
2070 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2072 /* These variables are supposed to be origin 1 */
2073 FRAME_CURSOR_X (f
) = (WINDOW_LEFT_MARGIN (w
)
2074 + minmax (0, pos
.hpos
, width
));
2075 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
2077 /* This doesn't do the trick, because if a window to the right of
2078 this one must be redisplayed, this does nothing because there
2079 is nothing in DesiredFrame yet, and then the other window is
2080 redisplayed, making likes that are empty in this window's columns.
2081 if (WINDOW_FULL_WIDTH_P (w))
2082 preserve_my_columns (w);
2084 if (current_buffer
->clip_changed
2085 && ! NILP (Vwindow_scroll_functions
))
2086 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2087 make_number (marker_position (w
->start
)));
2091 /* Don't bother trying redisplay with same start;
2092 we already know it will lose */
2094 /* If current starting point was originally the beginning of a line
2095 but no longer is, find a new starting point. */
2096 else if (!NILP (w
->start_at_line_beg
)
2098 || FETCH_BYTE (startp_byte
- 1) == '\n'))
2102 else if (just_this_one
&& !MINI_WINDOW_P (w
)
2104 && XFASTINT (w
->last_modified
)
2105 /* or else vmotion on first line won't work. */
2106 && ! NILP (w
->start_at_line_beg
)
2107 && ! EQ (w
->window_end_valid
, Qnil
)
2108 && do_id
&& !current_buffer
->clip_changed
2109 && !blank_end_of_window
2110 && WINDOW_FULL_WIDTH_P (w
)
2111 /* Can't use this case if highlighting a region. */
2112 && !(!NILP (Vtransient_mark_mode
)
2113 && !NILP (current_buffer
->mark_active
))
2114 /* Don't use try_window_id if newline
2115 doesn't display as the end of a line. */
2116 && !(dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, '\n')))
2117 && NILP (w
->region_showing
)
2118 && EQ (last_arrow_position
, COERCE_MARKER (Voverlay_arrow_position
))
2119 && EQ (last_arrow_string
, Voverlay_arrow_string
)
2120 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
2123 /* tem > 0 means success. tem == -1 means choose new start.
2124 tem == -2 means try again with same start,
2125 and nothing but whitespace follows the changed stuff.
2126 tem == 0 means try again with same start. */
2130 else if (startp
>= BEGV
&& startp
<= ZV
2132 /* Avoid starting at end of buffer. */
2133 #if 0 /* This change causes trouble for M-! finger & RET.
2134 It will have to be considered later. */
2135 || ! EQ (window
, selected_window
)
2136 /* Don't do the recentering if redisplay
2137 is not for no user action. */
2138 || preserve_echo_area
2141 || (XFASTINT (w
->last_modified
) >= MODIFF
2142 && XFASTINT (w
->last_overlay_modified
) >= OVERLAY_MODIFF
)))
2144 /* Try to redisplay starting at same place as before */
2145 /* If point has not moved off frame, accept the results */
2146 try_window (window
, startp
);
2147 if (cursor_vpos
>= 0)
2149 if (!just_this_one
|| current_buffer
->clip_changed
2150 || beg_unchanged
< startp
)
2151 /* Forget any recorded base line for line number display. */
2152 w
->base_line_number
= Qnil
;
2154 if (current_buffer
->clip_changed
2155 && ! NILP (Vwindow_scroll_functions
))
2156 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2157 make_number (marker_position (w
->start
)));
2162 cancel_my_columns (w
);
2165 XSETFASTINT (w
->last_modified
, 0);
2166 XSETFASTINT (w
->last_overlay_modified
, 0);
2167 /* Redisplay the mode line. Select the buffer properly for that. */
2168 if (!update_mode_line
)
2170 set_buffer_temp (old
);
2171 set_buffer_internal_1 (XBUFFER (w
->buffer
));
2172 update_mode_line
= 1;
2173 w
->update_mode_line
= Qt
;
2176 /* Try to scroll by specified few lines */
2178 if (scroll_conservatively
&& !current_buffer
->clip_changed
2179 && startp
>= BEGV
&& startp
<= ZV
)
2181 int this_scroll_margin
= scroll_margin
;
2182 int scroll_margin_pos
;
2184 /* Don't use a scroll margin that is negative or too large. */
2185 if (this_scroll_margin
< 0)
2186 this_scroll_margin
= 0;
2188 if (XINT (w
->height
) < 4 * this_scroll_margin
)
2189 this_scroll_margin
= XINT (w
->height
) / 4;
2191 scroll_margin_pos
= Z
- XFASTINT (w
->window_end_pos
);
2192 if (this_scroll_margin
)
2194 pos
= *vmotion (scroll_margin_pos
, -this_scroll_margin
, w
);
2195 scroll_margin_pos
= pos
.bufpos
;
2197 if (PT
>= scroll_margin_pos
)
2199 struct position pos
;
2200 pos
= *compute_motion (scroll_margin_pos
, 0, 0, 0,
2201 PT
, XFASTINT (w
->height
), 0,
2202 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2203 pos_tab_offset (w
, startp
, startp_byte
),
2205 if (pos
.vpos
> scroll_conservatively
)
2208 pos
= *vmotion (startp
, pos
.vpos
+ 1, w
);
2210 if (! NILP (Vwindow_scroll_functions
))
2212 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2213 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2214 make_number (pos
.bufpos
));
2215 pos
.bufpos
= marker_position (w
->start
);
2217 try_window (window
, pos
.bufpos
);
2218 if (cursor_vpos
>= 0)
2220 if (!just_this_one
|| current_buffer
->clip_changed
2221 || beg_unchanged
< startp
)
2222 /* Forget any recorded base line for line number display. */
2223 w
->base_line_number
= Qnil
;
2227 cancel_my_columns (w
);
2230 scroll_margin_pos
= startp
;
2231 if (this_scroll_margin
)
2233 pos
= *vmotion (scroll_margin_pos
, this_scroll_margin
, w
);
2234 scroll_margin_pos
= pos
.bufpos
;
2236 if (PT
< scroll_margin_pos
)
2238 struct position pos
;
2239 pos
= *compute_motion (PT
, 0, 0, 0,
2240 scroll_margin_pos
, XFASTINT (w
->height
), 0,
2241 XFASTINT (w
->width
), XFASTINT (w
->hscroll
),
2242 pos_tab_offset (w
, startp
, startp_byte
),
2244 if (pos
.vpos
> scroll_conservatively
)
2247 pos
= *vmotion (startp
, -pos
.vpos
, w
);
2249 if (! NILP (Vwindow_scroll_functions
))
2251 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2252 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2253 make_number (pos
.bufpos
));
2254 pos
.bufpos
= marker_position (w
->start
);
2256 try_window (window
, pos
.bufpos
);
2257 if (cursor_vpos
>= 0)
2259 if (!just_this_one
|| current_buffer
->clip_changed
2260 || beg_unchanged
< startp
)
2261 /* Forget any recorded base line for line number display. */
2262 w
->base_line_number
= Qnil
;
2266 cancel_my_columns (w
);
2271 if (scroll_step
&& !current_buffer
->clip_changed
2272 && startp
>= BEGV
&& startp
<= ZV
)
2276 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), scroll_step
, w
);
2277 if (pos
.vpos
>= height
)
2281 pos
= *vmotion (startp
, (PT
< startp
? - scroll_step
: scroll_step
), w
);
2283 if (PT
>= pos
.bufpos
)
2285 if (! NILP (Vwindow_scroll_functions
))
2287 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2288 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2289 make_number (pos
.bufpos
));
2290 pos
.bufpos
= marker_position (w
->start
);
2292 try_window (window
, pos
.bufpos
);
2293 if (cursor_vpos
>= 0)
2295 if (!just_this_one
|| current_buffer
->clip_changed
2296 || beg_unchanged
< startp
)
2297 /* Forget any recorded base line for line number display. */
2298 w
->base_line_number
= Qnil
;
2302 cancel_my_columns (w
);
2307 /* Finally, just choose place to start which centers point */
2310 /* Forget any previously recorded base line for line number display. */
2311 w
->base_line_number
= Qnil
;
2313 pos
= *vmotion (PT
, - (height
/ 2), w
);
2315 /* The minibuffer is often just one line. Ordinary scrolling
2316 gives little overlap and looks bad. So show 20 chars before point. */
2318 && (pos
.bufpos
>= PT
- minibuffer_scroll_overlap
2319 /* If we scrolled less than 1/2 line forward, we will
2320 get too much overlap, so change to the usual amount. */
2321 || pos
.bufpos
< startp
+ width
/ 2)
2322 && PT
> BEGV
+ minibuffer_scroll_overlap
2323 /* If we scrolled to an actual line boundary,
2324 that's different; don't ignore line boundaries. */
2325 && FETCH_BYTE (pos
.bufpos
- 1) != '\n')
2327 pos
.bufpos
= PT
- minibuffer_scroll_overlap
;
2328 pos
.bytepos
= CHAR_TO_BYTE (pos
.bufpos
);
2331 /* Set startp here explicitly in case that helps avoid an infinite loop
2332 in case the window-scroll-functions functions get errors. */
2333 set_marker_both (w
->start
, Qnil
, pos
.bufpos
, pos
.bytepos
);
2334 if (! NILP (Vwindow_scroll_functions
))
2336 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
2337 make_number (pos
.bufpos
));
2338 pos
.bufpos
= marker_position (w
->start
);
2339 pos
.bytepos
= marker_byte_position (w
->start
);
2341 try_window (window
, pos
.bufpos
);
2343 startp
= marker_position (w
->start
);
2344 startp_byte
= marker_byte_position (w
->start
);
2345 w
->start_at_line_beg
2346 = (startp
== BEGV
|| FETCH_BYTE (startp_byte
- 1) == '\n') ? Qt
: Qnil
;
2349 if ((update_mode_line
2350 /* If window not full width, must redo its mode line
2351 if the window to its side is being redone */
2352 || (!just_this_one
&& !WINDOW_FULL_WIDTH_P (w
))
2353 || INTEGERP (w
->base_line_pos
)
2354 || (!NILP (w
->column_number_displayed
)
2355 && XFASTINT (w
->column_number_displayed
) != current_column ()))
2356 && height
!= XFASTINT (w
->height
))
2357 display_mode_line (w
);
2358 if (! line_number_displayed
2359 && ! BUFFERP (w
->base_line_pos
))
2361 w
->base_line_pos
= Qnil
;
2362 w
->base_line_number
= Qnil
;
2365 /* When we reach a frame's selected window, redo the frame's menu bar. */
2366 if (update_mode_line
2367 && (FRAME_WINDOW_P (f
)
2369 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2370 FRAME_EXTERNAL_MENU_BAR (f
)
2372 FRAME_MENU_BAR_LINES (f
) > 0
2374 : FRAME_MENU_BAR_LINES (f
) > 0)
2375 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
2376 display_menu_bar (w
);
2379 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2381 int start
, end
, whole
;
2383 /* Calculate the start and end positions for the current window.
2384 At some point, it would be nice to choose between scrollbars
2385 which reflect the whole buffer size, with special markers
2386 indicating narrowing, and scrollbars which reflect only the
2389 Note that minibuffers sometimes aren't displaying any text. */
2390 if (! MINI_WINDOW_P (w
)
2391 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
2394 start
= marker_position (w
->start
) - BEGV
;
2395 /* I don't think this is guaranteed to be right. For the
2396 moment, we'll pretend it is. */
2397 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
2399 if (end
< start
) end
= start
;
2400 if (whole
< (end
- start
)) whole
= end
- start
;
2403 start
= end
= whole
= 0;
2405 /* Indicate what this scroll bar ought to be displaying now. */
2406 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
2408 /* Note that we actually used the scroll bar attached to this window,
2409 so it shouldn't be deleted at the end of redisplay. */
2410 (*redeem_scroll_bar_hook
) (w
);
2413 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
2414 if (update_mode_line
)
2415 set_buffer_internal_1 (old
);
2417 set_buffer_temp (old
);
2418 TEMP_SET_PT_BOTH (lpoint
, lpoint_byte
);
2421 /* Do full redisplay on one window, starting at position `pos'. */
2424 try_window (window
, pos
)
2428 register struct window
*w
= XWINDOW (window
);
2429 register int height
= window_internal_height (w
);
2430 register int vpos
= XFASTINT (w
->top
);
2431 register int last_text_vpos
= vpos
;
2432 FRAME_PTR f
= XFRAME (w
->frame
);
2433 int width
= window_internal_width (w
) - 1;
2434 struct position val
;
2436 /* POS should never be out of range! */
2437 if (pos
< XBUFFER (w
->buffer
)->begv
2438 || pos
> XBUFFER (w
->buffer
)->zv
)
2441 if (XMARKER (w
->start
)->charpos
!= pos
)
2442 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2445 overlay_arrow_seen
= 0;
2446 zv_strings_seen
= 0;
2447 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2448 val
.ovstring_chars_done
= 0;
2449 val
.bytepos
= marker_byte_position (w
->start
);
2450 val
.tab_offset
= pos_tab_offset (w
, pos
, val
.bytepos
);
2452 while (--height
>= 0)
2454 val
= *display_text_line (w
, pos
, val
.bytepos
, vpos
,
2455 val
.hpos
, val
.tab_offset
,
2456 val
.ovstring_chars_done
);
2457 /* The following code is omitted because we maintain tab_offset
2460 tab_offset
+= width
;
2461 if (val
.vpos
) tab_offset
= 0;
2464 if (pos
!= val
.bufpos
)
2467 #ifdef USE_TEXT_PROPERTIES
2468 Lisp_Object invis_prop
;
2469 invis_prop
= Fget_char_property (val
.bufpos
-1, Qinvisible
, window
);
2470 invis
= TEXT_PROP_MEANS_INVISIBLE (invis_prop
);
2474 /* Next line, unless prev line ended in end of buffer with no cr */
2476 && (FETCH_BYTE (val
.bytepos
- 1) != '\n' || invis
));
2481 /* If last line is continued in middle of character,
2482 include the split character in the text considered on the frame */
2483 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2486 /* If bottom just moved off end of frame, change mode line percentage. */
2487 if (XFASTINT (w
->window_end_pos
) == 0
2489 w
->update_mode_line
= Qt
;
2491 /* Say where last char on frame will be, once redisplay is finished. */
2492 XSETFASTINT (w
->window_end_pos
, Z
- pos
);
2493 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
- XFASTINT (w
->top
));
2494 /* But that is not valid info until redisplay finishes. */
2495 w
->window_end_valid
= Qnil
;
2498 /* Try to redisplay when buffer is modified locally,
2499 computing insert/delete line to preserve text outside
2500 the bounds of the changes.
2501 Return 1 if successful, 0 if if cannot tell what to do,
2502 or -1 to tell caller to find a new window start,
2503 or -2 to tell caller to do normal redisplay with same window start. */
2506 try_window_id (window
)
2510 int opoint
, opoint_byte
;
2511 register struct window
*w
= XWINDOW (window
);
2512 register int height
= window_internal_height (w
);
2513 FRAME_PTR f
= XFRAME (w
->frame
);
2514 int top
= XFASTINT (w
->top
);
2515 int start
= marker_position (w
->start
);
2516 int width
= window_internal_width (w
) - 1;
2517 int hscroll
= XINT (w
->hscroll
);
2518 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
2521 register int i
, tem
;
2522 int last_text_vpos
= 0;
2524 int selective
= (INTEGERP (current_buffer
->selective_display
)
2525 ? XINT (current_buffer
->selective_display
)
2526 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
2528 struct position val
, bp
, ep
, xp
, pp
;
2529 int scroll_amount
= 0;
2533 int start_byte
= marker_byte_position (w
->start
);
2535 if (GPT
- BEG
< beg_unchanged
)
2536 beg_unchanged
= GPT
- BEG
;
2537 if (Z
- GPT
< end_unchanged
)
2538 end_unchanged
= Z
- GPT
;
2540 if (beg_unchanged
+ BEG
< start
)
2541 return 0; /* Give up if changes go above top of window */
2543 /* Find position before which nothing is changed. */
2544 bp
= *compute_motion (start
, 0, lmargin
, 0,
2545 min (ZV
, beg_unchanged
+ BEG
), height
,
2546 /* BUG FIX: See the comment of
2547 Fpos_visible_in_window_p (window.c). */
2548 - (1 << (BITS_PER_SHORT
- 1)),
2550 pos_tab_offset (w
, start
, start_byte
),
2552 if (bp
.vpos
>= height
)
2556 /* All changes are beyond the window end, and point is on the screen.
2557 We don't need to change the text at all.
2558 But we need to update window_end_pos to account for
2559 any change in buffer size. */
2560 bp
= *compute_motion (start
, 0, lmargin
, 0,
2562 /* BUG FIX: See the comment of
2563 Fpos_visible_in_window_p() (window.c). */
2564 - (1 << (BITS_PER_SHORT
- 1)),
2566 pos_tab_offset (w
, start
, start_byte
), w
);
2567 XSETFASTINT (w
->window_end_vpos
, height
);
2568 XSETFASTINT (w
->window_end_pos
, Z
- bp
.bufpos
);
2576 /* Find beginning of that frame line. Must display from there. */
2577 bp
= *vmotion (bp
.bufpos
, 0, w
);
2580 pos_byte
= bp
.bytepos
;
2586 /* If about to start displaying at the beginning of a continuation line,
2587 really start with previous frame line, in case it was not
2588 continued when last redisplayed */
2589 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
2591 /* Likewise if we have to worry about selective display. */
2592 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
2594 bp
= *vmotion (bp
.bufpos
, -1, w
);
2597 pos_byte
= bp
.bytepos
;
2599 val
.tab_offset
= bp
.tab_offset
; /* Update tab offset. */
2601 if (bp
.contin
&& bp
.hpos
!= lmargin
)
2603 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
2604 val
.tab_offset
= bp
.tab_offset
+ bp
.prevhpos
- width
;
2612 /* Find first visible newline after which no more is changed. */
2613 opoint
= PT
, opoint_byte
= PT_BYTE
;
2614 SET_PT (Z
- max (end_unchanged
, Z
- ZV
));
2615 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2617 while (PT
< ZV
- 1 && indented_beyond_p (PT
, PT_BYTE
, selective
))
2618 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
2620 SET_PT_BOTH (opoint
, opoint_byte
);
2622 /* Compute the cursor position after that newline. */
2623 ep
= *compute_motion (pos
, vpos
, val
.hpos
, did_motion
, tem
,
2624 height
, - (1 << (BITS_PER_SHORT
- 1)),
2626 /* We have tab offset in VAL, use it. */
2629 /* If changes reach past the text available on the frame,
2630 just display rest of frame. */
2631 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
2634 stop_vpos
= ep
.vpos
;
2636 /* If no newline before ep, the line ep is on includes some changes
2637 that must be displayed. Make sure we don't stop before it. */
2638 /* Also, if changes reach all the way until ep.bufpos,
2639 it is possible that something was deleted after the
2640 newline before it, so the following line must be redrawn. */
2641 if (stop_vpos
== ep
.vpos
2642 && (ep
.bufpos
== BEGV
2643 || FETCH_BYTE (ep
.bufpos
- 1) != '\n'
2644 || ep
.bufpos
== Z
- end_unchanged
))
2645 stop_vpos
= ep
.vpos
+ 1;
2648 overlay_arrow_seen
= 0;
2649 zv_strings_seen
= 0;
2651 /* If changes do not reach to bottom of window,
2652 figure out how much to scroll the rest of the window */
2653 if (stop_vpos
< height
)
2655 /* Now determine how far up or down the rest of the window has moved */
2656 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2657 Z
- XFASTINT (w
->window_end_pos
),
2658 /* Don't care for VPOS... */
2659 1 << (BITS_PER_SHORT
- 1),
2661 1 << (BITS_PER_SHORT
- 1),
2662 width
, hscroll
, ep
.tab_offset
, w
);
2663 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
2665 /* Is everything on frame below the changes whitespace?
2666 If so, no scrolling is really necessary. */
2667 for (i
= ep
.bufpos
; i
< xp
.bufpos
; i
++)
2669 tem
= FETCH_BYTE (i
);
2670 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
2676 XSETFASTINT (w
->window_end_vpos
,
2677 XFASTINT (w
->window_end_vpos
) + scroll_amount
);
2679 /* Before doing any scrolling, verify that point will be on frame. */
2680 if (PT
> ep
.bufpos
&& !(PT
<= xp
.bufpos
&& xp
.vpos
< height
))
2682 if (PT
<= xp
.bufpos
)
2684 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
2685 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2687 /* We have tab offset in EP, use it. */
2692 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
, 1,
2693 PT
, height
, - (1 << (BITS_PER_SHORT
- 1)),
2695 /* We have tab offset in XP, use it. */
2698 if (pp
.bufpos
< PT
|| pp
.vpos
== height
)
2700 cursor_vpos
= pp
.vpos
+ top
;
2701 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, pp
.hpos
, width
);
2704 if (stop_vpos
- scroll_amount
>= height
2705 || ep
.bufpos
== xp
.bufpos
)
2707 if (scroll_amount
< 0)
2708 stop_vpos
-= scroll_amount
;
2710 /* In this path, we have altered window_end_vpos
2711 and not left it negative.
2712 We must make sure that, in case display is preempted
2713 before the frame changes to reflect what we do here,
2714 further updates will not come to try_window_id
2715 and assume the frame and window_end_vpos match. */
2716 blank_end_of_window
= 1;
2718 else if (!scroll_amount
)
2720 /* Even if we don't need to scroll, we must adjust the
2721 charstarts of subsequent lines (that we won't redisplay)
2722 according to the amount of text inserted or deleted. */
2723 int oldpos
= FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2724 int adjust
= ep
.bufpos
- oldpos
;
2725 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1, adjust
);
2727 else if (bp
.bufpos
== Z
- end_unchanged
)
2729 /* If reprinting everything is nearly as fast as scrolling,
2730 don't bother scrolling. Can happen if lines are short. */
2731 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
2732 top
+ height
- max (0, scroll_amount
),
2734 > xp
.bufpos
- bp
.bufpos
- 20)
2735 /* Return "try normal display with same window-start."
2736 Too bad we can't prevent further scroll-thinking. */
2738 /* If pure deletion, scroll up as many lines as possible.
2739 In common case of killing a line, this can save the
2740 following line from being overwritten by scrolling
2741 and therefore having to be redrawn. */
2742 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
2743 top
+ height
- max (0, scroll_amount
),
2744 scroll_amount
, bp
.bufpos
);
2749 /* scroll_frame_lines did not properly adjust subsequent
2750 lines' charstarts in the case where the text of the
2751 screen line at bp.vpos has changed.
2752 (This can happen in a deletion that ends in mid-line.)
2753 To adjust properly, we need to make things consistent
2755 So do a second adjust to make that happen.
2756 Note that stop_vpos >= ep.vpos, so it is sufficient
2757 to update the charstarts for lines at ep.vpos and below. */
2759 = FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2760 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1,
2761 ep
.bufpos
- oldstart
);
2764 else if (scroll_amount
)
2766 /* If reprinting everything is nearly as fast as scrolling,
2767 don't bother scrolling. Can happen if lines are short. */
2768 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
2769 overestimate of cost of reprinting, since xp.bufpos
2770 would end up below the bottom of the window. */
2771 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
2772 top
+ height
- max (0, scroll_amount
),
2774 > xp
.bufpos
- ep
.bufpos
- 20)
2775 /* Return "try normal display with same window-start."
2776 Too bad we can't prevent further scroll-thinking. */
2778 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
2779 top
+ height
- max (0, scroll_amount
),
2780 scroll_amount
, ep
.bufpos
);
2781 if (!tem
) stop_vpos
= height
;
2785 /* In any case, do not display past bottom of window */
2786 if (stop_vpos
>= height
)
2792 /* Handle case where pos is before w->start --
2793 can happen if part of line had been clipped and is not clipped now */
2794 if (vpos
== 0 && pos
< marker_position (w
->start
))
2795 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2797 val
.bytepos
= pos_byte
;
2799 /* Redisplay the lines where the text was changed */
2800 last_text_vpos
= vpos
;
2801 /* The following code is omitted because we maintain tab offset in
2804 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2805 /* If we are starting display in mid-character, correct tab_offset
2806 to account for passing the line that that character really starts in. */
2807 if (val
.hpos
< lmargin
)
2808 tab_offset
+= width
;
2811 while (vpos
< stop_vpos
)
2813 val
= *display_text_line (w
, pos
, val
.bytepos
, top
+ vpos
++,
2814 val
.hpos
, val
.tab_offset
,
2815 val
.ovstring_chars_done
);
2816 /* If display_text_line ran a hook and changed some text,
2817 redisplay all the way to bottom of buffer
2818 So that we show the changes. */
2819 if (old_tick
!= MODIFF
)
2821 /* The following code is omitted because we maintain tab offset
2822 in val.tab_offset. */
2824 tab_offset
+= width
;
2825 if (val
.vpos
) tab_offset
= 0;
2827 if (pos
!= val
.bufpos
)
2829 /* Next line, unless prev line ended in end of buffer with no cr */
2830 = vpos
- (val
.vpos
&& FETCH_BYTE (val
.bufpos
- 1) != '\n');
2834 /* There are two cases:
2835 1) we have displayed down to the bottom of the window
2836 2) we have scrolled lines below stop_vpos by scroll_amount */
2840 /* If last line is continued in middle of character,
2841 include the split character in the text considered on the frame */
2842 if (val
.hpos
< lmargin
)
2844 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
);
2845 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2848 /* If scrolling made blank lines at window bottom,
2849 redisplay to fill those lines */
2850 if (scroll_amount
< 0)
2852 /* Don't consider these lines for general-purpose scrolling.
2853 That will save time in the scrolling computation. */
2854 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
2857 pos_byte
= xp
.bytepos
;
2859 val
.tab_offset
= xp
.tab_offset
;
2861 { /* Display from next line */
2862 vpos
= height
+ scroll_amount
;
2866 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
2868 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
2869 val
.tab_offset
= xp
.tab_offset
+ bp
.prevhpos
- width
;
2874 blank_end_of_window
= 1;
2875 /* The following code is omitted because we maintain tab offset
2876 in val.tab_offset. */
2878 tab_offset
= pos_tab_offset (w
, pos
, pos_byte
);
2879 /* If we are starting display in mid-character, correct tab_offset
2880 to account for passing the line that that character starts in. */
2881 if (val
.hpos
< lmargin
)
2882 tab_offset
+= width
;
2885 while (vpos
< height
)
2887 val
= *display_text_line (w
, pos
, val
.bytepos
,
2888 top
+ vpos
++, val
.hpos
,
2889 val
.tab_offset
, val
.ovstring_chars_done
);
2890 /* The following code is omitted because we maintain tab
2891 offset in val.tab_offset. */
2893 tab_offset
+= width
;
2894 if (val
.vpos
) tab_offset
= 0;
2899 /* Here is a case where display_text_line sets cursor_vpos wrong.
2900 Make it be fixed up, below. */
2906 /* If bottom just moved off end of frame, change mode line percentage. */
2907 if (XFASTINT (w
->window_end_pos
) == 0
2909 w
->update_mode_line
= Qt
;
2911 /* Attempt to adjust end-of-text positions to new bottom line */
2914 delta
= height
- xp
.vpos
;
2916 || (delta
> 0 && xp
.bufpos
<= ZV
)
2917 || (delta
== 0 && xp
.hpos
))
2919 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), delta
, w
);
2920 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2921 XSETFASTINT (w
->window_end_vpos
,
2922 XFASTINT (w
->window_end_vpos
) + val
.vpos
);
2926 w
->window_end_valid
= Qnil
;
2928 /* If point was not in a line that was displayed, find it */
2929 if (cursor_vpos
< 0)
2932 val
= *compute_motion (start
, 0, lmargin
, 0, PT
,
2933 /* Don't care for VPOS... */
2934 1 << (BITS_PER_SHORT
- 1),
2936 1 << (BITS_PER_SHORT
- 1),
2938 pos_tab_offset (w
, start
, start_byte
),
2940 /* Admit failure if point is off frame now */
2941 if (val
.vpos
>= height
)
2943 for (vpos
= 0; vpos
< height
; vpos
++)
2944 cancel_line (vpos
+ top
, f
);
2947 cursor_vpos
= val
.vpos
+ top
;
2948 cursor_hpos
= WINDOW_LEFT_MARGIN (w
) + minmax (0, val
.hpos
, width
);
2951 FRAME_CURSOR_X (f
) = cursor_hpos
;
2952 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2956 val
= *compute_motion (start
, 0, lmargin
, 0, ZV
,
2957 height
, - (1 << (BITS_PER_SHORT
- 1)),
2959 pos_tab_offset (w
, start
, start_byte
),
2961 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
2963 if (XFASTINT (w
->window_end_pos
)
2971 /* Copy LEN glyphs starting address FROM to the rope TO.
2972 But don't actually copy the parts that would come in before S.
2973 Value is TO, advanced past the copied data.
2974 F is the frame we are displaying in. */
2977 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
2979 register GLYPH
*to
; /* Copy to here. */
2980 register GLYPH
*s
; /* Starting point. */
2981 Lisp_Object
*from
; /* Data to copy. */
2983 int face
; /* Face to apply to glyphs which don't specify one. */
2986 register Lisp_Object
*fp
= from
;
2987 /* These cache the results of the last call to compute_glyph_face. */
2989 int last_merged
= 0;
2992 if (! FRAME_TERMCAP_P (f
))
2995 GLYPH glyph
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
2997 unsigned int c
= FAST_GLYPH_CHAR (glyph
);
3000 /* For an invalid character code, use space. */
3003 if (FAST_GLYPH_FACE (glyph
) == 0)
3004 /* If GLYPH has no face code, use FACE. */
3006 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
3007 /* If it's same as previous glyph, use same result. */
3008 facecode
= last_merged
;
3011 /* Merge this glyph's face and remember the result. */
3012 last_code
= FAST_GLYPH_FACE (glyph
);
3013 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
3017 *to
= FAST_MAKE_GLYPH (c
, facecode
);
3025 if (to
>= s
) *to
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
3032 /* Correct a glyph by replacing its specified user-level face code
3033 with a displayable computed face code. */
3036 fix_glyph (f
, glyph
, cface
)
3042 if (! FRAME_TERMCAP_P (f
))
3044 if (FAST_GLYPH_FACE (glyph
) != 0)
3045 cface
= compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
), cface
);
3046 glyph
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), cface
);
3052 /* Return the column of position POS / POS_BYTE in window W's buffer.
3053 The result is rounded down to a multiple of the internal width of W.
3054 This is the amount of indentation of position POS
3055 that is not visible in its horizontal position in the window. */
3058 pos_tab_offset (w
, pos
, pos_byte
)
3060 register int pos
, pos_byte
;
3063 int opoint_byte
= PT_BYTE
;
3065 int width
= window_internal_width (w
) - 1;
3068 return MINI_WINDOW_P (w
) ? -minibuf_prompt_width
: 0;
3070 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3073 TEMP_SET_PT_BOTH (pos
, pos_byte
);
3074 col
= current_column ();
3075 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
3080 /* Display one line of window W, starting at char position START in W's buffer.
3081 START_BYTE is the corresponding byte position.
3083 Display starting at horizontal position HPOS, expressed relative to
3084 W's left edge. In situations where the text at START shouldn't
3085 start at the left margin (i.e. when the window is hscrolled, or
3086 we're continuing a line which left off in the midst of a
3087 multi-column character), HPOS should be negative; we throw away
3088 characters up 'til hpos = 0. So, HPOS must take hscrolling into
3091 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
3093 OVSTR_DONE is the number of chars of overlay before/after strings
3094 at this position which have already been processed.
3096 Display on position VPOS on the frame. It is origin 0, relative to
3097 the top of the frame, not W.
3099 Returns a STRUCT POSITION giving character to start next line with
3100 and where to display it, including a zero or negative hpos.
3101 The vpos field is not really a vpos; it is 1 unless the line is continued */
3103 struct position val_display_text_line
;
3105 static struct position
*
3106 display_text_line (w
, start
, start_byte
, vpos
, hpos
, taboffset
, ovstr_done
)
3114 register int pos
= start
;
3115 int pos_byte
= start_byte
;
3118 int pause
, limit_byte
;
3119 register unsigned char *p
;
3121 register GLYPH
*leftmargin
;
3122 register GLYPH
*p1prev
;
3123 register GLYPH
*p1start
;
3124 int prevpos
, prevpos_byte
;
3126 FRAME_PTR f
= XFRAME (w
->frame
);
3127 int tab_width
= XINT (current_buffer
->tab_width
);
3128 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
3129 int width
= window_internal_width (w
) - 1;
3130 struct position val
;
3131 int lastpos
, lastpos_byte
;
3133 int last_invis_skip
= 0;
3134 Lisp_Object last_invis_prop
;
3135 int hscroll
= XINT (w
->hscroll
);
3136 int truncate
= (hscroll
3137 || (truncate_partial_width_windows
3138 && !WINDOW_FULL_WIDTH_P (w
))
3139 || !NILP (current_buffer
->truncate_lines
));
3141 /* 1 if this buffer has a region to highlight. */
3142 int highlight_region
3143 = (!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
)
3144 && XMARKER (current_buffer
->mark
)->buffer
!= 0);
3145 int region_beg
, region_end
;
3147 int selective
= (INTEGERP (current_buffer
->selective_display
)
3148 ? XINT (current_buffer
->selective_display
)
3149 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
3150 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3151 register struct Lisp_Char_Table
*dp
= window_display_table (w
);
3153 Lisp_Object default_invis_vector
[3];
3154 /* Number of characters of ellipsis to display after an invisible line
3155 if it calls for an ellipsis.
3156 Note that this value can be nonzero regardless of whether
3157 selective display is enabled--you must check that separately. */
3159 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3160 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
3161 : !NILP (current_buffer
->selective_display_ellipses
) ? 3 : 0);
3162 /* This is the sequence of Lisp objects to display
3163 when there are invisible lines. */
3164 Lisp_Object
*invis_vector_contents
3165 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
3166 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
3167 : default_invis_vector
);
3169 GLYPH truncator
= (dp
== 0 || !INTEGERP (DISP_TRUNC_GLYPH (dp
))
3170 || !GLYPH_CHAR_VALID_P (XINT (DISP_TRUNC_GLYPH (dp
)))
3171 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
3172 GLYPH continuer
= (dp
== 0 || !INTEGERP (DISP_CONTINUE_GLYPH (dp
))
3173 || !GLYPH_CHAR_VALID_P (XINT (DISP_CONTINUE_GLYPH (dp
)))
3174 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
3176 /* If 1, we must handle multibyte characters. */
3177 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
3178 /* Length of multibyte form of each character. */
3180 /* Glyphs generated should be set this bit mask if text must be
3181 displayed from right to left. */
3182 GLYPH rev_dir_bit
= (NILP (current_buffer
->direction_reversed
)
3183 ? 0 : GLYPH_MASK_REV_DIR
);
3185 /* The next buffer location at which the face should change, due
3186 to overlays or text property changes. */
3187 int next_face_change
;
3189 /* The next location where the `invisible' property changes, or an
3190 overlay starts or ends. */
3193 /* The face we're currently using. */
3194 int current_face
= 0;
3197 XSETFASTINT (default_invis_vector
[2], '.');
3198 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
3200 get_display_line (f
, vpos
, WINDOW_LEFT_MARGIN (w
));
3201 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3203 /* Show where to highlight the region. */
3204 if (highlight_region
3205 /* Maybe highlight only in selected window. */
3206 && (highlight_nonselected_windows
3207 || w
== XWINDOW (selected_window
)
3208 || (MINI_WINDOW_P (XWINDOW (selected_window
))
3209 && w
== XWINDOW (Vminibuf_scroll_window
))))
3211 region_beg
= marker_position (current_buffer
->mark
);
3212 if (PT
< region_beg
)
3214 region_end
= region_beg
;
3219 w
->region_showing
= Qt
;
3223 region_beg
= region_end
= -1;
3224 w
->region_showing
= Qnil
;
3227 if (MINI_WINDOW_P (w
)
3229 && vpos
== XFASTINT (w
->top
))
3231 if (! NILP (minibuf_prompt
))
3233 int old_width
= minibuf_prompt_width
;
3235 minibuf_prompt_width
3236 = (display_string (w
, vpos
, XSTRING (minibuf_prompt
)->data
,
3237 XSTRING (minibuf_prompt
)->size_byte
,
3238 hpos
+ WINDOW_LEFT_MARGIN (w
),
3239 /* Display a space if we truncate. */
3242 /* Truncate the prompt a little before the
3243 margin, so user input can at least start
3244 on the first line. */
3245 (XFASTINT (w
->width
) > 10
3246 ? XFASTINT (w
->width
) - 4 : -1),
3247 STRING_MULTIBYTE (minibuf_prompt
))
3248 - hpos
- WINDOW_LEFT_MARGIN (w
));
3249 hpos
+= minibuf_prompt_width
;
3250 taboffset
-= minibuf_prompt_width
- old_width
;
3253 minibuf_prompt_width
= 0;
3256 /* If we're hscrolled at all, use compute_motion to skip over any
3257 text off the left edge of the window. compute_motion may know
3258 tricks to do this faster than we can. */
3261 struct position
*left_edge
3262 = compute_motion (pos
, vpos
, hpos
, 0,
3264 width
, hscroll
, taboffset
, w
);
3266 /* Retrieve the buffer position and column provided by
3267 compute_motion. We can't assume that the column will be
3268 zero, because you may have multi-column characters crossing
3271 compute_motion may have moved us past the screen position we
3272 requested, if we hit a multi-column character, or the end of
3273 the line. If so, back up. */
3274 if (left_edge
->vpos
> vpos
3275 || left_edge
->hpos
> 0)
3277 pos
= left_edge
->bufpos
;
3278 /* Since this should not be a valid multibyte character, we
3279 can decrease POS by 1. */
3281 pos_byte
= left_edge
->bytepos
- 1;
3282 hpos
= left_edge
->prevhpos
;
3286 pos
= left_edge
->bufpos
;
3287 pos_byte
= left_edge
->bytepos
;
3288 hpos
= left_edge
->hpos
;
3292 hpos
+= WINDOW_LEFT_MARGIN (w
);
3294 desired_glyphs
->bufp
[vpos
] = start
;
3295 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3297 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
3298 /* In case we don't ever write anything into it... */
3299 desired_glyphs
->charstarts
[vpos
][WINDOW_LEFT_MARGIN (w
)] = -1;
3300 leftmargin
= desired_glyphs
->glyphs
[vpos
] + WINDOW_LEFT_MARGIN (w
);
3301 endp
= leftmargin
+ width
;
3303 /* Arrange the overlays nicely for our purposes. Usually, we call
3304 display_text_line on only one line at a time, in which case this
3305 can't really hurt too much, or we call it on lines which appear
3306 one after another in the buffer, in which case all calls to
3307 recenter_overlay_lists but the first will be pretty cheap. */
3308 recenter_overlay_lists (current_buffer
, pos
);
3310 /* Loop generating characters.
3311 Stop at end of buffer, before newline,
3312 if reach or pass continuation column,
3313 or at face change. */
3315 limit_byte
= pos_byte
;
3316 next_face_change
= pos
;
3317 next_boundary
= pos
;
3320 prevpos_byte
= pos_byte
;
3322 /* If the window is hscrolled and point is in the invisible part of the
3323 current line beyond the left margin we can record the cursor location
3325 if (hscroll
&& start
<= PT
&& PT
< pos
&& cursor_vpos
< 0)
3328 cursor_hpos
= p1
- leftmargin
;
3337 while (pos
== next_boundary
)
3339 Lisp_Object position
, limit
, prop
, ww
;
3341 /* Display the overlay strings here, unless we're at ZV
3342 and have already displayed the appropriate strings
3343 on an earlier line. */
3344 if (pos
< ZV
|| !zv_strings_seen
++)
3347 unsigned char *ovstr
;
3348 ovlen
= overlay_strings (pos
, w
, &ovstr
);
3352 /* Skip the ones we did in a previous line. */
3353 ovstr
+= ovstr_done
;
3354 ovlen
-= ovstr_done
;
3363 c
= STRING_CHAR_AND_LENGTH (ovstr
, ovlen
, len
);
3364 ovstr
+= len
, ovlen
-= len
, ovstr_done
+= len
;
3365 charset
= CHAR_CHARSET (c
);
3366 cols
= (charset
== CHARSET_COMPOSITION
3367 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3368 : CHARSET_WIDTH (charset
));
3372 c
= *ovstr
++, ovlen
--, ovstr_done
++;
3375 g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3378 if (p1
>= leftmargin
&& p1
< endp
)
3379 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3383 /* If we did all the overlay strings
3384 and we have room for text, clear ovstr_done
3385 just for neatness' sake. */
3386 if (ovlen
== 0 && p1
< endp
)
3391 /* Did we reach point? Record the cursor location. */
3392 if (pos
== PT
&& cursor_vpos
< 0)
3395 cursor_hpos
= p1
- leftmargin
;
3401 XSETFASTINT (position
, pos
);
3402 limit
= Fnext_overlay_change (position
);
3403 #ifdef USE_TEXT_PROPERTIES
3404 /* This is just an estimate to give reasonable
3405 performance; nothing should go wrong if it is too small. */
3406 if (XFASTINT (limit
) > pos
+ 50)
3408 int limitpos
= pos
+ 50;
3409 XSETFASTINT (limit
, limitpos
);
3411 limit
= Fnext_single_property_change (position
, Qinvisible
,
3412 Fcurrent_buffer (), limit
);
3414 next_boundary
= XFASTINT (limit
);
3415 /* if the `invisible' property is set, we can skip to
3416 the next property change. */
3418 prop
= Fget_char_property (position
, Qinvisible
, ww
);
3419 if (TEXT_PROP_MEANS_INVISIBLE (prop
))
3421 if (pos
< PT
&& next_boundary
>= PT
)
3424 cursor_hpos
= p1
- leftmargin
;
3426 pos
= next_boundary
;
3427 pos_byte
= CHAR_TO_BYTE (pos
);
3428 last_invis_skip
= pos
;
3429 last_invis_prop
= prop
;
3433 /* Did we reach point? Record the cursor location. */
3434 if (pos
== PT
&& cursor_vpos
< 0)
3437 cursor_hpos
= p1
- leftmargin
;
3440 /* Did we hit the end of the visible region of the buffer?
3444 /* Update charstarts for the end of this line. */
3445 /* Do nothing if off the left edge or at the right edge. */
3446 if (p1
>= leftmargin
&& p1
+ 1 != endp
)
3448 int *p2x
= &charstart
[(p1
< leftmargin
3456 /* Figure out where (if at all) the
3457 redisplay_end_trigger-hook should run. */
3458 if (MARKERP (w
->redisplay_end_trigger
)
3459 && XMARKER (w
->redisplay_end_trigger
)->buffer
!= 0)
3460 e_t_h
= marker_position (w
->redisplay_end_trigger
);
3461 else if (INTEGERP (w
->redisplay_end_trigger
))
3462 e_t_h
= XINT (w
->redisplay_end_trigger
);
3466 /* If we've gone past the place to run a hook,
3468 if (pos
>= e_t_h
&& e_t_h
!= ZV
)
3470 Lisp_Object args
[3];
3472 args
[0] = Qredisplay_end_trigger_functions
;
3473 XSETWINDOW (args
[1], w
);
3474 XSETINT (args
[2], e_t_h
);
3476 /* Since we are *trying* to run these functions,
3477 don't try to run them again, even if they get an error. */
3478 w
->redisplay_end_trigger
= Qnil
;
3479 Frun_hook_with_args (3, args
);
3482 /* Notice if it changed the face of this character. */
3483 next_face_change
= pos
;
3487 /* Did we hit a face change? Figure out what face we should
3488 use now. We also hit this the first time through the
3489 loop, to see what face we should start with. */
3490 if (pos
>= next_face_change
3491 && (FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
)))
3493 int limit
= pos
+ 50;
3495 current_face
= compute_char_face (f
, w
, pos
,
3496 region_beg
, region_end
,
3497 &next_face_change
, limit
, 0);
3501 /* Compute the next place we need to stop
3502 and do something special; set PAUSE. */
3506 if (pos
< next_boundary
&& next_boundary
< pause
)
3507 pause
= next_boundary
;
3508 if (pos
< next_face_change
&& next_face_change
< pause
)
3509 pause
= next_face_change
;
3514 /* Wouldn't you hate to read the next line to someone over
3516 if (pos
< PT
&& PT
< pause
)
3518 if (pos
< GPT
&& GPT
< pause
)
3521 /* LIMIT_BYTE is not the same place in the buffer as PAUSE.
3522 It is a limit on valid characters.
3523 We use it to bound STRING_CHAR_AND_LENGTH. */
3524 limit_byte
= ZV_BYTE
;
3525 if (pos
< GPT
&& GPT_BYTE
< limit_byte
)
3526 limit_byte
= GPT_BYTE
;
3529 int temp
= CHAR_TO_BYTE (pos
);
3530 p
= BYTE_POS_ADDR (temp
);
3540 c
= STRING_CHAR_AND_LENGTH (p
, limit_byte
- pos_byte
, len
), p
+= len
;
3543 /* Let a display table override all standard display methods. */
3544 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
3546 p1
= copy_part_of_rope (f
, p1
, leftmargin
,
3547 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3548 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3549 current_face
, rev_dir_bit
);
3551 else if (c
>= 040 && c
< 0177)
3553 if (p1
>= leftmargin
)
3554 *p1
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3560 /* Same as p1prev, but after the invis_vector_contents text
3561 (if we have that on this line). */
3562 GLYPH
*p1prev_modified
;
3566 if (last_invis_skip
== pos
3567 && TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (last_invis_prop
))
3571 && indented_beyond_p (pos
+ 1, pos_byte
+ 1, selective
))
3573 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3576 if (! NILP (current_buffer
->enable_multibyte_characters
))
3577 INC_BOTH (pos
, pos_byte
);
3580 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3581 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3586 SET_PT_BOTH (opoint
, opoint_byte
);
3588 if (invis
&& selective_rlen
> 0 && p1
>= leftmargin
)
3593 cs
= charstart
+ (p1
- p1start
);
3596 p1
+= selective_rlen
;
3597 if (p1
- leftmargin
> width
)
3600 #if 0 /* This needs more work; charstarts needs to record
3601 both whether a position ho;ds an ellipsis character
3602 and what buffer position it corresponds to. */
3603 csend
= charstart
+ (p1
- p1start
);
3606 /* The idea is to use p1prev_modified instead of p1prev
3607 in the loop below over p2x. */
3608 p1prev_modified
= p1
;
3611 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3612 (p1
- p1prev
), current_face
, rev_dir_bit
);
3615 /* Update charstarts for the newline that ended this line. */
3616 /* Do nothing here for a char that's entirely off the left edge
3617 or if it starts at the right edge. */
3618 if (p1
>= leftmargin
&& p1prev
!= endp
)
3620 /* Store the newline's position into charstarts
3621 for the column where the newline starts.
3622 Store -1 for the rest of the glyphs it occupies. */
3623 int *p2x
= &charstart
[(p1prev
< leftmargin
3624 ? leftmargin
: p1prev
)
3626 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3633 /* Draw the face of the newline character as extending all the
3634 way to the end of the frame line. */
3637 if (p1
< leftmargin
)
3640 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3650 if (p1
>= leftmargin
&& p1
< endp
)
3651 *p1
= MAKE_GLYPH (f
, ' ', current_face
) | rev_dir_bit
;
3654 while ((p1
- leftmargin
+ taboffset
+ hscroll
- (hscroll
> 0))
3657 else if (c
== Ctl ('M') && selective
== -1)
3659 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3660 scan_newline (pos
, pos_byte
, ZV
, ZV_BYTE
, 1, 1);
3661 pos
= PT
, pos_byte
= PT_BYTE
;
3662 SET_PT_BOTH (opoint
, opoint_byte
);
3664 if (FETCH_BYTE (pos_byte
- 1) == '\n')
3666 if (selective_rlen
> 0)
3668 p1
+= selective_rlen
;
3669 if (p1
- leftmargin
> width
)
3671 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
3672 (p1
- p1prev
), current_face
, rev_dir_bit
);
3675 /* Draw the face of the newline character as extending all the
3676 way to the end of the frame line. */
3679 if (p1
< leftmargin
)
3682 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
) | rev_dir_bit
;
3686 /* Update charstarts for the ^M that ended this line. */
3687 /* Do nothing here for a char that's entirely off the left edge
3688 or if it starts at the right edge. */
3689 if (p1
>= leftmargin
&& p1prev
!= endp
)
3691 /* Store the newline's position into charstarts
3692 for the column where the newline starts.
3693 Store -1 for the rest of the glyphs it occupies. */
3694 int *p2x
= &charstart
[(p1prev
< leftmargin
3695 ? leftmargin
: p1prev
)
3697 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3705 else if (c
< 0200 && ctl_arrow
)
3707 if (p1
>= leftmargin
)
3709 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
3710 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
3711 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3715 if (p1
>= leftmargin
&& p1
< endp
)
3716 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
) | rev_dir_bit
;
3721 /* C is not a multibyte character. */
3722 if (p1
>= leftmargin
)
3724 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
3725 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
3726 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3730 if (p1
>= leftmargin
&& p1
< endp
)
3731 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
) | rev_dir_bit
;
3733 if (p1
>= leftmargin
&& p1
< endp
)
3734 *p1
= (MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
)
3737 if (p1
>= leftmargin
&& p1
< endp
)
3738 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
) | rev_dir_bit
;
3743 /* C is a multibyte character. */
3744 int charset
= CHAR_CHARSET (c
);
3745 int columns
= (charset
== CHARSET_COMPOSITION
3746 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
3747 : CHARSET_WIDTH (charset
));
3748 GLYPH g
= MAKE_GLYPH (f
, c
, current_face
) | rev_dir_bit
;
3752 if (p1
>= leftmargin
&& p1
< endp
)
3753 *p1
= g
, g
|= GLYPH_MASK_PADDING
;
3759 prevpos_byte
= pos_byte
;
3763 /* Update charstarts for the character just output. */
3765 /* Do nothing here for a char that's entirely off the left edge. */
3766 if (p1
>= leftmargin
)
3768 /* Store the char's position into charstarts
3769 for the first glyph occupied by this char.
3770 Store -1 for the rest of the glyphs it occupies. */
3773 int *p2x
= &charstart
[(p1prev
< leftmargin
3774 ? leftmargin
: p1prev
)
3776 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
3786 val
.hpos
= - XINT (w
->hscroll
);
3793 lastpos_byte
= pos_byte
;
3795 /* Store 0 in this charstart line for the positions where
3796 there is no character. But do leave what was recorded
3797 for the character that ended the line. */
3798 /* Add 1 in the endtest to compensate for the fact that ENDP was
3799 made from WIDTH, which is 1 less than the window's actual
3801 i
= p1
- p1start
+ 1;
3802 if (p1
< leftmargin
)
3803 i
+= leftmargin
- p1
;
3804 for (; i
< endp
- p1start
+ 1; i
++)
3807 /* Handle continuation in middle of a character */
3808 /* by backing up over it */
3811 /* Don't back up if we never actually displayed any text.
3812 This occurs when the minibuffer prompt takes up the whole line. */
3815 /* Start the next line with that same character whose
3816 character code is C and the length of multi-byte form is
3819 pos_byte
= prevpos_byte
;
3822 /* C is not a multi-byte character. We can break it and
3823 start from the middle column in the next line. So,
3824 adjust VAL.HPOS to skip the columns output on this
3826 val
.hpos
+= p1prev
- endp
;
3829 /* C is a multibyte character. Since we can't broke it
3830 in the middle, the whole character should be driven
3831 into the next line. */
3832 /* As the result, the actual columns occupied by the
3833 text on this line is less than WIDTH. VAL.TAB_OFFSET
3834 must be adjusted. */
3835 taboffset
= taboffset
+ (p1prev
- endp
);
3836 /* Let's fill unused columns with TRUNCATOR or CONTINUER. */
3838 GLYPH g
= fix_glyph (f
, truncate
? truncator
: continuer
, 0);
3839 while (p1prev
< endp
)
3842 /* If POINT is at POS, cursor should not on this line. */
3844 lastpos_byte
= pos_byte
;
3850 /* Keep in this line everything up to the continuation column. */
3854 /* Finish deciding which character to start the next line on,
3855 and what hpos to start it at.
3856 Also set `lastpos' to the last position which counts as "on this line"
3857 for cursor-positioning. */
3861 if (FETCH_BYTE (pos_byte
) == '\n')
3863 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3865 /* If stopped due to a newline, start next line after it */
3866 SET_PT_BOTH (pos
+ 1, pos_byte
+ 1);
3869 /* Check again for hidden lines, in case the newline occurred exactly
3870 at the right margin. */
3871 while (PT
< ZV
&& selective
> 0
3872 && indented_beyond_p (PT
, PT_BYTE
, selective
))
3873 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3875 pos
= PT
, pos_byte
= PT_BYTE
;
3876 SET_PT_BOTH (opoint
, opoint_byte
);
3879 /* Stopped due to right margin of window */
3883 int opoint
= PT
, opoint_byte
= PT_BYTE
;
3885 SET_PT_BOTH (pos
, pos_byte
);
3886 *p1
++ = fix_glyph (f
, truncator
, 0);
3887 /* Truncating => start next line after next newline,
3888 and point is on this line if it is before the newline,
3889 and skip none of first char of next line */
3891 scan_newline (PT
, PT_BYTE
, ZV
, ZV_BYTE
, 1, 1);
3892 while (PT
< ZV
&& selective
> 0
3893 && indented_beyond_p (PT
, PT_BYTE
, selective
));
3894 pos
= PT
, pos_byte
= PT_BYTE
;
3895 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
3896 SET_PT_BOTH (opoint
, opoint_byte
);
3898 lastpos
= pos
- (FETCH_BYTE (pos_byte
- 1) == '\n');
3899 lastpos_byte
= CHAR_TO_BYTE (lastpos
);
3904 *p1
++ = fix_glyph (f
, continuer
, 0);
3907 DEC_POS (lastpos_byte
);
3908 val
.tab_offset
= taboffset
+ width
;
3915 /* If point is at eol or in invisible text at eol,
3916 record its frame location now. */
3918 if (start
<= PT
&& PT
<= lastpos
&& cursor_vpos
< 0)
3921 cursor_hpos
= p1
- leftmargin
;
3924 if (cursor_vpos
== vpos
)
3926 if (cursor_hpos
< 0) cursor_hpos
= 0;
3927 if (cursor_hpos
> width
) cursor_hpos
= width
;
3928 cursor_hpos
+= WINDOW_LEFT_MARGIN (w
);
3929 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
3931 if (!(cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f
)
3932 && EQ (FRAME_MINIBUF_WINDOW (f
), minibuf_window
)))
3934 FRAME_CURSOR_Y (f
) = cursor_vpos
;
3935 FRAME_CURSOR_X (f
) = cursor_hpos
;
3938 if (w
== XWINDOW (selected_window
))
3940 /* Line is not continued and did not start
3941 in middle of character */
3942 if ((hpos
- WINDOW_LEFT_MARGIN (w
)
3943 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
3946 this_line_bufpos
= start
;
3947 this_line_buffer
= current_buffer
;
3948 this_line_vpos
= cursor_vpos
;
3949 this_line_start_hpos
= hpos
- WINDOW_LEFT_MARGIN (w
);
3950 this_line_endpos
= Z
- lastpos
;
3953 this_line_bufpos
= 0;
3958 /* If hscroll and line not empty, insert truncation-at-left marker */
3959 if (hscroll
&& lastpos
!= start
)
3961 GLYPH g
= fix_glyph (f
, truncator
, 0);
3963 if (p1
<= leftmargin
)
3964 p1
= leftmargin
+ 1;
3965 else /* MULE: it may be a wide-column character */
3967 p1prev
= leftmargin
+ 1;
3968 while (p1prev
< p1
&& *p1prev
& GLYPH_MASK_PADDING
)
3973 if (!WINDOW_RIGHTMOST_P (w
))
3976 if (p1
< leftmargin
) p1
= leftmargin
;
3977 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
3979 /* Don't draw vertical bars if we're using scroll bars. They're
3980 covered up by the scroll bars, and it's distracting to see
3981 them when the scroll bar windows are flickering around to be
3983 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3986 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
3989 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3990 *p1
++ = (dp
&& INTEGERP (DISP_BORDER_GLYPH (dp
))
3991 ? XINT (DISP_BORDER_GLYPH (dp
))
3994 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
3995 p1
- desired_glyphs
->glyphs
[vpos
]);
3996 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
3998 /* If the start of this line is the overlay arrow-position,
3999 then put the arrow string into the display-line. */
4001 if (MARKERP (Voverlay_arrow_position
)
4002 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
4003 && start
== marker_position (Voverlay_arrow_position
)
4004 && STRINGP (Voverlay_arrow_string
)
4005 && ! overlay_arrow_seen
)
4008 int len
= XSTRING (Voverlay_arrow_string
)->size
;
4014 if (!NULL_INTERVAL_P (XSTRING (Voverlay_arrow_string
)->intervals
))
4016 /* If the arrow string has text props, obey them when displaying. */
4017 for (i
= 0, i_byte
= 0; i
< len
; )
4020 Lisp_Object face
, ilisp
;
4023 if (STRING_MULTIBYTE (Voverlay_arrow_string
))
4024 FETCH_STRING_CHAR_ADVANCE (c
, Voverlay_arrow_string
, i
, i_byte
);
4026 c
= XSTRING (Voverlay_arrow_string
)->data
[i
++];
4028 XSETFASTINT (ilisp
, i
);
4029 face
= Fget_text_property (ilisp
, Qface
, Voverlay_arrow_string
);
4030 newface
= compute_glyph_face_1 (f
, face
, 0);
4031 leftmargin
[i
] = FAST_MAKE_GLYPH (c
, newface
);
4035 #endif /* HAVE_FACES */
4037 for (i
= 0; i
< len
; i
++)
4038 leftmargin
[i
] = p
[i
];
4041 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
4042 arrow_end
= (leftmargin
- desired_glyphs
->glyphs
[vpos
]) + len
;
4043 if (desired_glyphs
->used
[vpos
] < arrow_end
)
4044 desired_glyphs
->used
[vpos
] = arrow_end
;
4046 overlay_arrow_seen
= 1;
4050 val
.bytepos
= pos_byte
;
4051 val
.ovstring_chars_done
= ovstr_done
;
4052 val_display_text_line
= val
;
4053 return &val_display_text_line
;
4056 /* Redisplay the menu bar in the frame for window W. */
4059 display_menu_bar (w
)
4062 Lisp_Object items
, tail
;
4063 register int vpos
= 0;
4064 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4065 int maxendcol
= FRAME_WIDTH (f
) + WINDOW_LEFT_MARGIN (w
);
4070 if (!NILP (Vwindow_system
))
4074 #ifdef USE_X_TOOLKIT
4077 #endif /* USE_X_TOOLKIT */
4079 get_display_line (f
, vpos
, 0);
4081 items
= FRAME_MENU_BAR_ITEMS (f
);
4082 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 4)
4084 Lisp_Object pos
, string
;
4085 string
= XVECTOR (items
)->contents
[i
+ 1];
4089 XSETFASTINT (XVECTOR (items
)->contents
[i
+ 3], hpos
);
4091 if (hpos
< maxendcol
)
4092 hpos
= display_string (w
, vpos
,
4093 XSTRING (string
)->data
,
4094 XSTRING (string
)->size_byte
,
4095 hpos
, 0, 0, hpos
, maxendcol
,
4096 STRING_MULTIBYTE (string
));
4097 /* Put a space between items. */
4098 if (hpos
< maxendcol
)
4100 int hpos1
= hpos
+ 1;
4101 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
4102 min (hpos1
, maxendcol
), maxendcol
, 0);
4106 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4107 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4109 /* Fill out the line with spaces. */
4110 if (maxendcol
> hpos
)
4111 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
, 0);
4113 /* Clear the rest of the lines allocated to the menu bar. */
4115 while (vpos
< FRAME_MENU_BAR_LINES (f
))
4116 get_display_line (f
, vpos
++, 0);
4119 /* Display the mode line for window w */
4122 display_mode_line (w
)
4125 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
4126 register int left
= WINDOW_LEFT_MARGIN (w
);
4127 register int right
= WINDOW_RIGHT_MARGIN (w
);
4128 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4130 line_number_displayed
= 0;
4131 w
->column_number_displayed
= Qnil
;
4133 get_display_line (f
, vpos
, left
);
4135 /* Temporarily make frame F's kboard the current kboard
4136 so that kboard-local variables in the mode_line_format
4137 will get the right values. */
4138 push_frame_kboard (f
);
4140 display_mode_element (w
, vpos
, left
, 0, right
, right
,
4141 current_buffer
->mode_line_format
);
4143 pop_frame_kboard ();
4145 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
4147 /* Put the mode line in inverse video.
4148 Use faces if possible, since that lets us handle
4149 partial-width windows and avoid inverting the scroll bar columns. */
4151 if (! FRAME_TERMCAP_P (f
) && mode_line_inverse_video
)
4153 /* For a partial width window, explicitly set face of each glyph. */
4155 unsigned int padding
;
4156 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
4157 for (i
= left
; i
< right
; ++i
)
4159 padding
= ptr
[i
] & GLYPH_MASK_PADDING
;
4160 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1) | padding
;
4166 /* Make the mode line inverse video if the entire line
4167 is made of mode lines.
4168 I.e. if this window is full width,
4169 or if it is the child of a full width window
4170 (which implies that that window is split side-by-side
4171 and the rest of this line is mode lines of the sibling windows). */
4172 if (WINDOW_FULL_WIDTH_P (w
)
4173 || WINDOW_FULL_WIDTH_P (XWINDOW (w
->parent
)))
4174 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
4177 /* Contribute ELT to the mode line for window W.
4178 How it translates into text depends on its data type.
4180 VPOS is the position of the mode line being displayed.
4182 HPOS is the position (absolute on frame) where this element's text
4183 should start. The output is truncated automatically at the right
4186 DEPTH is the depth in recursion. It is used to prevent
4187 infinite recursion here.
4189 MINENDCOL is the hpos before which the element may not end.
4190 The element is padded at the right with spaces if nec
4191 to reach this column.
4193 MAXENDCOL is the hpos past which this element may not extend.
4194 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
4195 (This is necessary to make nested padding and truncation work.)
4197 Returns the hpos of the end of the text generated by ELT.
4198 The next element will receive that value as its HPOS arg,
4199 so as to concatenate the elements. */
4202 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
4204 register int vpos
, hpos
;
4207 register int maxendcol
;
4208 register Lisp_Object elt
;
4216 switch (SWITCH_ENUM_CAST (XTYPE (elt
)))
4220 /* A string: output it and check for %-constructs within it. */
4221 register unsigned char c
;
4222 register unsigned char *this = XSTRING (elt
)->data
;
4224 while (hpos
< maxendcol
&& *this)
4226 unsigned char *last
= this;
4227 while ((c
= *this++) != '\0' && c
!= '%')
4229 if (this - 1 != last
)
4231 register int lim
= --this - last
+ hpos
;
4232 if (frame_title_ptr
)
4233 hpos
= store_frame_title (last
, hpos
, min (lim
, maxendcol
));
4235 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
4236 hpos
, min (lim
, maxendcol
),
4237 STRING_MULTIBYTE (elt
));
4241 register int minendcol
;
4242 register int spec_width
= 0;
4244 /* We can't allow -ve args due to the "%-" construct */
4245 /* Argument specifies minwidth but not maxwidth
4246 (maxwidth can be specified by
4247 (<negative-number> . <stuff>) mode-line elements) */
4249 while ((c
= *this++) >= '0' && c
<= '9')
4251 spec_width
= spec_width
* 10 + (c
- '0');
4254 minendcol
= hpos
+ spec_width
;
4255 if (minendcol
> maxendcol
)
4257 spec_width
= maxendcol
- hpos
;
4258 minendcol
= maxendcol
;
4262 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4263 spec_width
, maxendcol
,
4264 Vglobal_mode_string
);
4267 char *spec
= decode_mode_spec (w
, c
, spec_width
,
4269 if (frame_title_ptr
)
4270 hpos
= store_frame_title (spec
, minendcol
, maxendcol
);
4272 hpos
= display_string (w
, vpos
, spec
, -1,
4274 minendcol
, maxendcol
, -1);
4282 /* A symbol: process the value of the symbol recursively
4283 as if it appeared here directly. Avoid error if symbol void.
4284 Special case: if value of symbol is a string, output the string
4287 register Lisp_Object tem
;
4288 tem
= Fboundp (elt
);
4291 tem
= Fsymbol_value (elt
);
4292 /* If value is a string, output that string literally:
4293 don't check for % within it. */
4296 if (frame_title_ptr
)
4297 hpos
= store_frame_title (XSTRING (tem
)->data
,
4298 minendcol
, maxendcol
);
4300 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
4301 XSTRING (tem
)->size_byte
,
4302 hpos
, 0, 1, minendcol
, maxendcol
,
4303 STRING_MULTIBYTE (tem
));
4305 /* Give up right away for nil or t. */
4306 else if (!EQ (tem
, elt
))
4307 { elt
= tem
; goto tail_recurse
; }
4314 register Lisp_Object car
, tem
;
4316 /* A cons cell: three distinct cases.
4317 If first element is a string or a cons, process all the elements
4318 and effectively concatenate them.
4319 If first element is a negative number, truncate displaying cdr to
4320 at most that many characters. If positive, pad (with spaces)
4321 to at least that many characters.
4322 If first element is a symbol, process the cadr or caddr recursively
4323 according to whether the symbol's value is non-nil or nil. */
4324 car
= XCONS (elt
)->car
;
4327 tem
= Fboundp (car
);
4328 elt
= XCONS (elt
)->cdr
;
4331 /* elt is now the cdr, and we know it is a cons cell.
4332 Use its car if CAR has a non-nil value. */
4335 tem
= Fsymbol_value (car
);
4337 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
4339 /* Symbol's value is nil (or symbol is unbound)
4340 Get the cddr of the original list
4341 and if possible find the caddr and use that. */
4342 elt
= XCONS (elt
)->cdr
;
4345 else if (!CONSP (elt
))
4347 elt
= XCONS (elt
)->car
;
4350 else if (INTEGERP (car
))
4352 register int lim
= XINT (car
);
4353 elt
= XCONS (elt
)->cdr
;
4355 /* Negative int means reduce maximum width.
4356 DO NOT change MINENDCOL here!
4357 (20 -10 . foo) should truncate foo to 10 col
4358 and then pad to 20. */
4359 maxendcol
= min (maxendcol
, hpos
- lim
);
4362 /* Padding specified. Don't let it be more than
4365 if (lim
> maxendcol
)
4367 /* If that's more padding than already wanted, queue it.
4368 But don't reduce padding already specified even if
4369 that is beyond the current truncation point. */
4370 if (lim
> minendcol
)
4375 else if (STRINGP (car
) || CONSP (car
))
4377 register int limit
= 50;
4378 /* LIMIT is to protect against circular lists. */
4379 while (CONSP (elt
) && --limit
> 0
4380 && hpos
< maxendcol
)
4382 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
4385 elt
= XCONS (elt
)->cdr
;
4393 if (frame_title_ptr
)
4394 hpos
= store_frame_title ("*invalid*", minendcol
, maxendcol
);
4396 hpos
= display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
4397 minendcol
, maxendcol
, 0);
4401 if (minendcol
> hpos
)
4402 if (frame_title_ptr
)
4403 hpos
= store_frame_title ("", minendcol
, maxendcol
);
4405 hpos
= display_string (w
, vpos
, "", 0, hpos
,
4406 0, 1, minendcol
, maxendcol
, 0);
4410 /* Write a null-terminated, right justified decimal representation of
4411 the positive integer D to BUF using a minimal field width WIDTH. */
4414 pint2str (buf
, width
, d
)
4419 register char *p
= buf
;
4426 *p
++ = d
% 10 + '0';
4429 for (width
-= (int) (p
- buf
); width
> 0; --width
) *p
++ = ' ';
4439 /* Set a mnemonic character for CODING_SYSTEM (Lisp symbol) in BUF.
4440 If EOL_FLAG is 1, set also a mnemonic character for end-of-line
4441 type of CODING_SYSTEM. Return updated pointer into BUF. */
4444 decode_mode_spec_coding (coding_system
, buf
, eol_flag
)
4445 Lisp_Object coding_system
;
4450 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
4452 val
= coding_system
;
4454 if (NILP (val
)) /* Not yet decided. */
4459 *buf
++ = eol_mnemonic_undecided
;
4460 /* Don't mention EOL conversion if it isn't decided. */
4464 Lisp_Object eolvalue
;
4466 eolvalue
= Fget (coding_system
, Qeol_type
);
4468 while (!NILP (val
) && SYMBOLP (val
))
4470 val
= Fget (val
, Qcoding_system
);
4471 if (NILP (eolvalue
))
4472 eolvalue
= Fget (val
, Qeol_type
);
4476 *buf
++ = XFASTINT (XVECTOR (val
)->contents
[1]);
4480 /* The EOL conversion we are using. */
4482 /* The EOL conversion that is normal on this system. */
4484 if (NILP (eolvalue
)) /* Not yet decided. */
4485 eoltype
= eol_mnemonic_undecided
;
4486 else if (VECTORP (eolvalue
)) /* Not yet decided. */
4487 eoltype
= eol_mnemonic_undecided
;
4488 else /* INTEGERP (eolvalue) -- 0:LF, 1:CRLF, 2:CR */
4489 eoltype
= (XFASTINT (eolvalue
) == 0
4491 : (XFASTINT (eolvalue
) == 1
4492 ? eol_mnemonic_dos
: eol_mnemonic_mac
));
4494 /* Mention the EOL conversion if it is not the usual one. */
4501 /* Return a string for the output of a mode line %-spec for window W,
4502 generated by character C. SPEC_WIDTH is the field width when
4503 padding to the left (%c, %l). The value returned from this
4504 function will later be truncated to width MAXWIDTH. */
4506 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
4509 decode_mode_spec (w
, c
, spec_width
, maxwidth
)
4512 register int spec_width
;
4513 register int maxwidth
;
4516 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
4517 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
4518 struct buffer
*b
= XBUFFER (w
->buffer
);
4521 if (maxwidth
> FRAME_WIDTH (f
))
4522 maxwidth
= FRAME_WIDTH (f
);
4527 if (!NILP (b
->read_only
))
4529 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4534 /* This differs from %* only for a modified read-only buffer. */
4535 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4537 if (!NILP (b
->read_only
))
4542 /* This differs from %* in ignoring read-only-ness. */
4543 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
4555 if (command_loop_level
> 5)
4557 p
= decode_mode_spec_buf
;
4558 for (i
= 0; i
< command_loop_level
; i
++)
4561 return decode_mode_spec_buf
;
4569 if (command_loop_level
> 5)
4571 p
= decode_mode_spec_buf
;
4572 for (i
= 0; i
< command_loop_level
; i
++)
4575 return decode_mode_spec_buf
;
4583 if (maxwidth
< sizeof (lots_of_dashes
))
4584 return lots_of_dashes
;
4587 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
4591 return decode_mode_spec_buf
;
4597 if (maxwidth
>= 3 && XSTRING (obj
)->size_byte
> maxwidth
)
4599 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
4600 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
4601 decode_mode_spec_buf
[maxwidth
] = '\0';
4602 return decode_mode_spec_buf
;
4609 int col
= current_column ();
4610 XSETFASTINT (w
->column_number_displayed
, col
);
4611 pint2str (decode_mode_spec_buf
, spec_width
, col
);
4612 return decode_mode_spec_buf
;
4616 /* %F displays the frame name. */
4617 /* Systems that can only display a single frame at a time should
4618 NOT replace the frame name with the (constant) frame title,
4619 since then they won't be able to tell which frame is that. */
4620 if (FRAME_WINDOW_P (f
) && !NILP (f
->title
))
4621 return (char *) XSTRING (f
->title
)->data
;
4622 if (f
->explicit_name
|| ! FRAME_WINDOW_P (f
))
4623 return (char *) XSTRING (f
->name
)->data
;
4631 else if (STRINGP (obj
) && XSTRING (obj
)->size_byte
> maxwidth
)
4633 bcopy ("...", decode_mode_spec_buf
, 3);
4634 bcopy (XSTRING (obj
)->data
+ XSTRING (obj
)->size_byte
- maxwidth
+ 3,
4635 decode_mode_spec_buf
+ 3, maxwidth
- 3);
4636 return decode_mode_spec_buf
;
4643 int startpos
= XMARKER (w
->start
)->charpos
;
4644 int startpos_byte
= marker_byte_position (w
->start
);
4645 int line
, linepos
, linepos_byte
, topline
;
4648 int height
= XFASTINT (w
->height
);
4650 /* If we decided that this buffer isn't suitable for line numbers,
4651 don't forget that too fast. */
4652 if (EQ (w
->base_line_pos
, w
->buffer
))
4654 /* But do forget it, if the window shows a different buffer now. */
4655 else if (BUFFERP (w
->base_line_pos
))
4656 w
->base_line_pos
= Qnil
;
4658 /* If the buffer is very big, don't waste time. */
4659 if (BUF_ZV (b
) - BUF_BEGV (b
) > line_number_display_limit
)
4661 w
->base_line_pos
= Qnil
;
4662 w
->base_line_number
= Qnil
;
4666 if (!NILP (w
->base_line_number
)
4667 && !NILP (w
->base_line_pos
)
4668 && XFASTINT (w
->base_line_pos
) <= startpos
)
4670 line
= XFASTINT (w
->base_line_number
);
4671 linepos
= XFASTINT (w
->base_line_pos
);
4672 linepos_byte
= buf_charpos_to_bytepos (b
, linepos
);
4677 linepos
= BUF_BEGV (b
);
4678 linepos_byte
= BUF_BEGV_BYTE (b
);
4681 /* Count lines from base line to window start position. */
4682 nlines
= display_count_lines (linepos
, linepos_byte
,
4686 topline
= nlines
+ line
;
4688 /* Determine a new base line, if the old one is too close
4689 or too far away, or if we did not have one.
4690 "Too close" means it's plausible a scroll-down would
4692 if (startpos
== BUF_BEGV (b
))
4694 XSETFASTINT (w
->base_line_number
, topline
);
4695 XSETFASTINT (w
->base_line_pos
, BUF_BEGV (b
));
4697 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
4698 || linepos
== BUF_BEGV (b
))
4700 int limit
= BUF_BEGV (b
);
4701 int limit_byte
= BUF_BEGV_BYTE (b
);
4703 int distance
= (height
* 2 + 30) * 200;
4705 if (startpos
- distance
> limit
)
4707 limit
= startpos
- distance
;
4708 limit_byte
= CHAR_TO_BYTE (limit
);
4711 nlines
= display_count_lines (startpos
, startpos_byte
,
4713 - (height
* 2 + 30),
4715 /* If we couldn't find the lines we wanted within
4717 give up on line numbers for this window. */
4718 if (position
== limit_byte
&& limit
== startpos
- distance
)
4720 w
->base_line_pos
= w
->buffer
;
4721 w
->base_line_number
= Qnil
;
4725 XSETFASTINT (w
->base_line_number
, topline
- nlines
);
4726 XSETFASTINT (w
->base_line_pos
, BYTE_TO_CHAR (position
));
4729 /* Now count lines from the start pos to point. */
4730 nlines
= display_count_lines (startpos
, startpos_byte
,
4731 PT_BYTE
, PT
, &junk
);
4733 /* Record that we did display the line number. */
4734 line_number_displayed
= 1;
4736 /* Make the string to show. */
4737 pint2str (decode_mode_spec_buf
, spec_width
, topline
+ nlines
);
4738 return decode_mode_spec_buf
;
4741 char* p
= decode_mode_spec_buf
;
4742 for (spec_width
-= 2; spec_width
> 0; --spec_width
) *p
++ = ' ';
4744 return decode_mode_spec_buf
;
4754 if (BUF_BEGV (b
) > BUF_BEG (b
) || BUF_ZV (b
) < BUF_Z (b
))
4760 int pos
= marker_position (w
->start
);
4761 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4763 if (XFASTINT (w
->window_end_pos
) <= BUF_Z (b
) - BUF_ZV (b
))
4765 if (pos
<= BUF_BEGV (b
))
4770 else if (pos
<= BUF_BEGV (b
))
4774 if (total
> 1000000)
4775 /* Do it differently for a large value, to avoid overflow. */
4776 total
= ((pos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4778 total
= ((pos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4779 /* We can't normally display a 3-digit number,
4780 so get us a 2-digit number that is close. */
4783 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4784 return decode_mode_spec_buf
;
4788 /* Display percentage of size above the bottom of the screen. */
4791 int toppos
= marker_position (w
->start
);
4792 int botpos
= BUF_Z (b
) - XFASTINT (w
->window_end_pos
);
4793 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
4795 if (botpos
>= BUF_ZV (b
))
4797 if (toppos
<= BUF_BEGV (b
))
4804 if (total
> 1000000)
4805 /* Do it differently for a large value, to avoid overflow. */
4806 total
= ((botpos
- BUF_BEGV (b
)) + (total
/ 100) - 1) / (total
/ 100);
4808 total
= ((botpos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
4809 /* We can't normally display a 3-digit number,
4810 so get us a 2-digit number that is close. */
4813 if (toppos
<= BUF_BEGV (b
))
4814 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
4816 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
4817 return decode_mode_spec_buf
;
4822 /* status of process */
4823 obj
= Fget_buffer_process (w
->buffer
);
4825 return "no process";
4827 obj
= Fsymbol_name (Fprocess_status (obj
));
4831 case 't': /* indicate TEXT or BINARY */
4832 #ifdef MODE_LINE_BINARY_TEXT
4833 return MODE_LINE_BINARY_TEXT (b
);
4839 /* coding-system (not including end-of-line format) */
4841 /* coding-system (including end-of-line type) */
4843 int eol_flag
= (c
== 'Z');
4844 char *p
= decode_mode_spec_buf
;
4846 if (! FRAME_WINDOW_P (f
))
4848 /* No need to mention EOL here--the terminal never needs
4849 to do EOL conversion. */
4850 p
= decode_mode_spec_coding (keyboard_coding
.symbol
, p
, 0);
4851 p
= decode_mode_spec_coding (terminal_coding
.symbol
, p
, 0);
4853 p
= decode_mode_spec_coding (b
->buffer_file_coding_system
,
4856 #if 0 /* This proves to be annoying; I think we can do without. -- rms. */
4858 obj
= Fget_buffer_process (Fcurrent_buffer ());
4861 p
= decode_mode_spec_coding (XPROCESS (obj
)->decode_coding_system
,
4863 p
= decode_mode_spec_coding (XPROCESS (obj
)->encode_coding_system
,
4866 #endif /* subprocesses */
4869 return decode_mode_spec_buf
;
4874 return (char *) XSTRING (obj
)->data
;
4879 /* Count up to COUNT lines starting from START / START_BYTE.
4880 But don't go beyond LIMIT_BYTE.
4881 Return the number of lines thus found (always nonnegative).
4883 Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */
4886 display_count_lines (start
, start_byte
, limit_byte
, count
, byte_pos_ptr
)
4887 int start
, start_byte
, limit_byte
, count
;
4890 register unsigned char *cursor
;
4891 unsigned char *base
;
4893 register int ceiling
;
4894 register unsigned char *ceiling_addr
;
4895 int orig_count
= count
;
4897 /* If we are not in selective display mode,
4898 check only for newlines. */
4899 int selective_display
= (!NILP (current_buffer
->selective_display
)
4900 && !INTEGERP (current_buffer
->selective_display
));
4904 while (start_byte
< limit_byte
)
4906 ceiling
= BUFFER_CEILING_OF (start_byte
);
4907 ceiling
= min (limit_byte
- 1, ceiling
);
4908 ceiling_addr
= BYTE_POS_ADDR (ceiling
) + 1;
4909 base
= (cursor
= BYTE_POS_ADDR (start_byte
));
4912 if (selective_display
)
4913 while (*cursor
!= '\n' && *cursor
!= 015 && ++cursor
!= ceiling_addr
)
4916 while (*cursor
!= '\n' && ++cursor
!= ceiling_addr
)
4919 if (cursor
!= ceiling_addr
)
4923 start_byte
+= cursor
- base
+ 1;
4924 *byte_pos_ptr
= start_byte
;
4928 if (++cursor
== ceiling_addr
)
4934 start_byte
+= cursor
- base
;
4939 while (start_byte
> limit_byte
)
4941 ceiling
= BUFFER_FLOOR_OF (start_byte
- 1);
4942 ceiling
= max (limit_byte
, ceiling
);
4943 ceiling_addr
= BYTE_POS_ADDR (ceiling
) - 1;
4944 base
= (cursor
= BYTE_POS_ADDR (start_byte
- 1) + 1);
4947 if (selective_display
)
4948 while (--cursor
!= ceiling_addr
4949 && *cursor
!= '\n' && *cursor
!= 015)
4952 while (--cursor
!= ceiling_addr
&& *cursor
!= '\n')
4955 if (cursor
!= ceiling_addr
)
4959 start_byte
+= cursor
- base
+ 1;
4960 *byte_pos_ptr
= start_byte
;
4961 /* When scanning backwards, we should
4962 not count the newline posterior to which we stop. */
4963 return - orig_count
- 1;
4969 /* Here we add 1 to compensate for the last decrement
4970 of CURSOR, which took it past the valid range. */
4971 start_byte
+= cursor
- base
+ 1;
4975 *byte_pos_ptr
= limit_byte
;
4978 return - orig_count
+ count
;
4979 return orig_count
- count
;
4983 /* Display STRING on one line of window W, starting at HPOS.
4984 Display at position VPOS. Caller should have done get_display_line.
4985 If VPOS == -1, display it as the current frame's title.
4986 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
4988 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
4990 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
4991 MAXCOL is the last column ok to end at. Truncate here.
4992 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
4993 Both count from the left edge of the frame, as does HPOS.
4994 The right edge of W is an implicit maximum.
4995 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
4997 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
4998 at the place where the current window ends in this line
4999 and not display anything beyond there. Otherwise, only MAXCOL
5000 controls where to stop output.
5002 MULTIBYTE can be 0 meaning do not display multibyte chars,
5003 1 meaning do display them, or -1 meaning obey the current buffer's
5004 value of enable_multibyte_characters.
5006 Returns ending hpos. */
5009 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
5010 obey_window_width
, mincol
, maxcol
, multibyte
)
5012 unsigned char *string
;
5016 int obey_window_width
;
5023 int hscroll
= XINT (w
->hscroll
);
5024 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
5025 register GLYPH
*start
;
5026 register GLYPH
*end
;
5027 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
5028 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
5029 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
5030 int window_width
= XFASTINT (w
->width
);
5032 /* Use the standard display table, not the window's display table.
5033 We don't want the mode line in rot13. */
5034 register struct Lisp_Char_Table
*dp
= 0;
5037 if (multibyte
== -1)
5038 multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
5039 /* Now multibyte is 1 if we should display multibyte characters. */
5041 if (DISP_TABLE_P (Vstandard_display_table
))
5042 dp
= XCHAR_TABLE (Vstandard_display_table
);
5044 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
5047 start
= desired_glyphs
->glyphs
[vpos
];
5049 if (obey_window_width
)
5051 start
+= XFASTINT (w
->left
);
5052 end
= start
+ window_width
- (truncate
!= 0);
5054 if (!WINDOW_RIGHTMOST_P (w
))
5056 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
5060 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
5063 else if (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
5068 if (! obey_window_width
5069 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
5070 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
5072 /* Store 0 in charstart for these columns. */
5073 for (i
= (hpos
>= 0 ? hpos
: 0); i
< end
- p1start
+ hpos
; i
++)
5074 desired_glyphs
->charstarts
[vpos
][i
] = 0;
5076 if (maxcol
>= 0 && mincol
> maxcol
)
5080 /* We need this value for multibyte characters. */
5081 length
= strlen (string
);
5083 /* We set truncated to 1 if we get stopped by trying to pass END
5084 (that is, trying to pass MAXCOL.) */
5093 c
= STRING_CHAR_AND_LENGTH (string
, length
, len
);
5095 c
= *string
, len
= 1;
5097 string
+= len
, length
-= len
;
5105 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
5107 p1
= copy_part_of_rope (f
, p1
, start
,
5108 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
5109 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
5112 else if (c
>= 040 && c
< 0177)
5122 if (p1
>= start
&& p1
< end
)
5126 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
5128 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
5132 (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
5133 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (dp
)))
5134 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
5137 if (p1
>= start
&& p1
< end
)
5143 /* C is a control character or a binary byte data. */
5146 (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
5147 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp
)))
5148 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
5151 if (p1
>= start
&& p1
< end
)
5152 *p1
= (c
>> 6) + '0';
5154 if (p1
>= start
&& p1
< end
)
5155 *p1
= (7 & (c
>> 3)) + '0';
5157 if (p1
>= start
&& p1
< end
)
5158 *p1
= (7 & c
) + '0';
5163 /* C is a multibyte character. */
5164 int charset
= CHAR_CHARSET (c
);
5165 int columns
= (charset
== CHARSET_COMPOSITION
5166 ? cmpchar_table
[COMPOSITE_CHAR_ID (c
)]->width
5167 : CHARSET_WIDTH (charset
));
5171 /* Since we can't show the left part of C, fill all
5172 columns with spaces. */
5173 columns
-= start
- p1
;
5182 else if (p1
+ columns
> end
)
5184 /* Since we can't show the right part of C, fill all
5185 columns with TRUNCATE if TRUNCATE is specified. */
5189 *p1
++ = fix_glyph (f
, truncate
, 0);
5190 /* And tell the line is truncated. */
5197 /* We can show the whole glyph of C. */
5200 *p1
++ = c
| GLYPH_MASK_PADDING
;
5208 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
5210 else if (mincol
>= 0)
5212 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
5218 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
5220 if (len
> desired_glyphs
->used
[vpos
])
5221 desired_glyphs
->used
[vpos
] = len
;
5222 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
5228 /* This is like a combination of memq and assq.
5229 Return 1 if PROPVAL appears as an element of LIST
5230 or as the car of an element of LIST.
5231 If PROPVAL is a list, compare each element against LIST
5232 in that way, and return 1 if any element of PROPVAL is found in LIST.
5234 This function cannot quit. */
5237 invisible_p (propval
, list
)
5238 register Lisp_Object propval
;
5241 register Lisp_Object tail
, proptail
;
5242 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5244 register Lisp_Object tem
;
5245 tem
= XCONS (tail
)->car
;
5246 if (EQ (propval
, tem
))
5248 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5251 if (CONSP (propval
))
5252 for (proptail
= propval
; CONSP (proptail
);
5253 proptail
= XCONS (proptail
)->cdr
)
5255 Lisp_Object propelt
;
5256 propelt
= XCONS (proptail
)->car
;
5257 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5259 register Lisp_Object tem
;
5260 tem
= XCONS (tail
)->car
;
5261 if (EQ (propelt
, tem
))
5263 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5270 /* Return 1 if PROPVAL appears as the car of an element of LIST
5271 and the cdr of that element is non-nil.
5272 If PROPVAL is a list, check each element of PROPVAL in that way,
5273 and the first time some element is found,
5274 return 1 if the cdr of that element is non-nil.
5276 This function cannot quit. */
5279 invisible_ellipsis_p (propval
, list
)
5280 register Lisp_Object propval
;
5283 register Lisp_Object tail
, proptail
;
5284 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5286 register Lisp_Object tem
;
5287 tem
= XCONS (tail
)->car
;
5288 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
5289 return ! NILP (XCONS (tem
)->cdr
);
5291 if (CONSP (propval
))
5292 for (proptail
= propval
; CONSP (proptail
);
5293 proptail
= XCONS (proptail
)->cdr
)
5295 Lisp_Object propelt
;
5296 propelt
= XCONS (proptail
)->car
;
5297 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
5299 register Lisp_Object tem
;
5300 tem
= XCONS (tail
)->car
;
5301 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
5302 return ! NILP (XCONS (tem
)->cdr
);
5311 staticpro (&Qmenu_bar_update_hook
);
5312 Qmenu_bar_update_hook
= intern ("menu-bar-update-hook");
5314 staticpro (&Qoverriding_terminal_local_map
);
5315 Qoverriding_terminal_local_map
= intern ("overriding-terminal-local-map");
5317 staticpro (&Qoverriding_local_map
);
5318 Qoverriding_local_map
= intern ("overriding-local-map");
5320 staticpro (&Qwindow_scroll_functions
);
5321 Qwindow_scroll_functions
= intern ("window-scroll-functions");
5323 staticpro (&Qredisplay_end_trigger_functions
);
5324 Qredisplay_end_trigger_functions
= intern ("redisplay-end-trigger-functions");
5326 staticpro (&last_arrow_position
);
5327 staticpro (&last_arrow_string
);
5328 last_arrow_position
= Qnil
;
5329 last_arrow_string
= Qnil
;
5331 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
5332 "String (or mode line construct) included (normally) in `mode-line-format'.");
5333 Vglobal_mode_string
= Qnil
;
5335 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
5336 "Marker for where to display an arrow on top of the buffer text.\n\
5337 This must be the beginning of a line in order to work.\n\
5338 See also `overlay-arrow-string'.");
5339 Voverlay_arrow_position
= Qnil
;
5341 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
5342 "String to display as an arrow. See also `overlay-arrow-position'.");
5343 Voverlay_arrow_string
= Qnil
;
5345 DEFVAR_INT ("scroll-step", &scroll_step
,
5346 "*The number of lines to try scrolling a window by when point moves out.\n\
5347 If that fails to bring point back on frame, point is centered instead.\n\
5348 If this is zero, point is always centered after it moves off frame.");
5350 DEFVAR_INT ("scroll-conservatively", &scroll_conservatively
,
5351 "*Scroll up to this many lines, to bring point back on screen.");
5352 scroll_conservatively
= 0;
5354 DEFVAR_INT ("scroll-margin", &scroll_margin
,
5355 "*Number of lines of margin at the top and bottom of a window.\n\
5356 Recenter the window whenever point gets within this many lines\n\
5357 of the top or bottom of the window.");
5360 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
5362 DEFVAR_BOOL ("truncate-partial-width-windows",
5363 &truncate_partial_width_windows
,
5364 "*Non-nil means truncate lines in all windows less than full frame wide.");
5365 truncate_partial_width_windows
= 1;
5367 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
5368 "*Non-nil means use inverse video for the mode line.");
5369 mode_line_inverse_video
= 1;
5371 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
5372 "*Maximum buffer size for which line number should be displayed.");
5373 line_number_display_limit
= 1000000;
5375 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
5376 "*Non-nil means highlight region even in nonselected windows.");
5377 highlight_nonselected_windows
= 0;
5379 DEFVAR_BOOL ("multiple-frames", &multiple_frames
,
5380 "Non-nil if more than one frame is visible on this display.\n\
5381 Minibuffer-only frames don't count, but iconified frames do.\n\
5382 This variable is not guaranteed to be accurate except while processing\n\
5383 `frame-title-format' and `icon-title-format'.");
5385 DEFVAR_LISP ("frame-title-format", &Vframe_title_format
,
5386 "Template for displaying the titlebar of visible frames.\n\
5387 \(Assuming the window manager supports this feature.)\n\
5388 This variable has the same structure as `mode-line-format' (which see),\n\
5389 and is used only on frames for which no explicit name has been set\n\
5390 \(see `modify-frame-parameters').");
5391 DEFVAR_LISP ("icon-title-format", &Vicon_title_format
,
5392 "Template for displaying the titlebar of an iconified frame.\n\
5393 \(Assuming the window manager supports this feature.)\n\
5394 This variable has the same structure as `mode-line-format' (which see),\n\
5395 and is used only on frames for which no explicit name has been set\n\
5396 \(see `modify-frame-parameters').");
5398 = Vframe_title_format
5399 = Fcons (intern ("multiple-frames"),
5400 Fcons (build_string ("%b"),
5401 Fcons (Fcons (build_string (""),
5402 Fcons (intern ("invocation-name"),
5403 Fcons (build_string ("@"),
5404 Fcons (intern ("system-name"),
5408 DEFVAR_LISP ("message-log-max", &Vmessage_log_max
,
5409 "Maximum number of lines to keep in the message log buffer.\n\
5410 If nil, disable message logging. If t, log messages but don't truncate\n\
5411 the buffer when it becomes large.");
5412 XSETFASTINT (Vmessage_log_max
, 50);
5414 DEFVAR_LISP ("window-size-change-functions", &Vwindow_size_change_functions
,
5415 "Functions called before redisplay, if window sizes have changed.\n\
5416 The value should be a list of functions that take one argument.\n\
5417 Just before redisplay, for each frame, if any of its windows have changed\n\
5418 size since the last redisplay, or have been split or deleted,\n\
5419 all the functions in the list are called, with the frame as argument.");
5420 Vwindow_size_change_functions
= Qnil
;
5422 DEFVAR_LISP ("window-scroll-functions", &Vwindow_scroll_functions
,
5423 "List of functions to call before redisplaying a window with scrolling.\n\
5424 Each function is called with two arguments, the window\n\
5425 and its new display-start position. Note that the value of `window-end'\n\
5426 is not valid when these functions are called.");
5427 Vwindow_scroll_functions
= Qnil
;
5429 DEFVAR_INT ("minibuffer-scroll-overlap", &minibuffer_scroll_overlap
,
5430 "*Number of characters of overlap when scrolling a one-line window.\n\
5431 This commonly affects the minibuffer window, hence the name of the variable.");
5432 minibuffer_scroll_overlap
= 20;
5435 /* initialize the window system */
5438 Lisp_Object root_window
;
5439 #ifndef COMPILER_REGISTER_BUG
5441 #endif /* COMPILER_REGISTER_BUG */
5442 struct window
*mini_w
;
5444 this_line_bufpos
= 0;
5446 mini_w
= XWINDOW (minibuf_window
);
5447 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
5449 echo_area_glyphs
= 0;
5450 previous_echo_glyphs
= 0;
5452 if (!noninteractive
)
5454 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
5455 XSETFASTINT (XWINDOW (root_window
)->top
, FRAME_MENU_BAR_LINES (f
));
5456 set_window_height (root_window
,
5457 FRAME_HEIGHT (f
) - 1 - FRAME_MENU_BAR_LINES (f
),
5459 XSETFASTINT (mini_w
->top
, FRAME_HEIGHT (f
) - 1);
5460 set_window_height (minibuf_window
, 1, 0);
5462 XSETFASTINT (XWINDOW (root_window
)->width
, FRAME_WIDTH (f
));
5463 XSETFASTINT (mini_w
->width
, FRAME_WIDTH (f
));