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