Mercurial > emacs
annotate src/dispnew.c @ 2318:50737ca2fd45
Decide automatically whether to use COFF or ELF.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 22 Mar 1993 19:50:35 +0000 |
| parents | 4759343bbaad |
| children | a302de11debf |
| rev | line source |
|---|---|
| 314 | 1 /* Updating of data structures for redisplay. |
|
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
2 Copyright (C) 1985, 1986, 1987, 1988, 1990, |
|
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
3 1992, 1993 Free Software Foundation, Inc. |
| 314 | 4 |
| 5 This file is part of GNU Emacs. | |
| 6 | |
| 7 GNU Emacs is free software; you can redistribute it and/or modify | |
| 8 it under the terms of the GNU General Public License as published by | |
|
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
| 314 | 10 any later version. |
| 11 | |
| 12 GNU Emacs is distributed in the hope that it will be useful, | |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 GNU General Public License for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
| 18 along with GNU Emacs; see the file COPYING. If not, write to | |
| 19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
| 20 | |
| 21 | |
| 22 #include <signal.h> | |
| 23 | |
| 24 #include "config.h" | |
| 25 #include <stdio.h> | |
| 26 #include <ctype.h> | |
| 27 | |
| 28 #include "termchar.h" | |
| 29 #include "termopts.h" | |
| 2198 | 30 #include "termhooks.h" |
| 314 | 31 #include "cm.h" |
| 32 #include "lisp.h" | |
| 33 #include "dispextern.h" | |
| 34 #include "buffer.h" | |
| 764 | 35 #include "frame.h" |
| 314 | 36 #include "window.h" |
| 37 #include "commands.h" | |
| 38 #include "disptab.h" | |
| 39 #include "indent.h" | |
| 40 | |
|
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
41 #include "systty.h" |
| 554 | 42 #include "systime.h" |
| 43 | |
| 314 | 44 #ifdef HAVE_X_WINDOWS |
| 45 #include "xterm.h" | |
| 46 #endif /* HAVE_X_WINDOWS */ | |
| 47 | |
| 48 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
| 49 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
| 50 | |
| 51 #ifndef PENDING_OUTPUT_COUNT | |
| 52 /* Get number of chars of output now in the buffer of a stdio stream. | |
| 53 This ought to be built in in stdio, but it isn't. | |
| 54 Some s- files override this because their stdio internals differ. */ | |
| 55 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base) | |
| 56 #endif | |
| 57 | |
| 554 | 58 /* Nonzero upon entry to redisplay means do not assume anything about |
| 764 | 59 current contents of actual terminal frame; clear and redraw it. */ |
| 314 | 60 |
| 764 | 61 int frame_garbaged; |
| 314 | 62 |
| 63 /* Nonzero means last display completed. Zero means it was preempted. */ | |
| 64 | |
| 65 int display_completed; | |
| 66 | |
| 67 /* Lisp variable visible-bell; enables use of screen-flash | |
| 68 instead of audible bell. */ | |
| 69 | |
| 70 int visible_bell; | |
| 71 | |
| 764 | 72 /* Invert the color of the whole frame, at a low level. */ |
| 314 | 73 |
| 74 int inverse_video; | |
| 75 | |
| 76 /* Line speed of the terminal. */ | |
| 77 | |
| 78 int baud_rate; | |
| 79 | |
| 80 /* nil or a symbol naming the window system under which emacs is | |
| 81 running ('x is the only current possibility). */ | |
| 82 | |
| 83 Lisp_Object Vwindow_system; | |
| 84 | |
| 85 /* Version number of X windows: 10, 11 or nil. */ | |
| 86 Lisp_Object Vwindow_system_version; | |
| 87 | |
| 88 /* Vector of glyph definitions. Indexed by glyph number, | |
| 89 the contents are a string which is how to output the glyph. | |
| 90 | |
| 91 If Vglyph_table is nil, a glyph is output by using its low 8 bits | |
| 92 as a character code. */ | |
| 93 | |
| 94 Lisp_Object Vglyph_table; | |
| 95 | |
| 96 /* Display table to use for vectors that don't specify their own. */ | |
| 97 | |
| 98 Lisp_Object Vstandard_display_table; | |
| 99 | |
| 100 /* Nonzero means reading single-character input with prompt | |
| 708 | 101 so put cursor on minibuffer after the prompt. |
| 102 positive means at end of text in echo area; | |
| 103 negative means at beginning of line. */ | |
| 314 | 104 int cursor_in_echo_area; |
| 105 | |
| 764 | 106 /* The currently selected frame. |
| 107 In a single-frame version, this variable always remains 0. */ | |
| 314 | 108 |
| 764 | 109 FRAME_PTR selected_frame; |
| 314 | 110 |
| 764 | 111 /* A frame which is not just a minibuffer, or 0 if there are no such |
| 112 frames. This is usually the most recent such frame that was | |
| 113 selected. In a single-frame version, this variable always remains 0. */ | |
| 114 FRAME_PTR last_nonminibuf_frame; | |
| 732 | 115 |
| 764 | 116 /* In a single-frame version, the information that would otherwise |
|
986
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
117 exist inside frame objects lives in the following structure instead. |
|
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
118 |
|
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
119 NOTE: the_only_frame is not checked for garbage collection; don't |
|
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
120 store collectable objects in any of its fields! |
|
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
121 |
|
83605f96f58e
* dispnew.c (the_only_frame): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
960
diff
changeset
|
122 You're not/The only frame in town/... */ |
| 314 | 123 |
| 764 | 124 #ifndef MULTI_FRAME |
| 125 struct frame the_only_frame; | |
| 732 | 126 #endif |
| 314 | 127 |
| 128 /* This is a vector, made larger whenever it isn't large enough, | |
| 764 | 129 which is used inside `update_frame' to hold the old contents |
| 130 of the FRAME_PHYS_LINES of the frame being updated. */ | |
| 131 struct frame_glyphs **ophys_lines; | |
| 314 | 132 /* Length of vector currently allocated. */ |
| 133 int ophys_lines_length; | |
| 134 | |
| 135 FILE *termscript; /* Stdio stream being used for copy of all output. */ | |
| 136 | |
| 137 struct cm Wcm; /* Structure for info on cursor positioning */ | |
| 138 | |
| 139 extern short ospeed; /* Output speed (from sg_ospeed) */ | |
| 140 | |
| 141 int delayed_size_change; /* 1 means SIGWINCH happened when not safe. */ | |
| 142 | |
| 764 | 143 #ifdef MULTI_FRAME |
| 314 | 144 |
| 764 | 145 DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, |
| 146 "Clear frame FRAME and output again what is supposed to appear on it.") | |
| 147 (frame) | |
| 148 Lisp_Object frame; | |
| 314 | 149 { |
| 764 | 150 FRAME_PTR f; |
| 314 | 151 |
| 764 | 152 CHECK_LIVE_FRAME (frame, 0); |
| 153 f = XFRAME (frame); | |
| 154 update_begin (f); | |
| 314 | 155 /* set_terminal_modes (); */ |
| 764 | 156 clear_frame (); |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
157 clear_frame_records (f); |
| 764 | 158 update_end (f); |
| 314 | 159 fflush (stdout); |
| 160 windows_or_buffers_changed++; | |
| 161 /* Mark all windows as INaccurate, | |
| 162 so that every window will have its redisplay done. */ | |
| 764 | 163 mark_window_display_accurate (FRAME_ROOT_WINDOW (f), 0); |
| 164 f->garbaged = 0; | |
| 314 | 165 return Qnil; |
| 166 } | |
| 167 | |
| 764 | 168 redraw_frame (f) |
| 169 FRAME_PTR f; | |
| 314 | 170 { |
| 764 | 171 Lisp_Object frame; |
| 172 XSET (frame, Lisp_Frame, f); | |
| 173 Fredraw_frame (frame); | |
| 314 | 174 } |
| 175 | |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
176 #else |
| 314 | 177 |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
178 DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, "", |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
179 "Clear frame FRAME and output again what is supposed to appear on it.") |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
180 (frame) |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
181 Lisp_Object frame; |
| 314 | 182 { |
| 183 update_begin (0); | |
| 184 set_terminal_modes (); | |
| 764 | 185 clear_frame (); |
| 314 | 186 update_end (0); |
| 187 fflush (stdout); | |
| 764 | 188 clear_frame_records (0); |
| 314 | 189 windows_or_buffers_changed++; |
| 190 /* Mark all windows as INaccurate, | |
| 191 so that every window will have its redisplay done. */ | |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
192 mark_window_display_accurate (FRAME_ROOT_WINDOW (0), 0); |
| 314 | 193 return Qnil; |
| 194 } | |
| 195 | |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
196 #endif |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
197 |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
198 DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "", |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
199 "Clear and redisplay all visible frames.") |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
200 () |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
201 { |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
202 Lisp_Object tail, frame; |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
203 |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
204 FOR_EACH_FRAME (tail, frame) |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
205 /* If we simply redrew all visible frames, whether or not they |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
206 were garbaged, then this would make all frames clear and |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
207 nredraw whenever a new frame is created or an existing frame |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
208 is de-iconified; those events set the global frame_garbaged |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
209 flag, to which redisplay responds by calling this function. |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
210 |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
211 This used to redraw all visible frames; the only advantage of |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
212 that approach is that if a frame changes from invisible to |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
213 visible without setting its garbaged flag, it still gets |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
214 redisplayed. But that should never happen; since invisible |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
215 frames are not updated, they should always be marked as |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
216 garbaged when they become visible again. If that doesn't |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
217 happen, it's a bug in the visibility code, not a bug here. */ |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
218 if (FRAME_VISIBLE_P (XFRAME (frame)) |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
219 && FRAME_GARBAGED_P (XFRAME (frame))) |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
220 Fredraw_frame (frame); |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
221 |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
222 return Qnil; |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
223 } |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
224 |
| 314 | 225 |
| 764 | 226 static struct frame_glyphs * |
| 227 make_frame_glyphs (frame, empty) | |
| 228 register FRAME_PTR frame; | |
| 314 | 229 int empty; |
| 230 { | |
| 231 register int i; | |
| 764 | 232 register width = FRAME_WIDTH (frame); |
| 233 register height = FRAME_HEIGHT (frame); | |
| 234 register struct frame_glyphs *new = | |
| 235 (struct frame_glyphs *) xmalloc (sizeof (struct frame_glyphs)); | |
| 314 | 236 |
| 764 | 237 SET_GLYPHS_FRAME (new, frame); |
| 314 | 238 new->height = height; |
| 239 new->width = width; | |
| 240 new->used = (int *) xmalloc (height * sizeof (int)); | |
| 241 new->glyphs = (GLYPH **) xmalloc (height * sizeof (GLYPH *)); | |
| 242 new->highlight = (char *) xmalloc (height * sizeof (char)); | |
| 243 new->enable = (char *) xmalloc (height * sizeof (char)); | |
| 244 bzero (new->enable, height * sizeof (char)); | |
| 245 new->bufp = (int *) xmalloc (height * sizeof (int)); | |
| 246 | |
| 247 #ifdef HAVE_X_WINDOWS | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
248 if (FRAME_X_P (frame)) |
| 314 | 249 { |
| 250 new->top_left_x = (short *) xmalloc (height * sizeof (short)); | |
| 251 new->top_left_y = (short *) xmalloc (height * sizeof (short)); | |
| 252 new->pix_width = (short *) xmalloc (height * sizeof (short)); | |
| 253 new->pix_height = (short *) xmalloc (height * sizeof (short)); | |
|
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
254 new->max_ascent = (short *) xmalloc (height * sizeof (short)); |
| 314 | 255 } |
| 256 #endif | |
| 257 | |
| 258 if (empty) | |
| 259 { | |
| 260 /* Make the buffer used by decode_mode_spec. This buffer is also | |
| 764 | 261 used as temporary storage when updating the frame. See scroll.c. */ |
| 314 | 262 unsigned int total_glyphs = (width + 2) * sizeof (GLYPH); |
| 263 | |
| 264 new->total_contents = (GLYPH *) xmalloc (total_glyphs); | |
| 265 bzero (new->total_contents, total_glyphs); | |
| 266 } | |
| 267 else | |
| 268 { | |
| 269 unsigned int total_glyphs = height * (width + 2) * sizeof (GLYPH); | |
| 270 | |
| 271 new->total_contents = (GLYPH *) xmalloc (total_glyphs); | |
| 272 bzero (new->total_contents, total_glyphs); | |
| 273 for (i = 0; i < height; i++) | |
| 274 new->glyphs[i] = new->total_contents + i * (width + 2) + 1; | |
| 275 } | |
| 276 | |
| 277 return new; | |
| 278 } | |
| 279 | |
| 280 static void | |
| 764 | 281 free_frame_glyphs (frame, glyphs) |
| 282 FRAME_PTR frame; | |
| 283 struct frame_glyphs *glyphs; | |
| 314 | 284 { |
| 285 if (glyphs->total_contents) | |
| 286 free (glyphs->total_contents); | |
| 287 | |
| 288 free (glyphs->used); | |
| 289 free (glyphs->glyphs); | |
| 290 free (glyphs->highlight); | |
| 291 free (glyphs->enable); | |
| 292 free (glyphs->bufp); | |
| 293 | |
| 294 #ifdef HAVE_X_WINDOWS | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
295 if (FRAME_X_P (frame)) |
| 314 | 296 { |
| 297 free (glyphs->top_left_x); | |
| 298 free (glyphs->top_left_y); | |
| 299 free (glyphs->pix_width); | |
| 300 free (glyphs->pix_height); | |
|
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
301 free (glyphs->max_ascent); |
| 314 | 302 } |
| 303 #endif | |
| 304 | |
| 305 free (glyphs); | |
| 306 } | |
| 307 | |
| 308 static void | |
| 764 | 309 remake_frame_glyphs (frame) |
| 310 FRAME_PTR frame; | |
| 314 | 311 { |
| 764 | 312 if (FRAME_CURRENT_GLYPHS (frame)) |
| 313 free_frame_glyphs (frame, FRAME_CURRENT_GLYPHS (frame)); | |
| 314 if (FRAME_DESIRED_GLYPHS (frame)) | |
| 315 free_frame_glyphs (frame, FRAME_DESIRED_GLYPHS (frame)); | |
| 316 if (FRAME_TEMP_GLYPHS (frame)) | |
| 317 free_frame_glyphs (frame, FRAME_TEMP_GLYPHS (frame)); | |
| 314 | 318 |
| 764 | 319 if (FRAME_MESSAGE_BUF (frame)) |
|
1872
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
320 { |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
321 /* Reallocate the frame's message buffer; remember that |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
322 echo_area_glyphs may be pointing here. */ |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
323 char *old_message_buf = FRAME_MESSAGE_BUF (frame); |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
324 |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
325 FRAME_MESSAGE_BUF (frame) |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
326 = (char *) xrealloc (FRAME_MESSAGE_BUF (frame), |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
327 FRAME_WIDTH (frame) + 1); |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
328 |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
329 if (echo_area_glyphs == old_message_buf) |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
330 echo_area_glyphs = FRAME_MESSAGE_BUF (frame); |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
331 if (previous_echo_glyphs == old_message_buf) |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
332 previous_echo_glyphs = FRAME_MESSAGE_BUF (frame); |
|
ad692b76edf4
* dispnew.c (remake_frame_glyphs): When re-allocating the frame's
Jim Blandy <jimb@redhat.com>
parents:
1849
diff
changeset
|
333 } |
| 314 | 334 else |
| 764 | 335 FRAME_MESSAGE_BUF (frame) |
| 336 = (char *) xmalloc (FRAME_WIDTH (frame) + 1); | |
| 314 | 337 |
| 764 | 338 FRAME_CURRENT_GLYPHS (frame) = make_frame_glyphs (frame, 0); |
| 339 FRAME_DESIRED_GLYPHS (frame) = make_frame_glyphs (frame, 0); | |
| 340 FRAME_TEMP_GLYPHS (frame) = make_frame_glyphs (frame, 1); | |
| 341 SET_FRAME_GARBAGED (frame); | |
| 314 | 342 } |
| 343 | |
| 764 | 344 /* Return the hash code of contents of line VPOS in frame-matrix M. */ |
| 314 | 345 |
| 346 static int | |
| 347 line_hash_code (m, vpos) | |
| 764 | 348 register struct frame_glyphs *m; |
| 314 | 349 int vpos; |
| 350 { | |
| 351 register GLYPH *body, *end; | |
| 352 register int h = 0; | |
| 353 | |
| 354 if (!m->enable[vpos]) | |
| 355 return 0; | |
| 356 | |
|
1495
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
357 /* Give all highlighted lines the same hash code |
| 314 | 358 so as to encourage scrolling to leave them in place. */ |
| 359 if (m->highlight[vpos]) | |
| 360 return -1; | |
| 361 | |
| 362 body = m->glyphs[vpos]; | |
| 363 | |
| 364 if (must_write_spaces) | |
| 365 while (1) | |
| 366 { | |
| 367 GLYPH g = *body++; | |
| 368 | |
| 369 if (g == 0) | |
| 370 break; | |
| 371 h = (((h << 4) + (h >> 24)) & 0x0fffffff) + g - SPACEGLYPH; | |
| 372 } | |
| 373 else | |
| 374 while (1) | |
| 375 { | |
| 376 GLYPH g = *body++; | |
| 377 | |
| 378 if (g == 0) | |
| 379 break; | |
| 380 h = (((h << 4) + (h >> 24)) & 0x0fffffff) + g; | |
| 381 } | |
| 382 | |
| 383 if (h) | |
| 384 return h; | |
| 385 return 1; | |
| 386 } | |
| 387 | |
| 388 /* Return number of characters in line in M at vpos VPOS, | |
| 389 except don't count leading and trailing spaces | |
| 390 unless the terminal requires those to be explicitly output. */ | |
| 391 | |
| 392 static unsigned int | |
| 393 line_draw_cost (m, vpos) | |
| 764 | 394 struct frame_glyphs *m; |
| 314 | 395 int vpos; |
| 396 { | |
| 397 register GLYPH *beg = m->glyphs[vpos]; | |
| 398 register GLYPH *end = m->glyphs[vpos] + m->used[vpos]; | |
| 399 register int i; | |
| 400 register int tlen = GLYPH_TABLE_LENGTH; | |
| 401 register Lisp_Object *tbase = GLYPH_TABLE_BASE; | |
| 402 | |
| 403 /* Ignore trailing and leading spaces if we can. */ | |
| 404 if (!must_write_spaces) | |
| 405 { | |
| 406 while ((end != beg) && (*end == SPACEGLYPH)) | |
| 407 --end; | |
| 408 if (end == beg) | |
| 409 return (0); /* All blank line. */ | |
| 410 | |
| 411 while (*beg == SPACEGLYPH) | |
| 412 ++beg; | |
| 413 } | |
| 414 | |
| 415 /* If we don't have a glyph-table, each glyph is one character, | |
| 416 so return the number of glyphs. */ | |
| 417 if (tbase == 0) | |
| 418 return end - beg; | |
| 419 | |
| 420 /* Otherwise, scan the glyphs and accumulate their total size in I. */ | |
| 421 i = 0; | |
| 422 while ((beg <= end) && *beg) | |
| 423 { | |
| 424 register GLYPH g = *beg++; | |
| 425 | |
| 426 if (GLYPH_SIMPLE_P (tbase, tlen, g)) | |
| 427 i += 1; | |
| 428 else | |
| 429 i += GLYPH_LENGTH (tbase, g); | |
| 430 } | |
| 431 return i; | |
| 432 } | |
| 433 | |
| 434 /* The functions on this page are the interface from xdisp.c to redisplay. | |
| 435 | |
| 436 The only other interface into redisplay is through setting | |
| 764 | 437 FRAME_CURSOR_X (frame) and FRAME_CURSOR_Y (frame) |
| 438 and SET_FRAME_GARBAGED (frame). */ | |
| 314 | 439 |
| 440 /* cancel_line eliminates any request to display a line at position `vpos' */ | |
| 441 | |
| 764 | 442 cancel_line (vpos, frame) |
| 314 | 443 int vpos; |
| 764 | 444 register FRAME_PTR frame; |
| 314 | 445 { |
| 764 | 446 FRAME_DESIRED_GLYPHS (frame)->enable[vpos] = 0; |
| 314 | 447 } |
| 448 | |
| 764 | 449 clear_frame_records (frame) |
| 450 register FRAME_PTR frame; | |
| 314 | 451 { |
| 764 | 452 bzero (FRAME_CURRENT_GLYPHS (frame)->enable, FRAME_HEIGHT (frame)); |
| 314 | 453 } |
| 454 | |
| 455 /* Prepare to display on line VPOS starting at HPOS within it. */ | |
| 456 | |
| 457 void | |
| 764 | 458 get_display_line (frame, vpos, hpos) |
| 459 register FRAME_PTR frame; | |
| 314 | 460 int vpos; |
| 461 register int hpos; | |
| 462 { | |
| 764 | 463 register struct frame_glyphs *glyphs; |
| 464 register struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (frame); | |
| 314 | 465 register GLYPH *p; |
| 466 | |
|
1192
5c380ec3cfc6
* dispnew.c (get_display_line): Don't abort if the frame is
Jim Blandy <jimb@redhat.com>
parents:
1042
diff
changeset
|
467 if (vpos < 0) |
| 314 | 468 abort (); |
| 469 | |
| 470 if ((desired_glyphs->enable[vpos]) && desired_glyphs->used[vpos] > hpos) | |
| 471 abort (); | |
| 472 | |
| 473 if (! desired_glyphs->enable[vpos]) | |
| 474 { | |
| 475 desired_glyphs->used[vpos] = 0; | |
| 476 desired_glyphs->highlight[vpos] = 0; | |
| 477 desired_glyphs->enable[vpos] = 1; | |
| 478 } | |
| 479 | |
| 480 if (hpos > desired_glyphs->used[vpos]) | |
| 481 { | |
| 482 GLYPH *g = desired_glyphs->glyphs[vpos] + desired_glyphs->used[vpos]; | |
| 483 GLYPH *end = desired_glyphs->glyphs[vpos] + hpos; | |
| 484 | |
| 485 desired_glyphs->used[vpos] = hpos; | |
| 486 while (g != end) | |
| 487 *g++ = SPACEGLYPH; | |
| 488 } | |
| 489 } | |
| 490 | |
| 491 /* Like bcopy except never gets confused by overlap. */ | |
| 492 | |
| 493 void | |
| 494 safe_bcopy (from, to, size) | |
| 495 char *from, *to; | |
| 496 int size; | |
| 497 { | |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
498 if (size <= 0 || from == to) |
| 314 | 499 return; |
| 500 | |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
501 /* If the source and destination don't overlap, then bcopy can |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
502 handle it. If they do overlap, but the destination is lower in |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
503 memory than the source, we'll assume bcopy can handle that. */ |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
504 if (to < from || from + size <= to) |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
505 bcopy (from, to, size); |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
506 |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
507 /* Otherwise, we'll copy from the end. */ |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
508 else |
| 314 | 509 { |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
510 register char *endf = from + size; |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
511 register char *endt = to + size; |
| 314 | 512 |
| 513 /* If TO - FROM is large, then we should break the copy into | |
| 514 nonoverlapping chunks of TO - FROM bytes each. However, if | |
| 515 TO - FROM is small, then the bcopy function call overhead | |
| 516 makes this not worth it. The crossover point could be about | |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
517 anywhere. Since I don't think the obvious copy loop is too |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
518 bad, I'm trying to err in its favor. */ |
| 314 | 519 if (to - from < 64) |
| 520 { | |
| 521 do | |
| 522 *--endt = *--endf; | |
| 523 while (endf != from); | |
| 524 } | |
| 525 else | |
| 526 { | |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
527 for (;;) |
| 314 | 528 { |
| 529 endt -= (to - from); | |
| 530 endf -= (to - from); | |
| 531 | |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
532 if (endt < to) |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
533 break; |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
534 |
| 314 | 535 bcopy (endf, endt, to - from); |
| 536 } | |
|
1588
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
537 |
|
732a88db381f
* dispnew.c [not MULTI_FRAME] (Fredraw_display): Pass the correct
Jim Blandy <jimb@redhat.com>
parents:
1495
diff
changeset
|
538 /* If SIZE wasn't a multiple of TO - FROM, there will be a |
| 314 | 539 little left over. The amount left over is |
| 540 (endt + (to - from)) - to, which is endt - from. */ | |
| 541 bcopy (from, to, endt - from); | |
| 542 } | |
| 543 } | |
| 544 } | |
| 545 | |
| 352 | 546 /* Rotate a vector of SIZE bytes right, by DISTANCE bytes. |
| 314 | 547 DISTANCE may be negative. */ |
| 548 | |
| 549 static void | |
| 550 rotate_vector (vector, size, distance) | |
| 551 char *vector; | |
| 552 int size; | |
| 553 int distance; | |
| 554 { | |
| 555 char *temp = (char *) alloca (size); | |
| 556 | |
| 557 if (distance < 0) | |
| 558 distance += size; | |
| 559 | |
| 560 bcopy (vector, temp + distance, size - distance); | |
| 561 bcopy (vector + size - distance, temp, distance); | |
| 562 bcopy (temp, vector, size); | |
| 563 } | |
| 564 | |
| 565 /* Scroll lines from vpos FROM up to but not including vpos END | |
| 566 down by AMOUNT lines (AMOUNT may be negative). | |
| 567 Returns nonzero if done, zero if terminal cannot scroll them. */ | |
| 568 | |
| 569 int | |
| 764 | 570 scroll_frame_lines (frame, from, end, amount) |
| 571 register FRAME_PTR frame; | |
| 314 | 572 int from, end, amount; |
| 573 { | |
| 574 register int i; | |
| 764 | 575 register struct frame_glyphs *current_frame |
| 576 = FRAME_CURRENT_GLYPHS (frame); | |
| 314 | 577 |
| 578 if (!line_ins_del_ok) | |
| 579 return 0; | |
| 580 | |
| 581 if (amount == 0) | |
| 582 return 1; | |
| 583 | |
| 584 if (amount > 0) | |
| 585 { | |
| 764 | 586 update_begin (frame); |
| 314 | 587 set_terminal_window (end + amount); |
| 588 if (!scroll_region_ok) | |
| 589 ins_del_lines (end, -amount); | |
| 590 ins_del_lines (from, amount); | |
| 591 set_terminal_window (0); | |
| 592 | |
| 764 | 593 rotate_vector (current_frame->glyphs + from, |
| 314 | 594 sizeof (GLYPH *) * (end + amount - from), |
| 595 amount * sizeof (GLYPH *)); | |
| 596 | |
| 764 | 597 safe_bcopy (current_frame->used + from, |
| 598 current_frame->used + from + amount, | |
| 599 (end - from) * sizeof current_frame->used[0]); | |
| 314 | 600 |
| 764 | 601 safe_bcopy (current_frame->highlight + from, |
| 602 current_frame->highlight + from + amount, | |
| 603 (end - from) * sizeof current_frame->highlight[0]); | |
| 314 | 604 |
| 764 | 605 safe_bcopy (current_frame->enable + from, |
| 606 current_frame->enable + from + amount, | |
| 607 (end - from) * sizeof current_frame->enable[0]); | |
| 314 | 608 |
| 609 /* Mark the lines made empty by scrolling as enabled, empty and | |
| 610 normal video. */ | |
| 764 | 611 bzero (current_frame->used + from, |
| 612 amount * sizeof current_frame->used[0]); | |
| 613 bzero (current_frame->highlight + from, | |
| 614 amount * sizeof current_frame->highlight[0]); | |
| 314 | 615 for (i = from; i < from + amount; i++) |
| 616 { | |
| 764 | 617 current_frame->glyphs[i][0] = '\0'; |
| 618 current_frame->enable[i] = 1; | |
| 314 | 619 } |
| 620 | |
| 764 | 621 safe_bcopy (current_frame->bufp + from, |
| 622 current_frame->bufp + from + amount, | |
| 623 (end - from) * sizeof current_frame->bufp[0]); | |
| 314 | 624 |
| 625 #ifdef HAVE_X_WINDOWS | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
626 if (FRAME_X_P (frame)) |
| 314 | 627 { |
| 764 | 628 safe_bcopy (current_frame->top_left_x + from, |
| 629 current_frame->top_left_x + from + amount, | |
| 630 (end - from) * sizeof current_frame->top_left_x[0]); | |
| 314 | 631 |
| 764 | 632 safe_bcopy (current_frame->top_left_y + from, |
| 633 current_frame->top_left_y + from + amount, | |
| 634 (end - from) * sizeof current_frame->top_left_y[0]); | |
| 314 | 635 |
| 764 | 636 safe_bcopy (current_frame->pix_width + from, |
| 637 current_frame->pix_width + from + amount, | |
| 638 (end - from) * sizeof current_frame->pix_width[0]); | |
| 314 | 639 |
| 764 | 640 safe_bcopy (current_frame->pix_height + from, |
| 641 current_frame->pix_height + from + amount, | |
| 642 (end - from) * sizeof current_frame->pix_height[0]); | |
|
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
643 |
|
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
644 safe_bcopy (current_frame->max_ascent + from, |
|
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
645 current_frame->max_ascent + from + amount, |
|
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
646 (end - from) * sizeof current_frame->max_ascent[0]); |
| 314 | 647 } |
| 648 #endif /* HAVE_X_WINDOWS */ | |
| 649 | |
| 764 | 650 update_end (frame); |
| 314 | 651 } |
| 652 if (amount < 0) | |
| 653 { | |
| 764 | 654 update_begin (frame); |
| 314 | 655 set_terminal_window (end); |
| 656 ins_del_lines (from + amount, amount); | |
| 657 if (!scroll_region_ok) | |
| 658 ins_del_lines (end + amount, -amount); | |
| 659 set_terminal_window (0); | |
| 660 | |
| 764 | 661 rotate_vector (current_frame->glyphs + from + amount, |
| 314 | 662 sizeof (GLYPH *) * (end - from - amount), |
| 663 amount * sizeof (GLYPH *)); | |
| 664 | |
| 764 | 665 safe_bcopy (current_frame->used + from, |
| 666 current_frame->used + from + amount, | |
| 667 (end - from) * sizeof current_frame->used[0]); | |
| 314 | 668 |
| 764 | 669 safe_bcopy (current_frame->highlight + from, |
| 670 current_frame->highlight + from + amount, | |
| 671 (end - from) * sizeof current_frame->highlight[0]); | |
| 314 | 672 |
| 764 | 673 safe_bcopy (current_frame->enable + from, |
| 674 current_frame->enable + from + amount, | |
| 675 (end - from) * sizeof current_frame->enable[0]); | |
| 314 | 676 |
| 677 /* Mark the lines made empty by scrolling as enabled, empty and | |
| 678 normal video. */ | |
| 764 | 679 bzero (current_frame->used + end + amount, |
| 680 - amount * sizeof current_frame->used[0]); | |
| 681 bzero (current_frame->highlight + end + amount, | |
| 682 - amount * sizeof current_frame->highlight[0]); | |
| 314 | 683 for (i = end + amount; i < end; i++) |
| 684 { | |
| 764 | 685 current_frame->glyphs[i][0] = '\0'; |
| 686 current_frame->enable[i] = 1; | |
| 314 | 687 } |
| 688 | |
| 764 | 689 safe_bcopy (current_frame->bufp + from, |
| 690 current_frame->bufp + from + amount, | |
| 691 (end - from) * sizeof current_frame->bufp[0]); | |
| 314 | 692 |
| 693 #ifdef HAVE_X_WINDOWS | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
694 if (FRAME_X_P (frame)) |
| 314 | 695 { |
| 764 | 696 safe_bcopy (current_frame->top_left_x + from, |
| 697 current_frame->top_left_x + from + amount, | |
| 698 (end - from) * sizeof current_frame->top_left_x[0]); | |
| 314 | 699 |
| 764 | 700 safe_bcopy (current_frame->top_left_y + from, |
| 701 current_frame->top_left_y + from + amount, | |
| 702 (end - from) * sizeof current_frame->top_left_y[0]); | |
| 314 | 703 |
| 764 | 704 safe_bcopy (current_frame->pix_width + from, |
| 705 current_frame->pix_width + from + amount, | |
| 706 (end - from) * sizeof current_frame->pix_width[0]); | |
| 314 | 707 |
| 764 | 708 safe_bcopy (current_frame->pix_height + from, |
| 709 current_frame->pix_height + from + amount, | |
| 710 (end - from) * sizeof current_frame->pix_height[0]); | |
|
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
711 |
|
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
712 safe_bcopy (current_frame->max_ascent + from, |
|
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
713 current_frame->max_ascent + from + amount, |
|
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
714 (end - from) * sizeof current_frame->max_ascent[0]); |
| 314 | 715 } |
| 716 #endif /* HAVE_X_WINDOWS */ | |
| 717 | |
| 764 | 718 update_end (frame); |
| 314 | 719 } |
| 720 return 1; | |
| 721 } | |
| 722 | |
| 764 | 723 /* After updating a window W that isn't the full frame wide, |
| 314 | 724 copy all the columns that W does not occupy |
| 764 | 725 into the FRAME_DESIRED_GLYPHS (frame) from the FRAME_PHYS_GLYPHS (frame) |
| 726 so that update_frame will not change those columns. */ | |
| 314 | 727 |
| 728 preserve_other_columns (w) | |
| 729 struct window *w; | |
| 730 { | |
| 731 register int vpos; | |
| 764 | 732 register struct frame_glyphs *current_frame, *desired_frame; |
| 733 register FRAME_PTR frame = XFRAME (w->frame); | |
| 314 | 734 int start = XFASTINT (w->left); |
| 735 int end = XFASTINT (w->left) + XFASTINT (w->width); | |
| 736 int bot = XFASTINT (w->top) + XFASTINT (w->height); | |
| 737 | |
| 764 | 738 current_frame = FRAME_CURRENT_GLYPHS (frame); |
| 739 desired_frame = FRAME_DESIRED_GLYPHS (frame); | |
| 314 | 740 |
| 741 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) | |
| 742 { | |
| 764 | 743 if (current_frame->enable[vpos] && desired_frame->enable[vpos]) |
| 314 | 744 { |
| 745 if (start > 0) | |
| 746 { | |
| 747 int len; | |
| 748 | |
| 764 | 749 bcopy (current_frame->glyphs[vpos], |
| 750 desired_frame->glyphs[vpos], start); | |
| 751 len = min (start, current_frame->used[vpos]); | |
| 752 if (desired_frame->used[vpos] < len) | |
| 753 desired_frame->used[vpos] = len; | |
| 314 | 754 } |
| 764 | 755 if (current_frame->used[vpos] > end |
| 756 && desired_frame->used[vpos] < current_frame->used[vpos]) | |
| 314 | 757 { |
| 764 | 758 while (desired_frame->used[vpos] < end) |
| 759 desired_frame->glyphs[vpos][desired_frame->used[vpos]++] | |
| 314 | 760 = SPACEGLYPH; |
| 764 | 761 bcopy (current_frame->glyphs[vpos] + end, |
| 762 desired_frame->glyphs[vpos] + end, | |
| 763 current_frame->used[vpos] - end); | |
| 764 desired_frame->used[vpos] = current_frame->used[vpos]; | |
| 314 | 765 } |
| 766 } | |
| 767 } | |
| 768 } | |
| 769 | |
| 770 #if 0 | |
| 771 | |
| 764 | 772 /* If window w does not need to be updated and isn't the full frame wide, |
| 314 | 773 copy all the columns that w does occupy |
| 764 | 774 into the FRAME_DESIRED_LINES (frame) from the FRAME_PHYS_LINES (frame) |
| 775 so that update_frame will not change those columns. | |
| 314 | 776 |
| 777 Have not been able to figure out how to use this correctly. */ | |
| 778 | |
| 779 preserve_my_columns (w) | |
| 780 struct window *w; | |
| 781 { | |
| 782 register int vpos, fin; | |
| 764 | 783 register struct frame_glyphs *l1, *l2; |
| 784 register FRAME_PTR frame = XFRAME (w->frame); | |
| 314 | 785 int start = XFASTINT (w->left); |
| 786 int end = XFASTINT (w->left) + XFASTINT (w->width); | |
| 787 int bot = XFASTINT (w->top) + XFASTINT (w->height); | |
| 788 | |
| 789 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) | |
| 790 { | |
| 764 | 791 if ((l1 = FRAME_DESIRED_GLYPHS (frame)->glyphs[vpos + 1]) |
| 792 && (l2 = FRAME_PHYS_GLYPHS (frame)->glyphs[vpos + 1])) | |
| 314 | 793 { |
| 794 if (l2->length > start && l1->length < l2->length) | |
| 795 { | |
| 796 fin = l2->length; | |
| 797 if (fin > end) fin = end; | |
| 798 while (l1->length < start) | |
| 799 l1->body[l1->length++] = ' '; | |
| 800 bcopy (l2->body + start, l1->body + start, fin - start); | |
| 801 l1->length = fin; | |
| 802 } | |
| 803 } | |
| 804 } | |
| 805 } | |
| 806 | |
| 807 #endif | |
| 808 | |
| 809 /* On discovering that the redisplay for a window was no good, | |
| 810 cancel the columns of that window, so that when the window is | |
| 811 displayed over again get_display_line will not complain. */ | |
| 812 | |
| 813 cancel_my_columns (w) | |
| 814 struct window *w; | |
| 815 { | |
| 816 register int vpos; | |
| 764 | 817 register struct frame_glyphs *desired_glyphs = |
| 818 FRAME_DESIRED_GLYPHS (XFRAME (w->frame)); | |
| 314 | 819 register int start = XFASTINT (w->left); |
| 820 register int bot = XFASTINT (w->top) + XFASTINT (w->height); | |
| 821 | |
| 822 for (vpos = XFASTINT (w->top); vpos < bot; vpos++) | |
| 823 if (desired_glyphs->enable[vpos] | |
| 824 && desired_glyphs->used[vpos] >= start) | |
| 825 desired_glyphs->used[vpos] = start; | |
| 826 } | |
| 827 | |
| 764 | 828 /* These functions try to perform directly and immediately on the frame |
| 314 | 829 the necessary output for one change in the buffer. |
| 830 They may return 0 meaning nothing was done if anything is difficult, | |
| 831 or 1 meaning the output was performed properly. | |
| 764 | 832 They assume that the frame was up to date before the buffer |
|
1495
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
833 change being displayed. They make various other assumptions too; |
| 314 | 834 see command_loop_1 where these are called. */ |
| 835 | |
| 836 int | |
| 837 direct_output_for_insert (g) | |
| 838 int g; | |
| 839 { | |
| 764 | 840 register FRAME_PTR frame = selected_frame; |
| 841 register struct frame_glyphs *current_frame | |
| 842 = FRAME_CURRENT_GLYPHS (frame); | |
| 314 | 843 |
| 844 #ifndef COMPILER_REGISTER_BUG | |
| 845 register | |
| 846 #endif /* COMPILER_REGISTER_BUG */ | |
| 847 struct window *w = XWINDOW (selected_window); | |
| 848 #ifndef COMPILER_REGISTER_BUG | |
| 849 register | |
| 850 #endif /* COMPILER_REGISTER_BUG */ | |
| 764 | 851 int hpos = FRAME_CURSOR_X (frame); |
| 314 | 852 #ifndef COMPILER_REGISTER_BUG |
| 853 register | |
| 854 #endif /* COMPILER_REGISTER_BUG */ | |
| 764 | 855 int vpos = FRAME_CURSOR_Y (frame); |
| 314 | 856 |
|
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
857 /* Give up if about to continue line. */ |
|
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
858 if (hpos >= XFASTINT (w->left) + window_internal_width (w) - 1 |
|
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
859 |
| 314 | 860 /* Avoid losing if cursor is in invisible text off left margin */ |
| 861 || (XINT (w->hscroll) && hpos == XFASTINT (w->left)) | |
| 862 | |
| 863 /* Give up if cursor outside window (in minibuf, probably) */ | |
|
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
864 || cursor_in_echo_area |
| 764 | 865 || FRAME_CURSOR_Y (frame) < XFASTINT (w->top) |
| 866 || FRAME_CURSOR_Y (frame) >= XFASTINT (w->top) + XFASTINT (w->height) | |
| 314 | 867 |
| 764 | 868 /* Give up if cursor not really at FRAME_CURSOR_X, FRAME_CURSOR_Y */ |
| 314 | 869 || !display_completed |
| 870 | |
| 871 /* Give up if buffer appears in two places. */ | |
| 872 || buffer_shared > 1 | |
| 873 | |
| 874 /* Give up if w is minibuffer and a message is being displayed there */ | |
| 875 || (MINI_WINDOW_P (w) && echo_area_glyphs)) | |
| 876 return 0; | |
| 877 | |
| 764 | 878 current_frame->glyphs[vpos][hpos] = g; |
| 314 | 879 unchanged_modified = MODIFF; |
| 880 beg_unchanged = GPT - BEG; | |
| 881 XFASTINT (w->last_point) = point; | |
| 882 XFASTINT (w->last_point_x) = hpos; | |
| 883 XFASTINT (w->last_modified) = MODIFF; | |
| 884 | |
| 885 reassert_line_highlight (0, vpos); | |
| 764 | 886 write_glyphs (¤t_frame->glyphs[vpos][hpos], 1); |
| 314 | 887 fflush (stdout); |
| 764 | 888 ++FRAME_CURSOR_X (frame); |
| 889 if (hpos == current_frame->used[vpos]) | |
| 314 | 890 { |
| 764 | 891 current_frame->used[vpos] = hpos + 1; |
| 892 current_frame->glyphs[vpos][hpos + 1] = 0; | |
| 314 | 893 } |
| 894 | |
| 895 return 1; | |
| 896 } | |
| 897 | |
| 898 int | |
| 899 direct_output_forward_char (n) | |
| 900 int n; | |
| 901 { | |
| 764 | 902 register FRAME_PTR frame = selected_frame; |
| 314 | 903 register struct window *w = XWINDOW (selected_window); |
| 904 | |
| 543 | 905 /* Avoid losing if cursor is in invisible text off left margin |
| 906 or about to go off either side of window. */ | |
| 764 | 907 if ((FRAME_CURSOR_X (frame) == XFASTINT (w->left) |
| 543 | 908 && (XINT (w->hscroll) || n < 0)) |
| 909 || (n > 0 | |
|
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
910 && (FRAME_CURSOR_X (frame) + 1 >= window_internal_width (w) - 1)) |
|
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
911 || cursor_in_echo_area) |
| 314 | 912 return 0; |
| 913 | |
| 764 | 914 FRAME_CURSOR_X (frame) += n; |
| 915 XFASTINT (w->last_point_x) = FRAME_CURSOR_X (frame); | |
| 314 | 916 XFASTINT (w->last_point) = point; |
| 764 | 917 cursor_to (FRAME_CURSOR_Y (frame), FRAME_CURSOR_X (frame)); |
| 314 | 918 fflush (stdout); |
| 919 return 1; | |
| 920 } | |
| 921 | |
| 922 static void update_line (); | |
| 923 | |
| 764 | 924 /* Update frame F based on the data in FRAME_DESIRED_GLYPHS. |
| 314 | 925 Value is nonzero if redisplay stopped due to pending input. |
| 926 FORCE nonzero means do not stop for pending input. */ | |
| 927 | |
| 928 int | |
| 764 | 929 update_frame (f, force, inhibit_hairy_id) |
| 930 FRAME_PTR f; | |
| 314 | 931 int force; |
| 932 int inhibit_hairy_id; | |
| 933 { | |
| 764 | 934 register struct frame_glyphs *current_frame = FRAME_CURRENT_GLYPHS (f); |
| 935 register struct frame_glyphs *desired_frame = FRAME_DESIRED_GLYPHS (f); | |
| 314 | 936 register int i; |
| 937 int pause; | |
| 938 int preempt_count = baud_rate / 2400 + 1; | |
| 939 extern input_pending; | |
| 940 #ifdef HAVE_X_WINDOWS | |
| 941 register int downto, leftmost; | |
| 942 #endif | |
| 943 | |
| 764 | 944 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
| 314 | 945 |
| 946 detect_input_pending (); | |
| 947 if (input_pending && !force) | |
| 948 { | |
| 949 pause = 1; | |
| 950 goto do_pause; | |
| 951 } | |
| 952 | |
| 764 | 953 update_begin (f); |
| 314 | 954 |
| 955 if (!line_ins_del_ok) | |
| 956 inhibit_hairy_id = 1; | |
| 957 | |
| 493 | 958 /* See if any of the desired lines are enabled; don't compute for |
| 959 i/d line if just want cursor motion. */ | |
| 764 | 960 for (i = 0; i < FRAME_HEIGHT (f); i++) |
| 961 if (desired_frame->enable[i]) | |
| 314 | 962 break; |
| 963 | |
| 964 /* Try doing i/d line, if not yet inhibited. */ | |
| 764 | 965 if (!inhibit_hairy_id && i < FRAME_HEIGHT (f)) |
| 966 force |= scrolling (f); | |
| 314 | 967 |
| 968 /* Update the individual lines as needed. Do bottom line first. */ | |
| 969 | |
| 764 | 970 if (desired_frame->enable[FRAME_HEIGHT (f) - 1]) |
| 971 update_line (f, FRAME_HEIGHT (f) - 1); | |
| 314 | 972 |
| 973 #ifdef HAVE_X_WINDOWS | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
974 if (FRAME_X_P (f)) |
| 314 | 975 { |
| 764 | 976 leftmost = downto = f->display.x->internal_border_width; |
| 977 if (desired_frame->enable[0]) | |
| 314 | 978 { |
| 764 | 979 current_frame->top_left_x[FRAME_HEIGHT (f) - 1] = leftmost; |
| 980 current_frame->top_left_y[FRAME_HEIGHT (f) - 1] | |
| 981 = PIXEL_HEIGHT (f) - f->display.x->internal_border_width | |
|
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
982 - current_frame->pix_height[FRAME_HEIGHT (f) - 1]; |
| 764 | 983 current_frame->top_left_x[0] = leftmost; |
| 984 current_frame->top_left_y[0] = downto; | |
| 314 | 985 } |
| 986 } | |
| 987 #endif /* HAVE_X_WINDOWS */ | |
| 988 | |
| 989 /* Now update the rest of the lines. */ | |
| 764 | 990 for (i = 0; i < FRAME_HEIGHT (f) - 1 && (force || !input_pending); i++) |
| 314 | 991 { |
| 764 | 992 if (desired_frame->enable[i]) |
| 314 | 993 { |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
994 if (FRAME_TERMCAP_P (f)) |
| 314 | 995 { |
| 996 /* Flush out every so many lines. | |
| 997 Also flush out if likely to have more than 1k buffered | |
| 998 otherwise. I'm told that some telnet connections get | |
| 999 really screwed by more than 1k output at once. */ | |
| 1000 int outq = PENDING_OUTPUT_COUNT (stdout); | |
| 1001 if (outq > 900 | |
| 1002 || (outq > 20 && ((i - 1) % preempt_count == 0))) | |
| 1003 { | |
| 1004 fflush (stdout); | |
| 1005 if (preempt_count == 1) | |
| 1006 { | |
| 554 | 1007 #ifdef EMACS_OUTQSIZE |
| 1008 if (EMACS_OUTQSIZE (0, &outq) < 0) | |
| 314 | 1009 /* Probably not a tty. Ignore the error and reset |
| 1010 * the outq count. */ | |
| 1011 outq = PENDING_OUTPUT_COUNT (stdout); | |
| 1012 #endif | |
| 1013 outq *= 10; | |
| 1014 sleep (outq / baud_rate); | |
| 1015 } | |
| 1016 } | |
| 1017 if ((i - 1) % preempt_count == 0) | |
| 1018 detect_input_pending (); | |
| 1019 } | |
| 1020 | |
| 764 | 1021 update_line (f, i); |
| 314 | 1022 #ifdef HAVE_X_WINDOWS |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1023 if (FRAME_X_P (f)) |
| 314 | 1024 { |
| 764 | 1025 current_frame->top_left_y[i] = downto; |
| 1026 current_frame->top_left_x[i] = leftmost; | |
| 314 | 1027 } |
| 1028 #endif /* HAVE_X_WINDOWS */ | |
| 1029 } | |
| 1030 | |
| 732 | 1031 #ifdef HAVE_X_WINDOWS |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1032 if (FRAME_X_P (f)) |
|
1407
0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
Joseph Arceneaux <jla@gnu.org>
parents:
1192
diff
changeset
|
1033 downto += current_frame->pix_height[i]; |
| 732 | 1034 #endif |
| 314 | 1035 } |
| 764 | 1036 pause = (i < FRAME_HEIGHT (f) - 1) ? i : 0; |
| 314 | 1037 |
| 1038 /* Now just clean up termcap drivers and set cursor, etc. */ | |
| 1039 if (!pause) | |
| 1040 { | |
|
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1041 if (cursor_in_echo_area |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1042 && FRAME_HAS_MINIBUF_P (f)) |
| 708 | 1043 { |
|
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1044 int top = XINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top); |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1045 int row, col; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1046 |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1047 if (cursor_in_echo_area < 0) |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1048 { |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1049 row = top; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1050 col = 0; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1051 } |
| 708 | 1052 else |
|
1042
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1053 { |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1054 /* If the minibuffer is several lines high, find the last |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1055 line that has any text on it. */ |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1056 row = FRAME_HEIGHT (f); |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1057 do |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1058 { |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1059 row--; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1060 if (current_frame->enable[row]) |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1061 col = current_frame->used[row]; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1062 else |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1063 col = 0; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1064 } |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1065 while (row > top && col == 0); |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1066 |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1067 if (col >= FRAME_WIDTH (f)) |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1068 { |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1069 col = 0; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1070 if (row < FRAME_HEIGHT (f) - 1) |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1071 row++; |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1072 } |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1073 } |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1074 |
|
41b77a76b885
* dispnew.c: Incude "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1003
diff
changeset
|
1075 cursor_to (row, col); |
| 708 | 1076 } |
| 314 | 1077 else |
| 764 | 1078 cursor_to (FRAME_CURSOR_Y (f), max (min (FRAME_CURSOR_X (f), |
| 1079 FRAME_WIDTH (f) - 1), 0)); | |
| 314 | 1080 } |
| 1081 | |
| 764 | 1082 update_end (f); |
| 314 | 1083 |
| 1084 if (termscript) | |
| 1085 fflush (termscript); | |
| 1086 fflush (stdout); | |
| 1087 | |
| 1088 /* Here if output is preempted because input is detected. */ | |
| 1089 do_pause: | |
| 1090 | |
| 764 | 1091 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
| 314 | 1092 display_completed = !pause; |
| 1093 | |
| 764 | 1094 bzero (desired_frame->enable, FRAME_HEIGHT (f)); |
| 314 | 1095 return pause; |
| 1096 } | |
| 1097 | |
| 1098 /* Called when about to quit, to check for doing so | |
| 1099 at an improper time. */ | |
| 1100 | |
| 1101 void | |
| 1102 quit_error_check () | |
| 1103 { | |
| 764 | 1104 if (FRAME_DESIRED_GLYPHS (selected_frame) == 0) |
| 314 | 1105 return; |
| 764 | 1106 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[0]) |
| 314 | 1107 abort (); |
| 764 | 1108 if (FRAME_DESIRED_GLYPHS (selected_frame)->enable[FRAME_HEIGHT (selected_frame) - 1]) |
| 314 | 1109 abort (); |
| 1110 } | |
| 1111 | |
| 1112 /* Decide what insert/delete line to do, and do it */ | |
| 1113 | |
| 1114 extern void scrolling_1 (); | |
| 1115 | |
| 764 | 1116 scrolling (frame) |
| 1117 FRAME_PTR frame; | |
| 314 | 1118 { |
| 1119 int unchanged_at_top, unchanged_at_bottom; | |
| 1120 int window_size; | |
| 1121 int changed_lines; | |
| 764 | 1122 int *old_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); |
| 1123 int *new_hash = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); | |
| 1124 int *draw_cost = (int *) alloca (FRAME_HEIGHT (frame) * sizeof (int)); | |
| 314 | 1125 register int i; |
| 764 | 1126 int free_at_end_vpos = FRAME_HEIGHT (frame); |
| 1127 register struct frame_glyphs *current_frame = FRAME_CURRENT_GLYPHS (frame); | |
| 1128 register struct frame_glyphs *desired_frame = FRAME_DESIRED_GLYPHS (frame); | |
| 314 | 1129 |
| 1130 /* Compute hash codes of all the lines. | |
| 1131 Also calculate number of changed lines, | |
| 1132 number of unchanged lines at the beginning, | |
| 1133 and number of unchanged lines at the end. */ | |
| 1134 | |
| 1135 changed_lines = 0; | |
| 1136 unchanged_at_top = 0; | |
| 764 | 1137 unchanged_at_bottom = FRAME_HEIGHT (frame); |
| 1138 for (i = 0; i < FRAME_HEIGHT (frame); i++) | |
| 314 | 1139 { |
| 1140 /* Give up on this scrolling if some old lines are not enabled. */ | |
| 764 | 1141 if (!current_frame->enable[i]) |
| 314 | 1142 return 0; |
| 764 | 1143 old_hash[i] = line_hash_code (current_frame, i); |
| 1144 if (! desired_frame->enable[i]) | |
| 314 | 1145 new_hash[i] = old_hash[i]; |
| 1146 else | |
| 764 | 1147 new_hash[i] = line_hash_code (desired_frame, i); |
| 314 | 1148 |
| 1149 if (old_hash[i] != new_hash[i]) | |
| 1150 { | |
| 1151 changed_lines++; | |
| 764 | 1152 unchanged_at_bottom = FRAME_HEIGHT (frame) - i - 1; |
| 314 | 1153 } |
| 1154 else if (i == unchanged_at_top) | |
| 1155 unchanged_at_top++; | |
| 764 | 1156 draw_cost[i] = line_draw_cost (desired_frame, i); |
| 314 | 1157 } |
| 1158 | |
| 1159 /* If changed lines are few, don't allow preemption, don't scroll. */ | |
| 1160 if (changed_lines < baud_rate / 2400 | |
| 764 | 1161 || unchanged_at_bottom == FRAME_HEIGHT (frame)) |
| 314 | 1162 return 1; |
| 1163 | |
| 764 | 1164 window_size = (FRAME_HEIGHT (frame) - unchanged_at_top |
| 314 | 1165 - unchanged_at_bottom); |
| 1166 | |
| 1167 if (scroll_region_ok) | |
| 1168 free_at_end_vpos -= unchanged_at_bottom; | |
| 764 | 1169 else if (memory_below_frame) |
| 314 | 1170 free_at_end_vpos = -1; |
| 1171 | |
| 1172 /* If large window, fast terminal and few lines in common between | |
| 764 | 1173 current frame and desired frame, don't bother with i/d calc. */ |
| 314 | 1174 if (window_size >= 18 && baud_rate > 2400 |
| 1175 && (window_size >= | |
| 1176 10 * scrolling_max_lines_saved (unchanged_at_top, | |
| 764 | 1177 FRAME_HEIGHT (frame) - unchanged_at_bottom, |
| 314 | 1178 old_hash, new_hash, draw_cost))) |
| 1179 return 0; | |
| 1180 | |
| 764 | 1181 scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, |
| 314 | 1182 draw_cost + unchanged_at_top - 1, |
| 1183 old_hash + unchanged_at_top - 1, | |
| 1184 new_hash + unchanged_at_top - 1, | |
| 1185 free_at_end_vpos - unchanged_at_top); | |
| 1186 | |
| 1187 return 0; | |
| 1188 } | |
| 1189 | |
| 1190 /* Return the offset in its buffer of the character at location col, line | |
| 1191 in the given window. */ | |
| 1192 int | |
| 1193 buffer_posn_from_coords (window, col, line) | |
| 1194 struct window *window; | |
| 1195 int col, line; | |
| 1196 { | |
| 1197 int window_left = XFASTINT (window->left); | |
| 1198 | |
| 1199 /* The actual width of the window is window->width less one for the | |
| 493 | 1200 DISP_CONTINUE_GLYPH, and less one if it's not the rightmost |
| 1201 window. */ | |
|
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1766
diff
changeset
|
1202 int window_width = window_internal_width (window) - 1; |
| 314 | 1203 |
| 493 | 1204 int startp = marker_position (window->start); |
| 314 | 1205 |
| 1206 /* Since compute_motion will only operate on the current buffer, | |
| 1207 we need to save the old one and restore it when we're done. */ | |
| 1208 struct buffer *old_current_buffer = current_buffer; | |
| 493 | 1209 struct position *posn; |
| 314 | 1210 |
| 1211 current_buffer = XBUFFER (window->buffer); | |
| 1212 | |
| 764 | 1213 /* It would be nice if we could use FRAME_CURRENT_GLYPHS (XFRAME |
| 1214 (window->frame))->bufp to avoid scanning from the very top of | |
| 493 | 1215 the window, but it isn't maintained correctly, and I'm not even |
| 1216 sure I will keep it. */ | |
| 1217 posn = compute_motion (startp, 0, | |
| 1218 (window == XWINDOW (minibuf_window) && startp == 1 | |
| 1219 ? minibuf_prompt_width : 0), | |
| 1220 ZV, line, col - window_left, | |
| 1221 window_width, XINT (window->hscroll), 0); | |
| 314 | 1222 |
| 1223 current_buffer = old_current_buffer; | |
| 1224 | |
| 764 | 1225 /* compute_motion considers frame points past the end of a line |
| 493 | 1226 to be *after* the newline, i.e. at the start of the next line. |
| 1227 This is reasonable, but not really what we want. So if the | |
| 1228 result is on a line below LINE, back it up one character. */ | |
| 1229 if (posn->vpos > line) | |
| 1230 return posn->bufpos - 1; | |
| 1231 else | |
| 1232 return posn->bufpos; | |
| 314 | 1233 } |
| 1234 | |
| 1235 static int | |
| 1236 count_blanks (r) | |
| 1237 register GLYPH *r; | |
| 1238 { | |
| 1239 register GLYPH *p = r; | |
|
1495
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
1240 while (*p++ == SPACEGLYPH); |
|
f17665e7347e
(count_blanks): Leave argument r constant, and increment p.
Richard M. Stallman <rms@gnu.org>
parents:
1407
diff
changeset
|
1241 return p - r - 1; |
| 314 | 1242 } |
| 1243 | |
| 1244 static int | |
| 1245 count_match (str1, str2) | |
| 1246 GLYPH *str1, *str2; | |
| 1247 { | |
| 1248 register GLYPH *p1 = str1; | |
| 1249 register GLYPH *p2 = str2; | |
| 1250 while (*p1++ == *p2++); | |
| 1251 return p1 - str1 - 1; | |
| 1252 } | |
| 1253 | |
| 1254 /* Char insertion/deletion cost vector, from term.c */ | |
| 1255 extern int *char_ins_del_vector; | |
| 1256 | |
|
1849
23ab36427257
(char_ins_del_cost): Use FRAME_WIDTH, not FRAME_HEIGHT.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
1257 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH((f))]) |
| 314 | 1258 |
| 1259 static void | |
| 764 | 1260 update_line (frame, vpos) |
| 1261 register FRAME_PTR frame; | |
| 314 | 1262 int vpos; |
| 1263 { | |
| 1264 register GLYPH *obody, *nbody, *op1, *op2, *np1, *temp; | |
| 1265 int tem; | |
| 1266 int osp, nsp, begmatch, endmatch, olen, nlen; | |
| 1267 int save; | |
| 764 | 1268 register struct frame_glyphs *current_frame |
| 1269 = FRAME_CURRENT_GLYPHS (frame); | |
| 1270 register struct frame_glyphs *desired_frame | |
| 1271 = FRAME_DESIRED_GLYPHS (frame); | |
| 314 | 1272 |
| 764 | 1273 if (desired_frame->highlight[vpos] |
| 1274 != (current_frame->enable[vpos] && current_frame->highlight[vpos])) | |
| 314 | 1275 { |
| 764 | 1276 change_line_highlight (desired_frame->highlight[vpos], vpos, |
| 1277 (current_frame->enable[vpos] ? | |
| 1278 current_frame->used[vpos] : 0)); | |
| 1279 current_frame->enable[vpos] = 0; | |
| 314 | 1280 } |
| 1281 else | |
| 764 | 1282 reassert_line_highlight (desired_frame->highlight[vpos], vpos); |
| 314 | 1283 |
| 764 | 1284 if (! current_frame->enable[vpos]) |
| 314 | 1285 { |
| 1286 olen = 0; | |
| 1287 } | |
| 1288 else | |
| 1289 { | |
| 764 | 1290 obody = current_frame->glyphs[vpos]; |
| 1291 olen = current_frame->used[vpos]; | |
| 1292 if (! current_frame->highlight[vpos]) | |
| 314 | 1293 { |
| 1294 if (!must_write_spaces) | |
| 1295 while (obody[olen - 1] == SPACEGLYPH && olen > 0) | |
| 1296 olen--; | |
| 1297 } | |
| 1298 else | |
| 1299 { | |
| 1300 /* For an inverse-video line, remember we gave it | |
| 764 | 1301 spaces all the way to the frame edge |
| 314 | 1302 so that the reverse video extends all the way across. */ |
| 1303 | |
| 764 | 1304 while (olen < FRAME_WIDTH (frame) - 1) |
| 314 | 1305 obody[olen++] = SPACEGLYPH; |
| 1306 } | |
| 1307 } | |
| 1308 | |
| 1309 /* One way or another, this will enable the line being updated. */ | |
| 764 | 1310 current_frame->enable[vpos] = 1; |
| 1311 current_frame->used[vpos] = desired_frame->used[vpos]; | |
| 1312 current_frame->highlight[vpos] = desired_frame->highlight[vpos]; | |
| 1313 current_frame->bufp[vpos] = desired_frame->bufp[vpos]; | |
| 314 | 1314 |
| 1315 #ifdef HAVE_X_WINDOWS | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1316 if (FRAME_X_P (frame)) |
| 314 | 1317 { |
| 764 | 1318 current_frame->pix_width[vpos] |
| 1319 = current_frame->used[vpos] | |
| 1320 * FONT_WIDTH (frame->display.x->font); | |
| 1321 current_frame->pix_height[vpos] | |
| 1322 = FONT_HEIGHT (frame->display.x->font); | |
| 314 | 1323 } |
| 1324 #endif /* HAVE_X_WINDOWS */ | |
| 1325 | |
| 764 | 1326 if (!desired_frame->enable[vpos]) |
| 314 | 1327 { |
| 1328 nlen = 0; | |
| 1329 goto just_erase; | |
| 1330 } | |
| 1331 | |
| 764 | 1332 nbody = desired_frame->glyphs[vpos]; |
| 1333 nlen = desired_frame->used[vpos]; | |
| 314 | 1334 |
| 1335 /* Pretend trailing spaces are not there at all, | |
| 1336 unless for one reason or another we must write all spaces. */ | |
| 764 | 1337 if (! desired_frame->highlight[vpos]) |
| 314 | 1338 { |
| 1339 if (!must_write_spaces) | |
| 1340 /* We know that the previous character byte contains 0. */ | |
| 1341 while (nbody[nlen - 1] == SPACEGLYPH) | |
| 1342 nlen--; | |
| 1343 } | |
| 1344 else | |
| 1345 { | |
| 1346 /* For an inverse-video line, give it extra trailing spaces | |
| 764 | 1347 all the way to the frame edge |
| 314 | 1348 so that the reverse video extends all the way across. */ |
| 1349 | |
| 764 | 1350 while (nlen < FRAME_WIDTH (frame) - 1) |
| 314 | 1351 nbody[nlen++] = SPACEGLYPH; |
| 1352 } | |
| 1353 | |
| 1354 /* If there's no i/d char, quickly do the best we can without it. */ | |
| 1355 if (!char_ins_del_ok) | |
| 1356 { | |
| 1357 int i,j; | |
| 1358 | |
| 1359 for (i = 0; i < nlen; i++) | |
| 1360 { | |
| 1361 if (i >= olen || nbody[i] != obody[i]) /* A non-matching char. */ | |
| 1362 { | |
| 1363 cursor_to (vpos, i); | |
| 1364 for (j = 1; (i + j < nlen && | |
| 1365 (i + j >= olen || nbody[i+j] != obody[i+j])); | |
| 1366 j++); | |
| 1367 | |
| 1368 /* Output this run of non-matching chars. */ | |
| 1369 write_glyphs (nbody + i, j); | |
| 1370 i += j - 1; | |
| 1371 | |
| 1372 /* Now find the next non-match. */ | |
| 1373 } | |
| 1374 } | |
| 1375 | |
| 1376 /* Clear the rest of the line, or the non-clear part of it. */ | |
| 1377 if (olen > nlen) | |
| 1378 { | |
| 1379 cursor_to (vpos, nlen); | |
| 1380 clear_end_of_line (olen); | |
| 1381 } | |
| 1382 | |
| 764 | 1383 /* Exchange contents between current_frame and new_frame. */ |
| 1384 temp = desired_frame->glyphs[vpos]; | |
| 1385 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | |
| 1386 current_frame->glyphs[vpos] = temp; | |
| 314 | 1387 |
| 1388 return; | |
| 1389 } | |
| 1390 | |
| 1391 if (!olen) | |
| 1392 { | |
| 764 | 1393 nsp = (must_write_spaces || desired_frame->highlight[vpos]) |
| 314 | 1394 ? 0 : count_blanks (nbody); |
| 1395 if (nlen > nsp) | |
| 1396 { | |
| 1397 cursor_to (vpos, nsp); | |
| 1398 write_glyphs (nbody + nsp, nlen - nsp); | |
| 1399 } | |
| 1400 | |
| 764 | 1401 /* Exchange contents between current_frame and new_frame. */ |
| 1402 temp = desired_frame->glyphs[vpos]; | |
| 1403 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | |
| 1404 current_frame->glyphs[vpos] = temp; | |
| 314 | 1405 |
| 1406 return; | |
| 1407 } | |
| 1408 | |
| 1409 obody[olen] = 1; | |
| 1410 save = nbody[nlen]; | |
| 1411 nbody[nlen] = 0; | |
| 1412 | |
| 1413 /* Compute number of leading blanks in old and new contents. */ | |
| 1414 osp = count_blanks (obody); | |
| 764 | 1415 if (!desired_frame->highlight[vpos]) |
| 314 | 1416 nsp = count_blanks (nbody); |
| 1417 else | |
| 1418 nsp = 0; | |
| 1419 | |
| 1420 /* Compute number of matching chars starting with first nonblank. */ | |
| 1421 begmatch = count_match (obody + osp, nbody + nsp); | |
| 1422 | |
| 1423 /* Spaces in new match implicit space past the end of old. */ | |
| 1424 /* A bug causing this to be a no-op was fixed in 18.29. */ | |
| 1425 if (!must_write_spaces && osp + begmatch == olen) | |
| 1426 { | |
| 1427 np1 = nbody + nsp; | |
| 1428 while (np1[begmatch] == SPACEGLYPH) | |
| 1429 begmatch++; | |
| 1430 } | |
| 1431 | |
| 1432 /* Avoid doing insert/delete char | |
| 1433 just cause number of leading spaces differs | |
| 1434 when the following text does not match. */ | |
| 1435 if (begmatch == 0 && osp != nsp) | |
| 1436 osp = nsp = min (osp, nsp); | |
| 1437 | |
| 1438 /* Find matching characters at end of line */ | |
| 1439 op1 = obody + olen; | |
| 1440 np1 = nbody + nlen; | |
| 1441 op2 = op1 + begmatch - min (olen - osp, nlen - nsp); | |
| 1442 while (op1 > op2 && op1[-1] == np1[-1]) | |
| 1443 { | |
| 1444 op1--; | |
| 1445 np1--; | |
| 1446 } | |
| 1447 endmatch = obody + olen - op1; | |
| 1448 | |
| 1449 /* Put correct value back in nbody[nlen]. | |
| 1450 This is important because direct_output_for_insert | |
| 1451 can write into the line at a later point. | |
| 1452 If this screws up the zero at the end of the line, re-establish it. */ | |
| 1453 nbody[nlen] = save; | |
| 1454 obody[olen] = 0; | |
| 1455 | |
| 1456 /* tem gets the distance to insert or delete. | |
| 1457 endmatch is how many characters we save by doing so. | |
| 1458 Is it worth it? */ | |
| 1459 | |
| 1460 tem = (nlen - nsp) - (olen - osp); | |
| 1461 if (endmatch && tem | |
| 764 | 1462 && (!char_ins_del_ok || endmatch <= char_ins_del_cost (frame)[tem])) |
| 314 | 1463 endmatch = 0; |
| 1464 | |
| 1465 /* nsp - osp is the distance to insert or delete. | |
| 1466 If that is nonzero, begmatch is known to be nonzero also. | |
| 1467 begmatch + endmatch is how much we save by doing the ins/del. | |
| 1468 Is it worth it? */ | |
| 1469 | |
| 1470 if (nsp != osp | |
| 1471 && (!char_ins_del_ok | |
| 764 | 1472 || begmatch + endmatch <= char_ins_del_cost (frame)[nsp - osp])) |
| 314 | 1473 { |
| 1474 begmatch = 0; | |
| 1475 endmatch = 0; | |
| 1476 osp = nsp = min (osp, nsp); | |
| 1477 } | |
| 1478 | |
| 1479 /* Now go through the line, inserting, writing and | |
| 1480 deleting as appropriate. */ | |
| 1481 | |
| 1482 if (osp > nsp) | |
| 1483 { | |
| 1484 cursor_to (vpos, nsp); | |
| 1485 delete_glyphs (osp - nsp); | |
| 1486 } | |
| 1487 else if (nsp > osp) | |
| 1488 { | |
| 1489 /* If going to delete chars later in line | |
| 1490 and insert earlier in the line, | |
| 1491 must delete first to avoid losing data in the insert */ | |
| 1492 if (endmatch && nlen < olen + nsp - osp) | |
| 1493 { | |
| 1494 cursor_to (vpos, nlen - endmatch + osp - nsp); | |
| 1495 delete_glyphs (olen + nsp - osp - nlen); | |
| 1496 olen = nlen - (nsp - osp); | |
| 1497 } | |
| 1498 cursor_to (vpos, osp); | |
| 1499 insert_glyphs ((char *)0, nsp - osp); | |
| 1500 } | |
| 1501 olen += nsp - osp; | |
| 1502 | |
| 1503 tem = nsp + begmatch + endmatch; | |
| 1504 if (nlen != tem || olen != tem) | |
| 1505 { | |
| 1506 cursor_to (vpos, nsp + begmatch); | |
| 1507 if (!endmatch || nlen == olen) | |
| 1508 { | |
| 1509 /* If new text being written reaches right margin, | |
| 1510 there is no need to do clear-to-eol at the end. | |
| 1511 (and it would not be safe, since cursor is not | |
| 1512 going to be "at the margin" after the text is done) */ | |
| 764 | 1513 if (nlen == FRAME_WIDTH (frame)) |
| 314 | 1514 olen = 0; |
| 1515 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
| 1516 | |
| 1517 #ifdef obsolete | |
| 1518 | |
| 1519 /* the following code loses disastrously if tem == nlen. | |
| 1520 Rather than trying to fix that case, I am trying the simpler | |
| 1521 solution found above. */ | |
| 1522 | |
| 1523 /* If the text reaches to the right margin, | |
| 1524 it will lose one way or another (depending on AutoWrap) | |
| 1525 to clear to end of line after outputting all the text. | |
| 1526 So pause with one character to go and clear the line then. */ | |
| 764 | 1527 if (nlen == FRAME_WIDTH (frame) && fast_clear_end_of_line && olen > nlen) |
| 314 | 1528 { |
| 1529 /* endmatch must be zero, and tem must equal nsp + begmatch */ | |
| 1530 write_glyphs (nbody + tem, nlen - tem - 1); | |
| 1531 clear_end_of_line (olen); | |
| 1532 olen = 0; /* Don't let it be cleared again later */ | |
| 1533 write_glyphs (nbody + nlen - 1, 1); | |
| 1534 } | |
| 1535 else | |
| 1536 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
| 1537 #endif /* OBSOLETE */ | |
| 1538 | |
| 1539 } | |
| 1540 else if (nlen > olen) | |
| 1541 { | |
| 1542 write_glyphs (nbody + nsp + begmatch, olen - tem); | |
| 1543 insert_glyphs (nbody + nsp + begmatch + olen - tem, nlen - olen); | |
| 1544 olen = nlen; | |
| 1545 } | |
| 1546 else if (olen > nlen) | |
| 1547 { | |
| 1548 write_glyphs (nbody + nsp + begmatch, nlen - tem); | |
| 1549 delete_glyphs (olen - nlen); | |
| 1550 olen = nlen; | |
| 1551 } | |
| 1552 } | |
| 1553 | |
| 1554 just_erase: | |
| 1555 /* If any unerased characters remain after the new line, erase them. */ | |
| 1556 if (olen > nlen) | |
| 1557 { | |
| 1558 cursor_to (vpos, nlen); | |
| 1559 clear_end_of_line (olen); | |
| 1560 } | |
| 1561 | |
| 764 | 1562 /* Exchange contents between current_frame and new_frame. */ |
| 1563 temp = desired_frame->glyphs[vpos]; | |
| 1564 desired_frame->glyphs[vpos] = current_frame->glyphs[vpos]; | |
| 1565 current_frame->glyphs[vpos] = temp; | |
| 314 | 1566 } |
| 1567 | |
| 1568 DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript, | |
| 1569 1, 1, "FOpen termscript file: ", | |
| 1570 "Start writing all terminal output to FILE as well as the terminal.\n\ | |
| 1571 FILE = nil means just close any termscript file currently open.") | |
| 1572 (file) | |
| 1573 Lisp_Object file; | |
| 1574 { | |
| 1575 if (termscript != 0) fclose (termscript); | |
| 1576 termscript = 0; | |
| 1577 | |
| 493 | 1578 if (! NILP (file)) |
| 314 | 1579 { |
| 1580 file = Fexpand_file_name (file, Qnil); | |
| 1581 termscript = fopen (XSTRING (file)->data, "w"); | |
| 1582 if (termscript == 0) | |
| 1583 report_file_error ("Opening termscript", Fcons (file, Qnil)); | |
| 1584 } | |
| 1585 return Qnil; | |
| 1586 } | |
| 1587 | |
| 1588 | |
| 1589 #ifdef SIGWINCH | |
| 493 | 1590 SIGTYPE |
| 314 | 1591 window_change_signal () |
| 1592 { | |
| 1593 int width, height; | |
| 1594 extern int errno; | |
| 1595 int old_errno = errno; | |
| 1596 | |
| 764 | 1597 get_frame_size (&width, &height); |
| 314 | 1598 |
| 764 | 1599 /* The frame size change obviously applies to a termcap-controlled |
| 1600 frame. Find such a frame in the list, and assume it's the only | |
| 314 | 1601 one (since the redisplay code always writes to stdout, not a |
| 764 | 1602 FILE * specified in the frame structure). Record the new size, |
| 314 | 1603 but don't reallocate the data structures now. Let that be done |
| 1604 later outside of the signal handler. */ | |
| 1605 | |
| 1606 { | |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1607 Lisp_Object tail, frame; |
| 314 | 1608 |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1609 FOR_EACH_FRAME (tail, frame) |
| 314 | 1610 { |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1611 if (FRAME_TERMCAP_P (XFRAME (frame))) |
| 314 | 1612 { |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1613 change_frame_size (XFRAME (frame), height, width, 0, 1); |
| 314 | 1614 break; |
| 1615 } | |
| 1616 } | |
| 1617 } | |
| 1618 | |
| 1619 signal (SIGWINCH, window_change_signal); | |
| 1620 errno = old_errno; | |
| 1621 } | |
| 1622 #endif /* SIGWINCH */ | |
| 1623 | |
| 1624 | |
| 764 | 1625 /* Do any change in frame size that was requested by a signal. */ |
| 314 | 1626 |
| 1627 do_pending_window_change () | |
| 1628 { | |
| 1629 /* If window_change_signal should have run before, run it now. */ | |
| 1630 while (delayed_size_change) | |
| 1631 { | |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1632 Lisp_Object tail, frame; |
| 314 | 1633 |
| 1634 delayed_size_change = 0; | |
| 1635 | |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1636 FOR_EACH_FRAME (tail, frame) |
| 314 | 1637 { |
|
2252
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1638 FRAME_PTR f = XFRAME (frame); |
|
9793d8654e23
* frame.h (FOR_EACH_FRAME): Change the definition so that
Jim Blandy <jimb@redhat.com>
parents:
2198
diff
changeset
|
1639 |
| 764 | 1640 int height = FRAME_NEW_HEIGHT (f); |
| 1641 int width = FRAME_NEW_WIDTH (f); | |
| 314 | 1642 |
| 764 | 1643 FRAME_NEW_HEIGHT (f) = 0; |
| 1644 FRAME_NEW_WIDTH (f) = 0; | |
| 314 | 1645 |
| 1646 if (height != 0) | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1647 change_frame_size (f, height, width, 0, 0); |
| 314 | 1648 } |
| 1649 } | |
| 1650 } | |
| 1651 | |
| 1652 | |
| 764 | 1653 /* Change the frame height and/or width. Values may be given as zero to |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1654 indicate no change is to take place. |
| 314 | 1655 |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1656 If DELAY is non-zero, then assume we're being called from a signal |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1657 handler, and queue the change for later - perhaps the next |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1658 redisplay. Since this tries to resize windows, we can't call it |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1659 from a signal handler. */ |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1660 |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1661 change_frame_size (frame, newheight, newwidth, pretend, delay) |
| 764 | 1662 register FRAME_PTR frame; |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1663 int newheight, newwidth, pretend; |
| 314 | 1664 { |
| 1665 /* If we can't deal with the change now, queue it for later. */ | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1666 if (delay) |
| 314 | 1667 { |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1668 FRAME_NEW_HEIGHT (frame) = newheight; |
| 764 | 1669 FRAME_NEW_WIDTH (frame) = newwidth; |
| 314 | 1670 delayed_size_change = 1; |
| 1671 return; | |
| 1672 } | |
| 1673 | |
| 764 | 1674 /* This size-change overrides any pending one for this frame. */ |
| 1675 FRAME_NEW_HEIGHT (frame) = 0; | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1676 FRAME_NEW_WIDTH (frame) = 0; |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1677 |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1678 /* If an arguments is zero, set it to the current value. */ |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1679 newheight || (newheight = FRAME_HEIGHT (frame)); |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1680 newwidth || (newwidth = FRAME_WIDTH (frame)); |
| 314 | 1681 |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1682 /* Round up to the smallest acceptable size. */ |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1683 check_frame_size (frame, &newheight, &newwidth); |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1684 |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1685 /* If we're not changing the frame size, quit now. */ |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1686 if (newheight == FRAME_HEIGHT (frame) |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1687 && newwidth == FRAME_WIDTH (frame)) |
| 314 | 1688 return; |
| 1689 | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1690 if (newheight != FRAME_HEIGHT (frame)) |
| 314 | 1691 { |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1692 if (FRAME_HAS_MINIBUF_P (frame) |
| 764 | 1693 && ! FRAME_MINIBUF_ONLY_P (frame)) |
| 314 | 1694 { |
| 764 | 1695 /* Frame has both root and minibuffer. */ |
| 1696 set_window_height (FRAME_ROOT_WINDOW (frame), | |
|
2132
0f4b18efebf5
(change_frame_size): Handle FRAME_MENU_BAR_LINES.
Richard M. Stallman <rms@gnu.org>
parents:
1915
diff
changeset
|
1697 newheight - 1 - FRAME_MENU_BAR_LINES (frame), 0); |
| 764 | 1698 XFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (frame))->top) |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1699 = newheight - 1; |
| 764 | 1700 set_window_height (FRAME_MINIBUF_WINDOW (frame), 1, 0); |
| 314 | 1701 } |
| 1702 else | |
| 764 | 1703 /* Frame has just one top-level window. */ |
|
2132
0f4b18efebf5
(change_frame_size): Handle FRAME_MENU_BAR_LINES.
Richard M. Stallman <rms@gnu.org>
parents:
1915
diff
changeset
|
1704 set_window_height (FRAME_ROOT_WINDOW (frame), |
|
0f4b18efebf5
(change_frame_size): Handle FRAME_MENU_BAR_LINES.
Richard M. Stallman <rms@gnu.org>
parents:
1915
diff
changeset
|
1705 newheight - FRAME_MENU_BAR_LINES (frame), 0); |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1706 |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1707 if (FRAME_TERMCAP_P (frame) && !pretend) |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1708 FrameRows = newheight; |
| 314 | 1709 |
| 1710 #if 0 | |
| 764 | 1711 if (frame->output_method == output_termcap) |
| 314 | 1712 { |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1713 frame_height = newheight; |
| 314 | 1714 if (!pretend) |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1715 FrameRows = newheight; |
| 314 | 1716 } |
| 1717 #endif | |
| 1718 } | |
| 1719 | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1720 if (newwidth != FRAME_WIDTH (frame)) |
| 314 | 1721 { |
| 764 | 1722 set_window_width (FRAME_ROOT_WINDOW (frame), newwidth, 0); |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1723 if (FRAME_HAS_MINIBUF_P (frame)) |
| 764 | 1724 set_window_width (FRAME_MINIBUF_WINDOW (frame), newwidth, 0); |
| 314 | 1725 |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1726 if (FRAME_TERMCAP_P (frame) && !pretend) |
| 764 | 1727 FrameCols = newwidth; |
| 314 | 1728 #if 0 |
| 764 | 1729 if (frame->output_method == output_termcap) |
| 314 | 1730 { |
| 764 | 1731 frame_width = newwidth; |
| 314 | 1732 if (!pretend) |
| 764 | 1733 FrameCols = newwidth; |
| 314 | 1734 } |
| 1735 #endif | |
| 1736 } | |
| 1737 | |
|
960
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1738 FRAME_HEIGHT (frame) = newheight; |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1739 FRAME_WIDTH (frame) = newwidth; |
|
17986889d3b6
* dispnew.c (Fredraw_frame): Call clear_frame_records before
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1740 |
| 764 | 1741 remake_frame_glyphs (frame); |
| 1742 calculate_costs (frame); | |
| 314 | 1743 } |
| 1744 | |
| 1745 DEFUN ("send-string-to-terminal", Fsend_string_to_terminal, | |
| 1746 Ssend_string_to_terminal, 1, 1, 0, | |
| 1747 "Send STRING to the terminal without alteration.\n\ | |
| 1748 Control characters in STRING will have terminal-dependent effects.") | |
| 1749 (str) | |
| 1750 Lisp_Object str; | |
| 1751 { | |
| 1752 CHECK_STRING (str, 0); | |
| 1753 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, stdout); | |
| 1754 fflush (stdout); | |
| 1755 if (termscript) | |
| 1756 { | |
| 1757 fwrite (XSTRING (str)->data, 1, XSTRING (str)->size, termscript); | |
| 1758 fflush (termscript); | |
| 1759 } | |
| 1760 return Qnil; | |
| 1761 } | |
| 1762 | |
| 1763 DEFUN ("ding", Fding, Sding, 0, 1, 0, | |
| 1764 "Beep, or flash the screen.\n\ | |
| 1765 Also, unless an argument is given,\n\ | |
| 1766 terminate any keyboard macro currently executing.") | |
| 1767 (arg) | |
| 1768 Lisp_Object arg; | |
| 1769 { | |
| 493 | 1770 if (!NILP (arg)) |
| 314 | 1771 { |
|
649
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1772 if (noninteractive) |
|
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1773 putchar (07); |
|
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1774 else |
|
61deba7b73b6
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
587
diff
changeset
|
1775 ring_bell (); |
| 314 | 1776 fflush (stdout); |
| 1777 } | |
| 1778 else | |
| 1779 bitch_at_user (); | |
| 1780 | |
| 1781 return Qnil; | |
| 1782 } | |
| 1783 | |
| 1784 bitch_at_user () | |
| 1785 { | |
| 1786 if (noninteractive) | |
| 1787 putchar (07); | |
| 1788 else if (!INTERACTIVE) /* Stop executing a keyboard macro. */ | |
| 1789 error ("Keyboard macro terminated by a command ringing the bell"); | |
| 1790 else | |
| 1791 ring_bell (); | |
| 1792 fflush (stdout); | |
| 1793 } | |
| 1794 | |
| 1795 DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0, | |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1796 "Pause, without updating display, for SECONDS seconds.\n\ |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1797 Optional second arg MILLISECONDS specifies an additional wait period,\n\ |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1798 in milliseconds.\n\ |
| 314 | 1799 \(Not all operating systems support milliseconds.)") |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1800 (seconds, milliseconds) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1801 Lisp_Object seconds, milliseconds; |
| 314 | 1802 { |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1803 int sec, usec; |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1804 |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1805 CHECK_NUMBER (seconds, 0); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1806 sec = XINT (seconds); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1807 |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1808 if (NILP (milliseconds)) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1809 XSET (milliseconds, Lisp_Int, 0); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1810 else |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1811 CHECK_NUMBER (milliseconds, 1); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1812 usec = XINT (milliseconds); |
| 314 | 1813 |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1814 #ifndef EMACS_HAS_USECS |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1815 if (sec == 0 && usec != 0) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1816 error ("millisecond `sleep-for' not supported on %s", SYSTEM_TYPE); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1817 #endif |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1818 |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1819 /* Assure that 0 <= usec < 1000000. */ |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1820 if (usec < 0) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1821 { |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1822 /* We can't rely on the rounding being correct if user is negative. */ |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1823 if (-1000000 < usec) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1824 sec--, usec += 1000000; |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1825 else |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1826 sec -= -usec / 1000000, usec = 1000000 - (-usec % 1000000); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1827 } |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1828 else |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1829 sec += usec / 1000000, usec %= 1000000; |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1830 |
| 314 | 1831 if (sec <= 0) |
| 1832 return Qnil; | |
| 1833 | |
| 650 | 1834 { |
| 1835 Lisp_Object zero; | |
| 1836 | |
| 1837 XFASTINT (zero) = 0; | |
| 1838 wait_reading_process_input (sec, usec, zero, 0); | |
| 1839 } | |
| 587 | 1840 |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1841 /* We should always have wait_reading_process_input; we have a dummy |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1842 implementation for systems which don't support subprocesses. */ |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1843 #if 0 |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1844 /* No wait_reading_process_input */ |
| 314 | 1845 immediate_quit = 1; |
| 1846 QUIT; | |
| 1847 | |
| 1848 #ifdef VMS | |
| 1849 sys_sleep (sec); | |
| 1850 #else /* not VMS */ | |
| 1851 /* The reason this is done this way | |
| 1852 (rather than defined (H_S) && defined (H_T)) | |
| 1853 is because the VMS preprocessor doesn't grok `defined' */ | |
| 1854 #ifdef HAVE_SELECT | |
| 554 | 1855 EMACS_GET_TIME (end_time); |
| 1856 EMACS_SET_SECS_USECS (timeout, sec, usec); | |
| 587 | 1857 EMACS_ADD_TIME (end_time, end_time, timeout); |
| 554 | 1858 |
| 314 | 1859 while (1) |
| 1860 { | |
| 554 | 1861 EMACS_GET_TIME (timeout); |
| 1862 EMACS_SUB_TIME (timeout, end_time, timeout); | |
| 1863 if (EMACS_TIME_NEG_P (timeout) | |
| 1864 || !select (1, 0, 0, 0, &timeout)) | |
| 314 | 1865 break; |
| 1866 } | |
| 1867 #else /* not HAVE_SELECT */ | |
| 1868 sleep (sec); | |
| 1869 #endif /* HAVE_SELECT */ | |
| 1870 #endif /* not VMS */ | |
| 1871 | |
| 1872 immediate_quit = 0; | |
| 1873 #endif /* no subprocesses */ | |
| 1874 | |
| 1875 return Qnil; | |
| 1876 } | |
| 1877 | |
| 650 | 1878 /* This is just like wait_reading_process_input, except that |
| 1879 it does the redisplay. | |
| 1880 | |
| 1881 It's also just like Fsit_for, except that it can be used for | |
| 1882 waiting for input as well. */ | |
| 1883 | |
| 1884 Lisp_Object | |
| 1885 sit_for (sec, usec, reading, display) | |
| 1886 int sec, usec, reading, display; | |
| 314 | 1887 { |
| 650 | 1888 Lisp_Object read_kbd; |
| 314 | 1889 |
| 1890 if (detect_input_pending ()) | |
| 1891 return Qnil; | |
| 650 | 1892 |
| 1893 if (display) | |
| 314 | 1894 redisplay_preserve_echo_area (); |
| 1895 | |
| 673 | 1896 if (sec == 0 && usec == 0) |
| 1897 return Qt; | |
| 1898 | |
| 314 | 1899 #ifdef SIGIO |
|
1915
98ecf99d7b1a
* dispnew.c (sit_for): Pass the correct number of arguments to
Jim Blandy <jimb@redhat.com>
parents:
1872
diff
changeset
|
1900 gobble_input (0); |
| 650 | 1901 #endif |
| 1902 | |
| 1903 XSET (read_kbd, Lisp_Int, reading ? -1 : 1); | |
| 1904 wait_reading_process_input (sec, usec, read_kbd, display); | |
| 1905 | |
| 587 | 1906 |
|
2288
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1907 /* wait_reading_process_input should always be available now; it is |
|
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1908 simulated in a simple way on systems that don't support |
|
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1909 subprocesses. */ |
|
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1910 #if 0 |
|
c6f3343edee1
Do * dispnew.c (sit_for): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2252
diff
changeset
|
1911 /* No wait_reading_process_input available. */ |
| 314 | 1912 immediate_quit = 1; |
| 1913 QUIT; | |
| 1914 | |
| 1915 waitchannels = 1; | |
| 1916 #ifdef VMS | |
| 650 | 1917 input_wait_timeout (XINT (arg)); |
| 314 | 1918 #else /* not VMS */ |
| 587 | 1919 #ifndef HAVE_TIMEVAL |
| 1920 timeout_sec = sec; | |
| 1921 select (1, &waitchannels, 0, 0, &timeout_sec); | |
| 1922 #else /* HAVE_TIMEVAL */ | |
| 1923 timeout.tv_sec = sec; | |
| 1924 timeout.tv_usec = usec; | |
| 314 | 1925 select (1, &waitchannels, 0, 0, &timeout); |
| 587 | 1926 #endif /* HAVE_TIMEVAL */ |
| 314 | 1927 #endif /* not VMS */ |
| 1928 | |
| 1929 immediate_quit = 0; | |
| 587 | 1930 #endif |
| 314 | 1931 |
| 1932 return detect_input_pending () ? Qnil : Qt; | |
| 1933 } | |
| 1934 | |
| 650 | 1935 DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0, |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1936 "Perform redisplay, then wait for SECONDS seconds or until input is available.\n\ |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1937 Optional second arg MILLISECONDS specifies an additional wait period, in\n\ |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1938 milliseconds.\n\ |
| 2292 | 1939 \(Not all operating systems support milliseconds.)\n\ |
| 650 | 1940 Optional third arg non-nil means don't redisplay, just wait for input.\n\ |
| 1941 Redisplay is preempted as always if input arrives, and does not happen\n\ | |
| 1942 if input is available before it starts.\n\ | |
| 1943 Value is t if waited the full time with no input arriving.") | |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1944 (seconds, milliseconds, nodisp) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1945 Lisp_Object seconds, milliseconds, nodisp; |
| 650 | 1946 { |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1947 int sec, usec; |
| 650 | 1948 |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1949 CHECK_NUMBER (seconds, 0); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1950 sec = XINT (seconds); |
| 650 | 1951 |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1952 if (NILP (milliseconds)) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1953 XSET (milliseconds, Lisp_Int, 0); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1954 else |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1955 CHECK_NUMBER (milliseconds, 1); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1956 usec = XINT (milliseconds); |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1957 |
| 650 | 1958 #ifndef EMACS_HAS_USECS |
|
2291
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1959 if (usec != 0 && sec == 0) |
|
bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
Jim Blandy <jimb@redhat.com>
parents:
2288
diff
changeset
|
1960 error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); |
| 650 | 1961 #endif |
| 1962 | |
| 1963 return sit_for (sec, usec, 0, NILP (nodisp)); | |
| 1964 } | |
| 314 | 1965 |
| 1966 char *terminal_type; | |
| 1967 | |
| 1968 /* Initialization done when Emacs fork is started, before doing stty. */ | |
| 1969 /* Determine terminal type and set terminal_driver */ | |
| 1970 /* Then invoke its decoding routine to set up variables | |
| 1971 in the terminal package */ | |
| 1972 | |
| 1973 init_display () | |
| 1974 { | |
| 1975 #ifdef HAVE_X_WINDOWS | |
| 1976 extern int display_arg; | |
| 1977 #endif | |
| 1978 | |
| 1979 meta_key = 0; | |
| 1980 inverse_video = 0; | |
| 1981 cursor_in_echo_area = 0; | |
| 1982 terminal_type = (char *) 0; | |
| 1983 | |
| 1984 /* If the DISPLAY environment variable is set, try to use X, and | |
| 1985 die with an error message if that doesn't work. */ | |
| 1986 | |
| 1987 /* Check if we're using a window system here before trying to | |
| 1988 initialize the terminal. If we check the terminal first, | |
| 1989 | |
| 1990 If someone has indicated that they want | |
| 1991 to use a window system, we shouldn't bother initializing the | |
| 1992 terminal. This is especially important when the terminal is so | |
| 1993 dumb that emacs gives up before and doesn't bother using the window | |
| 1994 system. */ | |
| 1995 | |
| 1996 #ifdef HAVE_X_WINDOWS | |
| 493 | 1997 if (!inhibit_window_system && (display_arg || getenv ("DISPLAY"))) |
| 314 | 1998 { |
| 1999 Vwindow_system = intern ("x"); | |
| 2000 #ifdef HAVE_X11 | |
| 2001 Vwindow_system_version = make_number (11); | |
| 2002 #else | |
| 2003 Vwindow_system_version = make_number (10); | |
| 2004 #endif | |
| 2005 return; | |
| 2006 } | |
| 2007 #endif /* HAVE_X_WINDOWS */ | |
| 2008 | |
| 2009 /* If no window system has been specified, try to use the terminal. */ | |
| 2010 if (! isatty (0)) | |
| 2011 { | |
| 2012 fprintf (stderr, "emacs: standard input is not a tty\n"); | |
| 2013 exit (1); | |
| 2014 } | |
| 2015 | |
| 2016 /* Look at the TERM variable */ | |
| 2017 terminal_type = (char *) getenv ("TERM"); | |
| 2018 if (!terminal_type) | |
| 2019 { | |
| 2020 #ifdef VMS | |
| 2021 fprintf (stderr, "Please specify your terminal type.\n\ | |
| 2022 For types defined in VMS, use set term /device=TYPE.\n\ | |
| 2023 For types not defined in VMS, use define emacs_term \"TYPE\".\n\ | |
| 2024 \(The quotation marks are necessary since terminal types are lower case.)\n"); | |
| 2025 #else | |
| 2026 fprintf (stderr, "Please set the environment variable TERM; see tset(1).\n"); | |
| 2027 #endif | |
| 2028 exit (1); | |
| 2029 } | |
| 2030 | |
| 2031 #ifdef VMS | |
| 2032 /* VMS DCL tends to upcase things, so downcase term type. | |
| 2033 Hardly any uppercase letters in terminal types; should be none. */ | |
| 2034 { | |
| 2035 char *new = (char *) xmalloc (strlen (terminal_type) + 1); | |
| 2036 char *p; | |
| 2037 | |
| 2038 strcpy (new, terminal_type); | |
| 2039 | |
| 2040 for (p = new; *p; p++) | |
| 2041 if (isupper (*p)) | |
| 2042 *p = tolower (*p); | |
| 2043 | |
| 2044 terminal_type = new; | |
| 2045 } | |
| 2046 #endif | |
| 2047 | |
| 2048 term_init (terminal_type); | |
| 2049 | |
| 764 | 2050 remake_frame_glyphs (selected_frame); |
| 2051 calculate_costs (selected_frame); | |
| 314 | 2052 |
| 2053 /* X and Y coordinates of the cursor between updates. */ | |
| 764 | 2054 FRAME_CURSOR_X (selected_frame) = 0; |
| 2055 FRAME_CURSOR_Y (selected_frame) = 0; | |
| 314 | 2056 |
| 2057 #ifdef SIGWINCH | |
| 2058 #ifndef CANNOT_DUMP | |
| 2059 if (initialized) | |
| 2060 #endif /* CANNOT_DUMP */ | |
| 2061 signal (SIGWINCH, window_change_signal); | |
| 2062 #endif /* SIGWINCH */ | |
| 2063 } | |
| 2064 | |
| 2065 syms_of_display () | |
| 2066 { | |
| 764 | 2067 #ifdef MULTI_FRAME |
| 2068 defsubr (&Sredraw_frame); | |
| 314 | 2069 #endif |
| 2070 defsubr (&Sredraw_display); | |
| 2071 defsubr (&Sopen_termscript); | |
| 2072 defsubr (&Sding); | |
| 2073 defsubr (&Ssit_for); | |
| 2074 defsubr (&Ssleep_for); | |
| 2075 defsubr (&Ssend_string_to_terminal); | |
| 2076 | |
| 2077 DEFVAR_INT ("baud-rate", &baud_rate, | |
| 2078 "The output baud rate of the terminal.\n\ | |
| 2079 On most systems, changing this value will affect the amount of padding\n\ | |
| 2080 and the other strategic decisions made during redisplay."); | |
| 2081 DEFVAR_BOOL ("inverse-video", &inverse_video, | |
| 764 | 2082 "*Non-nil means invert the entire frame display.\n\ |
| 314 | 2083 This means everything is in inverse video which otherwise would not be."); |
| 2084 DEFVAR_BOOL ("visible-bell", &visible_bell, | |
| 764 | 2085 "*Non-nil means try to flash the frame to represent a bell."); |
| 314 | 2086 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter, |
| 764 | 2087 "*Non-nil means no need to redraw entire frame after suspending.\n\ |
| 314 | 2088 A non-nil value is useful if the terminal can automatically preserve\n\ |
| 764 | 2089 Emacs's frame display when you reenter Emacs.\n\ |
| 314 | 2090 It is up to you to set this variable if your terminal can do that."); |
| 2091 DEFVAR_LISP ("window-system", &Vwindow_system, | |
| 2092 "A symbol naming the window-system under which Emacs is running\n\ | |
| 2093 \(such as `x'), or nil if emacs is running on an ordinary terminal."); | |
| 2094 DEFVAR_LISP ("window-system-version", &Vwindow_system_version, | |
| 2095 "The version number of the window system in use.\n\ | |
| 2096 For X windows, this is 10 or 11."); | |
| 2097 DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area, | |
| 2098 "Non-nil means put cursor in minibuffer, at end of any message there."); | |
| 2099 DEFVAR_LISP ("glyph-table", &Vglyph_table, | |
| 764 | 2100 "Table defining how to output a glyph code to the frame.\n\ |
| 314 | 2101 If not nil, this is a vector indexed by glyph code to define the glyph.\n\ |
| 2102 Each element can be:\n\ | |
| 2103 integer: a glyph code which this glyph is an alias for.\n\ | |
| 2104 string: output this glyph using that string (not impl. in X windows).\n\ | |
| 2105 nil: this glyph mod 256 is char code to output,\n\ | |
| 2106 and this glyph / 256 is face code for X windows (see `x-set-face')."); | |
| 2107 Vglyph_table = Qnil; | |
| 2108 | |
| 2109 DEFVAR_LISP ("standard-display-table", &Vstandard_display_table, | |
| 2110 "Display table to use for buffers that specify none.\n\ | |
| 2111 See `buffer-display-table' for more information."); | |
| 2112 Vstandard_display_table = Qnil; | |
| 2113 | |
| 2114 /* Initialize `window-system', unless init_display already decided it. */ | |
| 2115 #ifdef CANNOT_DUMP | |
| 2116 if (noninteractive) | |
| 2117 #endif | |
| 2118 { | |
| 2119 Vwindow_system = Qnil; | |
| 2120 Vwindow_system_version = Qnil; | |
| 2121 } | |
| 2122 } | |
| 2123 |
