1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /*#include <ctype.h>*/
29 #include "dispextern.h"
35 #include "termhooks.h"
36 #include "intervals.h"
40 extern void set_frame_menubar ();
43 extern int interrupt_input
;
44 extern int command_loop_level
;
46 extern Lisp_Object Qface
;
48 extern Lisp_Object Voverriding_local_map
;
49 extern Lisp_Object Voverriding_local_map_menu_flag
;
51 Lisp_Object Qoverriding_local_map
, Qoverriding_terminal_local_map
;
53 /* Nonzero means print newline to stdout before next minibuffer message. */
55 int noninteractive_need_newline
;
57 /* Nonzero means print newline to message log before next message. */
59 static int message_log_need_newline
;
61 #define min(a, b) ((a) < (b) ? (a) : (b))
62 #define max(a, b) ((a) > (b) ? (a) : (b))
63 #define minmax(floor, val, ceil) \
64 ((val) < (floor) ? (floor) : (val) > (ceil) ? (ceil) : (val))
66 /* The buffer position of the first character appearing
67 entirely or partially on the current frame line.
68 Or zero, which disables the optimization for the current frame line. */
69 static int this_line_bufpos
;
71 /* Number of characters past the end of this line,
72 including the terminating newline */
73 static int this_line_endpos
;
75 /* The vertical position of this frame line. */
76 static int this_line_vpos
;
78 /* Hpos value for start of display on this frame line.
79 Usually zero, but negative if first character really began
81 static int this_line_start_hpos
;
83 /* Buffer that this_line variables are describing. */
84 static struct buffer
*this_line_buffer
;
86 /* Value of echo_area_glyphs when it was last acted on.
87 If this is nonzero, there is a message on the frame
88 in the minibuffer and it should be erased as soon
89 as it is no longer requested to appear. */
90 char *previous_echo_glyphs
;
92 /* Nonzero means truncate lines in all windows less wide than the frame */
93 int truncate_partial_width_windows
;
95 /* Nonzero means we have more than one non-minibuffer-only frame.
96 Not guaranteed to be accurate except while parsing frame-title-format. */
99 Lisp_Object Vglobal_mode_string
;
101 /* Marker for where to display an arrow on top of the buffer text. */
102 Lisp_Object Voverlay_arrow_position
;
104 /* String to display for the arrow. */
105 Lisp_Object Voverlay_arrow_string
;
107 /* Like mode-line-format, but for the titlebar on a visible frame. */
108 Lisp_Object Vframe_title_format
;
110 /* Like mode-line-format, but for the titlebar on an iconified frame. */
111 Lisp_Object Vicon_title_format
;
113 /* List of functions to call when a window's size changes. These
114 functions get one arg, a frame on which one or more windows' sizes
116 static Lisp_Object Vwindow_size_change_functions
;
118 /* Values of those variables at last redisplay. */
119 static Lisp_Object last_arrow_position
, last_arrow_string
;
121 Lisp_Object Qmenu_bar_update_hook
;
123 /* Nonzero if overlay arrow has been displayed once in this window. */
124 static int overlay_arrow_seen
;
126 /* Nonzero if visible end of buffer has already been displayed once
127 in this window. (We need this variable in case there are overlay
128 strings that get displayed there.) */
129 static int zv_strings_seen
;
131 /* Nonzero means highlight the region even in nonselected windows. */
132 static int highlight_nonselected_windows
;
134 /* If cursor motion alone moves point off frame,
135 Try scrolling this many lines up or down if that will bring it back. */
136 static int scroll_step
;
138 /* Nonzero if try_window_id has made blank lines at window bottom
139 since the last redisplay that paused */
140 static int blank_end_of_window
;
142 /* Number of windows showing the buffer of the selected window
143 (or another buffer with the same base buffer).
144 keyboard.c refers to this. */
147 /* display_text_line sets these to the frame position (origin 0) of point,
148 whether the window is selected or not.
149 Set one to -1 first to determine whether point was found afterwards. */
151 static int cursor_vpos
;
152 static int cursor_hpos
;
154 static int debug_end_pos
;
156 /* Nonzero means display mode line highlighted */
157 int mode_line_inverse_video
;
159 static int message_log_check_duplicate ();
160 static void echo_area_display ();
161 void mark_window_display_accurate ();
162 static void redisplay_windows ();
163 static void redisplay_window ();
164 static void update_menu_bar ();
165 static void try_window ();
166 static int try_window_id ();
167 static struct position
*display_text_line ();
168 static void display_mode_line ();
169 static int display_mode_element ();
170 static char *decode_mode_spec ();
171 static int display_string ();
172 static void display_menu_bar ();
173 static int display_count_lines ();
175 /* Prompt to display in front of the minibuffer contents */
176 Lisp_Object minibuf_prompt
;
178 /* Width in columns of current minibuffer prompt. */
179 int minibuf_prompt_width
;
181 /* Message to display instead of minibuffer contents
182 This is what the functions error and message make,
183 and command echoing uses it as well.
184 It overrides the minibuf_prompt as well as the buffer. */
185 char *echo_area_glyphs
;
187 /* This is the length of the message in echo_area_glyphs. */
188 int echo_area_glyphs_length
;
190 /* true iff we should redraw the mode lines on the next redisplay */
191 int update_mode_lines
;
193 /* Smallest number of characters before the gap
194 at any time since last redisplay that finished.
195 Valid for current buffer when try_window_id can be called. */
198 /* Smallest number of characters after the gap
199 at any time since last redisplay that finished.
200 Valid for current buffer when try_window_id can be called. */
203 /* MODIFF as of last redisplay that finished;
204 if it matches MODIFF, beg_unchanged and end_unchanged
205 contain no useful information */
206 int unchanged_modified
;
208 /* Nonzero if window sizes or contents have changed
209 since last redisplay that finished */
210 int windows_or_buffers_changed
;
212 /* Nonzero after display_mode_line if %l was used
213 and it displayed a line number. */
214 int line_number_displayed
;
216 /* Maximum buffer size for which to display line numbers. */
217 static int line_number_display_limit
;
219 /* Number of lines to keep in the message log buffer.
220 t means infinite. nil means don't log at all. */
221 Lisp_Object Vmessage_log_max
;
224 message_log_maybe_newline ()
226 if (message_log_need_newline
)
227 message_dolog ("", 0, 1);
231 /* Add a string to the message log, optionally terminated with a newline.
232 This function calls low-level routines in order to bypass text property
233 hooks, etc. which might not be safe to run. */
236 message_dolog (m
, len
, nlflag
)
240 if (!NILP (Vmessage_log_max
))
242 struct buffer
*oldbuf
;
243 int oldpoint
, oldbegv
, oldzv
;
245 oldbuf
= current_buffer
;
246 Fset_buffer (Fget_buffer_create (build_string ("*Messages*")));
247 current_buffer
->undo_list
= Qt
;
254 oldpoint
+= len
+ nlflag
;
256 oldzv
+= len
+ nlflag
;
259 insert_1 (m
, len
, 1, 0);
262 int this_bol
, prev_bol
, dup
;
263 insert_1 ("\n", 1, 1, 0);
265 this_bol
= scan_buffer ('\n', Z
, 0, -2, 0, 0);
268 prev_bol
= scan_buffer ('\n', this_bol
, 0, -2, 0, 0);
269 dup
= message_log_check_duplicate (prev_bol
, this_bol
);
272 if (oldpoint
> prev_bol
)
273 oldpoint
-= min (this_bol
, oldpoint
) - prev_bol
;
274 if (oldbegv
> prev_bol
)
275 oldbegv
-= min (this_bol
, oldbegv
) - prev_bol
;
276 if (oldzv
> prev_bol
)
277 oldzv
-= min (this_bol
, oldzv
) - prev_bol
;
278 del_range_1 (prev_bol
, this_bol
, 0);
284 /* If you change this format, don't forget to also
285 change message_log_check_duplicate. */
286 sprintf (dupstr
, " [%d times]", dup
);
287 duplen
= strlen (dupstr
);
293 insert_1 (dupstr
, duplen
, 1, 0);
298 if (NATNUMP (Vmessage_log_max
))
300 int pos
= scan_buffer ('\n', Z
, 0,
301 -XFASTINT (Vmessage_log_max
) - 1, 0, 0);
302 oldpoint
-= min (pos
, oldpoint
) - BEG
;
303 oldbegv
-= min (pos
, oldbegv
) - BEG
;
304 oldzv
-= min (pos
, oldzv
) - BEG
;
305 del_range_1 (BEG
, pos
, 0);
310 TEMP_SET_PT (oldpoint
);
311 set_buffer_internal (oldbuf
);
312 message_log_need_newline
= !nlflag
;
317 /* We are at the end of the buffer after just having inserted a newline.
318 (Note: We depend on the fact we won't be crossing the gap.)
319 Check to see if the most recent message looks a lot like the previous one.
320 Return 0 if different, 1 if the new one should just replace it, or a
321 value N > 1 if we should also append " [N times]". */
324 message_log_check_duplicate (prev_bol
, this_bol
)
325 int prev_bol
, this_bol
;
328 int len
= Z
- 1 - this_bol
;
330 unsigned char *p1
= BUF_CHAR_ADDRESS (current_buffer
, prev_bol
);
331 unsigned char *p2
= BUF_CHAR_ADDRESS (current_buffer
, this_bol
);
333 for (i
= 0; i
< len
; i
++)
335 if (i
>= 3 && p1
[i
-3] == '.' && p1
[i
-2] == '.' && p1
[i
-1] == '.'
344 if (*p1
++ == ' ' && *p1
++ == '[')
347 while (*p1
>= '0' && *p1
<= '9')
348 n
= n
* 10 + *p1
++ - '0';
349 if (strncmp (p1
, " times]\n", 8) == 0)
355 /* Display an echo area message M with a specified length of LEN chars.
356 The string may include null characters. If m is 0, clear out any
357 existing message, and let the minibuffer text show through.
358 Do not pass text that is stored in a Lisp string. */
365 /* First flush out any partial line written with print. */
366 message_log_maybe_newline ();
368 message_dolog (m
, len
, 1);
369 message2_nolog (m
, len
);
373 /* The non-logging part of that function. */
376 message2_nolog (m
, len
)
382 if (noninteractive_need_newline
)
384 noninteractive_need_newline
= 0;
385 fwrite (m
, len
, 1, stderr
);
386 if (cursor_in_echo_area
== 0)
387 fprintf (stderr
, "\n");
390 /* A null message buffer means that the frame hasn't really been
391 initialized yet. Error messages get reported properly by
392 cmd_error, so this must be just an informative message; toss it. */
393 else if (INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
396 Lisp_Object minibuf_frame
;
398 choose_minibuf_frame ();
399 minibuf_frame
= WINDOW_FRAME (XWINDOW (minibuf_window
));
400 FRAME_SAMPLE_VISIBILITY (XFRAME (minibuf_frame
));
401 if (FRAME_VISIBLE_P (selected_frame
)
402 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame
)))
403 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window
)));
408 echo_area_glyphs
= m
;
409 echo_area_glyphs_length
= len
;
412 echo_area_glyphs
= previous_echo_glyphs
= 0;
414 do_pending_window_change ();
415 echo_area_display ();
416 update_frame (XFRAME (XWINDOW (minibuf_window
)->frame
), 1, 1);
417 do_pending_window_change ();
418 if (frame_up_to_date_hook
!= 0 && ! gc_in_progress
)
419 (*frame_up_to_date_hook
) (XFRAME (XWINDOW (minibuf_window
)->frame
));
427 message2 (m
, (m
? strlen (m
) : 0));
434 message2_nolog (m
, (m
? strlen (m
) : 0));
437 /* Truncate what will be displayed in the echo area
438 the next time we display it--but don't redisplay it now. */
441 truncate_echo_area (len
)
444 /* A null message buffer means that the frame hasn't really been
445 initialized yet. Error messages get reported properly by
446 cmd_error, so this must be just an informative message; toss it. */
447 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
448 echo_area_glyphs_length
= len
;
451 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
452 zero if being used by message. */
453 int message_buf_print
;
455 /* Dump an informative message to the minibuf. If m is 0, clear out
456 any existing message, and let the minibuffer text show through. */
459 message (m
, a1
, a2
, a3
)
461 EMACS_INT a1
, a2
, a3
;
467 if (noninteractive_need_newline
)
469 noninteractive_need_newline
= 0;
470 fprintf (stderr
, m
, a1
, a2
, a3
);
471 if (cursor_in_echo_area
== 0)
472 fprintf (stderr
, "\n");
476 else if (INTERACTIVE
)
478 /* The frame whose minibuffer we're going to display the message on.
479 It may be larger than the selected frame, so we need
480 to use its buffer, not the selected frame's buffer. */
481 FRAME_PTR echo_frame
;
483 choose_minibuf_frame ();
484 echo_frame
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
486 echo_frame
= selected_frame
;
489 /* A null message buffer means that the frame hasn't really been
490 initialized yet. Error messages get reported properly by
491 cmd_error, so this must be just an informative message; toss it. */
492 if (FRAME_MESSAGE_BUF (echo_frame
))
503 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
504 FRAME_WIDTH (echo_frame
), m
, (char *)0, 3, a
);
506 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
507 FRAME_WIDTH (echo_frame
), m
, (char *)0, 3, &a1
);
508 #endif /* NO_ARG_ARRAY */
510 message2 (FRAME_MESSAGE_BUF (echo_frame
), len
);
515 /* Print should start at the beginning of the message
517 message_buf_print
= 0;
522 /* The non-logging version of that function. */
524 message_nolog (m
, a1
, a2
, a3
)
526 EMACS_INT a1
, a2
, a3
;
528 Lisp_Object old_log_max
;
529 old_log_max
= Vmessage_log_max
;
530 Vmessage_log_max
= Qnil
;
531 message (m
, a1
, a2
, a3
);
532 Vmessage_log_max
= old_log_max
;
538 message2 (echo_area_glyphs
, echo_area_glyphs_length
);
548 choose_minibuf_frame ();
551 f
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
553 if (! FRAME_VISIBLE_P (f
))
558 redraw_garbaged_frames ();
562 if (echo_area_glyphs
|| minibuf_level
== 0)
564 vpos
= XFASTINT (XWINDOW (minibuf_window
)->top
);
565 get_display_line (f
, vpos
, 0);
566 display_string (XWINDOW (minibuf_window
), vpos
,
567 echo_area_glyphs
? echo_area_glyphs
: "",
568 echo_area_glyphs
? echo_area_glyphs_length
: -1,
569 0, 0, 0, 0, FRAME_WIDTH (f
));
571 #if 0 /* This just gets in the way. update_frame does the job. */
572 /* If desired cursor location is on this line, put it at end of text */
573 if (cursor_in_echo_area
)
574 FRAME_CURSOR_Y (f
) = vpos
;
575 if (FRAME_CURSOR_Y (f
) == vpos
)
576 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
579 /* Fill the rest of the minibuffer window with blank lines. */
584 i
< vpos
+ XFASTINT (XWINDOW (minibuf_window
)->height
); i
++)
586 get_display_line (f
, i
, 0);
587 display_string (XWINDOW (minibuf_window
), vpos
,
588 "", 0, 0, 0, 0, 0, FRAME_WIDTH (f
));
592 else if (!EQ (minibuf_window
, selected_window
))
593 windows_or_buffers_changed
++;
595 if (EQ (minibuf_window
, selected_window
))
596 this_line_bufpos
= 0;
598 previous_echo_glyphs
= echo_area_glyphs
;
601 #ifdef HAVE_X_WINDOWS
602 static char frame_title_buf
[512];
603 static char *frame_title_ptr
;
606 store_frame_title (str
, mincol
, maxcol
)
611 if (maxcol
< 0 || maxcol
>= sizeof(frame_title_buf
))
612 maxcol
= sizeof (frame_title_buf
);
613 limit
= &frame_title_buf
[maxcol
];
614 while (*str
!= '\0' && frame_title_ptr
< limit
)
615 *frame_title_ptr
++ = *str
++;
616 while (frame_title_ptr
< &frame_title_buf
[mincol
])
617 *frame_title_ptr
++ = ' ';
618 return frame_title_ptr
- frame_title_buf
;
622 x_consider_frame_title (frame
)
628 FRAME_PTR f
= XFRAME (frame
);
630 if (!FRAME_X_P (f
) || FRAME_MINIBUF_ONLY_P (f
) || f
->explicit_name
)
633 /* Do we have more than one visible frame on this X display? */
637 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
639 FRAME_PTR tf
= XFRAME (XCONS (tail
)->car
);
641 if (tf
!= f
&& FRAME_KBOARD (tf
) == FRAME_KBOARD (f
)
642 && !FRAME_MINIBUF_ONLY_P (tf
)
643 && (FRAME_VISIBLE_P (tf
) || FRAME_ICONIFIED_P (tf
)))
647 multiple_frames
= CONSP (tail
);
650 obuf
= current_buffer
;
651 Fset_buffer (XWINDOW (f
->selected_window
)->buffer
);
652 fmt
= (FRAME_ICONIFIED_P (f
) ? Vicon_title_format
: Vframe_title_format
);
653 frame_title_ptr
= frame_title_buf
;
654 len
= display_mode_element (XWINDOW (f
->selected_window
), 0, 0, 0,
655 0, sizeof (frame_title_buf
), fmt
);
657 set_buffer_internal (obuf
);
658 /* Set the name only if it's changed. This avoids consing
659 in the common case where it hasn't. (If it turns out that we've
660 already wasted too much time by walking through the list with
661 display_mode_element, then we might need to optimize at a higher
663 if (! STRINGP (f
->name
) || XSTRING (f
->name
)->size
!= len
664 || bcmp (frame_title_buf
, XSTRING (f
->name
)->data
, len
) != 0)
665 x_implicitly_set_name (f
, make_string (frame_title_buf
, len
), Qnil
);
668 #define frame_title_ptr ((char *)0)
669 #define store_frame_title(str, mincol, maxcol) 0
672 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
673 This can call eval. */
678 register struct window
*w
= XWINDOW (selected_window
);
680 struct gcpro gcpro1
, gcpro2
;
682 all_windows
= (update_mode_lines
|| buffer_shared
> 1
683 || windows_or_buffers_changed
);
685 /* Update all frame titles based on their buffer names, etc.
686 We do this before the menu bars so that the buffer-menu
687 will show the up-to-date frame titles.
689 This used to be done after the menu bars, for a reason that
690 was stated as follows but which I do not understand:
691 "We do this after the menu bars so that the frame will first
692 create its menu bar using the name `emacs' if no other name
693 has yet been specified."
694 I think that is no longer a concern. */
695 #ifdef HAVE_X_WINDOWS
696 if (windows_or_buffers_changed
)
698 Lisp_Object tail
, frame
;
700 FOR_EACH_FRAME (tail
, frame
)
701 if (FRAME_VISIBLE_P (XFRAME (frame
))
702 || FRAME_ICONIFIED_P (XFRAME (frame
)))
703 x_consider_frame_title (frame
);
707 /* Update the menu bar item lists, if appropriate.
708 This has to be done before any actual redisplay
709 or generation of display lines. */
712 Lisp_Object tail
, frame
;
713 int count
= specpdl_ptr
- specpdl
;
715 record_unwind_protect (Fstore_match_data
, Fmatch_data ());
717 FOR_EACH_FRAME (tail
, frame
)
719 /* If a window on this frame changed size,
720 report that to the user and clear the size-change flag. */
721 if (FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)))
723 Lisp_Object functions
;
724 /* Clear flag first in case we get error below. */
725 FRAME_WINDOW_SIZES_CHANGED (XFRAME (frame
)) = 0;
726 functions
= Vwindow_size_change_functions
;
727 GCPRO2 (tail
, functions
);
728 while (CONSP (functions
))
730 call1 (XCONS (functions
)->car
, frame
);
731 functions
= XCONS (functions
)->cdr
;
736 update_menu_bar (XFRAME (frame
), 0);
740 unbind_to (count
, Qnil
);
743 update_menu_bar (selected_frame
, 1);
746 /* Do a frame update, taking possible shortcuts into account.
747 This is the main external entry point for redisplay.
749 If the last redisplay displayed an echo area message and that
750 message is no longer requested, we clear the echo area
751 or bring back the minibuffer if that is in use.
753 Do not call eval from within this function.
754 Calls to eval after the call to echo_area_display would confuse
755 the display_line mechanism and would cause a crash.
756 Calls to eval before that point will work most of the time,
757 but can still lose, because this function
758 can be called from signal handlers; with alarms set up;
759 or with synchronous processes running.
761 See Fcall_process; if you called it from here, it could be
762 entered recursively. */
764 static int do_verify_charstarts
;
766 /* Counter is used to clear the face cache
767 no more than once ever 1000 redisplays. */
768 static int clear_face_cache_count
;
773 register struct window
*w
= XWINDOW (selected_window
);
777 register int tlbufpos
, tlendpos
;
783 /* Set the visible flags for all frames.
784 Do this before checking for resized or garbaged frames; they want
785 to know if their frames are visible.
786 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
788 Lisp_Object tail
, frame
;
790 FOR_EACH_FRAME (tail
, frame
)
792 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
794 /* Clear out all the display lines in which we will generate the
795 glyphs to display. */
796 init_desired_glyphs (XFRAME (frame
));
800 /* Notice any pending interrupt request to change frame size. */
801 do_pending_window_change ();
805 redraw_garbaged_frames ();
809 prepare_menu_bars ();
811 if (windows_or_buffers_changed
)
814 /* Detect case that we need to write a star in the mode line. */
815 if (XFASTINT (w
->last_modified
) < MODIFF
816 && XFASTINT (w
->last_modified
) <= SAVE_MODIFF
)
818 w
->update_mode_line
= Qt
;
819 if (buffer_shared
> 1)
823 /* If %c is in use, update it if needed. */
824 if (!NILP (w
->column_number_displayed
)
825 /* This alternative quickly identifies a common case
826 where no change is needed. */
827 && !(PT
== XFASTINT (w
->last_point
)
828 && XFASTINT (w
->last_modified
) >= MODIFF
)
829 && XFASTINT (w
->column_number_displayed
) != current_column ())
830 w
->update_mode_line
= Qt
;
832 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
834 all_windows
= update_mode_lines
|| buffer_shared
> 1;
836 /* If specs for an arrow have changed, do thorough redisplay
837 to ensure we remove any arrow that should no longer exist. */
838 if (! EQ (Voverlay_arrow_position
, last_arrow_position
)
839 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
842 /* Normally the message* functions will have already displayed and
843 updated the echo area, but the frame may have been trashed, or
844 the update may have been preempted, so display the echo area
846 if (echo_area_glyphs
|| previous_echo_glyphs
)
848 echo_area_display ();
852 /* If showing region, and mark has changed, must redisplay whole window. */
853 if (((!NILP (Vtransient_mark_mode
)
854 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
855 != !NILP (w
->region_showing
))
856 || (!NILP (w
->region_showing
)
857 && !EQ (w
->region_showing
,
858 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
859 this_line_bufpos
= -1;
861 tlbufpos
= this_line_bufpos
;
862 tlendpos
= this_line_endpos
;
863 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
864 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
865 /* Make sure recorded data applies to current buffer, etc */
866 && this_line_buffer
== current_buffer
867 && current_buffer
== XBUFFER (w
->buffer
)
868 && NILP (w
->force_start
)
869 /* Point must be on the line that we have info recorded about */
871 && PT
<= Z
- tlendpos
872 /* All text outside that line, including its final newline,
874 && (XFASTINT (w
->last_modified
) >= MODIFF
875 || (beg_unchanged
>= tlbufpos
- 1
877 /* If selective display, can't optimize
878 if the changes start at the beginning of the line. */
879 && ((INTEGERP (current_buffer
->selective_display
)
880 && XINT (current_buffer
->selective_display
) > 0
881 ? (beg_unchanged
>= tlbufpos
884 && end_unchanged
>= tlendpos
885 && Z
- GPT
>= tlendpos
)))
887 if (tlbufpos
> BEGV
&& FETCH_CHAR (tlbufpos
- 1) != '\n'
889 || FETCH_CHAR (tlbufpos
) == '\n'))
890 /* Former continuation line has disappeared by becoming empty */
892 else if (XFASTINT (w
->last_modified
) < MODIFF
893 || MINI_WINDOW_P (w
))
896 overlay_arrow_seen
= 0;
898 display_text_line (w
, tlbufpos
, this_line_vpos
, this_line_start_hpos
,
899 pos_tab_offset (w
, tlbufpos
));
900 /* If line contains point, is not continued,
901 and ends at same distance from eob as before, we win */
902 if (cursor_vpos
>= 0 && this_line_bufpos
903 && this_line_endpos
== tlendpos
)
905 /* If this is not the window's last line,
906 we must adjust the charstarts of the lines below. */
907 if (this_line_vpos
+ 1
908 < XFASTINT (w
->top
) + window_internal_height (w
))
910 int left
= XFASTINT (w
->left
);
911 int *charstart_next_line
912 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
915 if (Z
- tlendpos
== ZV
)
916 /* This line ends at end of (accessible part of) buffer.
917 There is no newline to count. */
918 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
920 /* This line ends in a newline.
921 Must take account of the newline and the rest of the
922 text that follows. */
923 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
925 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
928 if (XFASTINT (w
->width
) != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w
))))
929 preserve_other_columns (w
);
935 else if (PT
== XFASTINT (w
->last_point
)
936 /* Make sure the cursor was last displayed
937 in this window. Otherwise we have to reposition it. */
938 && XINT (w
->top
) <= FRAME_CURSOR_Y (selected_frame
)
939 && (XINT (w
->top
) + XINT (w
->height
)
940 > FRAME_CURSOR_Y (selected_frame
)))
944 do_pending_window_change ();
949 /* If highlighting the region, or if the cursor is in the echo area,
950 then we can't just move the cursor. */
951 else if (! (!NILP (Vtransient_mark_mode
)
952 && !NILP (current_buffer
->mark_active
))
953 && NILP (w
->region_showing
)
954 && !cursor_in_echo_area
)
956 pos
= *compute_motion (tlbufpos
, 0,
957 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
959 PT
, 2, - (1 << (SHORTBITS
- 1)),
960 window_internal_width (w
) - 1,
962 pos_tab_offset (w
, tlbufpos
), w
);
965 int width
= window_internal_width (w
) - 1;
966 FRAME_CURSOR_X (selected_frame
)
967 = XFASTINT (w
->left
) + minmax (0, pos
.hpos
, width
);
968 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
975 /* Text changed drastically or point moved off of line */
976 cancel_line (this_line_vpos
, selected_frame
);
979 this_line_bufpos
= 0;
980 all_windows
|= buffer_shared
> 1;
982 clear_face_cache_count
++;
986 Lisp_Object tail
, frame
;
989 /* Clear the face cache, only when we do a full redisplay
990 and not too often either. */
991 if (clear_face_cache_count
> 1000)
994 clear_face_cache_count
= 0;
998 /* Recompute # windows showing selected buffer.
999 This will be incremented each time such a window is displayed. */
1002 FOR_EACH_FRAME (tail
, frame
)
1004 FRAME_PTR f
= XFRAME (frame
);
1005 if (! FRAME_TERMCAP_P (f
) || f
== selected_frame
)
1008 /* Mark all the scroll bars to be removed; we'll redeem the ones
1009 we want when we redisplay their windows. */
1010 if (condemn_scroll_bars_hook
)
1011 (*condemn_scroll_bars_hook
) (f
);
1013 if (FRAME_VISIBLE_P (f
))
1014 redisplay_windows (FRAME_ROOT_WINDOW (f
));
1016 /* Any scroll bars which redisplay_windows should have nuked
1017 should now go away. */
1018 if (judge_scroll_bars_hook
)
1019 (*judge_scroll_bars_hook
) (f
);
1023 else if (FRAME_VISIBLE_P (selected_frame
))
1025 redisplay_window (selected_window
, 1);
1026 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
1027 preserve_other_columns (w
);
1031 /* Prevent various kinds of signals during display update.
1032 stdio is not robust about handling signals,
1033 which can cause an apparent I/O error. */
1034 if (interrupt_input
)
1045 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1049 if (!FRAMEP (XCONS (tail
)->car
))
1052 f
= XFRAME (XCONS (tail
)->car
);
1054 if ((! FRAME_TERMCAP_P (f
) || f
== selected_frame
)
1055 && FRAME_VISIBLE_P (f
))
1057 pause
|= update_frame (f
, 0, 0);
1060 mark_window_display_accurate (f
->root_window
, 1);
1061 if (frame_up_to_date_hook
!= 0)
1062 (*frame_up_to_date_hook
) (f
);
1068 #endif /* MULTI_FRAME */
1070 if (FRAME_VISIBLE_P (selected_frame
))
1071 pause
= update_frame (selected_frame
, 0, 0);
1075 /* We may have called echo_area_display at the top of this
1076 function. If the echo area is on another frame, that may
1077 have put text on a frame other than the selected one, so the
1078 above call to update_frame would not have caught it. Catch
1081 FRAME_PTR mini_frame
1082 = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
1084 if (mini_frame
!= selected_frame
)
1085 pause
|= update_frame (mini_frame
, 0, 0);
1089 /* If frame does not match, prevent doing single-line-update next time.
1090 Also, don't forget to check every line to update the arrow. */
1093 this_line_bufpos
= 0;
1094 if (!NILP (last_arrow_position
))
1096 last_arrow_position
= Qt
;
1097 last_arrow_string
= Qt
;
1099 /* If we pause after scrolling, some lines in current_frame
1100 may be null, so preserve_other_columns won't be able to
1101 preserve all the vertical-bar separators. So, avoid using it
1103 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
1104 update_mode_lines
= 1;
1107 /* Now text on frame agrees with windows, so
1108 put info into the windows for partial redisplay to follow */
1112 register struct buffer
*b
= XBUFFER (w
->buffer
);
1114 blank_end_of_window
= 0;
1115 unchanged_modified
= BUF_MODIFF (b
);
1116 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
1117 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
1119 XSETFASTINT (w
->last_point
, BUF_PT (b
));
1120 XSETFASTINT (w
->last_point_x
, FRAME_CURSOR_X (selected_frame
));
1121 XSETFASTINT (w
->last_point_y
, FRAME_CURSOR_Y (selected_frame
));
1124 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
1127 b
->clip_changed
= 0;
1128 w
->update_mode_line
= Qnil
;
1129 XSETFASTINT (w
->last_modified
, BUF_MODIFF (b
));
1130 w
->window_end_valid
= w
->buffer
;
1131 last_arrow_position
= Voverlay_arrow_position
;
1132 last_arrow_string
= Voverlay_arrow_string
;
1133 if (do_verify_charstarts
)
1134 verify_charstarts (w
);
1135 if (frame_up_to_date_hook
!= 0)
1136 (*frame_up_to_date_hook
) (selected_frame
);
1138 update_mode_lines
= 0;
1139 windows_or_buffers_changed
= 0;
1142 /* Start SIGIO interrupts coming again.
1143 Having them off during the code above
1144 makes it less likely one will discard output,
1145 but not impossible, since there might be stuff
1146 in the system buffer here.
1147 But it is much hairier to try to do anything about that. */
1149 if (interrupt_input
)
1153 /* Change frame size now if a change is pending. */
1154 do_pending_window_change ();
1156 /* If we just did a pending size change, redisplay again
1157 for the new size. */
1158 if (windows_or_buffers_changed
&& !pause
)
1162 /* Redisplay, but leave alone any recent echo area message
1163 unless another message has been requested in its place.
1165 This is useful in situations where you need to redisplay but no
1166 user action has occurred, making it inappropriate for the message
1167 area to be cleared. See tracking_off and
1168 wait_reading_process_input for examples of these situations. */
1170 redisplay_preserve_echo_area ()
1172 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
1174 echo_area_glyphs
= previous_echo_glyphs
;
1176 echo_area_glyphs
= 0;
1183 mark_window_display_accurate (window
, flag
)
1187 register struct window
*w
;
1189 for (;!NILP (window
); window
= w
->next
)
1191 if (!WINDOWP (window
)) abort ();
1192 w
= XWINDOW (window
);
1194 if (!NILP (w
->buffer
))
1196 XSETFASTINT (w
->last_modified
,
1197 !flag
? 0 : BUF_MODIFF (XBUFFER (w
->buffer
)));
1199 /* Record if we are showing a region, so can make sure to
1200 update it fully at next redisplay. */
1201 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
1202 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
1203 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
1207 w
->window_end_valid
= w
->buffer
;
1208 w
->update_mode_line
= Qnil
;
1209 if (!NILP (w
->buffer
))
1210 XBUFFER (w
->buffer
)->clip_changed
= 0;
1212 if (!NILP (w
->vchild
))
1213 mark_window_display_accurate (w
->vchild
, flag
);
1214 if (!NILP (w
->hchild
))
1215 mark_window_display_accurate (w
->hchild
, flag
);
1220 last_arrow_position
= Voverlay_arrow_position
;
1221 last_arrow_string
= Voverlay_arrow_string
;
1225 /* t is unequal to any useful value of Voverlay_arrow_... */
1226 last_arrow_position
= Qt
;
1227 last_arrow_string
= Qt
;
1231 /* Update the menu bar item list for frame F.
1232 This has to be done before we start to fill in any display lines,
1233 because it can call eval.
1235 If SAVE_MATCH_DATA is 1, we must save and restore it here. */
1238 update_menu_bar (f
, save_match_data
)
1240 int save_match_data
;
1242 struct buffer
*old
= current_buffer
;
1244 register struct window
*w
;
1246 window
= FRAME_SELECTED_WINDOW (f
);
1247 w
= XWINDOW (window
);
1249 if (update_mode_lines
)
1250 w
->update_mode_line
= Qt
;
1253 #ifdef USE_X_TOOLKIT
1254 FRAME_EXTERNAL_MENU_BAR (f
)
1256 FRAME_MENU_BAR_LINES (f
) > 0
1260 /* If the user has switched buffers or windows, we need to
1261 recompute to reflect the new bindings. But we'll
1262 recompute when update_mode_lines is set too; that means
1263 that people can use force-mode-line-update to request
1264 that the menu bar be recomputed. The adverse effect on
1265 the rest of the redisplay algorithm is about the same as
1266 windows_or_buffers_changed anyway. */
1267 if (windows_or_buffers_changed
1268 || !NILP (w
->update_mode_line
)
1269 || (XFASTINT (w
->last_modified
) < MODIFF
1270 && (XFASTINT (w
->last_modified
)
1271 <= BUF_SAVE_MODIFF (XBUFFER (w
->buffer
))))
1272 || ((!NILP (Vtransient_mark_mode
)
1273 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
1274 != !NILP (w
->region_showing
)))
1276 struct buffer
*prev
= current_buffer
;
1277 int count
= specpdl_ptr
- specpdl
;
1279 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1280 if (save_match_data
)
1281 record_unwind_protect (Fstore_match_data
, Fmatch_data ());
1282 if (NILP (Voverriding_local_map_menu_flag
))
1284 specbind (Qoverriding_terminal_local_map
, Qnil
);
1285 specbind (Qoverriding_local_map
, Qnil
);
1288 /* Run the Lucid hook. */
1289 call1 (Vrun_hooks
, Qactivate_menubar_hook
);
1290 /* If it has changed current-menubar from previous value,
1291 really recompute the menubar from the value. */
1292 if (! NILP (Vlucid_menu_bar_dirty_flag
))
1293 call0 (Qrecompute_lucid_menubar
);
1294 call1 (Vrun_hooks
, Qmenu_bar_update_hook
);
1295 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
1296 #ifdef USE_X_TOOLKIT
1297 set_frame_menubar (f
, 0);
1298 #endif /* USE_X_TOOLKIT */
1300 unbind_to (count
, Qnil
);
1301 set_buffer_internal_1 (prev
);
1308 /* Redisplay WINDOW and its subwindows and siblings. */
1311 redisplay_windows (window
)
1314 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1315 redisplay_window (window
, 0);
1318 /* Redisplay window WINDOW and its subwindows. */
1321 redisplay_window (window
, just_this_one
)
1325 register struct window
*w
= XWINDOW (window
);
1326 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1328 register int lpoint
= PT
;
1329 struct buffer
*old
= current_buffer
;
1330 register int width
= window_internal_width (w
) - 1;
1331 register int startp
;
1332 register int hscroll
= XINT (w
->hscroll
);
1333 struct position pos
;
1336 int update_mode_line
;
1337 struct Lisp_Vector
*dp
= window_display_table (w
);
1339 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1341 /* If this is a combination window, do its children; that's all. */
1343 if (!NILP (w
->vchild
))
1345 redisplay_windows (w
->vchild
);
1348 if (!NILP (w
->hchild
))
1350 redisplay_windows (w
->hchild
);
1353 if (NILP (w
->buffer
))
1356 height
= window_internal_height (w
);
1357 update_mode_line
= (!NILP (w
->update_mode_line
) || update_mode_lines
);
1359 if (MINI_WINDOW_P (w
))
1361 if (w
== XWINDOW (minibuf_window
))
1363 if (echo_area_glyphs
)
1364 /* We've already displayed the echo area glyphs, if any. */
1365 goto finish_scroll_bars
;
1369 /* This is a minibuffer, but it's not the currently active one, so
1371 int vpos
= XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f
))->top
);
1374 for (i
= 0; i
< height
; i
++)
1376 get_display_line (f
, vpos
+ i
, 0);
1377 display_string (w
, vpos
+ i
, "", 0, 0, 0, 1, 0, width
);
1380 goto finish_scroll_bars
;
1384 /* Otherwise set up data on this window; select its buffer and point value */
1386 if (update_mode_line
)
1387 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1389 set_buffer_temp (XBUFFER (w
->buffer
));
1393 /* If %c is in mode line, update it if needed. */
1394 if (!NILP (w
->column_number_displayed
)
1395 /* This alternative quickly identifies a common case
1396 where no change is needed. */
1397 && !(PT
== XFASTINT (w
->last_point
)
1398 && XFASTINT (w
->last_modified
) >= MODIFF
)
1399 && XFASTINT (w
->column_number_displayed
) != current_column ())
1400 update_mode_line
= 1;
1402 /* Count number of windows showing the selected buffer.
1403 An indirect buffer counts as its base buffer. */
1407 struct buffer
*current_base
, *window_base
;
1408 current_base
= current_buffer
;
1409 window_base
= XBUFFER (XWINDOW (selected_window
)->buffer
);
1410 if (current_base
->base_buffer
)
1411 current_base
= current_base
->base_buffer
;
1412 if (window_base
->base_buffer
)
1413 window_base
= window_base
->base_buffer
;
1414 if (current_base
== window_base
)
1418 /* POINT refers normally to the selected window.
1419 For any other window, set up appropriate value. */
1421 if (!EQ (window
, selected_window
))
1423 int new_pt
= marker_position (w
->pointm
);
1427 Fset_marker (w
->pointm
, make_number (new_pt
), Qnil
);
1429 else if (new_pt
> (ZV
- 1))
1432 Fset_marker (w
->pointm
, make_number (new_pt
), Qnil
);
1434 /* We don't use SET_PT so that the point-motion hooks don't run. */
1435 BUF_PT (current_buffer
) = new_pt
;
1438 /* If any of the character widths specified in the display table
1439 have changed, invalidate the width run cache. It's true that this
1440 may be a bit late to catch such changes, but the rest of
1441 redisplay goes (non-fatally) haywire when the display table is
1442 changed, so why should we worry about doing any better? */
1443 if (current_buffer
->width_run_cache
)
1445 struct Lisp_Vector
*disptab
= buffer_display_table ();
1447 if (! disptab_matches_widthtab (disptab
,
1448 XVECTOR (current_buffer
->width_table
)))
1450 invalidate_region_cache (current_buffer
,
1451 current_buffer
->width_run_cache
,
1453 recompute_width_table (current_buffer
, disptab
);
1457 /* If window-start is screwed up, choose a new one. */
1458 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1461 startp
= marker_position (w
->start
);
1463 /* Handle case where place to start displaying has been specified,
1464 unless the specified location is outside the accessible range. */
1465 if (!NILP (w
->force_start
))
1467 /* Forget any recorded base line for line number display. */
1468 w
->base_line_number
= Qnil
;
1469 /* Redisplay the mode line. Select the buffer properly for that. */
1470 if (!update_mode_line
)
1472 set_buffer_temp (old
);
1473 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1474 update_mode_line
= 1;
1475 w
->update_mode_line
= Qt
;
1477 w
->force_start
= Qnil
;
1478 XSETFASTINT (w
->last_modified
, 0);
1479 if (startp
< BEGV
) startp
= BEGV
;
1480 if (startp
> ZV
) startp
= ZV
;
1481 try_window (window
, startp
);
1482 if (cursor_vpos
< 0)
1484 /* If point does not appear, move point so it does appear */
1485 pos
= *compute_motion (startp
, 0,
1486 (((EQ (window
, minibuf_window
)
1488 ? minibuf_prompt_width
: 0)
1489 + (hscroll
? 1 - hscroll
: 0)),
1492 - (1 << (SHORTBITS
- 1)),
1493 width
, hscroll
, pos_tab_offset (w
, startp
), w
);
1494 BUF_PT (current_buffer
) = pos
.bufpos
;
1495 if (w
!= XWINDOW (selected_window
))
1496 Fset_marker (w
->pointm
, make_number (PT
), Qnil
);
1499 if (current_buffer
== old
)
1501 FRAME_CURSOR_X (f
) = (XFASTINT (w
->left
)
1502 + minmax (0, pos
.hpos
, width
));
1503 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1505 /* If we are highlighting the region,
1506 then we just changed the region, so redisplay to show it. */
1507 if (!NILP (Vtransient_mark_mode
)
1508 && !NILP (current_buffer
->mark_active
))
1510 cancel_my_columns (XWINDOW (window
));
1511 try_window (window
, startp
);
1517 /* Handle case where text has not changed, only point,
1518 and it has not moved off the frame */
1520 /* This code is not used for minibuffer for the sake of
1521 the case of redisplaying to replace an echo area message;
1522 since in that case the minibuffer contents per se are usually unchanged.
1523 This code is of no real use in the minibuffer since
1524 the handling of this_line_bufpos, etc.,
1525 in redisplay handles the same cases. */
1527 if (XFASTINT (w
->last_modified
) >= MODIFF
1528 && PT
>= startp
&& current_buffer
->clip_changed
1529 && (just_this_one
|| XFASTINT (w
->width
) == FRAME_WIDTH (f
))
1530 /* If force-mode-line-update was called, really redisplay;
1531 that's how redisplay is forced after e.g. changing
1532 buffer-invisibility-spec. */
1533 && NILP (w
->update_mode_line
)
1534 /* Can't use this case if highlighting a region. */
1535 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
1536 && NILP (w
->region_showing
)
1537 /* If end pos is out of date, scroll bar and percentage will be wrong */
1538 && INTEGERP (w
->window_end_vpos
)
1539 && XFASTINT (w
->window_end_vpos
) < XFASTINT (w
->height
)
1540 && !EQ (window
, minibuf_window
))
1542 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0), 0,
1543 PT
, height
, 0, width
, hscroll
,
1544 pos_tab_offset (w
, startp
), w
);
1546 if (pos
.vpos
< height
)
1548 /* Ok, point is still on frame */
1549 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
1551 /* These variables are supposed to be origin 1 */
1552 FRAME_CURSOR_X (f
) = (XFASTINT (w
->left
)
1553 + minmax (0, pos
.hpos
, width
));
1554 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1556 /* This doesn't do the trick, because if a window to the right of
1557 this one must be redisplayed, this does nothing because there
1558 is nothing in DesiredFrame yet, and then the other window is
1559 redisplayed, making likes that are empty in this window's columns.
1560 if (XFASTINT (w->width) != FRAME_WIDTH (f))
1561 preserve_my_columns (w);
1565 /* Don't bother trying redisplay with same start;
1566 we already know it will lose */
1568 /* If current starting point was originally the beginning of a line
1569 but no longer is, find a new starting point. */
1570 else if (!NILP (w
->start_at_line_beg
)
1572 || FETCH_CHAR (startp
- 1) == '\n'))
1576 else if (just_this_one
&& !MINI_WINDOW_P (w
)
1578 && XFASTINT (w
->last_modified
)
1579 /* or else vmotion on first line won't work. */
1580 && ! NILP (w
->start_at_line_beg
)
1581 && ! EQ (w
->window_end_valid
, Qnil
)
1582 && do_id
&& current_buffer
->clip_changed
1583 && !blank_end_of_window
1584 && XFASTINT (w
->width
) == FRAME_WIDTH (f
)
1585 /* Can't use this case if highlighting a region. */
1586 && !(!NILP (Vtransient_mark_mode
)
1587 && !NILP (current_buffer
->mark_active
))
1588 /* Don't use try_window_id if newline
1589 doesn't display as the end of a line. */
1590 && !(dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, '\n')))
1591 && NILP (w
->region_showing
)
1592 && EQ (last_arrow_position
, Voverlay_arrow_position
)
1593 && EQ (last_arrow_string
, Voverlay_arrow_string
)
1594 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
1597 /* tem > 0 means success. tem == -1 means choose new start.
1598 tem == -2 means try again with same start,
1599 and nothing but whitespace follows the changed stuff.
1600 tem == 0 means try again with same start. */
1604 else if (startp
>= BEGV
&& startp
<= ZV
1605 /* Avoid starting display at end of buffer! */
1606 && (startp
< ZV
|| startp
== BEGV
1607 || (XFASTINT (w
->last_modified
) >= MODIFF
)))
1609 /* Try to redisplay starting at same place as before */
1610 /* If point has not moved off frame, accept the results */
1611 try_window (window
, startp
);
1612 if (cursor_vpos
>= 0)
1614 if (!just_this_one
|| current_buffer
->clip_changed
1615 || beg_unchanged
< startp
)
1616 /* Forget any recorded base line for line number display. */
1617 w
->base_line_number
= Qnil
;
1621 cancel_my_columns (w
);
1624 XSETFASTINT (w
->last_modified
, 0);
1625 /* Redisplay the mode line. Select the buffer properly for that. */
1626 if (!update_mode_line
)
1628 set_buffer_temp (old
);
1629 set_buffer_internal_1 (XBUFFER (w
->buffer
));
1630 update_mode_line
= 1;
1631 w
->update_mode_line
= Qt
;
1634 /* Try to scroll by specified few lines */
1636 if (scroll_step
&& !current_buffer
->clip_changed
)
1640 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), scroll_step
, w
);
1641 if (pos
.vpos
>= height
)
1645 pos
= *vmotion (startp
, (PT
< startp
? - scroll_step
: scroll_step
), w
);
1647 if (PT
>= pos
.bufpos
)
1649 try_window (window
, pos
.bufpos
);
1650 if (cursor_vpos
>= 0)
1652 if (!just_this_one
|| current_buffer
->clip_changed
1653 || beg_unchanged
< startp
)
1654 /* Forget any recorded base line for line number display. */
1655 w
->base_line_number
= Qnil
;
1659 cancel_my_columns (w
);
1664 /* Finally, just choose place to start which centers point */
1667 /* Forget any previously recorded base line for line number display. */
1668 w
->base_line_number
= Qnil
;
1670 pos
= *vmotion (PT
, - (height
/ 2), w
);
1671 try_window (window
, pos
.bufpos
);
1673 startp
= marker_position (w
->start
);
1674 w
->start_at_line_beg
1675 = (startp
== BEGV
|| FETCH_CHAR (startp
- 1) == '\n') ? Qt
: Qnil
;
1678 if ((update_mode_line
1679 /* If window not full width, must redo its mode line
1680 if the window to its side is being redone */
1681 || (!just_this_one
&& width
< FRAME_WIDTH (f
) - 1)
1682 || INTEGERP (w
->base_line_pos
)
1683 || (!NILP (w
->column_number_displayed
)
1684 && XFASTINT (w
->column_number_displayed
) != current_column ()))
1685 && height
!= XFASTINT (w
->height
))
1686 display_mode_line (w
);
1687 if (! line_number_displayed
1688 && ! BUFFERP (w
->base_line_pos
))
1690 w
->base_line_pos
= Qnil
;
1691 w
->base_line_number
= Qnil
;
1694 /* When we reach a frame's selected window, redo the frame's menu bar. */
1695 if (update_mode_line
1696 #ifdef USE_X_TOOLKIT
1697 && FRAME_EXTERNAL_MENU_BAR (f
)
1699 && FRAME_MENU_BAR_LINES (f
) > 0
1701 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
1702 display_menu_bar (w
);
1705 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1707 int start
, end
, whole
;
1709 /* Calculate the start and end positions for the current window.
1710 At some point, it would be nice to choose between scrollbars
1711 which reflect the whole buffer size, with special markers
1712 indicating narrowing, and scrollbars which reflect only the
1715 Note that minibuffers sometimes aren't displaying any text. */
1716 if (! MINI_WINDOW_P (w
)
1717 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
1720 start
= marker_position (w
->start
) - BEGV
;
1721 /* I don't think this is guaranteed to be right. For the
1722 moment, we'll pretend it is. */
1723 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
1725 if (end
< start
) end
= start
;
1726 if (whole
< (end
- start
)) whole
= end
- start
;
1729 start
= end
= whole
= 0;
1731 /* Indicate what this scroll bar ought to be displaying now. */
1732 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
1734 /* Note that we actually used the scroll bar attached to this window,
1735 so it shouldn't be deleted at the end of redisplay. */
1736 (*redeem_scroll_bar_hook
) (w
);
1739 BUF_PT (current_buffer
) = opoint
;
1740 if (update_mode_line
)
1741 set_buffer_internal_1 (old
);
1743 set_buffer_temp (old
);
1744 BUF_PT (current_buffer
) = lpoint
;
1747 /* Do full redisplay on one window, starting at position `pos'. */
1750 try_window (window
, pos
)
1754 register struct window
*w
= XWINDOW (window
);
1755 register int height
= window_internal_height (w
);
1756 register int vpos
= XFASTINT (w
->top
);
1757 register int last_text_vpos
= vpos
;
1758 int tab_offset
= pos_tab_offset (w
, pos
);
1759 FRAME_PTR f
= XFRAME (w
->frame
);
1760 int width
= window_internal_width (w
) - 1;
1761 struct position val
;
1763 Fset_marker (w
->start
, make_number (pos
), Qnil
);
1765 overlay_arrow_seen
= 0;
1766 zv_strings_seen
= 0;
1767 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
1769 while (--height
>= 0)
1771 val
= *display_text_line (w
, pos
, vpos
, val
.hpos
, tab_offset
);
1772 tab_offset
+= width
;
1773 /* For the first line displayed, display_text_line
1774 subtracts the prompt width from the tab offset.
1775 But it does not affect the value of our variable tab_offset.
1776 So we do the subtraction again,
1777 for the sake of continuation lines of that first line. */
1778 if (MINI_WINDOW_P (w
) && vpos
== XFASTINT (w
->top
))
1779 tab_offset
-= minibuf_prompt_width
;
1781 if (val
.vpos
) tab_offset
= 0;
1783 if (pos
!= val
.bufpos
)
1786 #ifdef USE_TEXT_PROPERTIES
1787 Lisp_Object invis_prop
;
1788 invis_prop
= Fget_char_property (val
.bufpos
-1, Qinvisible
, window
);
1789 invis
= TEXT_PROP_MEANS_INVISIBLE (invis_prop
);
1793 /* Next line, unless prev line ended in end of buffer with no cr */
1795 && (FETCH_CHAR (val
.bufpos
- 1) != '\n' || invis
));
1800 /* If last line is continued in middle of character,
1801 include the split character in the text considered on the frame */
1802 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
1805 /* If bottom just moved off end of frame, change mode line percentage. */
1806 if (XFASTINT (w
->window_end_pos
) == 0
1808 w
->update_mode_line
= Qt
;
1810 /* Say where last char on frame will be, once redisplay is finished. */
1811 XSETFASTINT (w
->window_end_pos
, Z
- pos
);
1812 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
- XFASTINT (w
->top
));
1813 /* But that is not valid info until redisplay finishes. */
1814 w
->window_end_valid
= Qnil
;
1817 /* Try to redisplay when buffer is modified locally,
1818 computing insert/delete line to preserve text outside
1819 the bounds of the changes.
1820 Return 1 if successful, 0 if if cannot tell what to do,
1821 or -1 to tell caller to find a new window start,
1822 or -2 to tell caller to do normal redisplay with same window start. */
1825 try_window_id (window
)
1829 register struct window
*w
= XWINDOW (window
);
1830 register int height
= window_internal_height (w
);
1831 FRAME_PTR f
= XFRAME (w
->frame
);
1832 int top
= XFASTINT (w
->top
);
1833 int start
= marker_position (w
->start
);
1834 int width
= window_internal_width (w
) - 1;
1835 int hscroll
= XINT (w
->hscroll
);
1836 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
1839 register int i
, tem
;
1840 int last_text_vpos
= 0;
1842 int selective
= (INTEGERP (current_buffer
->selective_display
)
1843 ? XINT (current_buffer
->selective_display
)
1844 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
1846 struct position val
, bp
, ep
, xp
, pp
;
1847 int scroll_amount
= 0;
1849 int tab_offset
, epto
;
1851 if (GPT
- BEG
< beg_unchanged
)
1852 beg_unchanged
= GPT
- BEG
;
1853 if (Z
- GPT
< end_unchanged
)
1854 end_unchanged
= Z
- GPT
;
1856 if (beg_unchanged
+ BEG
< start
)
1857 return 0; /* Give up if changes go above top of window */
1859 /* Find position before which nothing is changed. */
1860 bp
= *compute_motion (start
, 0, lmargin
, 0,
1861 min (ZV
, beg_unchanged
+ BEG
), height
, 0,
1862 width
, hscroll
, pos_tab_offset (w
, start
), w
);
1863 if (bp
.vpos
>= height
)
1867 /* All changes are below the frame, and point is on the frame.
1868 We don't need to change the frame at all.
1869 But we need to update window_end_pos to account for
1870 any change in buffer size. */
1871 bp
= *compute_motion (start
, 0, lmargin
, 0,
1873 width
, hscroll
, pos_tab_offset (w
, start
), w
);
1874 XSETFASTINT (w
->window_end_vpos
, height
);
1875 XSETFASTINT (w
->window_end_pos
, Z
- bp
.bufpos
);
1883 /* Find beginning of that frame line. Must display from there. */
1884 bp
= *vmotion (bp
.bufpos
, 0, w
);
1892 /* If about to start displaying at the beginning of a continuation line,
1893 really start with previous frame line, in case it was not
1894 continued when last redisplayed */
1895 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
1897 /* Likewise if we have to worry about selective display. */
1898 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
1900 bp
= *vmotion (bp
.bufpos
, -1, w
);
1905 if (bp
.contin
&& bp
.hpos
!= lmargin
)
1907 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
1914 /* Find first visible newline after which no more is changed. */
1915 tem
= find_next_newline (Z
- max (end_unchanged
, Z
- ZV
), 1);
1917 while (tem
< ZV
- 1 && (indented_beyond_p (tem
, selective
)))
1918 tem
= find_next_newline (tem
, 1);
1920 /* Compute the cursor position after that newline. */
1921 ep
= *compute_motion (pos
, vpos
, val
.hpos
, did_motion
, tem
,
1922 height
, - (1 << (SHORTBITS
- 1)),
1923 width
, hscroll
, pos_tab_offset (w
, bp
.bufpos
), w
);
1925 /* If changes reach past the text available on the frame,
1926 just display rest of frame. */
1927 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
1930 stop_vpos
= ep
.vpos
;
1932 /* If no newline before ep, the line ep is on includes some changes
1933 that must be displayed. Make sure we don't stop before it. */
1934 /* Also, if changes reach all the way until ep.bufpos,
1935 it is possible that something was deleted after the
1936 newline before it, so the following line must be redrawn. */
1937 if (stop_vpos
== ep
.vpos
1938 && (ep
.bufpos
== BEGV
1939 || FETCH_CHAR (ep
.bufpos
- 1) != '\n'
1940 || ep
.bufpos
== Z
- end_unchanged
))
1941 stop_vpos
= ep
.vpos
+ 1;
1944 overlay_arrow_seen
= 0;
1945 zv_strings_seen
= 0;
1947 /* If changes do not reach to bottom of window,
1948 figure out how much to scroll the rest of the window */
1949 if (stop_vpos
< height
)
1951 /* Now determine how far up or down the rest of the window has moved */
1952 epto
= pos_tab_offset (w
, ep
.bufpos
);
1953 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
1954 Z
- XFASTINT (w
->window_end_pos
),
1955 10000, 0, width
, hscroll
, epto
, w
);
1956 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
1958 /* Is everything on frame below the changes whitespace?
1959 If so, no scrolling is really necessary. */
1960 for (i
= ep
.bufpos
; i
< xp
.bufpos
; i
++)
1962 tem
= FETCH_CHAR (i
);
1963 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
1969 XSETFASTINT (w
->window_end_vpos
,
1970 XFASTINT (w
->window_end_vpos
) + scroll_amount
);
1972 /* Before doing any scrolling, verify that point will be on frame. */
1973 if (PT
> ep
.bufpos
&& !(PT
<= xp
.bufpos
&& xp
.bufpos
< height
))
1975 if (PT
<= xp
.bufpos
)
1977 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
, 1,
1978 PT
, height
, - (1 << (SHORTBITS
- 1)),
1979 width
, hscroll
, epto
, w
);
1983 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
, 1,
1984 PT
, height
, - (1 << (SHORTBITS
- 1)),
1986 pos_tab_offset (w
, xp
.bufpos
), w
);
1988 if (pp
.bufpos
< PT
|| pp
.vpos
== height
)
1990 cursor_vpos
= pp
.vpos
+ top
;
1991 cursor_hpos
= XFASTINT (w
->left
) + minmax (0, pp
.hpos
, width
);
1994 if (stop_vpos
- scroll_amount
>= height
1995 || ep
.bufpos
== xp
.bufpos
)
1997 if (scroll_amount
< 0)
1998 stop_vpos
-= scroll_amount
;
2000 /* In this path, we have altered window_end_vpos
2001 and not left it negative.
2002 We must make sure that, in case display is preempted
2003 before the frame changes to reflect what we do here,
2004 further updates will not come to try_window_id
2005 and assume the frame and window_end_vpos match. */
2006 blank_end_of_window
= 1;
2008 else if (!scroll_amount
)
2010 /* Even if we don't need to scroll, we must adjust the
2011 charstarts of subsequent lines (that we won't redisplay)
2012 according to the amount of text inserted or deleted. */
2013 int oldpos
= FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2014 int adjust
= ep
.bufpos
- oldpos
;
2015 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1, adjust
);
2017 else if (bp
.bufpos
== Z
- end_unchanged
)
2019 /* If reprinting everything is nearly as fast as scrolling,
2020 don't bother scrolling. Can happen if lines are short. */
2021 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
2022 top
+ height
- max (0, scroll_amount
),
2024 > xp
.bufpos
- bp
.bufpos
- 20)
2025 /* Return "try normal display with same window-start."
2026 Too bad we can't prevent further scroll-thinking. */
2028 /* If pure deletion, scroll up as many lines as possible.
2029 In common case of killing a line, this can save the
2030 following line from being overwritten by scrolling
2031 and therefore having to be redrawn. */
2032 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
2033 top
+ height
- max (0, scroll_amount
),
2034 scroll_amount
, bp
.bufpos
);
2039 /* scroll_frame_lines did not properly adjust subsequent
2040 lines' charstarts in the case where the text of the
2041 screen line at bp.vpos has changed.
2042 (This can happen in a deletion that ends in mid-line.)
2043 To adjust properly, we need to make things constent at
2045 So do a second adjust to make that happen.
2046 Note that stop_vpos >= ep.vpos, so it is sufficient
2047 to update the charstarts for lines at ep.vpos and below. */
2049 = FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
2050 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1,
2051 ep
.bufpos
- oldstart
);
2054 else if (scroll_amount
)
2056 /* If reprinting everything is nearly as fast as scrolling,
2057 don't bother scrolling. Can happen if lines are short. */
2058 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
2059 overestimate of cost of reprinting, since xp.bufpos
2060 would end up below the bottom of the window. */
2061 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
2062 top
+ height
- max (0, scroll_amount
),
2064 > xp
.bufpos
- ep
.bufpos
- 20)
2065 /* Return "try normal display with same window-start."
2066 Too bad we can't prevent further scroll-thinking. */
2068 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
2069 top
+ height
- max (0, scroll_amount
),
2070 scroll_amount
, ep
.bufpos
);
2071 if (!tem
) stop_vpos
= height
;
2075 /* In any case, do not display past bottom of window */
2076 if (stop_vpos
>= height
)
2082 /* Handle case where pos is before w->start --
2083 can happen if part of line had been clipped and is not clipped now */
2084 if (vpos
== 0 && pos
< marker_position (w
->start
))
2085 Fset_marker (w
->start
, make_number (pos
), Qnil
);
2087 /* Redisplay the lines where the text was changed */
2088 last_text_vpos
= vpos
;
2089 tab_offset
= pos_tab_offset (w
, pos
);
2090 /* If we are starting display in mid-character, correct tab_offset
2091 to account for passing the line that that character really starts in. */
2092 if (val
.hpos
< lmargin
)
2093 tab_offset
+= width
;
2094 while (vpos
< stop_vpos
)
2096 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
2097 tab_offset
+= width
;
2098 if (val
.vpos
) tab_offset
= 0;
2099 if (pos
!= val
.bufpos
)
2101 /* Next line, unless prev line ended in end of buffer with no cr */
2102 = vpos
- (val
.vpos
&& FETCH_CHAR (val
.bufpos
- 1) != '\n');
2106 /* There are two cases:
2107 1) we have displayed down to the bottom of the window
2108 2) we have scrolled lines below stop_vpos by scroll_amount */
2112 /* If last line is continued in middle of character,
2113 include the split character in the text considered on the frame */
2114 if (val
.hpos
< lmargin
)
2116 XSETFASTINT (w
->window_end_vpos
, last_text_vpos
);
2117 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2120 /* If scrolling made blank lines at window bottom,
2121 redisplay to fill those lines */
2122 if (scroll_amount
< 0)
2124 /* Don't consider these lines for general-purpose scrolling.
2125 That will save time in the scrolling computation. */
2126 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
2131 vpos
= height
+ scroll_amount
;
2132 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
2134 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
2138 blank_end_of_window
= 1;
2139 tab_offset
= pos_tab_offset (w
, pos
);
2140 /* If we are starting display in mid-character, correct tab_offset
2141 to account for passing the line that that character starts in. */
2142 if (val
.hpos
< lmargin
)
2143 tab_offset
+= width
;
2145 while (vpos
< height
)
2147 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
2148 tab_offset
+= width
;
2149 if (val
.vpos
) tab_offset
= 0;
2153 /* Here is a case where display_text_line sets cursor_vpos wrong.
2154 Make it be fixed up, below. */
2160 /* If bottom just moved off end of frame, change mode line percentage. */
2161 if (XFASTINT (w
->window_end_pos
) == 0
2163 w
->update_mode_line
= Qt
;
2165 /* Attempt to adjust end-of-text positions to new bottom line */
2168 delta
= height
- xp
.vpos
;
2170 || (delta
> 0 && xp
.bufpos
<= ZV
)
2171 || (delta
== 0 && xp
.hpos
))
2173 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
), delta
, w
);
2174 XSETFASTINT (w
->window_end_pos
, Z
- val
.bufpos
);
2175 XSETFASTINT (w
->window_end_vpos
,
2176 XFASTINT (w
->window_end_vpos
) + val
.vpos
);
2180 w
->window_end_valid
= Qnil
;
2182 /* If point was not in a line that was displayed, find it */
2183 if (cursor_vpos
< 0)
2186 val
= *compute_motion (start
, 0, lmargin
, 0, PT
, 10000, 10000,
2187 width
, hscroll
, pos_tab_offset (w
, start
), w
);
2188 /* Admit failure if point is off frame now */
2189 if (val
.vpos
>= height
)
2191 for (vpos
= 0; vpos
< height
; vpos
++)
2192 cancel_line (vpos
+ top
, f
);
2195 cursor_vpos
= val
.vpos
+ top
;
2196 cursor_hpos
= XFASTINT (w
->left
) + minmax (0, val
.hpos
, width
);
2199 FRAME_CURSOR_X (f
) = cursor_hpos
;
2200 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2204 val
= *compute_motion (start
, 0, lmargin
, 0, ZV
,
2205 height
, - (1 << (SHORTBITS
- 1)),
2206 width
, hscroll
, pos_tab_offset (w
, start
), w
);
2207 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
2209 if (XFASTINT (w
->window_end_pos
)
2217 /* Mark a section of BUF as modified, but only for the sake of redisplay.
2218 This is useful for recording changes to overlays.
2220 We increment the buffer's modification timestamp and set the
2221 redisplay caches (windows_or_buffers_changed, beg_unchanged, etc)
2222 as if the region of text between START and END had been modified;
2223 the redisplay code will check this against the windows' timestamps,
2224 and redraw the appropriate area of the buffer.
2226 However, if the buffer is unmodified, we bump the last-save
2227 timestamp as well, so that incrementing the timestamp doesn't fool
2228 Emacs into thinking that the buffer's text has been modified.
2230 Tweaking the timestamps shouldn't hurt the first-modification
2231 timestamps recorded in the undo records; those values aren't
2232 written until just before a real text modification is made, so they
2233 will never catch the timestamp value just before this function gets
2237 redisplay_region (buf
, start
, end
)
2247 start
= end
; end
= temp
;
2250 /* If this is a buffer not in the selected window,
2251 we must do other windows. */
2252 if (buf
!= XBUFFER (XWINDOW (selected_window
)->buffer
))
2253 windows_or_buffers_changed
= 1;
2254 /* If it's not current, we can't use beg_unchanged, end_unchanged for it. */
2255 else if (buf
!= current_buffer
)
2256 windows_or_buffers_changed
= 1;
2257 /* If multiple windows show this buffer, we must do other windows. */
2258 else if (buffer_shared
> 1)
2259 windows_or_buffers_changed
= 1;
2262 if (unchanged_modified
== MODIFF
)
2264 beg_unchanged
= start
- BEG
;
2265 end_unchanged
= Z
- end
;
2269 if (Z
- end
< end_unchanged
)
2270 end_unchanged
= Z
- end
;
2271 if (start
- BEG
< beg_unchanged
)
2272 beg_unchanged
= start
- BEG
;
2276 /* Increment the buffer's time stamp, but also increment the save
2277 and autosave timestamps, so as not to screw up that timekeeping. */
2278 if (BUF_MODIFF (buf
) == BUF_SAVE_MODIFF (buf
))
2279 BUF_SAVE_MODIFF (buf
)++;
2280 if (BUF_MODIFF (buf
) == buf
->auto_save_modified
)
2281 buf
->auto_save_modified
++;
2283 BUF_MODIFF (buf
) ++;
2287 /* Copy LEN glyphs starting address FROM to the rope TO.
2288 But don't actually copy the parts that would come in before S.
2289 Value is TO, advanced past the copied data.
2290 F is the frame we are displaying in. */
2293 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
2295 register GLYPH
*to
; /* Copy to here. */
2296 register GLYPH
*s
; /* Starting point. */
2297 Lisp_Object
*from
; /* Data to copy. */
2299 int face
; /* Face to apply to glyphs which don't specify one. */
2302 register Lisp_Object
*fp
= from
;
2303 /* These cache the results of the last call to compute_glyph_face. */
2305 int last_merged
= 0;
2308 if (! FRAME_TERMCAP_P (f
))
2311 int glyph
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
2314 if (FAST_GLYPH_FACE (glyph
) == 0)
2315 /* If GLYPH has no face code, use FACE. */
2317 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
2318 /* If it's same as previous glyph, use same result. */
2319 facecode
= last_merged
;
2322 /* Merge this glyph's face and remember the result. */
2323 last_code
= FAST_GLYPH_FACE (glyph
);
2324 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
2328 *to
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), facecode
);
2336 if (to
>= s
) *to
= (INTEGERP (*fp
) ? XFASTINT (*fp
) : 0);
2343 /* Correct a glyph by replacing its specified user-level face code
2344 with a displayable computed face code. */
2347 fix_glyph (f
, glyph
, cface
)
2353 if (! FRAME_TERMCAP_P (f
))
2355 if (FAST_GLYPH_FACE (glyph
) != 0)
2356 cface
= compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
), cface
);
2357 glyph
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), cface
);
2363 /* Display one line of window W, starting at position START in W's buffer.
2365 Display starting at horizontal position HPOS, expressed relative to
2366 W's left edge. In situations where the text at START shouldn't
2367 start at the left margin (i.e. when the window is hscrolled, or
2368 we're continuing a line which left off in the midst of a
2369 multi-column character), HPOS should be negative; we throw away
2370 characters up 'til hpos = 0. So, HPOS must take hscrolling into
2373 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
2375 Display on position VPOS on the frame. It is origin 0, relative to
2376 the top of the frame, not W.
2378 Returns a STRUCT POSITION giving character to start next line with
2379 and where to display it, including a zero or negative hpos.
2380 The vpos field is not really a vpos; it is 1 unless the line is continued */
2382 struct position val_display_text_line
;
2384 static struct position
*
2385 display_text_line (w
, start
, vpos
, hpos
, taboffset
)
2392 register int pos
= start
;
2396 register unsigned char *p
;
2398 register GLYPH
*leftmargin
;
2399 register GLYPH
*p1prev
;
2400 register GLYPH
*p1start
;
2403 FRAME_PTR f
= XFRAME (w
->frame
);
2404 int tab_width
= XINT (current_buffer
->tab_width
);
2405 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
2406 int width
= window_internal_width (w
) - 1;
2407 struct position val
;
2410 int last_invis_skip
= 0;
2411 Lisp_Object last_invis_prop
;
2412 int hscroll
= XINT (w
->hscroll
);
2413 int truncate
= (hscroll
2414 || (truncate_partial_width_windows
2415 && XFASTINT (w
->width
) < FRAME_WIDTH (f
))
2416 || !NILP (current_buffer
->truncate_lines
));
2418 /* 1 if we should highlight the region. */
2419 int highlight_region
2420 = !NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
);
2421 int region_beg
, region_end
;
2423 int selective
= (INTEGERP (current_buffer
->selective_display
)
2424 ? XINT (current_buffer
->selective_display
)
2425 : !NILP (current_buffer
->selective_display
) ? -1 : 0);
2426 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
2427 register struct Lisp_Vector
*dp
= window_display_table (w
);
2429 Lisp_Object default_invis_vector
[3];
2430 /* Number of characters of ellipsis to display after an invisible line
2431 if it calls for an ellipsis.
2432 Note that this value can be nonzero regardless of whether
2433 selective display is enabled--you must check that separately. */
2435 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
2436 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
2437 : !NILP (current_buffer
->selective_display_ellipses
) ? 3 : 0);
2438 /* This is the sequence of Lisp objects to display
2439 when there are invisible lines. */
2440 Lisp_Object
*invis_vector_contents
2441 = (dp
&& VECTORP (DISP_INVIS_VECTOR (dp
))
2442 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
2443 : default_invis_vector
);
2445 GLYPH truncator
= (dp
== 0 || !INTEGERP (DISP_TRUNC_GLYPH (dp
))
2446 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
2447 GLYPH continuer
= (dp
== 0 || !INTEGERP (DISP_CONTINUE_GLYPH (dp
))
2448 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
2450 /* The next buffer location at which the face should change, due
2451 to overlays or text property changes. */
2452 int next_face_change
;
2454 /* The next location where the `invisible' property changes, or an
2455 overlay starts or ends. */
2458 /* The face we're currently using. */
2459 int current_face
= 0;
2462 XSETFASTINT (default_invis_vector
[2], '.');
2463 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
2465 hpos
+= XFASTINT (w
->left
);
2466 get_display_line (f
, vpos
, XFASTINT (w
->left
));
2467 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
2469 /* Show where to highlight the region. */
2470 if (highlight_region
&& XMARKER (current_buffer
->mark
)->buffer
!= 0
2471 /* Maybe highlight only in selected window. */
2472 && (highlight_nonselected_windows
2473 || w
== XWINDOW (selected_window
)))
2475 region_beg
= marker_position (current_buffer
->mark
);
2476 if (PT
< region_beg
)
2478 region_end
= region_beg
;
2483 w
->region_showing
= Qt
;
2486 region_beg
= region_end
= -1;
2488 if (MINI_WINDOW_P (w
)
2490 && vpos
== XFASTINT (w
->top
))
2492 if (! NILP (minibuf_prompt
))
2494 minibuf_prompt_width
2495 = (display_string (w
, vpos
, XSTRING (minibuf_prompt
)->data
,
2496 XSTRING (minibuf_prompt
)->size
, hpos
,
2497 /* Display a space if we truncate. */
2500 /* Truncate the prompt a little before the
2501 margin, so user input can at least start
2502 on the first line. */
2503 w
->width
> 10 ? w
->width
- 4 : -1)
2505 hpos
+= minibuf_prompt_width
;
2506 taboffset
-= minibuf_prompt_width
;
2509 minibuf_prompt_width
= 0;
2512 /* If we're hscrolled at all, use compute_motion to skip over any
2513 text off the left edge of the window. compute_motion may know
2514 tricks to do this faster than we can. */
2517 struct position
*left_edge
2518 = compute_motion (pos
, vpos
, hpos
, 0,
2520 width
, hscroll
, taboffset
, w
);
2522 /* Retrieve the buffer position and column provided by
2523 compute_motion. We can't assume that the column will be
2524 zero, because you may have multi-column characters crossing
2527 compute_motion may have moved us past the screen position we
2528 requested, if we hit a multi-column character, or the end of
2529 the line. If so, back up. */
2530 if (left_edge
->vpos
> vpos
2531 || left_edge
->hpos
> 0)
2533 pos
= left_edge
->bufpos
- 1;
2534 hpos
= left_edge
->prevhpos
;
2538 pos
= left_edge
->bufpos
;
2539 hpos
= left_edge
->hpos
;
2543 desired_glyphs
->bufp
[vpos
] = start
;
2544 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
2546 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
2547 /* In case we don't ever write anything into it... */
2548 desired_glyphs
->charstarts
[vpos
][XFASTINT (w
->left
)] = -1;
2549 leftmargin
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
2550 endp
= leftmargin
+ width
;
2552 /* Arrange the overlays nicely for our purposes. Usually, we call
2553 display_text_line on only one line at a time, in which case this
2554 can't really hurt too much, or we call it on lines which appear
2555 one after another in the buffer, in which case all calls to
2556 recenter_overlay_lists but the first will be pretty cheap. */
2557 recenter_overlay_lists (current_buffer
, pos
);
2559 /* Loop generating characters.
2560 Stop at end of buffer, before newline,
2561 if reach or pass continuation column,
2562 or at face change. */
2564 next_face_change
= pos
;
2565 next_boundary
= pos
;
2572 while (pos
== next_boundary
)
2574 Lisp_Object position
, limit
, prop
, ww
;
2576 /* Display the overlay strings here, unless we're at ZV
2577 and have already displayed the appropriate strings
2578 on an earlier line. */
2579 if (pos
< ZV
|| !zv_strings_seen
++)
2583 ovlen
= overlay_strings (pos
, w
, &ovstr
);
2584 for (; ovlen
; ovlen
--, ovstr
++)
2586 if (p1
>= leftmargin
&& p1
< endp
)
2587 *p1
= MAKE_GLYPH (f
, *ovstr
, current_face
);
2592 /* Did we reach point? Record the cursor location. */
2593 if (pos
== PT
&& cursor_vpos
< 0)
2596 cursor_hpos
= p1
- leftmargin
;
2602 XSETFASTINT (position
, pos
);
2603 limit
= Fnext_overlay_change (position
);
2604 #ifdef USE_TEXT_PROPERTIES
2605 /* This is just an estimate to give reasonable
2606 performance; nothing should go wrong if it is too small. */
2607 if (XFASTINT (limit
) > pos
+ 50)
2608 XSETFASTINT (limit
, pos
+ 50);
2609 limit
= Fnext_single_property_change (position
, Qinvisible
,
2610 Fcurrent_buffer (), limit
);
2612 next_boundary
= XFASTINT (limit
);
2613 /* if the `invisible' property is set, we can skip to
2614 the next property change. */
2616 prop
= Fget_char_property (position
, Qinvisible
, ww
);
2617 if (TEXT_PROP_MEANS_INVISIBLE (prop
))
2619 if (pos
< PT
&& next_boundary
>= PT
)
2622 cursor_hpos
= p1
- leftmargin
;
2624 pos
= next_boundary
;
2625 last_invis_skip
= pos
;
2626 last_invis_prop
= prop
;
2630 /* Did we reach point? Record the cursor location. */
2631 if (pos
== PT
&& cursor_vpos
< 0)
2634 cursor_hpos
= p1
- leftmargin
;
2637 /* Did we hit the end of the visible region of the buffer?
2641 /* Update charstarts for the end of this line. */
2642 /* Do nothing if off the left edge or at the right edge. */
2643 if (p1
>= leftmargin
&& p1
+ 1 != endp
)
2645 int *p2x
= &charstart
[(p1
< leftmargin
2654 /* Did we hit a face change? Figure out what face we should
2655 use now. We also hit this the first time through the
2656 loop, to see what face we should start with. */
2657 if (pos
>= next_face_change
&& FRAME_X_P (f
))
2658 current_face
= compute_char_face (f
, w
, pos
,
2659 region_beg
, region_end
,
2660 &next_face_change
, pos
+ 50, 0);
2665 if (pos
< next_boundary
&& next_boundary
< pause
)
2666 pause
= next_boundary
;
2667 if (pos
< next_face_change
&& next_face_change
< pause
)
2668 pause
= next_face_change
;
2670 /* Wouldn't you hate to read the next line to someone over
2672 if (pos
< PT
&& PT
< pause
)
2674 if (pos
< GPT
&& GPT
< pause
)
2677 p
= &FETCH_CHAR (pos
);
2686 /* Let a display table override all standard display methods. */
2687 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
2689 p1
= copy_part_of_rope (f
, p1
, leftmargin
,
2690 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
2691 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
2694 else if (c
>= 040 && c
< 0177)
2696 if (p1
>= leftmargin
)
2697 *p1
= MAKE_GLYPH (f
, c
, current_face
);
2703 if (last_invis_skip
== pos
2704 && TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (last_invis_prop
))
2708 && indented_beyond_p (pos
+ 1, selective
))
2711 pos
= find_next_newline (pos
+ 1, 1);
2712 if (FETCH_CHAR (pos
- 1) == '\n')
2715 if (invis
&& selective_rlen
> 0 && p1
>= leftmargin
)
2717 p1
+= selective_rlen
;
2718 if (p1
- leftmargin
> width
)
2720 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2721 (p1
- p1prev
), current_face
);
2724 /* Draw the face of the newline character as extending all the
2725 way to the end of the frame line. */
2728 if (p1
< leftmargin
)
2731 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2735 /* Update charstarts for the newline that ended this line. */
2736 /* Do nothing here for a char that's entirely off the left edge
2737 or if it starts at the right edge. */
2738 if (p1
>= leftmargin
&& p1prev
!= endp
)
2740 /* Store the newline's position into charstarts
2741 for the column where the newline starts.
2742 Store -1 for the rest of the glyphs it occupies. */
2743 int *p2x
= &charstart
[(p1prev
< leftmargin
2744 ? leftmargin
: p1prev
)
2746 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
2759 if (p1
>= leftmargin
&& p1
< endp
)
2760 *p1
= MAKE_GLYPH (f
, ' ', current_face
);
2763 while ((p1
- leftmargin
+ taboffset
+ hscroll
- (hscroll
> 0))
2766 else if (c
== Ctl ('M') && selective
== -1)
2768 pos
= find_next_newline (pos
, 1);
2769 if (FETCH_CHAR (pos
- 1) == '\n')
2771 if (selective_rlen
> 0)
2773 p1
+= selective_rlen
;
2774 if (p1
- leftmargin
> width
)
2776 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2777 (p1
- p1prev
), current_face
);
2780 /* Draw the face of the newline character as extending all the
2781 way to the end of the frame line. */
2784 if (p1
< leftmargin
)
2787 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2791 /* Update charstarts for the ^M that ended this line. */
2792 /* Do nothing here for a char that's entirely off the left edge
2793 or if it starts at the right edge. */
2794 if (p1
>= leftmargin
&& p1prev
!= endp
)
2796 /* Store the newline's position into charstarts
2797 for the column where the newline starts.
2798 Store -1 for the rest of the glyphs it occupies. */
2799 int *p2x
= &charstart
[(p1prev
< leftmargin
2800 ? leftmargin
: p1prev
)
2802 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
2810 else if (c
< 0200 && ctl_arrow
)
2812 if (p1
>= leftmargin
)
2813 *p1
= fix_glyph (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
2814 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
2817 if (p1
>= leftmargin
&& p1
< endp
)
2818 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
);
2823 if (p1
>= leftmargin
)
2824 *p1
= fix_glyph (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
2825 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
2828 if (p1
>= leftmargin
&& p1
< endp
)
2829 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
);
2831 if (p1
>= leftmargin
&& p1
< endp
)
2832 *p1
= MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
);
2834 if (p1
>= leftmargin
&& p1
< endp
)
2835 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
);
2842 /* Update charstarts for the character just output. */
2844 /* Do nothing here for a char that's entirely off the left edge. */
2845 if (p1
>= leftmargin
)
2847 /* Store the char's position into charstarts
2848 for the first glyph occupied by this char.
2849 Store -1 for the rest of the glyphs it occupies. */
2852 int *p2x
= &charstart
[(p1prev
< leftmargin
2853 ? leftmargin
: p1prev
)
2855 int *p2
= &charstart
[(p1
< endp
? p1
: endp
) - p1start
];
2865 val
.hpos
= - XINT (w
->hscroll
);
2873 /* Store 0 in this charstart line for the positions where
2874 there is no character. But do leave what was recorded
2875 for the character that ended the line. */
2876 /* Add 1 in the endtest to compensate for the fact that ENDP was
2877 made from WIDTH, which is 1 less than the window's actual
2879 i
= p1
- p1start
+ 1;
2880 if (p1
< leftmargin
)
2881 i
+= leftmargin
- p1
;
2882 for (; i
< endp
- p1start
+ 1; i
++)
2885 /* Handle continuation in middle of a character */
2886 /* by backing up over it */
2889 /* Don't back up if we never actually displayed any text.
2890 This occurs when the minibuffer prompt takes up the whole line. */
2893 /* Start the next line with that same character */
2895 /* but at negative hpos, to skip the columns output on this line. */
2896 val
.hpos
+= p1prev
- endp
;
2899 /* Keep in this line everything up to the continuation column. */
2903 /* Finish deciding which character to start the next line on,
2904 and what hpos to start it at.
2905 Also set `lastpos' to the last position which counts as "on this line"
2906 for cursor-positioning. */
2910 if (FETCH_CHAR (pos
) == '\n')
2912 /* If stopped due to a newline, start next line after it */
2914 /* Check again for hidden lines, in case the newline occurred exactly
2915 at the right margin. */
2916 while (pos
< ZV
&& selective
> 0
2917 && indented_beyond_p (pos
, selective
))
2918 pos
= find_next_newline (pos
, 1);
2921 /* Stopped due to right margin of window */
2925 *p1
++ = fix_glyph (f
, truncator
, 0);
2926 /* Truncating => start next line after next newline,
2927 and point is on this line if it is before the newline,
2928 and skip none of first char of next line */
2930 pos
= find_next_newline (pos
, 1);
2931 while (pos
< ZV
&& selective
> 0
2932 && indented_beyond_p (pos
, selective
));
2933 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2935 lastpos
= pos
- (FETCH_CHAR (pos
- 1) == '\n');
2939 *p1
++ = fix_glyph (f
, continuer
, 0);
2946 /* If point is at eol or in invisible text at eol,
2947 record its frame location now. */
2949 if (start
<= PT
&& PT
<= lastpos
&& cursor_vpos
< 0)
2952 cursor_hpos
= p1
- leftmargin
;
2955 if (cursor_vpos
== vpos
)
2957 if (cursor_hpos
< 0) cursor_hpos
= 0;
2958 if (cursor_hpos
> width
) cursor_hpos
= width
;
2959 cursor_hpos
+= XFASTINT (w
->left
);
2960 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2962 if (!(cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f
)
2963 && EQ (FRAME_MINIBUF_WINDOW (f
), minibuf_window
)))
2965 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2966 FRAME_CURSOR_X (f
) = cursor_hpos
;
2969 if (w
== XWINDOW (selected_window
))
2971 /* Line is not continued and did not start
2972 in middle of character */
2973 if ((hpos
- XFASTINT (w
->left
)
2974 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2977 this_line_bufpos
= start
;
2978 this_line_buffer
= current_buffer
;
2979 this_line_vpos
= cursor_vpos
;
2980 this_line_start_hpos
= hpos
;
2981 this_line_endpos
= Z
- lastpos
;
2984 this_line_bufpos
= 0;
2989 /* If hscroll and line not empty, insert truncation-at-left marker */
2990 if (hscroll
&& lastpos
!= start
)
2992 *leftmargin
= fix_glyph (f
, truncator
, 0);
2993 if (p1
<= leftmargin
)
2994 p1
= leftmargin
+ 1;
2997 if (XFASTINT (w
->width
) + XFASTINT (w
->left
) != FRAME_WIDTH (f
))
3000 if (p1
< leftmargin
) p1
= leftmargin
;
3001 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
3003 /* Don't draw vertical bars if we're using scroll bars. They're
3004 covered up by the scroll bars, and it's distracting to see
3005 them when the scroll bar windows are flickering around to be
3007 *p1
++ = (FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3009 : (dp
&& INTEGERP (DISP_BORDER_GLYPH (dp
))
3010 ? DISP_BORDER_GLYPH (dp
)
3013 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
3014 p1
- desired_glyphs
->glyphs
[vpos
]);
3015 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
3017 /* If the start of this line is the overlay arrow-position,
3018 then put the arrow string into the display-line. */
3020 if (MARKERP (Voverlay_arrow_position
)
3021 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
3022 && start
== marker_position (Voverlay_arrow_position
)
3023 && STRINGP (Voverlay_arrow_string
)
3024 && ! overlay_arrow_seen
)
3026 unsigned char *p
= XSTRING (Voverlay_arrow_string
)->data
;
3028 int len
= XSTRING (Voverlay_arrow_string
)->size
;
3034 if (!NULL_INTERVAL_P (XSTRING (Voverlay_arrow_string
)->intervals
))
3036 /* If the arrow string has text props, obey them when displaying. */
3037 for (i
= 0; i
< len
; i
++)
3040 Lisp_Object face
, ilisp
;
3043 XSETFASTINT (ilisp
, i
);
3044 face
= Fget_text_property (ilisp
, Qface
, Voverlay_arrow_string
);
3045 newface
= compute_glyph_face_1 (f
, face
, 0);
3046 leftmargin
[i
] = FAST_MAKE_GLYPH (c
, newface
);
3050 #endif /* HAVE_FACES */
3052 for (i
= 0; i
< len
; i
++)
3053 leftmargin
[i
] = p
[i
];
3056 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
3057 arrow_end
= (leftmargin
- desired_glyphs
->glyphs
[vpos
]) + len
;
3058 if (desired_glyphs
->used
[vpos
] < arrow_end
)
3059 desired_glyphs
->used
[vpos
] = arrow_end
;
3061 overlay_arrow_seen
= 1;
3065 val_display_text_line
= val
;
3066 return &val_display_text_line
;
3069 /* Redisplay the menu bar in the frame for window W. */
3072 display_menu_bar (w
)
3075 Lisp_Object items
, tail
;
3076 register int vpos
= 0;
3077 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3078 int maxendcol
= FRAME_WIDTH (f
);
3082 #ifndef USE_X_TOOLKIT
3083 if (FRAME_MENU_BAR_LINES (f
) <= 0)
3086 get_display_line (f
, vpos
, 0);
3088 items
= FRAME_MENU_BAR_ITEMS (f
);
3089 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 3)
3091 Lisp_Object pos
, string
;
3092 string
= XVECTOR (items
)->contents
[i
+ 1];
3096 XSETFASTINT (XVECTOR (items
)->contents
[i
+ 2], hpos
);
3098 if (hpos
< maxendcol
)
3099 hpos
= display_string (XWINDOW (FRAME_ROOT_WINDOW (f
)), vpos
,
3100 XSTRING (string
)->data
,
3101 XSTRING (string
)->size
,
3102 hpos
, 0, 0, hpos
, maxendcol
);
3103 /* Put a space between items. */
3104 if (hpos
< maxendcol
)
3106 int hpos1
= hpos
+ 1;
3107 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
3108 min (hpos1
, maxendcol
), maxendcol
);
3112 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
3113 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
3115 /* Fill out the line with spaces. */
3116 if (maxendcol
> hpos
)
3117 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
);
3119 /* Clear the rest of the lines allocated to the menu bar. */
3121 while (vpos
< FRAME_MENU_BAR_LINES (f
))
3122 get_display_line (f
, vpos
++, 0);
3123 #endif /* not USE_X_TOOLKIT */
3126 /* Display the mode line for window w */
3129 display_mode_line (w
)
3132 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
3133 register int left
= XFASTINT (w
->left
);
3134 register int right
= XFASTINT (w
->width
) + left
;
3135 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3137 line_number_displayed
= 0;
3138 w
->column_number_displayed
= Qnil
;
3140 get_display_line (f
, vpos
, left
);
3142 /* Temporarily make frame F's kboard the current kboard
3143 so that kboard-local variables in the mode_line_format
3144 will get the right values. */
3145 push_frame_kboard (f
);
3147 display_mode_element (w
, vpos
, left
, 0, right
, right
,
3148 current_buffer
->mode_line_format
);
3150 pop_frame_kboard ();
3152 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
3154 /* Make the mode line inverse video if the entire line
3155 is made of mode lines.
3156 I.e. if this window is full width,
3157 or if it is the child of a full width window
3158 (which implies that that window is split side-by-side
3159 and the rest of this line is mode lines of the sibling windows). */
3160 if (XFASTINT (w
->width
) == FRAME_WIDTH (f
)
3161 || XFASTINT (XWINDOW (w
->parent
)->width
) == FRAME_WIDTH (f
))
3162 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
3164 else if (! FRAME_TERMCAP_P (f
) && mode_line_inverse_video
)
3166 /* For a partial width window, explicitly set face of each glyph. */
3168 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
3169 for (i
= left
; i
< right
; ++i
)
3170 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1);
3175 /* Contribute ELT to the mode line for window W.
3176 How it translates into text depends on its data type.
3178 VPOS is the position of the mode line being displayed.
3180 HPOS is the position (absolute on frame) where this element's text
3181 should start. The output is truncated automatically at the right
3184 DEPTH is the depth in recursion. It is used to prevent
3185 infinite recursion here.
3187 MINENDCOL is the hpos before which the element may not end.
3188 The element is padded at the right with spaces if nec
3189 to reach this column.
3191 MAXENDCOL is the hpos past which this element may not extend.
3192 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
3193 (This is necessary to make nested padding and truncation work.)
3195 Returns the hpos of the end of the text generated by ELT.
3196 The next element will receive that value as its HPOS arg,
3197 so as to concatenate the elements. */
3200 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
3202 register int vpos
, hpos
;
3205 register int maxendcol
;
3206 register Lisp_Object elt
;
3214 switch (SWITCH_ENUM_CAST (XTYPE (elt
)))
3218 /* A string: output it and check for %-constructs within it. */
3219 register unsigned char c
;
3220 register unsigned char *this = XSTRING (elt
)->data
;
3222 while (hpos
< maxendcol
&& *this)
3224 unsigned char *last
= this;
3225 while ((c
= *this++) != '\0' && c
!= '%')
3227 if (this - 1 != last
)
3229 register int lim
= --this - last
+ hpos
;
3230 if (frame_title_ptr
)
3231 hpos
= store_frame_title (last
, hpos
, min (lim
, maxendcol
));
3233 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
3234 hpos
, min (lim
, maxendcol
));
3238 register int spec_width
= 0;
3240 /* We can't allow -ve args due to the "%-" construct */
3241 /* Argument specifies minwidth but not maxwidth
3242 (maxwidth can be specified by
3243 (<negative-number> . <stuff>) mode-line elements) */
3245 while ((c
= *this++) >= '0' && c
<= '9')
3247 spec_width
= spec_width
* 10 + (c
- '0');
3251 if (spec_width
> maxendcol
)
3252 spec_width
= maxendcol
;
3255 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
3256 spec_width
, maxendcol
,
3257 Vglobal_mode_string
);
3260 char *spec
= decode_mode_spec (w
, c
, maxendcol
- hpos
);
3261 if (frame_title_ptr
)
3262 hpos
= store_frame_title (spec
, spec_width
, maxendcol
);
3264 hpos
= display_string (w
, vpos
, spec
, -1,
3266 spec_width
, maxendcol
);
3274 /* A symbol: process the value of the symbol recursively
3275 as if it appeared here directly. Avoid error if symbol void.
3276 Special case: if value of symbol is a string, output the string
3279 register Lisp_Object tem
;
3280 tem
= Fboundp (elt
);
3283 tem
= Fsymbol_value (elt
);
3284 /* If value is a string, output that string literally:
3285 don't check for % within it. */
3288 if (frame_title_ptr
)
3289 hpos
= store_frame_title (XSTRING (tem
)->data
,
3290 minendcol
, maxendcol
);
3292 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
3293 XSTRING (tem
)->size
,
3294 hpos
, 0, 1, minendcol
, maxendcol
);
3296 /* Give up right away for nil or t. */
3297 else if (!EQ (tem
, elt
))
3298 { elt
= tem
; goto tail_recurse
; }
3305 register Lisp_Object car
, tem
;
3307 /* A cons cell: three distinct cases.
3308 If first element is a string or a cons, process all the elements
3309 and effectively concatenate them.
3310 If first element is a negative number, truncate displaying cdr to
3311 at most that many characters. If positive, pad (with spaces)
3312 to at least that many characters.
3313 If first element is a symbol, process the cadr or caddr recursively
3314 according to whether the symbol's value is non-nil or nil. */
3315 car
= XCONS (elt
)->car
;
3318 tem
= Fboundp (car
);
3319 elt
= XCONS (elt
)->cdr
;
3322 /* elt is now the cdr, and we know it is a cons cell.
3323 Use its car if CAR has a non-nil value. */
3326 tem
= Fsymbol_value (car
);
3328 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
3330 /* Symbol's value is nil (or symbol is unbound)
3331 Get the cddr of the original list
3332 and if possible find the caddr and use that. */
3333 elt
= XCONS (elt
)->cdr
;
3336 else if (!CONSP (elt
))
3338 elt
= XCONS (elt
)->car
;
3341 else if (INTEGERP (car
))
3343 register int lim
= XINT (car
);
3344 elt
= XCONS (elt
)->cdr
;
3346 /* Negative int means reduce maximum width.
3347 DO NOT change MINENDCOL here!
3348 (20 -10 . foo) should truncate foo to 10 col
3349 and then pad to 20. */
3350 maxendcol
= min (maxendcol
, hpos
- lim
);
3353 /* Padding specified. Don't let it be more than
3356 if (lim
> maxendcol
)
3358 /* If that's more padding than already wanted, queue it.
3359 But don't reduce padding already specified even if
3360 that is beyond the current truncation point. */
3361 if (lim
> minendcol
)
3366 else if (STRINGP (car
) || CONSP (car
))
3368 register int limit
= 50;
3369 /* LIMIT is to protect against circular lists. */
3370 while (CONSP (elt
) && --limit
> 0
3371 && hpos
< maxendcol
)
3373 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
3376 elt
= XCONS (elt
)->cdr
;
3384 if (frame_title_ptr
)
3385 hpos
= store_frame_title ("*invalid*", minendcol
, maxendcol
);
3387 hpos
= display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
3388 minendcol
, maxendcol
);
3392 if (minendcol
> hpos
)
3393 if (frame_title_ptr
)
3394 hpos
= store_frame_title ("", minendcol
, maxendcol
);
3396 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 1, minendcol
, maxendcol
);
3400 /* Return a string for the output of a mode line %-spec for window W,
3401 generated by character C and width MAXWIDTH. */
3403 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
3406 decode_mode_spec (w
, c
, maxwidth
)
3409 register int maxwidth
;
3412 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3413 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
3414 struct buffer
*b
= XBUFFER (w
->buffer
);
3417 if (maxwidth
> FRAME_WIDTH (f
))
3418 maxwidth
= FRAME_WIDTH (f
);
3423 if (!NILP (b
->read_only
))
3425 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
3430 /* This differs from %* only for a modified read-only buffer. */
3431 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
3433 if (!NILP (b
->read_only
))
3438 /* This differs from %* in ignoring read-only-ness. */
3439 if (BUF_MODIFF (b
) > BUF_SAVE_MODIFF (b
))
3451 if (command_loop_level
> 5)
3453 p
= decode_mode_spec_buf
;
3454 for (i
= 0; i
< command_loop_level
; i
++)
3457 return decode_mode_spec_buf
;
3465 if (command_loop_level
> 5)
3467 p
= decode_mode_spec_buf
;
3468 for (i
= 0; i
< command_loop_level
; i
++)
3471 return decode_mode_spec_buf
;
3479 if (maxwidth
< sizeof (lots_of_dashes
))
3480 return lots_of_dashes
;
3483 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
3487 return decode_mode_spec_buf
;
3493 if (maxwidth
>= 3 && XSTRING (obj
)->size
> maxwidth
)
3495 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
3496 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
3497 decode_mode_spec_buf
[maxwidth
] = '\0';
3498 return decode_mode_spec_buf
;
3505 int col
= current_column ();
3506 XSETFASTINT (w
->column_number_displayed
, col
);
3507 sprintf (decode_mode_spec_buf
, "%d", col
);
3508 return decode_mode_spec_buf
;
3512 /* %F displays the frame name. */
3514 return (char *) XSTRING (selected_frame
->name
)->data
;
3524 else if (STRINGP (obj
) && XSTRING (obj
)->size
> maxwidth
)
3526 bcopy ("...", decode_mode_spec_buf
, 3);
3527 bcopy (XSTRING (obj
)->data
+ XSTRING (obj
)->size
- maxwidth
+ 3,
3528 decode_mode_spec_buf
+ 3, maxwidth
- 3);
3529 return decode_mode_spec_buf
;
3536 int startpos
= marker_position (w
->start
);
3537 int line
, linepos
, topline
;
3540 int height
= XFASTINT (w
->height
);
3542 /* If we decided that this buffer isn't suitable for line numbers,
3543 don't forget that too fast. */
3544 if (EQ (w
->base_line_pos
, w
->buffer
))
3547 /* If the buffer is very big, don't waste time. */
3548 if (BUF_ZV (b
) - BUF_BEGV (b
) > line_number_display_limit
)
3550 w
->base_line_pos
= Qnil
;
3551 w
->base_line_number
= Qnil
;
3555 if (!NILP (w
->base_line_number
)
3556 && !NILP (w
->base_line_pos
)
3557 && XFASTINT (w
->base_line_pos
) <= marker_position (w
->start
))
3559 line
= XFASTINT (w
->base_line_number
);
3560 linepos
= XFASTINT (w
->base_line_pos
);
3565 linepos
= BUF_BEGV (b
);
3568 /* Count lines from base line to window start position. */
3569 nlines
= display_count_lines (linepos
, startpos
, startpos
, &junk
);
3571 topline
= nlines
+ line
;
3573 /* Determine a new base line, if the old one is too close
3574 or too far away, or if we did not have one.
3575 "Too close" means it's plausible a scroll-down would
3577 if (startpos
== BUF_BEGV (b
))
3579 XSETFASTINT (w
->base_line_number
, topline
);
3580 XSETFASTINT (w
->base_line_pos
, BUF_BEGV (b
));
3582 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
3583 || linepos
== BUF_BEGV (b
))
3585 int limit
= BUF_BEGV (b
);
3587 int distance
= (height
* 2 + 30) * 200;
3589 if (startpos
- distance
> limit
)
3590 limit
= startpos
- distance
;
3592 nlines
= display_count_lines (startpos
, limit
,
3595 /* If we couldn't find the lines we wanted within
3597 give up on line numbers for this window. */
3598 if (position
== startpos
- distance
)
3600 w
->base_line_pos
= w
->buffer
;
3601 w
->base_line_number
= Qnil
;
3605 XSETFASTINT (w
->base_line_number
, topline
- nlines
);
3606 XSETFASTINT (w
->base_line_pos
, position
);
3609 /* Now count lines from the start pos to point. */
3610 nlines
= display_count_lines (startpos
, PT
, PT
, &junk
);
3612 /* Record that we did display the line number. */
3613 line_number_displayed
= 1;
3615 /* Make the string to show. */
3616 sprintf (decode_mode_spec_buf
, "%d", topline
+ nlines
);
3617 return decode_mode_spec_buf
;
3626 if (BUF_BEGV (b
) > BUF_BEG (b
) || BUF_ZV (b
) < BUF_Z (b
))
3632 int pos
= marker_position (w
->start
);
3633 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
3635 if (XFASTINT (w
->window_end_pos
) <= BUF_Z (b
) - BUF_ZV (b
))
3637 if (pos
<= BUF_BEGV (b
))
3642 else if (pos
<= BUF_BEGV (b
))
3646 total
= ((pos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
3647 /* We can't normally display a 3-digit number,
3648 so get us a 2-digit number that is close. */
3651 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
3652 return decode_mode_spec_buf
;
3656 /* Display percentage of size above the bottom of the screen. */
3659 int toppos
= marker_position (w
->start
);
3660 int botpos
= BUF_Z (b
) - XFASTINT (w
->window_end_pos
);
3661 int total
= BUF_ZV (b
) - BUF_BEGV (b
);
3663 if (botpos
>= BUF_ZV (b
))
3665 if (toppos
<= BUF_BEGV (b
))
3672 total
= ((botpos
- BUF_BEGV (b
)) * 100 + total
- 1) / total
;
3673 /* We can't normally display a 3-digit number,
3674 so get us a 2-digit number that is close. */
3677 if (toppos
<= BUF_BEGV (b
))
3678 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
3680 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
3681 return decode_mode_spec_buf
;
3686 /* status of process */
3687 obj
= Fget_buffer_process (w
->buffer
);
3689 return "no process";
3691 obj
= Fsymbol_name (Fprocess_status (obj
));
3695 case 't': /* indicate TEXT or BINARY */
3696 #ifdef MODE_LINE_BINARY_TEXT
3697 return MODE_LINE_BINARY_TEXT (b
);
3704 return (char *) XSTRING (obj
)->data
;
3709 /* Search for COUNT instances of a line boundary, which means either a
3710 newline or (if selective display enabled) a carriage return.
3711 Start at START. If COUNT is negative, search backwards.
3713 If we find COUNT instances, set *SHORTAGE to zero, and return the
3714 position after the COUNTth match. Note that for reverse motion
3715 this is not the same as the usual convention for Emacs motion commands.
3717 If we don't find COUNT instances before reaching the end of the
3718 buffer (or the beginning, if scanning backwards), set *SHORTAGE to
3719 the number of line boundaries left unfound, and return the end of the
3720 buffer we bumped up against. */
3723 display_scan_buffer (start
, count
, shortage
)
3724 int *shortage
, start
;
3727 int limit
= ((count
> 0) ? ZV
- 1 : BEGV
);
3728 int direction
= ((count
> 0) ? 1 : -1);
3730 register unsigned char *cursor
;
3731 unsigned char *base
;
3733 register int ceiling
;
3734 register unsigned char *ceiling_addr
;
3736 /* If we are not in selective display mode,
3737 check only for newlines. */
3738 if (! (!NILP (current_buffer
->selective_display
)
3739 && !INTEGERP (current_buffer
->selective_display
)))
3740 return scan_buffer ('\n', start
, 0, count
, shortage
, 0);
3742 /* The code that follows is like scan_buffer
3743 but checks for either newline or carriage return. */
3749 while (start
!= limit
+ 1)
3751 ceiling
= BUFFER_CEILING_OF (start
);
3752 ceiling
= min (limit
, ceiling
);
3753 ceiling_addr
= &FETCH_CHAR (ceiling
) + 1;
3754 base
= (cursor
= &FETCH_CHAR (start
));
3757 while (*cursor
!= '\n' && *cursor
!= 015 && ++cursor
!= ceiling_addr
)
3759 if (cursor
!= ceiling_addr
)
3764 return (start
+ cursor
- base
+ 1);
3767 if (++cursor
== ceiling_addr
)
3773 start
+= cursor
- base
;
3777 start
--; /* first character we scan */
3778 while (start
> limit
- 1)
3779 { /* we WILL scan under start */
3780 ceiling
= BUFFER_FLOOR_OF (start
);
3781 ceiling
= max (limit
, ceiling
);
3782 ceiling_addr
= &FETCH_CHAR (ceiling
) - 1;
3783 base
= (cursor
= &FETCH_CHAR (start
));
3787 while (--cursor
!= ceiling_addr
3788 && *cursor
!= '\n' && *cursor
!= 015)
3790 if (cursor
!= ceiling_addr
)
3795 return (start
+ cursor
- base
+ 1);
3801 start
+= cursor
- base
;
3806 *shortage
= count
* direction
;
3807 return (start
+ ((direction
== 1 ? 0 : 1)));
3810 /* Count up to N lines starting from FROM.
3811 But don't go beyond LIMIT.
3812 Return the number of lines thus found (always positive).
3813 Store the position after what was found into *POS_PTR. */
3816 display_count_lines (from
, limit
, n
, pos_ptr
)
3829 *pos_ptr
= display_scan_buffer (from
, n
, &shortage
);
3835 /* When scanning backwards, scan_buffer stops *after* the last newline
3836 it finds, but does count it. Compensate for that. */
3837 return - n
- shortage
- (*pos_ptr
!= limit
);
3838 return n
- shortage
;
3841 /* Display STRING on one line of window W, starting at HPOS.
3842 Display at position VPOS. Caller should have done get_display_line.
3843 If VPOS == -1, display it as the current frame's title.
3844 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
3846 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
3848 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
3849 MAXCOL is the last column ok to end at. Truncate here.
3850 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
3851 Both count from the left edge of the frame, as does HPOS.
3852 The right edge of W is an implicit maximum.
3853 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
3855 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
3856 at the place where the current window ends in this line
3857 and not display anything beyond there. Otherwise, only MAXCOL
3858 controls where to stop output.
3860 Returns ending hpos. */
3863 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
3864 obey_window_width
, mincol
, maxcol
)
3866 unsigned char *string
;
3870 int obey_window_width
;
3875 int hscroll
= XINT (w
->hscroll
);
3876 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
3877 register GLYPH
*start
;
3878 register GLYPH
*end
;
3879 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3880 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3881 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3882 int window_width
= XFASTINT (w
->width
);
3884 /* Use the standard display table, not the window's display table.
3885 We don't want the mode line in rot13. */
3886 register struct Lisp_Vector
*dp
= 0;
3889 if (VECTORP (Vstandard_display_table
)
3890 && XVECTOR (Vstandard_display_table
)->size
== DISP_TABLE_SIZE
)
3891 dp
= XVECTOR (Vstandard_display_table
);
3893 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3896 start
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
3898 if (obey_window_width
)
3900 end
= start
+ window_width
- (truncate
!= 0);
3902 if ((window_width
+ XFASTINT (w
->left
)) != FRAME_WIDTH (f
))
3904 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3908 for (i
= 0; i
< FRAME_SCROLL_BAR_COLS (f
); i
++)
3916 if (! obey_window_width
3917 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
3918 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
3920 /* Store 0 in charstart for these columns. */
3921 for (i
= (hpos
>= 0 ? hpos
: 0); i
< end
- p1start
+ hpos
; i
++)
3922 desired_glyphs
->charstarts
[vpos
][i
] = 0;
3924 if (maxcol
>= 0 && mincol
> maxcol
)
3932 /* Specified length. */
3935 /* Unspecified length (null-terminated string). */
3939 if (dp
!= 0 && VECTORP (DISP_CHAR_VECTOR (dp
, c
)))
3941 p1
= copy_part_of_rope (f
, p1
, start
,
3942 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3943 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3946 else if (c
>= 040 && c
< 0177)
3956 if (p1
>= start
&& p1
< end
)
3960 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
3962 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
3965 *p1
= fix_glyph (f
, (dp
&& INTEGERP (DISP_CTRL_GLYPH (dp
))
3966 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3969 if (p1
>= start
&& p1
< end
)
3976 *p1
= fix_glyph (f
, (dp
&& INTEGERP (DISP_ESCAPE_GLYPH (dp
))
3977 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3980 if (p1
>= start
&& p1
< end
)
3981 *p1
= (c
>> 6) + '0';
3983 if (p1
>= start
&& p1
< end
)
3984 *p1
= (7 & (c
>> 3)) + '0';
3986 if (p1
>= start
&& p1
< end
)
3987 *p1
= (7 & c
) + '0';
3992 if (c
&& length
> 0)
3995 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
3997 else if (mincol
>= 0)
3999 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
4005 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
4007 if (len
> desired_glyphs
->used
[vpos
])
4008 desired_glyphs
->used
[vpos
] = len
;
4009 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
4015 /* This is like a combination of memq and assq.
4016 Return 1 if PROPVAL appears as an element of LIST
4017 or as the car of an element of LIST.
4018 If PROPVAL is a list, compare each element against LIST
4019 in that way, and return 1 if any element of PROPVAL is found in LIST.
4021 This function cannot quit. */
4024 invisible_p (propval
, list
)
4025 register Lisp_Object propval
;
4028 register Lisp_Object tail
, proptail
;
4029 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
4031 register Lisp_Object tem
;
4032 tem
= XCONS (tail
)->car
;
4033 if (EQ (propval
, tem
))
4035 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
4038 if (CONSP (propval
))
4039 for (proptail
= propval
; CONSP (proptail
);
4040 proptail
= XCONS (proptail
)->cdr
)
4042 Lisp_Object propelt
;
4043 propelt
= XCONS (proptail
)->car
;
4044 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
4046 register Lisp_Object tem
;
4047 tem
= XCONS (tail
)->car
;
4048 if (EQ (propelt
, tem
))
4050 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
4057 /* Return 1 if PROPVAL appears as the car of an element of LIST
4058 and the cdr of that element is non-nil.
4059 If PROPVAL is a list, check each element of PROPVAL in that way,
4060 and the first time some element is found,
4061 return 1 if the cdr of that element is non-nil.
4063 This function cannot quit. */
4066 invisible_ellipsis_p (propval
, list
)
4067 register Lisp_Object propval
;
4070 register Lisp_Object tail
, proptail
;
4071 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
4073 register Lisp_Object tem
;
4074 tem
= XCONS (tail
)->car
;
4075 if (CONSP (tem
) && EQ (propval
, XCONS (tem
)->car
))
4076 return ! NILP (XCONS (tem
)->cdr
);
4078 if (CONSP (propval
))
4079 for (proptail
= propval
; CONSP (proptail
);
4080 proptail
= XCONS (proptail
)->cdr
)
4082 Lisp_Object propelt
;
4083 propelt
= XCONS (proptail
)->car
;
4084 for (tail
= list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
4086 register Lisp_Object tem
;
4087 tem
= XCONS (tail
)->car
;
4088 if (CONSP (tem
) && EQ (propelt
, XCONS (tem
)->car
))
4089 return ! NILP (XCONS (tem
)->cdr
);
4098 staticpro (&Qmenu_bar_update_hook
);
4099 Qmenu_bar_update_hook
= intern ("menu-bar-update-hook");
4101 staticpro (&Qoverriding_terminal_local_map
);
4102 Qoverriding_terminal_local_map
= intern ("overriding-terminal-local-map");
4104 staticpro (&Qoverriding_local_map
);
4105 Qoverriding_local_map
= intern ("overriding-local-map");
4107 staticpro (&last_arrow_position
);
4108 staticpro (&last_arrow_string
);
4109 last_arrow_position
= Qnil
;
4110 last_arrow_string
= Qnil
;
4112 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
4113 "String (or mode line construct) included (normally) in `mode-line-format'.");
4114 Vglobal_mode_string
= Qnil
;
4116 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
4117 "Marker for where to display an arrow on top of the buffer text.\n\
4118 This must be the beginning of a line in order to work.\n\
4119 See also `overlay-arrow-string'.");
4120 Voverlay_arrow_position
= Qnil
;
4122 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
4123 "String to display as an arrow. See also `overlay-arrow-position'.");
4124 Voverlay_arrow_string
= Qnil
;
4126 DEFVAR_INT ("scroll-step", &scroll_step
,
4127 "*The number of lines to try scrolling a window by when point moves out.\n\
4128 If that fails to bring point back on frame, point is centered instead.\n\
4129 If this is zero, point is always centered after it moves off frame.");
4131 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
4133 DEFVAR_BOOL ("truncate-partial-width-windows",
4134 &truncate_partial_width_windows
,
4135 "*Non-nil means truncate lines in all windows less than full frame wide.");
4136 truncate_partial_width_windows
= 1;
4138 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
4139 "*Non-nil means use inverse video for the mode line.");
4140 mode_line_inverse_video
= 1;
4142 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
4143 "*Maximum buffer size for which line number should be displayed.");
4144 line_number_display_limit
= 1000000;
4146 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
4147 "*Non-nil means highlight region even in nonselected windows.");
4148 highlight_nonselected_windows
= 1;
4150 DEFVAR_BOOL ("multiple-frames", &multiple_frames
,
4151 "Non-nil if more than one frame is visible on this display.\n\
4152 Minibuffer-only frames don't count, but iconified frames do.\n\
4153 This variable is not guaranteed to be accurate except while parsing\n\
4154 frame-title-format.");
4156 DEFVAR_LISP ("frame-title-format", &Vframe_title_format
,
4157 "Template for displaying the titlebar of visible frames.\n\
4158 \(Assuming the window manager supports this feature.)\n\
4159 This variable has the same structure as `mode-line-format' (which see),\n\
4160 and is used only on frames for which no explicit name has been set\n\
4161 \(see `modify-frame-parameters').");
4162 DEFVAR_LISP ("icon-title-format", &Vicon_title_format
,
4163 "Template for displaying the titlebar of an iconified frame.\n\
4164 \(Assuming the window manager supports this feature.)\n\
4165 This variable has the same structure as `mode-line-format' (which see),\n\
4166 and is used only on frames for which no explicit name has been set\n\
4167 \(see `modify-frame-parameters').");
4169 = Vframe_title_format
4170 = Fcons (intern ("multiple-frames"),
4171 Fcons (build_string ("%b"),
4172 Fcons (Fcons (build_string (""),
4173 Fcons (intern ("invocation-name"),
4174 Fcons (build_string ("@"),
4175 Fcons (intern ("system-name"),
4179 DEFVAR_LISP ("message-log-max", &Vmessage_log_max
,
4180 "Maximum number of lines to keep in the message log buffer.\n\
4181 If nil, disable message logging. If t, log messages but don't truncate\n\
4182 the buffer when it becomes large.");
4183 XSETFASTINT (Vmessage_log_max
, 50);
4185 DEFVAR_LISP ("window-size-change-functions", &Vwindow_size_change_functions
,
4186 "Functions called before redisplay, if window sizes have changed.\n\
4187 The value should be a list of functions that take one argument.\n\
4188 Just before redisplay, for each frame, if any of its windows have changed\n\
4189 size since the last redisplay, or have been split or deleted,\n\
4190 all the functions in the list are called, with the frame as argument.");
4191 Vwindow_size_change_functions
= Qnil
;
4194 /* initialize the window system */
4197 Lisp_Object root_window
;
4198 #ifndef COMPILER_REGISTER_BUG
4200 #endif /* COMPILER_REGISTER_BUG */
4201 struct window
*mini_w
;
4203 this_line_bufpos
= 0;
4205 mini_w
= XWINDOW (minibuf_window
);
4206 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
4208 echo_area_glyphs
= 0;
4209 previous_echo_glyphs
= 0;
4211 if (!noninteractive
)
4213 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
4214 XSETFASTINT (XWINDOW (root_window
)->top
, 0);
4215 set_window_height (root_window
, FRAME_HEIGHT (f
) - 1, 0);
4216 XSETFASTINT (mini_w
->top
, FRAME_HEIGHT (f
) - 1);
4217 set_window_height (minibuf_window
, 1, 0);
4219 XSETFASTINT (XWINDOW (root_window
)->width
, FRAME_WIDTH (f
));
4220 XSETFASTINT (mini_w
->width
, FRAME_WIDTH (f
));