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 ();
247 message2 (m
, (m
? strlen (m
) : 0));
250 /* Truncate what will be displayed in the echo area
251 the next time we display it--but don't redisplay it now. */
254 truncate_echo_area (len
)
257 /* A null message buffer means that the frame hasn't really been
258 initialized yet. Error messages get reported properly by
259 cmd_error, so this must be just an informative message; toss it. */
260 if (!noninteractive
&& INTERACTIVE
&& FRAME_MESSAGE_BUF (selected_frame
))
261 echo_area_glyphs_length
= len
;
264 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print;
265 zero if being used by message. */
266 int message_buf_print
;
268 /* Dump an informative message to the minibuf. If m is 0, clear out
269 any existing message, and let the minibuffer text show through. */
272 message (m
, a1
, a2
, a3
)
279 if (noninteractive_need_newline
)
281 noninteractive_need_newline
= 0;
282 fprintf (stderr
, m
, a1
, a2
, a3
);
283 if (cursor_in_echo_area
== 0)
284 fprintf (stderr
, "\n");
288 else if (INTERACTIVE
)
290 /* The frame whose minibuffer we're going to display the message on.
291 It may be larger than the selected frame, so we need
292 to use its buffer, not the selected frame's buffer. */
293 FRAME_PTR echo_frame
;
295 choose_minibuf_frame ();
296 echo_frame
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
298 echo_frame
= selected_frame
;
301 /* A null message buffer means that the frame hasn't really been
302 initialized yet. Error messages get reported properly by
303 cmd_error, so this must be just an informative message; toss it. */
304 if (FRAME_MESSAGE_BUF (echo_frame
))
315 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
316 FRAME_WIDTH (echo_frame
), m
, 0, 3, a
);
318 len
= doprnt (FRAME_MESSAGE_BUF (echo_frame
),
319 FRAME_WIDTH (echo_frame
), m
, 0, 3, &a1
);
320 #endif /* NO_ARG_ARRAY */
322 message2 (FRAME_MESSAGE_BUF (echo_frame
), len
);
327 /* Print should start at the beginning of the message
329 message_buf_print
= 0;
341 choose_minibuf_frame ();
344 f
= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
346 if (! FRAME_VISIBLE_P (f
))
351 redraw_garbaged_frames ();
355 if (echo_area_glyphs
|| minibuf_level
== 0)
357 vpos
= XFASTINT (XWINDOW (minibuf_window
)->top
);
358 get_display_line (f
, vpos
, 0);
359 display_string (XWINDOW (minibuf_window
), vpos
,
360 echo_area_glyphs
? echo_area_glyphs
: "",
361 echo_area_glyphs
? echo_area_glyphs_length
: -1,
362 0, 0, 0, 0, FRAME_WIDTH (f
));
364 /* If desired cursor location is on this line, put it at end of text */
365 if (FRAME_CURSOR_Y (f
) == vpos
)
366 FRAME_CURSOR_X (f
) = FRAME_DESIRED_GLYPHS (f
)->used
[vpos
];
368 /* Fill the rest of the minibuffer window with blank lines. */
373 i
< vpos
+ XFASTINT (XWINDOW (minibuf_window
)->height
); i
++)
375 get_display_line (f
, i
, 0);
376 display_string (XWINDOW (minibuf_window
), vpos
,
377 "", 0, 0, 0, 0, 0, FRAME_WIDTH (f
));
381 else if (!EQ (minibuf_window
, selected_window
))
382 windows_or_buffers_changed
++;
384 if (EQ (minibuf_window
, selected_window
))
385 this_line_bufpos
= 0;
387 previous_echo_glyphs
= echo_area_glyphs
;
390 #ifdef HAVE_X_WINDOWS
391 /* I'm trying this out because I saw Unimpress use it, but it's
392 possible that this may mess adversely with some window managers. -jla
394 Wouldn't it be nice to use something like mode-line-format to
395 describe frame titles? -JimB */
397 /* Change the title of the frame to the name of the buffer displayed
398 in the currently selected window. Don't do this for minibuffer frames,
399 and don't do it when there's only one non-minibuffer frame. */
401 x_consider_frame_title (frame
)
404 FRAME_PTR f
= XFRAME (frame
);
406 if (FRAME_X_P (f
) && ! FRAME_MINIBUF_ONLY_P (f
))
411 if (! EQ (Fnext_frame (frame
, Qnil
), frame
))
412 title
= XBUFFER (XWINDOW (f
->selected_window
)->buffer
)->name
;
414 x_implicitly_set_name (f
, title
, Qnil
);
419 /* Prepare for redisplay by updating menu-bar item lists when appropriate.
420 This can't be done in `redisplay' itself because it can call eval. */
425 register struct window
*w
= XWINDOW (selected_window
);
431 /* Set the visible flags for all frames.
432 Do this before checking for resized or garbaged frames; they want
433 to know if their frames are visible.
434 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
436 Lisp_Object tail
, frame
;
438 FOR_EACH_FRAME (tail
, frame
)
439 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
442 /* Notice any pending interrupt request to change frame size. */
443 do_pending_window_change ();
447 redraw_garbaged_frames ();
451 if (clip_changed
|| windows_or_buffers_changed
)
454 /* Detect case that we need to write a star in the mode line. */
455 if (XFASTINT (w
->last_modified
) < MODIFF
456 && XFASTINT (w
->last_modified
) <= current_buffer
->save_modified
)
458 w
->update_mode_line
= Qt
;
459 if (buffer_shared
> 1)
463 all_windows
= update_mode_lines
|| buffer_shared
> 1;
465 /* If specs for an arrow have changed, do thorough redisplay
466 to ensure we remove any arrow that should no longer exist. */
467 if (! EQ (Voverlay_arrow_position
, last_arrow_position
)
468 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
469 all_windows
= 1, clip_changed
= 1;
471 /* Update the menu bar item lists, if appropriate.
472 This has to be done before any actual redisplay
473 or generation of display lines. */
476 Lisp_Object tail
, frame
;
478 FOR_EACH_FRAME (tail
, frame
)
480 FRAME_PTR f
= XFRAME (frame
);
482 if (FRAME_VISIBLE_P (f
))
483 update_menu_bars (FRAME_ROOT_WINDOW (f
));
486 else if (FRAME_VISIBLE_P (selected_frame
))
487 update_menu_bar (selected_window
);
490 /* Do a frame update, taking possible shortcuts into account.
491 This is the main external entry point for redisplay.
493 If the last redisplay displayed an echo area message and that
494 message is no longer requested, we clear the echo area
495 or bring back the minibuffer if that is in use.
497 Do not call eval from within this function.
498 Calls to eval after the call to echo_area_display would confuse
499 the display_line mechanism and would cause a crash.
500 Calls to eval before that point will work most of the time,
501 but can still lose, because this function
502 can be called from signal handlers; with alarms set up;
503 or with synchronous processes running.
505 See Fcall_process; if you called it from here, it could be
506 entered recursively. */
511 register struct window
*w
= XWINDOW (selected_window
);
515 register int tlbufpos
, tlendpos
;
517 extern int input_pending
;
522 /* Set the visible flags for all frames.
523 Do this before checking for resized or garbaged frames; they want
524 to know if their frames are visible.
525 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */
527 Lisp_Object tail
, frame
;
529 FOR_EACH_FRAME (tail
, frame
)
530 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
533 /* Notice any pending interrupt request to change frame size. */
534 do_pending_window_change ();
538 redraw_garbaged_frames ();
542 if (clip_changed
|| windows_or_buffers_changed
)
545 /* Detect case that we need to write a star in the mode line. */
546 if (XFASTINT (w
->last_modified
) < MODIFF
547 && XFASTINT (w
->last_modified
) <= current_buffer
->save_modified
)
549 w
->update_mode_line
= Qt
;
550 if (buffer_shared
> 1)
554 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w
->frame
)) = -1;
556 all_windows
= update_mode_lines
|| buffer_shared
> 1;
558 /* If specs for an arrow have changed, do thorough redisplay
559 to ensure we remove any arrow that should no longer exist. */
560 if (! EQ (Voverlay_arrow_position
, last_arrow_position
)
561 || ! EQ (Voverlay_arrow_string
, last_arrow_string
))
562 all_windows
= 1, clip_changed
= 1;
564 /* Normally the message* functions will have already displayed and
565 updated the echo area, but the frame may have been trashed, or
566 the update may have been preempted, so display the echo area
568 if (echo_area_glyphs
|| previous_echo_glyphs
)
570 echo_area_display ();
574 /* If showing region, and mark has changed, must redisplay whole window. */
575 if (((!NILP (Vtransient_mark_mode
)
576 && !NILP (XBUFFER (w
->buffer
)->mark_active
))
577 != !NILP (w
->region_showing
))
578 || (!NILP (w
->region_showing
)
579 && !EQ (w
->region_showing
,
580 Fmarker_position (XBUFFER (w
->buffer
)->mark
))))
581 this_line_bufpos
= -1;
583 tlbufpos
= this_line_bufpos
;
584 tlendpos
= this_line_endpos
;
585 if (!all_windows
&& tlbufpos
> 0 && NILP (w
->update_mode_line
)
586 && FRAME_VISIBLE_P (XFRAME (w
->frame
))
587 /* Make sure recorded data applies to current buffer, etc */
588 && this_line_buffer
== current_buffer
589 && current_buffer
== XBUFFER (w
->buffer
)
590 && NILP (w
->force_start
)
591 /* Point must be on the line that we have info recorded about */
593 && point
<= Z
- tlendpos
594 /* All text outside that line, including its final newline,
596 && (XFASTINT (w
->last_modified
) >= MODIFF
597 || (beg_unchanged
>= tlbufpos
- 1
599 /* If selective display, can't optimize
600 if the changes start at the beginning of the line. */
601 && ((XTYPE (current_buffer
->selective_display
) == Lisp_Int
602 && XINT (current_buffer
->selective_display
) > 0
603 ? (beg_unchanged
>= tlbufpos
606 && end_unchanged
>= tlendpos
607 && Z
- GPT
>= tlendpos
)))
609 if (tlbufpos
> BEGV
&& FETCH_CHAR (tlbufpos
- 1) != '\n'
611 || FETCH_CHAR (tlbufpos
) == '\n'))
612 /* Former continuation line has disappeared by becoming empty */
614 else if (XFASTINT (w
->last_modified
) < MODIFF
615 || MINI_WINDOW_P (w
))
618 overlay_arrow_seen
= 0;
619 display_text_line (w
, tlbufpos
, this_line_vpos
, this_line_start_hpos
,
620 pos_tab_offset (w
, tlbufpos
));
621 /* If line contains point, is not continued,
622 and ends at same distance from eob as before, we win */
623 if (cursor_vpos
>= 0 && this_line_bufpos
624 && this_line_endpos
== tlendpos
)
626 if (XFASTINT (w
->width
) != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w
))))
627 preserve_other_columns (w
);
633 else if (point
== XFASTINT (w
->last_point
))
637 do_pending_window_change ();
642 /* If highlighting the region, we can't just move the cursor. */
643 else if (! (!NILP (Vtransient_mark_mode
)
644 && !NILP (current_buffer
->mark_active
))
645 && NILP (w
->region_showing
))
647 pos
= *compute_motion (tlbufpos
, 0,
648 XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0,
649 point
, 2, - (1 << (SHORTBITS
- 1)),
650 window_internal_width (w
) - 1,
652 pos_tab_offset (w
, tlbufpos
));
655 FRAME_CURSOR_X (selected_frame
)
656 = XFASTINT (w
->left
) + max (pos
.hpos
, 0);
657 FRAME_CURSOR_Y (selected_frame
) = this_line_vpos
;
664 /* Text changed drastically or point moved off of line */
665 cancel_line (this_line_vpos
, selected_frame
);
668 this_line_bufpos
= 0;
669 all_windows
|= buffer_shared
> 1;
673 Lisp_Object tail
, frame
;
675 #ifdef HAVE_X_WINDOWS
676 /* Since we're doing a thorough redisplay, we might as well
677 recompute all our display faces. */
678 clear_face_vector ();
681 /* Recompute # windows showing selected buffer.
682 This will be incremented each time such a window is displayed. */
685 FOR_EACH_FRAME (tail
, frame
)
687 FRAME_PTR f
= XFRAME (frame
);
689 /* Mark all the scroll bars to be removed; we'll redeem the ones
690 we want when we redisplay their windows. */
691 if (condemn_scroll_bars_hook
)
692 (*condemn_scroll_bars_hook
) (f
);
694 if (FRAME_VISIBLE_P (f
))
695 redisplay_windows (FRAME_ROOT_WINDOW (f
));
696 #ifdef HAVE_X_WINDOWS
697 else if (FRAME_ICONIFIED_P (f
)
698 && ! MINI_WINDOW_P (XWINDOW (f
->selected_window
)))
699 x_consider_frame_title (frame
);
702 /* Any scroll bars which redisplay_windows should have nuked
703 should now go away. */
704 if (judge_scroll_bars_hook
)
705 (*judge_scroll_bars_hook
) (f
);
708 else if (FRAME_VISIBLE_P (selected_frame
))
710 redisplay_window (selected_window
, 1);
711 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
712 preserve_other_columns (w
);
716 /* Prevent various kinds of signals during display update.
717 stdio is not robust about handling signals,
718 which can cause an apparent I/O error. */
730 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
734 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
737 f
= XFRAME (XCONS (tail
)->car
);
738 if (FRAME_VISIBLE_P (f
))
740 pause
|= update_frame (f
, 0, 0);
743 mark_window_display_accurate (f
->root_window
, 1);
744 if (frame_up_to_date_hook
!= 0)
745 (*frame_up_to_date_hook
) (f
);
751 #endif /* MULTI_FRAME */
753 if (FRAME_VISIBLE_P (selected_frame
))
754 pause
= update_frame (selected_frame
, 0, 0);
756 /* We may have called echo_area_display at the top of this
757 function. If the echo area is on another frame, that may
758 have put text on a frame other than the selected one, so the
759 above call to update_frame would not have caught it. Catch
763 = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)));
765 if (mini_frame
!= selected_frame
)
766 pause
|= update_frame (mini_frame
, 0, 0);
770 /* If frame does not match, prevent doing single-line-update next time.
771 Also, don't forget to check every line to update the arrow. */
774 this_line_bufpos
= 0;
775 if (!NILP (last_arrow_position
))
777 last_arrow_position
= Qt
;
778 last_arrow_string
= Qt
;
780 /* If we pause after scrolling, some lines in current_frame
781 may be null, so preserve_other_columns won't be able to
782 preserve all the vertical-bar separators. So, avoid using it
784 if (XFASTINT (w
->width
) != FRAME_WIDTH (selected_frame
))
785 update_mode_lines
= 1;
788 /* Now text on frame agrees with windows, so
789 put info into the windows for partial redisplay to follow */
793 register struct buffer
*b
= XBUFFER (w
->buffer
);
795 blank_end_of_window
= 0;
797 unchanged_modified
= BUF_MODIFF (b
);
798 beg_unchanged
= BUF_GPT (b
) - BUF_BEG (b
);
799 end_unchanged
= BUF_Z (b
) - BUF_GPT (b
);
801 XFASTINT (w
->last_point
) = BUF_PT (b
);
802 XFASTINT (w
->last_point_x
) = FRAME_CURSOR_X (selected_frame
);
803 XFASTINT (w
->last_point_y
) = FRAME_CURSOR_Y (selected_frame
);
806 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame
), 1);
809 w
->update_mode_line
= Qnil
;
810 XFASTINT (w
->last_modified
) = BUF_MODIFF (b
);
811 w
->window_end_valid
= Qt
;
812 last_arrow_position
= Voverlay_arrow_position
;
813 last_arrow_string
= Voverlay_arrow_string
;
814 if (frame_up_to_date_hook
!= 0)
815 (*frame_up_to_date_hook
) (selected_frame
);
817 update_mode_lines
= 0;
818 windows_or_buffers_changed
= 0;
821 /* Start SIGIO interrupts coming again.
822 Having them off during the code above
823 makes it less likely one will discard output,
824 but not impossible, since there might be stuff
825 in the system buffer here.
826 But it is much hairier to try to do anything about that. */
832 /* Change frame size now if a change is pending. */
833 do_pending_window_change ();
836 /* Redisplay, but leave alone any recent echo area message
837 unless another message has been requested in its place.
839 This is useful in situations where you need to redisplay but no
840 user action has occurred, making it inappropriate for the message
841 area to be cleared. See tracking_off and
842 wait_reading_process_input for examples of these situations. */
844 redisplay_preserve_echo_area ()
846 if (echo_area_glyphs
== 0 && previous_echo_glyphs
!= 0)
848 echo_area_glyphs
= previous_echo_glyphs
;
850 echo_area_glyphs
= 0;
857 mark_window_display_accurate (window
, flag
)
861 register struct window
*w
;
863 for (;!NILP (window
); window
= w
->next
)
865 if (XTYPE (window
) != Lisp_Window
) abort ();
866 w
= XWINDOW (window
);
868 if (!NILP (w
->buffer
))
870 XFASTINT (w
->last_modified
)
872 : XBUFFER (w
->buffer
) == current_buffer
873 ? MODIFF
: BUF_MODIFF (XBUFFER (w
->buffer
));
875 /* Record if we are showing a region, so can make sure to
876 update it fully at next redisplay. */
877 w
->region_showing
= (!NILP (Vtransient_mark_mode
)
878 && !NILP (XBUFFER (w
->buffer
)->mark_active
)
879 ? Fmarker_position (XBUFFER (w
->buffer
)->mark
)
883 w
->window_end_valid
= Qt
;
884 w
->update_mode_line
= Qnil
;
886 if (!NILP (w
->vchild
))
887 mark_window_display_accurate (w
->vchild
, flag
);
888 if (!NILP (w
->hchild
))
889 mark_window_display_accurate (w
->hchild
, flag
);
894 last_arrow_position
= Voverlay_arrow_position
;
895 last_arrow_string
= Voverlay_arrow_string
;
899 /* t is unequal to any useful value of Voverlay_arrow_... */
900 last_arrow_position
= Qt
;
901 last_arrow_string
= Qt
;
905 /* Update the menu bar item lists for WINDOW
906 and its subwindows and siblings.
907 This has to be done before we start to fill in any display lines,
908 because it can call eval. */
911 update_menu_bars (window
)
914 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
915 update_menu_bar (window
);
918 /* Update the menu bar item list for window WINDOW and its subwindows. */
921 update_menu_bar (window
)
924 register struct window
*w
= XWINDOW (window
);
925 struct buffer
*old
= current_buffer
;
926 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
928 /* If this is a combination window, do its children; that's all. */
930 if (!NILP (w
->vchild
))
932 update_menu_bars (w
->vchild
);
935 if (!NILP (w
->hchild
))
937 update_menu_bars (w
->hchild
);
940 if (NILP (w
->buffer
))
943 if (update_mode_lines
)
944 w
->update_mode_line
= Qt
;
946 /* When we reach a frame's selected window, redo the frame's menu bar. */
947 if (!NILP (w
->update_mode_line
)
949 && FRAME_EXTERNAL_MENU_BAR (f
)
951 && FRAME_MENU_BAR_LINES (f
) > 0
953 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
955 /* If the user has switched buffers or windows, we need to
956 recompute to reflect the new bindings. But we'll
957 recompute when update_mode_lines is set too; that means
958 that people can use force-mode-line-update to request
959 that the menu bar be recomputed. The adverse effect on
960 the rest of the redisplay algorithm is about the same as
961 windows_or_buffers_changed anyway. */
962 if (windows_or_buffers_changed
964 || (XFASTINT (w
->last_modified
) < MODIFF
965 && (XFASTINT (w
->last_modified
)
966 <= XBUFFER (w
->buffer
)->save_modified
)))
968 struct buffer
*prev
= current_buffer
;
969 current_buffer
= XBUFFER (w
->buffer
);
970 FRAME_MENU_BAR_ITEMS (f
) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f
));
971 current_buffer
= prev
;
973 set_frame_menubar (f
);
974 #endif /* USE_X_TOOLKIT */
981 /* Redisplay WINDOW and its subwindows and siblings. */
984 redisplay_windows (window
)
987 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
988 redisplay_window (window
, 0);
991 /* Redisplay window WINDOW and its subwindows. */
994 redisplay_window (window
, just_this_one
)
998 register struct window
*w
= XWINDOW (window
);
999 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
1001 register int lpoint
= point
;
1002 struct buffer
*old
= current_buffer
;
1003 register int width
= window_internal_width (w
) - 1;
1004 register int startp
;
1005 register int hscroll
= XINT (w
->hscroll
);
1006 struct position pos
;
1009 int window_needs_modeline
;
1011 if (FRAME_HEIGHT (f
) == 0) abort (); /* Some bug zeros some core */
1013 /* If this is a combination window, do its children; that's all. */
1015 if (!NILP (w
->vchild
))
1017 redisplay_windows (w
->vchild
);
1020 if (!NILP (w
->hchild
))
1022 redisplay_windows (w
->hchild
);
1025 if (NILP (w
->buffer
))
1028 height
= window_internal_height (w
);
1030 if (MINI_WINDOW_P (w
))
1032 if (w
== XWINDOW (minibuf_window
))
1034 if (echo_area_glyphs
)
1035 /* We've already displayed the echo area glyphs, if any. */
1036 goto finish_scroll_bars
;
1040 /* This is a minibuffer, but it's not the currently active one, so
1042 int vpos
= XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f
))->top
);
1045 for (i
= 0; i
< height
; i
++)
1047 get_display_line (f
, vpos
+ i
, 0);
1048 display_string (w
, vpos
+ i
, "", 0, 0, 0, 1, 0, width
);
1051 goto finish_scroll_bars
;
1055 if (update_mode_lines
)
1056 w
->update_mode_line
= Qt
;
1058 /* Otherwise set up data on this window; select its buffer and point value */
1060 current_buffer
= XBUFFER (w
->buffer
);
1063 /* Count number of windows showing the selected buffer. */
1066 && current_buffer
== XBUFFER (XWINDOW (selected_window
)->buffer
))
1069 /* POINT refers normally to the selected window.
1070 For any other window, set up appropriate value. */
1072 if (!EQ (window
, selected_window
))
1074 SET_PT (marker_position (w
->pointm
));
1078 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1080 else if (point
> (ZV
- 1))
1083 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1087 /* If window-start is screwed up, choose a new one. */
1088 if (XMARKER (w
->start
)->buffer
!= current_buffer
)
1091 startp
= marker_position (w
->start
);
1093 /* Handle case where place to start displaying has been specified,
1094 unless the specified location is outside the accessible range. */
1095 if (!NILP (w
->force_start
))
1097 /* Forget any recorded base line for line number display. */
1098 w
->base_line_number
= Qnil
;
1099 w
->update_mode_line
= Qt
;
1100 w
->force_start
= Qnil
;
1101 XFASTINT (w
->last_modified
) = 0;
1102 if (startp
< BEGV
) startp
= BEGV
;
1103 if (startp
> ZV
) startp
= ZV
;
1104 try_window (window
, startp
);
1105 if (cursor_vpos
< 0)
1107 /* ??? What should happen here if highlighting a region? */
1108 /* If point does not appear, move point so it does appear */
1109 pos
= *compute_motion (startp
, 0,
1110 ((EQ (window
, minibuf_window
) && startp
== 1)
1111 ? minibuf_prompt_width
: 0)
1113 (hscroll
? 1 - hscroll
: 0),
1115 - (1 << (SHORTBITS
- 1)),
1116 width
, hscroll
, pos_tab_offset (w
, startp
));
1117 SET_PT (pos
.bufpos
);
1118 if (w
!= XWINDOW (selected_window
))
1119 Fset_marker (w
->pointm
, make_number (point
), Qnil
);
1122 if (current_buffer
== old
)
1124 FRAME_CURSOR_X (f
) = max (0, pos
.hpos
) + XFASTINT (w
->left
);
1125 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1131 /* Handle case where text has not changed, only point,
1132 and it has not moved off the frame */
1134 /* This code is not used for minibuffer for the sake of
1135 the case of redisplaying to replace an echo area message;
1136 since in that case the minibuffer contents per se are usually unchanged.
1137 This code is of no real use in the minibuffer since
1138 the handling of this_line_bufpos, etc.,
1139 in redisplay handles the same cases. */
1141 if (XFASTINT (w
->last_modified
) >= MODIFF
1142 && point
>= startp
&& !clip_changed
1143 && (just_this_one
|| XFASTINT (w
->width
) == FRAME_WIDTH (f
))
1144 /* Can't use this case if highlighting a region. */
1145 && !(!NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
))
1146 && NILP (w
->region_showing
)
1147 && !EQ (window
, minibuf_window
))
1149 pos
= *compute_motion (startp
, 0, (hscroll
? 1 - hscroll
: 0),
1150 point
, height
+ 1, 10000, width
, hscroll
,
1151 pos_tab_offset (w
, startp
));
1153 if (pos
.vpos
< height
)
1155 /* Ok, point is still on frame */
1156 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
1158 /* These variables are supposed to be origin 1 */
1159 FRAME_CURSOR_X (f
) = max (0, pos
.hpos
) + XFASTINT (w
->left
);
1160 FRAME_CURSOR_Y (f
) = pos
.vpos
+ XFASTINT (w
->top
);
1162 /* This doesn't do the trick, because if a window to the right of
1163 this one must be redisplayed, this does nothing because there
1164 is nothing in DesiredFrame yet, and then the other window is
1165 redisplayed, making likes that are empty in this window's columns.
1166 if (XFASTINT (w->width) != FRAME_WIDTH (f))
1167 preserve_my_columns (w);
1171 /* Don't bother trying redisplay with same start;
1172 we already know it will lose */
1174 /* If current starting point was originally the beginning of a line
1175 but no longer is, find a new starting point. */
1176 else if (!NILP (w
->start_at_line_beg
)
1178 || FETCH_CHAR (startp
- 1) == '\n'))
1182 else if (just_this_one
&& !MINI_WINDOW_P (w
)
1184 && XFASTINT (w
->last_modified
)
1185 /* or else vmotion on first line won't work. */
1186 && ! NILP (w
->start_at_line_beg
)
1187 && ! EQ (w
->window_end_valid
, Qnil
)
1188 && do_id
&& !clip_changed
1189 && !blank_end_of_window
1190 && XFASTINT (w
->width
) == FRAME_WIDTH (f
)
1191 /* Can't use this case if highlighting a region. */
1192 && !(!NILP (Vtransient_mark_mode
)
1193 && !NILP (current_buffer
->mark_active
))
1194 && NILP (w
->region_showing
)
1195 && EQ (last_arrow_position
, Voverlay_arrow_position
)
1196 && EQ (last_arrow_string
, Voverlay_arrow_string
)
1197 && (tem
= try_window_id (FRAME_SELECTED_WINDOW (f
)))
1200 /* tem > 0 means success. tem == -1 means choose new start.
1201 tem == -2 means try again with same start,
1202 and nothing but whitespace follows the changed stuff.
1203 tem == 0 means try again with same start. */
1207 else if (startp
>= BEGV
&& startp
<= ZV
1208 /* Avoid starting display at end of buffer! */
1209 && (startp
< ZV
|| startp
== BEGV
1210 || (XFASTINT (w
->last_modified
) >= MODIFF
)))
1212 /* Try to redisplay starting at same place as before */
1213 /* If point has not moved off frame, accept the results */
1214 try_window (window
, startp
);
1215 if (cursor_vpos
>= 0)
1217 if (!just_this_one
|| clip_changed
|| beg_unchanged
< startp
)
1218 /* Forget any recorded base line for line number display. */
1219 w
->base_line_number
= Qnil
;
1223 cancel_my_columns (w
);
1226 XFASTINT (w
->last_modified
) = 0;
1227 w
->update_mode_line
= Qt
;
1229 /* Try to scroll by specified few lines */
1231 if (scroll_step
&& !clip_changed
)
1235 pos
= *vmotion (Z
- XFASTINT (w
->window_end_pos
),
1236 scroll_step
, width
, hscroll
, window
);
1237 if (pos
.vpos
>= height
)
1241 pos
= *vmotion (startp
, point
< startp
? - scroll_step
: scroll_step
,
1242 width
, hscroll
, window
);
1244 if (point
>= pos
.bufpos
)
1246 try_window (window
, pos
.bufpos
);
1247 if (cursor_vpos
>= 0)
1249 if (!just_this_one
|| clip_changed
|| beg_unchanged
< startp
)
1250 /* Forget any recorded base line for line number display. */
1251 w
->base_line_number
= Qnil
;
1255 cancel_my_columns (w
);
1260 /* Finally, just choose place to start which centers point */
1263 /* Forget any previously recorded base line for line number display. */
1264 w
->base_line_number
= Qnil
;
1266 pos
= *vmotion (point
, - (height
/ 2), width
, hscroll
, window
);
1267 try_window (window
, pos
.bufpos
);
1269 startp
= marker_position (w
->start
);
1270 w
->start_at_line_beg
=
1271 (startp
== BEGV
|| FETCH_CHAR (startp
- 1) == '\n') ? Qt
: Qnil
;
1274 if ((!NILP (w
->update_mode_line
)
1275 /* If window not full width, must redo its mode line
1276 if the window to its side is being redone */
1277 || (!just_this_one
&& width
< FRAME_WIDTH (f
) - 1)
1278 || INTEGERP (w
->base_line_pos
))
1279 && height
!= XFASTINT (w
->height
))
1280 display_mode_line (w
);
1281 if (! line_number_displayed
1282 && ! BUFFERP (w
->base_line_pos
))
1284 w
->base_line_pos
= Qnil
;
1285 w
->base_line_number
= Qnil
;
1288 /* When we reach a frame's selected window, redo the frame's menu bar. */
1289 if (!NILP (w
->update_mode_line
)
1290 #ifdef USE_X_TOOLKIT
1291 && FRAME_EXTERNAL_MENU_BAR (f
)
1293 && FRAME_MENU_BAR_LINES (f
) > 0
1295 && EQ (FRAME_SELECTED_WINDOW (f
), window
))
1296 display_menu_bar (w
);
1299 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1301 int start
, end
, whole
;
1303 /* Calculate the start and end positions for the current window.
1304 At some point, it would be nice to choose between scrollbars
1305 which reflect the whole buffer size, with special markers
1306 indicating narrowing, and scrollbars which reflect only the
1309 Note that minibuffers sometimes aren't displaying any text. */
1310 if (! MINI_WINDOW_P (w
)
1311 || (w
== XWINDOW (minibuf_window
) && ! echo_area_glyphs
))
1314 start
= startp
- BEGV
;
1315 /* I don't think this is guaranteed to be right. For the
1316 moment, we'll pretend it is. */
1317 end
= (Z
- XINT (w
->window_end_pos
)) - BEGV
;
1319 if (end
< start
) end
= start
;
1320 if (whole
< (end
- start
)) whole
= end
- start
;
1323 start
= end
= whole
= 0;
1325 /* Indicate what this scroll bar ought to be displaying now. */
1326 (*set_vertical_scroll_bar_hook
) (w
, end
- start
, whole
, start
);
1328 /* Note that we actually used the scroll bar attached to this window,
1329 so it shouldn't be deleted at the end of redisplay. */
1330 (*redeem_scroll_bar_hook
) (w
);
1334 current_buffer
= old
;
1338 /* Do full redisplay on one window, starting at position `pos'. */
1341 try_window (window
, pos
)
1345 register struct window
*w
= XWINDOW (window
);
1346 register int height
= window_internal_height (w
);
1347 register int vpos
= XFASTINT (w
->top
);
1348 register int last_text_vpos
= vpos
;
1349 int tab_offset
= pos_tab_offset (w
, pos
);
1350 FRAME_PTR f
= XFRAME (w
->frame
);
1351 int width
= window_internal_width (w
) - 1;
1352 struct position val
;
1354 Fset_marker (w
->start
, make_number (pos
), Qnil
);
1356 overlay_arrow_seen
= 0;
1357 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
1359 while (--height
>= 0)
1361 val
= *display_text_line (w
, pos
, vpos
, val
.hpos
, tab_offset
);
1362 tab_offset
+= width
;
1363 if (val
.vpos
) tab_offset
= 0;
1365 if (pos
!= val
.bufpos
)
1367 /* Next line, unless prev line ended in end of buffer with no cr */
1368 = vpos
- (val
.vpos
&& (FETCH_CHAR (val
.bufpos
- 1) != '\n'
1369 #ifdef USE_TEXT_PROPERTIES
1370 || ! NILP (Fget_char_property (val
.bufpos
-1,
1378 /* If last line is continued in middle of character,
1379 include the split character in the text considered on the frame */
1380 if (val
.hpos
< (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
1383 /* If bottom just moved off end of frame, change mode line percentage. */
1384 if (XFASTINT (w
->window_end_pos
) == 0
1386 w
->update_mode_line
= Qt
;
1388 /* Say where last char on frame will be, once redisplay is finished. */
1389 XFASTINT (w
->window_end_pos
) = Z
- pos
;
1390 XFASTINT (w
->window_end_vpos
) = last_text_vpos
- XFASTINT (w
->top
);
1391 /* But that is not valid info until redisplay finishes. */
1392 w
->window_end_valid
= Qnil
;
1395 /* Try to redisplay when buffer is modified locally,
1396 computing insert/delete line to preserve text outside
1397 the bounds of the changes.
1398 Return 1 if successful, 0 if if cannot tell what to do,
1399 or -1 to tell caller to find a new window start,
1400 or -2 to tell caller to do normal redisplay with same window start. */
1403 try_window_id (window
)
1407 register struct window
*w
= XWINDOW (window
);
1408 register int height
= window_internal_height (w
);
1409 FRAME_PTR f
= XFRAME (w
->frame
);
1410 int top
= XFASTINT (w
->top
);
1411 int start
= marker_position (w
->start
);
1412 int width
= window_internal_width (w
) - 1;
1413 int hscroll
= XINT (w
->hscroll
);
1414 int lmargin
= hscroll
> 0 ? 1 - hscroll
: 0;
1416 register int i
, tem
;
1417 int last_text_vpos
= 0;
1420 = XTYPE (current_buffer
->selective_display
) == Lisp_Int
1421 ? XINT (current_buffer
->selective_display
)
1422 : !NILP (current_buffer
->selective_display
) ? -1 : 0;
1424 struct position val
, bp
, ep
, xp
, pp
;
1425 int scroll_amount
= 0;
1427 int tab_offset
, epto
;
1429 if (GPT
- BEG
< beg_unchanged
)
1430 beg_unchanged
= GPT
- BEG
;
1431 if (Z
- GPT
< end_unchanged
)
1432 end_unchanged
= Z
- GPT
;
1434 if (beg_unchanged
+ BEG
< start
)
1435 return 0; /* Give up if changes go above top of window */
1437 /* Find position before which nothing is changed. */
1438 bp
= *compute_motion (start
, 0, lmargin
,
1439 min (ZV
, beg_unchanged
+ BEG
), height
+ 1, 0,
1440 width
, hscroll
, pos_tab_offset (w
, start
));
1441 if (bp
.vpos
>= height
)
1443 if (point
< bp
.bufpos
&& !bp
.contin
)
1445 /* All changes are below the frame, and point is on the frame.
1446 We don't need to change the frame at all.
1447 But we need to update window_end_pos to account for
1448 any change in buffer size. */
1449 bp
= *compute_motion (start
, 0, lmargin
,
1451 width
, hscroll
, pos_tab_offset (w
, start
));
1452 XFASTINT (w
->window_end_vpos
) = height
;
1453 XFASTINT (w
->window_end_pos
) = Z
- bp
.bufpos
;
1461 /* Find beginning of that frame line. Must display from there. */
1462 bp
= *vmotion (bp
.bufpos
, 0, width
, hscroll
, window
);
1469 /* If about to start displaying at the beginning of a continuation line,
1470 really start with previous frame line, in case it was not
1471 continued when last redisplayed */
1472 if ((bp
.contin
&& bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0)
1474 /* Likewise if we have to worry about selective display. */
1475 (selective
> 0 && bp
.bufpos
- 1 == beg_unchanged
&& vpos
> 0))
1477 bp
= *vmotion (bp
.bufpos
, -1, width
, hscroll
, window
);
1482 if (bp
.contin
&& bp
.hpos
!= lmargin
)
1484 val
.hpos
= bp
.prevhpos
- width
+ lmargin
;
1490 /* Find first visible newline after which no more is changed. */
1491 tem
= find_next_newline (Z
- max (end_unchanged
, Z
- ZV
), 1);
1493 while (tem
< ZV
- 1 && (indented_beyond_p (tem
, selective
)))
1494 tem
= find_next_newline (tem
, 1);
1496 /* Compute the cursor position after that newline. */
1497 ep
= *compute_motion (pos
, vpos
, val
.hpos
, tem
,
1498 height
, - (1 << (SHORTBITS
- 1)),
1499 width
, hscroll
, pos_tab_offset (w
, bp
.bufpos
));
1501 /* If changes reach past the text available on the frame,
1502 just display rest of frame. */
1503 if (ep
.bufpos
> Z
- XFASTINT (w
->window_end_pos
))
1506 stop_vpos
= ep
.vpos
;
1508 /* If no newline before ep, the line ep is on includes some changes
1509 that must be displayed. Make sure we don't stop before it. */
1510 /* Also, if changes reach all the way until ep.bufpos,
1511 it is possible that something was deleted after the
1512 newline before it, so the following line must be redrawn. */
1513 if (stop_vpos
== ep
.vpos
1514 && (ep
.bufpos
== BEGV
1515 || FETCH_CHAR (ep
.bufpos
- 1) != '\n'
1516 || ep
.bufpos
== Z
- end_unchanged
))
1517 stop_vpos
= ep
.vpos
+ 1;
1520 overlay_arrow_seen
= 0;
1522 /* If changes do not reach to bottom of window,
1523 figure out how much to scroll the rest of the window */
1524 if (stop_vpos
< height
)
1526 /* Now determine how far up or down the rest of the window has moved */
1527 epto
= pos_tab_offset (w
, ep
.bufpos
);
1528 xp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
,
1529 Z
- XFASTINT (w
->window_end_pos
),
1530 10000, 0, width
, hscroll
, epto
);
1531 scroll_amount
= xp
.vpos
- XFASTINT (w
->window_end_vpos
);
1533 /* Is everything on frame below the changes whitespace?
1534 If so, no scrolling is really necessary. */
1535 for (i
= ep
.bufpos
; i
< xp
.bufpos
; i
++)
1537 tem
= FETCH_CHAR (i
);
1538 if (tem
!= ' ' && tem
!= '\n' && tem
!= '\t')
1544 XFASTINT (w
->window_end_vpos
) += scroll_amount
;
1546 /* Before doing any scrolling, verify that point will be on frame. */
1547 if (point
> ep
.bufpos
&& !(point
<= xp
.bufpos
&& xp
.bufpos
< height
))
1549 if (point
<= xp
.bufpos
)
1551 pp
= *compute_motion (ep
.bufpos
, ep
.vpos
, ep
.hpos
,
1552 point
, height
, - (1 << (SHORTBITS
- 1)),
1553 width
, hscroll
, epto
);
1557 pp
= *compute_motion (xp
.bufpos
, xp
.vpos
, xp
.hpos
,
1558 point
, height
, - (1 << (SHORTBITS
- 1)),
1559 width
, hscroll
, pos_tab_offset (w
, xp
.bufpos
));
1561 if (pp
.bufpos
< point
|| pp
.vpos
== height
)
1563 cursor_vpos
= pp
.vpos
+ top
;
1564 cursor_hpos
= pp
.hpos
+ XFASTINT (w
->left
);
1567 if (stop_vpos
- scroll_amount
>= height
1568 || ep
.bufpos
== xp
.bufpos
)
1570 if (scroll_amount
< 0)
1571 stop_vpos
-= scroll_amount
;
1573 /* In this path, we have altered window_end_vpos
1574 and not left it negative.
1575 We must make sure that, in case display is preempted
1576 before the frame changes to reflect what we do here,
1577 further updates will not come to try_window_id
1578 and assume the frame and window_end_vpos match. */
1579 blank_end_of_window
= 1;
1581 else if (!scroll_amount
)
1583 else if (bp
.bufpos
== Z
- end_unchanged
)
1585 /* If reprinting everything is nearly as fast as scrolling,
1586 don't bother scrolling. Can happen if lines are short. */
1587 if (scroll_cost (f
, bp
.vpos
+ top
- scroll_amount
,
1588 top
+ height
- max (0, scroll_amount
),
1590 > xp
.bufpos
- bp
.bufpos
- 20)
1591 /* Return "try normal display with same window-start."
1592 Too bad we can't prevent further scroll-thinking. */
1594 /* If pure deletion, scroll up as many lines as possible.
1595 In common case of killing a line, this can save the
1596 following line from being overwritten by scrolling
1597 and therefore having to be redrawn. */
1598 tem
= scroll_frame_lines (f
, bp
.vpos
+ top
- scroll_amount
,
1599 top
+ height
- max (0, scroll_amount
),
1601 if (!tem
) stop_vpos
= height
;
1603 else if (scroll_amount
)
1605 /* If reprinting everything is nearly as fast as scrolling,
1606 don't bother scrolling. Can happen if lines are short. */
1607 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an
1608 overestimate of cost of reprinting, since xp.bufpos
1609 would end up below the bottom of the window. */
1610 if (scroll_cost (f
, ep
.vpos
+ top
- scroll_amount
,
1611 top
+ height
- max (0, scroll_amount
),
1613 > xp
.bufpos
- ep
.bufpos
- 20)
1614 /* Return "try normal display with same window-start."
1615 Too bad we can't prevent further scroll-thinking. */
1617 tem
= scroll_frame_lines (f
, ep
.vpos
+ top
- scroll_amount
,
1618 top
+ height
- max (0, scroll_amount
),
1620 if (!tem
) stop_vpos
= height
;
1624 /* In any case, do not display past bottom of window */
1625 if (stop_vpos
>= height
)
1631 /* Handle case where pos is before w->start --
1632 can happen if part of line had been clipped and is not clipped now */
1633 if (vpos
== 0 && pos
< marker_position (w
->start
))
1634 Fset_marker (w
->start
, make_number (pos
), Qnil
);
1636 /* Redisplay the lines where the text was changed */
1637 last_text_vpos
= vpos
;
1638 tab_offset
= pos_tab_offset (w
, pos
);
1639 /* If we are starting display in mid-character, correct tab_offset
1640 to account for passing the line that that character really starts in. */
1641 if (val
.hpos
< lmargin
)
1642 tab_offset
+= width
;
1643 while (vpos
< stop_vpos
)
1645 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
1646 tab_offset
+= width
;
1647 if (val
.vpos
) tab_offset
= 0;
1648 if (pos
!= val
.bufpos
)
1650 /* Next line, unless prev line ended in end of buffer with no cr */
1651 = vpos
- (val
.vpos
&& FETCH_CHAR (val
.bufpos
- 1) != '\n');
1655 /* There are two cases:
1656 1) we have displayed down to the bottom of the window
1657 2) we have scrolled lines below stop_vpos by scroll_amount */
1661 /* If last line is continued in middle of character,
1662 include the split character in the text considered on the frame */
1663 if (val
.hpos
< lmargin
)
1665 XFASTINT (w
->window_end_vpos
) = last_text_vpos
;
1666 XFASTINT (w
->window_end_pos
) = Z
- val
.bufpos
;
1669 /* If scrolling made blank lines at window bottom,
1670 redisplay to fill those lines */
1671 if (scroll_amount
< 0)
1673 /* Don't consider these lines for general-purpose scrolling.
1674 That will save time in the scrolling computation. */
1675 FRAME_SCROLL_BOTTOM_VPOS (f
) = xp
.vpos
;
1680 vpos
= height
+ scroll_amount
;
1681 else if (xp
.contin
&& xp
.hpos
!= lmargin
)
1683 val
.hpos
= xp
.prevhpos
- width
+ lmargin
;
1687 blank_end_of_window
= 1;
1688 tab_offset
= pos_tab_offset (w
, pos
);
1689 /* If we are starting display in mid-character, correct tab_offset
1690 to account for passing the line that that character starts in. */
1691 if (val
.hpos
< lmargin
)
1692 tab_offset
+= width
;
1694 while (vpos
< height
)
1696 val
= *display_text_line (w
, pos
, top
+ vpos
++, val
.hpos
, tab_offset
);
1697 tab_offset
+= width
;
1698 if (val
.vpos
) tab_offset
= 0;
1702 /* Here is a case where display_text_line sets cursor_vpos wrong.
1703 Make it be fixed up, below. */
1705 && xp
.bufpos
== point
)
1709 /* If bottom just moved off end of frame, change mode line percentage. */
1710 if (XFASTINT (w
->window_end_pos
) == 0
1712 w
->update_mode_line
= Qt
;
1714 /* Attempt to adjust end-of-text positions to new bottom line */
1717 delta
= height
- xp
.vpos
;
1719 || (delta
> 0 && xp
.bufpos
<= ZV
)
1720 || (delta
== 0 && xp
.hpos
))
1722 val
= *vmotion (Z
- XFASTINT (w
->window_end_pos
),
1723 delta
, width
, hscroll
, window
);
1724 XFASTINT (w
->window_end_pos
) = Z
- val
.bufpos
;
1725 XFASTINT (w
->window_end_vpos
) += val
.vpos
;
1729 w
->window_end_valid
= Qnil
;
1731 /* If point was not in a line that was displayed, find it */
1732 if (cursor_vpos
< 0)
1734 val
= *compute_motion (start
, 0, lmargin
, point
, 10000, 10000,
1735 width
, hscroll
, pos_tab_offset (w
, start
));
1736 /* Admit failure if point is off frame now */
1737 if (val
.vpos
>= height
)
1739 for (vpos
= 0; vpos
< height
; vpos
++)
1740 cancel_line (vpos
+ top
, f
);
1743 cursor_vpos
= val
.vpos
+ top
;
1744 cursor_hpos
= val
.hpos
+ XFASTINT (w
->left
);
1747 FRAME_CURSOR_X (f
) = max (0, cursor_hpos
);
1748 FRAME_CURSOR_Y (f
) = cursor_vpos
;
1752 val
= *compute_motion (start
, 0, lmargin
, ZV
,
1753 height
, - (1 << (SHORTBITS
- 1)),
1754 width
, hscroll
, pos_tab_offset (w
, start
));
1755 if (val
.vpos
!= XFASTINT (w
->window_end_vpos
))
1757 if (XFASTINT (w
->window_end_pos
)
1765 /* Mark a section of BUF as modified, but only for the sake of redisplay.
1766 This is useful for recording changes to overlays.
1768 We increment the buffer's modification timestamp and set the
1769 redisplay caches (windows_or_buffers_changed, beg_unchanged, etc)
1770 as if the region of text between START and END had been modified;
1771 the redisplay code will check this against the windows' timestamps,
1772 and redraw the appropriate area of the buffer.
1774 However, if the buffer is unmodified, we bump the last-save
1775 timestamp as well, so that incrementing the timestamp doesn't fool
1776 Emacs into thinking that the buffer's text has been modified.
1778 Tweaking the timestamps shouldn't hurt the first-modification
1779 timestamps recorded in the undo records; those values aren't
1780 written until just before a real text modification is made, so they
1781 will never catch the timestamp value just before this function gets
1785 redisplay_region (buf
, start
, end
)
1795 start
= end
; end
= temp
;
1798 if (buf
!= current_buffer
)
1799 windows_or_buffers_changed
= 1;
1802 if (unchanged_modified
== MODIFF
)
1804 beg_unchanged
= start
- BEG
;
1805 end_unchanged
= Z
- end
;
1809 if (Z
- end
< end_unchanged
)
1810 end_unchanged
= Z
- end
;
1811 if (start
- BEG
< beg_unchanged
)
1812 beg_unchanged
= start
- BEG
;
1816 /* Increment the buffer's time stamp, but also increment the save
1817 and autosave timestamps, so as not to screw up that timekeeping. */
1818 if (BUF_MODIFF (buf
) == buf
->save_modified
)
1819 buf
->save_modified
++;
1820 if (BUF_MODIFF (buf
) == buf
->auto_save_modified
)
1821 buf
->auto_save_modified
++;
1823 BUF_MODIFF (buf
) ++;
1827 /* Copy LEN glyphs starting address FROM to the rope TO.
1828 But don't actually copy the parts that would come in before S.
1829 Value is TO, advanced past the copied data.
1830 F is the frame we are displaying in. */
1833 copy_part_of_rope (f
, to
, s
, from
, len
, face
)
1835 register GLYPH
*to
; /* Copy to here. */
1836 register GLYPH
*s
; /* Starting point. */
1837 Lisp_Object
*from
; /* Data to copy. */
1839 int face
; /* Face to apply to glyphs which don't specify one. */
1842 register Lisp_Object
*fp
= from
;
1843 /* These cache the results of the last call to compute_glyph_face. */
1845 int last_merged
= 0;
1847 #ifdef HAVE_X_WINDOWS
1848 if (! FRAME_TERMCAP_P (f
))
1851 int glyph
= XFASTINT (*fp
);
1854 if (FAST_GLYPH_FACE (glyph
) == 0)
1855 /* If GLYPH has no face code, use FACE. */
1857 else if (FAST_GLYPH_FACE (glyph
) == last_code
)
1858 /* If it's same as previous glyph, use same result. */
1859 facecode
= last_merged
;
1862 /* Merge this glyph's face and remember the result. */
1863 last_code
= FAST_GLYPH_FACE (glyph
);
1864 last_merged
= facecode
= compute_glyph_face (f
, last_code
, face
);
1868 *to
= FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
), facecode
);
1876 if (to
>= s
) *to
= XFASTINT (*fp
);
1883 /* Correct a glyph by replacing its specified user-level face code
1884 with a displayable computed face code. */
1887 fix_glyph (f
, glyph
, current_face
)
1892 #ifdef HAVE_X_WINDOWS
1893 if (! FRAME_TERMCAP_P (f
) && FAST_GLYPH_FACE (glyph
) != 0)
1894 return FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph
),
1895 compute_glyph_face (f
, FAST_GLYPH_FACE (glyph
),
1901 /* Display one line of window w, starting at position START in W's buffer.
1902 Display starting at horizontal position HPOS, which is normally zero
1903 or negative. A negative value causes output up to hpos = 0 to be discarded.
1904 This is done for negative hscroll, or when this is a continuation line
1905 and the continuation occurred in the middle of a multi-column character.
1907 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations.
1909 Display on position VPOS on the frame. (origin 0).
1911 Returns a STRUCT POSITION giving character to start next line with
1912 and where to display it, including a zero or negative hpos.
1913 The vpos field is not really a vpos; it is 1 unless the line is continued */
1915 struct position val_display_text_line
;
1917 static struct position
*
1918 display_text_line (w
, start
, vpos
, hpos
, taboffset
)
1925 register int pos
= start
;
1930 register unsigned char *p
;
1932 register GLYPH
*startp
;
1933 register GLYPH
*p1prev
= 0;
1934 register GLYPH
*p1start
;
1936 FRAME_PTR f
= XFRAME (w
->frame
);
1937 int tab_width
= XINT (current_buffer
->tab_width
);
1938 int ctl_arrow
= !NILP (current_buffer
->ctl_arrow
);
1939 int width
= window_internal_width (w
) - 1;
1940 struct position val
;
1943 int hscroll
= XINT (w
->hscroll
);
1944 int truncate
= hscroll
1945 || (truncate_partial_width_windows
1946 && XFASTINT (w
->width
) < FRAME_WIDTH (f
))
1947 || !NILP (current_buffer
->truncate_lines
);
1949 /* 1 if we should highlight the region. */
1950 int highlight_region
1951 = !NILP (Vtransient_mark_mode
) && !NILP (current_buffer
->mark_active
);
1952 int region_beg
, region_end
;
1955 = XTYPE (current_buffer
->selective_display
) == Lisp_Int
1956 ? XINT (current_buffer
->selective_display
)
1957 : !NILP (current_buffer
->selective_display
) ? -1 : 0;
1958 register struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
1959 register struct Lisp_Vector
*dp
= window_display_table (w
);
1961 Lisp_Object default_invis_vector
[3];
1962 /* Nonzero means display something where there are invisible lines.
1963 The precise value is the number of glyphs to display. */
1965 = (selective
&& dp
&& XTYPE (DISP_INVIS_VECTOR (dp
)) == Lisp_Vector
1966 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->size
1967 : selective
&& !NILP (current_buffer
->selective_display_ellipses
)
1969 /* This is the sequence of Lisp objects to display
1970 when there are invisible lines. */
1971 Lisp_Object
*invis_vector_contents
1972 = (dp
&& XTYPE (DISP_INVIS_VECTOR (dp
)) == Lisp_Vector
1973 ? XVECTOR (DISP_INVIS_VECTOR (dp
))->contents
1974 : default_invis_vector
);
1976 GLYPH truncator
= (dp
== 0 || XTYPE (DISP_TRUNC_GLYPH (dp
)) != Lisp_Int
1977 ? '$' : XINT (DISP_TRUNC_GLYPH (dp
)));
1978 GLYPH continuer
= (dp
== 0 || XTYPE (DISP_CONTINUE_GLYPH (dp
)) != Lisp_Int
1979 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp
)));
1981 /* The next buffer location at which the face should change, due
1982 to overlays or text property changes. */
1983 int next_face_change
;
1985 #ifdef USE_TEXT_PROPERTIES
1986 /* The next location where the `invisible' property changes */
1990 /* The face we're currently using. */
1991 int current_face
= 0;
1994 XFASTINT (default_invis_vector
[2]) = '.';
1995 default_invis_vector
[0] = default_invis_vector
[1] = default_invis_vector
[2];
1997 hpos
+= XFASTINT (w
->left
);
1998 get_display_line (f
, vpos
, XFASTINT (w
->left
));
1999 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
2001 /* Show where to highlight the region. */
2002 if (highlight_region
&& XMARKER (current_buffer
->mark
)->buffer
!= 0
2003 /* Maybe highlight only in selected window. */
2004 && (highlight_nonselected_windows
2005 || w
== XWINDOW (selected_window
)))
2007 region_beg
= marker_position (current_buffer
->mark
);
2008 if (PT
< region_beg
)
2010 region_end
= region_beg
;
2015 w
->region_showing
= Qt
;
2018 region_beg
= region_end
= -1;
2020 if (MINI_WINDOW_P (w
) && start
== 1
2021 && vpos
== XFASTINT (w
->top
))
2024 hpos
= display_string (w
, vpos
, minibuf_prompt
, -1, hpos
,
2025 (!truncate
? continuer
: truncator
),
2027 minibuf_prompt_width
= hpos
;
2030 desired_glyphs
->bufp
[vpos
] = pos
;
2031 p1
= desired_glyphs
->glyphs
[vpos
] + hpos
;
2033 charstart
= desired_glyphs
->charstarts
[vpos
] + hpos
;
2034 /* In case we don't ever write anything into it... */
2037 startp
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
2038 endp
= startp
+ width
;
2040 /* Arrange the overlays nicely for our purposes. Usually, we call
2041 display_text_line on only one line at a time, in which case this
2042 can't really hurt too much, or we call it on lines which appear
2043 one after another in the buffer, in which case all calls to
2044 recenter_overlay_lists but the first will be pretty cheap. */
2045 recenter_overlay_lists (current_buffer
, pos
);
2047 /* Loop generating characters.
2048 Stop at end of buffer, before newline,
2049 if reach or pass continuation column,
2050 or at face change. */
2052 next_face_change
= pos
;
2053 #ifdef USE_TEXT_PROPERTIES
2054 next_invisible
= pos
;
2058 /* Record which glyph starts a character,
2059 and the character position of that character. */
2060 charstart
[p1
- p1start
] = pos
;
2065 /* Did we hit the end of the visible region of the buffer?
2070 /* Did we reach point? Record the cursor location. */
2071 if (pos
== point
&& cursor_vpos
< 0)
2074 cursor_hpos
= p1
- startp
;
2077 #ifdef USE_TEXT_PROPERTIES
2078 /* if the `invisible' property is set to t, we can skip to
2079 the next property change */
2080 while (pos
== next_invisible
&& pos
< end
)
2082 Lisp_Object position
, limit
, endpos
, prop
, ww
;
2083 XFASTINT (position
) = pos
;
2084 XSET (ww
, Lisp_Window
, w
);
2085 prop
= Fget_char_property (position
, Qinvisible
, ww
);
2086 /* This is just an estimate to give reasonable
2087 performance; nothing should go wrong if it is too small. */
2088 limit
= Fnext_overlay_change (position
);
2089 if (XFASTINT (limit
) > pos
+ 50)
2090 XFASTINT (limit
) = pos
+ 50;
2091 endpos
= Fnext_single_property_change (position
, Qinvisible
,
2092 Fcurrent_buffer (), limit
);
2093 if (INTEGERP (endpos
))
2094 next_invisible
= XINT (endpos
);
2096 next_invisible
= end
;
2099 if (pos
< point
&& next_invisible
>= point
)
2102 cursor_hpos
= p1
- startp
;
2104 pos
= next_invisible
;
2111 #ifdef HAVE_X_WINDOWS
2112 /* Did we hit a face change? Figure out what face we should
2113 use now. We also hit this the first time through the
2114 loop, to see what face we should start with. */
2115 if (pos
>= next_face_change
&& FRAME_X_P (f
))
2116 current_face
= compute_char_face (f
, w
, pos
,
2117 region_beg
, region_end
,
2118 &next_face_change
, pos
+ 50, 0);
2123 #ifdef USE_TEXT_PROPERTIES
2124 if (pos
< next_invisible
&& next_invisible
< pause
)
2125 pause
= next_invisible
;
2127 if (pos
< next_face_change
&& next_face_change
< pause
)
2128 pause
= next_face_change
;
2130 /* Wouldn't you hate to read the next line to someone over
2132 if (pos
< point
&& point
< pause
)
2134 if (pos
< GPT
&& GPT
< pause
)
2137 p
= &FETCH_CHAR (pos
);
2140 if (c
>= 040 && c
< 0177
2141 && (dp
== 0 || XTYPE (DISP_CHAR_VECTOR (dp
, c
)) != Lisp_Vector
))
2144 *p1
= MAKE_GLYPH (f
, c
, current_face
);
2152 && indented_beyond_p (pos
+ 1, selective
))
2155 pos
= find_next_newline (pos
+ 1, 1);
2156 if (FETCH_CHAR (pos
- 1) == '\n')
2159 if (invis
&& selective_rlen
> 0 && p1
>= startp
)
2161 p1
+= selective_rlen
;
2162 if (p1
- startp
> width
)
2164 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2165 (p1
- p1prev
), current_face
);
2167 #ifdef HAVE_X_WINDOWS
2168 /* Draw the face of the newline character as extending all the
2169 way to the end of the frame line. */
2172 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2180 if (p1
>= startp
&& p1
< endp
)
2181 *p1
= MAKE_GLYPH (f
, ' ', current_face
);
2184 while ((p1
- startp
+ taboffset
+ hscroll
- (hscroll
> 0))
2187 else if (c
== Ctl ('M') && selective
== -1)
2189 pos
= find_next_newline (pos
, 1);
2190 if (FETCH_CHAR (pos
- 1) == '\n')
2192 if (selective_rlen
> 0)
2194 p1
+= selective_rlen
;
2195 if (p1
- startp
> width
)
2197 copy_part_of_rope (f
, p1prev
, p1prev
, invis_vector_contents
,
2198 (p1
- p1prev
), current_face
);
2200 #ifdef HAVE_X_WINDOWS
2201 /* Draw the face of the newline character as extending all the
2202 way to the end of the frame line. */
2205 *p1
++ = FAST_MAKE_GLYPH (' ', current_face
);
2209 else if (dp
!= 0 && XTYPE (DISP_CHAR_VECTOR (dp
, c
)) == Lisp_Vector
)
2211 p1
= copy_part_of_rope (f
, p1
, startp
,
2212 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
2213 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
2216 else if (c
< 0200 && ctl_arrow
)
2219 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_CTRL_GLYPH (dp
)) == Lisp_Int
2220 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
2223 if (p1
>= startp
&& p1
< endp
)
2224 *p1
= MAKE_GLYPH (f
, c
^ 0100, current_face
);
2230 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_ESCAPE_GLYPH (dp
)) == Lisp_Int
2231 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
2234 if (p1
>= startp
&& p1
< endp
)
2235 *p1
= MAKE_GLYPH (f
, (c
>> 6) + '0', current_face
);
2237 if (p1
>= startp
&& p1
< endp
)
2238 *p1
= MAKE_GLYPH (f
, (7 & (c
>> 3)) + '0', current_face
);
2240 if (p1
>= startp
&& p1
< endp
)
2241 *p1
= MAKE_GLYPH (f
, (7 & c
) + '0', current_face
);
2245 /* For all the glyphs occupied by this character, except for the
2246 first, store -1 in charstarts. */
2249 int *p2x
= &charstart
[p1prev
- p1start
] + 1;
2250 int *p2
= &charstart
[p1
- p1start
];
2255 /* If this character took up no space,
2256 erase all mention of it from charstart. */
2257 charstart
[p1
- p1start
] = 0;
2261 val
.hpos
= - XINT (w
->hscroll
);
2269 /* Store 0 in this charstart line for the positions where
2270 there is no character. But do leave what was recorded
2271 for the character that ended the line. */
2272 for (i
= p1
- p1start
+ 1; i
< endp
- p1start
; i
++)
2275 /* Handle continuation in middle of a character */
2276 /* by backing up over it */
2279 /* Don't back up if we never actually displayed any text.
2280 This occurs when the minibuffer prompt takes up the whole line. */
2283 /* Start the next line with that same character */
2285 /* but at negative hpos, to skip the columns output on this line. */
2286 val
.hpos
+= p1prev
- endp
;
2289 /* Keep in this line everything up to the continuation column. */
2293 /* Finish deciding which character to start the next line on,
2294 and what hpos to start it at.
2295 Also set `lastpos' to the last position which counts as "on this line"
2296 for cursor-positioning. */
2300 if (FETCH_CHAR (pos
) == '\n')
2302 /* If stopped due to a newline, start next line after it */
2304 /* Check again for hidden lines, in case the newline occurred exactly
2305 at the right margin. */
2306 while (pos
< ZV
&& selective
> 0
2307 && indented_beyond_p (pos
, selective
))
2308 pos
= find_next_newline (pos
, 1);
2311 /* Stopped due to right margin of window */
2315 *p1
++ = fix_glyph (f
, truncator
, 0);
2316 /* Truncating => start next line after next newline,
2317 and point is on this line if it is before the newline,
2318 and skip none of first char of next line */
2320 pos
= find_next_newline (pos
, 1);
2321 while (pos
< ZV
&& selective
> 0
2322 && indented_beyond_p (pos
, selective
));
2323 val
.hpos
= XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0;
2325 lastpos
= pos
- (FETCH_CHAR (pos
- 1) == '\n');
2329 *p1
++ = fix_glyph (f
, continuer
, 0);
2336 /* If point is at eol or in invisible text at eol,
2337 record its frame location now. */
2339 if (start
<= point
&& point
<= lastpos
&& cursor_vpos
< 0)
2342 cursor_hpos
= p1
- startp
;
2345 if (cursor_vpos
== vpos
)
2347 if (cursor_hpos
< 0) cursor_hpos
= 0;
2348 if (cursor_hpos
> width
) cursor_hpos
= width
;
2349 cursor_hpos
+= XFASTINT (w
->left
);
2350 if (w
== XWINDOW (FRAME_SELECTED_WINDOW (f
)))
2352 FRAME_CURSOR_Y (f
) = cursor_vpos
;
2353 FRAME_CURSOR_X (f
) = cursor_hpos
;
2355 if (w
== XWINDOW (selected_window
))
2357 /* Line is not continued and did not start
2358 in middle of character */
2359 if ((hpos
- XFASTINT (w
->left
)
2360 == (XINT (w
->hscroll
) ? 1 - XINT (w
->hscroll
) : 0))
2363 this_line_bufpos
= start
;
2364 this_line_buffer
= current_buffer
;
2365 this_line_vpos
= cursor_vpos
;
2366 this_line_start_hpos
= hpos
;
2367 this_line_endpos
= Z
- lastpos
;
2370 this_line_bufpos
= 0;
2375 /* If hscroll and line not empty, insert truncation-at-left marker */
2376 if (hscroll
&& lastpos
!= start
)
2378 *startp
= fix_glyph (f
, truncator
, 0);
2383 if (XFASTINT (w
->width
) + XFASTINT (w
->left
) != FRAME_WIDTH (f
))
2386 if (p1
< startp
) p1
= startp
;
2387 while (p1
< endp
) *p1
++ = SPACEGLYPH
;
2389 /* Don't draw vertical bars if we're using scroll bars. They're
2390 covered up by the scroll bars, and it's distracting to see
2391 them when the scroll bar windows are flickering around to be
2393 *p1
++ = (FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2396 desired_glyphs
->used
[vpos
] = max (desired_glyphs
->used
[vpos
],
2397 p1
- desired_glyphs
->glyphs
[vpos
]);
2398 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
2400 /* If the start of this line is the overlay arrow-position,
2401 then put the arrow string into the display-line. */
2403 if (XTYPE (Voverlay_arrow_position
) == Lisp_Marker
2404 && current_buffer
== XMARKER (Voverlay_arrow_position
)->buffer
2405 && start
== marker_position (Voverlay_arrow_position
)
2406 && XTYPE (Voverlay_arrow_string
) == Lisp_String
2407 && ! overlay_arrow_seen
)
2409 unsigned char *p
= XSTRING (Voverlay_arrow_string
)->data
;
2411 int len
= XSTRING (Voverlay_arrow_string
)->size
;
2416 for (i
= 0; i
< len
; i
++)
2419 /* Bug in SunOS 4.1.1 compiler requires this intermediate variable. */
2420 arrow_end
= (startp
- desired_glyphs
->glyphs
[vpos
]) + len
;
2421 if (desired_glyphs
->used
[vpos
] < arrow_end
)
2422 desired_glyphs
->used
[vpos
] = arrow_end
;
2424 overlay_arrow_seen
= 1;
2428 val_display_text_line
= val
;
2429 return &val_display_text_line
;
2432 /* Redisplay the menu bar in the frame for window W. */
2435 display_menu_bar (w
)
2438 Lisp_Object items
, tail
;
2439 register int vpos
= 0;
2440 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2441 int maxendcol
= FRAME_WIDTH (f
);
2445 #ifndef USE_X_TOOLKIT
2446 if (FRAME_MENU_BAR_LINES (f
) <= 0)
2449 get_display_line (f
, vpos
, 0);
2451 items
= FRAME_MENU_BAR_ITEMS (f
);
2452 for (i
= 0; i
< XVECTOR (items
)->size
; i
+= 3)
2454 Lisp_Object pos
, string
;
2455 string
= XVECTOR (items
)->contents
[i
+ 1];
2459 XFASTINT (XVECTOR (items
)->contents
[i
+ 2]) = hpos
;
2461 if (hpos
< maxendcol
)
2462 hpos
= display_string (XWINDOW (FRAME_ROOT_WINDOW (f
)), vpos
,
2463 XSTRING (string
)->data
,
2464 XSTRING (string
)->size
,
2465 hpos
, 0, 0, hpos
, maxendcol
);
2466 /* Put a gap of 3 spaces between items. */
2467 if (hpos
< maxendcol
)
2469 int hpos1
= hpos
+ 3;
2470 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0,
2471 min (hpos1
, maxendcol
), maxendcol
);
2475 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
2476 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
2478 /* Fill out the line with spaces. */
2479 if (maxendcol
> hpos
)
2480 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 0, maxendcol
, maxendcol
);
2482 /* Clear the rest of the lines allocated to the menu bar. */
2484 while (vpos
< FRAME_MENU_BAR_LINES (f
))
2485 get_display_line (f
, vpos
++, 0);
2486 #endif /* not USE_X_TOOLKIT */
2489 /* Display the mode line for window w */
2492 display_mode_line (w
)
2495 register int vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
2496 register int left
= XFASTINT (w
->left
);
2497 register int right
= XFASTINT (w
->width
) + left
;
2498 register FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2500 line_number_displayed
= 0;
2502 get_display_line (f
, vpos
, left
);
2503 display_mode_element (w
, vpos
, left
, 0, right
, right
,
2504 current_buffer
->mode_line_format
);
2505 FRAME_DESIRED_GLYPHS (f
)->bufp
[vpos
] = 0;
2507 /* Make the mode line inverse video if the entire line
2508 is made of mode lines.
2509 I.e. if this window is full width,
2510 or if it is the child of a full width window
2511 (which implies that that window is split side-by-side
2512 and the rest of this line is mode lines of the sibling windows). */
2513 if (XFASTINT (w
->width
) == FRAME_WIDTH (f
)
2514 || XFASTINT (XWINDOW (w
->parent
)->width
) == FRAME_WIDTH (f
))
2515 FRAME_DESIRED_GLYPHS (f
)->highlight
[vpos
] = mode_line_inverse_video
;
2516 #ifdef HAVE_X_WINDOWS
2517 else if (! FRAME_TERMCAP_P (f
))
2519 /* For a partial width window, explicitly set face of each glyph. */
2521 GLYPH
*ptr
= FRAME_DESIRED_GLYPHS (f
)->glyphs
[vpos
];
2522 for (i
= left
; i
< right
; ++i
)
2523 ptr
[i
] = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (ptr
[i
]), 1);
2527 #ifdef HAVE_X_WINDOWS
2528 if (w
== XWINDOW (f
->selected_window
))
2529 x_consider_frame_title (WINDOW_FRAME (w
));
2533 /* Contribute ELT to the mode line for window W.
2534 How it translates into text depends on its data type.
2536 VPOS is the position of the mode line being displayed.
2538 HPOS is the position (absolute on frame) where this element's text
2539 should start. The output is truncated automatically at the right
2542 DEPTH is the depth in recursion. It is used to prevent
2543 infinite recursion here.
2545 MINENDCOL is the hpos before which the element may not end.
2546 The element is padded at the right with spaces if nec
2547 to reach this column.
2549 MAXENDCOL is the hpos past which this element may not extend.
2550 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority.
2551 (This is necessary to make nested padding and truncation work.)
2553 Returns the hpos of the end of the text generated by ELT.
2554 The next element will receive that value as its HPOS arg,
2555 so as to concatenate the elements. */
2558 display_mode_element (w
, vpos
, hpos
, depth
, minendcol
, maxendcol
, elt
)
2560 register int vpos
, hpos
;
2563 register int maxendcol
;
2564 register Lisp_Object elt
;
2572 #ifdef SWITCH_ENUM_BUG
2573 switch ((int) XTYPE (elt
))
2575 switch (XTYPE (elt
))
2580 /* A string: output it and check for %-constructs within it. */
2581 register unsigned char c
;
2582 register unsigned char *this = XSTRING (elt
)->data
;
2584 while (hpos
< maxendcol
&& *this)
2586 unsigned char *last
= this;
2587 while ((c
= *this++) != '\0' && c
!= '%')
2589 if (this - 1 != last
)
2591 register int lim
= --this - last
+ hpos
;
2592 hpos
= display_string (w
, vpos
, last
, -1, hpos
, 0, 1,
2593 hpos
, min (lim
, maxendcol
));
2597 register int spec_width
= 0;
2599 /* We can't allow -ve args due to the "%-" construct */
2600 /* Argument specifies minwidth but not maxwidth
2601 (maxwidth can be specified by
2602 (<negative-number> . <stuff>) mode-line elements) */
2604 while ((c
= *this++) >= '0' && c
<= '9')
2606 spec_width
= spec_width
* 10 + (c
- '0');
2610 if (spec_width
> maxendcol
)
2611 spec_width
= maxendcol
;
2614 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
2615 spec_width
, maxendcol
,
2616 Vglobal_mode_string
);
2618 hpos
= display_string (w
, vpos
,
2619 decode_mode_spec (w
, c
,
2622 hpos
, 0, 1, spec_width
, maxendcol
);
2629 /* A symbol: process the value of the symbol recursively
2630 as if it appeared here directly. Avoid error if symbol void.
2631 Special case: if value of symbol is a string, output the string
2634 register Lisp_Object tem
;
2635 tem
= Fboundp (elt
);
2638 tem
= Fsymbol_value (elt
);
2639 /* If value is a string, output that string literally:
2640 don't check for % within it. */
2641 if (XTYPE (tem
) == Lisp_String
)
2642 hpos
= display_string (w
, vpos
, XSTRING (tem
)->data
,
2643 XSTRING (tem
)->size
,
2644 hpos
, 0, 1, minendcol
, maxendcol
);
2645 /* Give up right away for nil or t. */
2646 else if (!EQ (tem
, elt
))
2647 { elt
= tem
; goto tail_recurse
; }
2654 register Lisp_Object car
, tem
;
2656 /* A cons cell: three distinct cases.
2657 If first element is a string or a cons, process all the elements
2658 and effectively concatenate them.
2659 If first element is a negative number, truncate displaying cdr to
2660 at most that many characters. If positive, pad (with spaces)
2661 to at least that many characters.
2662 If first element is a symbol, process the cadr or caddr recursively
2663 according to whether the symbol's value is non-nil or nil. */
2664 car
= XCONS (elt
)->car
;
2665 if (XTYPE (car
) == Lisp_Symbol
)
2667 tem
= Fboundp (car
);
2668 elt
= XCONS (elt
)->cdr
;
2669 if (XTYPE (elt
) != Lisp_Cons
)
2671 /* elt is now the cdr, and we know it is a cons cell.
2672 Use its car if CAR has a non-nil value. */
2675 tem
= Fsymbol_value (car
);
2677 { elt
= XCONS (elt
)->car
; goto tail_recurse
; }
2679 /* Symbol's value is nil (or symbol is unbound)
2680 Get the cddr of the original list
2681 and if possible find the caddr and use that. */
2682 elt
= XCONS (elt
)->cdr
;
2685 else if (XTYPE (elt
) != Lisp_Cons
)
2687 elt
= XCONS (elt
)->car
;
2690 else if (XTYPE (car
) == Lisp_Int
)
2692 register int lim
= XINT (car
);
2693 elt
= XCONS (elt
)->cdr
;
2695 /* Negative int means reduce maximum width.
2696 DO NOT change MINENDCOL here!
2697 (20 -10 . foo) should truncate foo to 10 col
2698 and then pad to 20. */
2699 maxendcol
= min (maxendcol
, hpos
- lim
);
2702 /* Padding specified. Don't let it be more than
2705 if (lim
> maxendcol
)
2707 /* If that's more padding than already wanted, queue it.
2708 But don't reduce padding already specified even if
2709 that is beyond the current truncation point. */
2710 if (lim
> minendcol
)
2715 else if (XTYPE (car
) == Lisp_String
|| XTYPE (car
) == Lisp_Cons
)
2717 register int limit
= 50;
2718 /* LIMIT is to protect against circular lists. */
2719 while (XTYPE (elt
) == Lisp_Cons
&& --limit
> 0
2720 && hpos
< maxendcol
)
2722 hpos
= display_mode_element (w
, vpos
, hpos
, depth
,
2725 elt
= XCONS (elt
)->cdr
;
2733 return (display_string (w
, vpos
, "*invalid*", -1, hpos
, 0, 1,
2734 minendcol
, maxendcol
));
2738 if (minendcol
> hpos
)
2739 hpos
= display_string (w
, vpos
, "", 0, hpos
, 0, 1, minendcol
, maxendcol
);
2743 /* Return a string for the output of a mode line %-spec for window W,
2744 generated by character C and width MAXWIDTH. */
2746 static char lots_of_dashes
[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
2749 decode_mode_spec (w
, c
, maxwidth
)
2752 register int maxwidth
;
2755 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2756 char *decode_mode_spec_buf
= (char *) FRAME_TEMP_GLYPHS (f
)->total_contents
;
2759 if (maxwidth
> FRAME_WIDTH (f
))
2760 maxwidth
= FRAME_WIDTH (f
);
2765 obj
= current_buffer
->name
;
2767 if (maxwidth
>= 3 && XSTRING (obj
)->size
> maxwidth
)
2769 bcopy (XSTRING (obj
)->data
, decode_mode_spec_buf
, maxwidth
- 1);
2770 decode_mode_spec_buf
[maxwidth
- 1] = '\\';
2771 decode_mode_spec_buf
[maxwidth
] = '\0';
2772 return decode_mode_spec_buf
;
2778 obj
= current_buffer
->filename
;
2782 else if (XTYPE (obj
) == Lisp_String
&& XSTRING (obj
)->size
> maxwidth
)
2784 bcopy ("...", decode_mode_spec_buf
, 3);
2785 bcopy (XSTRING (obj
)->data
+ XSTRING (obj
)->size
- maxwidth
+ 3,
2786 decode_mode_spec_buf
+ 3, maxwidth
- 3);
2787 return decode_mode_spec_buf
;
2794 int startpos
= marker_position (w
->start
);
2795 int line
, linepos
, topline
;
2798 int height
= XFASTINT (w
->height
);
2800 /* If we decided that this buffer isn't suitable for line numbers,
2801 don't forget that too fast. */
2802 if (EQ (w
->base_line_pos
, w
->buffer
))
2805 /* If the buffer is very big, don't waste time. */
2806 if (ZV
- BEGV
> line_number_display_limit
)
2808 w
->base_line_pos
= Qnil
;
2809 w
->base_line_number
= Qnil
;
2813 if (!NILP (w
->base_line_number
)
2814 && !NILP (w
->base_line_pos
)
2815 && XFASTINT (w
->base_line_pos
) <= marker_position (w
->start
))
2817 line
= XFASTINT (w
->base_line_number
);
2818 linepos
= XFASTINT (w
->base_line_pos
);
2826 /* Count lines from base line to window start position. */
2827 nlines
= display_count_lines (linepos
, startpos
, startpos
, &junk
);
2829 topline
= nlines
+ line
;
2831 /* Determine a new base line, if the old one is too close
2832 or too far away, or if we did not have one.
2833 "Too close" means it's plausible a scroll-down would
2835 if (startpos
== BEGV
)
2837 XFASTINT (w
->base_line_number
) = topline
;
2838 XFASTINT (w
->base_line_pos
) = BEGV
;
2840 else if (nlines
< height
+ 25 || nlines
> height
* 3 + 50
2845 int distance
= (height
* 2 + 30) * 200;
2847 if (startpos
- distance
> limit
)
2848 limit
= startpos
- distance
;
2850 nlines
= display_count_lines (startpos
, limit
,
2853 /* If we couldn't find the lines we wanted within
2855 give up on line numbers for this window. */
2856 if (position
== startpos
- distance
)
2858 w
->base_line_pos
= w
->buffer
;
2859 w
->base_line_number
= Qnil
;
2863 XFASTINT (w
->base_line_number
) = topline
- nlines
;
2864 XFASTINT (w
->base_line_pos
) = position
;
2867 /* Now count lines from the start pos to point. */
2868 nlines
= display_count_lines (startpos
, PT
, PT
, &junk
);
2870 /* Record that we did display the line number. */
2871 line_number_displayed
= 1;
2873 /* Make the string to show. */
2874 sprintf (decode_mode_spec_buf
, "%d", topline
+ nlines
);
2875 return decode_mode_spec_buf
;
2880 obj
= current_buffer
->mode_name
;
2884 if (BEGV
> BEG
|| ZV
< Z
)
2889 if (!NILP (current_buffer
->read_only
))
2891 if (MODIFF
> current_buffer
->save_modified
)
2896 if (MODIFF
> current_buffer
->save_modified
)
2901 /* status of process */
2902 obj
= Fget_buffer_process (Fcurrent_buffer ());
2904 return "no process";
2906 obj
= Fsymbol_name (Fprocess_status (obj
));
2910 case 't': /* indicate TEXT or BINARY */
2912 decode_mode_spec_buf
[0]
2913 = NILP (current_buffer
->buffer_file_type
) ? "T" : "B";
2914 decode_mode_spec_buf
[1] = 0;
2915 return decode_mode_spec_buf
;
2916 #else /* not MSDOS */
2918 #endif /* not MSDOS */
2922 int pos
= marker_position (w
->start
);
2923 int total
= ZV
- BEGV
;
2925 if (XFASTINT (w
->window_end_pos
) <= Z
- ZV
)
2932 else if (pos
<= BEGV
)
2936 total
= ((pos
- BEGV
) * 100 + total
- 1) / total
;
2937 /* We can't normally display a 3-digit number,
2938 so get us a 2-digit number that is close. */
2941 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
2942 return decode_mode_spec_buf
;
2946 /* Display percentage of size above the bottom of the screen. */
2949 int toppos
= marker_position (w
->start
);
2950 int botpos
= Z
- XFASTINT (w
->window_end_pos
);
2951 int total
= ZV
- BEGV
;
2962 total
= ((botpos
- BEGV
) * 100 + total
- 1) / total
;
2963 /* We can't normally display a 3-digit number,
2964 so get us a 2-digit number that is close. */
2968 sprintf (decode_mode_spec_buf
, "Top%2d%%", total
);
2970 sprintf (decode_mode_spec_buf
, "%2d%%", total
);
2971 return decode_mode_spec_buf
;
2983 if (command_loop_level
> 5)
2985 p
= decode_mode_spec_buf
;
2986 for (i
= 0; i
< command_loop_level
; i
++)
2989 return decode_mode_spec_buf
;
2997 if (command_loop_level
> 5)
2999 p
= decode_mode_spec_buf
;
3000 for (i
= 0; i
< command_loop_level
; i
++)
3003 return decode_mode_spec_buf
;
3011 if (maxwidth
< sizeof (lots_of_dashes
))
3012 return lots_of_dashes
;
3015 for (p
= decode_mode_spec_buf
, i
= maxwidth
; i
> 0; i
--)
3019 return decode_mode_spec_buf
;
3023 if (XTYPE (obj
) == Lisp_String
)
3024 return (char *) XSTRING (obj
)->data
;
3029 /* Count up to N lines starting from FROM.
3030 But don't go beyond LIMIT.
3031 Return the number of lines thus found (always positive).
3032 Store the position after what was found into *POS_PTR. */
3035 display_count_lines (from
, limit
, n
, pos_ptr
)
3048 *pos_ptr
= scan_buffer ('\n', from
, n
, &shortage
, 0);
3054 /* When scanning backwards, scan_buffer stops *after* the last newline
3055 it finds, but does count it. Compensate for that. */
3056 return - n
- shortage
- (*pos_ptr
!= limit
);
3057 return n
- shortage
;
3060 /* Display STRING on one line of window W, starting at HPOS.
3061 Display at position VPOS. Caller should have done get_display_line.
3062 If VPOS == -1, display it as the current frame's title.
3063 LENGTH is the length of STRING, or -1 meaning STRING is null-terminated.
3065 TRUNCATE is GLYPH to display at end if truncated. Zero for none.
3067 MINCOL is the first column ok to end at. (Pad with spaces to this col.)
3068 MAXCOL is the last column ok to end at. Truncate here.
3069 -1 for MINCOL or MAXCOL means no explicit minimum or maximum.
3070 Both count from the left edge of the frame, as does HPOS.
3071 The right edge of W is an implicit maximum.
3072 If TRUNCATE is nonzero, the implicit maximum is one column before the edge.
3074 OBEY_WINDOW_WIDTH says to put spaces or vertical bars
3075 at the place where the current window ends in this line
3076 and not display anything beyond there. Otherwise, only MAXCOL
3077 controls where to stop output.
3079 Returns ending hpos. */
3082 display_string (w
, vpos
, string
, length
, hpos
, truncate
,
3083 obey_window_width
, mincol
, maxcol
)
3085 unsigned char *string
;
3089 int obey_window_width
;
3094 int hscroll
= XINT (w
->hscroll
);
3095 int tab_width
= XINT (XBUFFER (w
->buffer
)->tab_width
);
3096 register GLYPH
*start
;
3097 register GLYPH
*end
;
3098 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
3099 struct frame_glyphs
*desired_glyphs
= FRAME_DESIRED_GLYPHS (f
);
3100 GLYPH
*p1start
= desired_glyphs
->glyphs
[vpos
] + hpos
;
3101 int window_width
= XFASTINT (w
->width
);
3103 /* Use the standard display table, not the window's display table.
3104 We don't want the mode line in rot13. */
3105 register struct Lisp_Vector
*dp
= 0;
3108 if (XTYPE (Vstandard_display_table
) == Lisp_Vector
3109 && XVECTOR (Vstandard_display_table
)->size
== DISP_TABLE_SIZE
)
3110 dp
= XVECTOR (Vstandard_display_table
);
3112 if (tab_width
<= 0 || tab_width
> 1000) tab_width
= 8;
3115 start
= desired_glyphs
->glyphs
[vpos
] + XFASTINT (w
->left
);
3117 if (obey_window_width
)
3119 end
= start
+ window_width
- (truncate
!= 0);
3121 if ((window_width
+ XFASTINT (w
->left
)) != FRAME_WIDTH (f
))
3123 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3127 for (i
= 0; i
< VERTICAL_SCROLL_BAR_WIDTH
; i
++)
3135 if (! obey_window_width
3136 || (maxcol
>= 0 && end
- desired_glyphs
->glyphs
[vpos
] > maxcol
))
3137 end
= desired_glyphs
->glyphs
[vpos
] + maxcol
;
3139 /* Store 0 in charstart for these columns. */
3140 for (i
= hpos
; i
< end
- p1start
+ hpos
; i
++)
3141 desired_glyphs
->charstarts
[vpos
][i
] = 0;
3143 if (maxcol
>= 0 && mincol
> maxcol
)
3151 /* Specified length. */
3154 /* Unspecified length (null-terminated string). */
3158 if (c
>= 040 && c
< 0177
3159 && (dp
== 0 || XTYPE (DISP_CHAR_VECTOR (dp
, c
)) != Lisp_Vector
))
3169 if (p1
>= start
&& p1
< end
)
3173 while ((p1
- start
+ hscroll
- (hscroll
> 0)) % tab_width
);
3175 else if (dp
!= 0 && XTYPE (DISP_CHAR_VECTOR (dp
, c
)) == Lisp_Vector
)
3177 p1
= copy_part_of_rope (f
, p1
, start
,
3178 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->contents
,
3179 XVECTOR (DISP_CHAR_VECTOR (dp
, c
))->size
,
3182 else if (c
< 0200 && ! NILP (buffer_defaults
.ctl_arrow
))
3185 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_CTRL_GLYPH (dp
)) == Lisp_Int
3186 ? XINT (DISP_CTRL_GLYPH (dp
)) : '^'),
3189 if (p1
>= start
&& p1
< end
)
3196 *p1
= fix_glyph (f
, (dp
&& XTYPE (DISP_ESCAPE_GLYPH (dp
)) == Lisp_Int
3197 ? XINT (DISP_ESCAPE_GLYPH (dp
)) : '\\'),
3200 if (p1
>= start
&& p1
< end
)
3201 *p1
= (c
>> 6) + '0';
3203 if (p1
>= start
&& p1
< end
)
3204 *p1
= (7 & (c
>> 3)) + '0';
3206 if (p1
>= start
&& p1
< end
)
3207 *p1
= (7 & c
) + '0';
3212 if (c
&& length
> 0)
3215 if (truncate
) *p1
++ = fix_glyph (f
, truncate
, 0);
3217 else if (mincol
>= 0)
3219 end
= desired_glyphs
->glyphs
[vpos
] + mincol
;
3225 register int len
= p1
- desired_glyphs
->glyphs
[vpos
];
3227 if (len
> desired_glyphs
->used
[vpos
])
3228 desired_glyphs
->used
[vpos
] = len
;
3229 desired_glyphs
->glyphs
[vpos
][desired_glyphs
->used
[vpos
]] = 0;
3238 staticpro (&last_arrow_position
);
3239 staticpro (&last_arrow_string
);
3240 last_arrow_position
= Qnil
;
3241 last_arrow_string
= Qnil
;
3243 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string
,
3244 "String (or mode line construct) included (normally) in `mode-line-format'.");
3245 Vglobal_mode_string
= Qnil
;
3247 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position
,
3248 "Marker for where to display an arrow on top of the buffer text.\n\
3249 This must be the beginning of a line in order to work.\n\
3250 See also `overlay-arrow-string'.");
3251 Voverlay_arrow_position
= Qnil
;
3253 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string
,
3254 "String to display as an arrow. See also `overlay-arrow-position'.");
3255 Voverlay_arrow_string
= Qnil
;
3257 DEFVAR_INT ("scroll-step", &scroll_step
,
3258 "*The number of lines to try scrolling a window by when point moves out.\n\
3259 If that fails to bring point back on frame, point is centered instead.\n\
3260 If this is zero, point is always centered after it moves off frame.");
3262 DEFVAR_INT ("debug-end-pos", &debug_end_pos
, "Don't ask");
3264 DEFVAR_BOOL ("truncate-partial-width-windows",
3265 &truncate_partial_width_windows
,
3266 "*Non-nil means truncate lines in all windows less than full frame wide.");
3267 truncate_partial_width_windows
= 1;
3269 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video
,
3270 "*Non-nil means use inverse video for the mode line.");
3271 mode_line_inverse_video
= 1;
3273 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit
,
3274 "*Maximum buffer size for which line number should be displayed.");
3275 line_number_display_limit
= 1000000;
3277 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows
,
3278 "*Non-nil means highlight region even in nonselected windows.");
3279 highlight_nonselected_windows
= 1;
3282 /* initialize the window system */
3285 Lisp_Object root_window
;
3286 #ifndef COMPILER_REGISTER_BUG
3288 #endif /* COMPILER_REGISTER_BUG */
3289 struct window
*mini_w
;
3291 this_line_bufpos
= 0;
3293 mini_w
= XWINDOW (minibuf_window
);
3294 root_window
= FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w
)));
3296 echo_area_glyphs
= 0;
3297 previous_echo_glyphs
= 0;
3299 if (!noninteractive
)
3301 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (root_window
)));
3302 XFASTINT (XWINDOW (root_window
)->top
) = 0;
3303 set_window_height (root_window
, FRAME_HEIGHT (f
) - 1, 0);
3304 XFASTINT (mini_w
->top
) = FRAME_HEIGHT (f
) - 1;
3305 set_window_height (minibuf_window
, 1, 0);
3307 XFASTINT (XWINDOW (root_window
)->width
) = FRAME_WIDTH (f
);
3308 XFASTINT (mini_w
->width
) = FRAME_WIDTH (f
);