1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1985, 86, 87, 88, 93, 94 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"
39 extern void set_frame_menubar ();
42 extern int interrupt_input
;
43 extern int command_loop_level
;
45 /* Nonzero means print newline before next minibuffer message. */
47 int noninteractive_need_newline
;
49 #define min(a, b) ((a) < (b) ? (a) : (b))
50 #define max(a, b) ((a) > (b) ? (a) : (b))
52 /* The buffer position of the first character appearing
53 entirely or partially on the current frame line.
54 Or zero, which disables the optimization for the current frame line. */
55 static int this_line_bufpos
;
57 /* Number of characters past the end of this line,
58 including the terminating newline */
59 static int this_line_endpos
;
61 /* The vertical position of this frame line. */
62 static int this_line_vpos
;
64 /* Hpos value for start of display on this frame line.
65 Usually zero, but negative if first character really began
67 static int this_line_start_hpos
;
69 /* Buffer that this_line variables are describing. */
70 static struct buffer
*this_line_buffer
;
72 /* Set by try_window_id to the vpos of first of any lines
73 scrolled on to the bottom of the frame. These lines should
74 not be included in any general scroll computation. */
75 static int scroll_bottom_vpos
;
77 /* Value of echo_area_glyphs when it was last acted on.
78 If this is nonzero, there is a message on the frame
79 in the minibuffer and it should be erased as soon
80 as it is no longer requested to appear. */
81 char *previous_echo_glyphs
;
83 /* Nonzero means truncate lines in all windows less wide than the frame */
84 int truncate_partial_width_windows
;
86 Lisp_Object Vglobal_mode_string
;
88 /* Marker for where to display an arrow on top of the buffer text. */
89 Lisp_Object Voverlay_arrow_position
;
91 /* String to display for the arrow. */
92 Lisp_Object Voverlay_arrow_string
;
94 /* Values of those variables at last redisplay. */
95 static Lisp_Object last_arrow_position
, last_arrow_string
;
97 /* Nonzero if overlay arrow has been displayed once in this window. */
98 static int overlay_arrow_seen
;
100 /* Nonzero means highlight the region even in nonselected windows. */
101 static int highlight_nonselected_windows
;
103 /* If cursor motion alone moves point off frame,
104 Try scrolling this many lines up or down if that will bring it back. */
107 /* Nonzero if try_window_id has made blank lines at window bottom
108 since the last redisplay that paused */
109 static int blank_end_of_window
;
111 /* Number of windows showing the buffer of the selected window.
112 keyboard.c refers to this. */
115 /* display_text_line sets these to the frame position (origin 0) of point,
116 whether the window is selected or not.
117 Set one to -1 first to determine whether point was found afterwards. */
119 static int cursor_vpos
;
120 static int cursor_hpos
;
124 /* Nonzero means display mode line highlighted */
125 int mode_line_inverse_video
;
127 static void echo_area_display ();
128 void mark_window_display_accurate ();
129 static void redisplay_windows ();
130 static void redisplay_window ();
131 static void update_menu_bars ();
132 static void update_menu_bar ();
133 static void try_window ();
134 static int try_window_id ();
135 static struct position
*display_text_line ();
136 static void display_mode_line ();
137 static int display_mode_element ();
138 static char *fmodetrunc ();
139 static char *decode_mode_spec ();
140 static int display_string ();
141 static void display_menu_bar ();
142 static int display_count_lines ();
144 /* Prompt to display in front of the minibuffer contents */
145 char *minibuf_prompt
;
147 /* Width in columns of current minibuffer prompt. */
148 int minibuf_prompt_width
;
150 /* Message to display instead of minibuffer contents
151 This is what the functions error and message make,
152 and command echoing uses it as well.
153 It overrides the minibuf_prompt as well as the buffer. */
154 char *echo_area_glyphs
;
156 /* This is the length of the message in echo_area_glyphs. */
157 int echo_area_glyphs_length
;
159 /* true iff we should redraw the mode lines on the next redisplay */
160 int update_mode_lines
;
162 /* Smallest number of characters before the gap
163 at any time since last redisplay that finished.
164 Valid for current buffer when try_window_id can be called. */
167 /* Smallest number of characters after the gap
168 at any time since last redisplay that finished.
169 Valid for current buffer when try_window_id can be called. */
172 /* MODIFF as of last redisplay that finished;
173 if it matches MODIFF, beg_unchanged and end_unchanged
174 contain no useful information */
175 int unchanged_modified
;
177 /* Nonzero if head_clip or tail_clip of current buffer has changed
178 since last redisplay that finished */
181 /* Nonzero if window sizes or contents have changed
182 since last redisplay that finished */
183 int windows_or_buffers_changed
;
185 /* Nonzero after display_mode_line if %l was used
186 and it displayed a line number. */
187 int line_number_displayed
;
189 /* Maximum buffer size for which to display line numbers. */
190 int line_number_display_limit
;
192 /* Display an echo area message M with a specified length of LEN chars.
193 The string may include null characters. If m is 0, clear out any
194 existing message, and let the minibuffer text show through.
195 Do not pass text that is stored in a Lisp string. */
204 if (noninteractive_need_newline
)
206 noninteractive_need_newline
= 0;
207 fwrite (m
, len
, 1, stderr
);
208 if (cursor_in_echo_area
== 0)
209 fprintf (stderr
, "\n");
212 /* A null message buffer means that the frame hasn't really been
213 initialized yet. Error messages get reported properly by
214 cmd_error, so this must be just an informative message; toss it. */
215 else if (INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
218 Lisp_Object minibuf_frame
;
220 choose_minibuf_frame ();
221 minibuf_frame
= WINDOW_FRAME (XWINDOW (minibuf_window
));
222 FRAME_SAMPLE_VISIBILITY (XFRAME (minibuf_frame
));
223 if (FRAME_VISIBLE_P (selected_frame
)
224 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame
)))
225 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window
)));
230 echo_area_glyphs
= m
;
231 echo_area_glyphs_length
= len
;
234 echo_area_glyphs
= previous_echo_glyphs
= 0;
236 do_pending_window_change ();
237 echo_area_display ();
238 update_frame (XFRAME (XWINDOW (minibuf_window
)->frame
), 1, 1);
239 do_pending_window_change ();
240 if (frame_up_to_date_hook
!= 0 && ! gc_in_progress
)
241 (*frame_up_to_date_hook
) (XFRAME (XWINDOW (minibuf_window
)->frame
));
249 message2 (m
, (m
? strlen (m
) : 0));
252 /* Truncate what will be displayed in the echo area
253 the next time we display it--but don't redisplay it now. */
256 truncate_echo_area (len
)
259 /* A null message buffer means that the frame hasn't really been
260 initialized yet. Error messages get reported properly by
261 cmd_error, so this must be just an informative message; toss it. */
262 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
263 echo_area_glyphs_length
= len
;
266 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
267 zero if being used by message. */
268 int message_buf_print
;
270 /* Dump an informative message to the minibuf. If m is 0, clear out
271 any existing message, and let the minibuffer text show through. */
274 message (m
, a1
, a2
, a3
)
281 if (noninteractive_need_newline
)
283 noninteractive_need_newline
= 0;
284 fprintf (stderr
, m
, a1
, a2
, a3
);
285 if (cursor_in_echo_area
== 0)
286 fprintf (stderr
, "\n");
290 else if (INTERACTIVE
)
292 /* The frame whose minibuffer we're going to display the message on.
293 It may be larger than the selected frame, so we need
294 to use its buffer, not the selected frame's buffer. */
295 FRAME_PTR echo_frame
;
297 choose_minibuf_frame ();
298 echo_frame
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
300 echo_frame
= selected_frame
;
303 /* A null message buffer means that the frame hasn't really been
304 initialized yet. Error messages get reported properly by
305 cmd_error, so this must be just an informative message; toss it. */
306 if (FRAME_MESSAGE_BUF (echo_frame
))
317 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
318 FRAME_WIDTH (echo_frame
), m
, 0, 3, a
);
320 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
321 FRAME_WIDTH (echo_frame
), m
, 0, 3, &a1
);
322 #endif /* NO_ARG_ARRAY */
324 message2 (FRAME_MESSAGE_BUF (echo_frame
), len
);
329 /* Print should start at the beginning of the message
331 message_buf_print
= 0;
343 choose_minibuf_frame ();
346 f
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
348 if (! FRAME_VISIBLE_P (f
))
353 redraw_garbaged_frames ();
357 if (echo_area_glyphs
|| minibuf_level
== 0)
359 vpos
= XFASTINT (XWINDOW (minibuf_window
)->top
);
360 get_display_line (f
, vpos
, 0);
361 display_string (XWINDOW (minibuf_window
), vpos
,
362 echo_area_glyphs
? echo_area_glyphs
: "",
363 echo_area_glyphs
? echo_area_glyphs_length
: -1,
364 0, 0, 0, 0, FRAME_WIDTH (f
));
366 /* If desired cursor location is on this line, put it at end of text */
367 if (FRAME_CURSOR_Y (f
) == vpos
)
368 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
370 /* Fill the rest of the minibuffer window with blank lines. */
375 i
< vpos
+ XFASTINT (XWINDOW (minibuf_window
)->height
); i
++)
377 get_display_line (f
, i
, 0);
378 display_string (XWINDOW (minibuf_window
), vpos
,
379 "", 0, 0, 0, 0, 0, FRAME_WIDTH (f
));
383 else if (!EQ (minibuf_window
, selected_window
))
384 windows_or_buffers_changed
++;
386 if (EQ (minibuf_window
, selected_window
))
387 this_line_bufpos
= 0;
389 previous_echo_glyphs
= echo_area_glyphs
;
392 #ifdef HAVE_X_WINDOWS
393 /* I'm trying this out because I saw Unimpress use it, but it's
394 possible that this may mess adversely with some window managers. -jla
396 Wouldn't it be nice to use something like mode-line-format to
397 describe frame titles? -JimB */
399 /* Change the title of the frame to the name of the buffer displayed
400 in the currently selected window. Don't do this for minibuffer frames,
401 and don't do it when there's only one non-minibuffer frame. */
403 x_consider_frame_title (frame
)
406 FRAME_PTR f
= XFRAME (frame
);
408 if (FRAME_X_P (f
) && ! FRAME_MINIBUF_ONLY_P (f
))
413 if (! EQ (Fnext_frame (frame
, Qnil
), frame
))
414 title
= XBUFFER (XWINDOW (f
->selected_window
)->buffer
)->name
;
416 x_implicitly_set_name (f
, title
, Qnil
);
421 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
422 This can't be done in `redisplay' itself because it can call eval. */
427 register struct window
*w
= XWINDOW (selected_window
);
433 /* Set the visible flags for all frames.
434 Do this before checking for resized or garbaged frames; they want
435 to know if their frames are visible.
436 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
438 Lisp_Object tail
, frame
;
440 FOR_EACH_FRAME (tail
, frame
)
441 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
444 /* Notice any pending interrupt request to change frame size. */
445 do_pending_window_change ();
449 redraw_garbaged_frames ();
453 if (clip_changed
|| windows_or_buffers_changed
)
456 /* Detect case that we need to write a star in the mode line. */
457 if (XFASTINT (w
->last_modified
) < MODIFF
458 && XFASTINT (w
->last_modified
) <= current_buffer
->save_modified
)
460 w
->update_mode_line
= Qt
;
461 if (buffer_shared
> 1)
465 all_windows
= update_mode_lines
|| buffer_shared
> 1;
467 /* If specs for an arrow have changed, do thorough redisplay
468 to ensure we remove any arrow that should no longer exist. */
469 if (! EQ (Voverlay_arrow_position
, last_arrow_position
)
470 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
471 all_windows
= 1, clip_changed
= 1;
473 /* Update the menu bar item lists, if appropriate.
474 This has to be done before any actual redisplay
475 or generation of display lines. */
478 Lisp_Object tail
, frame
;
480 FOR_EACH_FRAME (tail
, frame
)
482 FRAME_PTR f
= XFRAME (frame
);
484 if (FRAME_VISIBLE_P (f
))
485 update_menu_bars (FRAME_ROOT_WINDOW (f
));
488 else if (FRAME_VISIBLE_P (selected_frame
))
489 update_menu_bar (selected_window
);
492 /* Do a frame update, taking possible shortcuts into account.
493 This is the main external entry point for redisplay.
495 If the last redisplay displayed an echo area message and that
496 message is no longer requested, we clear the echo area
497 or bring back the minibuffer if that is in use.
499 Do not call eval from within this function.
500 Calls to eval after the call to echo_area_display would confuse
501 the display_line mechanism and would cause a crash.
502 Calls to eval before that point will work most of the time,
503 but can still lose, because this function
504 can be called from signal handlers; with alarms set up;
505 or with synchronous processes running.
507 See Fcall_process; if you called it from here, it could be
508 entered recursively. */
510 static int do_verify_charstarts
;
515 register struct window
*w
= XWINDOW (selected_window
);
519 register int tlbufpos
, tlendpos
;
521 extern int input_pending
;
526 /* Set the visible flags for all frames.
527 Do this before checking for resized or garbaged frames; they want
528 to know if their frames are visible.
529 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
531 Lisp_Object tail
, frame
;
533 FOR_EACH_FRAME (tail
, frame
)
534 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
537 /* Notice any pending interrupt request to change frame size. */
538 do_pending_window_change ();
542 redraw_garbaged_frames ();
546 if (clip_changed
|| windows_or_buffers_changed
)
549 /* Detect case that we need to write a star in the mode line. */
550 if (XFASTINT (w
->last_modified
) < MODIFF
551 && XFASTINT (w
->last_modified
) <= current_buffer
->save_modified
)
553 w
->update_mode_line
= Qt
;
554 if (buffer_shared
> 1)
558 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
560 all_windows
= update_mode_lines
|| buffer_shared
> 1;
562 /* If specs for an arrow have changed, do thorough redisplay
563 to ensure we remove any arrow that should no longer exist. */
564 if (! EQ (Voverlay_arrow_position
, last_arrow_position
)
565 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
566 all_windows
= 1, clip_changed
= 1;
568 /* Normally the message* functions will have already displayed and
569 updated the echo area, but the frame may have been trashed, or
570 the update may have been preempted, so display the echo area
572 if (echo_area_glyphs
|| previous_echo_glyphs
)
574 echo_area_display ();
578 /* If showing region, and mark has changed, must redisplay whole window. */
579 if (((!NILP (Vtransient_mark_mode
)
580 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
581 != !NILP (w
->region_showing
))
582 || (!NILP (w
->region_showing
)
583 && !EQ (w
->region_showing
,
584 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
585 this_line_bufpos
= -1;
587 tlbufpos
= this_line_bufpos
;
588 tlendpos
= this_line_endpos
;
589 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
590 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
591 /* Make sure recorded data applies to current buffer, etc */
592 && this_line_buffer
== current_buffer
593 && current_buffer
== XBUFFER (w
->buffer
)
594 && NILP (w
->force_start
)
595 /* Point must be on the line that we have info recorded about */
597 && point
<= Z
- tlendpos
598 /* All text outside that line, including its final newline,
600 && (XFASTINT (w
->last_modified
) >= MODIFF
601 || (beg_unchanged
>= tlbufpos
- 1
603 /* If selective display, can't optimize
604 if the changes start at the beginning of the line. */
605 && ((XTYPE (current_buffer
->selective_display
) == Lisp_Int
606 && XINT (current_buffer
->selective_display
) > 0
607 ? (beg_unchanged
>= tlbufpos
610 && end_unchanged
>= tlendpos
611 && Z
- GPT
>= tlendpos
)))
613 if (tlbufpos
> BEGV
&& FETCH_CHAR (tlbufpos
- 1) != '\n'
615 || FETCH_CHAR (tlbufpos
) == '\n'))
616 /* Former continuation line has disappeared by becoming empty */
618 else if (XFASTINT (w
->last_modified
) < MODIFF
619 || MINI_WINDOW_P (w
))
622 overlay_arrow_seen
= 0;
623 display_text_line (w
, tlbufpos
, this_line_vpos
, this_line_start_hpos
,
624 pos_tab_offset (w
, tlbufpos
));
625 /* If line contains point, is not continued,
626 and ends at same distance from eob as before, we win */
627 if (cursor_vpos
>= 0 && this_line_bufpos
628 && this_line_endpos
== tlendpos
)
630 /* If this is not the window's last line,
631 we must adjust the charstarts of the lines below. */
632 if (this_line_vpos
+ 1
633 < XFASTINT (w
->top
) + window_internal_height (w
))
635 int left
= XFASTINT (w
->left
);
636 int *charstart_next_line
637 = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w
)))->charstarts
[this_line_vpos
+ 1];
641 if (Z
- tlendpos
== ZV
)
642 /* This line ends at end of (accessible part of) buffer.
643 There is no newline to count. */
644 adjust
= Z
- tlendpos
- charstart_next_line
[left
];
646 /* This line ends in a newline.
647 Must take account of the newline and the rest of the
648 text that follows. */
649 adjust
= Z
- tlendpos
+ 1 - charstart_next_line
[left
];
651 adjust_window_charstarts (w
, this_line_vpos
, adjust
);
654 if (XFASTINT (w
->width
) != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w
))))
655 preserve_other_columns (w
);
661 else if (point
== XFASTINT (w
->last_point
))
665 do_pending_window_change ();
670 /* If highlighting the region, we can't just move the cursor. */
671 else if (! (!NILP (Vtransient_mark_mode
)
672 && !NILP (current_buffer
->mark_active
))
673 && NILP (w
->region_showing
))
675 pos
= *compute_motion (tlbufpos
, 0,
676 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
677 point
, 2, - (1 << (SHORTBITS
- 1)),
678 window_internal_width (w
) - 1,
680 pos_tab_offset (w
, tlbufpos
), w
);
683 FRAME_CURSOR_X (selected_frame
)
684 = XFASTINT (w
->left
) + max (pos
.hpos
, 0);
685 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
692 /* Text changed drastically or point moved off of line */
693 cancel_line (this_line_vpos
, selected_frame
);
696 this_line_bufpos
= 0;
697 all_windows
|= buffer_shared
> 1;
701 Lisp_Object tail
, frame
;
703 #ifdef HAVE_X_WINDOWS
704 /* Since we're doing a thorough redisplay, we might as well
705 recompute all our display faces. */
706 clear_face_vector ();
709 /* Recompute # windows showing selected buffer.
710 This will be incremented each time such a window is displayed. */
713 FOR_EACH_FRAME (tail
, frame
)
715 FRAME_PTR f
= XFRAME (frame
);
717 /* Mark all the scroll bars to be removed; we'll redeem the ones
718 we want when we redisplay their windows. */
719 if (condemn_scroll_bars_hook
)
720 (*condemn_scroll_bars_hook
) (f
);
722 if (FRAME_VISIBLE_P (f
))
723 redisplay_windows (FRAME_ROOT_WINDOW (f
));
724 #ifdef HAVE_X_WINDOWS
725 else if (FRAME_ICONIFIED_P (f
)
726 && ! MINI_WINDOW_P (XWINDOW (f
->selected_window
)))
727 x_consider_frame_title (frame
);
730 /* Any scroll bars which redisplay_windows should have nuked
731 should now go away. */
732 if (judge_scroll_bars_hook
)
733 (*judge_scroll_bars_hook
) (f
);
736 else if (FRAME_VISIBLE_P (selected_frame
))
738 redisplay_window (selected_window
, 1);
739 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
740 preserve_other_columns (w
);
744 /* Prevent various kinds of signals during display update.
745 stdio is not robust about handling signals,
746 which can cause an apparent I/O error. */
758 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
762 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
765 f
= XFRAME (XCONS (tail
)->car
);
766 if (FRAME_VISIBLE_P (f
))
768 pause
|= update_frame (f
, 0, 0);
771 mark_window_display_accurate (f
->root_window
, 1);
772 if (frame_up_to_date_hook
!= 0)
773 (*frame_up_to_date_hook
) (f
);
779 #endif /* MULTI_FRAME */
781 if (FRAME_VISIBLE_P (selected_frame
))
782 pause
= update_frame (selected_frame
, 0, 0);
784 /* We may have called echo_area_display at the top of this
785 function. If the echo area is on another frame, that may
786 have put text on a frame other than the selected one, so the
787 above call to update_frame would not have caught it. Catch
791 = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
793 if (mini_frame
!= selected_frame
)
794 pause
|= update_frame (mini_frame
, 0, 0);
798 /* If frame does not match, prevent doing single-line-update next time.
799 Also, don't forget to check every line to update the arrow. */
802 this_line_bufpos
= 0;
803 if (!NILP (last_arrow_position
))
805 last_arrow_position
= Qt
;
806 last_arrow_string
= Qt
;
808 /* If we pause after scrolling, some lines in current_frame
809 may be null, so preserve_other_columns won't be able to
810 preserve all the vertical-bar separators. So, avoid using it
812 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
813 update_mode_lines
= 1;
816 /* Now text on frame agrees with windows, so
817 put info into the windows for partial redisplay to follow */
821 register struct buffer
*b
= XBUFFER (w
->buffer
);
823 blank_end_of_window
= 0;
825 unchanged_modified
= BUF_MODIFF (b
);
826 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
827 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
829 XFASTINT (w
->last_point
) = BUF_PT (b
);
830 XFASTINT (w
->last_point_x
) = FRAME_CURSOR_X (selected_frame
);
831 XFASTINT (w
->last_point_y
) = FRAME_CURSOR_Y (selected_frame
);
834 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
837 w
->update_mode_line
= Qnil
;
838 XFASTINT (w
->last_modified
) = BUF_MODIFF (b
);
839 w
->window_end_valid
= w
->buffer
;
840 last_arrow_position
= Voverlay_arrow_position
;
841 last_arrow_string
= Voverlay_arrow_string
;
842 if (do_verify_charstarts
)
843 verify_charstarts (w
);
844 if (frame_up_to_date_hook
!= 0)
845 (*frame_up_to_date_hook
) (selected_frame
);
847 update_mode_lines
= 0;
848 windows_or_buffers_changed
= 0;
851 /* Start SIGIO interrupts coming again.
852 Having them off during the code above
853 makes it less likely one will discard output,
854 but not impossible, since there might be stuff
855 in the system buffer here.
856 But it is much hairier to try to do anything about that. */
862 /* Change frame size now if a change is pending. */
863 do_pending_window_change ();
866 /* Redisplay, but leave alone any recent echo area message
867 unless another message has been requested in its place.
869 This is useful in situations where you need to redisplay but no
870 user action has occurred, making it inappropriate for the message
871 area to be cleared. See tracking_off and
872 wait_reading_process_input for examples of these situations. */
874 redisplay_preserve_echo_area ()
876 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
878 echo_area_glyphs
= previous_echo_glyphs
;
880 echo_area_glyphs
= 0;
887 mark_window_display_accurate (window
, flag
)
891 register struct window
*w
;
893 for (;!NILP (window
); window
= w
->next
)
895 if (XTYPE (window
) != Lisp_Window
) abort ();
896 w
= XWINDOW (window
);
898 if (!NILP (w
->buffer
))
900 XFASTINT (w
->last_modified
)
902 : XBUFFER (w
->buffer
) == current_buffer
903 ? MODIFF
: BUF_MODIFF (XBUFFER (w
->buffer
));
905 /* Record if we are showing a region, so can make sure to
906 update it fully at next redisplay. */
907 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
908 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
909 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
913 w
->window_end_valid
= w
->buffer
;
914 w
->update_mode_line
= Qnil
;
916 if (!NILP (w
->vchild
))
917 mark_window_display_accurate (w
->vchild
, flag
);
918 if (!NILP (w
->hchild
))
919 mark_window_display_accurate (w
->hchild
, flag
);
924 last_arrow_position
= Voverlay_arrow_position
;
925 last_arrow_string
= Voverlay_arrow_string
;
929 /* t is unequal to any useful value of Voverlay_arrow_... */
930 last_arrow_position
= Qt
;
931 last_arrow_string
= Qt
;
935 /* Update the menu bar item lists for WINDOW
936 and its subwindows and siblings.
937 This has to be done before we start to fill in any display lines,
938 because it can call eval. */
941 update_menu_bars (window
)
944 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
945 update_menu_bar (window
);
948 /* Update the menu bar item list for window WINDOW and its subwindows. */
951 update_menu_bar (window
)
954 register struct window
*w
= XWINDOW (window
);
955 struct buffer
*old
= current_buffer
;
956 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
958 /* If this is a combination window, do its children; that's all. */
960 if (!NILP (w
->vchild
))
962 update_menu_bars (w
->vchild
);
965 if (!NILP (w
->hchild
))
967 update_menu_bars (w
->hchild
);
970 if (NILP (w
->buffer
))
973 if (update_mode_lines
)
974 w
->update_mode_line
= Qt
;
976 /* When we reach a frame's selected window, redo the frame's menu bar. */
977 if (!NILP (w
->update_mode_line
)
979 && FRAME_EXTERNAL_MENU_BAR (f
)
981 && FRAME_MENU_BAR_LINES (f
) > 0
983 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
985 /* If the user has switched buffers or windows, we need to
986 recompute to reflect the new bindings. But we'll
987 recompute when update_mode_lines is set too; that means
988 that people can use force-mode-line-update to request
989 that the menu bar be recomputed. The adverse effect on
990 the rest of the redisplay algorithm is about the same as
991 windows_or_buffers_changed anyway. */
992 if (windows_or_buffers_changed
994 || (XFASTINT (w
->last_modified
) < MODIFF
995 && (XFASTINT (w
->last_modified
)
996 <= XBUFFER (w
->buffer
)->save_modified
)))
998 struct buffer
*prev
= current_buffer
;
999 current_buffer
= XBUFFER (w
->buffer
);
1000 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
1001 current_buffer
= prev
;
1002 #ifdef USE_X_TOOLKIT
1003 set_frame_menubar (f
, 0);
1004 #endif /* USE_X_TOOLKIT */
1011 /* Redisplay WINDOW and its subwindows and siblings. */
1014 redisplay_windows (window
)
1017 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
1018 redisplay_window (window
, 0);
1021 /* Redisplay window WINDOW and its subwindows. */
1024 redisplay_window (window
, just_this_one
)
1028 register struct window
*w
= XWINDOW (window
);
1029 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1031 register int lpoint
= point
;
1032 struct buffer
*old
= current_buffer
;
1033 register int width
= window_internal_width (w
) - 1;
1034 register int startp
;
1035 register int hscroll
= XINT (w
->hscroll
);
1036 struct position pos
;
1039 int window_needs_modeline
;
1041 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1043 /* If this is a combination window, do its children; that's all. */
1045 if (!NILP (w
->vchild
))
1047 redisplay_windows (w
->vchild
);
1050 if (!NILP (w
->hchild
))
1052 redisplay_windows (w
->hchild
);
1055 if (NILP (w
->buffer
))
1058 height
= window_internal_height (w
);
1060 if (MINI_WINDOW_P (w
))
1062 if (w
== XWINDOW (minibuf_window
))
1064 if (echo_area_glyphs
)
1065 /* We've already displayed the echo area glyphs, if any. */
1066 goto finish_scroll_bars
;
1070 /* This is a minibuffer, but it's not the currently active one, so
1072 int vpos
= XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f
))->top
);
1075 for (i
= 0; i
< height
; i
++)
1077 get_display_line (f
, vpos
+ i
, 0);
1078 display_string (w
, vpos
+ i
, "", 0, 0, 0, 1, 0, width
);
1081 goto finish_scroll_bars
;
1085 if (update_mode_lines
)
1086 w
->update_mode_line
= Qt
;
1088 /* Otherwise set up data on this window; select its buffer and point value */
1090 current_buffer
= XBUFFER (w
->buffer
);
1093 /* Count number of windows showing the selected buffer. */
1096 && current_buffer
== XBUFFER (XWINDOW (selected_window
)->buffer
))
1099 /* POINT refers normally to the selected window.
1100 For any other window, set up appropriate value. */
1102 if (!EQ (window
, selected_window
))
1104 SET_PT (marker_position (w
->pointm
));
1108 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1110 else if (point
> (ZV
- 1))
1113 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1117 /* If window-start is screwed up, choose a new one. */
1118 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1121 startp
= marker_position (w
->start
);
1123 /* Handle case where place to start displaying has been specified,
1124 unless the specified location is outside the accessible range. */
1125 if (!NILP (w
->force_start
))
1127 /* Forget any recorded base line for line number display. */
1128 w
->base_line_number
= Qnil
;
1129 w
->update_mode_line
= Qt
;
1130 w
->force_start
= Qnil
;
1131 XFASTINT (w
->last_modified
) = 0;
1132 if (startp
< BEGV
) startp
= BEGV
;
1133 if (startp
> ZV
) startp
= ZV
;
1134 try_window (window
, startp
);
1135 if (cursor_vpos
< 0)
1137 /* ??? What should happen here if highlighting a region? */
1138 /* If point does not appear, move point so it does appear */
1139 pos
= *compute_motion (startp
, 0,
1140 ((EQ (window
, minibuf_window
) && startp
== 1)
1141 ? minibuf_prompt_width
: 0)
1143 (hscroll
? 1 - hscroll
: 0),
1145 - (1 << (SHORTBITS
- 1)),
1146 width
, hscroll
, pos_tab_offset (w
, startp
), w
);
1147 SET_PT (pos
.bufpos
);
1148 if (w
!= XWINDOW (selected_window
))
1149 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1152 if (current_buffer
== old
)
1154 FRAME_CURSOR_X (f
) = max (0, pos
.hpos
) + XFASTINT (w
->left
);
1155 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1161 /* Handle case where text has not changed, only point,
1162 and it has not moved off the frame */
1164 /* This code is not used for minibuffer for the sake of
1165 the case of redisplaying to replace an echo area message;
1166 since in that case the minibuffer contents per se are usually unchanged.
1167 This code is of no real use in the minibuffer since
1168 the handling of this_line_bufpos, etc.,
1169 in redisplay handles the same cases. */
1171 if (XFASTINT (w
->last_modified
) >= MODIFF
1172 && point
>= startp
&& !clip_changed
1173 && (just_this_one
|| XFASTINT (w
->width
) == FRAME_WIDTH (f
))
1174 /* Can't use this case if highlighting a region. */
1175 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
1176 && NILP (w
->region_showing
)
1177 && !EQ (window
, minibuf_window
))
1179 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0),
1180 point
, height
+ 1, 10000, width
, hscroll
,
1181 pos_tab_offset (w
, startp
), w
);
1183 if (pos
.vpos
< height
)
1185 /* Ok, point is still on frame */
1186 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
1188 /* These variables are supposed to be origin 1 */
1189 FRAME_CURSOR_X (f
) = max (0, pos
.hpos
) + XFASTINT (w
->left
);
1190 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1192 /* This doesn't do the trick, because if a window to the right of
1193 this one must be redisplayed, this does nothing because there
1194 is nothing in DesiredFrame yet, and then the other window is
1195 redisplayed, making likes that are empty in this window's columns.
1196 if (XFASTINT (w->width) != FRAME_WIDTH (f))
1197 preserve_my_columns (w);
1201 /* Don't bother trying redisplay with same start;
1202 we already know it will lose */
1204 /* If current starting point was originally the beginning of a line
1205 but no longer is, find a new starting point. */
1206 else if (!NILP (w
->start_at_line_beg
)
1208 || FETCH_CHAR (startp
- 1) == '\n'))
1212 else if (just_this_one
&& !MINI_WINDOW_P (w
)
1214 && XFASTINT (w
->last_modified
)
1215 /* or else vmotion on first line won't work. */
1216 && ! NILP (w
->start_at_line_beg
)
1217 && ! EQ (w
->window_end_valid
, Qnil
)
1218 && do_id
&& !clip_changed
1219 && !blank_end_of_window
1220 && XFASTINT (w
->width
) == FRAME_WIDTH (f
)
1221 /* Can't use this case if highlighting a region. */
1222 && !(!NILP (Vtransient_mark_mode
)
1223 && !NILP (current_buffer
->mark_active
))
1224 && NILP (w
->region_showing
)
1225 && EQ (last_arrow_position
, Voverlay_arrow_position
)
1226 && EQ (last_arrow_string
, Voverlay_arrow_string
)
1227 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
1230 /* tem > 0 means success. tem == -1 means choose new start.
1231 tem == -2 means try again with same start,
1232 and nothing but whitespace follows the changed stuff.
1233 tem == 0 means try again with same start. */
1237 else if (startp
>= BEGV
&& startp
<= ZV
1238 /* Avoid starting display at end of buffer! */
1239 && (startp
< ZV
|| startp
== BEGV
1240 || (XFASTINT (w
->last_modified
) >= MODIFF
)))
1242 /* Try to redisplay starting at same place as before */
1243 /* If point has not moved off frame, accept the results */
1244 try_window (window
, startp
);
1245 if (cursor_vpos
>= 0)
1247 if (!just_this_one
|| clip_changed
|| beg_unchanged
< startp
)
1248 /* Forget any recorded base line for line number display. */
1249 w
->base_line_number
= Qnil
;
1253 cancel_my_columns (w
);
1256 XFASTINT (w
->last_modified
) = 0;
1257 w
->update_mode_line
= Qt
;
1259 /* Try to scroll by specified few lines */
1261 if (scroll_step
&& !clip_changed
)
1265 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
),
1266 scroll_step
, width
, hscroll
, window
);
1267 if (pos
.vpos
>= height
)
1271 pos
= *vmotion (startp
, point
< startp
? - scroll_step
: scroll_step
,
1272 width
, hscroll
, window
);
1274 if (point
>= pos
.bufpos
)
1276 try_window (window
, pos
.bufpos
);
1277 if (cursor_vpos
>= 0)
1279 if (!just_this_one
|| clip_changed
|| beg_unchanged
< startp
)
1280 /* Forget any recorded base line for line number display. */
1281 w
->base_line_number
= Qnil
;
1285 cancel_my_columns (w
);
1290 /* Finally, just choose place to start which centers point */
1293 /* Forget any previously recorded base line for line number display. */
1294 w
->base_line_number
= Qnil
;
1296 pos
= *vmotion (point
, - (height
/ 2), width
, hscroll
, window
);
1297 try_window (window
, pos
.bufpos
);
1299 startp
= marker_position (w
->start
);
1300 w
->start_at_line_beg
=
1301 (startp
== BEGV
|| FETCH_CHAR (startp
- 1) == '\n') ? Qt
: Qnil
;
1304 if ((!NILP (w
->update_mode_line
)
1305 /* If window not full width, must redo its mode line
1306 if the window to its side is being redone */
1307 || (!just_this_one
&& width
< FRAME_WIDTH (f
) - 1)
1308 || INTEGERP (w
->base_line_pos
))
1309 && height
!= XFASTINT (w
->height
))
1310 display_mode_line (w
);
1311 if (! line_number_displayed
1312 && ! BUFFERP (w
->base_line_pos
))
1314 w
->base_line_pos
= Qnil
;
1315 w
->base_line_number
= Qnil
;
1318 /* When we reach a frame's selected window, redo the frame's menu bar. */
1319 if (!NILP (w
->update_mode_line
)
1320 #ifdef USE_X_TOOLKIT
1321 && FRAME_EXTERNAL_MENU_BAR (f
)
1323 && FRAME_MENU_BAR_LINES (f
) > 0
1325 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
1326 display_menu_bar (w
);
1329 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1331 int start
, end
, whole
;
1333 /* Calculate the start and end positions for the current window.
1334 At some point, it would be nice to choose between scrollbars
1335 which reflect the whole buffer size, with special markers
1336 indicating narrowing, and scrollbars which reflect only the
1339 Note that minibuffers sometimes aren't displaying any text. */
1340 if (! MINI_WINDOW_P (w
)
1341 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
1344 start
= startp
- BEGV
;
1345 /* I don't think this is guaranteed to be right. For the
1346 moment, we'll pretend it is. */
1347 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
1349 if (end
< start
) end
= start
;
1350 if (whole
< (end
- start
)) whole
= end
- start
;
1353 start
= end
= whole
= 0;
1355 /* Indicate what this scroll bar ought to be displaying now. */
1356 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
1358 /* Note that we actually used the scroll bar attached to this window,
1359 so it shouldn't be deleted at the end of redisplay. */
1360 (*redeem_scroll_bar_hook
) (w
);
1364 current_buffer
= old
;
1368 /* Do full redisplay on one window, starting at position `pos'. */
1371 try_window (window
, pos
)
1375 register struct window
*w
= XWINDOW (window
);
1376 register int height
= window_internal_height (w
);
1377 register int vpos
= XFASTINT (w
->top
);
1378 register int last_text_vpos
= vpos
;
1379 int tab_offset
= pos_tab_offset (w
, pos
);
1380 FRAME_PTR f
= XFRAME (w
->frame
);
1381 int width
= window_internal_width (w
) - 1;
1382 struct position val
;
1384 Fset_marker (w
->start
, make_number (pos
), Qnil
);
1386 overlay_arrow_seen
= 0;
1387 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
1389 while (--height
>= 0)
1391 val
= *display_text_line (w
, pos
, vpos
, val
.hpos
, tab_offset
);
1392 tab_offset
+= width
;
1393 if (val
.vpos
) tab_offset
= 0;
1395 if (pos
!= val
.bufpos
)
1397 /* Next line, unless prev line ended in end of buffer with no cr */
1398 = vpos
- (val
.vpos
&& (FETCH_CHAR (val
.bufpos
- 1) != '\n'
1399 #ifdef USE_TEXT_PROPERTIES
1400 || ! NILP (Fget_char_property (val
.bufpos
-1,
1408 /* If last line is continued in middle of character,
1409 include the split character in the text considered on the frame */
1410 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
1413 /* If bottom just moved off end of frame, change mode line percentage. */
1414 if (XFASTINT (w
->window_end_pos
) == 0
1416 w
->update_mode_line
= Qt
;
1418 /* Say where last char on frame will be, once redisplay is finished. */
1419 XFASTINT (w
->window_end_pos
) = Z
- pos
;
1420 XFASTINT (w
->window_end_vpos
) = last_text_vpos
- XFASTINT (w
->top
);
1421 /* But that is not valid info until redisplay finishes. */
1422 w
->window_end_valid
= Qnil
;
1425 /* Try to redisplay when buffer is modified locally,
1426 computing insert/delete line to preserve text outside
1427 the bounds of the changes.
1428 Return 1 if successful, 0 if if cannot tell what to do,
1429 or -1 to tell caller to find a new window start,
1430 or -2 to tell caller to do normal redisplay with same window start. */
1433 try_window_id (window
)
1437 register struct window
*w
= XWINDOW (window
);
1438 register int height
= window_internal_height (w
);
1439 FRAME_PTR f
= XFRAME (w
->frame
);
1440 int top
= XFASTINT (w
->top
);
1441 int start
= marker_position (w
->start
);
1442 int width
= window_internal_width (w
) - 1;
1443 int hscroll
= XINT (w
->hscroll
);
1444 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
1446 register int i
, tem
;
1447 int last_text_vpos
= 0;
1450 = XTYPE (current_buffer
->selective_display
) == Lisp_Int
1451 ? XINT (current_buffer
->selective_display
)
1452 : !NILP (current_buffer
->selective_display
) ? -1 : 0;
1454 struct position val
, bp
, ep
, xp
, pp
;
1455 int scroll_amount
= 0;
1457 int tab_offset
, epto
;
1459 if (GPT
- BEG
< beg_unchanged
)
1460 beg_unchanged
= GPT
- BEG
;
1461 if (Z
- GPT
< end_unchanged
)
1462 end_unchanged
= Z
- GPT
;
1464 if (beg_unchanged
+ BEG
< start
)
1465 return 0; /* Give up if changes go above top of window */
1467 /* Find position before which nothing is changed. */
1468 bp
= *compute_motion (start
, 0, lmargin
,
1469 min (ZV
, beg_unchanged
+ BEG
), height
+ 1, 0,
1470 width
, hscroll
, pos_tab_offset (w
, start
), w
);
1471 if (bp
.vpos
>= height
)
1473 if (point
< bp
.bufpos
&& !bp
.contin
)
1475 /* All changes are below the frame, and point is on the frame.
1476 We don't need to change the frame at all.
1477 But we need to update window_end_pos to account for
1478 any change in buffer size. */
1479 bp
= *compute_motion (start
, 0, lmargin
,
1481 width
, hscroll
, pos_tab_offset (w
, start
), w
);
1482 XFASTINT (w
->window_end_vpos
) = height
;
1483 XFASTINT (w
->window_end_pos
) = Z
- bp
.bufpos
;
1491 /* Find beginning of that frame line. Must display from there. */
1492 bp
= *vmotion (bp
.bufpos
, 0, width
, hscroll
, window
);
1499 /* If about to start displaying at the beginning of a continuation line,
1500 really start with previous frame line, in case it was not
1501 continued when last redisplayed */
1502 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
1504 /* Likewise if we have to worry about selective display. */
1505 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
1507 bp
= *vmotion (bp
.bufpos
, -1, width
, hscroll
, window
);
1512 if (bp
.contin
&& bp
.hpos
!= lmargin
)
1514 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
1520 /* Find first visible newline after which no more is changed. */
1521 tem
= find_next_newline (Z
- max (end_unchanged
, Z
- ZV
), 1);
1523 while (tem
< ZV
- 1 && (indented_beyond_p (tem
, selective
)))
1524 tem
= find_next_newline (tem
, 1);
1526 /* Compute the cursor position after that newline. */
1527 ep
= *compute_motion (pos
, vpos
, val
.hpos
, tem
,
1528 height
, - (1 << (SHORTBITS
- 1)),
1529 width
, hscroll
, pos_tab_offset (w
, bp
.bufpos
), w
);
1531 /* If changes reach past the text available on the frame,
1532 just display rest of frame. */
1533 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
1536 stop_vpos
= ep
.vpos
;
1538 /* If no newline before ep, the line ep is on includes some changes
1539 that must be displayed. Make sure we don't stop before it. */
1540 /* Also, if changes reach all the way until ep.bufpos,
1541 it is possible that something was deleted after the
1542 newline before it, so the following line must be redrawn. */
1543 if (stop_vpos
== ep
.vpos
1544 && (ep
.bufpos
== BEGV
1545 || FETCH_CHAR (ep
.bufpos
- 1) != '\n'
1546 || ep
.bufpos
== Z
- end_unchanged
))
1547 stop_vpos
= ep
.vpos
+ 1;
1550 overlay_arrow_seen
= 0;
1552 /* If changes do not reach to bottom of window,
1553 figure out how much to scroll the rest of the window */
1554 if (stop_vpos
< height
)
1556 /* Now determine how far up or down the rest of the window has moved */
1557 epto
= pos_tab_offset (w
, ep
.bufpos
);
1558 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
,
1559 Z
- XFASTINT (w
->window_end_pos
),
1560 10000, 0, width
, hscroll
, epto
, w
);
1561 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
1563 /* Is everything on frame below the changes whitespace?
1564 If so, no scrolling is really necessary. */
1565 for (i
= ep
.bufpos
; i
< xp
.bufpos
; i
++)
1567 tem
= FETCH_CHAR (i
);
1568 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
1574 XFASTINT (w
->window_end_vpos
) += scroll_amount
;
1576 /* Before doing any scrolling, verify that point will be on frame. */
1577 if (point
> ep
.bufpos
&& !(point
<= xp
.bufpos
&& xp
.bufpos
< height
))
1579 if (point
<= xp
.bufpos
)
1581 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
,
1582 point
, height
, - (1 << (SHORTBITS
- 1)),
1583 width
, hscroll
, epto
, w
);
1587 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
,
1588 point
, height
, - (1 << (SHORTBITS
- 1)),
1590 pos_tab_offset (w
, xp
.bufpos
), w
);
1592 if (pp
.bufpos
< point
|| pp
.vpos
== height
)
1594 cursor_vpos
= pp
.vpos
+ top
;
1595 cursor_hpos
= pp
.hpos
+ XFASTINT (w
->left
);
1598 if (stop_vpos
- scroll_amount
>= height
1599 || ep
.bufpos
== xp
.bufpos
)
1601 if (scroll_amount
< 0)
1602 stop_vpos
-= scroll_amount
;
1604 /* In this path, we have altered window_end_vpos
1605 and not left it negative.
1606 We must make sure that, in case display is preempted
1607 before the frame changes to reflect what we do here,
1608 further updates will not come to try_window_id
1609 and assume the frame and window_end_vpos match. */
1610 blank_end_of_window
= 1;
1612 else if (!scroll_amount
)
1614 /* Even if we don't need to scroll, we must adjust the
1615 charstarts of subsequent lines (that we won't redisplay)
1616 according to the amount of text inserted or deleted. */
1617 int oldpos
= FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
1618 int adjust
= ep
.bufpos
- oldpos
;
1619 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1, adjust
);
1621 else if (bp
.bufpos
== Z
- end_unchanged
)
1623 /* If reprinting everything is nearly as fast as scrolling,
1624 don't bother scrolling. Can happen if lines are short. */
1625 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
1626 top
+ height
- max (0, scroll_amount
),
1628 > xp
.bufpos
- bp
.bufpos
- 20)
1629 /* Return "try normal display with same window-start."
1630 Too bad we can't prevent further scroll-thinking. */
1632 /* If pure deletion, scroll up as many lines as possible.
1633 In common case of killing a line, this can save the
1634 following line from being overwritten by scrolling
1635 and therefore having to be redrawn. */
1636 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
1637 top
+ height
- max (0, scroll_amount
),
1638 scroll_amount
, bp
.bufpos
);
1643 /* scroll_frame_lines did not properly adjust subsequent
1644 lines' charstarts in the case where the text of the
1645 screen line at bp.vpos has changed.
1646 (This can happen in a deletion that ends in mid-line.)
1647 To adjust properly, we need to make things constent at
1649 So do a second adjust to make that happen.
1650 Note that stop_vpos >= ep.vpos, so it is sufficient
1651 to update the charstarts for lines at ep.vpos and below. */
1653 = FRAME_CURRENT_GLYPHS (f
)->charstarts
[ep
.vpos
+ top
][0];
1654 adjust_window_charstarts (w
, ep
.vpos
+ top
- 1,
1655 ep
.bufpos
- oldstart
);
1658 else if (scroll_amount
)
1660 /* If reprinting everything is nearly as fast as scrolling,
1661 don't bother scrolling. Can happen if lines are short. */
1662 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
1663 overestimate of cost of reprinting, since xp.bufpos
1664 would end up below the bottom of the window. */
1665 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
1666 top
+ height
- max (0, scroll_amount
),
1668 > xp
.bufpos
- ep
.bufpos
- 20)
1669 /* Return "try normal display with same window-start."
1670 Too bad we can't prevent further scroll-thinking. */
1672 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
1673 top
+ height
- max (0, scroll_amount
),
1674 scroll_amount
, ep
.bufpos
);
1675 if (!tem
) stop_vpos
= height
;
1679 /* In any case, do not display past bottom of window */
1680 if (stop_vpos
>= height
)
1686 /* Handle case where pos is before w->start --
1687 can happen if part of line had been clipped and is not clipped now */
1688 if (vpos
== 0 && pos
< marker_position (w
->start
))
1689 Fset_marker (w
->start
, make_number (pos
), Qnil
);
1691 /* Redisplay the lines where the text was changed */
1692 last_text_vpos
= vpos
;
1693 tab_offset
= pos_tab_offset (w
, pos
);
1694 /* If we are starting display in mid-character, correct tab_offset
1695 to account for passing the line that that character really starts in. */
1696 if (val
.hpos
< lmargin
)
1697 tab_offset
+= width
;
1698 while (vpos
< stop_vpos
)
1700 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
1701 tab_offset
+= width
;
1702 if (val
.vpos
) tab_offset
= 0;
1703 if (pos
!= val
.bufpos
)
1705 /* Next line, unless prev line ended in end of buffer with no cr */
1706 = vpos
- (val
.vpos
&& FETCH_CHAR (val
.bufpos
- 1) != '\n');
1710 /* There are two cases:
1711 1) we have displayed down to the bottom of the window
1712 2) we have scrolled lines below stop_vpos by scroll_amount */
1716 /* If last line is continued in middle of character,
1717 include the split character in the text considered on the frame */
1718 if (val
.hpos
< lmargin
)
1720 XFASTINT (w
->window_end_vpos
) = last_text_vpos
;
1721 XFASTINT (w
->window_end_pos
) = Z
- val
.bufpos
;
1724 /* If scrolling made blank lines at window bottom,
1725 redisplay to fill those lines */
1726 if (scroll_amount
< 0)
1728 /* Don't consider these lines for general-purpose scrolling.
1729 That will save time in the scrolling computation. */
1730 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
1735 vpos
= height
+ scroll_amount
;
1736 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
1738 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
1742 blank_end_of_window
= 1;
1743 tab_offset
= pos_tab_offset (w
, pos
);
1744 /* If we are starting display in mid-character, correct tab_offset
1745 to account for passing the line that that character starts in. */
1746 if (val
.hpos
< lmargin
)
1747 tab_offset
+= width
;
1749 while (vpos
< height
)
1751 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
1752 tab_offset
+= width
;
1753 if (val
.vpos
) tab_offset
= 0;
1757 /* Here is a case where display_text_line sets cursor_vpos wrong.
1758 Make it be fixed up, below. */
1760 && xp
.bufpos
== point
)
1764 /* If bottom just moved off end of frame, change mode line percentage. */
1765 if (XFASTINT (w
->window_end_pos
) == 0
1767 w
->update_mode_line
= Qt
;
1769 /* Attempt to adjust end-of-text positions to new bottom line */
1772 delta
= height
- xp
.vpos
;
1774 || (delta
> 0 && xp
.bufpos
<= ZV
)
1775 || (delta
== 0 && xp
.hpos
))
1777 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
),
1778 delta
, width
, hscroll
, window
);
1779 XFASTINT (w
->window_end_pos
) = Z
- val
.bufpos
;
1780 XFASTINT (w
->window_end_vpos
) += val
.vpos
;
1784 w
->window_end_valid
= Qnil
;
1786 /* If point was not in a line that was displayed, find it */
1787 if (cursor_vpos
< 0)
1789 val
= *compute_motion (start
, 0, lmargin
, point
, 10000, 10000,
1790 width
, hscroll
, pos_tab_offset (w
, start
), w
);
1791 /* Admit failure if point is off frame now */
1792 if (val
.vpos
>= height
)
1794 for (vpos
= 0; vpos
< height
; vpos
++)
1795 cancel_line (vpos
+ top
, f
);
1798 cursor_vpos
= val
.vpos
+ top
;
1799 cursor_hpos
= val
.hpos
+ XFASTINT (w
->left
);
1802 FRAME_CURSOR_X (f
) = max (0, cursor_hpos
);
1803 FRAME_CURSOR_Y (f
) = cursor_vpos
;
1807 val
= *compute_motion (start
, 0, lmargin
, ZV
,
1808 height
, - (1 << (SHORTBITS
- 1)),
1809 width
, hscroll
, pos_tab_offset (w
, start
), w
);
1810 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
1812 if (XFASTINT (w
->window_end_pos
)
1820 /* Mark a section of BUF as modified, but only for the sake of redisplay.
1821 This is useful for recording changes to overlays.
1823 We increment the buffer's modification timestamp and set the
1824 redisplay caches (windows_or_buffers_changed, beg_unchanged, etc)
1825 as if the region of text between START and END had been modified;
1826 the redisplay code will check this against the windows' timestamps,
1827 and redraw the appropriate area of the buffer.
1829 However, if the buffer is unmodified, we bump the last-save
1830 timestamp as well, so that incrementing the timestamp doesn't fool
1831 Emacs into thinking that the buffer's text has been modified.
1833 Tweaking the timestamps shouldn't hurt the first-modification
1834 timestamps recorded in the undo records; those values aren't
1835 written until just before a real text modification is made, so they
1836 will never catch the timestamp value just before this function gets
1840 redisplay_region (buf
, start
, end
)
1850 start
= end
; end
= temp
;
1853 if (buf
!= current_buffer
)
1854 windows_or_buffers_changed
= 1;
1857 if (unchanged_modified
== MODIFF
)
1859 beg_unchanged
= start
- BEG
;
1860 end_unchanged
= Z
- end
;
1864 if (Z
- end
< end_unchanged
)
1865 end_unchanged
= Z
- end
;
1866 if (start
- BEG
< beg_unchanged
)
1867 beg_unchanged
= start
- BEG
;
1871 /* Increment the buffer's time stamp, but also increment the save
1872 and autosave timestamps, so as not to screw up that timekeeping. */
1873 if (BUF_MODIFF (buf
) == buf
->save_modified
)
1874 buf
->save_modified
++;
1875 if (BUF_MODIFF (buf
) == buf
->auto_save_modified
)
1876 buf
->auto_save_modified
++;
1878 BUF_MODIFF (buf
) ++;
1882 /* Copy LEN glyphs starting address FROM to the rope TO.
1883 But don't actually copy the parts that would come in before S.
1884 Value is TO, advanced past the copied data.
1885 F is the frame we are displaying in. */
1888 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
1890 register GLYPH
*to
; /* Copy to here. */
1891 register GLYPH
*s
; /* Starting point. */
1892 Lisp_Object
*from
; /* Data to copy. */
1894 int face
; /* Face to apply to glyphs which don't specify one. */
1897 register Lisp_Object
*fp
= from
;
1898 /* These cache the results of the last call to compute_glyph_face. */
1900 int last_merged
= 0;
1902 #ifdef HAVE_X_WINDOWS
1903 if (! FRAME_TERMCAP_P (f
))
1906 int glyph
= XFASTINT (*fp
);
1909 if (FAST_GLYPH_FACE (glyph
) == 0)
1910 /* If GLYPH has no face code, use FACE. */
1912 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
1913 /* If it's same as previous glyph, use same result. */
1914 facecode
= last_merged
;
1917 /* Merge this glyph's face and remember the result. */
1918 last_code
= FAST_GLYPH_FACE (glyph
);
1919 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
1923 *to
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), facecode
);
1931 if (to
>= s
) *to
= XFASTINT (*fp
);
1938 /* Correct a glyph by replacing its specified user-level face code
1939 with a displayable computed face code. */
1942 fix_glyph (f
, glyph
, current_face
)
1947 #ifdef HAVE_X_WINDOWS
1948 if (! FRAME_TERMCAP_P (f
) && FAST_GLYPH_FACE (glyph
) != 0)
1949 return FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
),
1950 compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
),
1956 /* Display one line of window w, starting at position START in W's buffer.
1957 Display starting at horizontal position HPOS, which is normally zero
1958 or negative. A negative value causes output up to hpos = 0 to be discarded.
1959 This is done for negative hscroll, or when this is a continuation line
1960 and the continuation occurred in the middle of a multi-column character.
1962 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
1964 Display on position VPOS on the frame. (origin 0).
1966 Returns a STRUCT POSITION giving character to start next line with
1967 and where to display it, including a zero or negative hpos.
1968 The vpos field is not really a vpos; it is 1 unless the line is continued */
1970 struct position val_display_text_line
;
1972 static struct position
*
1973 display_text_line (w
, start
, vpos
, hpos
, taboffset
)
1980 register int pos
= start
;
1985 register unsigned char *p
;
1987 register GLYPH
*leftmargin
;
1988 register GLYPH
*p1prev
= 0;
1989 register GLYPH
*p1start
;
1991 FRAME_PTR f
= XFRAME (w
->frame
);
1992 int tab_width
= XINT (current_buffer
->tab_width
);
1993 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
1994 int width
= window_internal_width (w
) - 1;
1995 struct position val
;
1998 int hscroll
= XINT (w
->hscroll
);
1999 int truncate
= (hscroll
2000 || (truncate_partial_width_windows
2001 && XFASTINT (w
->width
) < FRAME_WIDTH (f
))
2002 || !NILP (current_buffer
->truncate_lines
));
2004 /* 1 if we should highlight the region. */
2005 int highlight_region
2006 = !NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
);
2007 int region_beg
, region_end
;
2010 = XTYPE (current_buffer
->selective_display
) == Lisp_Int
2011 ? XINT (current_buffer
->selective_display
)
2012 : !NILP (current_buffer
->selective_display
) ? -1 : 0;
2013 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
2014 register struct Lisp_Vector
*dp
= window_display_table (w
);
2016 Lisp_Object default_invis_vector
[3];
2017 /* Nonzero means display something where there are invisible lines.
2018 The precise value is the number of glyphs to display. */
2020 = (selective
&& dp
&& XTYPE (DISP_INVIS_VECTOR (dp
)) == Lisp_Vector
2021 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
2022 : selective
&& !NILP (current_buffer
->selective_display_ellipses
)
2024 /* This is the sequence of Lisp objects to display
2025 when there are invisible lines. */
2026 Lisp_Object
*invis_vector_contents
2027 = (dp
&& XTYPE (DISP_INVIS_VECTOR (dp
)) == Lisp_Vector
2028 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
2029 : default_invis_vector
);
2031 GLYPH truncator
= (dp
== 0 || XTYPE (DISP_TRUNC_GLYPH (dp
)) != Lisp_Int
2032 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
2033 GLYPH continuer
= (dp
== 0 || XTYPE (DISP_CONTINUE_GLYPH (dp
)) != Lisp_Int
2034 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
2036 /* The next buffer location at which the face should change, due
2037 to overlays or text property changes. */
2038 int next_face_change
;
2040 #ifdef USE_TEXT_PROPERTIES
2041 /* The next location where the `invisible' property changes */
2045 /* The face we're currently using. */
2046 int current_face
= 0;
2049 XFASTINT (default_invis_vector
[2]) = '.';
2050 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
2052 hpos
+= XFASTINT (w
->left
);
2053 get_display_line (f
, vpos
, XFASTINT (w
->left
));
2054 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
2056 /* Show where to highlight the region. */
2057 if (highlight_region
&& XMARKER (current_buffer
->mark
)->buffer
!= 0
2058 /* Maybe highlight only in selected window. */
2059 && (highlight_nonselected_windows
2060 || w
== XWINDOW (selected_window
)))
2062 region_beg
= marker_position (current_buffer
->mark
);
2063 if (PT
< region_beg
)
2065 region_end
= region_beg
;
2070 w
->region_showing
= Qt
;
2073 region_beg
= region_end
= -1;
2075 if (MINI_WINDOW_P (w
) && start
== 1
2076 && vpos
== XFASTINT (w
->top
))
2079 hpos
= display_string (w
, vpos
, minibuf_prompt
, -1, hpos
,
2080 (!truncate
? continuer
: truncator
),
2082 minibuf_prompt_width
= hpos
;
2085 desired_glyphs
->bufp
[vpos
] = pos
;
2086 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
2088 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
2089 /* In case we don't ever write anything into it... */
2092 leftmargin
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
2093 endp
= leftmargin
+ width
;
2095 /* Arrange the overlays nicely for our purposes. Usually, we call
2096 display_text_line on only one line at a time, in which case this
2097 can't really hurt too much, or we call it on lines which appear
2098 one after another in the buffer, in which case all calls to
2099 recenter_overlay_lists but the first will be pretty cheap. */
2100 recenter_overlay_lists (current_buffer
, pos
);
2102 /* Loop generating characters.
2103 Stop at end of buffer, before newline,
2104 if reach or pass continuation column,
2105 or at face change. */
2107 next_face_change
= pos
;
2108 #ifdef USE_TEXT_PROPERTIES
2109 next_invisible
= pos
;
2113 /* Record which glyph starts a character,
2114 and the character position of that character. */
2115 if (p1
>= leftmargin
)
2116 charstart
[p1
- p1start
] = pos
;
2124 /* Did we hit the end of the visible region of the buffer?
2129 /* Did we reach point? Record the cursor location. */
2130 if (pos
== point
&& cursor_vpos
< 0)
2133 cursor_hpos
= p1
- leftmargin
;
2136 #ifdef USE_TEXT_PROPERTIES
2137 /* if the `invisible' property is set to t, we can skip to
2138 the next property change */
2139 while (pos
== next_invisible
&& pos
< end
)
2141 Lisp_Object position
, limit
, endpos
, prop
, ww
;
2142 XFASTINT (position
) = pos
;
2143 XSET (ww
, Lisp_Window
, w
);
2144 prop
= Fget_char_property (position
, Qinvisible
, ww
);
2145 /* This is just an estimate to give reasonable
2146 performance; nothing should go wrong if it is too small. */
2147 limit
= Fnext_overlay_change (position
);
2148 if (XFASTINT (limit
) > pos
+ 50)
2149 XFASTINT (limit
) = pos
+ 50;
2150 endpos
= Fnext_single_property_change (position
, Qinvisible
,
2151 Fcurrent_buffer (), limit
);
2152 if (INTEGERP (endpos
))
2153 next_invisible
= XINT (endpos
);
2155 next_invisible
= end
;
2158 if (pos
< point
&& next_invisible
>= point
)
2161 cursor_hpos
= p1
- leftmargin
;
2163 pos
= next_invisible
;
2170 #ifdef HAVE_X_WINDOWS
2171 /* Did we hit a face change? Figure out what face we should
2172 use now. We also hit this the first time through the
2173 loop, to see what face we should start with. */
2174 if (pos
>= next_face_change
&& FRAME_X_P (f
))
2175 current_face
= compute_char_face (f
, w
, pos
,
2176 region_beg
, region_end
,
2177 &next_face_change
, pos
+ 50, 0);
2182 #ifdef USE_TEXT_PROPERTIES
2183 if (pos
< next_invisible
&& next_invisible
< pause
)
2184 pause
= next_invisible
;
2186 if (pos
< next_face_change
&& next_face_change
< pause
)
2187 pause
= next_face_change
;
2189 /* Wouldn't you hate to read the next line to someone over
2191 if (pos
< point
&& point
< pause
)
2193 if (pos
< GPT
&& GPT
< pause
)
2196 p
= &FETCH_CHAR (pos
);
2199 if (c
>= 040 && c
< 0177
2200 && (dp
== 0 || XTYPE (DISP_CHAR_VECTOR (dp
, c
)) != Lisp_Vector
))
2202 if (p1
>= leftmargin
)
2203 *p1
= MAKE_GLYPH (f
, c
, current_face
);
2211 && indented_beyond_p (pos
+ 1, selective
))
2214 pos
= find_next_newline (pos
+ 1, 1);
2215 if (FETCH_CHAR (pos
- 1) == '\n')
2218 if (invis
&& selective_rlen
> 0 && p1
>= leftmargin
)
2220 p1
+= selective_rlen
;
2221 if (p1
- leftmargin
> width
)
2223 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2224 (p1
- p1prev
), current_face
);
2226 #ifdef HAVE_X_WINDOWS
2227 /* Draw the face of the newline character as extending all the
2228 way to the end of the frame line. */
2231 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2239 if (p1
>= leftmargin
&& p1
< endp
)
2240 *p1
= MAKE_GLYPH (f
, ' ', current_face
);
2243 while ((p1
- leftmargin
+ taboffset
+ hscroll
- (hscroll
> 0))
2246 else if (c
== Ctl ('M') && selective
== -1)
2248 pos
= find_next_newline (pos
, 1);
2249 if (FETCH_CHAR (pos
- 1) == '\n')
2251 if (selective_rlen
> 0)
2253 p1
+= selective_rlen
;
2254 if (p1
- leftmargin
> width
)
2256 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2257 (p1
- p1prev
), current_face
);
2259 #ifdef HAVE_X_WINDOWS
2260 /* Draw the face of the newline character as extending all the
2261 way to the end of the frame line. */
2264 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2268 else if (dp
!= 0 && XTYPE (DISP_CHAR_VECTOR (dp
, c
)) == Lisp_Vector
)
2270 p1
= copy_part_of_rope (f
, p1
, leftmargin
,
2271 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
2272 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
2275 else if (c
< 0200 && ctl_arrow
)
2277 if (p1
>= leftmargin
)
2278 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_CTRL_GLYPH (dp
)) == Lisp_Int
2279 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
2282 if (p1
>= leftmargin
&& p1
< endp
)
2283 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
);
2288 if (p1
>= leftmargin
)
2289 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_ESCAPE_GLYPH (dp
)) == Lisp_Int
2290 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
2293 if (p1
>= leftmargin
&& p1
< endp
)
2294 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
);
2296 if (p1
>= leftmargin
&& p1
< endp
)
2297 *p1
= MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
);
2299 if (p1
>= leftmargin
&& p1
< endp
)
2300 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
);
2304 /* Do nothing here for a char that's entirely off the left edge. */
2305 if (p1
>= leftmargin
)
2307 /* For all the glyphs occupied by this character, except for the
2308 first, store -1 in charstarts. */
2311 int *p2x
= &charstart
[p1prev
- p1start
];
2312 int *p2
= &charstart
[p1
- p1start
];
2314 /* The window's left column should always
2315 contain a character position.
2316 And don't clobber anything to the left of that. */
2317 if (p1prev
< leftmargin
)
2323 /* This loop skips over the char p2x initially points to. */
2332 val
.hpos
= - XINT (w
->hscroll
);
2340 /* Store 0 in this charstart line for the positions where
2341 there is no character. But do leave what was recorded
2342 for the character that ended the line. */
2343 /* Add 1 in the endtest to compensate for the fact that ENDP was
2344 made from WIDTH, which is 1 less than the window's actual
2346 for (i
= p1
- p1start
+ 1; i
< endp
- p1start
+ 1; i
++)
2349 /* Handle continuation in middle of a character */
2350 /* by backing up over it */
2353 /* Don't back up if we never actually displayed any text.
2354 This occurs when the minibuffer prompt takes up the whole line. */
2357 /* Start the next line with that same character */
2359 /* but at negative hpos, to skip the columns output on this line. */
2360 val
.hpos
+= p1prev
- endp
;
2363 /* Keep in this line everything up to the continuation column. */
2367 /* Finish deciding which character to start the next line on,
2368 and what hpos to start it at.
2369 Also set `lastpos' to the last position which counts as "on this line"
2370 for cursor-positioning. */
2374 if (FETCH_CHAR (pos
) == '\n')
2376 /* If stopped due to a newline, start next line after it */
2378 /* Check again for hidden lines, in case the newline occurred exactly
2379 at the right margin. */
2380 while (pos
< ZV
&& selective
> 0
2381 && indented_beyond_p (pos
, selective
))
2382 pos
= find_next_newline (pos
, 1);
2385 /* Stopped due to right margin of window */
2389 *p1
++ = fix_glyph (f
, truncator
, 0);
2390 /* Truncating => start next line after next newline,
2391 and point is on this line if it is before the newline,
2392 and skip none of first char of next line */
2394 pos
= find_next_newline (pos
, 1);
2395 while (pos
< ZV
&& selective
> 0
2396 && indented_beyond_p (pos
, selective
));
2397 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2399 lastpos
= pos
- (FETCH_CHAR (pos
- 1) == '\n');
2403 *p1
++ = fix_glyph (f
, continuer
, 0);
2410 /* If point is at eol or in invisible text at eol,
2411 record its frame location now. */
2413 if (start
<= point
&& point
<= lastpos
&& cursor_vpos
< 0)
2416 cursor_hpos
= p1
- leftmargin
;
2419 if (cursor_vpos
== vpos
)
2421 if (cursor_hpos
< 0) cursor_hpos
= 0;
2422 if (cursor_hpos
> width
) cursor_hpos
= width
;
2423 cursor_hpos
+= XFASTINT (w
->left
);
2424 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2426 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2427 FRAME_CURSOR_X (f
) = cursor_hpos
;
2429 if (w
== XWINDOW (selected_window
))
2431 /* Line is not continued and did not start
2432 in middle of character */
2433 if ((hpos
- XFASTINT (w
->left
)
2434 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2437 this_line_bufpos
= start
;
2438 this_line_buffer
= current_buffer
;
2439 this_line_vpos
= cursor_vpos
;
2440 this_line_start_hpos
= hpos
;
2441 this_line_endpos
= Z
- lastpos
;
2444 this_line_bufpos
= 0;
2449 /* If hscroll and line not empty, insert truncation-at-left marker */
2450 if (hscroll
&& lastpos
!= start
)
2452 *leftmargin
= fix_glyph (f
, truncator
, 0);
2453 if (p1
<= leftmargin
)
2454 p1
= leftmargin
+ 1;
2457 if (XFASTINT (w
->width
) + XFASTINT (w
->left
) != FRAME_WIDTH (f
))
2460 if (p1
< leftmargin
) p1
= leftmargin
;
2461 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
2463 /* Don't draw vertical bars if we're using scroll bars. They're
2464 covered up by the scroll bars, and it's distracting to see
2465 them when the scroll bar windows are flickering around to be
2467 *p1
++ = (FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2470 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
2471 p1
- desired_glyphs
->glyphs
[vpos
]);
2472 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
2474 /* If the start of this line is the overlay arrow-position,
2475 then put the arrow string into the display-line. */
2477 if (XTYPE (Voverlay_arrow_position
) == Lisp_Marker
2478 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
2479 && start
== marker_position (Voverlay_arrow_position
)
2480 && XTYPE (Voverlay_arrow_string
) == Lisp_String
2481 && ! overlay_arrow_seen
)
2483 unsigned char *p
= XSTRING (Voverlay_arrow_string
)->data
;
2485 int len
= XSTRING (Voverlay_arrow_string
)->size
;
2490 for (i
= 0; i
< len
; i
++)
2491 leftmargin
[i
] = p
[i
];
2493 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
2494 arrow_end
= (leftmargin
- desired_glyphs
->glyphs
[vpos
]) + len
;
2495 if (desired_glyphs
->used
[vpos
] < arrow_end
)
2496 desired_glyphs
->used
[vpos
] = arrow_end
;
2498 overlay_arrow_seen
= 1;
2502 val_display_text_line
= val
;
2503 return &val_display_text_line
;
2506 /* Redisplay the menu bar in the frame for window W. */
2509 display_menu_bar (w
)
2512 Lisp_Object items
, tail
;
2513 register int vpos
= 0;
2514 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2515 int maxendcol
= FRAME_WIDTH (f
);
2519 #ifndef USE_X_TOOLKIT
2520 if (FRAME_MENU_BAR_LINES (f
) <= 0)
2523 get_display_line (f
, vpos
, 0);
2525 items
= FRAME_MENU_BAR_ITEMS (f
);
2526 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 3)
2528 Lisp_Object pos
, string
;
2529 string
= XVECTOR (items
)->contents
[i
+ 1];
2533 XFASTINT (XVECTOR (items
)->contents
[i
+ 2]) = hpos
;
2535 if (hpos
< maxendcol
)
2536 hpos
= display_string (XWINDOW (FRAME_ROOT_WINDOW (f
)), vpos
,
2537 XSTRING (string
)->data
,
2538 XSTRING (string
)->size
,
2539 hpos
, 0, 0, hpos
, maxendcol
);
2540 /* Put a gap of 3 spaces between items. */
2541 if (hpos
< maxendcol
)
2543 int hpos1
= hpos
+ 3;
2544 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
2545 min (hpos1
, maxendcol
), maxendcol
);
2549 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
2550 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
2552 /* Fill out the line with spaces. */
2553 if (maxendcol
> hpos
)
2554 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
);
2556 /* Clear the rest of the lines allocated to the menu bar. */
2558 while (vpos
< FRAME_MENU_BAR_LINES (f
))
2559 get_display_line (f
, vpos
++, 0);
2560 #endif /* not USE_X_TOOLKIT */
2563 /* Display the mode line for window w */
2566 display_mode_line (w
)
2569 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
2570 register int left
= XFASTINT (w
->left
);
2571 register int right
= XFASTINT (w
->width
) + left
;
2572 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2574 line_number_displayed
= 0;
2576 get_display_line (f
, vpos
, left
);
2577 display_mode_element (w
, vpos
, left
, 0, right
, right
,
2578 current_buffer
->mode_line_format
);
2579 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
2581 /* Make the mode line inverse video if the entire line
2582 is made of mode lines.
2583 I.e. if this window is full width,
2584 or if it is the child of a full width window
2585 (which implies that that window is split side-by-side
2586 and the rest of this line is mode lines of the sibling windows). */
2587 if (XFASTINT (w
->width
) == FRAME_WIDTH (f
)
2588 || XFASTINT (XWINDOW (w
->parent
)->width
) == FRAME_WIDTH (f
))
2589 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
2590 #ifdef HAVE_X_WINDOWS
2591 else if (! FRAME_TERMCAP_P (f
))
2593 /* For a partial width window, explicitly set face of each glyph. */
2595 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
2596 for (i
= left
; i
< right
; ++i
)
2597 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1);
2601 #ifdef HAVE_X_WINDOWS
2602 if (w
== XWINDOW (f
->selected_window
))
2603 x_consider_frame_title (WINDOW_FRAME (w
));
2607 /* Contribute ELT to the mode line for window W.
2608 How it translates into text depends on its data type.
2610 VPOS is the position of the mode line being displayed.
2612 HPOS is the position (absolute on frame) where this element's text
2613 should start. The output is truncated automatically at the right
2616 DEPTH is the depth in recursion. It is used to prevent
2617 infinite recursion here.
2619 MINENDCOL is the hpos before which the element may not end.
2620 The element is padded at the right with spaces if nec
2621 to reach this column.
2623 MAXENDCOL is the hpos past which this element may not extend.
2624 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
2625 (This is necessary to make nested padding and truncation work.)
2627 Returns the hpos of the end of the text generated by ELT.
2628 The next element will receive that value as its HPOS arg,
2629 so as to concatenate the elements. */
2632 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
2634 register int vpos
, hpos
;
2637 register int maxendcol
;
2638 register Lisp_Object elt
;
2646 #ifdef SWITCH_ENUM_BUG
2647 switch ((int) XTYPE (elt
))
2649 switch (XTYPE (elt
))
2654 /* A string: output it and check for %-constructs within it. */
2655 register unsigned char c
;
2656 register unsigned char *this = XSTRING (elt
)->data
;
2658 while (hpos
< maxendcol
&& *this)
2660 unsigned char *last
= this;
2661 while ((c
= *this++) != '\0' && c
!= '%')
2663 if (this - 1 != last
)
2665 register int lim
= --this - last
+ hpos
;
2666 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
2667 hpos
, min (lim
, maxendcol
));
2671 register int spec_width
= 0;
2673 /* We can't allow -ve args due to the "%-" construct */
2674 /* Argument specifies minwidth but not maxwidth
2675 (maxwidth can be specified by
2676 (<negative-number> . <stuff>) mode-line elements) */
2678 while ((c
= *this++) >= '0' && c
<= '9')
2680 spec_width
= spec_width
* 10 + (c
- '0');
2684 if (spec_width
> maxendcol
)
2685 spec_width
= maxendcol
;
2688 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
2689 spec_width
, maxendcol
,
2690 Vglobal_mode_string
);
2692 hpos
= display_string (w
, vpos
,
2693 decode_mode_spec (w
, c
,
2696 hpos
, 0, 1, spec_width
, maxendcol
);
2703 /* A symbol: process the value of the symbol recursively
2704 as if it appeared here directly. Avoid error if symbol void.
2705 Special case: if value of symbol is a string, output the string
2708 register Lisp_Object tem
;
2709 tem
= Fboundp (elt
);
2712 tem
= Fsymbol_value (elt
);
2713 /* If value is a string, output that string literally:
2714 don't check for % within it. */
2715 if (XTYPE (tem
) == Lisp_String
)
2716 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
2717 XSTRING (tem
)->size
,
2718 hpos
, 0, 1, minendcol
, maxendcol
);
2719 /* Give up right away for nil or t. */
2720 else if (!EQ (tem
, elt
))
2721 { elt
= tem
; goto tail_recurse
; }
2728 register Lisp_Object car
, tem
;
2730 /* A cons cell: three distinct cases.
2731 If first element is a string or a cons, process all the elements
2732 and effectively concatenate them.
2733 If first element is a negative number, truncate displaying cdr to
2734 at most that many characters. If positive, pad (with spaces)
2735 to at least that many characters.
2736 If first element is a symbol, process the cadr or caddr recursively
2737 according to whether the symbol's value is non-nil or nil. */
2738 car
= XCONS (elt
)->car
;
2739 if (XTYPE (car
) == Lisp_Symbol
)
2741 tem
= Fboundp (car
);
2742 elt
= XCONS (elt
)->cdr
;
2743 if (XTYPE (elt
) != Lisp_Cons
)
2745 /* elt is now the cdr, and we know it is a cons cell.
2746 Use its car if CAR has a non-nil value. */
2749 tem
= Fsymbol_value (car
);
2751 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
2753 /* Symbol's value is nil (or symbol is unbound)
2754 Get the cddr of the original list
2755 and if possible find the caddr and use that. */
2756 elt
= XCONS (elt
)->cdr
;
2759 else if (XTYPE (elt
) != Lisp_Cons
)
2761 elt
= XCONS (elt
)->car
;
2764 else if (XTYPE (car
) == Lisp_Int
)
2766 register int lim
= XINT (car
);
2767 elt
= XCONS (elt
)->cdr
;
2769 /* Negative int means reduce maximum width.
2770 DO NOT change MINENDCOL here!
2771 (20 -10 . foo) should truncate foo to 10 col
2772 and then pad to 20. */
2773 maxendcol
= min (maxendcol
, hpos
- lim
);
2776 /* Padding specified. Don't let it be more than
2779 if (lim
> maxendcol
)
2781 /* If that's more padding than already wanted, queue it.
2782 But don't reduce padding already specified even if
2783 that is beyond the current truncation point. */
2784 if (lim
> minendcol
)
2789 else if (XTYPE (car
) == Lisp_String
|| XTYPE (car
) == Lisp_Cons
)
2791 register int limit
= 50;
2792 /* LIMIT is to protect against circular lists. */
2793 while (XTYPE (elt
) == Lisp_Cons
&& --limit
> 0
2794 && hpos
< maxendcol
)
2796 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
2799 elt
= XCONS (elt
)->cdr
;
2807 return (display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
2808 minendcol
, maxendcol
));
2812 if (minendcol
> hpos
)
2813 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 1, minendcol
, maxendcol
);
2817 /* Return a string for the output of a mode line %-spec for window W,
2818 generated by character C and width MAXWIDTH. */
2820 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
2823 decode_mode_spec (w
, c
, maxwidth
)
2826 register int maxwidth
;
2829 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2830 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
2833 if (maxwidth
> FRAME_WIDTH (f
))
2834 maxwidth
= FRAME_WIDTH (f
);
2839 obj
= current_buffer
->name
;
2841 if (maxwidth
>= 3 && XSTRING (obj
)->size
> maxwidth
)
2843 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
2844 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
2845 decode_mode_spec_buf
[maxwidth
] = '\0';
2846 return decode_mode_spec_buf
;
2852 obj
= current_buffer
->filename
;
2856 else if (XTYPE (obj
) == Lisp_String
&& XSTRING (obj
)->size
> maxwidth
)
2858 bcopy ("...", decode_mode_spec_buf
, 3);
2859 bcopy (XSTRING (obj
)->data
+ XSTRING (obj
)->size
- maxwidth
+ 3,
2860 decode_mode_spec_buf
+ 3, maxwidth
- 3);
2861 return decode_mode_spec_buf
;
2868 int startpos
= marker_position (w
->start
);
2869 int line
, linepos
, topline
;
2872 int height
= XFASTINT (w
->height
);
2874 /* If we decided that this buffer isn't suitable for line numbers,
2875 don't forget that too fast. */
2876 if (EQ (w
->base_line_pos
, w
->buffer
))
2879 /* If the buffer is very big, don't waste time. */
2880 if (ZV
- BEGV
> line_number_display_limit
)
2882 w
->base_line_pos
= Qnil
;
2883 w
->base_line_number
= Qnil
;
2887 if (!NILP (w
->base_line_number
)
2888 && !NILP (w
->base_line_pos
)
2889 && XFASTINT (w
->base_line_pos
) <= marker_position (w
->start
))
2891 line
= XFASTINT (w
->base_line_number
);
2892 linepos
= XFASTINT (w
->base_line_pos
);
2900 /* Count lines from base line to window start position. */
2901 nlines
= display_count_lines (linepos
, startpos
, startpos
, &junk
);
2903 topline
= nlines
+ line
;
2905 /* Determine a new base line, if the old one is too close
2906 or too far away, or if we did not have one.
2907 "Too close" means it's plausible a scroll-down would
2909 if (startpos
== BEGV
)
2911 XFASTINT (w
->base_line_number
) = topline
;
2912 XFASTINT (w
->base_line_pos
) = BEGV
;
2914 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
2919 int distance
= (height
* 2 + 30) * 200;
2921 if (startpos
- distance
> limit
)
2922 limit
= startpos
- distance
;
2924 nlines
= display_count_lines (startpos
, limit
,
2927 /* If we couldn't find the lines we wanted within
2929 give up on line numbers for this window. */
2930 if (position
== startpos
- distance
)
2932 w
->base_line_pos
= w
->buffer
;
2933 w
->base_line_number
= Qnil
;
2937 XFASTINT (w
->base_line_number
) = topline
- nlines
;
2938 XFASTINT (w
->base_line_pos
) = position
;
2941 /* Now count lines from the start pos to point. */
2942 nlines
= display_count_lines (startpos
, PT
, PT
, &junk
);
2944 /* Record that we did display the line number. */
2945 line_number_displayed
= 1;
2947 /* Make the string to show. */
2948 sprintf (decode_mode_spec_buf
, "%d", topline
+ nlines
);
2949 return decode_mode_spec_buf
;
2954 obj
= current_buffer
->mode_name
;
2958 if (BEGV
> BEG
|| ZV
< Z
)
2963 if (!NILP (current_buffer
->read_only
))
2965 if (MODIFF
> current_buffer
->save_modified
)
2970 if (MODIFF
> current_buffer
->save_modified
)
2975 /* status of process */
2976 obj
= Fget_buffer_process (Fcurrent_buffer ());
2978 return "no process";
2980 obj
= Fsymbol_name (Fprocess_status (obj
));
2984 case 't': /* indicate TEXT or BINARY */
2986 decode_mode_spec_buf
[0]
2987 = NILP (current_buffer
->buffer_file_type
) ? "T" : "B";
2988 decode_mode_spec_buf
[1] = 0;
2989 return decode_mode_spec_buf
;
2990 #else /* not MSDOS */
2992 #endif /* not MSDOS */
2996 int pos
= marker_position (w
->start
);
2997 int total
= ZV
- BEGV
;
2999 if (XFASTINT (w
->window_end_pos
) <= Z
- ZV
)
3006 else if (pos
<= BEGV
)
3010 total
= ((pos
- BEGV
) * 100 + total
- 1) / total
;
3011 /* We can't normally display a 3-digit number,
3012 so get us a 2-digit number that is close. */
3015 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
3016 return decode_mode_spec_buf
;
3020 /* Display percentage of size above the bottom of the screen. */
3023 int toppos
= marker_position (w
->start
);
3024 int botpos
= Z
- XFASTINT (w
->window_end_pos
);
3025 int total
= ZV
- BEGV
;
3036 total
= ((botpos
- BEGV
) * 100 + total
- 1) / total
;
3037 /* We can't normally display a 3-digit number,
3038 so get us a 2-digit number that is close. */
3042 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
3044 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
3045 return decode_mode_spec_buf
;
3057 if (command_loop_level
> 5)
3059 p
= decode_mode_spec_buf
;
3060 for (i
= 0; i
< command_loop_level
; i
++)
3063 return decode_mode_spec_buf
;
3071 if (command_loop_level
> 5)
3073 p
= decode_mode_spec_buf
;
3074 for (i
= 0; i
< command_loop_level
; i
++)
3077 return decode_mode_spec_buf
;
3085 if (maxwidth
< sizeof (lots_of_dashes
))
3086 return lots_of_dashes
;
3089 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
3093 return decode_mode_spec_buf
;
3097 if (XTYPE (obj
) == Lisp_String
)
3098 return (char *) XSTRING (obj
)->data
;
3103 /* Count up to N lines starting from FROM.
3104 But don't go beyond LIMIT.
3105 Return the number of lines thus found (always positive).
3106 Store the position after what was found into *POS_PTR. */
3109 display_count_lines (from
, limit
, n
, pos_ptr
)
3122 *pos_ptr
= scan_buffer ('\n', from
, n
, &shortage
, 0);
3128 /* When scanning backwards, scan_buffer stops *after* the last newline
3129 it finds, but does count it. Compensate for that. */
3130 return - n
- shortage
- (*pos_ptr
!= limit
);
3131 return n
- shortage
;
3134 /* Display STRING on one line of window W, starting at HPOS.
3135 Display at position VPOS. Caller should have done get_display_line.
3136 If VPOS == -1, display it as the current frame's title.
3137 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
3139 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
3141 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
3142 MAXCOL is the last column ok to end at. Truncate here.
3143 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
3144 Both count from the left edge of the frame, as does HPOS.
3145 The right edge of W is an implicit maximum.
3146 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
3148 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
3149 at the place where the current window ends in this line
3150 and not display anything beyond there. Otherwise, only MAXCOL
3151 controls where to stop output.
3153 Returns ending hpos. */
3156 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
3157 obey_window_width
, mincol
, maxcol
)
3159 unsigned char *string
;
3163 int obey_window_width
;
3168 int hscroll
= XINT (w
->hscroll
);
3169 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
3170 register GLYPH
*start
;
3171 register GLYPH
*end
;
3172 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3173 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3174 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3175 int window_width
= XFASTINT (w
->width
);
3177 /* Use the standard display table, not the window's display table.
3178 We don't want the mode line in rot13. */
3179 register struct Lisp_Vector
*dp
= 0;
3182 if (XTYPE (Vstandard_display_table
) == Lisp_Vector
3183 && XVECTOR (Vstandard_display_table
)->size
== DISP_TABLE_SIZE
)
3184 dp
= XVECTOR (Vstandard_display_table
);
3186 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3189 start
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
3191 if (obey_window_width
)
3193 end
= start
+ window_width
- (truncate
!= 0);
3195 if ((window_width
+ XFASTINT (w
->left
)) != FRAME_WIDTH (f
))
3197 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3201 for (i
= 0; i
< VERTICAL_SCROLL_BAR_WIDTH
; i
++)
3209 if (! obey_window_width
3210 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
3211 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
3213 /* Store 0 in charstart for these columns. */
3214 for (i
= (hpos
>= 0 ? hpos
: 0); i
< end
- p1start
+ hpos
; i
++)
3215 desired_glyphs
->charstarts
[vpos
][i
] = 0;
3217 if (maxcol
>= 0 && mincol
> maxcol
)
3225 /* Specified length. */
3228 /* Unspecified length (null-terminated string). */
3232 if (c
>= 040 && c
< 0177
3233 && (dp
== 0 || XTYPE (DISP_CHAR_VECTOR (dp
, c
)) != Lisp_Vector
))
3243 if (p1
>= start
&& p1
< end
)
3247 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
3249 else if (dp
!= 0 && XTYPE (DISP_CHAR_VECTOR (dp
, c
)) == Lisp_Vector
)
3251 p1
= copy_part_of_rope (f
, p1
, start
,
3252 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3253 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3256 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
3259 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_CTRL_GLYPH (dp
)) == Lisp_Int
3260 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3263 if (p1
>= start
&& p1
< end
)
3270 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_ESCAPE_GLYPH (dp
)) == Lisp_Int
3271 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3274 if (p1
>= start
&& p1
< end
)
3275 *p1
= (c
>> 6) + '0';
3277 if (p1
>= start
&& p1
< end
)
3278 *p1
= (7 & (c
>> 3)) + '0';
3280 if (p1
>= start
&& p1
< end
)
3281 *p1
= (7 & c
) + '0';
3286 if (c
&& length
> 0)
3289 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
3291 else if (mincol
>= 0)
3293 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
3299 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
3301 if (len
> desired_glyphs
->used
[vpos
])
3302 desired_glyphs
->used
[vpos
] = len
;
3303 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
3312 staticpro (&last_arrow_position
);
3313 staticpro (&last_arrow_string
);
3314 last_arrow_position
= Qnil
;
3315 last_arrow_string
= Qnil
;
3317 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
3318 "String (or mode line construct) included (normally) in `mode-line-format'.");
3319 Vglobal_mode_string
= Qnil
;
3321 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
3322 "Marker for where to display an arrow on top of the buffer text.\n\
3323 This must be the beginning of a line in order to work.\n\
3324 See also `overlay-arrow-string'.");
3325 Voverlay_arrow_position
= Qnil
;
3327 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
3328 "String to display as an arrow. See also `overlay-arrow-position'.");
3329 Voverlay_arrow_string
= Qnil
;
3331 DEFVAR_INT ("scroll-step", &scroll_step
,
3332 "*The number of lines to try scrolling a window by when point moves out.\n\
3333 If that fails to bring point back on frame, point is centered instead.\n\
3334 If this is zero, point is always centered after it moves off frame.");
3336 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
3338 DEFVAR_BOOL ("truncate-partial-width-windows",
3339 &truncate_partial_width_windows
,
3340 "*Non-nil means truncate lines in all windows less than full frame wide.");
3341 truncate_partial_width_windows
= 1;
3343 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
3344 "*Non-nil means use inverse video for the mode line.");
3345 mode_line_inverse_video
= 1;
3347 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
3348 "*Maximum buffer size for which line number should be displayed.");
3349 line_number_display_limit
= 1000000;
3351 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
3352 "*Non-nil means highlight region even in nonselected windows.");
3353 highlight_nonselected_windows
= 1;
3356 /* initialize the window system */
3359 Lisp_Object root_window
;
3360 #ifndef COMPILER_REGISTER_BUG
3362 #endif /* COMPILER_REGISTER_BUG */
3363 struct window
*mini_w
;
3365 this_line_bufpos
= 0;
3367 mini_w
= XWINDOW (minibuf_window
);
3368 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
3370 echo_area_glyphs
= 0;
3371 previous_echo_glyphs
= 0;
3373 if (!noninteractive
)
3375 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
3376 XFASTINT (XWINDOW (root_window
)->top
) = 0;
3377 set_window_height (root_window
, FRAME_HEIGHT (f
) - 1, 0);
3378 XFASTINT (mini_w
->top
) = FRAME_HEIGHT (f
) - 1;
3379 set_window_height (minibuf_window
, 1, 0);
3381 XFASTINT (XWINDOW (root_window
)->width
) = FRAME_WIDTH (f
);
3382 XFASTINT (mini_w
->width
) = FRAME_WIDTH (f
);