Mercurial > emacs
annotate src/xdisp.c @ 2797:ae18dabac465
(Fx_selection_exists_p): Handle nil, t as SELECTION arg.
Don't die if SELECTION is not recognized.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 15 May 1993 19:00:34 +0000 |
parents | aa7b6f6aa20a |
children | 3bcbd1795280 |
rev | line source |
---|---|
277 | 1 /* Display generation from window structure and buffer text. |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
2 Copyright (C) 1985, 1986, 1987, 1988, 1993 Free Software Foundation, Inc. |
277 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
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 | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
277 | 9 any later version. |
10 | |
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. | |
15 | |
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. */ | |
19 | |
20 | |
21 #include "config.h" | |
22 #include <stdio.h> | |
23 /*#include <ctype.h>*/ | |
24 #undef NULL | |
25 #include "lisp.h" | |
769 | 26 #include "frame.h" |
277 | 27 #include "window.h" |
28 #include "termchar.h" | |
29 #include "dispextern.h" | |
30 #include "buffer.h" | |
31 #include "indent.h" | |
32 #include "commands.h" | |
33 #include "macros.h" | |
34 #include "disptab.h" | |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
35 #include "termhooks.h" |
277 | 36 |
37 extern int interrupt_input; | |
38 extern int command_loop_level; | |
39 | |
40 /* Nonzero means print newline before next minibuffer message. */ | |
41 | |
42 int noninteractive_need_newline; | |
43 | |
44 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
45 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
46 | |
47 /* The buffer position of the first character appearing | |
769 | 48 entirely or partially on the current frame line. |
49 Or zero, which disables the optimization for the current frame line. */ | |
277 | 50 static int this_line_bufpos; |
51 | |
52 /* Number of characters past the end of this line, | |
53 including the terminating newline */ | |
54 static int this_line_endpos; | |
55 | |
769 | 56 /* The vertical position of this frame line. */ |
277 | 57 static int this_line_vpos; |
58 | |
769 | 59 /* Hpos value for start of display on this frame line. |
277 | 60 Usually zero, but negative if first character really began |
61 on previous line */ | |
62 static int this_line_start_hpos; | |
63 | |
64 /* Buffer that this_line variables are describing. */ | |
65 static struct buffer *this_line_buffer; | |
66 | |
67 /* Set by try_window_id to the vpos of first of any lines | |
769 | 68 scrolled on to the bottom of the frame. These lines should |
277 | 69 not be included in any general scroll computation. */ |
70 static int scroll_bottom_vpos; | |
71 | |
72 /* Value of echo_area_glyphs when it was last acted on. | |
769 | 73 If this is nonzero, there is a message on the frame |
277 | 74 in the minibuffer and it should be erased as soon |
75 as it is no longer requested to appear. */ | |
76 char *previous_echo_glyphs; | |
77 | |
769 | 78 /* Nonzero means truncate lines in all windows less wide than the frame */ |
277 | 79 int truncate_partial_width_windows; |
80 | |
81 Lisp_Object Vglobal_mode_string; | |
82 | |
83 /* Marker for where to display an arrow on top of the buffer text. */ | |
84 Lisp_Object Voverlay_arrow_position; | |
85 | |
86 /* String to display for the arrow. */ | |
87 Lisp_Object Voverlay_arrow_string; | |
88 | |
89 /* Values of those variables at last redisplay. */ | |
1527
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
90 static Lisp_Object last_arrow_position, last_arrow_string; |
277 | 91 |
92 /* Nonzero if overlay arrow has been displayed once in this window. */ | |
93 static int overlay_arrow_seen; | |
94 | |
769 | 95 /* If cursor motion alone moves point off frame, |
277 | 96 Try scrolling this many lines up or down if that will bring it back. */ |
97 int scroll_step; | |
98 | |
99 /* Nonzero if try_window_id has made blank lines at window bottom | |
100 since the last redisplay that paused */ | |
101 static int blank_end_of_window; | |
102 | |
103 /* Number of windows showing the buffer of the selected window. | |
104 keyboard.c refers to this. */ | |
105 int buffer_shared; | |
106 | |
769 | 107 /* display_text_line sets these to the frame position (origin 0) of point, |
277 | 108 whether the window is selected or not. |
109 Set one to -1 first to determine whether point was found afterwards. */ | |
110 | |
111 static int cursor_vpos; | |
112 static int cursor_hpos; | |
113 | |
114 int debug_end_pos; | |
115 | |
116 /* Nonzero means display mode line highlighted */ | |
117 int mode_line_inverse_video; | |
118 | |
119 static void echo_area_display (); | |
120 void mark_window_display_accurate (); | |
121 static void redisplay_windows (); | |
122 static void redisplay_window (); | |
123 static void try_window (); | |
124 static int try_window_id (); | |
125 static struct position *display_text_line (); | |
126 static void display_mode_line (); | |
127 static int display_mode_element (); | |
128 static char *fmodetrunc (); | |
129 static char *decode_mode_spec (); | |
130 static int display_string (); | |
2150
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
131 static void display_menu_bar (); |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
132 static int display_count_lines (); |
277 | 133 |
134 /* Prompt to display in front of the minibuffer contents */ | |
135 char *minibuf_prompt; | |
136 | |
137 /* Width in columns of current minibuffer prompt. */ | |
138 int minibuf_prompt_width; | |
139 | |
140 /* Message to display instead of minibuffer contents | |
141 This is what the functions error and message make, | |
142 and command echoing uses it as well. | |
143 It overrides the minibuf_prompt as well as the buffer. */ | |
144 char *echo_area_glyphs; | |
145 | |
146 /* true iff we should redraw the mode lines on the next redisplay */ | |
147 int update_mode_lines; | |
148 | |
149 /* Smallest number of characters before the gap | |
150 at any time since last redisplay that finished. | |
151 Valid for current buffer when try_window_id can be called. */ | |
152 int beg_unchanged; | |
153 | |
154 /* Smallest number of characters after the gap | |
155 at any time since last redisplay that finished. | |
156 Valid for current buffer when try_window_id can be called. */ | |
157 int end_unchanged; | |
158 | |
159 /* MODIFF as of last redisplay that finished; | |
160 if it matches MODIFF, beg_unchanged and end_unchanged | |
161 contain no useful information */ | |
162 int unchanged_modified; | |
163 | |
164 /* Nonzero if head_clip or tail_clip of current buffer has changed | |
165 since last redisplay that finished */ | |
166 int clip_changed; | |
167 | |
168 /* Nonzero if window sizes or contents have changed | |
169 since last redisplay that finished */ | |
170 int windows_or_buffers_changed; | |
171 | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
172 /* Nonzero after display_mode_line if %l was used |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
173 and it displayed a line number. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
174 int line_number_displayed; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
175 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
176 /* Maximum buffer size for which to display line numbers. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
177 int line_number_display_limit; |
277 | 178 |
1527
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
179 /* Specify m, a string, as a message in the minibuf. If m is 0, clear out |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
180 any existing message, and let the minibuffer text show through. */ |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
181 void |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
182 message1 (m) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
183 char *m; |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
184 { |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
185 if (noninteractive) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
186 { |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
187 if (noninteractive_need_newline) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
188 putc ('\n', stderr); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
189 noninteractive_need_newline = 0; |
2526
bcba821c17bc
(message, message1): If noninteractive and
Richard M. Stallman <rms@gnu.org>
parents:
2324
diff
changeset
|
190 if (cursor_in_echo_area != 0) |
bcba821c17bc
(message, message1): If noninteractive and
Richard M. Stallman <rms@gnu.org>
parents:
2324
diff
changeset
|
191 fprintf (stderr, "%s", m); |
bcba821c17bc
(message, message1): If noninteractive and
Richard M. Stallman <rms@gnu.org>
parents:
2324
diff
changeset
|
192 else |
bcba821c17bc
(message, message1): If noninteractive and
Richard M. Stallman <rms@gnu.org>
parents:
2324
diff
changeset
|
193 fprintf (stderr, "%s\n", m); |
1527
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
194 fflush (stderr); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
195 } |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
196 /* A null message buffer means that the frame hasn't really been |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
197 initialized yet. Error messages get reported properly by |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
198 cmd_error, so this must be just an informative message; toss it. */ |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
199 else if (INTERACTIVE && FRAME_MESSAGE_BUF (selected_frame)) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
200 { |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
201 #ifdef MULTI_FRAME |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
202 Lisp_Object minibuf_frame; |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
203 |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
204 choose_minibuf_frame (); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
205 minibuf_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); |
1656
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
206 FRAME_SAMPLE_VISIBILITY (XFRAME (minibuf_frame)); |
1527
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
207 if (FRAME_VISIBLE_P (selected_frame) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
208 && ! FRAME_VISIBLE_P (XFRAME (minibuf_frame))) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
209 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (minibuf_window))); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
210 #endif |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
211 |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
212 if (m) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
213 echo_area_glyphs = m; |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
214 else |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
215 echo_area_glyphs = previous_echo_glyphs = 0; |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
216 |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
217 do_pending_window_change (); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
218 echo_area_display (); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
219 update_frame (XFRAME (XWINDOW (minibuf_window)->frame), 1, 1); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
220 do_pending_window_change (); |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
221 } |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
222 } |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
223 |
769 | 224 /* Nonzero if FRAME_MESSAGE_BUF (selected_frame) is being used by print; |
331 | 225 zero if being used by message. */ |
226 int message_buf_print; | |
227 | |
1446
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
228 /* Dump an informative message to the minibuf. If m is 0, clear out |
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
229 any existing message, and let the minibuffer text show through. */ |
277 | 230 /* VARARGS 1 */ |
231 void | |
232 message (m, a1, a2, a3) | |
233 char *m; | |
234 { | |
235 if (noninteractive) | |
236 { | |
1446
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
237 if (m) |
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
238 { |
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
239 if (noninteractive_need_newline) |
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
240 putc ('\n', stderr); |
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
241 noninteractive_need_newline = 0; |
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
242 fprintf (stderr, m, a1, a2, a3); |
2526
bcba821c17bc
(message, message1): If noninteractive and
Richard M. Stallman <rms@gnu.org>
parents:
2324
diff
changeset
|
243 if (cursor_in_echo_area == 0) |
bcba821c17bc
(message, message1): If noninteractive and
Richard M. Stallman <rms@gnu.org>
parents:
2324
diff
changeset
|
244 fprintf (stderr, "\n"); |
1446
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
245 fflush (stderr); |
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
246 } |
277 | 247 } |
1873
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
248 else if (INTERACTIVE) |
277 | 249 { |
1873
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
250 /* The frame whose minibuffer we're going to display the message on. |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
251 It may be larger than the selected frame, so we need |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
252 to use its buffer, not the selected frame's buffer. */ |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
253 FRAME_PTR echo_frame; |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
254 #ifdef MULTI_FRAME |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
255 choose_minibuf_frame (); |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
256 echo_frame = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
257 #else |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
258 echo_frame = selected_frame; |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
259 #endif |
277 | 260 |
1873
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
261 /* A null message buffer means that the frame hasn't really been |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
262 initialized yet. Error messages get reported properly by |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
263 cmd_error, so this must be just an informative message; toss it. */ |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
264 if (FRAME_MESSAGE_BUF (echo_frame)) |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
265 { |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
266 if (m) |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
267 { |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
268 { |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
269 #ifdef NO_ARG_ARRAY |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
270 int a[3]; |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
271 a[0] = a1; |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
272 a[1] = a2; |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
273 a[2] = a3; |
277 | 274 |
1873
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
275 doprnt (FRAME_MESSAGE_BUF (echo_frame), |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
276 FRAME_WIDTH (echo_frame), m, 0, 3, a); |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
277 #else |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
278 doprnt (FRAME_MESSAGE_BUF (echo_frame), |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
279 FRAME_WIDTH (echo_frame), m, 0, 3, &a1); |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
280 #endif /* NO_ARG_ARRAY */ |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
281 } |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
282 |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
283 message1 (FRAME_MESSAGE_BUF (echo_frame)); |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
284 } |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
285 else |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
286 message1 (0); |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
287 |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
288 /* Print should start at the beginning of the message |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
289 buffer next time. */ |
c5038f47c602
* xdisp.c (message): Set echo_frame to the frame whose message buf
Jim Blandy <jimb@redhat.com>
parents:
1785
diff
changeset
|
290 message_buf_print = 0; |
1446
37b3c2981b40
* xdisp.c (message): If M is zero, clear echo_area_glyphs and
Jim Blandy <jimb@redhat.com>
parents:
1124
diff
changeset
|
291 } |
277 | 292 } |
293 } | |
294 | |
295 static void | |
296 echo_area_display () | |
297 { | |
298 register int vpos; | |
769 | 299 FRAME_PTR f; |
277 | 300 |
769 | 301 #ifdef MULTI_FRAME |
302 choose_minibuf_frame (); | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
303 #endif |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
304 |
769 | 305 f = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); |
277 | 306 |
769 | 307 if (! FRAME_VISIBLE_P (f)) |
277 | 308 return; |
309 | |
769 | 310 if (frame_garbaged) |
277 | 311 { |
312 Fredraw_display (); | |
769 | 313 frame_garbaged = 0; |
277 | 314 } |
315 | |
316 if (echo_area_glyphs || minibuf_level == 0) | |
317 { | |
318 vpos = XFASTINT (XWINDOW (minibuf_window)->top); | |
769 | 319 get_display_line (f, vpos, 0); |
277 | 320 display_string (XWINDOW (minibuf_window), vpos, |
321 echo_area_glyphs ? echo_area_glyphs : "", | |
769 | 322 0, 0, 0, FRAME_WIDTH (f)); |
277 | 323 |
324 /* If desired cursor location is on this line, put it at end of text */ | |
769 | 325 if (FRAME_CURSOR_Y (f) == vpos) |
326 FRAME_CURSOR_X (f) = FRAME_DESIRED_GLYPHS (f)->used[vpos]; | |
727 | 327 |
328 /* Fill the rest of the minibuffer window with blank lines. */ | |
329 { | |
330 int i; | |
331 | |
332 for (i = vpos + 1; i < vpos + XWINDOW (minibuf_window)->height; i++) | |
333 { | |
769 | 334 get_display_line (f, i, 0); |
727 | 335 display_string (XWINDOW (minibuf_window), vpos, |
769 | 336 "", 0, 0, 0, FRAME_WIDTH (f)); |
727 | 337 } |
338 } | |
277 | 339 } |
340 else if (!EQ (minibuf_window, selected_window)) | |
341 windows_or_buffers_changed++; | |
342 | |
343 if (EQ (minibuf_window, selected_window)) | |
344 this_line_bufpos = 0; | |
345 | |
346 previous_echo_glyphs = echo_area_glyphs; | |
347 } | |
348 | |
769 | 349 /* Do a frame update, taking possible shortcuts into account. |
277 | 350 This is the main external entry point for redisplay. |
351 | |
352 If the last redisplay displayed an echo area message and that | |
353 message is no longer requested, we clear the echo area | |
354 or bring back the minibuffer if that is in use. | |
355 | |
356 Everyone would like to have a hook here to call eval, | |
357 but that cannot be done safely without a lot of changes elsewhere. | |
358 This can be called from signal handlers; with alarms set up; | |
359 or with synchronous processes running. | |
360 See the function `echo' in keyboard.c. | |
361 See Fcall_process; if you called it from here, it could be | |
362 entered recursively. */ | |
363 | |
364 void | |
365 redisplay () | |
366 { | |
367 register struct window *w = XWINDOW (selected_window); | |
368 register int pause; | |
369 int must_finish = 0; | |
370 int all_windows; | |
371 register int tlbufpos, tlendpos; | |
372 struct position pos; | |
373 extern int input_pending; | |
374 | |
375 if (noninteractive) | |
376 return; | |
377 | |
1656
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
378 /* Set the visible flags for all frames. |
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
379 Do this before checking for resized or garbaged frames; they want |
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
380 to know if their frames are visible. |
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
381 See the comment in frame.h for FRAME_SAMPLE_VISIBILITY. */ |
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
382 { |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2189
diff
changeset
|
383 Lisp_Object tail, frame; |
1656
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
384 |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2189
diff
changeset
|
385 FOR_EACH_FRAME (tail, frame) |
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2189
diff
changeset
|
386 FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); |
1656
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
387 } |
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
388 |
769 | 389 /* Notice any pending interrupt request to change frame size. */ |
277 | 390 do_pending_window_change (); |
391 | |
769 | 392 if (frame_garbaged) |
277 | 393 { |
394 Fredraw_display (); | |
769 | 395 frame_garbaged = 0; |
277 | 396 } |
397 | |
368 | 398 /* Normally the message* functions will have already displayed and |
769 | 399 updated the echo area, but the frame may have been trashed, or |
368 | 400 the update may have been preempted, so display the echo area |
401 again here. */ | |
277 | 402 if (echo_area_glyphs || previous_echo_glyphs) |
403 { | |
404 echo_area_display (); | |
405 must_finish = 1; | |
406 } | |
407 | |
408 if (clip_changed || windows_or_buffers_changed) | |
409 update_mode_lines++; | |
410 | |
411 /* Detect case that we need to write a star in the mode line. */ | |
412 if (XFASTINT (w->last_modified) < MODIFF | |
413 && XFASTINT (w->last_modified) <= current_buffer->save_modified) | |
414 { | |
415 w->update_mode_line = Qt; | |
416 if (buffer_shared > 1) | |
417 update_mode_lines++; | |
418 } | |
419 | |
769 | 420 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1; |
277 | 421 |
422 all_windows = update_mode_lines || buffer_shared > 1; | |
423 | |
424 /* If specs for an arrow have changed, do thorough redisplay | |
425 to ensure we remove any arrow that should no longer exist. */ | |
1527
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
426 if (! EQ (Voverlay_arrow_position, last_arrow_position) |
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
427 || ! EQ (Voverlay_arrow_string, last_arrow_string)) |
277 | 428 all_windows = 1, clip_changed = 1; |
429 | |
430 tlbufpos = this_line_bufpos; | |
431 tlendpos = this_line_endpos; | |
485 | 432 if (!all_windows && tlbufpos > 0 && NILP (w->update_mode_line) |
769 | 433 && FRAME_VISIBLE_P (XFRAME (w->frame)) |
277 | 434 /* Make sure recorded data applies to current buffer, etc */ |
435 && this_line_buffer == current_buffer | |
436 && current_buffer == XBUFFER (w->buffer) | |
485 | 437 && NILP (w->force_start) |
277 | 438 /* Point must be on the line that we have info recorded about */ |
439 && point >= tlbufpos | |
440 && point <= Z - tlendpos | |
441 /* All text outside that line, including its final newline, | |
442 must be unchanged */ | |
443 && (XFASTINT (w->last_modified) >= MODIFF | |
444 || (beg_unchanged >= tlbufpos - 1 | |
445 && GPT >= tlbufpos | |
528 | 446 /* If selective display, can't optimize |
447 if the changes start at the beginning of the line. */ | |
448 && ((XTYPE (current_buffer->selective_display) == Lisp_Int | |
449 && XINT (current_buffer->selective_display) > 0 | |
450 ? (beg_unchanged >= tlbufpos | |
451 && GPT > tlbufpos) | |
452 : 1)) | |
277 | 453 && end_unchanged >= tlendpos |
454 && Z - GPT >= tlendpos))) | |
455 { | |
456 if (tlbufpos > BEGV && FETCH_CHAR (tlbufpos - 1) != '\n' | |
457 && (tlbufpos == ZV | |
458 || FETCH_CHAR (tlbufpos) == '\n')) | |
459 /* Former continuation line has disappeared by becoming empty */ | |
460 goto cancel; | |
461 else if (XFASTINT (w->last_modified) < MODIFF | |
462 || MINI_WINDOW_P (w)) | |
463 { | |
464 cursor_vpos = -1; | |
465 overlay_arrow_seen = 0; | |
466 display_text_line (w, tlbufpos, this_line_vpos, this_line_start_hpos, | |
467 pos_tab_offset (w, tlbufpos)); | |
468 /* If line contains point, is not continued, | |
469 and ends at same distance from eob as before, we win */ | |
470 if (cursor_vpos >= 0 && this_line_bufpos | |
471 && this_line_endpos == tlendpos) | |
472 { | |
769 | 473 if (XFASTINT (w->width) != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) |
277 | 474 preserve_other_columns (w); |
475 goto update; | |
476 } | |
477 else | |
478 goto cancel; | |
479 } | |
480 else if (point == XFASTINT (w->last_point)) | |
481 { | |
482 if (!must_finish) | |
483 { | |
484 do_pending_window_change (); | |
485 return; | |
486 } | |
487 goto update; | |
488 } | |
489 else | |
490 { | |
491 pos = *compute_motion (tlbufpos, 0, | |
492 XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0, | |
493 point, 2, - (1 << (SHORTBITS - 1)), | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
494 window_internal_width (w) - 1, |
574 | 495 XINT (w->hscroll), |
496 pos_tab_offset (w, tlbufpos)); | |
277 | 497 if (pos.vpos < 1) |
498 { | |
769 | 499 FRAME_CURSOR_X (selected_frame) |
277 | 500 = XFASTINT (w->left) + max (pos.hpos, 0); |
769 | 501 FRAME_CURSOR_Y (selected_frame) = this_line_vpos; |
277 | 502 goto update; |
503 } | |
504 else | |
505 goto cancel; | |
506 } | |
507 cancel: | |
508 /* Text changed drastically or point moved off of line */ | |
769 | 509 cancel_line (this_line_vpos, selected_frame); |
277 | 510 } |
511 | |
512 this_line_bufpos = 0; | |
513 all_windows |= buffer_shared > 1; | |
514 | |
515 if (all_windows) | |
516 { | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2189
diff
changeset
|
517 Lisp_Object tail, frame; |
277 | 518 |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
519 #ifdef HAVE_X_WINDOWS |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
520 /* Since we're doing a thorough redisplay, we might as well |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
521 recompute all our display faces. */ |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
522 clear_face_vector (); |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
523 #endif |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
524 |
277 | 525 /* Recompute # windows showing selected buffer. |
433 | 526 This will be incremented each time such a window is displayed. */ |
277 | 527 buffer_shared = 0; |
528 | |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2189
diff
changeset
|
529 FOR_EACH_FRAME (tail, frame) |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
530 { |
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2189
diff
changeset
|
531 FRAME_PTR f = XFRAME (frame); |
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2189
diff
changeset
|
532 |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
533 /* Mark all the scroll bars to be removed; we'll redeem the ones |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
534 we want when we redisplay their windows. */ |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
535 if (condemn_scroll_bars_hook) |
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
536 (*condemn_scroll_bars_hook) (f); |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
537 |
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
538 if (FRAME_VISIBLE_P (f)) |
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
539 redisplay_windows (FRAME_ROOT_WINDOW (f)); |
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
540 |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
541 /* Any scroll bars which redisplay_windows should have nuked |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
542 should now go away. */ |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
543 if (judge_scroll_bars_hook) |
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
544 (*judge_scroll_bars_hook) (f); |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
545 } |
277 | 546 } |
769 | 547 else if (FRAME_VISIBLE_P (selected_frame)) |
277 | 548 { |
549 redisplay_window (selected_window, 1); | |
769 | 550 if (XFASTINT (w->width) != FRAME_WIDTH (selected_frame)) |
277 | 551 preserve_other_columns (w); |
552 } | |
553 | |
554 update: | |
555 /* Prevent various kinds of signals during display update. | |
556 stdio is not robust about handling signals, | |
557 which can cause an apparent I/O error. */ | |
558 if (interrupt_input) | |
559 unrequest_sigio (); | |
560 stop_polling (); | |
561 | |
769 | 562 #ifdef MULTI_FRAME |
277 | 563 if (all_windows) |
564 { | |
565 Lisp_Object tail; | |
566 | |
567 pause = 0; | |
568 | |
769 | 569 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
277 | 570 { |
769 | 571 FRAME_PTR f; |
277 | 572 |
769 | 573 if (XTYPE (XCONS (tail)->car) != Lisp_Frame) |
277 | 574 continue; |
575 | |
769 | 576 f = XFRAME (XCONS (tail)->car); |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
577 if (FRAME_VISIBLE_P (f)) |
277 | 578 { |
769 | 579 pause |= update_frame (f, 0, 0); |
277 | 580 if (!pause) |
769 | 581 mark_window_display_accurate (f->root_window, 1); |
277 | 582 } |
583 } | |
584 } | |
585 else | |
769 | 586 #endif /* MULTI_FRAME */ |
368 | 587 { |
769 | 588 if (FRAME_VISIBLE_P (selected_frame)) |
589 pause = update_frame (selected_frame, 0, 0); | |
1656
a532c5a23984
* xdisp.c (redisplay): Call FRAME_SAMPLE_VISIBILITY to set the
Jim Blandy <jimb@redhat.com>
parents:
1600
diff
changeset
|
590 |
433 | 591 /* We may have called echo_area_display at the top of this |
769 | 592 function. If the echo area is on another frame, that may |
593 have put text on a frame other than the selected one, so the | |
594 above call to update_frame would not have caught it. Catch | |
433 | 595 it here. */ |
596 { | |
769 | 597 FRAME_PTR mini_frame = |
598 XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); | |
433 | 599 |
769 | 600 if (mini_frame != selected_frame) |
601 pause |= update_frame (mini_frame, 0, 0); | |
433 | 602 } |
368 | 603 } |
277 | 604 |
769 | 605 /* If frame does not match, prevent doing single-line-update next time. |
277 | 606 Also, don't forget to check every line to update the arrow. */ |
607 if (pause) | |
608 { | |
609 this_line_bufpos = 0; | |
485 | 610 if (!NILP (last_arrow_position)) |
277 | 611 { |
612 last_arrow_position = Qt; | |
613 last_arrow_string = Qt; | |
614 } | |
769 | 615 /* If we pause after scrolling, some lines in current_frame |
277 | 616 may be null, so preserve_other_columns won't be able to |
617 preserve all the vertical-bar separators. So, avoid using it | |
618 in that case. */ | |
769 | 619 if (XFASTINT (w->width) != FRAME_WIDTH (selected_frame)) |
277 | 620 update_mode_lines = 1; |
621 } | |
622 | |
769 | 623 /* Now text on frame agrees with windows, so |
277 | 624 put info into the windows for partial redisplay to follow */ |
625 | |
626 if (!pause) | |
627 { | |
628 register struct buffer *b = XBUFFER (w->buffer); | |
629 | |
630 blank_end_of_window = 0; | |
631 clip_changed = 0; | |
632 unchanged_modified = BUF_MODIFF (b); | |
633 beg_unchanged = BUF_GPT (b) - BUF_BEG (b); | |
634 end_unchanged = BUF_Z (b) - BUF_GPT (b); | |
635 | |
636 XFASTINT (w->last_point) = BUF_PT (b); | |
769 | 637 XFASTINT (w->last_point_x) = FRAME_CURSOR_X (selected_frame); |
638 XFASTINT (w->last_point_y) = FRAME_CURSOR_Y (selected_frame); | |
277 | 639 |
640 if (all_windows) | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
641 mark_window_display_accurate (FRAME_ROOT_WINDOW (selected_frame), 1); |
277 | 642 else |
643 { | |
644 w->update_mode_line = Qnil; | |
645 XFASTINT (w->last_modified) = BUF_MODIFF (b); | |
646 w->window_end_valid = Qt; | |
647 last_arrow_position = Voverlay_arrow_position; | |
648 last_arrow_string = Voverlay_arrow_string; | |
649 } | |
650 update_mode_lines = 0; | |
651 windows_or_buffers_changed = 0; | |
652 } | |
653 | |
654 /* Start SIGIO interrupts coming again. | |
655 Having them off during the code above | |
656 makes it less likely one will discard output, | |
657 but not impossible, since there might be stuff | |
658 in the system buffer here. | |
659 But it is much hairier to try to do anything about that. */ | |
660 | |
661 if (interrupt_input) | |
662 request_sigio (); | |
663 start_polling (); | |
664 | |
769 | 665 /* Change frame size now if a change is pending. */ |
277 | 666 do_pending_window_change (); |
667 } | |
668 | |
669 /* Redisplay, but leave alone any recent echo area message | |
670 unless another message has been requested in its place. | |
671 | |
672 This is useful in situations where you need to redisplay but no | |
673 user action has occurred, making it inappropriate for the message | |
674 area to be cleared. See tracking_off and | |
675 wait_reading_process_input for examples of these situations. */ | |
676 | |
677 redisplay_preserve_echo_area () | |
678 { | |
679 if (echo_area_glyphs == 0 && previous_echo_glyphs != 0) | |
680 { | |
681 echo_area_glyphs = previous_echo_glyphs; | |
682 redisplay (); | |
683 echo_area_glyphs = 0; | |
684 } | |
685 else | |
686 redisplay (); | |
687 } | |
688 | |
689 void | |
690 mark_window_display_accurate (window, flag) | |
691 Lisp_Object window; | |
692 int flag; | |
693 { | |
694 register struct window *w; | |
695 | |
485 | 696 for (;!NILP (window); window = w->next) |
277 | 697 { |
1527
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
698 if (XTYPE (window) != Lisp_Window) abort (); |
277 | 699 w = XWINDOW (window); |
700 | |
485 | 701 if (!NILP (w->buffer)) |
277 | 702 XFASTINT (w->last_modified) |
703 = !flag ? 0 | |
704 : XBUFFER (w->buffer) == current_buffer | |
705 ? MODIFF : BUF_MODIFF (XBUFFER (w->buffer)); | |
706 w->window_end_valid = Qt; | |
707 w->update_mode_line = Qnil; | |
708 | |
485 | 709 if (!NILP (w->vchild)) |
277 | 710 mark_window_display_accurate (w->vchild, flag); |
485 | 711 if (!NILP (w->hchild)) |
277 | 712 mark_window_display_accurate (w->hchild, flag); |
713 } | |
714 | |
715 if (flag) | |
716 { | |
717 last_arrow_position = Voverlay_arrow_position; | |
718 last_arrow_string = Voverlay_arrow_string; | |
719 } | |
720 else | |
721 { | |
722 /* t is unequal to any useful value of Voverlay_arrow_... */ | |
723 last_arrow_position = Qt; | |
724 last_arrow_string = Qt; | |
725 } | |
726 } | |
727 | |
728 int do_id = 1; | |
729 | |
730 static void | |
731 redisplay_windows (window) | |
732 Lisp_Object window; | |
733 { | |
485 | 734 for (; !NILP (window); window = XWINDOW (window)->next) |
277 | 735 redisplay_window (window, 0); |
736 } | |
737 | |
738 static void | |
739 redisplay_window (window, just_this_one) | |
740 Lisp_Object window; | |
741 int just_this_one; | |
742 { | |
743 register struct window *w = XWINDOW (window); | |
1718
f80c1f73f5b9
* xdisp.c: #include "termhooks.h".
Jim Blandy <jimb@redhat.com>
parents:
1656
diff
changeset
|
744 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
277 | 745 int height; |
746 register int lpoint = point; | |
747 struct buffer *old = current_buffer; | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
748 register int width = window_internal_width (w) - 1; |
277 | 749 register int startp; |
750 register int hscroll = XINT (w->hscroll); | |
751 struct position pos; | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
752 int opoint = point; |
277 | 753 int tem; |
754 int window_needs_modeline; | |
755 | |
769 | 756 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
277 | 757 |
758 /* If this is a combination window, do its children; that's all. */ | |
759 | |
485 | 760 if (!NILP (w->vchild)) |
277 | 761 { |
762 redisplay_windows (w->vchild); | |
763 return; | |
764 } | |
485 | 765 if (!NILP (w->hchild)) |
277 | 766 { |
767 redisplay_windows (w->hchild); | |
768 return; | |
769 } | |
485 | 770 if (NILP (w->buffer)) |
277 | 771 abort (); |
433 | 772 |
773 height = window_internal_height (w); | |
774 | |
775 if (MINI_WINDOW_P (w)) | |
776 { | |
777 if (w == XWINDOW (minibuf_window)) | |
778 { | |
779 if (echo_area_glyphs) | |
780 /* We've already displayed the echo area glyphs, if any. */ | |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
781 goto finish_scroll_bars; |
433 | 782 } |
783 else | |
784 { | |
785 /* This is a minibuffer, but it's not the currently active one, so | |
786 clear it. */ | |
769 | 787 int vpos = XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top); |
433 | 788 int i; |
789 | |
790 for (i = 0; i < height; i++) | |
791 { | |
769 | 792 get_display_line (f, vpos + i, 0); |
433 | 793 display_string (w, vpos + i, "", 0, 0, 0, width); |
794 } | |
795 | |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
796 goto finish_scroll_bars; |
433 | 797 } |
798 } | |
277 | 799 |
800 if (update_mode_lines) | |
801 w->update_mode_line = Qt; | |
802 | |
803 /* Otherwise set up data on this window; select its buffer and point value */ | |
804 | |
805 current_buffer = XBUFFER (w->buffer); | |
806 opoint = point; | |
807 | |
808 /* Count number of windows showing the selected buffer. */ | |
809 | |
810 if (!just_this_one | |
811 && current_buffer == XBUFFER (XWINDOW (selected_window)->buffer)) | |
812 buffer_shared++; | |
813 | |
814 /* POINT refers normally to the selected window. | |
815 For any other window, set up appropriate value. */ | |
816 | |
817 if (!EQ (window, selected_window)) | |
818 { | |
819 SET_PT (marker_position (w->pointm)); | |
820 if (point < BEGV) | |
821 { | |
485 | 822 SET_PT (BEGV); |
277 | 823 Fset_marker (w->pointm, make_number (point), Qnil); |
824 } | |
825 else if (point > (ZV - 1)) | |
826 { | |
485 | 827 SET_PT (ZV); |
277 | 828 Fset_marker (w->pointm, make_number (point), Qnil); |
829 } | |
830 } | |
831 | |
832 /* If window-start is screwed up, choose a new one. */ | |
833 if (XMARKER (w->start)->buffer != current_buffer) | |
834 goto recenter; | |
835 | |
836 startp = marker_position (w->start); | |
837 | |
433 | 838 /* Handle case where place to start displaying has been specified, |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
839 unless the specified location is outside the accessible range. */ |
485 | 840 if (!NILP (w->force_start)) |
277 | 841 { |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
842 /* Forget any recorded base line for line number display. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
843 w->base_line_number = Qnil; |
277 | 844 w->update_mode_line = Qt; |
845 w->force_start = Qnil; | |
846 XFASTINT (w->last_modified) = 0; | |
433 | 847 if (startp < BEGV) startp = BEGV; |
848 if (startp > ZV) startp = ZV; | |
277 | 849 try_window (window, startp); |
850 if (cursor_vpos < 0) | |
851 { | |
852 /* If point does not appear, move point so it does appear */ | |
853 pos = *compute_motion (startp, 0, | |
854 ((EQ (window, minibuf_window) && startp == 1) | |
855 ? minibuf_prompt_width : 0) | |
856 + | |
857 (hscroll ? 1 - hscroll : 0), | |
858 ZV, height / 2, | |
859 - (1 << (SHORTBITS - 1)), | |
860 width, hscroll, pos_tab_offset (w, startp)); | |
861 SET_PT (pos.bufpos); | |
769 | 862 if (w != XWINDOW (FRAME_SELECTED_WINDOW (f))) |
277 | 863 Fset_marker (w->pointm, make_number (point), Qnil); |
864 else | |
865 { | |
866 lpoint = point; | |
769 | 867 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left); |
868 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top); | |
277 | 869 } |
870 } | |
871 goto done; | |
872 } | |
873 | |
874 /* Handle case where text has not changed, only point, | |
769 | 875 and it has not moved off the frame */ |
277 | 876 |
877 /* This code is not used for minibuffer for the sake of | |
878 the case of redisplaying to replace an echo area message; | |
879 since in that case the minibuffer contents per se are usually unchanged. | |
880 This code is of no real use in the minibuffer since | |
881 the handling of this_line_bufpos, etc., | |
882 in redisplay handles the same cases. */ | |
883 | |
884 if (XFASTINT (w->last_modified) >= MODIFF | |
885 && point >= startp && !clip_changed | |
769 | 886 && (just_this_one || XFASTINT (w->width) == FRAME_WIDTH (f)) |
277 | 887 && !EQ (window, minibuf_window)) |
888 { | |
889 pos = *compute_motion (startp, 0, (hscroll ? 1 - hscroll : 0), | |
890 point, height + 1, 10000, width, hscroll, | |
891 pos_tab_offset (w, startp)); | |
892 | |
893 if (pos.vpos < height) | |
894 { | |
769 | 895 /* Ok, point is still on frame */ |
896 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f))) | |
277 | 897 { |
898 /* These variables are supposed to be origin 1 */ | |
769 | 899 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left); |
900 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top); | |
277 | 901 } |
902 /* This doesn't do the trick, because if a window to the right of | |
903 this one must be redisplayed, this does nothing because there | |
769 | 904 is nothing in DesiredFrame yet, and then the other window is |
277 | 905 redisplayed, making likes that are empty in this window's columns. |
769 | 906 if (XFASTINT (w->width) != FRAME_WIDTH (f)) |
277 | 907 preserve_my_columns (w); |
908 */ | |
909 goto done; | |
910 } | |
911 /* Don't bother trying redisplay with same start; | |
912 we already know it will lose */ | |
913 } | |
914 /* If current starting point was originally the beginning of a line | |
915 but no longer is, find a new starting point. */ | |
485 | 916 else if (!NILP (w->start_at_line_beg) |
277 | 917 && !(startp == BEGV |
918 || FETCH_CHAR (startp - 1) == '\n')) | |
919 { | |
920 goto recenter; | |
921 } | |
922 else if (just_this_one && !MINI_WINDOW_P (w) | |
923 && point >= startp | |
924 && XFASTINT (w->last_modified) | |
925 && ! EQ (w->window_end_valid, Qnil) | |
926 && do_id && !clip_changed | |
927 && !blank_end_of_window | |
769 | 928 && XFASTINT (w->width) == FRAME_WIDTH (f) |
277 | 929 && EQ (last_arrow_position, Voverlay_arrow_position) |
930 && EQ (last_arrow_string, Voverlay_arrow_string) | |
769 | 931 && (tem = try_window_id (FRAME_SELECTED_WINDOW (f))) |
277 | 932 && tem != -2) |
933 { | |
934 /* tem > 0 means success. tem == -1 means choose new start. | |
935 tem == -2 means try again with same start, | |
936 and nothing but whitespace follows the changed stuff. | |
937 tem == 0 means try again with same start. */ | |
938 if (tem > 0) | |
939 goto done; | |
940 } | |
941 else if (startp >= BEGV && startp <= ZV | |
942 /* Avoid starting display at end of buffer! */ | |
433 | 943 && (startp < ZV || startp == BEGV |
277 | 944 || (XFASTINT (w->last_modified) >= MODIFF))) |
945 { | |
946 /* Try to redisplay starting at same place as before */ | |
769 | 947 /* If point has not moved off frame, accept the results */ |
277 | 948 try_window (window, startp); |
949 if (cursor_vpos >= 0) | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
950 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
951 if (!just_this_one || clip_changed || beg_unchanged < startp) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
952 /* Forget any recorded base line for line number display. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
953 w->base_line_number = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
954 goto done; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
955 } |
277 | 956 else |
957 cancel_my_columns (w); | |
958 } | |
959 | |
960 XFASTINT (w->last_modified) = 0; | |
961 w->update_mode_line = Qt; | |
962 | |
963 /* Try to scroll by specified few lines */ | |
964 | |
965 if (scroll_step && !clip_changed) | |
966 { | |
967 if (point > startp) | |
968 { | |
969 pos = *vmotion (Z - XFASTINT (w->window_end_pos), | |
970 scroll_step, width, hscroll, window); | |
971 if (pos.vpos >= height) | |
972 goto scroll_fail; | |
973 } | |
974 | |
975 pos = *vmotion (startp, point < startp ? - scroll_step : scroll_step, | |
976 width, hscroll, window); | |
977 | |
978 if (point >= pos.bufpos) | |
979 { | |
980 try_window (window, pos.bufpos); | |
981 if (cursor_vpos >= 0) | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
982 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
983 if (!just_this_one || clip_changed || beg_unchanged < startp) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
984 /* Forget any recorded base line for line number display. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
985 w->base_line_number = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
986 goto done; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
987 } |
277 | 988 else |
989 cancel_my_columns (w); | |
990 } | |
991 scroll_fail: ; | |
992 } | |
993 | |
994 /* Finally, just choose place to start which centers point */ | |
995 | |
996 recenter: | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
997 /* Forget any previously recorded base line for line number display. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
998 w->base_line_number = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
999 |
277 | 1000 pos = *vmotion (point, - height / 2, width, hscroll, window); |
1001 try_window (window, pos.bufpos); | |
1002 | |
1003 startp = marker_position (w->start); | |
1004 w->start_at_line_beg = | |
1005 (startp == BEGV || FETCH_CHAR (startp - 1) == '\n') ? Qt : Qnil; | |
1006 | |
1007 done: | |
485 | 1008 if ((!NILP (w->update_mode_line) |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1009 /* If window not full width, must redo its mode line |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1010 if the window to its side is being redone */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1011 || (!just_this_one && width < FRAME_WIDTH (f) - 1) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1012 || INTEGERP (w->base_line_pos)) |
277 | 1013 && height != XFASTINT (w->height)) |
1014 display_mode_line (w); | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1015 if (! line_number_displayed |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1016 && ! BUFFERP (w->base_line_pos)) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1017 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1018 w->base_line_pos = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1019 w->base_line_number = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
1020 } |
277 | 1021 |
2150
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1022 /* When we reach a frame's selected window, redo the frame's menu bar. */ |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1023 if (!NILP (w->update_mode_line) |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1024 && FRAME_MENU_BAR_LINES (f) > 0 |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1025 && EQ (FRAME_SELECTED_WINDOW (f), window)) |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1026 display_menu_bar (w); |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1027 |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1028 finish_scroll_bars: |
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1029 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1030 { |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1031 int start, end, whole; |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1032 |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1033 /* Calculate the start and end positions for the current window. |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1034 Note that minibuffers sometimes aren't displaying any text. */ |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1035 if (! MINI_WINDOW_P (w) |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1036 || (w == XWINDOW (minibuf_window) && ! echo_area_glyphs)) |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1037 { |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1038 start = startp; |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1039 /* I don't think this is guaranteed to be right. For the |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1040 moment, we'll pretend it is. */ |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1041 end = Z - XINT (w->window_end_pos); |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1042 whole = Z - BEG; |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1043 } |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1044 else |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1045 start = end = whole = 0; |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1046 |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1047 /* Indicate what this scroll bar ought to be displaying now. */ |
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1048 (*set_vertical_scroll_bar_hook) (w, end - start, whole, start - 1); |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1049 |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1050 /* Note that we actually used the scroll bar attached to this window, |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1051 so it shouldn't be deleted at the end of redisplay. */ |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1052 (*redeem_scroll_bar_hook) (w); |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1053 } |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1054 |
277 | 1055 SET_PT (opoint); |
1056 current_buffer = old; | |
1057 SET_PT (lpoint); | |
1058 } | |
1059 | |
1060 /* Do full redisplay on one window, starting at position `pos'. */ | |
1061 | |
1062 static void | |
1063 try_window (window, pos) | |
1064 Lisp_Object window; | |
1065 register int pos; | |
1066 { | |
1067 register struct window *w = XWINDOW (window); | |
1068 register int height = window_internal_height (w); | |
1069 register int vpos = XFASTINT (w->top); | |
1070 register int last_text_vpos = vpos; | |
1071 int tab_offset = pos_tab_offset (w, pos); | |
769 | 1072 FRAME_PTR f = XFRAME (w->frame); |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1073 int width = window_internal_width (w) - 1; |
277 | 1074 struct position val; |
1075 | |
1076 Fset_marker (w->start, make_number (pos), Qnil); | |
1077 cursor_vpos = -1; | |
1078 overlay_arrow_seen = 0; | |
1079 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0; | |
1080 | |
1081 while (--height >= 0) | |
1082 { | |
1083 val = *display_text_line (w, pos, vpos, val.hpos, tab_offset); | |
1084 tab_offset += width; | |
1085 if (val.vpos) tab_offset = 0; | |
1086 vpos++; | |
1087 if (pos != val.bufpos) | |
1088 last_text_vpos | |
1089 /* Next line, unless prev line ended in end of buffer with no cr */ | |
1090 = vpos - (val.vpos && FETCH_CHAR (val.bufpos - 1) != '\n'); | |
1091 pos = val.bufpos; | |
1092 } | |
1093 | |
1094 /* If last line is continued in middle of character, | |
769 | 1095 include the split character in the text considered on the frame */ |
277 | 1096 if (val.hpos < (XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0)) |
1097 pos++; | |
1098 | |
769 | 1099 /* If bottom just moved off end of frame, change mode line percentage. */ |
277 | 1100 if (XFASTINT (w->window_end_pos) == 0 |
1101 && Z != pos) | |
1102 w->update_mode_line = Qt; | |
1103 | |
769 | 1104 /* Say where last char on frame will be, once redisplay is finished. */ |
277 | 1105 XFASTINT (w->window_end_pos) = Z - pos; |
1106 XFASTINT (w->window_end_vpos) = last_text_vpos - XFASTINT (w->top); | |
1107 /* But that is not valid info until redisplay finishes. */ | |
1108 w->window_end_valid = Qnil; | |
1109 } | |
1110 | |
1111 /* Try to redisplay when buffer is modified locally, | |
1112 computing insert/delete line to preserve text outside | |
1113 the bounds of the changes. | |
1114 Return 1 if successful, 0 if if cannot tell what to do, | |
1115 or -1 to tell caller to find a new window start, | |
1116 or -2 to tell caller to do normal redisplay with same window start. */ | |
1117 | |
1118 static int | |
1119 try_window_id (window) | |
1120 Lisp_Object window; | |
1121 { | |
1122 int pos; | |
1123 register struct window *w = XWINDOW (window); | |
1124 register int height = window_internal_height (w); | |
769 | 1125 FRAME_PTR f = XFRAME (w->frame); |
277 | 1126 int top = XFASTINT (w->top); |
1127 int start = marker_position (w->start); | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1128 int width = window_internal_width (w) - 1; |
277 | 1129 int hscroll = XINT (w->hscroll); |
1130 int lmargin = hscroll > 0 ? 1 - hscroll : 0; | |
1131 register int vpos; | |
1132 register int i, tem; | |
1133 int last_text_vpos = 0; | |
1134 int stop_vpos; | |
1135 | |
1136 struct position val, bp, ep, xp, pp; | |
1137 int scroll_amount = 0; | |
1138 int delta; | |
1139 int tab_offset, epto; | |
1140 | |
1141 if (GPT - BEG < beg_unchanged) | |
1142 beg_unchanged = GPT - BEG; | |
1143 if (Z - GPT < end_unchanged) | |
1144 end_unchanged = Z - GPT; | |
1145 | |
1146 if (beg_unchanged + 1 < start) | |
1147 return 0; /* Give up if changes go above top of window */ | |
1148 | |
1149 /* Find position before which nothing is changed. */ | |
1150 bp = *compute_motion (start, 0, lmargin, | |
371 | 1151 beg_unchanged + 1, height + 1, 0, width, hscroll, |
277 | 1152 pos_tab_offset (w, start)); |
1153 if (bp.vpos >= height) | |
368 | 1154 { |
1155 if (point < bp.bufpos && !bp.contin) | |
1156 { | |
769 | 1157 /* All changes are below the frame, and point is on the frame. |
1158 We don't need to change the frame at all. | |
368 | 1159 But we need to update window_end_pos to account for |
1160 any change in buffer size. */ | |
371 | 1161 bp = *compute_motion (start, 0, lmargin, |
1162 Z, height, 0, | |
1163 width, hscroll, pos_tab_offset (w, start)); | |
368 | 1164 XFASTINT (w->window_end_vpos) = height; |
1165 XFASTINT (w->window_end_pos) = Z - bp.bufpos; | |
1166 return 1; | |
1167 } | |
1168 return 0; | |
1169 } | |
277 | 1170 |
1171 vpos = bp.vpos; | |
1172 | |
769 | 1173 /* Find beginning of that frame line. Must display from there. */ |
277 | 1174 bp = *vmotion (bp.bufpos, 0, width, hscroll, window); |
1175 | |
1176 pos = bp.bufpos; | |
1177 val.hpos = lmargin; | |
1178 if (pos < start) | |
1179 return -1; | |
1180 | |
1181 /* If about to start displaying at the beginning of a continuation line, | |
769 | 1182 really start with previous frame line, in case it was not |
277 | 1183 continued when last redisplayed */ |
528 | 1184 if ((bp.contin && bp.bufpos - 1 == beg_unchanged && vpos > 0) |
1185 || | |
1186 /* Likewise if we have to worry about selective display. */ | |
1187 (XTYPE (current_buffer->selective_display) == Lisp_Int | |
1188 && XINT (current_buffer->selective_display) > 0 | |
1189 && bp.bufpos - 1 == beg_unchanged && vpos > 0)) | |
277 | 1190 { |
1191 bp = *vmotion (bp.bufpos, -1, width, hscroll, window); | |
1192 --vpos; | |
1193 pos = bp.bufpos; | |
1194 } | |
1195 | |
1196 if (bp.contin && bp.hpos != lmargin) | |
1197 { | |
1198 val.hpos = bp.prevhpos - width + lmargin; | |
1199 pos--; | |
1200 } | |
1201 | |
1202 bp.vpos = vpos; | |
1203 | |
1204 /* Find first visible newline after which no more is changed. */ | |
1205 tem = find_next_newline (Z - max (end_unchanged, Z - ZV), 1); | |
1206 if (XTYPE (current_buffer->selective_display) == Lisp_Int | |
1207 && XINT (current_buffer->selective_display) > 0) | |
1208 while (tem < ZV - 1 | |
1209 && (position_indentation (tem) | |
1210 >= XINT (current_buffer->selective_display))) | |
1211 tem = find_next_newline (tem, 1); | |
1212 | |
1213 /* Compute the cursor position after that newline. */ | |
1214 ep = *compute_motion (pos, vpos, val.hpos, tem, | |
1215 height, - (1 << (SHORTBITS - 1)), | |
1216 width, hscroll, pos_tab_offset (w, bp.bufpos)); | |
1217 | |
769 | 1218 /* If changes reach past the text available on the frame, |
1219 just display rest of frame. */ | |
277 | 1220 if (ep.bufpos > Z - XFASTINT (w->window_end_pos)) |
1221 stop_vpos = height; | |
1222 else | |
1223 stop_vpos = ep.vpos; | |
1224 | |
1225 /* If no newline before ep, the line ep is on includes some changes | |
1226 that must be displayed. Make sure we don't stop before it. */ | |
1227 /* Also, if changes reach all the way until ep.bufpos, | |
1228 it is possible that something was deleted after the | |
1229 newline before it, so the following line must be redrawn. */ | |
1230 if (stop_vpos == ep.vpos | |
1231 && (ep.bufpos == BEGV | |
1232 || FETCH_CHAR (ep.bufpos - 1) != '\n' | |
1233 || ep.bufpos == Z - end_unchanged)) | |
1234 stop_vpos = ep.vpos + 1; | |
1235 | |
1236 cursor_vpos = -1; | |
1237 overlay_arrow_seen = 0; | |
1238 | |
1239 /* If changes do not reach to bottom of window, | |
1240 figure out how much to scroll the rest of the window */ | |
1241 if (stop_vpos < height) | |
1242 { | |
1243 /* Now determine how far up or down the rest of the window has moved */ | |
1244 epto = pos_tab_offset (w, ep.bufpos); | |
1245 xp = *compute_motion (ep.bufpos, ep.vpos, ep.hpos, | |
1246 Z - XFASTINT (w->window_end_pos), | |
1247 10000, 0, width, hscroll, epto); | |
1248 scroll_amount = xp.vpos - XFASTINT (w->window_end_vpos); | |
1249 | |
769 | 1250 /* Is everything on frame below the changes whitespace? |
277 | 1251 If so, no scrolling is really necessary. */ |
1252 for (i = ep.bufpos; i < xp.bufpos; i++) | |
1253 { | |
1254 tem = FETCH_CHAR (i); | |
1255 if (tem != ' ' && tem != '\n' && tem != '\t') | |
1256 break; | |
1257 } | |
1258 if (i == xp.bufpos) | |
1259 return -2; | |
1260 | |
1261 XFASTINT (w->window_end_vpos) += scroll_amount; | |
1262 | |
769 | 1263 /* Before doing any scrolling, verify that point will be on frame. */ |
277 | 1264 if (point > ep.bufpos && !(point <= xp.bufpos && xp.bufpos < height)) |
1265 { | |
1266 if (point <= xp.bufpos) | |
1267 { | |
1268 pp = *compute_motion (ep.bufpos, ep.vpos, ep.hpos, | |
1269 point, height, - (1 << (SHORTBITS - 1)), | |
1270 width, hscroll, epto); | |
1271 } | |
1272 else | |
1273 { | |
1274 pp = *compute_motion (xp.bufpos, xp.vpos, xp.hpos, | |
1275 point, height, - (1 << (SHORTBITS - 1)), | |
1276 width, hscroll, pos_tab_offset (w, xp.bufpos)); | |
1277 } | |
1278 if (pp.bufpos < point || pp.vpos == height) | |
1279 return 0; | |
1280 cursor_vpos = pp.vpos + top; | |
1281 cursor_hpos = pp.hpos + XFASTINT (w->left); | |
1282 } | |
1283 | |
1284 if (stop_vpos - scroll_amount >= height | |
1285 || ep.bufpos == xp.bufpos) | |
1286 { | |
1287 if (scroll_amount < 0) | |
1288 stop_vpos -= scroll_amount; | |
1289 scroll_amount = 0; | |
1290 /* In this path, we have altered window_end_vpos | |
1291 and not left it negative. | |
1292 We must make sure that, in case display is preempted | |
769 | 1293 before the frame changes to reflect what we do here, |
277 | 1294 further updates will not come to try_window_id |
769 | 1295 and assume the frame and window_end_vpos match. */ |
277 | 1296 blank_end_of_window = 1; |
1297 } | |
1298 else if (!scroll_amount) | |
1299 {} | |
1300 else if (bp.bufpos == Z - end_unchanged) | |
1301 { | |
1302 /* If reprinting everything is nearly as fast as scrolling, | |
1303 don't bother scrolling. Can happen if lines are short. */ | |
769 | 1304 if (scroll_cost (f, bp.vpos + top - scroll_amount, |
277 | 1305 top + height - max (0, scroll_amount), |
1306 scroll_amount) | |
1307 > xp.bufpos - bp.bufpos - 20) | |
1308 /* Return "try normal display with same window-start." | |
1309 Too bad we can't prevent further scroll-thinking. */ | |
1310 return -2; | |
1311 /* If pure deletion, scroll up as many lines as possible. | |
1312 In common case of killing a line, this can save the | |
1313 following line from being overwritten by scrolling | |
1314 and therefore having to be redrawn. */ | |
769 | 1315 tem = scroll_frame_lines (f, bp.vpos + top - scroll_amount, |
277 | 1316 top + height - max (0, scroll_amount), |
1317 scroll_amount); | |
1318 if (!tem) stop_vpos = height; | |
1319 } | |
1320 else if (scroll_amount) | |
1321 { | |
1322 /* If reprinting everything is nearly as fast as scrolling, | |
1323 don't bother scrolling. Can happen if lines are short. */ | |
1324 /* Note that if scroll_amount > 0, xp.bufpos - bp.bufpos is an | |
1325 overestimate of cost of reprinting, since xp.bufpos | |
1326 would end up below the bottom of the window. */ | |
769 | 1327 if (scroll_cost (f, ep.vpos + top - scroll_amount, |
277 | 1328 top + height - max (0, scroll_amount), |
1329 scroll_amount) | |
1330 > xp.bufpos - ep.bufpos - 20) | |
1331 /* Return "try normal display with same window-start." | |
1332 Too bad we can't prevent further scroll-thinking. */ | |
1333 return -2; | |
769 | 1334 tem = scroll_frame_lines (f, ep.vpos + top - scroll_amount, |
277 | 1335 top + height - max (0, scroll_amount), |
1336 scroll_amount); | |
1337 if (!tem) stop_vpos = height; | |
1338 } | |
1339 } | |
1340 | |
1341 /* In any case, do not display past bottom of window */ | |
1342 if (stop_vpos >= height) | |
1343 { | |
1344 stop_vpos = height; | |
1345 scroll_amount = 0; | |
1346 } | |
1347 | |
1348 /* Handle case where pos is before w->start -- | |
1349 can happen if part of line had been clipped and is not clipped now */ | |
1350 if (vpos == 0 && pos < marker_position (w->start)) | |
1351 Fset_marker (w->start, make_number (pos), Qnil); | |
1352 | |
1353 /* Redisplay the lines where the text was changed */ | |
1354 last_text_vpos = vpos; | |
1355 tab_offset = pos_tab_offset (w, pos); | |
1356 /* If we are starting display in mid-character, correct tab_offset | |
1357 to account for passing the line that that character really starts in. */ | |
1358 if (val.hpos < lmargin) | |
1359 tab_offset += width; | |
1360 while (vpos < stop_vpos) | |
1361 { | |
1362 val = *display_text_line (w, pos, top + vpos++, val.hpos, tab_offset); | |
1363 tab_offset += width; | |
1364 if (val.vpos) tab_offset = 0; | |
1365 if (pos != val.bufpos) | |
1366 last_text_vpos | |
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 pos = val.bufpos; | |
1370 } | |
1371 | |
1372 /* There are two cases: | |
1373 1) we have displayed down to the bottom of the window | |
1374 2) we have scrolled lines below stop_vpos by scroll_amount */ | |
1375 | |
1376 if (vpos == height) | |
1377 { | |
1378 /* If last line is continued in middle of character, | |
769 | 1379 include the split character in the text considered on the frame */ |
277 | 1380 if (val.hpos < lmargin) |
1381 val.bufpos++; | |
1382 XFASTINT (w->window_end_vpos) = last_text_vpos; | |
1383 XFASTINT (w->window_end_pos) = Z - val.bufpos; | |
1384 } | |
1385 | |
1386 /* If scrolling made blank lines at window bottom, | |
1387 redisplay to fill those lines */ | |
1388 if (scroll_amount < 0) | |
1389 { | |
1390 /* Don't consider these lines for general-purpose scrolling. | |
1391 That will save time in the scrolling computation. */ | |
769 | 1392 FRAME_SCROLL_BOTTOM_VPOS (f) = xp.vpos; |
277 | 1393 vpos = xp.vpos; |
1394 pos = xp.bufpos; | |
1395 val.hpos = lmargin; | |
1396 if (pos == ZV) | |
1397 vpos = height + scroll_amount; | |
1398 else if (xp.contin && xp.hpos != lmargin) | |
1399 { | |
1400 val.hpos = xp.prevhpos - width + lmargin; | |
1401 pos--; | |
1402 } | |
1403 | |
1404 blank_end_of_window = 1; | |
1405 tab_offset = pos_tab_offset (w, pos); | |
1406 /* If we are starting display in mid-character, correct tab_offset | |
1407 to account for passing the line that that character starts in. */ | |
1408 if (val.hpos < lmargin) | |
1409 tab_offset += width; | |
1410 | |
1411 while (vpos < height) | |
1412 { | |
1413 val = *display_text_line (w, pos, top + vpos++, val.hpos, tab_offset); | |
1414 tab_offset += width; | |
1415 if (val.vpos) tab_offset = 0; | |
1416 pos = val.bufpos; | |
1417 } | |
1418 | |
1419 /* Here is a case where display_text_line sets cursor_vpos wrong. | |
1420 Make it be fixed up, below. */ | |
1421 if (xp.bufpos == ZV | |
1422 && xp.bufpos == point) | |
1423 cursor_vpos = -1; | |
1424 } | |
1425 | |
769 | 1426 /* If bottom just moved off end of frame, change mode line percentage. */ |
277 | 1427 if (XFASTINT (w->window_end_pos) == 0 |
1428 && Z != val.bufpos) | |
1429 w->update_mode_line = Qt; | |
1430 | |
1431 /* Attempt to adjust end-of-text positions to new bottom line */ | |
1432 if (scroll_amount) | |
1433 { | |
1434 delta = height - xp.vpos; | |
1435 if (delta < 0 | |
1436 || (delta > 0 && xp.bufpos <= ZV) | |
1437 || (delta == 0 && xp.hpos)) | |
1438 { | |
1439 val = *vmotion (Z - XFASTINT (w->window_end_pos), | |
1440 delta, width, hscroll, window); | |
1441 XFASTINT (w->window_end_pos) = Z - val.bufpos; | |
1442 XFASTINT (w->window_end_vpos) += val.vpos; | |
1443 } | |
1444 } | |
1445 | |
1446 w->window_end_valid = Qnil; | |
1447 | |
1448 /* If point was not in a line that was displayed, find it */ | |
1449 if (cursor_vpos < 0) | |
1450 { | |
1451 val = *compute_motion (start, 0, lmargin, point, 10000, 10000, | |
1452 width, hscroll, pos_tab_offset (w, start)); | |
769 | 1453 /* Admit failure if point is off frame now */ |
277 | 1454 if (val.vpos >= height) |
1455 { | |
1456 for (vpos = 0; vpos < height; vpos++) | |
769 | 1457 cancel_line (vpos + top, f); |
277 | 1458 return 0; |
1459 } | |
1460 cursor_vpos = val.vpos + top; | |
1461 cursor_hpos = val.hpos + XFASTINT (w->left); | |
1462 } | |
1463 | |
769 | 1464 FRAME_CURSOR_X (f) = max (0, cursor_hpos); |
1465 FRAME_CURSOR_Y (f) = cursor_vpos; | |
277 | 1466 |
1467 if (debug_end_pos) | |
1468 { | |
1469 val = *compute_motion (start, 0, lmargin, ZV, | |
1470 height, - (1 << (SHORTBITS - 1)), | |
1471 width, hscroll, pos_tab_offset (w, start)); | |
1472 if (val.vpos != XFASTINT (w->window_end_vpos)) | |
1473 abort (); | |
1474 if (XFASTINT (w->window_end_pos) | |
1475 != Z - val.bufpos) | |
1476 abort (); | |
1477 } | |
1478 | |
1479 return 1; | |
1480 } | |
1481 | |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1482 /* Mark a section of BUF as modified, but only for the sake of redisplay. |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1483 This is useful for recording changes to overlays. |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1484 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1485 We increment the buffer's modification timestamp and set the |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1486 redisplay caches (windows_or_buffers_changed, beg_unchanged, etc) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1487 as if the region of text between START and END had been modified; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1488 the redisplay code will check this against the windows' timestamps, |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1489 and redraw the appropriate area of the buffer. |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1490 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1491 However, if the buffer is unmodified, we bump the last-save |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1492 timestamp as well, so that incrementing the timestamp doesn't fool |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1493 Emacs into thinking that the buffer's text has been modified. |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1494 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1495 Tweaking the timestamps shouldn't hurt the first-modification |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1496 timestamps recorded in the undo records; those values aren't |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1497 written until just before a real text modification is made, so they |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1498 will never catch the timestamp value just before this function gets |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1499 called. */ |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1500 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1501 void |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1502 redisplay_region (buf, start, end) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1503 struct buffer *buf; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1504 int start, end; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1505 { |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1506 if (start == end) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1507 return; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1508 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1509 if (start > end) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1510 { |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1511 int temp = start; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1512 start = end; end = temp; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1513 } |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1514 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1515 if (buf != current_buffer) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1516 windows_or_buffers_changed = 1; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1517 else |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1518 { |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1519 if (unchanged_modified == MODIFF) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1520 { |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1521 beg_unchanged = start - BEG; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1522 end_unchanged = Z - end; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1523 } |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1524 else |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1525 { |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1526 if (Z - end < end_unchanged) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1527 end_unchanged = Z - end; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1528 if (start - BEG < beg_unchanged) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1529 beg_unchanged = start - BEG; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1530 } |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1531 } |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1532 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1533 /* Increment the buffer's time stamp, but also increment the save |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1534 and autosave timestamps, so as not to screw up that timekeeping. */ |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1535 if (BUF_MODIFF (buf) == buf->save_modified) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1536 buf->save_modified++; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1537 if (BUF_MODIFF (buf) == buf->auto_save_modified) |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1538 buf->auto_save_modified++; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1539 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1540 BUF_MODIFF (buf) ++; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1541 } |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1542 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1543 |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1544 /* Copy glyphs from the vector FROM to the rope T. |
301 | 1545 But don't actually copy the parts that would come in before S. |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1546 Value is T, advanced past the copied data. */ |
277 | 1547 |
1548 GLYPH * | |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1549 copy_rope (t, s, from, face) |
277 | 1550 register GLYPH *t; /* Copy to here. */ |
1551 register GLYPH *s; /* Starting point. */ | |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1552 Lisp_Object from; /* Data to copy; known to be a vector. */ |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1553 int face; /* Face to apply to glyphs which don't specify one. */ |
277 | 1554 { |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1555 register int n = XVECTOR (from)->size; |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1556 register Lisp_Object *f = XVECTOR (from)->contents; |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1557 |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1558 while (n--) |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1559 { |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1560 if (t >= s) *t = MAKE_GLYPH (GLYPH_CHAR (*f), |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1561 (GLYPH_FACE (*f) |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1562 ? GLYPH_FACE (*f) |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1563 : face)); |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1564 ++t; |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1565 ++f; |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1566 } |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1567 return t; |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1568 } |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1569 |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1570 /* Copy exactly LEN glyphs from FROM into data at T. |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1571 But don't alter words before S. */ |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1572 |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1573 GLYPH * |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1574 copy_part_of_rope (t, s, from, len, face) |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1575 register GLYPH *t; /* Copy to here. */ |
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1576 register GLYPH *s; /* Starting point. */ |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1577 Lisp_Object *from; /* Data to copy. */ |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1578 int len; |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1579 int face; /* Face to apply to glyphs which don't specify one. */ |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1580 { |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1581 int n = len; |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1582 register Lisp_Object *f = from; |
277 | 1583 |
1584 while (n--) | |
1585 { | |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1586 if (t >= s) *t = MAKE_GLYPH (GLYPH_CHAR (*f), |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1587 (GLYPH_FACE (*f) |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1588 ? GLYPH_FACE (*f) |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1589 : face)); |
277 | 1590 ++t; |
1591 ++f; | |
1592 } | |
1593 return t; | |
1594 } | |
1595 | |
1596 /* Display one line of window w, starting at position START in W's buffer. | |
1597 Display starting at horizontal position HPOS, which is normally zero | |
1598 or negative. A negative value causes output up to hpos = 0 to be discarded. | |
1599 This is done for negative hscroll, or when this is a continuation line | |
1600 and the continuation occurred in the middle of a multi-column character. | |
1601 | |
1602 TABOFFSET is an offset for ostensible hpos, used in tab stop calculations. | |
1603 | |
769 | 1604 Display on position VPOS on the frame. (origin 0). |
277 | 1605 |
1606 Returns a STRUCT POSITION giving character to start next line with | |
1607 and where to display it, including a zero or negative hpos. | |
1608 The vpos field is not really a vpos; it is 1 unless the line is continued */ | |
1609 | |
1610 struct position val_display_text_line; | |
1611 | |
1612 static struct position * | |
1613 display_text_line (w, start, vpos, hpos, taboffset) | |
1614 struct window *w; | |
1615 int start; | |
1616 int vpos; | |
1617 int hpos; | |
1618 int taboffset; | |
1619 { | |
1620 register int pos = start; | |
1621 register int c; | |
1622 register GLYPH *p1; | |
1623 int end; | |
1624 register int pause; | |
1625 register unsigned char *p; | |
1626 GLYPH *endp; | |
1627 register GLYPH *startp; | |
1628 register GLYPH *p1prev; | |
769 | 1629 FRAME_PTR f = XFRAME (w->frame); |
277 | 1630 int tab_width = XINT (current_buffer->tab_width); |
485 | 1631 int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1632 int width = window_internal_width (w) - 1; |
277 | 1633 struct position val; |
1634 int lastpos; | |
1635 int invis; | |
1636 int hscroll = XINT (w->hscroll); | |
1637 int truncate = hscroll | |
1638 || (truncate_partial_width_windows | |
769 | 1639 && XFASTINT (w->width) < FRAME_WIDTH (f)) |
485 | 1640 || !NILP (current_buffer->truncate_lines); |
277 | 1641 int selective |
1642 = XTYPE (current_buffer->selective_display) == Lisp_Int | |
1643 ? XINT (current_buffer->selective_display) | |
485 | 1644 : !NILP (current_buffer->selective_display) ? -1 : 0; |
769 | 1645 register struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (f); |
277 | 1646 register struct Lisp_Vector *dp = window_display_table (w); |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1647 |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1648 Lisp_Object default_invis_vector[3]; |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1649 /* Nonzero means display something where there are invisible lines. |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1650 The precise value is the number of glyphs to display. */ |
277 | 1651 int selective_rlen |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1652 = (selective && dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1653 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1654 : selective && !NILP (current_buffer->selective_display_ellipses) |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1655 ? 3 : 0); |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1656 /* This is the sequence of Lisp objects to display |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1657 when there are invisible lines. */ |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1658 Lisp_Object *invis_vector_contents |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1659 = (dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1660 ? XVECTOR (DISP_INVIS_VECTOR (dp))->contents |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1661 : default_invis_vector); |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1662 |
277 | 1663 GLYPH truncator = (dp == 0 || XTYPE (DISP_TRUNC_GLYPH (dp)) != Lisp_Int |
1664 ? '$' : XINT (DISP_TRUNC_GLYPH (dp))); | |
1665 GLYPH continuer = (dp == 0 || XTYPE (DISP_CONTINUE_GLYPH (dp)) != Lisp_Int | |
1666 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp))); | |
1667 | |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1668 /* The next buffer location at which the face should change, due |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1669 to overlays or text property changes. */ |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1670 int next_face_change; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1671 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1672 /* The face we're currently using. */ |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1673 int current_face = 0; |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1674 |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1675 XFASTINT (default_invis_vector[2]) = '.'; |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1676 default_invis_vector[0] = default_invis_vector[1] = default_invis_vector[2]; |
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1677 |
277 | 1678 hpos += XFASTINT (w->left); |
769 | 1679 get_display_line (f, vpos, XFASTINT (w->left)); |
2324
24cd3df6f184
(display_string, display_text_line): Allow tab_width up to 1000.
Richard M. Stallman <rms@gnu.org>
parents:
2303
diff
changeset
|
1680 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
277 | 1681 |
1682 if (MINI_WINDOW_P (w) && start == 1 | |
1683 && vpos == XFASTINT (w->top)) | |
1684 { | |
1685 if (minibuf_prompt) | |
1686 hpos = display_string (w, vpos, minibuf_prompt, hpos, | |
1687 (!truncate ? continuer : truncator), | |
1688 -1, -1); | |
1689 minibuf_prompt_width = hpos; | |
1690 } | |
1691 | |
1692 desired_glyphs->bufp[vpos] = pos; | |
1693 p1 = desired_glyphs->glyphs[vpos] + hpos; | |
1694 end = ZV; | |
1695 startp = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); | |
1696 endp = startp + width; | |
1697 | |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1698 /* Arrange the overlays nicely for our purposes. Usually, we call |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1699 display_text_line on only one line at a time, in which case this |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1700 can't really hurt too much, or we call it on lines which appear |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1701 one after another in the buffer, in which case all calls to |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1702 recenter_overlay_lists but the first will be pretty cheap. */ |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1703 recenter_overlay_lists (current_buffer, pos); |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1704 |
277 | 1705 /* Loop generating characters. |
1706 Stop at end of buffer, before newline, | |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1707 if reach or pass continuation column, |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1708 or at face change. */ |
277 | 1709 pause = pos; |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1710 next_face_change = pos; |
277 | 1711 while (p1 < endp) |
1712 { | |
1713 p1prev = p1; | |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1714 if (pos >= pause) |
277 | 1715 { |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1716 /* Did we hit the end of the visible region of the buffer? |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1717 Stop here. */ |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1718 if (pos >= end) |
277 | 1719 break; |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1720 |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1721 /* Did we reach point? Record the cursor location. */ |
277 | 1722 if (pos == point && cursor_vpos < 0) |
1723 { | |
1724 cursor_vpos = vpos; | |
1725 cursor_hpos = p1 - startp; | |
1726 } | |
1727 | |
2742
7800e6a86421
* xdisp.c (display_text_line): Make face-handling code conditional
Jim Blandy <jimb@redhat.com>
parents:
2729
diff
changeset
|
1728 #ifdef HAVE_X_WINDOWS |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1729 /* Did we hit a face change? Figure out what face we should |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1730 use now. We also hit this the first time through the |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1731 loop, to see what face we should start with. */ |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1732 if (pos == next_face_change) |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1733 current_face = compute_char_face (f, w, pos, &next_face_change); |
2742
7800e6a86421
* xdisp.c (display_text_line): Make face-handling code conditional
Jim Blandy <jimb@redhat.com>
parents:
2729
diff
changeset
|
1734 #endif |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1735 |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1736 pause = end; |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1737 |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1738 if (pos < next_face_change && next_face_change < pause) |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1739 pause = next_face_change; |
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1740 |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1741 /* Wouldn't you hate to read the next line to someone over |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1742 the phone? */ |
277 | 1743 if (pos < point && point < pause) |
1744 pause = point; | |
1745 if (pos < GPT && GPT < pause) | |
1746 pause = GPT; | |
1747 | |
1748 p = &FETCH_CHAR (pos); | |
1749 } | |
1750 c = *p++; | |
1751 if (c >= 040 && c < 0177 | |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1752 && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector)) |
277 | 1753 { |
1754 if (p1 >= startp) | |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1755 *p1 = MAKE_GLYPH (c, current_face); |
277 | 1756 p1++; |
1757 } | |
1758 else if (c == '\n') | |
1759 { | |
1760 invis = 0; | |
1761 while (pos < end | |
1762 && selective > 0 | |
1763 && position_indentation (pos + 1) >= selective) | |
1764 { | |
1765 invis = 1; | |
1766 pos = find_next_newline (pos + 1, 1); | |
1767 if (FETCH_CHAR (pos - 1) == '\n') | |
1768 pos--; | |
1769 } | |
1770 if (invis && selective_rlen > 0 && p1 >= startp) | |
1771 { | |
1772 p1 += selective_rlen; | |
1773 if (p1 - startp > width) | |
1774 p1 = endp; | |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1775 copy_part_of_rope (p1prev, p1prev, invis_vector_contents, |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1776 (p1 - p1prev), current_face); |
277 | 1777 } |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1778 break; |
277 | 1779 } |
1780 else if (c == '\t') | |
1781 { | |
1782 do | |
1783 { | |
1784 if (p1 >= startp && p1 < endp) | |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1785 *p1 = MAKE_GLYPH (' ', current_face); |
277 | 1786 p1++; |
1787 } | |
1788 while ((p1 - startp + taboffset + hscroll - (hscroll > 0)) | |
1789 % tab_width); | |
1790 } | |
368 | 1791 else if (c == Ctl ('M') && selective == -1) |
277 | 1792 { |
1793 pos = find_next_newline (pos, 1); | |
1794 if (FETCH_CHAR (pos - 1) == '\n') | |
1795 pos--; | |
1796 if (selective_rlen > 0) | |
1797 { | |
1798 p1 += selective_rlen; | |
1799 if (p1 - startp > width) | |
1800 p1 = endp; | |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1801 copy_part_of_rope (p1prev, p1prev, invis_vector_contents, |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1802 (p1 - p1prev), current_face); |
277 | 1803 } |
2754
af06c054b48f
(display_text_line): Use break; to exit loop at eol.
Richard M. Stallman <rms@gnu.org>
parents:
2742
diff
changeset
|
1804 break; |
277 | 1805 } |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
1806 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector) |
277 | 1807 { |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1808 p1 = copy_rope (p1, startp, DISP_CHAR_VECTOR (dp, c), current_face); |
277 | 1809 } |
1810 else if (c < 0200 && ctl_arrow) | |
1811 { | |
1812 if (p1 >= startp) | |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1813 *p1 = MAKE_GLYPH ((dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1814 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'), |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1815 current_face); |
277 | 1816 p1++; |
368 | 1817 if (p1 >= startp && p1 < endp) |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1818 *p1 = MAKE_GLYPH (c ^ 0100, current_face); |
277 | 1819 p1++; |
1820 } | |
1821 else | |
1822 { | |
1823 if (p1 >= startp) | |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1824 *p1 = MAKE_GLYPH ((dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1825 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1826 current_face); |
277 | 1827 p1++; |
368 | 1828 if (p1 >= startp && p1 < endp) |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1829 *p1 = MAKE_GLYPH ((c >> 6) + '0', current_face); |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1830 p1++; |
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1831 if (p1 >= startp && p1 < endp) |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1832 *p1 = MAKE_GLYPH ((7 & (c >> 3)) + '0', current_face); |
277 | 1833 p1++; |
368 | 1834 if (p1 >= startp && p1 < endp) |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
1835 *p1 = MAKE_GLYPH ((7 & c) + '0', current_face); |
277 | 1836 p1++; |
1837 } | |
2729
76afd3322533
Arrange to tell redisplay about changes in overlays.
Jim Blandy <jimb@redhat.com>
parents:
2526
diff
changeset
|
1838 |
277 | 1839 pos++; |
1840 } | |
1841 | |
1842 val.hpos = - XINT (w->hscroll); | |
1843 if (val.hpos) | |
1844 val.hpos++; | |
1845 | |
1846 val.vpos = 1; | |
1847 | |
1848 lastpos = pos; | |
1849 | |
1850 /* Handle continuation in middle of a character */ | |
1851 /* by backing up over it */ | |
1852 if (p1 > endp) | |
1853 { | |
1854 /* Start the next line with that same character */ | |
1855 pos--; | |
1856 /* but at a negative hpos, to skip the columns output on this line. */ | |
1857 val.hpos += p1prev - endp; | |
1858 /* Keep in this line everything up to the continuation column. */ | |
1859 p1 = endp; | |
1860 } | |
1861 | |
1862 /* Finish deciding which character to start the next line on, | |
1863 and what hpos to start it at. | |
1864 Also set `lastpos' to the last position which counts as "on this line" | |
1865 for cursor-positioning. */ | |
1866 | |
1867 if (pos < ZV) | |
1868 { | |
1869 if (FETCH_CHAR (pos) == '\n') | |
1870 /* If stopped due to a newline, start next line after it */ | |
1871 pos++; | |
1872 else | |
1873 /* Stopped due to right margin of window */ | |
1874 { | |
1875 if (truncate) | |
1876 { | |
1877 *p1++ = truncator; | |
1878 /* Truncating => start next line after next newline, | |
1879 and point is on this line if it is before the newline, | |
1880 and skip none of first char of next line */ | |
1881 pos = find_next_newline (pos, 1); | |
1882 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0; | |
1883 | |
1884 lastpos = pos - (FETCH_CHAR (pos - 1) == '\n'); | |
1885 } | |
1886 else | |
1887 { | |
1888 *p1++ = continuer; | |
1889 val.vpos = 0; | |
1890 lastpos--; | |
1891 } | |
1892 } | |
1893 } | |
1894 | |
1895 /* If point is at eol or in invisible text at eol, | |
769 | 1896 record its frame location now. */ |
277 | 1897 |
1898 if (start <= point && point <= lastpos && cursor_vpos < 0) | |
1899 { | |
1900 cursor_vpos = vpos; | |
1901 cursor_hpos = p1 - startp; | |
1902 } | |
1903 | |
1904 if (cursor_vpos == vpos) | |
1905 { | |
1906 if (cursor_hpos < 0) cursor_hpos = 0; | |
1907 if (cursor_hpos > width) cursor_hpos = width; | |
1908 cursor_hpos += XFASTINT (w->left); | |
769 | 1909 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f))) |
277 | 1910 { |
769 | 1911 FRAME_CURSOR_Y (f) = cursor_vpos; |
1912 FRAME_CURSOR_X (f) = cursor_hpos; | |
277 | 1913 |
1914 if (w == XWINDOW (selected_window)) | |
1915 { | |
1916 /* Line is not continued and did not start | |
1917 in middle of character */ | |
1918 if ((hpos - XFASTINT (w->left) | |
1919 == (XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0)) | |
1920 && val.vpos) | |
1921 { | |
1922 this_line_bufpos = start; | |
1923 this_line_buffer = current_buffer; | |
1924 this_line_vpos = cursor_vpos; | |
1925 this_line_start_hpos = hpos; | |
1926 this_line_endpos = Z - lastpos; | |
1927 } | |
1928 else | |
1929 this_line_bufpos = 0; | |
1930 } | |
1931 } | |
1932 } | |
1933 | |
1934 /* If hscroll and line not empty, insert truncation-at-left marker */ | |
1935 if (hscroll && lastpos != start) | |
1936 { | |
1937 *startp = truncator; | |
1938 if (p1 <= startp) | |
1939 p1 = startp + 1; | |
1940 } | |
1941 | |
769 | 1942 if (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)) |
277 | 1943 { |
1944 endp++; | |
1945 if (p1 < startp) p1 = startp; | |
1946 while (p1 < endp) *p1++ = SPACEGLYPH; | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1947 |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1948 /* Don't draw vertical bars if we're using scroll bars. They're |
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1949 covered up by the scroll bars, and it's distracting to see |
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1950 them when the scroll bar windows are flickering around to be |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1951 reconfigured. */ |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
1952 *p1++ = (FRAME_HAS_VERTICAL_SCROLL_BARS (f) |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1953 ? ' ' : '|'); |
277 | 1954 } |
1955 desired_glyphs->used[vpos] = max (desired_glyphs->used[vpos], | |
1956 p1 - desired_glyphs->glyphs[vpos]); | |
1957 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0; | |
1958 | |
1959 /* If the start of this line is the overlay arrow-position, | |
1960 then put the arrow string into the display-line. */ | |
1961 | |
1962 if (XTYPE (Voverlay_arrow_position) == Lisp_Marker | |
1963 && current_buffer == XMARKER (Voverlay_arrow_position)->buffer | |
1964 && start == marker_position (Voverlay_arrow_position) | |
1965 && XTYPE (Voverlay_arrow_string) == Lisp_String | |
1966 && ! overlay_arrow_seen) | |
1967 { | |
1968 unsigned char *p = XSTRING (Voverlay_arrow_string)->data; | |
1969 int i; | |
1970 int len = XSTRING (Voverlay_arrow_string)->size; | |
1971 | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1972 if (len > width) |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
1973 len = width; |
277 | 1974 for (i = 0; i < len; i++) |
1975 startp[i] = p[i]; | |
1976 if (desired_glyphs->used[vpos] < | |
1977 (len + startp - desired_glyphs->glyphs[vpos])) | |
1978 desired_glyphs->used[vpos] = len + startp - desired_glyphs->glyphs[vpos]; | |
1979 | |
1980 overlay_arrow_seen = 1; | |
1981 } | |
1982 | |
1983 val.bufpos = pos; | |
1984 val_display_text_line = val; | |
1985 return &val_display_text_line; | |
1986 } | |
1987 | |
2150
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1988 /* Redisplay the menu bar in the frame for window W. */ |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1989 |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1990 static void |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1991 display_menu_bar (w) |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1992 struct window *w; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1993 { |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1994 Lisp_Object items, tail; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1995 register int vpos = 0; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1996 register FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1997 int maxendcol = FRAME_WIDTH (f); |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1998 int hpos = 0; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
1999 |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2000 if (FRAME_MENU_BAR_LINES (f) <= 0) |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2001 return; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2002 |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2003 get_display_line (f, vpos, 0); |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2004 |
2189
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2005 for (tail = FRAME_MENU_BAR_ITEMS (f); CONSP (tail); tail = XCONS (tail)->cdr) |
2150
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2006 { |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2007 Lisp_Object string; |
2189
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2008 |
2150
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2009 string = XCONS (XCONS (XCONS (tail)->car)->cdr)->car; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2010 |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2011 /* Record in each item its hpos. */ |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2012 XFASTINT (XCONS (XCONS (XCONS (tail)->car)->cdr)->cdr) = hpos; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2013 |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2014 if (hpos < maxendcol) |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2015 hpos = display_string (XWINDOW (FRAME_ROOT_WINDOW (f)), vpos, |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2016 XSTRING (string)->data, |
2189
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2017 hpos, 0, hpos, maxendcol); |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2018 /* Put a gap of 3 spaces between items. */ |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2019 if (hpos < maxendcol) |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2020 { |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2021 int hpos1 = hpos + 3; |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2022 hpos = display_string (w, vpos, "", hpos, 0, |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2023 min (hpos1, maxendcol), maxendcol); |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2024 } |
2150
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2025 } |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2026 |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2027 FRAME_DESIRED_GLYPHS (f)->bufp[vpos] = 0; |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2028 FRAME_DESIRED_GLYPHS (f)->highlight[vpos] = mode_line_inverse_video; |
2189
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2029 |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2030 /* Fill out the line with spaces. */ |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2031 if (maxendcol > hpos) |
cb92d253a599
(display_menu_bar): Assume FRAME_MENU_BAR_ITEMS already set.
Richard M. Stallman <rms@gnu.org>
parents:
2150
diff
changeset
|
2032 hpos = display_string (w, vpos, "", hpos, 0, maxendcol, -1); |
2150
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2033 } |
cb8205e30dda
(display_menu_bar): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2065
diff
changeset
|
2034 |
277 | 2035 /* Display the mode line for window w */ |
2036 | |
2037 static void | |
2038 display_mode_line (w) | |
2039 struct window *w; | |
2040 { | |
2041 register int vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1; | |
2042 register int left = XFASTINT (w->left); | |
2043 register int right = XFASTINT (w->width) + left; | |
769 | 2044 register FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
277 | 2045 |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2046 line_number_displayed = 0; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2047 |
769 | 2048 get_display_line (f, vpos, left); |
277 | 2049 display_mode_element (w, vpos, left, 0, right, right, |
2050 current_buffer->mode_line_format); | |
769 | 2051 FRAME_DESIRED_GLYPHS (f)->bufp[vpos] = 0; |
277 | 2052 |
2053 /* Make the mode line inverse video if the entire line | |
2054 is made of mode lines. | |
2055 I.e. if this window is full width, | |
2056 or if it is the child of a full width window | |
2057 (which implies that that window is split side-by-side | |
2058 and the rest of this line is mode lines of the sibling windows). */ | |
769 | 2059 if (XFASTINT (w->width) == FRAME_WIDTH (f) |
2060 || XFASTINT (XWINDOW (w->parent)->width) == FRAME_WIDTH (f)) | |
2061 FRAME_DESIRED_GLYPHS (f)->highlight[vpos] = mode_line_inverse_video; | |
277 | 2062 |
2063 #ifdef HAVE_X_WINDOWS | |
2064 /* I'm trying this out because I saw Unimpress use it, but it's | |
1124
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2065 possible that this may mess adversely with some window managers. -jla |
277 | 2066 |
1124
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2067 Wouldn't it be nice to use something like mode-line-format to |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2068 describe frame titles? -JimB */ |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2069 |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2070 /* Change the title of the frame to the name of the buffer displayed |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2071 in the currently selected window. Don't do this for minibuffer frames, |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2072 and don't do it when there's only one non-minibuffer frame. */ |
973
52267046b144
* xdisp.c (FRAME_IS_TERMCAP, FRAME_IS_X, FRAME_HAS_MINIBUF):
Jim Blandy <jimb@redhat.com>
parents:
831
diff
changeset
|
2073 if (FRAME_X_P (f) |
769 | 2074 && ! FRAME_MINIBUF_ONLY_P (f) |
831 | 2075 && w == XWINDOW (f->selected_window)) |
1124
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2076 x_implicitly_set_name (f, (EQ (Fnext_frame (WINDOW_FRAME (w), Qnil), |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2077 WINDOW_FRAME (w)) |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2078 ? Qnil |
453c24f2bdaa
* xdisp.c (display_mode_line): If the only other frames are
Jim Blandy <jimb@redhat.com>
parents:
1017
diff
changeset
|
2079 : XBUFFER (w->buffer)->name), |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2080 Qnil); |
277 | 2081 #endif |
2082 } | |
2083 | |
2084 /* Contribute ELT to the mode line for window W. | |
2085 How it translates into text depends on its data type. | |
2086 | |
2087 VPOS is the position of the mode line being displayed. | |
2088 | |
769 | 2089 HPOS is the position (absolute on frame) where this element's text |
277 | 2090 should start. The output is truncated automatically at the right |
2091 edge of window W. | |
2092 | |
2093 DEPTH is the depth in recursion. It is used to prevent | |
2094 infinite recursion here. | |
2095 | |
2096 MINENDCOL is the hpos before which the element may not end. | |
2097 The element is padded at the right with spaces if nec | |
2098 to reach this column. | |
2099 | |
2100 MAXENDCOL is the hpos past which this element may not extend. | |
2101 If MINENDCOL is > MAXENDCOL, MINENDCOL takes priority. | |
2102 (This is necessary to make nested padding and truncation work.) | |
2103 | |
2104 Returns the hpos of the end of the text generated by ELT. | |
2105 The next element will receive that value as its HPOS arg, | |
2106 so as to concatenate the elements. */ | |
2107 | |
2108 static int | |
2109 display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt) | |
2110 struct window *w; | |
2111 register int vpos, hpos; | |
2112 int depth; | |
2113 int minendcol; | |
2114 register int maxendcol; | |
2115 register Lisp_Object elt; | |
2116 { | |
2117 tail_recurse: | |
2118 if (depth > 10) | |
2119 goto invalid; | |
2120 | |
2121 depth++; | |
2122 | |
2123 #ifdef SWITCH_ENUM_BUG | |
2124 switch ((int) XTYPE (elt)) | |
2125 #else | |
2126 switch (XTYPE (elt)) | |
2127 #endif | |
2128 { | |
2129 case Lisp_String: | |
2130 { | |
2131 /* A string: output it and check for %-constructs within it. */ | |
2132 register unsigned char c; | |
2133 register unsigned char *this = XSTRING (elt)->data; | |
2134 | |
2135 while (hpos < maxendcol && *this) | |
2136 { | |
2137 unsigned char *last = this; | |
2138 while ((c = *this++) != '\0' && c != '%') | |
2139 ; | |
2140 if (this - 1 != last) | |
2141 { | |
2142 register int lim = --this - last + hpos; | |
2143 hpos = display_string (w, vpos, last, hpos, 0, hpos, | |
2144 min (lim, maxendcol)); | |
2145 } | |
2146 else /* c == '%' */ | |
2147 { | |
2148 register int spec_width = 0; | |
2149 | |
2150 /* We can't allow -ve args due to the "%-" construct */ | |
2151 /* Argument specifies minwidth but not maxwidth | |
2152 (maxwidth can be specified by | |
2153 (<negative-number> . <stuff>) mode-line elements) */ | |
2154 | |
2155 while ((c = *this++) >= '0' && c <= '9') | |
2156 { | |
2157 spec_width = spec_width * 10 + (c - '0'); | |
2158 } | |
2159 | |
2160 spec_width += hpos; | |
2161 if (spec_width > maxendcol) | |
2162 spec_width = maxendcol; | |
2163 | |
2164 if (c == 'M') | |
2165 hpos = display_mode_element (w, vpos, hpos, depth, | |
2166 spec_width, maxendcol, | |
2167 Vglobal_mode_string); | |
2168 else if (c != 0) | |
2169 hpos = display_string (w, vpos, | |
2170 decode_mode_spec (w, c, | |
2171 maxendcol - hpos), | |
2172 hpos, 0, spec_width, maxendcol); | |
2173 } | |
2174 } | |
2175 } | |
2176 break; | |
2177 | |
2178 case Lisp_Symbol: | |
2179 /* A symbol: process the value of the symbol recursively | |
2180 as if it appeared here directly. Avoid error if symbol void. | |
2181 Special case: if value of symbol is a string, output the string | |
2182 literally. */ | |
2183 { | |
2184 register Lisp_Object tem; | |
2185 tem = Fboundp (elt); | |
485 | 2186 if (!NILP (tem)) |
277 | 2187 { |
2188 tem = Fsymbol_value (elt); | |
2189 /* If value is a string, output that string literally: | |
2190 don't check for % within it. */ | |
2191 if (XTYPE (tem) == Lisp_String) | |
2192 hpos = display_string (w, vpos, XSTRING (tem)->data, | |
2193 hpos, 0, minendcol, maxendcol); | |
2194 /* Give up right away for nil or t. */ | |
2195 else if (!EQ (tem, elt)) | |
2196 { elt = tem; goto tail_recurse; } | |
2197 } | |
2198 } | |
2199 break; | |
2200 | |
2201 case Lisp_Cons: | |
2202 { | |
2203 register Lisp_Object car, tem; | |
2204 | |
2205 /* A cons cell: three distinct cases. | |
2206 If first element is a string or a cons, process all the elements | |
2207 and effectively concatenate them. | |
2208 If first element is a negative number, truncate displaying cdr to | |
2209 at most that many characters. If positive, pad (with spaces) | |
2210 to at least that many characters. | |
2211 If first element is a symbol, process the cadr or caddr recursively | |
2212 according to whether the symbol's value is non-nil or nil. */ | |
2213 car = XCONS (elt)->car; | |
2214 if (XTYPE (car) == Lisp_Symbol) | |
2215 { | |
2216 tem = Fboundp (car); | |
2217 elt = XCONS (elt)->cdr; | |
2218 if (XTYPE (elt) != Lisp_Cons) | |
2219 goto invalid; | |
2220 /* elt is now the cdr, and we know it is a cons cell. | |
2221 Use its car if CAR has a non-nil value. */ | |
485 | 2222 if (!NILP (tem)) |
277 | 2223 { |
2224 tem = Fsymbol_value (car); | |
485 | 2225 if (!NILP (tem)) |
277 | 2226 { elt = XCONS (elt)->car; goto tail_recurse; } |
2227 } | |
2228 /* Symbol's value is nil (or symbol is unbound) | |
2229 Get the cddr of the original list | |
2230 and if possible find the caddr and use that. */ | |
2231 elt = XCONS (elt)->cdr; | |
485 | 2232 if (NILP (elt)) |
277 | 2233 break; |
2234 else if (XTYPE (elt) != Lisp_Cons) | |
2235 goto invalid; | |
2236 elt = XCONS (elt)->car; | |
2237 goto tail_recurse; | |
2238 } | |
2239 else if (XTYPE (car) == Lisp_Int) | |
2240 { | |
2241 register int lim = XINT (car); | |
2242 elt = XCONS (elt)->cdr; | |
2243 if (lim < 0) | |
2244 /* Negative int means reduce maximum width. | |
2245 DO NOT change MINENDCOL here! | |
2246 (20 -10 . foo) should truncate foo to 10 col | |
2247 and then pad to 20. */ | |
2248 maxendcol = min (maxendcol, hpos - lim); | |
2249 else if (lim > 0) | |
2250 { | |
2251 /* Padding specified. Don't let it be more than | |
2252 current maximum. */ | |
2253 lim += hpos; | |
2254 if (lim > maxendcol) | |
2255 lim = maxendcol; | |
2256 /* If that's more padding than already wanted, queue it. | |
2257 But don't reduce padding already specified even if | |
2258 that is beyond the current truncation point. */ | |
2259 if (lim > minendcol) | |
2260 minendcol = lim; | |
2261 } | |
2262 goto tail_recurse; | |
2263 } | |
2264 else if (XTYPE (car) == Lisp_String || XTYPE (car) == Lisp_Cons) | |
2265 { | |
2266 register int limit = 50; | |
2267 /* LIMIT is to protect against circular lists. */ | |
2268 while (XTYPE (elt) == Lisp_Cons && --limit > 0 | |
2269 && hpos < maxendcol) | |
2270 { | |
2271 hpos = display_mode_element (w, vpos, hpos, depth, | |
2272 hpos, maxendcol, | |
2273 XCONS (elt)->car); | |
2274 elt = XCONS (elt)->cdr; | |
2275 } | |
2276 } | |
2277 } | |
2278 break; | |
2279 | |
2280 default: | |
2281 invalid: | |
2282 return (display_string (w, vpos, "*invalid*", hpos, 0, | |
2283 minendcol, maxendcol)); | |
2284 } | |
2285 | |
2286 end: | |
2287 if (minendcol > hpos) | |
2288 hpos = display_string (w, vpos, "", hpos, 0, minendcol, -1); | |
2289 return hpos; | |
2290 } | |
2291 | |
2292 /* Return a string for the output of a mode line %-spec for window W, | |
2293 generated by character C and width MAXWIDTH. */ | |
2294 | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2295 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------"; |
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2296 |
277 | 2297 static char * |
2298 decode_mode_spec (w, c, maxwidth) | |
2299 struct window *w; | |
2300 register char c; | |
2301 register int maxwidth; | |
2302 { | |
2303 Lisp_Object obj = Qnil; | |
769 | 2304 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
2305 char *decode_mode_spec_buf = (char *) FRAME_TEMP_GLYPHS (f)->total_contents; | |
277 | 2306 |
769 | 2307 if (maxwidth > FRAME_WIDTH (f)) |
2308 maxwidth = FRAME_WIDTH (f); | |
277 | 2309 |
2310 switch (c) | |
2311 { | |
2312 case 'b': | |
2313 obj = current_buffer->name; | |
2314 #if 0 | |
2315 if (maxwidth >= 3 && XSTRING (obj)->size > maxwidth) | |
2316 { | |
2317 bcopy (XSTRING (obj)->data, decode_mode_spec_buf, maxwidth - 1); | |
2318 decode_mode_spec_buf[maxwidth - 1] = '\\'; | |
2319 decode_mode_spec_buf[maxwidth] = '\0'; | |
2320 return decode_mode_spec_buf; | |
2321 } | |
2322 #endif | |
2323 break; | |
2324 | |
2325 case 'f': | |
2326 obj = current_buffer->filename; | |
2327 #if 0 | |
485 | 2328 if (NILP (obj)) |
277 | 2329 return "[none]"; |
2330 else if (XTYPE (obj) == Lisp_String && XSTRING (obj)->size > maxwidth) | |
2331 { | |
2332 bcopy ("...", decode_mode_spec_buf, 3); | |
2333 bcopy (XSTRING (obj)->data + XSTRING (obj)->size - maxwidth + 3, | |
2334 decode_mode_spec_buf + 3, maxwidth - 3); | |
2335 return decode_mode_spec_buf; | |
2336 } | |
2337 #endif | |
2338 break; | |
2339 | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2340 case 'l': |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2341 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2342 int startpos = marker_position (w->start); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2343 int line, linepos, topline; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2344 int nlines, junk; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2345 Lisp_Object tem; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2346 int height = XFASTINT (w->height); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2347 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2348 /* If we decided that this buffer isn't suitable for line numbers, |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2349 don't forget that too fast. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2350 if (EQ (w->base_line_pos, w->buffer)) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2351 return "??"; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2352 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2353 /* If the buffer is very big, don't waste time. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2354 if (ZV - BEGV > line_number_display_limit) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2355 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2356 w->base_line_pos = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2357 w->base_line_number = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2358 return "??"; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2359 } |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2360 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2361 if (!NILP (w->base_line_number) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2362 && !NILP (w->base_line_pos) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2363 && XFASTINT (w->base_line_pos) <= marker_position (w->start)) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2364 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2365 line = XFASTINT (w->base_line_number); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2366 linepos = XFASTINT (w->base_line_pos); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2367 } |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2368 else |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2369 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2370 line = 1; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2371 linepos = BEGV; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2372 } |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2373 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2374 /* Count lines from base line to window start position. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2375 nlines = display_count_lines (linepos, startpos, startpos, &junk); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2376 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2377 topline = nlines + line; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2378 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2379 /* Determine a new base line, if the old one is too close |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2380 or too far away, or if we did not have one. |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2381 "Too close" means it's plausible a scroll-down would |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2382 go back past it. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2383 if (startpos == BEGV) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2384 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2385 XFASTINT (w->base_line_number) = topline; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2386 XFASTINT (w->base_line_pos) = BEGV; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2387 } |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2388 else if (nlines < height + 25 || nlines > height * 3 + 50 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2389 || linepos == BEGV) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2390 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2391 int limit = BEGV; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2392 int position; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2393 int distance = (height * 2 + 30) * 200; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2394 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2395 if (startpos - distance > limit) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2396 limit = startpos - distance; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2397 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2398 nlines = display_count_lines (startpos, limit, |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2399 -(height * 2 + 30), |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2400 &position); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2401 /* If we couldn't find the lines we wanted within |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2402 200 chars per line, |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2403 give up on line numbers for this window. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2404 if (position == startpos - distance) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2405 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2406 w->base_line_pos = w->buffer; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2407 w->base_line_number = Qnil; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2408 return "??"; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2409 } |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2410 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2411 XFASTINT (w->base_line_number) = topline - nlines; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2412 XFASTINT (w->base_line_pos) = position; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2413 } |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2414 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2415 /* Now count lines from the start pos to point. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2416 nlines = display_count_lines (startpos, PT, PT, &junk); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2417 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2418 /* Record that we did display the line number. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2419 line_number_displayed = 1; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2420 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2421 /* Make the string to show. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2422 sprintf (decode_mode_spec_buf, "%d", topline + nlines); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2423 return decode_mode_spec_buf; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2424 } |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2425 break; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2426 |
277 | 2427 case 'm': |
2428 obj = current_buffer->mode_name; | |
2429 break; | |
2430 | |
2431 case 'n': | |
2432 if (BEGV > BEG || ZV < Z) | |
2433 return " Narrow"; | |
2434 break; | |
2435 | |
2436 case '*': | |
485 | 2437 if (!NILP (current_buffer->read_only)) |
277 | 2438 return "%"; |
2439 if (MODIFF > current_buffer->save_modified) | |
2440 return "*"; | |
2441 return "-"; | |
2442 | |
2443 case 's': | |
2444 /* status of process */ | |
2445 obj = Fget_buffer_process (Fcurrent_buffer ()); | |
485 | 2446 if (NILP (obj)) |
277 | 2447 return "no process"; |
2448 obj = Fsymbol_name (Fprocess_status (obj)); | |
2449 break; | |
2450 | |
2451 case 'p': | |
2452 { | |
2453 int pos = marker_position (w->start); | |
2454 int total = ZV - BEGV; | |
2455 | |
2456 if (XFASTINT (w->window_end_pos) <= Z - ZV) | |
2457 { | |
2458 if (pos <= BEGV) | |
2459 return "All"; | |
2460 else | |
2461 return "Bottom"; | |
2462 } | |
2463 else if (pos <= BEGV) | |
2464 return "Top"; | |
2465 else | |
2466 { | |
2467 total = ((pos - BEGV) * 100 + total - 1) / total; | |
2468 /* We can't normally display a 3-digit number, | |
2469 so get us a 2-digit number that is close. */ | |
2470 if (total == 100) | |
2471 total = 99; | |
2472 sprintf (decode_mode_spec_buf, "%2d%%", total); | |
2473 return decode_mode_spec_buf; | |
2474 } | |
2475 } | |
2476 | |
2477 case '%': | |
2478 return "%"; | |
2479 | |
2480 case '[': | |
2481 { | |
2482 int i; | |
2483 char *p; | |
2484 | |
2485 if (command_loop_level > 5) | |
2486 return "[[[... "; | |
2487 p = decode_mode_spec_buf; | |
2488 for (i = 0; i < command_loop_level; i++) | |
2489 *p++ = '['; | |
2490 *p = 0; | |
2491 return decode_mode_spec_buf; | |
2492 } | |
2493 | |
2494 case ']': | |
2495 { | |
2496 int i; | |
2497 char *p; | |
2498 | |
2499 if (command_loop_level > 5) | |
2500 return " ...]]]"; | |
2501 p = decode_mode_spec_buf; | |
2502 for (i = 0; i < command_loop_level; i++) | |
2503 *p++ = ']'; | |
2504 *p = 0; | |
2505 return decode_mode_spec_buf; | |
2506 } | |
2507 | |
2508 case '-': | |
2509 { | |
2510 register char *p; | |
2511 register int i; | |
2512 | |
2513 if (maxwidth < sizeof (lots_of_dashes)) | |
2514 return lots_of_dashes; | |
2515 else | |
2516 { | |
2517 for (p = decode_mode_spec_buf, i = maxwidth; i > 0; i--) | |
2518 *p++ = '-'; | |
2519 *p = '\0'; | |
2520 } | |
2521 return decode_mode_spec_buf; | |
2522 } | |
2523 } | |
2524 | |
2525 if (XTYPE (obj) == Lisp_String) | |
2526 return (char *) XSTRING (obj)->data; | |
2527 else | |
2528 return ""; | |
2529 } | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2530 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2531 /* Count up to N lines starting from FROM. |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2532 But don't go beyond LIMIT. |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2533 Return the number of lines thus found (always positive). |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2534 Store the position after what was found into *POS_PTR. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2535 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2536 static int |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2537 display_count_lines (from, limit, n, pos_ptr) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2538 int from, limit, n; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2539 int *pos_ptr; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2540 { |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2541 int oldbegv = BEGV; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2542 int oldzv = ZV; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2543 int shortage = 0; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2544 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2545 if (limit < from) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2546 BEGV = limit; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2547 else |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2548 ZV = limit; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2549 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2550 *pos_ptr = scan_buffer ('\n', from, n, &shortage); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2551 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2552 ZV = oldzv; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2553 BEGV = oldbegv; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2554 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2555 if (n < 0) |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2556 /* When scanning backwards, scan_buffer stops *after* the last newline |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2557 it finds, but does count it. Compensate for that. */ |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2558 return - n - shortage - (*pos_ptr != limit); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2559 return n - shortage; |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2560 } |
277 | 2561 |
2562 /* Display STRING on one line of window W, starting at HPOS. | |
2563 Display at position VPOS. Caller should have done get_display_line. | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2564 If VPOS == -1, display it as the current frame's title. |
277 | 2565 |
2566 TRUNCATE is GLYPH to display at end if truncated. Zero for none. | |
2567 | |
2568 MINCOL is the first column ok to end at. (Pad with spaces to this col.) | |
2569 MAXCOL is the last column ok to end at. Truncate here. | |
2570 -1 for MINCOL or MAXCOL means no explicit minimum or maximum. | |
769 | 2571 Both count from the left edge of the frame, as does HPOS. |
277 | 2572 The right edge of W is an implicit maximum. |
2573 If TRUNCATE is nonzero, the implicit maximum is one column before the edge. | |
2574 | |
2575 Returns ending hpos */ | |
2576 | |
2577 static int | |
2578 display_string (w, vpos, string, hpos, truncate, mincol, maxcol) | |
2579 struct window *w; | |
2580 unsigned char *string; | |
2581 int vpos, hpos; | |
2582 GLYPH truncate; | |
2583 int mincol, maxcol; | |
2584 { | |
2585 register int c; | |
2586 register GLYPH *p1; | |
2587 int hscroll = XINT (w->hscroll); | |
1600
775c2ab9800f
* xdisp.c (display_string): Use w's buffer's value of
Jim Blandy <jimb@redhat.com>
parents:
1527
diff
changeset
|
2588 int tab_width = XINT (XBUFFER (w->buffer)->tab_width); |
277 | 2589 register GLYPH *start; |
2590 register GLYPH *end; | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2591 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2592 struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (f); |
277 | 2593 GLYPH *p1start = desired_glyphs->glyphs[vpos] + hpos; |
2594 int window_width = XFASTINT (w->width); | |
2595 | |
2596 /* Use the standard display table, not the window's display table. | |
2597 We don't want the mode line in rot13. */ | |
2598 register struct Lisp_Vector *dp = 0; | |
2599 | |
2600 if (XTYPE (Vstandard_display_table) == Lisp_Vector | |
2601 && XVECTOR (Vstandard_display_table)->size == DISP_TABLE_SIZE) | |
2602 dp = XVECTOR (Vstandard_display_table); | |
2603 | |
2324
24cd3df6f184
(display_string, display_text_line): Allow tab_width up to 1000.
Richard M. Stallman <rms@gnu.org>
parents:
2303
diff
changeset
|
2604 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
277 | 2605 |
2606 p1 = p1start; | |
2607 start = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); | |
2608 end = start + window_width - (truncate != 0); | |
2609 | |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2610 if ((window_width + XFASTINT (w->left)) != FRAME_WIDTH (f)) |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2611 { |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
2612 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2613 { |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2614 int i; |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2615 |
1992
37c45885540a
* xdisp.c (redisplay): Protect calls to request_sigio and
Jim Blandy <jimb@redhat.com>
parents:
1873
diff
changeset
|
2616 for (i = 0; i < VERTICAL_SCROLL_BAR_WIDTH; i++) |
1785
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2617 *end-- = ' '; |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2618 } |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2619 else |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2620 *end-- = '|'; |
19755499df90
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1718
diff
changeset
|
2621 } |
277 | 2622 |
2623 if (maxcol >= 0 && end - desired_glyphs->glyphs[vpos] > maxcol) | |
2624 end = desired_glyphs->glyphs[vpos] + maxcol; | |
2625 if (maxcol >= 0 && mincol > maxcol) | |
2626 mincol = maxcol; | |
2627 | |
2628 while (p1 < end) | |
2629 { | |
2630 c = *string++; | |
2631 if (!c) break; | |
2632 if (c >= 040 && c < 0177 | |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
2633 && (dp == 0 || XTYPE (DISP_CHAR_VECTOR (dp, c)) != Lisp_Vector)) |
277 | 2634 { |
2635 if (p1 >= start) | |
2636 *p1 = c; | |
2637 p1++; | |
2638 } | |
2639 else if (c == '\t') | |
2640 { | |
2641 do | |
2642 { | |
2643 if (p1 >= start && p1 < end) | |
2644 *p1 = SPACEGLYPH; | |
2645 p1++; | |
2646 } | |
2647 while ((p1 - start + hscroll - (hscroll > 0)) % tab_width); | |
2648 } | |
2065
32afcdd08efe
(copy_rope): Expect FROM to be a vector.
Richard M. Stallman <rms@gnu.org>
parents:
1992
diff
changeset
|
2649 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector) |
2766
aa7b6f6aa20a
* xdisp.c (copy_rope, copy_part_of_rope): Add face argument.
Jim Blandy <jimb@redhat.com>
parents:
2754
diff
changeset
|
2650 p1 = copy_rope (p1, start, DISP_CHAR_VECTOR (dp, c), 0); |
1527
00109911b040
* xdisp.c (redisplay): Use ! EQ to compare the old and new arrow
Jim Blandy <jimb@redhat.com>
parents:
1446
diff
changeset
|
2651 else if (c < 0200 && ! NILP (buffer_defaults.ctl_arrow)) |
277 | 2652 { |
2653 if (p1 >= start) | |
2654 *p1 = (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int | |
2655 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'); | |
2656 p1++; | |
368 | 2657 if (p1 >= start && p1 < end) |
277 | 2658 *p1 = c ^ 0100; |
2659 p1++; | |
2660 } | |
2661 else | |
2662 { | |
2663 if (p1 >= start) | |
2664 *p1 = (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int | |
2665 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'); | |
2666 p1++; | |
368 | 2667 if (p1 >= start && p1 < end) |
277 | 2668 *p1 = (c >> 6) + '0'; |
2669 p1++; | |
368 | 2670 if (p1 >= start && p1 < end) |
277 | 2671 *p1 = (7 & (c >> 3)) + '0'; |
2672 p1++; | |
368 | 2673 if (p1 >= start && p1 < end) |
277 | 2674 *p1 = (7 & c) + '0'; |
2675 p1++; | |
2676 } | |
2677 } | |
2678 | |
2679 if (c) | |
2680 { | |
2681 p1 = end; | |
2682 if (truncate) *p1++ = truncate; | |
2683 } | |
2684 else if (mincol >= 0) | |
2685 { | |
2686 end = desired_glyphs->glyphs[vpos] + mincol; | |
2687 while (p1 < end) | |
2688 *p1++ = SPACEGLYPH; | |
2689 } | |
2690 | |
2691 { | |
2692 register int len = p1 - desired_glyphs->glyphs[vpos]; | |
2693 | |
2694 if (len > desired_glyphs->used[vpos]) | |
2695 desired_glyphs->used[vpos] = len; | |
2696 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0; | |
2697 | |
2698 return len; | |
2699 } | |
2700 } | |
2701 | |
2702 void | |
2703 syms_of_xdisp () | |
2704 { | |
2705 staticpro (&last_arrow_position); | |
2706 staticpro (&last_arrow_string); | |
2707 last_arrow_position = Qnil; | |
2708 last_arrow_string = Qnil; | |
2709 | |
2710 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string, | |
782
a6d00bdb2b60
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
781
diff
changeset
|
2711 "String (or mode line construct) included (normally) in `mode-line-format'."); |
277 | 2712 Vglobal_mode_string = Qnil; |
2713 | |
2714 DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position, | |
2715 "Marker for where to display an arrow on top of the buffer text.\n\ | |
2716 This must be the beginning of a line in order to work.\n\ | |
2717 See also `overlay-arrow-string'."); | |
2718 Voverlay_arrow_position = Qnil; | |
2719 | |
2720 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string, | |
2721 "String to display as an arrow. See also `overlay-arrow-position'."); | |
2722 Voverlay_arrow_string = Qnil; | |
2723 | |
2724 DEFVAR_INT ("scroll-step", &scroll_step, | |
2725 "*The number of lines to try scrolling a window by when point moves out.\n\ | |
769 | 2726 If that fails to bring point back on frame, point is centered instead.\n\ |
2727 If this is zero, point is always centered after it moves off frame."); | |
277 | 2728 |
2729 DEFVAR_INT ("debug-end-pos", &debug_end_pos, "Don't ask"); | |
2730 | |
2731 DEFVAR_BOOL ("truncate-partial-width-windows", | |
2732 &truncate_partial_width_windows, | |
769 | 2733 "*Non-nil means truncate lines in all windows less than full frame wide."); |
277 | 2734 truncate_partial_width_windows = 1; |
2735 | |
2736 DEFVAR_BOOL ("mode-line-inverse-video", &mode_line_inverse_video, | |
2737 "*Non-nil means use inverse video for the mode line."); | |
2738 mode_line_inverse_video = 1; | |
2303
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2739 |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2740 DEFVAR_INT ("line-number-display-limit", &line_number_display_limit, |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2741 "*Maximum buffer size for which line number should be displayed."); |
00e3cc81c1be
(decode_mode_spec): Handle `%l'.
Richard M. Stallman <rms@gnu.org>
parents:
2252
diff
changeset
|
2742 line_number_display_limit = 1000000; |
277 | 2743 } |
2744 | |
2745 /* initialize the window system */ | |
2746 init_xdisp () | |
2747 { | |
2748 Lisp_Object root_window; | |
2749 #ifndef COMPILER_REGISTER_BUG | |
2750 register | |
2751 #endif /* COMPILER_REGISTER_BUG */ | |
2752 struct window *mini_w; | |
2753 | |
2754 this_line_bufpos = 0; | |
2755 | |
2756 mini_w = XWINDOW (minibuf_window); | |
1017
d42877206c0a
* xdisp.c (display_mode_line): Use x_implicitly_set_name here.
Jim Blandy <jimb@redhat.com>
parents:
973
diff
changeset
|
2757 root_window = FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (mini_w))); |
277 | 2758 |
2759 echo_area_glyphs = 0; | |
2760 previous_echo_glyphs = 0; | |
2761 | |
2762 if (!noninteractive) | |
2763 { | |
769 | 2764 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (root_window))); |
277 | 2765 XFASTINT (XWINDOW (root_window)->top) = 0; |
769 | 2766 set_window_height (root_window, FRAME_HEIGHT (f) - 1, 0); |
2767 XFASTINT (mini_w->top) = FRAME_HEIGHT (f) - 1; | |
277 | 2768 set_window_height (minibuf_window, 1, 0); |
2769 | |
769 | 2770 XFASTINT (XWINDOW (root_window)->width) = FRAME_WIDTH (f); |
2771 XFASTINT (mini_w->width) = FRAME_WIDTH (f); | |
277 | 2772 } |
2773 } |