Mercurial > hg > xemacs-beta
annotate src/window.c @ 5391:f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
2011-04-02 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-output-preface): New.
* bytecomp.el (byte-compile-output-file-form):
* bytecomp.el (byte-compile-output-docform):
* bytecomp.el (byte-compile-file-form):
* bytecomp.el (byte-compile-file-form-defmumble):
* bytecomp.el (symbol-value):
* bytecomp.el (byte-compile-symbol-value): New.
* cl-macs.el (load-time-value):
No longer implement load-time-value by very hackishly redefining
#'byte-compile-file-form-defmumble, instead make the appropriate
changes in #'byte-compile-file-form-defmumble and
#'byte-compile-file-form instead. We also add a specific byte-compile
method for #'symbol-value, using the add-properties-to-a-gensym
approach that worked for #'block and #'return-from.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sat, 02 Apr 2011 16:13:20 +0100 |
| parents | 3889ef128488 |
| children | 4dee0387b9de |
| rev | line source |
|---|---|
| 428 | 1 /* Window creation, deletion and examination for XEmacs. |
| 2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. | |
| 3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
| 5043 | 4 Copyright (C) 1995, 1996, 2002, 2010 Ben Wing. |
| 428 | 5 Copyright (C) 1996 Chuck Thompson. |
| 6 | |
| 7 This file is part of XEmacs. | |
| 8 | |
| 9 XEmacs is free software; you can redistribute it and/or modify it | |
| 10 under the terms of the GNU General Public License as published by the | |
| 11 Free Software Foundation; either version 2, or (at your option) any | |
| 12 later version. | |
| 13 | |
| 14 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 17 for more details. | |
| 18 | |
| 19 You should have received a copy of the GNU General Public License | |
| 20 along with XEmacs; see the file COPYING. If not, write to | |
| 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 22 Boston, MA 02111-1307, USA. */ | |
| 23 | |
| 24 /* Synched up with: FSF 19.30. */ | |
| 25 /* Beginning to diverge significantly. */ | |
| 26 | |
| 853 | 27 /* Authorship: |
| 28 | |
| 29 Based on code from pre-release FSF 19, c. 1991. | |
| 30 Significantly reworked by Chuck Thompson, 1993-1996. | |
| 31 window mirror stuff added by Chuck Thompson c. 1993. | |
| 32 various cleanup by Ben Wing c. 1995 (window slots, window init code, | |
| 33 memory usage, synch. up to FSF 19.30, other). | |
| 34 Unknown work by Andy Piper. | |
| 35 new window-width/height fns. by Ben Wing, Mar 2000. */ | |
| 36 | |
| 428 | 37 /* This file has been Mule-ized. */ |
| 38 | |
| 39 #include <config.h> | |
| 40 #include "lisp.h" | |
| 41 | |
| 42 #include "buffer.h" | |
| 800 | 43 #include "commands.h" |
| 872 | 44 #include "device-impl.h" |
| 800 | 45 #include "elhash.h" |
| 428 | 46 #include "faces.h" |
| 872 | 47 #include "frame-impl.h" |
| 800 | 48 #include "glyphs.h" |
| 49 #include "gutter.h" | |
|
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5052
diff
changeset
|
50 #include "fontcolor.h" |
| 428 | 51 #include "redisplay.h" |
| 872 | 52 #include "window-impl.h" |
| 428 | 53 |
| 1149 | 54 Lisp_Object Qwindowp, Qwindow_live_p; |
| 428 | 55 Lisp_Object Qdisplay_buffer; |
| 56 | |
| 57 #ifdef MEMORY_USAGE_STATS | |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
58 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qredisplay_structs; |
| 428 | 59 #ifdef HAVE_SCROLLBARS |
| 60 Lisp_Object Qscrollbar_instances; | |
| 61 #endif | |
| 62 #endif | |
| 63 | |
| 1979 | 64 extern int allow_deletion_of_last_visible_frame; |
| 65 | |
| 428 | 66 EXFUN (Fnext_window, 4); |
| 67 | |
| 68 static int window_pixel_width_to_char_width (struct window *w, | |
| 69 int pixel_width, | |
| 70 int include_margins_p); | |
| 71 static int window_char_width_to_pixel_width (struct window *w, | |
| 72 int char_width, | |
| 73 int include_margins_p); | |
| 74 static int window_pixel_height_to_char_height (struct window *w, | |
| 75 int pixel_height, | |
| 76 int include_gutters_p); | |
| 77 static int window_char_height_to_pixel_height (struct window *w, | |
| 78 int char_height, | |
| 79 int include_gutters_p); | |
| 444 | 80 static void change_window_height (Lisp_Object window, int delta, |
| 81 Lisp_Object horizontalp, int inpixels); | |
| 428 | 82 |
| 83 /* Thickness of shadow border around 3d modelines. */ | |
| 84 Lisp_Object Vmodeline_shadow_thickness; | |
| 85 | |
| 86 /* Whether vertical dividers are draggable and displayed */ | |
| 87 Lisp_Object Vvertical_divider_always_visible_p; | |
| 88 | |
| 89 /* Whether a modeline should be displayed. */ | |
| 90 Lisp_Object Vhas_modeline_p; | |
| 91 | |
| 92 /* Thickness of shadow border around vertical dividers. */ | |
| 93 Lisp_Object Vvertical_divider_shadow_thickness; | |
| 94 | |
| 95 /* Divider surface width (not counting 3-d borders) */ | |
| 96 Lisp_Object Vvertical_divider_line_width; | |
| 97 | |
| 442 | 98 /* Spacing between outer edge of divider border and window edge */ |
| 428 | 99 Lisp_Object Vvertical_divider_spacing; |
| 100 | |
| 101 /* How much to scroll by per-line. */ | |
| 102 Lisp_Object Vwindow_pixel_scroll_increment; | |
| 103 | |
| 104 /* Scroll if point lands on the bottom line and that line is partially | |
| 105 clipped. */ | |
| 106 int scroll_on_clipped_lines; | |
| 107 | |
| 108 /* The minibuffer window of the selected frame. | |
| 109 Note that you cannot test for minibufferness of an arbitrary window | |
| 110 by comparing against this; but you can test for minibufferness of | |
| 111 the selected window. */ | |
| 112 Lisp_Object minibuf_window; | |
| 113 | |
| 114 /* Non-nil means it is the window for C-M-v to scroll | |
| 115 when the minibuffer is selected. */ | |
| 116 Lisp_Object Vminibuffer_scroll_window; | |
| 117 | |
| 118 /* Non-nil means this is the buffer whose window C-M-v should scroll. */ | |
| 119 Lisp_Object Vother_window_scroll_buffer; | |
| 120 | |
| 121 /* Non-nil means it's the function to call to display temp buffers. */ | |
| 122 Lisp_Object Vtemp_buffer_show_function; | |
| 123 | |
| 124 /* If a window gets smaller than either of these, it is removed. */ | |
| 458 | 125 Fixnum window_min_height; |
| 126 Fixnum window_min_width; | |
| 428 | 127 |
| 128 /* Number of lines of continuity in scrolling by screenfuls. */ | |
| 458 | 129 Fixnum next_screen_context_lines; |
| 428 | 130 |
| 1149 | 131 Lisp_Object Qcurrent_window_configuration, Qset_window_configuration; |
| 428 | 132 |
| 707 | 133 Lisp_Object Qtruncate_partial_width_windows; |
| 134 | |
| 428 | 135 #define SET_LAST_MODIFIED(w, cache_too) \ |
| 136 do { \ | |
| 137 (w)->last_modified[CURRENT_DISP] = Qzero; \ | |
| 138 (w)->last_modified[DESIRED_DISP] = Qzero; \ | |
| 139 (w)->last_modified[CMOTION_DISP] = Qzero; \ | |
| 140 if (cache_too) \ | |
| 141 (w)->line_cache_last_updated = Qzero; \ | |
| 142 } while (0) | |
| 143 | |
| 144 #define SET_LAST_FACECHANGE(w) \ | |
| 145 do { \ | |
| 146 (w)->last_facechange[CURRENT_DISP] = Qzero; \ | |
| 147 (w)->last_facechange[DESIRED_DISP] = Qzero; \ | |
| 148 (w)->last_facechange[CMOTION_DISP] = Qzero; \ | |
| 149 } while (0) | |
| 150 | |
| 151 | |
| 1204 | 152 |
| 153 static const struct memory_description int_description_1[] = { | |
| 154 { XD_END } | |
| 155 }; | |
| 156 | |
| 157 static const struct sized_memory_description int_description = { | |
| 158 sizeof (int), | |
| 159 int_description_1 | |
| 160 }; | |
| 161 | |
| 162 static const struct memory_description int_dynarr_description_1[] = { | |
| 163 XD_DYNARR_DESC (int_dynarr, &int_description), | |
| 164 { XD_END } | |
| 165 }; | |
| 166 | |
| 167 static const struct sized_memory_description int_dynarr_description = { | |
| 168 sizeof (int_dynarr), | |
| 169 int_dynarr_description_1 | |
| 170 }; | |
| 171 | |
| 172 static const struct memory_description face_cachel_description_1[] = { | |
| 2367 | 173 { XD_BLOCK_PTR, offsetof (face_cachel, merged_faces), |
| 2551 | 174 1, { &int_dynarr_description } }, |
| 1204 | 175 { XD_LISP_OBJECT, offsetof (face_cachel, face) }, |
| 176 { XD_LISP_OBJECT, offsetof (face_cachel, foreground) }, | |
| 177 { XD_LISP_OBJECT, offsetof (face_cachel, background) }, | |
| 178 { XD_LISP_OBJECT_ARRAY, offsetof (face_cachel, font), NUM_LEADING_BYTES }, | |
| 179 { XD_LISP_OBJECT, offsetof (face_cachel, display_table) }, | |
| 180 { XD_LISP_OBJECT, offsetof (face_cachel, background_pixmap) }, | |
| 181 { XD_END } | |
| 182 }; | |
| 183 | |
| 3092 | 184 #ifdef NEW_GC |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
185 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("face-cachel", face_cachel, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
186 0, face_cachel_description_1, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
187 Lisp_Face_Cachel); |
| 3092 | 188 #endif /* NEW_GC */ |
| 189 | |
| 1204 | 190 static const struct sized_memory_description face_cachel_description = { |
| 191 sizeof (face_cachel), | |
| 192 face_cachel_description_1 | |
| 193 }; | |
| 194 | |
| 195 static const struct memory_description face_cachel_dynarr_description_1[] = { | |
| 3092 | 196 #ifdef NEW_GC |
| 197 XD_LISP_DYNARR_DESC (face_cachel_dynarr, &face_cachel_description), | |
| 198 #else /* not NEW_GC */ | |
| 1204 | 199 XD_DYNARR_DESC (face_cachel_dynarr, &face_cachel_description), |
| 3092 | 200 #endif /* not NEW_GC */ |
| 1204 | 201 { XD_END } |
| 202 }; | |
| 203 | |
| 3092 | 204 #ifdef NEW_GC |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
205 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("face-cachel-dynarr", face_cachel_dynarr, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
206 0, face_cachel_dynarr_description_1, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
207 face_cachel_dynarr); |
| 3092 | 208 #else /* not NEW_GC */ |
| 1204 | 209 static const struct sized_memory_description face_cachel_dynarr_description = { |
| 210 sizeof (face_cachel_dynarr), | |
| 211 face_cachel_dynarr_description_1 | |
| 212 }; | |
| 3092 | 213 #endif /* not NEW_GC */ |
| 1204 | 214 |
| 215 static const struct memory_description glyph_cachel_description_1[] = { | |
| 216 { XD_LISP_OBJECT, offsetof (glyph_cachel, glyph) }, | |
| 217 { XD_END } | |
| 218 }; | |
| 219 | |
| 3092 | 220 #ifdef NEW_GC |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
221 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("glyph-cachel", glyph_cachel, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
222 0, glyph_cachel_description_1, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
223 Lisp_Glyph_Cachel); |
| 3092 | 224 #endif /* NEW_GC */ |
| 225 | |
| 1204 | 226 static const struct sized_memory_description glyph_cachel_description = { |
| 227 sizeof (glyph_cachel), | |
| 228 glyph_cachel_description_1 | |
| 229 }; | |
| 230 | |
| 231 static const struct memory_description glyph_cachel_dynarr_description_1[] = { | |
| 3092 | 232 #ifdef NEW_GC |
| 233 XD_LISP_DYNARR_DESC (glyph_cachel_dynarr, &glyph_cachel_description), | |
| 234 #else /* not NEW_GC */ | |
| 1204 | 235 XD_DYNARR_DESC (glyph_cachel_dynarr, &glyph_cachel_description), |
| 3092 | 236 #endif /* not NEW_GC */ |
| 1204 | 237 { XD_END } |
| 238 }; | |
| 239 | |
| 3092 | 240 #ifdef NEW_GC |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
241 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("glyph-cachel-dynarr", |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
242 glyph_cachel_dynarr, 0, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
243 glyph_cachel_dynarr_description_1, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
244 glyph_cachel_dynarr); |
| 3092 | 245 #else /* not NEW_GC */ |
| 1204 | 246 static const struct sized_memory_description glyph_cachel_dynarr_description = { |
| 247 sizeof (glyph_cachel_dynarr), | |
| 248 glyph_cachel_dynarr_description_1 | |
| 249 }; | |
| 3092 | 250 #endif /* not NEW_GC */ |
| 1204 | 251 |
| 252 static const struct memory_description line_start_cache_description_1[] = { | |
| 253 { XD_END } | |
| 254 }; | |
| 255 | |
| 256 static const struct sized_memory_description line_start_cache_description = { | |
| 257 sizeof (line_start_cache), | |
| 258 line_start_cache_description_1 | |
| 259 }; | |
| 260 | |
| 261 static const struct memory_description line_start_cache_dynarr_description_1[] = { | |
| 262 XD_DYNARR_DESC (line_start_cache_dynarr, &line_start_cache_description), | |
| 263 { XD_END } | |
| 264 }; | |
| 265 | |
| 266 static const struct sized_memory_description line_start_cache_dynarr_description = { | |
| 267 sizeof (line_start_cache_dynarr), | |
| 268 line_start_cache_dynarr_description_1 | |
| 269 }; | |
| 270 | |
| 271 static const struct memory_description window_description [] = { | |
| 272 #define WINDOW_SLOT(slot) { XD_LISP_OBJECT, offsetof (struct window, slot) }, | |
| 273 #define WINDOW_SLOT_ARRAY(slot, size) \ | |
| 274 { XD_LISP_OBJECT_ARRAY, offsetof (struct window, slot), size }, | |
| 275 #include "winslots.h" | |
| 276 | |
| 3092 | 277 #ifdef NEW_GC |
| 278 { XD_LISP_OBJECT, offsetof (struct window, face_cachels) }, | |
| 279 { XD_LISP_OBJECT, offsetof (struct window, glyph_cachels) }, | |
| 280 #else /* not NEW_GC */ | |
| 2367 | 281 { XD_BLOCK_PTR, offsetof (struct window, face_cachels), |
| 2551 | 282 1, { &face_cachel_dynarr_description } }, |
| 2367 | 283 { XD_BLOCK_PTR, offsetof (struct window, glyph_cachels), |
| 2551 | 284 1, { &glyph_cachel_dynarr_description } }, |
| 3092 | 285 #endif /* not NEW_GC */ |
| 2367 | 286 { XD_BLOCK_PTR, offsetof (struct window, line_start_cache), |
| 2775 | 287 1, { &line_start_cache_dynarr_description }, XD_FLAG_NO_KKCC }, |
| 1204 | 288 { XD_END } |
| 289 }; | |
| 428 | 290 |
| 291 static Lisp_Object | |
| 292 mark_window (Lisp_Object obj) | |
| 293 { | |
| 294 struct window *window = XWINDOW (obj); | |
| 295 | |
| 296 mark_face_cachels (window->face_cachels); | |
| 297 mark_glyph_cachels (window->glyph_cachels); | |
| 298 | |
| 617 | 299 #define WINDOW_SLOT(slot) mark_object (window->slot); |
| 428 | 300 #include "winslots.h" |
| 301 | |
| 302 return Qnil; | |
| 303 } | |
| 304 | |
| 305 static void | |
| 2286 | 306 print_window (Lisp_Object obj, Lisp_Object printcharfun, |
| 307 int UNUSED (escapeflag)) | |
| 428 | 308 { |
| 4846 | 309 Lisp_Object buf; |
| 310 | |
| 428 | 311 if (print_readably) |
|
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
312 printing_unreadable_lisp_object (obj, 0); |
| 428 | 313 |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
314 write_ascstring (printcharfun, "#<window"); |
| 4846 | 315 buf = XWINDOW_BUFFER (obj); |
| 316 if (EQ (buf, Qt)) | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
317 write_ascstring (printcharfun, " during creation"); |
| 4846 | 318 else if (!NILP (buf)) |
| 428 | 319 { |
| 4846 | 320 |
| 321 Lisp_Object name = XBUFFER (buf)->name; | |
| 800 | 322 write_fmt_string_lisp (printcharfun, " on %S", 1, name); |
| 428 | 323 } |
|
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
324 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); |
| 428 | 325 } |
| 326 | |
| 327 static void | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
328 finalize_window (Lisp_Object obj) |
| 428 | 329 { |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
330 struct window *w = XWINDOW (obj); |
| 428 | 331 |
| 332 if (w->line_start_cache) | |
| 333 { | |
| 334 Dynarr_free (w->line_start_cache); | |
| 335 w->line_start_cache = 0; | |
| 336 } | |
| 337 | |
| 338 if (w->face_cachels) | |
| 339 { | |
| 340 int i; | |
| 341 | |
| 342 for (i = 0; i < Dynarr_length (w->face_cachels); i++) | |
| 343 { | |
| 344 struct face_cachel *cachel = Dynarr_atp (w->face_cachels, i); | |
| 345 if (cachel->merged_faces) | |
| 346 { | |
| 347 Dynarr_free (cachel->merged_faces); | |
| 348 cachel->merged_faces = 0; | |
| 349 } | |
| 350 } | |
| 351 Dynarr_free (w->face_cachels); | |
| 352 w->face_cachels = 0; | |
| 353 } | |
| 354 | |
| 355 if (w->glyph_cachels) | |
| 356 { | |
| 357 Dynarr_free (w->glyph_cachels); | |
| 358 w->glyph_cachels = 0; | |
| 359 } | |
| 360 } | |
| 361 | |
| 844 | 362 /* These caches map buffers to markers. They are key-weak so that entries |
| 363 remain around as long as the buffers do. */ | |
| 364 | |
| 365 static Lisp_Object | |
| 366 make_saved_buffer_point_cache (void) | |
| 367 { | |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5178
diff
changeset
|
368 return make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, Qeq); |
| 844 | 369 } |
| 370 | |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
371 DEFINE_NODUMP_LISP_OBJECT ("window", window, |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
372 mark_window, print_window, finalize_window, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
373 0, 0, window_description, struct window); |
| 428 | 374 |
| 375 #define INIT_DISP_VARIABLE(field, initialization) \ | |
| 376 p->field[CURRENT_DISP] = initialization; \ | |
| 377 p->field[DESIRED_DISP] = initialization; \ | |
| 378 p->field[CMOTION_DISP] = initialization; | |
| 379 | |
| 380 /* We have an implicit assertion that the first two elements (default | |
| 381 and modeline faces) are always present in the face_element_cache. | |
| 382 Normally redisplay ensures this. However, it is possible for a | |
| 383 window to get created and functions which reference these values | |
| 384 called before redisplay works with the window for the first time. | |
| 385 All callers of allocate_window should therefore call | |
| 386 reset_face_cachels on the created window. We can't do it | |
| 387 here because the window must have its frame pointer set or | |
| 388 reset_face_cachels will fail. */ | |
| 389 Lisp_Object | |
| 390 allocate_window (void) | |
| 391 { | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
392 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (window); |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
393 struct window *p = XWINDOW (obj); |
| 617 | 394 |
| 395 #define WINDOW_SLOT(slot) p->slot = Qnil; | |
| 396 #include "winslots.h" | |
| 397 | |
| 428 | 398 INIT_DISP_VARIABLE (start, Fmake_marker ()); |
| 399 INIT_DISP_VARIABLE (pointm, Fmake_marker ()); | |
| 400 p->sb_point = Fmake_marker (); | |
| 844 | 401 p->saved_point_cache = make_saved_buffer_point_cache (); |
| 402 p->saved_last_window_start_cache = make_saved_buffer_point_cache (); | |
| 428 | 403 p->use_time = Qzero; |
| 404 INIT_DISP_VARIABLE (last_modified, Qzero); | |
| 405 INIT_DISP_VARIABLE (last_point, Fmake_marker ()); | |
| 406 INIT_DISP_VARIABLE (last_start, Fmake_marker ()); | |
| 407 INIT_DISP_VARIABLE (last_facechange, Qzero); | |
| 3092 | 408 #ifdef NEW_GC |
| 409 p->face_cachels = Dynarr_lisp_new (face_cachel, | |
| 410 &lrecord_face_cachel_dynarr, | |
| 411 &lrecord_face_cachel); | |
| 412 p->glyph_cachels = Dynarr_lisp_new (glyph_cachel, | |
| 413 &lrecord_glyph_cachel_dynarr, | |
| 414 &lrecord_glyph_cachel); | |
| 415 #else /* not NEW_GC */ | |
| 428 | 416 p->face_cachels = Dynarr_new (face_cachel); |
| 417 p->glyph_cachels = Dynarr_new (glyph_cachel); | |
| 3092 | 418 #endif /* not NEW_GC */ |
| 428 | 419 p->line_start_cache = Dynarr_new (line_start_cache); |
| 450 | 420 p->subwindow_instance_cache = make_image_instance_cache_hash_table (); |
| 421 | |
| 428 | 422 p->line_cache_last_updated = Qzero; |
| 442 | 423 |
| 428 | 424 p->windows_changed = 1; |
| 425 p->shadow_thickness_changed = 1; | |
| 426 | |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
427 return obj; |
| 428 | 428 } |
| 429 #undef INIT_DISP_VARIABLE | |
| 430 | |
| 617 | 431 /************************************************************************/ |
| 432 /* Window mirror structure */ | |
| 433 /************************************************************************/ | |
| 434 | |
| 428 | 435 /* |
| 436 * The redisplay structures used to be stored with each window. While | |
| 437 * they are logically something associated with frames they can't be | |
| 438 * stored there with a redisplay which handles variable height lines. | |
| 439 * Lines in horizontally split windows might not line up. So they get | |
| 440 * stored with the windows. | |
| 441 * | |
| 442 * The problem with this is window configurations. When restoring a | |
| 443 * window configuration it now becomes problematic to do an | |
| 444 * incremental redisplay. The solution is to store the redisplay | |
| 445 * structures with the frame as they should be but laid out in the | |
| 446 * same manner as the window structure. Thus is born the window | |
| 447 * mirror. | |
| 448 * | |
| 449 * It also becomes a convenient place to stick scrollbar instances | |
| 450 * since they extrapolate out to having the same problem described for | |
| 451 * the display structures. | |
| 452 */ | |
| 453 | |
| 617 | 454 /* NOTE: The window-mirror structure formerly was not a Lisp object, and |
| 455 marking was handled specially. I've gotten recurring crashes, however, | |
| 456 using the mouse wheel under Windows, where either the window mirror | |
| 457 accessed through a scrollbar instance, or the frame pointed to by that | |
| 458 window mirror, gets garbaged. Things are tricky under windows because | |
| 459 the scrollbar instances are stored in HWND-specific data. Furthermore, | |
| 460 we have scrollbar-instance caches to complicate things. Both of these | |
| 461 make it very difficult (for me at least, not being intimately familiar | |
| 462 with the redisplay code) to track exactly when and where a particular | |
| 463 window mirror or scrollbar instance has pointers to it, or whether a | |
| 464 window mirror might have a dead frame or buffer in it (i.e. not | |
| 465 necessarily gc-protected by being on a global list). By far the safest | |
| 466 thing, then, is to make both structures Lisp objects and not explicitly | |
| 467 xfree() them. This should make no practical difference in memory usage | |
| 468 because neither structure is created very often (only when windows are | |
| 469 created or deleted). --ben */ | |
| 470 | |
| 1204 | 471 static const struct memory_description window_mirror_description [] = { |
| 472 { XD_LISP_OBJECT, offsetof (struct window_mirror, frame) }, | |
| 473 { XD_LISP_OBJECT, offsetof (struct window_mirror, next) }, | |
| 474 { XD_LISP_OBJECT, offsetof (struct window_mirror, hchild) }, | |
| 475 { XD_LISP_OBJECT, offsetof (struct window_mirror, vchild) }, | |
| 476 | |
| 2367 | 477 { XD_BLOCK_PTR, offsetof (struct window_mirror, current_display_lines), |
| 2551 | 478 1, { &display_line_dynarr_description } }, |
| 2367 | 479 { XD_BLOCK_PTR, offsetof (struct window_mirror, desired_display_lines), |
| 2551 | 480 1, { &display_line_dynarr_description } }, |
| 1204 | 481 |
| 482 { XD_LISP_OBJECT, offsetof (struct window_mirror, buffer) }, | |
| 483 | |
| 484 #ifdef HAVE_SCROLLBARS | |
| 485 { XD_LISP_OBJECT, offsetof (struct window_mirror, | |
| 486 scrollbar_vertical_instance) }, | |
| 487 { XD_LISP_OBJECT, offsetof (struct window_mirror, | |
| 488 scrollbar_horizontal_instance) }, | |
| 489 #endif /* HAVE_SCROLLBARS */ | |
| 490 | |
| 934 | 491 { XD_END } |
| 492 }; | |
| 493 | |
| 617 | 494 static Lisp_Object |
| 495 mark_window_mirror (Lisp_Object obj) | |
| 496 { | |
| 497 struct window_mirror *mir = XWINDOW_MIRROR (obj); | |
| 498 | |
| 499 if (mir->current_display_lines) | |
| 500 mark_redisplay_structs (mir->current_display_lines); | |
| 501 if (mir->desired_display_lines) | |
| 502 mark_redisplay_structs (mir->desired_display_lines); | |
| 503 | |
| 504 if (mir->hchild) | |
| 505 mark_object (wrap_window_mirror (mir->hchild)); | |
| 506 if (mir->vchild) | |
| 507 mark_object (wrap_window_mirror (mir->vchild)); | |
| 508 | |
| 509 if (mir->frame) | |
| 510 mark_object (wrap_frame (mir->frame)); | |
| 511 if (mir->buffer) | |
| 512 mark_object (wrap_buffer (mir->buffer)); | |
| 513 | |
| 514 #ifdef HAVE_SCROLLBARS | |
| 515 if (mir->scrollbar_vertical_instance) | |
| 516 mark_object (wrap_scrollbar_instance (mir->scrollbar_vertical_instance)); | |
| 517 if (mir->scrollbar_horizontal_instance) | |
| 518 mark_object (wrap_scrollbar_instance (mir->scrollbar_horizontal_instance)); | |
| 519 #endif /* HAVE_SCROLLBARS */ | |
| 520 if (mir->next) | |
| 521 return wrap_window_mirror (mir->next); | |
| 522 else | |
| 523 return Qnil; | |
| 524 } | |
| 525 | |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
526 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("window-mirror", window_mirror, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
527 mark_window_mirror, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
528 window_mirror_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
529 struct window_mirror); |
| 617 | 530 |
| 428 | 531 /* Create a new window mirror structure and associated redisplay |
| 532 structs. */ | |
| 533 static struct window_mirror * | |
| 534 new_window_mirror (struct frame *f) | |
| 535 { | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
536 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (window_mirror); |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
537 struct window_mirror *t = XWINDOW_MIRROR (obj); |
| 428 | 538 |
| 539 t->frame = f; | |
| 540 t->current_display_lines = Dynarr_new (display_line); | |
| 541 t->desired_display_lines = Dynarr_new (display_line); | |
| 542 | |
| 543 return t; | |
| 544 } | |
| 545 | |
| 546 /* Synchronize the mirror structure with a given window structure. | |
| 547 This is normally called from update_frame_window_mirror with a | |
| 548 starting window of f->root_window. */ | |
| 549 static struct window_mirror * | |
| 550 update_mirror_internal (Lisp_Object win, struct window_mirror *mir) | |
| 551 { | |
| 552 if (NILP (win)) | |
| 553 { | |
| 554 if (mir) | |
| 555 { | |
| 556 free_window_mirror (mir); | |
| 557 mir = NULL; | |
| 558 } | |
| 559 return mir; | |
| 560 } | |
| 561 else | |
| 562 if (!mir) | |
| 563 mir = new_window_mirror (XFRAME (XWINDOW (win)->frame)); | |
| 564 | |
| 1204 | 565 mir->next = update_mirror_internal (XWINDOW (win)->next, mir->next); |
| 428 | 566 mir->hchild = update_mirror_internal (XWINDOW (win)->hchild, mir->hchild); |
| 567 mir->vchild = update_mirror_internal (XWINDOW (win)->vchild, mir->vchild); | |
| 568 | |
| 569 /* | |
| 570 * If the redisplay structs are not empty and the mirror has | |
| 571 * children, then this mirror structure was formerly being used for | |
| 572 * display but is no longer. Reset its current display structs so | |
| 573 * that redisplay doesn't accidentally think they are accurate if it | |
| 574 * is later used for display purposes once again. Also, mark the | |
| 575 * scrollbar instance as not active. | |
| 576 */ | |
| 577 if (mir->vchild || mir->hchild) | |
| 578 { | |
| 579 /* The redisplay structures are big. Leaving them around in | |
| 580 non-leaf windows can add up to a lot of wasted space. So | |
| 581 don't do it. */ | |
| 582 free_display_structs (mir); | |
| 583 mir->current_display_lines = Dynarr_new (display_line); | |
| 584 mir->desired_display_lines = Dynarr_new (display_line); | |
| 585 | |
| 586 #ifdef HAVE_SCROLLBARS | |
| 587 update_window_scrollbars (XWINDOW (win), mir, 0, 0); | |
| 588 #endif | |
| 589 mir->buffer = NULL; | |
| 590 } | |
| 591 | |
| 592 return mir; | |
| 593 } | |
| 594 | |
| 595 /* Given a window mirror, determine which real window it contains the | |
| 596 redisplay structures for. */ | |
| 597 static Lisp_Object | |
| 598 real_window_internal (Lisp_Object win, struct window_mirror *rmir, | |
| 599 struct window_mirror *mir) | |
| 600 { | |
| 601 for (; !NILP (win) && rmir ; win = XWINDOW (win)->next, rmir = rmir->next) | |
| 602 { | |
| 603 if (mir == rmir) | |
| 604 return win; | |
| 605 if (!NILP (XWINDOW (win)->vchild)) | |
| 606 { | |
| 607 Lisp_Object retval = | |
| 608 real_window_internal (XWINDOW (win)->vchild, rmir->vchild, mir); | |
| 609 if (!NILP (retval)) | |
| 610 return retval; | |
| 611 } | |
| 612 if (!NILP (XWINDOW (win)->hchild)) | |
| 613 { | |
| 614 Lisp_Object retval = | |
| 615 real_window_internal (XWINDOW (win)->hchild, rmir->hchild, mir); | |
| 616 if (!NILP (retval)) | |
| 617 return retval; | |
| 618 } | |
| 619 } | |
| 620 | |
| 621 return Qnil; | |
| 622 } | |
| 623 | |
| 624 /* Given a real window, find the mirror structure which contains its | |
| 625 redisplay structures. */ | |
| 626 static struct window_mirror * | |
| 627 find_window_mirror_internal (Lisp_Object win, struct window_mirror *rmir, | |
| 628 struct window *w) | |
| 629 { | |
|
5171
8cd17b2131a1
fix further crash in window-mirror finding
Ben Wing <ben@xemacs.org>
parents:
5170
diff
changeset
|
630 for (; !NILP (win) && rmir; win = XWINDOW (win)->next, rmir = rmir->next) |
| 428 | 631 { |
| 632 if (w == XWINDOW (win)) | |
| 633 return rmir; | |
| 634 | |
| 635 if (!NILP (XWINDOW (win)->vchild)) | |
| 636 { | |
| 637 struct window_mirror *retval = | |
| 638 find_window_mirror_internal (XWINDOW (win)->vchild, | |
| 639 rmir->vchild, w); | |
| 640 if (retval) return retval; | |
| 641 } | |
| 642 | |
| 643 if (!NILP (XWINDOW (win)->hchild)) | |
| 644 { | |
| 645 struct window_mirror *retval = | |
| 646 find_window_mirror_internal (XWINDOW (win)->hchild, | |
| 647 rmir->hchild, w); | |
| 648 if (retval) return retval; | |
| 649 } | |
| 650 } | |
| 651 | |
| 652 return 0; | |
| 653 } | |
| 654 | |
| 655 /* Update the mirror structure for the given frame. */ | |
| 656 void | |
| 657 update_frame_window_mirror (struct frame *f) | |
| 658 { | |
| 617 | 659 f->root_mirror = |
| 660 wrap_window_mirror (update_mirror_internal | |
| 661 (f->root_window, | |
| 662 NILP (f->root_mirror) ? 0 : | |
| 663 XWINDOW_MIRROR (f->root_mirror))); | |
| 428 | 664 f->mirror_dirty = 0; |
| 665 } | |
| 666 | |
| 667 /* Free a given mirror structure along with all of its children as | |
| 668 well as their associated display structures. */ | |
| 669 void | |
| 670 free_window_mirror (struct window_mirror *mir) | |
| 671 { | |
| 672 while (mir) | |
| 673 { | |
| 674 if (mir->hchild) free_window_mirror (mir->hchild); | |
| 675 if (mir->vchild) free_window_mirror (mir->vchild); | |
| 676 #ifdef HAVE_SCROLLBARS | |
| 677 release_window_mirror_scrollbars (mir); | |
| 678 #endif | |
| 679 free_display_structs (mir); | |
| 680 mir = mir->next; | |
|
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5128
diff
changeset
|
681 /* not worth calling free_normal_lisp_object() -- window mirrors |
| 617 | 682 are not created that frequently and it's dangerous. we don't |
| 683 know for sure that there aren't other pointers around -- e.g. | |
| 684 in a scrollbar instance. */ | |
| 428 | 685 } |
| 686 } | |
| 687 | |
| 688 /* Given a mirror structure, return the window it mirrors. Calls | |
| 689 real_window_internal to do most of the work. */ | |
| 690 Lisp_Object | |
| 691 real_window (struct window_mirror *mir, int no_abort) | |
| 692 { | |
| 617 | 693 Lisp_Object retval = |
| 694 real_window_internal (mir->frame->root_window, | |
| 695 XWINDOW_MIRROR (mir->frame->root_mirror), mir); | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
696 assert (!NILP (retval) || no_abort); |
| 428 | 697 |
| 698 return retval; | |
| 699 } | |
| 700 | |
| 701 /* Given a real window, return its mirror structure. Calls | |
| 702 find_window_mirror_internal to do all of the work. */ | |
| 703 struct window_mirror * | |
| 704 find_window_mirror (struct window *w) | |
| 705 { | |
| 706 struct frame *f = XFRAME (w->frame); | |
| 707 if (f->mirror_dirty) | |
| 708 update_frame_window_mirror (f); | |
| 617 | 709 return find_window_mirror_internal (f->root_window, |
| 710 XWINDOW_MIRROR (f->root_mirror), w); | |
| 428 | 711 } |
| 712 | |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
713 /* Given a real window, return its mirror structure, if it exists. |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
714 Don't do any updating. */ |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
715 static struct window_mirror * |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
716 find_window_mirror_maybe (struct window *w) |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
717 { |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
718 struct frame *f = XFRAME (w->frame); |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
719 if (!WINDOW_MIRRORP (f->root_mirror)) |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
720 return 0; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
721 return find_window_mirror_internal (f->root_window, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
722 XWINDOW_MIRROR (f->root_mirror), w); |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
723 } |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
724 |
| 428 | 725 /***************************************************************************** |
| 726 find_window_by_pixel_pos | |
| 727 | |
| 728 Given a pixel position relative to a frame, find the window at that | |
| 729 position. | |
| 730 ****************************************************************************/ | |
| 731 struct window * | |
| 732 find_window_by_pixel_pos (int pix_x, int pix_y, Lisp_Object win) | |
| 733 { | |
| 734 if (NILP (win)) | |
| 735 return 0; | |
| 736 | |
| 737 for (; !NILP (win); win = XWINDOW (win)->next) | |
| 738 { | |
| 739 struct window *w; | |
| 740 | |
| 741 if (!NILP (XWINDOW (win)->vchild)) | |
| 742 { | |
| 743 w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->vchild); | |
| 744 if (w) return w; | |
| 745 } | |
| 746 if (!NILP (XWINDOW (win)->hchild)) | |
| 747 { | |
| 748 w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->hchild); | |
| 749 if (w) return w; | |
| 750 } | |
| 751 w = XWINDOW (win); | |
| 752 if (pix_x >= WINDOW_LEFT (w) | |
| 753 && pix_x <= WINDOW_RIGHT (w) | |
| 754 && pix_y >= WINDOW_TOP (w) | |
| 755 && pix_y <= WINDOW_BOTTOM (w)) | |
| 756 return w; | |
| 757 } | |
| 758 return NULL; | |
| 759 } | |
| 760 | |
| 761 /* Return a pointer to the display structures for the given window. */ | |
| 762 display_line_dynarr * | |
| 763 window_display_lines (struct window *w, int which) | |
| 764 { | |
| 765 struct window_mirror *t; | |
| 766 | |
| 767 t = find_window_mirror (w); | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
768 assert (t); |
| 428 | 769 |
| 770 if (which == CURRENT_DISP) | |
| 771 return t->current_display_lines; | |
| 772 else if (which == DESIRED_DISP) | |
| 773 return t->desired_display_lines; | |
| 774 else if (which == CMOTION_DISP) | |
| 775 /* The CMOTION_DISP display lines are global. */ | |
| 776 return cmotion_display_lines; | |
| 777 else | |
| 2500 | 778 ABORT (); |
| 428 | 779 |
| 780 return 0; /* shut up compiler */ | |
| 781 } | |
| 782 | |
| 783 struct buffer * | |
| 784 window_display_buffer (struct window *w) | |
| 785 { | |
| 786 struct window_mirror *t; | |
| 787 | |
| 788 t = find_window_mirror (w); | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
789 assert (t); |
| 428 | 790 |
| 791 return t->buffer; | |
| 792 } | |
| 793 | |
| 794 void | |
| 795 set_window_display_buffer (struct window *w, struct buffer *b) | |
| 796 { | |
| 797 struct window_mirror *t; | |
| 798 | |
| 799 t = find_window_mirror (w); | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
800 assert (t); |
| 428 | 801 |
| 802 t->buffer = b; | |
| 803 } | |
| 804 | |
| 805 | |
| 806 /* Determining a window's position based solely on its pixel | |
| 807 positioning doesn't work. Instead, we do it the intelligent way, | |
| 808 by checking its positioning in the window hierarchy. */ | |
| 809 int | |
| 810 window_is_leftmost (struct window *w) | |
| 811 { | |
| 812 Lisp_Object parent, current_ancestor, window; | |
| 813 | |
| 793 | 814 window = wrap_window (w); |
| 428 | 815 |
| 816 parent = XWINDOW (window)->parent; | |
| 817 current_ancestor = window; | |
| 818 | |
| 819 while (!NILP (parent)) | |
| 820 { | |
| 821 if (!NILP (XWINDOW (parent)->hchild) && | |
| 822 !EQ (XWINDOW (parent)->hchild, current_ancestor)) | |
| 823 return 0; | |
| 824 | |
| 825 current_ancestor = parent; | |
| 826 parent = XWINDOW (parent)->parent; | |
| 827 } | |
| 828 | |
| 829 return 1; | |
| 830 } | |
| 831 | |
| 832 int | |
| 833 window_is_rightmost (struct window *w) | |
| 834 { | |
| 835 Lisp_Object parent, current_ancestor, window; | |
| 836 | |
| 793 | 837 window = wrap_window (w); |
| 428 | 838 |
| 839 parent = XWINDOW (window)->parent; | |
| 840 current_ancestor = window; | |
| 841 | |
| 842 while (!NILP (parent)) | |
| 843 { | |
| 844 if (!NILP (XWINDOW (parent)->hchild) | |
| 845 && !NILP (XWINDOW (current_ancestor)->next)) | |
| 846 return 0; | |
| 847 | |
| 848 current_ancestor = parent; | |
| 849 parent = XWINDOW (parent)->parent; | |
| 850 } | |
| 851 | |
| 852 return 1; | |
| 853 } | |
| 854 | |
| 855 static int | |
| 856 window_full_width_p (struct window *w) | |
| 857 { | |
| 858 return window_is_leftmost (w) && window_is_rightmost (w); | |
| 859 } | |
| 860 | |
| 861 int | |
| 862 window_is_highest (struct window *w) | |
| 863 { | |
| 864 Lisp_Object parent, current_ancestor, window; | |
| 865 | |
| 793 | 866 window = wrap_window (w); |
| 428 | 867 |
| 868 parent = XWINDOW (window)->parent; | |
| 869 current_ancestor = window; | |
| 870 | |
| 871 while (!NILP (parent)) | |
| 872 { | |
| 873 if (!NILP (XWINDOW (parent)->vchild) && | |
| 874 !EQ (XWINDOW (parent)->vchild, current_ancestor)) | |
| 875 return 0; | |
| 876 | |
| 877 current_ancestor = parent; | |
| 878 parent = XWINDOW (parent)->parent; | |
| 879 } | |
| 880 | |
| 881 /* This is really to catch the minibuffer but we make it generic in | |
| 882 case we ever change things around to let the minibuffer be on top. */ | |
| 883 if (NILP (XWINDOW (current_ancestor)->prev)) | |
| 884 return 1; | |
| 885 else | |
| 886 return 0; | |
| 887 } | |
| 888 | |
| 889 int | |
| 890 window_is_lowest (struct window *w) | |
| 891 { | |
| 892 Lisp_Object parent, current_ancestor, window; | |
| 893 | |
| 793 | 894 window = wrap_window (w); |
| 428 | 895 |
| 896 parent = XWINDOW (window)->parent; | |
| 897 current_ancestor = window; | |
| 898 | |
| 899 while (!NILP (parent)) | |
| 900 { | |
| 901 if (!NILP (XWINDOW (parent)->vchild) | |
| 902 && !NILP (XWINDOW (current_ancestor)->next)) | |
| 903 return 0; | |
| 904 | |
| 905 current_ancestor = parent; | |
| 906 parent = XWINDOW (parent)->parent; | |
| 907 } | |
| 908 | |
| 909 return 1; | |
| 910 } | |
| 911 | |
| 912 #if 0 /* not currently used */ | |
| 913 | |
| 914 static int | |
| 915 window_full_height_p (struct window *w) | |
| 916 { | |
| 917 return window_is_highest (w) && window_is_lowest (w); | |
| 918 } | |
| 919 | |
| 920 #endif | |
| 921 | |
| 922 int | |
| 923 window_truncation_on (struct window *w) | |
| 924 { | |
| 925 /* Minibuffer windows are never truncated. | |
| 440 | 926 #### is this the right way ? */ |
| 428 | 927 if (MINI_WINDOW_P (w)) |
| 928 return 0; | |
| 929 | |
| 930 /* Horizontally scrolled windows are truncated. */ | |
| 931 if (w->hscroll) | |
| 932 return 1; | |
| 933 | |
| 934 /* If truncate_partial_width_windows is true and the window is not | |
| 935 the full width of the frame it is truncated. */ | |
| 707 | 936 if (!NILP (symbol_value_in_buffer (Qtruncate_partial_width_windows, |
| 937 w->buffer)) | |
| 428 | 938 && !(window_is_leftmost (w) && window_is_rightmost (w))) |
| 939 return 1; | |
| 940 | |
| 941 /* If the window's buffer's value of truncate_lines is non-nil, then | |
| 942 the window is truncated. */ | |
| 943 if (!NILP (XBUFFER (w->buffer)->truncate_lines)) | |
| 944 return 1; | |
| 945 | |
| 946 return 0; | |
| 947 } | |
| 948 | |
| 949 DEFUN ("window-truncated-p", Fwindow_truncated_p, 0, 1, 0, /* | |
| 442 | 950 Returns non-nil if text in the window is truncated. |
| 428 | 951 */ |
| 952 (window)) | |
| 953 { | |
| 954 struct window *w = decode_window (window); | |
| 955 | |
| 956 return window_truncation_on (w) ? Qt : Qnil; | |
| 957 } | |
| 958 | |
| 959 | |
| 960 static int | |
| 961 have_undivided_common_edge (struct window *w_right, void *closure) | |
| 962 { | |
| 963 struct window *w_left = (struct window *) closure; | |
| 964 return (WINDOW_RIGHT (w_left) == WINDOW_LEFT (w_right) | |
| 965 && WINDOW_TOP (w_left) < WINDOW_BOTTOM (w_right) | |
| 966 && WINDOW_TOP (w_right) < WINDOW_BOTTOM (w_left) | |
| 967 #ifdef HAVE_SCROLLBARS | |
| 968 && (NILP (w_right->scrollbar_on_left_p) | |
| 969 || NILP (w_right->vertical_scrollbar_visible_p) | |
| 970 || ZEROP (w_right->scrollbar_width)) | |
| 971 #endif | |
| 972 ); | |
| 973 } | |
| 974 | |
| 975 static int | |
| 976 window_needs_vertical_divider_1 (struct window *w) | |
| 977 { | |
| 978 /* Never if we're on the right */ | |
| 979 if (window_is_rightmost (w)) | |
| 980 return 0; | |
| 981 | |
| 982 /* Always if draggable */ | |
| 983 if (!NILP (w->vertical_divider_always_visible_p)) | |
| 984 return 1; | |
| 985 | |
| 986 #ifdef HAVE_SCROLLBARS | |
| 987 /* Our right scrollbar is enough to separate us at the right */ | |
| 988 if (NILP (w->scrollbar_on_left_p) | |
| 989 && !NILP (w->vertical_scrollbar_visible_p) | |
| 990 && !ZEROP (w->scrollbar_width)) | |
| 991 return 0; | |
| 992 #endif | |
| 993 | |
| 994 /* Ok. to determine whether we need a divider on the left, we must | |
| 995 check that our right neighbor windows have scrollbars on their | |
| 996 left sides. We must check all such windows which have common | |
| 997 left edge with our window's right edge. */ | |
| 998 return map_windows (XFRAME (WINDOW_FRAME (w)), | |
| 999 have_undivided_common_edge, (void*)w); | |
| 1000 } | |
| 1001 | |
| 1002 int | |
| 1003 window_needs_vertical_divider (struct window *w) | |
| 1004 { | |
| 1005 if (!w->need_vertical_divider_valid_p) | |
| 1006 { | |
| 1007 w->need_vertical_divider_p = | |
| 1008 window_needs_vertical_divider_1 (w); | |
| 1009 w->need_vertical_divider_valid_p = 1; | |
| 1010 } | |
| 1011 return w->need_vertical_divider_p; | |
| 1012 } | |
| 1013 | |
| 1014 /* Called from invalidate_vertical_divider_cache_in_frame */ | |
| 1015 int | |
| 1016 invalidate_vertical_divider_cache_in_window (struct window *w, | |
| 2286 | 1017 void *UNUSED (unused)) |
| 428 | 1018 { |
| 1019 w->need_vertical_divider_valid_p = 0; | |
| 1020 return 0; | |
| 1021 } | |
| 1022 | |
| 1023 /* Calculate width of vertical divider, including its shadows | |
| 1024 and spacing. The returned value is effectively the distance | |
| 1025 between adjacent window edges. This function does not check | |
| 1026 whether a window needs a vertical divider, so the returned | |
| 1027 value is a "theoretical" one */ | |
| 1028 int | |
| 1029 window_divider_width (struct window *w) | |
| 1030 { | |
| 1031 /* the shadow thickness can be negative. This means that the divider | |
| 1032 will have a depressed look */ | |
| 1033 | |
| 1034 if (FRAME_WIN_P (XFRAME (WINDOW_FRAME (w)))) | |
| 1035 return | |
| 1036 XINT (w->vertical_divider_line_width) | |
| 1037 + 2 * XINT (w->vertical_divider_spacing) | |
| 1038 + 2 * abs (XINT (w->vertical_divider_shadow_thickness)); | |
| 1039 else | |
| 1040 return XINT (w->vertical_divider_line_width) == 0 ? 0 : 1; | |
| 1041 } | |
| 1042 | |
| 1043 int | |
| 4932 | 1044 window_scrollbar_width (struct window * USED_IF_SCROLLBARS (w)) |
| 428 | 1045 { |
| 1046 #ifdef HAVE_SCROLLBARS | |
| 1047 if (!WINDOW_WIN_P (w) | |
| 1048 || MINI_WINDOW_P (w) | |
| 1049 || NILP (w->buffer) | |
| 1050 || NILP (w->vertical_scrollbar_visible_p)) | |
| 1051 /* #### when does NILP (w->buffer) happen? */ | |
| 1052 return 0; | |
| 1053 | |
| 1054 return XINT (w->scrollbar_width); | |
| 1055 #else | |
| 1056 return 0; | |
| 1057 #endif /* HAVE_SCROLLBARS */ | |
| 1058 } | |
| 1059 | |
| 1060 /* Horizontal scrollbars are only active on windows with truncation | |
| 1061 turned on. */ | |
| 1062 int | |
| 4932 | 1063 window_scrollbar_height (struct window * USED_IF_SCROLLBARS (w)) |
| 428 | 1064 { |
| 1065 #ifdef HAVE_SCROLLBARS | |
| 1066 if (!WINDOW_WIN_P (w) | |
| 1067 || MINI_WINDOW_P (w) | |
| 1068 || NILP (w->buffer) | |
| 1069 || NILP (w->horizontal_scrollbar_visible_p) | |
| 1070 || !window_truncation_on (w)) | |
| 1071 return 0; | |
| 1072 | |
| 1073 return XINT (w->scrollbar_height); | |
| 1074 #else | |
| 1075 return 0; | |
| 1076 #endif /* HAVE_SCROLLBARS */ | |
| 1077 } | |
| 1078 | |
| 1079 int | |
| 1080 window_modeline_height (struct window *w) | |
| 1081 { | |
| 1082 struct frame *f = XFRAME (w->frame); | |
| 1083 int modeline_height; | |
| 1084 | |
| 1085 if (MINI_WINDOW_P (w) || NILP (w->buffer)) | |
| 1086 { | |
| 1087 modeline_height = 0; | |
| 1088 } | |
| 1089 else if (!WINDOW_HAS_MODELINE_P (w)) | |
| 1090 { | |
| 1091 if (window_scrollbar_height (w)) | |
| 1092 modeline_height = 0; | |
| 1093 else | |
| 1094 { | |
| 1095 modeline_height = FRAMEMETH (f, divider_height, ()); | |
| 1096 | |
| 1097 if (!EQ (Qzero, w->modeline_shadow_thickness) && FRAME_WIN_P (f)) | |
| 1098 modeline_height += (2 * MODELINE_SHADOW_THICKNESS (w)); | |
| 1099 } | |
| 1100 } | |
| 1101 else | |
| 1102 { | |
| 1103 if (noninteractive) | |
| 1104 modeline_height = 0; | |
| 1105 else | |
| 1106 { | |
| 1107 display_line_dynarr *dla; | |
| 1108 | |
| 1109 /* We don't force a regeneration of the modeline here. | |
| 1110 Instead it is now a precondition that any function calling | |
| 1111 this should make sure that one of these structures is | |
| 1112 up-to-date. In practice this only affects two internal | |
| 1113 redisplay functions, regenerate_window and | |
| 1114 regenerate_window_point_center. */ | |
| 1115 /* We check DESIRED_DISP because if it is valid it is more | |
| 1116 up-to-date than CURRENT_DISP. For calls to this outside | |
| 1117 of redisplay it doesn't matter which structure we check | |
| 1118 since there is a redisplay condition that these | |
| 1119 structures be identical outside of redisplay. */ | |
| 1120 dla = window_display_lines (w, DESIRED_DISP); | |
| 4967 | 1121 if (dla && Dynarr_length (dla) && Dynarr_begin (dla)->modeline) |
| 1122 modeline_height = (Dynarr_begin (dla)->ascent + | |
| 1123 Dynarr_begin (dla)->descent); | |
| 428 | 1124 else |
| 1125 { | |
| 1126 dla = window_display_lines (w, CURRENT_DISP); | |
| 4967 | 1127 if (dla && Dynarr_length (dla) && Dynarr_begin (dla)->modeline) |
| 1128 modeline_height = (Dynarr_begin (dla)->ascent + | |
| 1129 Dynarr_begin (dla)->descent); | |
| 428 | 1130 else |
| 1131 /* This should be an abort except I'm not yet 100% | |
| 1132 confident that it won't ever get hit (though I | |
| 1133 haven't been able to trigger it). It is extremely | |
| 1134 unlikely to cause any noticeable problem and even if | |
| 1135 it does it will be a minor display glitch. */ | |
| 1136 /* #### Bullshit alert. It does get hit and it causes | |
| 1137 noticeable glitches. real_current_modeline_height | |
| 1138 is a kludge to fix this for 19.14. */ | |
| 1139 modeline_height = real_current_modeline_height (w); | |
| 1140 } | |
| 1141 | |
| 1142 if (!EQ (Qzero, w->modeline_shadow_thickness) && FRAME_WIN_P (f)) | |
| 1143 modeline_height += (2 * MODELINE_SHADOW_THICKNESS (w)); | |
| 1144 } | |
| 1145 } | |
| 1146 | |
| 1147 return modeline_height; | |
| 1148 } | |
| 1149 | |
| 1150 /***************************************************************************** | |
| 1151 margin_width_internal | |
| 1152 | |
| 1153 For a given window, return the width in pixels of the specified margin. | |
| 1154 ****************************************************************************/ | |
| 1155 static int | |
| 1156 margin_width_internal (struct window *w, int left_margin) | |
| 1157 { | |
| 1158 int window_cwidth = window_char_width (w, 1); | |
| 1159 int margin_cwidth; | |
| 1160 int font_width; | |
| 1161 Lisp_Object window; | |
| 1162 | |
| 1163 /* We might be getting called on a non-leaf. */ | |
| 1164 if (NILP (w->buffer)) | |
| 1165 return 0; | |
| 1166 | |
| 1167 /* The minibuffer never has margins. */ | |
| 1168 if (MINI_WINDOW_P (w)) | |
| 1169 return 0; | |
| 1170 | |
| 793 | 1171 window = wrap_window (w); |
| 428 | 1172 margin_cwidth = (left_margin ? XINT (w->left_margin_width) : |
| 1173 XINT (w->right_margin_width)); | |
| 1174 | |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1175 default_face_width_and_height (window, &font_width, 0); |
| 428 | 1176 |
| 1177 /* The left margin takes precedence over the right margin so we | |
| 1178 subtract its width from the space available for the right | |
| 1179 margin. */ | |
| 1180 if (!left_margin) | |
| 1181 window_cwidth -= XINT (w->left_margin_width); | |
| 1182 | |
| 1183 /* The margin cannot be wider than the window is. We allow the | |
| 1184 value to be bigger since it is possible for the user to enlarge | |
| 1185 the window such that the left margin value would no longer be too | |
| 1186 big, but we won't return a value that is larger. */ | |
| 1187 if (margin_cwidth > window_cwidth) | |
| 1188 margin_cwidth = window_cwidth; | |
| 1189 | |
| 1190 /* At the user level the margin is always specified in characters. | |
| 1191 Internally however it is manipulated in terms of pixels. */ | |
| 1192 return margin_cwidth * font_width; | |
| 1193 } | |
| 1194 | |
| 1195 int | |
| 1196 window_left_margin_width (struct window *w) | |
| 1197 { | |
| 1198 return margin_width_internal (w, 1); | |
| 1199 } | |
| 1200 | |
| 1201 int | |
| 1202 window_right_margin_width (struct window *w) | |
| 1203 { | |
| 1204 return margin_width_internal (w, 0); | |
| 1205 } | |
| 1206 | |
| 1207 /***************************************************************************** | |
| 1208 Window Gutters | |
| 1209 | |
| 1210 The gutters of a window are those areas in the boundary defined by | |
| 1211 w->pixel_top, w->pixel_left, w->pixel_height and w->pixel_width which | |
| 1212 do not contain text. Items which may be in the gutters include | |
| 1213 scrollbars, toolbars and modelines. The margin areas are not | |
| 1214 included. This is an exception made because redisplay special cases | |
| 1215 the handling of those areas in many places in such a way that | |
| 1216 including them in the gutter area would make life difficult. | |
| 1217 | |
| 1218 The size functions refer to height for the bottom and top gutters and | |
| 1219 width for the left and right gutters. The starting position | |
| 1220 functions refer to the Y coord for bottom and top gutters and the X | |
| 1221 coord for left and right gutters. All starting positions are | |
| 1222 relative to the frame, not the window. | |
| 1223 ****************************************************************************/ | |
| 1224 | |
| 442 | 1225 static int |
| 1226 window_top_window_gutter_height (struct window *w) | |
| 1227 { | |
| 428 | 1228 if (!NILP (w->hchild) || !NILP (w->vchild)) |
| 1229 return 0; | |
| 1230 | |
| 1231 #ifdef HAVE_SCROLLBARS | |
| 1232 if (!NILP (w->scrollbar_on_top_p)) | |
| 442 | 1233 return window_scrollbar_height (w); |
| 428 | 1234 else |
| 1235 #endif | |
| 442 | 1236 return 0; |
| 428 | 1237 } |
| 1238 | |
| 1239 int | |
| 442 | 1240 window_top_gutter_height (struct window *w) |
| 1241 { | |
| 1242 return window_top_window_gutter_height (w); | |
| 1243 } | |
| 1244 | |
| 1245 static int | |
| 1246 window_bottom_window_gutter_height (struct window *w) | |
| 1247 { | |
| 1248 int gutter; | |
| 428 | 1249 |
| 1250 if (!NILP (w->hchild) || !NILP (w->vchild)) | |
| 1251 return 0; | |
| 1252 | |
| 442 | 1253 gutter = window_modeline_height (w); |
| 428 | 1254 |
| 1255 #ifdef HAVE_SCROLLBARS | |
| 1256 if (NILP (w->scrollbar_on_top_p)) | |
| 1257 return window_scrollbar_height (w) + gutter; | |
| 1258 else | |
| 1259 #endif | |
| 1260 return gutter; | |
| 1261 } | |
| 1262 | |
| 1263 int | |
| 442 | 1264 window_bottom_gutter_height (struct window *w) |
| 1265 { | |
| 1266 return window_bottom_window_gutter_height (w); | |
| 1267 } | |
| 1268 | |
| 1269 static int | |
| 4932 | 1270 window_left_window_gutter_width (struct window *w, |
| 1271 int USED_IF_SCROLLBARS (modeline)) | |
| 442 | 1272 { |
| 428 | 1273 if (!NILP (w->hchild) || !NILP (w->vchild)) |
| 1274 return 0; | |
| 1275 | |
| 1276 #ifdef HAVE_SCROLLBARS | |
| 1277 if (!modeline && !NILP (w->scrollbar_on_left_p)) | |
| 442 | 1278 return window_scrollbar_width (w); |
| 428 | 1279 #endif |
| 1280 | |
| 442 | 1281 return 0; |
| 428 | 1282 } |
| 1283 | |
| 1284 int | |
| 442 | 1285 window_left_gutter_width (struct window *w, int modeline) |
| 1286 { | |
| 1287 return window_left_window_gutter_width (w, modeline); | |
| 1288 } | |
| 1289 | |
| 1290 static int | |
| 4932 | 1291 window_right_window_gutter_width (struct window *w, |
| 1292 int USED_IF_SCROLLBARS (modeline)) | |
| 442 | 1293 { |
| 1294 int gutter = 0; | |
| 428 | 1295 |
| 1296 if (!NILP (w->hchild) || !NILP (w->vchild)) | |
| 1297 return 0; | |
| 1298 | |
| 1299 #ifdef HAVE_SCROLLBARS | |
| 1300 if (!modeline && NILP (w->scrollbar_on_left_p)) | |
| 1301 gutter += window_scrollbar_width (w); | |
| 1302 #endif | |
| 1303 | |
| 1304 if (window_needs_vertical_divider (w)) | |
| 1305 gutter += window_divider_width (w); | |
| 1306 | |
| 1307 return gutter; | |
| 1308 } | |
| 1309 | |
| 442 | 1310 int |
| 1311 window_right_gutter_width (struct window *w, int modeline) | |
| 1312 { | |
| 1313 return window_right_window_gutter_width (w, modeline); | |
| 1314 } | |
| 1315 | |
| 1316 static int | |
| 1317 window_pixel_height (struct window* w) | |
| 1318 { | |
| 1319 return WINDOW_HEIGHT (w); | |
| 1320 } | |
| 1321 | |
| 428 | 1322 |
| 1323 DEFUN ("windowp", Fwindowp, 1, 1, 0, /* | |
| 444 | 1324 Return t if OBJECT is a window. |
| 428 | 1325 */ |
| 444 | 1326 (object)) |
| 1327 { | |
| 1328 return WINDOWP (object) ? Qt : Qnil; | |
| 428 | 1329 } |
| 1330 | |
| 1331 DEFUN ("window-live-p", Fwindow_live_p, 1, 1, 0, /* | |
| 444 | 1332 Return t if OBJECT is a window which is currently visible. |
| 428 | 1333 */ |
| 444 | 1334 (object)) |
| 1335 { | |
| 1336 return WINDOWP (object) && WINDOW_LIVE_P (XWINDOW (object)) | |
| 1337 ? Qt : Qnil; | |
| 428 | 1338 } |
| 1339 | |
| 1340 DEFUN ("selected-window", Fselected_window, 0, 1, 0, /* | |
| 1341 Return the window that the cursor now appears in and commands apply to. | |
| 1342 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, return | |
| 1343 the selected window used by that frame. If CON-DEV-OR-FRAME is a device, | |
| 1344 then the selected frame on that device will be used. If CON-DEV-OR-FRAME | |
| 1345 is a console, the selected frame on that console's selected device will | |
| 1346 be used. Otherwise, the selected frame is used. | |
| 1347 */ | |
| 1348 (con_dev_or_frame)) | |
| 1349 { | |
| 1350 if (NILP (con_dev_or_frame) && NILP (Fselected_device (Qnil))) | |
| 1351 return Qnil; /* happens at startup */ | |
| 1352 | |
| 1353 { | |
| 1354 struct frame *f = decode_frame_or_selected (con_dev_or_frame); | |
| 1355 return FRAME_SELECTED_WINDOW (f); | |
| 1356 } | |
| 1357 } | |
| 1358 | |
| 1359 DEFUN ("last-nonminibuf-window", Flast_nonminibuf_window, 0, 1, 0, /* | |
| 1360 Return the last selected window that is not a minibuffer window. | |
| 1361 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, | |
| 1362 return the last non-minibuffer window used by that frame. If | |
| 1363 CON-DEV-OR-FRAME is a device, then the selected frame on that device | |
| 1364 will be used. If CON-DEV-OR-FRAME is a console, the selected frame on | |
| 1365 that console's selected device will be used. Otherwise, the selected | |
| 1366 frame is used. | |
| 1367 */ | |
| 1368 (con_dev_or_frame)) | |
| 1369 { | |
| 1370 if (NILP (con_dev_or_frame) && NILP (Fselected_device (Qnil))) | |
| 1371 return Qnil; /* happens at startup */ | |
| 1372 | |
| 1373 { | |
| 1374 struct frame *f = decode_frame_or_selected (con_dev_or_frame); | |
| 1375 return FRAME_LAST_NONMINIBUF_WINDOW (f); | |
| 1376 } | |
| 1377 } | |
| 1378 | |
| 1379 DEFUN ("minibuffer-window", Fminibuffer_window, 0, 1, 0, /* | |
| 1380 Return the window used now for minibuffers. | |
| 1381 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, return | |
| 1382 the minibuffer window used by that frame. If CON-DEV-OR-FRAME is a device, | |
| 1383 then the selected frame on that device will be used. If CON-DEV-OR-FRAME | |
| 1384 is a console, the selected frame on that console's selected device will | |
| 1385 be used. Otherwise, the selected frame is used. | |
| 1386 */ | |
| 1387 (con_dev_or_frame)) | |
| 1388 { | |
| 1389 return FRAME_MINIBUF_WINDOW (decode_frame_or_selected (con_dev_or_frame)); | |
| 1390 } | |
| 1391 | |
| 438 | 1392 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 0, 1, 0, /* |
| 428 | 1393 Return non-nil if WINDOW is a minibuffer window. |
| 1394 */ | |
| 1395 (window)) | |
| 1396 { | |
| 1397 return MINI_WINDOW_P (decode_window (window)) ? Qt : Qnil; | |
| 1398 } | |
| 1399 | |
| 1400 DEFUN ("window-first-hchild", Fwindow_first_hchild, 1, 1, 0, /* | |
| 1401 Return the first horizontal child of WINDOW, or nil. | |
| 1402 */ | |
| 1403 (window)) | |
| 1404 { | |
| 1405 return decode_window (window)->hchild; | |
| 1406 } | |
| 1407 | |
| 1408 DEFUN ("window-first-vchild", Fwindow_first_vchild, 1, 1, 0, /* | |
| 1409 Return the first vertical child of WINDOW, or nil. | |
| 1410 */ | |
| 1411 (window)) | |
| 1412 { | |
| 1413 return decode_window (window)->vchild; | |
| 1414 } | |
| 1415 | |
| 1416 DEFUN ("window-next-child", Fwindow_next_child, 1, 1, 0, /* | |
| 1417 Return the next window on the same level as WINDOW, or nil. | |
| 1418 */ | |
| 1419 (window)) | |
| 1420 { | |
| 1421 return decode_window (window)->next; | |
| 1422 } | |
| 1423 | |
| 1424 DEFUN ("window-previous-child", Fwindow_previous_child, 1, 1, 0, /* | |
| 1425 Return the previous window on the same level as WINDOW, or nil. | |
| 1426 */ | |
| 1427 (window)) | |
| 1428 { | |
| 1429 return decode_window (window)->prev; | |
| 1430 } | |
| 1431 | |
| 1432 DEFUN ("window-parent", Fwindow_parent, 1, 1, 0, /* | |
| 1433 Return the parent of WINDOW, or nil. | |
| 1434 */ | |
| 1435 (window)) | |
| 1436 { | |
| 1437 return decode_window (window)->parent; | |
| 1438 } | |
| 1439 | |
| 1440 DEFUN ("window-lowest-p", Fwindow_lowest_p, 1, 1, 0, /* | |
| 1441 Return non-nil if WINDOW is along the bottom of its frame. | |
| 1442 */ | |
| 1443 (window)) | |
| 1444 { | |
| 1445 return window_is_lowest (decode_window (window)) ? Qt : Qnil; | |
| 1446 } | |
| 1447 | |
| 1448 DEFUN ("window-highest-p", Fwindow_highest_p, 1, 1, 0, /* | |
| 1449 Return non-nil if WINDOW is along the top of its frame. | |
| 1450 */ | |
| 1451 (window)) | |
| 1452 { | |
| 1453 return window_is_highest (decode_window (window)) ? Qt : Qnil; | |
| 1454 } | |
| 1455 | |
| 1456 DEFUN ("window-leftmost-p", Fwindow_leftmost_p, 1, 1, 0, /* | |
| 1457 Return non-nil if WINDOW is along the left edge of its frame. | |
| 1458 */ | |
| 1459 (window)) | |
| 1460 { | |
| 1461 return window_is_leftmost (decode_window (window)) ? Qt : Qnil; | |
| 1462 } | |
| 1463 | |
| 1464 DEFUN ("window-rightmost-p", Fwindow_rightmost_p, 1, 1, 0, /* | |
| 1465 Return non-nil if WINDOW is along the right edge of its frame. | |
| 1466 */ | |
| 1467 (window)) | |
| 1468 { | |
| 1469 return window_is_rightmost (decode_window (window)) ? Qt : Qnil; | |
| 1470 } | |
| 1471 | |
| 1708 | 1472 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, 0, 3, 0, /* |
| 1473 Returns t if position POS is currently on the frame in WINDOW. | |
| 428 | 1474 Returns nil if that position is scrolled vertically out of view. |
| 1708 | 1475 If a character is only partially visible, nil is returned, unless the |
| 1476 optional argument PARTIALLY is non-nil. | |
| 428 | 1477 POS defaults to point in WINDOW's buffer; WINDOW, to the selected window. |
| 1478 */ | |
| 1708 | 1479 (pos, window, partially)) |
| 428 | 1480 { |
| 1481 struct window *w = decode_window (window); | |
| 665 | 1482 Charbpos top = marker_position (w->start[CURRENT_DISP]); |
| 1483 Charbpos posint; | |
| 428 | 1484 struct buffer *buf = XBUFFER (w->buffer); |
| 1485 | |
| 1486 if (NILP (pos)) | |
| 1487 posint = BUF_PT (buf); | |
| 1488 else | |
| 1489 { | |
| 1490 CHECK_INT_COERCE_MARKER (pos); | |
| 1491 posint = XINT (pos); | |
| 1492 } | |
| 1493 | |
| 1494 if (posint < top || posint > BUF_ZV (buf)) | |
| 1495 return Qnil; | |
| 1496 | |
| 1497 /* w->start can be out of range. If it is, do something reasonable. */ | |
| 1498 if (top < BUF_BEGV (buf) || top > BUF_ZV (buf)) | |
| 1499 return Qnil; | |
| 1500 | |
| 1708 | 1501 return point_would_be_visible (w, top, posint, !NILP (partially)) |
| 1502 ? Qt : Qnil; | |
| 428 | 1503 } |
| 1504 | |
| 1505 | |
| 1506 struct window * | |
| 1507 decode_window (Lisp_Object window) | |
| 1508 { | |
| 1509 if (NILP (window)) | |
| 1510 return XWINDOW (Fselected_window (Qnil)); | |
| 1511 | |
| 1512 CHECK_LIVE_WINDOW (window); | |
| 1513 return XWINDOW (window); | |
| 1514 } | |
| 1515 | |
| 872 | 1516 int |
| 1517 window_live_p (struct window *w) | |
| 1518 { | |
| 1519 return WINDOW_LIVE_P (w); | |
| 1520 } | |
| 1521 | |
| 1522 Lisp_Object | |
| 1523 window_frame (struct window *w) | |
| 1524 { | |
| 1525 return WINDOW_FRAME (w); | |
| 1526 } | |
| 1527 | |
| 1528 Lisp_Object | |
| 1529 window_buffer (struct window *w) | |
| 1530 { | |
| 1531 return WINDOW_BUFFER (w); | |
| 1532 } | |
| 1533 | |
| 428 | 1534 DEFUN ("window-buffer", Fwindow_buffer, 0, 1, 0, /* |
| 1535 Return the buffer that WINDOW is displaying. | |
| 1536 */ | |
| 1537 (window)) | |
| 1538 { | |
| 1539 return decode_window (window)->buffer; | |
| 1540 } | |
| 1541 | |
| 1542 DEFUN ("window-frame", Fwindow_frame, 0, 1, 0, /* | |
| 1543 Return the frame that window WINDOW is on. | |
| 1544 */ | |
| 1545 (window)) | |
| 1546 { | |
| 1547 return decode_window (window)->frame; | |
| 1548 } | |
| 1549 | |
| 1550 DEFUN ("window-height", Fwindow_height, 0, 1, 0, /* | |
| 1551 Return the number of default lines in WINDOW. | |
| 1552 This actually works by dividing the window's pixel height (including | |
| 1553 the modeline and horizontal scrollbar, if any) by the height of the | |
| 1554 default font; therefore, the number of displayed lines will probably | |
| 1555 be different. | |
| 1556 Use `window-height' to get consistent results in geometry calculations. | |
| 1557 Use `window-displayed-height' to get the actual number of lines | |
| 1558 currently displayed in a window. | |
| 442 | 1559 |
| 1560 The names are somewhat confusing; here's a table to help out: | |
| 1561 | |
| 1562 width height | |
| 1563 ------------------------------------------------------------------------- | |
| 1564 w/o gutters | |
| 1565 (rows/columns) window-width window-text-area-height | |
| 1566 (pixels) window-text-area-pixel-width window-text-area-pixel-height | |
| 1567 | |
| 1568 with gutters | |
| 1569 (rows/columns) window-full-width window-height | |
| 1570 (pixels) window-pixel-width window-pixel-height | |
| 1571 | |
| 1572 actually displayed | |
| 1573 (rows/columns) ---- window-displayed-height | |
| 1574 (pixels) ---- window-displayed-text-pixel-height | |
| 428 | 1575 */ |
| 1576 (window)) | |
| 1577 { | |
| 1578 return make_int (window_char_height (decode_window (window), 1)); | |
| 1579 } | |
| 1580 | |
| 1581 DEFUN ("window-displayed-height", Fwindow_displayed_height, 0, 1, 0, /* | |
| 1582 Return the number of lines currently displayed in WINDOW. | |
| 1583 This counts the actual number of lines displayed in WINDOW | |
| 1584 \(as opposed to `window-height'). The modeline and horizontal | |
| 1585 scrollbar do not count as lines. If there is some blank space | |
| 1586 between the end of the buffer and the end of the window, this | |
| 1587 function pretends that there are lines of text in the default | |
| 1588 font there. | |
| 1589 */ | |
| 1590 (window)) | |
| 1591 { | |
| 1592 return make_int (window_displayed_height (decode_window (window))); | |
| 1593 } | |
| 1594 | |
| 1595 DEFUN ("window-pixel-height", Fwindow_pixel_height, 0, 1, 0, /* | |
| 1596 Return the height of WINDOW in pixels. Defaults to current window. | |
| 1597 This includes the window's modeline and horizontal scrollbar (if any). | |
| 1598 */ | |
| 1599 (window)) | |
| 1600 { | |
| 442 | 1601 return make_int (window_pixel_height (decode_window (window))); |
| 1602 } | |
| 1603 | |
| 1604 DEFUN ("window-text-area-height", Fwindow_text_area_height, 0, 1, 0, /* | |
| 1605 Return the number of default lines in the text area of WINDOW. | |
| 1606 This actually works by dividing the window's text area pixel height (i.e. | |
| 1607 excluding the modeline and horizontal scrollbar, if any) by the height of the | |
| 1608 default font; therefore, the number of displayed lines will probably | |
| 1609 be different. | |
| 1610 See also `window-height' and `window-displayed-height'. | |
| 1611 */ | |
| 1612 (window)) | |
| 1613 { | |
| 1614 return make_int (window_char_height (decode_window (window), 0)); | |
| 428 | 1615 } |
| 1616 | |
| 1617 DEFUN ("window-text-area-pixel-height", | |
| 1618 Fwindow_text_area_pixel_height, 0, 1, 0, /* | |
| 1619 Return the height in pixels of the text-displaying portion of WINDOW. | |
| 1620 Unlike `window-pixel-height', the space occupied by the modeline and | |
| 1621 horizontal scrollbar, if any, is not counted. | |
| 1622 */ | |
| 1623 (window)) | |
| 1624 { | |
| 1625 struct window *w = decode_window (window); | |
| 1626 | |
| 1627 return make_int (WINDOW_TEXT_HEIGHT (w)); | |
| 1628 } | |
| 1629 | |
| 1630 DEFUN ("window-displayed-text-pixel-height", | |
| 1631 Fwindow_displayed_text_pixel_height, 0, 2, 0, /* | |
| 1632 Return the height in pixels of the text displayed in WINDOW. | |
| 1633 Unlike `window-text-area-pixel-height', any blank space below the | |
| 1634 end of the buffer is not included. If optional argument NOCLIPPED | |
| 1635 is non-nil, do not include space occupied by clipped lines. | |
| 1636 */ | |
| 1637 (window, noclipped)) | |
| 1638 { | |
| 1639 struct window *w; | |
| 665 | 1640 Charbpos start, eobuf; |
| 428 | 1641 int defheight; |
| 1642 int hlimit, height, prev_height = -1; | |
| 1643 int line; | |
| 1644 int elt, nelt, i; | |
| 1645 int needed; | |
| 1646 line_start_cache_dynarr *cache; | |
| 1647 | |
| 1648 if (NILP (window)) | |
| 1649 window = Fselected_window (Qnil); | |
| 1650 | |
| 1651 CHECK_LIVE_WINDOW (window); | |
| 1652 w = XWINDOW (window); | |
| 1653 | |
| 1654 start = marker_position (w->start[CURRENT_DISP]); | |
| 1655 hlimit = WINDOW_TEXT_HEIGHT (w); | |
| 1656 eobuf = BUF_ZV (XBUFFER (w->buffer)); | |
| 1657 | |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1658 default_face_width_and_height (window, NULL, &defheight); |
| 428 | 1659 |
| 1660 /* guess lines needed in line start cache + a few extra */ | |
| 1661 needed = (hlimit + defheight-1) / defheight + 3; | |
| 1662 | |
| 1663 while (1) { | |
| 1664 elt = point_in_line_start_cache (w, start, needed); | |
| 1665 assert (elt >= 0); /* in the cache */ | |
| 1666 | |
| 1667 cache = w->line_start_cache; | |
| 1668 nelt = Dynarr_length (cache); | |
| 1669 | |
| 1670 height = 0; | |
| 1671 for (i = elt; i < nelt; i++) { | |
| 1672 line = Dynarr_atp (cache, i)->height; | |
| 1673 | |
| 1674 if (height + line > hlimit) | |
| 1675 return make_int (!NILP (noclipped) ? height : hlimit); | |
| 1676 | |
| 1677 height += line; | |
| 1678 | |
| 1679 if (height == hlimit || Dynarr_atp (cache, i)->end >= eobuf) | |
| 1680 return make_int (height); | |
| 1681 } | |
| 1682 | |
| 1683 /* get here => need more cache lines. try again. */ | |
| 1684 assert(height > prev_height); /* progress? */ | |
| 1685 prev_height = height; | |
| 1686 | |
| 1687 needed += ((hlimit - height)*(nelt - elt) + height-1)/height + 3; | |
| 1688 } | |
| 1689 | |
| 1204 | 1690 RETURN_NOT_REACHED(make_int (0)); /* shut up compiler */ |
| 428 | 1691 } |
| 1692 | |
| 1693 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /* | |
| 1694 Return the number of display columns in WINDOW. | |
| 442 | 1695 This is the width that is usable columns available for text in WINDOW, |
| 1696 and does not include vertical scrollbars, dividers, or the like. See also | |
| 1697 `window-full-width' and `window-height'. | |
| 428 | 1698 */ |
| 1699 (window)) | |
| 1700 { | |
| 1701 return make_int (window_char_width (decode_window (window), 0)); | |
| 1702 } | |
| 1703 | |
| 442 | 1704 DEFUN ("window-full-width", Fwindow_full_width, 0, 1, 0, /* |
| 1705 Return the total number of columns in WINDOW. | |
| 1706 This is like `window-width' but includes vertical scrollbars, dividers, | |
| 1707 etc. | |
| 1708 */ | |
| 1709 (window)) | |
| 1710 { | |
| 1711 return make_int (window_char_width (decode_window (window), 1)); | |
| 1712 } | |
| 1713 | |
| 428 | 1714 DEFUN ("window-pixel-width", Fwindow_pixel_width, 0, 1, 0, /* |
| 1715 Return the width of WINDOW in pixels. Defaults to current window. | |
| 1716 */ | |
| 1717 (window)) | |
| 1718 { | |
| 1719 return make_int (decode_window (window)->pixel_width); | |
| 1720 } | |
| 1721 | |
| 1722 DEFUN ("window-text-area-pixel-width", | |
| 1723 Fwindow_text_area_pixel_width, 0, 1, 0, /* | |
| 1724 Return the width in pixels of the text-displaying portion of WINDOW. | |
| 1725 Unlike `window-pixel-width', the space occupied by the vertical | |
| 1726 scrollbar or divider, if any, is not counted. | |
| 1727 */ | |
| 1728 (window)) | |
| 1729 { | |
| 1730 struct window *w = decode_window (window); | |
| 1731 | |
| 1732 return make_int (WINDOW_TEXT_WIDTH (w)); | |
| 1733 } | |
| 1734 | |
| 1735 DEFUN ("window-hscroll", Fwindow_hscroll, 0, 1, 0, /* | |
| 1736 Return the number of columns by which WINDOW is scrolled from left margin. | |
| 1737 */ | |
| 1738 (window)) | |
| 1739 { | |
| 1740 return make_int (decode_window (window)->hscroll); | |
| 1741 } | |
| 1742 | |
| 1743 DEFUN ("modeline-hscroll", Fmodeline_hscroll, 0, 1, 0, /* | |
| 442 | 1744 Return the horizontal scrolling amount of WINDOW's modeline. |
| 438 | 1745 If the window has no modeline, return nil. |
| 428 | 1746 */ |
| 1747 (window)) | |
| 1748 { | |
| 1749 struct window *w = decode_window (window); | |
| 1750 | |
| 438 | 1751 return (WINDOW_HAS_MODELINE_P (w)) ? make_int ((int) w->modeline_hscroll) : |
| 1752 Qnil; | |
| 428 | 1753 } |
| 1754 | |
| 1755 DEFUN ("set-modeline-hscroll", Fset_modeline_hscroll, 2, 2, 0, /* | |
| 442 | 1756 Set the horizontal scrolling amount of WINDOW's modeline to NCOL. |
| 438 | 1757 If NCOL is negative, it will silently be forced to 0. |
| 1758 If the window has no modeline, return nil. Otherwise, return the actual | |
| 1759 value that was set. | |
| 428 | 1760 */ |
| 1761 (window, ncol)) | |
| 1762 { | |
| 1763 struct window *w = decode_window (window); | |
| 1764 | |
| 1765 if (WINDOW_HAS_MODELINE_P (w)) | |
| 1766 { | |
| 438 | 1767 Charcount ncols; |
| 1768 | |
| 428 | 1769 CHECK_INT (ncol); |
| 438 | 1770 ncols = (XINT (ncol) <= 0) ? 0 : (Charcount) XINT (ncol); |
| 1771 if (ncols != w->modeline_hscroll) | |
| 1772 { | |
| 1773 MARK_MODELINE_CHANGED; | |
| 1774 w->modeline_hscroll = ncols; | |
| 1775 } | |
| 1776 return make_int ((int) ncols); | |
| 428 | 1777 } |
| 438 | 1778 |
| 428 | 1779 return Qnil; |
| 1780 } | |
| 1781 | |
| 1782 DEFUN ("set-window-hscroll", Fset_window_hscroll, 2, 2, 0, /* | |
| 1783 Set number of columns WINDOW is scrolled from left margin to NCOL. | |
| 1784 NCOL should be zero or positive. | |
| 1785 */ | |
| 1786 (window, ncol)) | |
| 1787 { | |
| 1788 struct window *w; | |
| 1789 int ncols; | |
| 1790 | |
| 1791 CHECK_INT (ncol); | |
| 1792 ncols = XINT (ncol); | |
| 1793 if (ncols < 0) ncols = 0; | |
| 1794 w = decode_window (window); | |
| 1795 if (w->hscroll != ncols) | |
| 1796 MARK_CLIP_CHANGED; /* FSF marks differently but we aren't FSF. */ | |
| 1797 w->hscroll = ncols; | |
| 1798 return ncol; | |
| 1799 } | |
| 1800 | |
| 1801 DEFUN ("window-pixel-edges", Fwindow_pixel_edges, 0, 1, 0, /* | |
| 1802 Return a list of the pixel edge coordinates of WINDOW. | |
| 444 | 1803 The returned list is of the form (LEFT TOP RIGHT BOTTOM), |
| 1804 all relative to 0, 0 at the top left corner of WINDOW's frame. | |
| 1805 The frame toolbars, menubars and gutters are considered to be outside | |
| 1806 of this area, while the scrollbars are considered to be inside. | |
| 428 | 1807 */ |
| 1808 (window)) | |
| 1809 { | |
| 1810 struct window *w = decode_window (window); | |
| 1811 struct frame *f = XFRAME (w->frame); | |
| 1812 | |
| 5090 | 1813 int left = w->pixel_left - FRAME_PANED_LEFT_EDGE (f); |
| 1814 int top = w->pixel_top - FRAME_PANED_TOP_EDGE (f); | |
| 428 | 1815 |
| 1816 return list4 (make_int (left), | |
| 1817 make_int (top), | |
| 1818 make_int (left + w->pixel_width), | |
| 1819 make_int (top + w->pixel_height)); | |
| 1820 } | |
| 1821 | |
| 1822 DEFUN ("window-text-area-pixel-edges", | |
| 1823 Fwindow_text_area_pixel_edges, 0, 1, 0, /* | |
| 1824 Return a list of the pixel edge coordinates of the text area of WINDOW. | |
| 444 | 1825 The returned list is of the form (LEFT TOP RIGHT BOTTOM), |
| 1826 all relative to 0, 0 at the top left corner of the total area allocated | |
| 1827 to the window, which includes the scrollbars. | |
| 428 | 1828 */ |
| 1829 (window)) | |
| 1830 { | |
| 1831 struct window *w = decode_window (window); | |
| 1832 | |
| 1833 int left = window_left_gutter_width (w, /* modeline = */ 0); | |
| 1834 int top = window_top_gutter_height (w); | |
| 1835 int right = WINDOW_WIDTH (w) - window_right_gutter_width (w, 0); | |
| 1836 int bottom = WINDOW_HEIGHT (w) - window_bottom_gutter_height (w); | |
| 1837 | |
| 1838 return list4 (make_int (left), | |
| 1839 make_int (top), | |
| 1840 make_int (right), | |
| 1841 make_int (bottom)); | |
| 1842 } | |
| 1843 | |
| 1844 DEFUN ("window-point", Fwindow_point, 0, 1, 0, /* | |
| 1845 Return current value of point in WINDOW. | |
| 442 | 1846 For a non-selected window, this is the value point would have |
| 428 | 1847 if that window were selected. |
| 1848 | |
| 1849 Note that, when WINDOW is the selected window and its buffer | |
| 1850 is also currently selected, the value returned is the same as (point). | |
| 1851 It would be more strictly correct to return the `top-level' value | |
| 1852 of point, outside of any save-excursion forms. | |
| 444 | 1853 But that value is hard to find. |
| 428 | 1854 */ |
| 1855 (window)) | |
| 1856 { | |
| 1857 struct window *w = decode_window (window); | |
| 1858 | |
| 1859 /* The special check for current buffer is necessary for this | |
| 1860 function to work as defined when called within an excursion. */ | |
| 1861 if (w == XWINDOW (Fselected_window (XFRAME (w->frame)->device)) | |
| 1862 && current_buffer == XBUFFER (w->buffer)) | |
| 1863 return Fpoint (Qnil); | |
| 1864 return Fmarker_position (w->pointm[CURRENT_DISP]); | |
| 1865 } | |
| 1866 | |
| 1867 DEFUN ("window-start", Fwindow_start, 0, 1, 0, /* | |
| 1868 Return position at which display currently starts in WINDOW. | |
| 1869 This is updated by redisplay or by calling `set-window-start'. | |
| 1870 */ | |
| 1871 (window)) | |
| 1872 { | |
| 1873 return Fmarker_position (decode_window (window)->start[CURRENT_DISP]); | |
| 1874 } | |
| 1875 | |
| 1876 DEFUN ("window-end", Fwindow_end, 0, 2, 0, /* | |
| 1877 Return position at which display currently ends in WINDOW. | |
| 1878 This is updated by redisplay, when it runs to completion. | |
| 444 | 1879 Simply changing the buffer text or setting `window-start' does not |
| 1880 update this value. WINDOW defaults to the selected window. | |
| 1881 | |
| 1882 If optional arg GUARANTEE is non-nil, the return value is guaranteed | |
| 1883 to be the same value as this function would return at the end of the | |
| 1884 next full redisplay assuming nothing else changes in the meantime. | |
| 1885 This function is potentially much slower with this flag set. | |
| 428 | 1886 */ |
| 1887 (window, guarantee)) | |
| 1888 { | |
| 1889 struct window *w = decode_window (window); | |
| 1890 | |
| 1891 if (NILP (guarantee)) | |
| 1892 { | |
| 1893 Lisp_Object buf; | |
| 1894 buf = w->buffer; | |
| 1895 CHECK_BUFFER (buf); | |
| 1896 return make_int (BUF_Z (XBUFFER (buf)) - w->window_end_pos[CURRENT_DISP]); | |
| 1897 } | |
| 1898 else | |
| 1899 { | |
| 665 | 1900 Charbpos startp = marker_position (w->start[CURRENT_DISP]); |
| 428 | 1901 return make_int (end_of_last_line (w, startp)); |
| 1902 } | |
| 1903 } | |
| 1904 | |
| 442 | 1905 DEFUN ("window-last-line-visible-height", Fwindow_last_line_visible_height, 0, 1, 0, /* |
| 1906 Return pixel height of visible part of last window line if it is clipped. | |
| 1907 If the last line is not clipped, return nil. | |
| 1908 */ | |
| 1909 (window)) | |
| 1910 { | |
| 1911 struct window *w = decode_window (window); | |
| 1912 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP); | |
| 1913 int num_lines = Dynarr_length (dla); | |
| 1914 struct display_line *dl; | |
| 1915 | |
| 1916 /* No lines - no clipped lines */ | |
| 4967 | 1917 if (num_lines == 0 || (num_lines == 1 && Dynarr_begin (dla)->modeline)) |
| 442 | 1918 return Qnil; |
| 1919 | |
| 1920 dl = Dynarr_atp (dla, num_lines - 1); | |
| 1921 if (dl->clip == 0) | |
| 1922 return Qnil; | |
| 1923 | |
| 1924 return make_int (dl->ascent + dl->descent - dl->clip); | |
| 1925 } | |
| 1926 | |
| 428 | 1927 DEFUN ("set-window-point", Fset_window_point, 2, 2, 0, /* |
| 1928 Make point value in WINDOW be at position POS in WINDOW's buffer. | |
| 1161 | 1929 If WINDOW is the selected window, and window's buffer is the current |
| 1930 buffer, this actually changes the buffer's point instead of the window's | |
| 1931 point. (The equivalence of the selected window's point with its buffer's | |
| 1932 point is maintained throughout XEmacs. However, enforcing the additional | |
| 1933 restriction on the current buffer is "bug compatible" with FSF and is | |
| 1934 perhaps more logical.) | |
| 428 | 1935 */ |
| 1936 (window, pos)) | |
| 1937 { | |
| 1938 struct window *w = decode_window (window); | |
| 1939 | |
| 1940 CHECK_INT_COERCE_MARKER (pos); | |
| 1161 | 1941 |
| 844 | 1942 /* Don't dereference selected-window because there may not |
| 1943 be one -- e.g. at startup */ | |
| 1161 | 1944 if (EQ (wrap_window (w), Fselected_window (Qnil)) |
| 1945 && EQ (w->buffer, Fcurrent_buffer ())) | |
| 1946 Fgoto_char (pos, Qnil); | |
| 428 | 1947 else |
| 1948 set_marker_restricted (w->pointm[CURRENT_DISP], pos, w->buffer); | |
| 1949 | |
| 1950 MARK_POINT_CHANGED; | |
| 1951 return pos; | |
| 1952 } | |
| 1953 | |
| 1954 DEFUN ("set-window-start", Fset_window_start, 2, 3, 0, /* | |
| 1955 Make display in WINDOW start at position POS in WINDOW's buffer. | |
| 1956 Optional third arg NOFORCE non-nil inhibits next redisplay | |
| 1957 from overriding motion of point in order to display at this exact start. | |
| 1958 */ | |
| 1959 (window, pos, noforce)) | |
| 1960 { | |
| 1961 struct window *w = decode_window (window); | |
| 1962 | |
| 1963 CHECK_INT_COERCE_MARKER (pos); | |
| 1964 set_marker_restricted (w->start[CURRENT_DISP], pos, w->buffer); | |
| 1965 /* this is not right, but much easier than doing what is right. */ | |
| 1966 /* w->start_at_line_beg = 0; */ | |
| 1967 /* WTF is the above supposed to mean? GE */ | |
| 1968 w->start_at_line_beg = beginning_of_line_p (XBUFFER (w->buffer), | |
| 1969 marker_position (w->start[CURRENT_DISP])); | |
| 1970 if (NILP (noforce)) | |
| 1971 w->force_start = 1; | |
| 1972 w->redo_modeline = 1; | |
| 1973 SET_LAST_MODIFIED (w, 0); | |
| 1974 SET_LAST_FACECHANGE (w); | |
| 1975 | |
| 1976 MARK_WINDOWS_CHANGED (w); | |
| 1977 | |
| 1978 return pos; | |
| 1979 } | |
| 1980 | |
| 1981 DEFUN ("window-dedicated-p", Fwindow_dedicated_p, 1, 1, 0, /* | |
| 1982 Return WINDOW's dedicated object, usually t or nil. | |
| 1983 See also `set-window-dedicated-p'. | |
| 1984 */ | |
| 1985 (window)) | |
| 1986 { | |
| 1987 return decode_window (window)->dedicated; | |
| 1988 } | |
| 1989 | |
| 1990 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, 2, 2, 0, /* | |
| 1991 Control whether WINDOW is dedicated to the buffer it displays. | |
| 1992 If it is dedicated, Emacs will not automatically change | |
| 1993 which buffer appears in it. | |
| 1994 The second argument is the new value for the dedication flag; | |
| 1995 non-nil means yes. | |
| 1996 */ | |
| 1997 (window, arg)) | |
| 1998 { | |
| 1999 struct window *w = decode_window (window); | |
| 2000 | |
| 2001 w->dedicated = NILP (arg) ? Qnil : Qt; | |
| 2002 | |
| 2003 return w->dedicated; | |
| 2004 } | |
| 2005 | |
| 2006 /* FSFmacs has window-display-table here. We have display table as a | |
| 2007 specifier. */ | |
| 2008 | |
| 2009 | |
| 2010 /* Record info on buffer window w is displaying | |
| 2011 when it is about to cease to display that buffer. */ | |
| 2012 static void | |
| 2013 unshow_buffer (struct window *w) | |
| 2014 { | |
| 2015 Lisp_Object buf = w->buffer; | |
| 844 | 2016 struct buffer *b = XBUFFER (buf); |
| 2017 | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
2018 assert (b == XMARKER (w->pointm[CURRENT_DISP])->buffer); |
| 428 | 2019 |
| 2020 /* FSF disables this check, so I'll do it too. I hope it won't | |
| 2021 break things. --ben */ | |
| 2022 #if 0 | |
| 2023 if (w == XWINDOW (Fselected_window (Qnil)) | |
| 2024 || ! EQ (buf, XWINDOW (Fselected_window (Qnil))->buffer)) | |
| 2025 /* Do this except when the selected window's buffer | |
| 2026 is being removed from some other window. */ | |
| 2027 #endif | |
| 2028 /* last_window_start records the start position that this buffer | |
| 2029 had in the last window to be disconnected from it. | |
| 2030 Now that this statement is unconditional, | |
| 2031 it is possible for the buffer to be displayed in the | |
| 2032 selected window, while last_window_start reflects another | |
| 2033 window which was recently showing the same buffer. | |
| 2034 Some people might say that might be a good thing. Let's see. */ | |
| 2035 XBUFFER (buf)->last_window_start = | |
| 2036 marker_position (w->start[CURRENT_DISP]); | |
| 2037 | |
| 2038 /* Point in the selected window's buffer | |
| 2039 is actually stored in that buffer, and the window's pointm isn't used. | |
| 2040 So don't clobber point in that buffer. */ | |
| 2041 if (! EQ (buf, XWINDOW (Fselected_window (Qnil))->buffer)) | |
| 844 | 2042 BUF_SET_PT (b, |
| 2043 charbpos_clip_to_bounds | |
| 2044 (BUF_BEGV (b), | |
| 2045 marker_position (w->pointm[CURRENT_DISP]), | |
| 2046 BUF_ZV (b))); | |
| 2047 | |
| 2048 { | |
| 2049 Lisp_Object marker = Fgethash (buf, w->saved_point_cache, Qnil); | |
| 2050 int selected = EQ (wrap_window (w), Fselected_window (Qnil)); | |
| 2051 | |
| 2052 if (NILP (marker)) | |
| 2053 { | |
| 2054 marker = Fmake_marker (); | |
| 2055 Fputhash (buf, marker, w->saved_point_cache); | |
| 2056 } | |
| 2057 Fset_marker (marker, | |
| 2058 selected ? make_int (BUF_PT (b)) : w->pointm[CURRENT_DISP], | |
| 2059 buf); | |
| 2060 | |
| 2061 marker = Fgethash (buf, w->saved_last_window_start_cache, Qnil); | |
| 2062 | |
| 2063 if (NILP (marker)) | |
| 2064 { | |
| 2065 marker = Fmake_marker (); | |
| 2066 Fputhash (buf, marker, w->saved_last_window_start_cache); | |
| 2067 } | |
| 2068 Fset_marker (marker, w->start[CURRENT_DISP], buf); | |
| 2069 } | |
| 428 | 2070 } |
| 2071 | |
| 2072 /* Put REPLACEMENT into the window structure in place of OLD. */ | |
| 2073 static void | |
| 2074 replace_window (Lisp_Object old, Lisp_Object replacement) | |
| 2075 { | |
| 2076 Lisp_Object tem; | |
| 2077 struct window *o = XWINDOW (old), *p = XWINDOW (replacement); | |
| 2078 | |
| 2079 /* If OLD is its frame's root_window, then replacement is the new | |
| 2080 root_window for that frame. */ | |
| 2081 | |
| 2082 if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) | |
| 2083 FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement; | |
| 2084 | |
| 2085 WINDOW_LEFT (p) = WINDOW_LEFT (o); | |
| 2086 WINDOW_TOP (p) = WINDOW_TOP (o); | |
| 2087 WINDOW_WIDTH (p) = WINDOW_WIDTH (o); | |
| 2088 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o); | |
| 2089 | |
| 2090 p->next = tem = o->next; | |
| 2091 if (!NILP (tem)) | |
| 2092 XWINDOW (tem)->prev = replacement; | |
| 2093 | |
| 2094 p->prev = tem = o->prev; | |
| 2095 if (!NILP (tem)) | |
| 2096 XWINDOW (tem)->next = replacement; | |
| 2097 | |
| 2098 p->parent = tem = o->parent; | |
| 2099 if (!NILP (tem)) | |
| 2100 { | |
| 2101 if (EQ (XWINDOW (tem)->vchild, old)) | |
| 2102 XWINDOW (tem)->vchild = replacement; | |
| 2103 if (EQ (XWINDOW (tem)->hchild, old)) | |
| 2104 XWINDOW (tem)->hchild = replacement; | |
| 2105 } | |
| 2106 | |
| 2107 /* #### Here, if replacement is a vertical combination | |
| 2108 and so is its new parent, we should make replacement's | |
| 2109 children be children of that parent instead. */ | |
| 442 | 2110 |
| 2111 ERROR_CHECK_SUBWINDOW_CACHE (p); | |
| 2112 } | |
| 2113 | |
| 2114 static void | |
| 2115 window_unmap_subwindows (struct window* w) | |
| 2116 { | |
| 2117 assert (!NILP (w->subwindow_instance_cache)); | |
| 2118 elisp_maphash (unmap_subwindow_instance_cache_mapper, | |
| 2119 w->subwindow_instance_cache, (void*)1); | |
| 428 | 2120 } |
| 2121 | |
| 2122 /* we're deleting W; set the structure of W to indicate this. */ | |
| 2123 | |
| 2124 static void | |
| 2125 mark_window_as_deleted (struct window *w) | |
| 2126 { | |
| 442 | 2127 /* The window instance cache is going away now, so need to get the |
| 2128 cachels reset by redisplay. */ | |
| 2129 MARK_FRAME_SUBWINDOWS_CHANGED (XFRAME (WINDOW_FRAME (w))); | |
| 2130 | |
| 2131 /* The cache is going away. If we leave unmapping to | |
| 2132 reset_subwindow_cachels then we get in a situation where the | |
| 2133 domain (the window) has been deleted but we still need access to | |
| 2134 its attributes in order to unmap windows properly. Since the | |
| 2135 subwindows are going to get GC'd anyway as a result of the domain | |
| 2136 going away, it is safer to just unmap them all while we know the | |
| 2137 domain is still valid. */ | |
| 2138 ERROR_CHECK_SUBWINDOW_CACHE (w); | |
| 2139 window_unmap_subwindows (w); | |
| 2140 | |
| 617 | 2141 /* Free the extra data structures attached to windows immediately so |
| 2142 they don't sit around consuming excess space. They will be | |
| 2143 reinitialized by the window-configuration code as necessary. */ | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2144 finalize_window (wrap_window (w)); |
| 617 | 2145 |
| 1149 | 2146 /* Nobody should be accessing anything in this object any more, |
| 618 | 2147 and making them Qnil allows for better GC'ing in case a pointer |
| 2148 to the dead window continues to hang around. Zero all other | |
| 2149 structs in case someone tries to access something through them. | |
| 2150 | |
| 2151 (So, in point of fact, we zero out all of the "saved" slots, | |
| 2152 which are obviously restored from the window config, plus the | |
| 2153 slots which were already zeroed.) | |
| 617 | 2154 |
| 2155 As an example of why setting the values to Qnil is good, here | |
| 2156 is an old comment: | |
| 2157 | |
| 2158 In the loop | |
| 428 | 2159 (while t (split-window) (delete-window)) |
| 2160 we end up with a tree of deleted windows which are all connected | |
| 2161 through the `next' slot. This might not seem so bad, as they're | |
| 2162 deleted, and will presumably be GCed - but if even *one* of those | |
| 2163 windows is still being pointed to, by the user, or by a window | |
| 1149 | 2164 configuration, then *all* of those windows stick around. */ |
| 617 | 2165 |
| 618 | 2166 #define WINDOW_SLOT(slot) |
| 2167 #define WINDOW_SAVED_SLOT(slot, compare) w->slot = Qnil; | |
| 617 | 2168 #include "winslots.h" |
| 428 | 2169 |
| 618 | 2170 w->next = Qnil; |
| 2171 w->prev = Qnil; | |
| 2172 w->hchild = Qnil; | |
| 2173 w->vchild = Qnil; | |
| 2174 w->parent = Qnil; | |
| 2175 w->subwindow_instance_cache = Qnil; | |
| 2176 | |
| 428 | 2177 w->dead = 1; |
| 853 | 2178 note_object_deleted (wrap_window (w)); |
| 428 | 2179 } |
| 2180 | |
| 1207 | 2181 /* Check if window contains pwindow. */ |
| 2182 | |
| 2183 static int | |
| 2184 contains_window (Lisp_Object window, Lisp_Object pwindow) | |
| 2185 { | |
| 2186 while (!NILP (pwindow)) | |
| 2187 { | |
| 2188 if (EQ (window, pwindow)) | |
| 2189 return 1; | |
| 2190 pwindow = XWINDOW (pwindow)->parent; | |
| 2191 } | |
| 2192 return 0; | |
| 2193 } | |
| 2194 | |
| 428 | 2195 DEFUN ("delete-window", Fdelete_window, 0, 2, "", /* |
| 2196 Remove WINDOW from the display. Default is selected window. | |
| 444 | 2197 If window is the only one on its frame, the frame is deleted as well. |
| 428 | 2198 Normally, you cannot delete the last non-minibuffer-only frame (you must |
| 2199 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional | |
| 2200 second argument FORCE is non-nil, you can delete the last frame. (This | |
| 2201 will automatically call `save-buffers-kill-emacs'.) | |
| 2202 */ | |
| 2203 (window, force)) | |
| 2204 { | |
| 2205 /* This function can GC if this is the only window in the frame */ | |
| 2206 struct window *w; | |
| 2207 Lisp_Object parent; | |
| 2208 struct window *par; | |
| 2209 Lisp_Object frame; | |
| 2210 struct frame *f; | |
| 2211 struct device *d; | |
| 2212 | |
| 2213 /* Note: this function is called by other C code on non-leaf | |
| 2214 windows. */ | |
| 2215 | |
| 2216 /* Do the equivalent of decode_window() but don't error out on | |
| 2217 deleted window; it's OK to delete an already-deleted window. */ | |
| 2218 if (NILP (window)) | |
| 2219 window = Fselected_window (Qnil); | |
| 2220 else | |
| 2221 CHECK_WINDOW (window); | |
| 442 | 2222 |
| 428 | 2223 w = XWINDOW (window); |
| 2224 | |
| 2225 /* It's okay to delete an already-deleted window. */ | |
| 2226 if (! WINDOW_LIVE_P (w)) | |
| 2227 return Qnil; | |
| 2228 | |
| 853 | 2229 check_allowed_operation (OPERATION_DELETE_OBJECT, window, Qnil); |
| 2230 | |
| 428 | 2231 frame = WINDOW_FRAME (w); |
| 2232 f = XFRAME (frame); | |
| 2233 d = XDEVICE (FRAME_DEVICE (f)); | |
| 2234 | |
| 2235 if (TOP_LEVEL_WINDOW_P (w)) | |
| 2236 { | |
| 2237 if (NILP (memq_no_quit (frame, DEVICE_FRAME_LIST (d)))) | |
| 2238 /* this frame isn't fully initialized yet; don't blow up. */ | |
| 2239 return Qnil; | |
| 2240 | |
| 2241 if (MINI_WINDOW_P (XWINDOW (window))) | |
| 563 | 2242 signal_error (Qinvalid_operation, "Attempt to delete the minibuffer window", Qunbound); |
| 428 | 2243 |
| 2244 /* It has been suggested that it's a good thing for C-x 0 to have this | |
| 2245 behavior, but not such a good idea for #'delete-window to have it. | |
| 2246 Maybe C-x 0 should be bound to something else, or maybe frame | |
| 2247 deletion should only happen when this is called interactively. | |
| 2248 */ | |
| 2249 delete_frame_internal (f, !NILP (force), 0, 0); | |
| 2250 return Qnil; | |
| 2251 } | |
| 2252 | |
| 2253 /* At this point, we know the window has a parent. */ | |
| 2254 parent = w->parent; | |
| 2255 par = XWINDOW (parent); | |
| 2256 | |
| 2257 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); | |
| 430 | 2258 /* It's quite likely that deleting a window will result in |
| 2259 subwindows needing to be deleted also (since they are cached | |
| 2260 per-window). So we mark them as changed, so that the cachels will | |
| 2261 get reset by redisplay and thus deleted subwindows can get | |
| 2262 GC'd. */ | |
| 2263 MARK_FRAME_SUBWINDOWS_CHANGED (f); | |
| 428 | 2264 |
| 2265 /* Are we trying to delete any frame's selected window? | |
| 2266 Note that we could be dealing with a non-leaf window | |
| 2267 where the selected window is one of our children. | |
| 2268 So, we check by scanning all the ancestors of the | |
| 2269 frame's selected window and comparing each one with | |
| 2270 WINDOW. */ | |
| 1207 | 2271 if (contains_window (window, FRAME_SELECTED_WINDOW (f))) |
| 2272 { | |
| 2273 Lisp_Object alternative; | |
| 2274 alternative = Fnext_window (window, Qlambda, Qnil, Qnil); | |
| 2275 | |
| 2276 /* #### */ | |
| 2277 /* If we're about to delete the selected window on the | |
| 2278 selected frame, then we should use Fselect_window to select | |
| 2279 the new window. On the other hand, if we're about to | |
| 2280 delete the selected window on any other frame, we shouldn't do | |
| 2281 anything but set the frame's selected_window slot. */ | |
| 2282 if (EQ (frame, Fselected_frame (Qnil))) | |
| 2283 Fselect_window (alternative, Qnil); | |
| 2284 else | |
| 2285 set_frame_selected_window (f, alternative); | |
| 2286 } | |
| 2287 | |
| 2288 /* Some display parameters (gutter display specifically) depend on | |
| 2289 FRAME_LAST_NONMINIBUF (f) to be set to a live window. Ensure that. */ | |
| 2290 if (contains_window (window, FRAME_LAST_NONMINIBUF_WINDOW (f))) | |
| 2291 f->last_nonminibuf_window = Fnext_window (window, Qlambda, Qnil, Qnil); | |
| 428 | 2292 |
| 2293 /* w->buffer is nil in a non-leaf window; in this case, | |
| 2294 get rid of the markers we maintain that point into that buffer. */ | |
| 2295 if (!NILP (w->buffer)) | |
| 2296 { | |
| 2297 unshow_buffer (w); | |
| 2298 unchain_marker (w->pointm[CURRENT_DISP]); | |
| 2299 unchain_marker (w->pointm[DESIRED_DISP]); | |
| 2300 unchain_marker (w->pointm[CMOTION_DISP]); | |
| 2301 unchain_marker (w->start[CURRENT_DISP]); | |
| 2302 unchain_marker (w->start[DESIRED_DISP]); | |
| 2303 unchain_marker (w->start[CMOTION_DISP]); | |
| 2304 unchain_marker (w->sb_point); | |
| 1149 | 2305 w->buffer = Qnil; |
| 428 | 2306 } |
| 2307 | |
| 2308 /* close up the hole in the sibling list */ | |
| 2309 if (!NILP (w->next)) | |
| 2310 XWINDOW (w->next)->prev = w->prev; | |
| 2311 if (!NILP (w->prev)) | |
| 2312 XWINDOW (w->prev)->next = w->next; | |
| 2313 if (EQ (window, par->hchild)) | |
| 2314 par->hchild = w->next; | |
| 2315 if (EQ (window, par->vchild)) | |
| 2316 par->vchild = w->next; | |
| 2317 | |
| 2318 /* Find one of our siblings to give our space to. */ | |
| 2319 { | |
| 2320 Lisp_Object sib = w->prev; | |
| 2321 if (NILP (sib)) | |
| 2322 { | |
| 2323 /* If w gives its space to its next sibling, that sibling needs | |
| 2324 to have its top/left side pulled back to where w's is. | |
| 2325 set_window_{height,width} will re-position the sibling's | |
| 2326 children. */ | |
| 2327 sib = w->next; | |
| 2328 WINDOW_TOP (XWINDOW (sib)) = WINDOW_TOP (w); | |
| 2329 WINDOW_LEFT (XWINDOW (sib)) = WINDOW_LEFT (w); | |
| 2330 } | |
| 2331 | |
| 2332 /* Stretch that sibling. */ | |
| 2333 if (!NILP (par->vchild)) | |
| 2334 set_window_pixheight | |
| 2335 (sib, (WINDOW_HEIGHT (XWINDOW (sib)) + WINDOW_HEIGHT (w)), 1); | |
| 2336 if (!NILP (par->hchild)) | |
| 2337 set_window_pixwidth | |
| 2338 (sib, (WINDOW_WIDTH (XWINDOW (sib)) + WINDOW_WIDTH (w)), 1); | |
| 2339 } | |
| 2340 | |
| 2341 /* If parent now has only one child, | |
| 2342 put the child into the parent's place. */ | |
| 2343 { | |
| 2344 Lisp_Object parchild = par->hchild; | |
| 2345 if (NILP (parchild)) | |
| 2346 parchild = par->vchild; | |
| 2347 if (NILP (XWINDOW (parchild)->next)) | |
| 2348 { | |
| 2349 replace_window (parent, parchild); | |
| 2350 mark_window_as_deleted (XWINDOW (parent)); | |
| 2351 } | |
| 2352 } | |
| 2353 | |
| 2354 /* Since we may be deleting combination windows, we must make sure that | |
| 2355 not only W but all its children have been marked as deleted. */ | |
| 2356 if (!NILP (w->hchild)) | |
| 2357 delete_all_subwindows (XWINDOW (w->hchild)); | |
| 2358 else if (!NILP (w->vchild)) | |
| 2359 delete_all_subwindows (XWINDOW (w->vchild)); | |
| 2360 | |
| 1752 | 2361 /* Warning: mark_window_as_deleted calls window_unmap_subwindows and |
| 2362 therefore redisplay, so it requires the mirror structure to be | |
| 2363 correct. We must dirty the mirror before it is called. */ | |
| 2364 f->mirror_dirty = 1; | |
| 2365 | |
| 428 | 2366 mark_window_as_deleted (w); |
| 2367 | |
| 2368 return Qnil; | |
| 2369 } | |
| 2370 | |
| 2371 | |
| 2372 DEFUN ("next-window", Fnext_window, 0, 4, 0, /* | |
| 442 | 2373 Return the next window after WINDOW in the canonical ordering of windows. |
| 428 | 2374 If omitted, WINDOW defaults to the selected window. |
| 2375 | |
| 2376 Optional second arg MINIBUF t means count the minibuffer window even | |
| 2377 if not active. MINIBUF nil or omitted means count the minibuffer iff | |
| 2378 it is active. MINIBUF neither t nor nil means not to count the | |
| 2379 minibuffer even if it is active. | |
| 2380 | |
| 2381 Several frames may share a single minibuffer; if the minibuffer | |
| 2382 counts, all windows on all frames that share that minibuffer count | |
| 2383 too. Therefore, `next-window' can be used to iterate through the | |
| 2384 set of windows even when the minibuffer is on another frame. If the | |
| 2385 minibuffer does not count, only windows from WINDOW's frame count. | |
| 2386 | |
| 444 | 2387 By default, only the windows in the selected frame are considered. |
| 2388 The optional argument WHICH-FRAMES changes this behavior: | |
| 2389 WHICH-FRAMES = `visible' means search windows on all visible frames. | |
| 448 | 2390 WHICH-FRAMES = 0 means search windows on all visible and iconified frames. |
| 444 | 2391 WHICH-FRAMES = t means search windows on all frames including invisible frames. |
| 2392 WHICH-FRAMES = a frame means search only windows on that frame. | |
| 2393 Anything else means restrict to the selected frame. | |
| 2394 | |
| 2395 The optional fourth argument WHICH-DEVICES further clarifies on which | |
| 2396 devices to search for frames as specified by WHICH-FRAMES. This value | |
| 2397 is only meaningful if WHICH-FRAMES is non-nil. | |
| 2398 If nil or omitted, search all devices on the selected console. | |
| 2399 If a device, only search that device. | |
| 2400 If a console, search all devices on that console. | |
| 2401 If a device type, search all devices of that type. | |
| 2402 If `window-system', search all window-system devices. | |
| 2403 Any other non-nil value means search all devices. | |
| 2404 | |
| 2405 If you use consistent values for MINIBUF, WHICH-FRAMES, and WHICH-DEVICES, | |
| 2406 you can use `next-window' to iterate through the entire cycle of | |
| 2407 acceptable windows, eventually ending up back at the window you started with. | |
| 428 | 2408 `previous-window' traverses the same cycle, in the reverse order. |
| 2409 */ | |
| 444 | 2410 (window, minibuf, which_frames, which_devices)) |
| 428 | 2411 { |
| 2412 Lisp_Object tem; | |
| 2413 Lisp_Object start_window; | |
| 2414 | |
| 2415 if (NILP (window)) | |
| 2416 window = Fselected_window (Qnil); | |
| 2417 else | |
| 2418 CHECK_LIVE_WINDOW (window); | |
| 2419 | |
| 2420 start_window = window; | |
| 2421 | |
| 2422 /* minibuf == nil may or may not include minibuffers. | |
| 2423 Decide if it does. */ | |
| 2424 if (NILP (minibuf)) | |
| 2425 minibuf = (minibuf_level ? minibuf_window : Qlambda); | |
| 2426 else if (! EQ (minibuf, Qt)) | |
| 2427 minibuf = Qlambda; | |
| 442 | 2428 /* Now `minibuf' is one of: |
| 2429 t => count all minibuffer windows | |
| 2430 lambda => count none of them | |
| 428 | 2431 or a specific minibuffer window (the active one) to count. */ |
| 2432 | |
| 444 | 2433 /* which_frames == nil doesn't specify which frames to include. */ |
| 2434 if (NILP (which_frames)) | |
| 2435 which_frames = (! EQ (minibuf, Qlambda) | |
| 428 | 2436 ? (FRAME_MINIBUF_WINDOW |
| 2437 (XFRAME | |
| 2438 (WINDOW_FRAME | |
| 2439 (XWINDOW (window))))) | |
| 2440 : Qnil); | |
| 444 | 2441 else if (EQ (which_frames, Qvisible)) |
| 428 | 2442 ; |
| 444 | 2443 else if (ZEROP (which_frames)) |
| 428 | 2444 ; |
| 444 | 2445 else if (FRAMEP (which_frames) && ! EQ (which_frames, Fwindow_frame (window))) |
| 2446 /* If which_frames is a frame and window arg isn't on that frame, just | |
| 428 | 2447 return the first window on the frame. */ |
| 444 | 2448 return frame_first_window (XFRAME (which_frames)); |
| 2449 else if (! EQ (which_frames, Qt)) | |
| 2450 which_frames = Qnil; | |
| 2451 /* Now `which_frames' is one of: | |
| 442 | 2452 t => search all frames |
| 2453 nil => search just the current frame | |
| 2454 visible => search just visible frames | |
| 2455 0 => search visible and iconified frames | |
| 2456 a window => search the frame that window belongs to. */ | |
| 428 | 2457 |
| 2458 /* Do this loop at least once, to get the next window, and perhaps | |
| 2459 again, if we hit the minibuffer and that is not acceptable. */ | |
| 2460 do | |
| 2461 { | |
| 2462 /* Find a window that actually has a next one. This loop | |
| 2463 climbs up the tree. */ | |
| 2464 while (tem = XWINDOW (window)->next, NILP (tem)) | |
| 2465 if (tem = XWINDOW (window)->parent, !NILP (tem)) | |
| 2466 window = tem; | |
| 2467 else /* window must be minibuffer window now */ | |
| 2468 { | |
| 2469 /* We've reached the end of this frame. | |
| 2470 Which other frames are acceptable? */ | |
| 2471 tem = WINDOW_FRAME (XWINDOW (window)); | |
| 2472 | |
| 444 | 2473 if (! NILP (which_frames)) |
| 428 | 2474 { |
| 442 | 2475 Lisp_Object tem1 = tem; |
| 444 | 2476 tem = next_frame (tem, which_frames, which_devices); |
| 442 | 2477 |
| 428 | 2478 /* In the case where the minibuffer is active, |
| 2479 and we include its frame as well as the selected one, | |
| 2480 next_frame may get stuck in that frame. | |
| 2481 If that happens, go back to the selected frame | |
| 2482 so we can complete the cycle. */ | |
| 2483 if (EQ (tem, tem1)) | |
| 793 | 2484 tem = wrap_frame (selected_frame ()); |
| 428 | 2485 } |
| 2486 | |
| 2487 tem = FRAME_ROOT_WINDOW (XFRAME (tem)); | |
| 2488 break; | |
| 2489 } | |
| 2490 | |
| 2491 window = tem; | |
| 2492 | |
| 2493 /* If we're in a combination window, find its first child and | |
| 2494 recurse on that. Otherwise, we've found the window we want. */ | |
| 2495 while (1) | |
| 2496 { | |
| 2497 if (!NILP (XWINDOW (window)->hchild)) | |
| 2498 window = XWINDOW (window)->hchild; | |
| 2499 else if (!NILP (XWINDOW (window)->vchild)) | |
| 2500 window = XWINDOW (window)->vchild; | |
| 2501 else break; | |
| 2502 } | |
| 2503 } | |
| 2504 /* Which windows are acceptable? | |
| 2505 Exit the loop and accept this window if | |
| 2506 this isn't a minibuffer window, | |
| 2507 or we're accepting all minibuffer windows, | |
| 2508 or this is the active minibuffer and we are accepting that one, or | |
| 2509 we've come all the way around and we're back at the original window. */ | |
| 2510 while (MINI_WINDOW_P (XWINDOW (window)) | |
| 2511 && ! EQ (minibuf, Qt) | |
| 2512 && ! EQ (minibuf, window) | |
| 2513 && ! EQ (window, start_window)); | |
| 2514 | |
| 2515 return window; | |
| 2516 } | |
| 2517 | |
| 2518 DEFUN ("previous-window", Fprevious_window, 0, 4, 0, /* | |
| 442 | 2519 Return the window preceding WINDOW in the canonical ordering of windows. |
| 428 | 2520 If omitted, WINDOW defaults to the selected window. |
| 2521 | |
| 2522 Optional second arg MINIBUF t means count the minibuffer window even | |
| 2523 if not active. MINIBUF nil or omitted means count the minibuffer iff | |
| 2524 it is active. MINIBUF neither t nor nil means not to count the | |
| 2525 minibuffer even if it is active. | |
| 2526 | |
| 2527 Several frames may share a single minibuffer; if the minibuffer | |
| 2528 counts, all windows on all frames that share that minibuffer count | |
| 2529 too. Therefore, `previous-window' can be used to iterate through | |
| 2530 the set of windows even when the minibuffer is on another frame. If | |
| 442 | 2531 the minibuffer does not count, only windows from WINDOW's frame count. |
| 2532 | |
| 444 | 2533 By default, only the windows in the selected frame are considered. |
| 2534 The optional argument WHICH-FRAMES changes this behavior: | |
| 2535 WHICH-FRAMES = `visible' means search windows on all visible frames. | |
| 448 | 2536 WHICH-FRAMES = 0 means search windows on all visible and iconified frames. |
| 444 | 2537 WHICH-FRAMES = t means search windows on all frames including invisible frames. |
| 2538 WHICH-FRAMES = a frame means search only windows on that frame. | |
| 2539 Anything else means restrict to the selected frame. | |
| 2540 | |
| 2541 The optional fourth argument WHICH-DEVICES further clarifies on which | |
| 2542 devices to search for frames as specified by WHICH-FRAMES. This value | |
| 2543 is only meaningful if WHICH-FRAMES is non-nil. | |
| 2544 If nil or omitted, search all devices on the selected console. | |
| 2545 If a device, only search that device. | |
| 2546 If a console, search all devices on that console. | |
| 2547 If a device type, search all devices of that type. | |
| 2548 If `window-system', search all window-system devices. | |
| 2549 Any other non-nil value means search all devices. | |
| 2550 | |
| 2551 If you use consistent values for MINIBUF, WHICH-FRAMES, and WHICH-DEVICES, | |
| 2552 you can use `previous-window' to iterate through the entire cycle of | |
| 2553 acceptable windows, eventually ending up back at the window you started with. | |
| 428 | 2554 `next-window' traverses the same cycle, in the reverse order. |
| 2555 */ | |
| 444 | 2556 (window, minibuf, which_frames, devices)) |
| 428 | 2557 { |
| 2558 Lisp_Object tem; | |
| 2559 Lisp_Object start_window; | |
| 2560 | |
| 2561 if (NILP (window)) | |
| 2562 window = Fselected_window (Qnil); | |
| 2563 else | |
| 2564 CHECK_LIVE_WINDOW (window); | |
| 2565 | |
| 2566 start_window = window; | |
| 2567 | |
| 2568 /* minibuf == nil may or may not include minibuffers. | |
| 2569 Decide if it does. */ | |
| 2570 if (NILP (minibuf)) | |
| 2571 minibuf = (minibuf_level ? minibuf_window : Qlambda); | |
| 2572 else if (! EQ (minibuf, Qt)) | |
| 2573 minibuf = Qlambda; | |
| 442 | 2574 /* Now `minibuf' is one of: |
| 2575 t => count all minibuffer windows | |
| 2576 lambda => count none of them | |
| 428 | 2577 or a specific minibuffer window (the active one) to count. */ |
| 2578 | |
| 444 | 2579 /* which_frames == nil doesn't specify which frames to include. |
| 428 | 2580 Decide which frames it includes. */ |
| 444 | 2581 if (NILP (which_frames)) |
| 2582 which_frames = (! EQ (minibuf, Qlambda) | |
| 428 | 2583 ? (FRAME_MINIBUF_WINDOW |
| 2584 (XFRAME | |
| 2585 (WINDOW_FRAME | |
| 2586 (XWINDOW (window))))) | |
| 2587 : Qnil); | |
| 444 | 2588 else if (EQ (which_frames, Qvisible)) |
| 428 | 2589 ; |
| 444 | 2590 else if (ZEROP (which_frames)) |
| 428 | 2591 ; |
| 444 | 2592 else if (FRAMEP (which_frames) && ! EQ (which_frames, Fwindow_frame (window))) |
| 2593 /* If which_frames is a frame and window arg isn't on that frame, just | |
| 428 | 2594 return the first window on the frame. */ |
| 444 | 2595 return frame_first_window (XFRAME (which_frames)); |
| 2596 else if (! EQ (which_frames, Qt)) | |
| 2597 which_frames = Qnil; | |
| 2598 /* Now `which_frames' is one of: | |
| 442 | 2599 t => search all frames |
| 2600 nil => search just the current frame | |
| 2601 visible => search just visible frames | |
| 2602 0 => search visible and iconified frames | |
| 2603 a window => search the frame that window belongs to. */ | |
| 428 | 2604 |
| 2605 /* Do this loop at least once, to get the next window, and perhaps | |
| 2606 again, if we hit the minibuffer and that is not acceptable. */ | |
| 2607 do | |
| 2608 { | |
| 2609 /* Find a window that actually has a next one. This loop | |
| 2610 climbs up the tree. */ | |
| 2611 while (tem = XWINDOW (window)->prev, NILP (tem)) | |
| 2612 if (tem = XWINDOW (window)->parent, !NILP (tem)) | |
| 2613 window = tem; | |
| 2614 else /* window must be minibuffer window now */ | |
| 2615 { | |
| 2616 /* We have found the top window on the frame. | |
| 2617 Which frames are acceptable? */ | |
| 2618 tem = WINDOW_FRAME (XWINDOW (window)); | |
| 2619 | |
| 444 | 2620 if (! NILP (which_frames)) |
| 442 | 2621 /* It's actually important that we use previous_frame here, |
| 428 | 2622 rather than next_frame. All the windows acceptable |
| 2623 according to the given parameters should form a ring; | |
| 2624 Fnext_window and Fprevious_window should go back and | |
| 2625 forth around the ring. If we use next_frame here, | |
| 2626 then Fnext_window and Fprevious_window take different | |
| 2627 paths through the set of acceptable windows. | |
| 2628 window_loop assumes that these `ring' requirement are | |
| 2629 met. */ | |
| 2630 { | |
| 442 | 2631 Lisp_Object tem1 = tem; |
| 444 | 2632 tem = previous_frame (tem, which_frames, devices); |
| 428 | 2633 /* In the case where the minibuffer is active, |
| 2634 and we include its frame as well as the selected one, | |
| 2635 next_frame may get stuck in that frame. | |
| 2636 If that happens, go back to the selected frame | |
| 2637 so we can complete the cycle. */ | |
| 2638 if (EQ (tem, tem1)) | |
| 793 | 2639 tem = wrap_frame (selected_frame ()); |
| 428 | 2640 } |
| 2641 | |
| 2642 /* If this frame has a minibuffer, find that window first, | |
| 2643 because it is conceptually the last window in that frame. */ | |
| 2644 if (FRAME_HAS_MINIBUF_P (XFRAME (tem))) | |
| 2645 tem = FRAME_MINIBUF_WINDOW (XFRAME (tem)); | |
| 2646 else | |
| 2647 tem = FRAME_ROOT_WINDOW (XFRAME (tem)); | |
| 2648 | |
| 2649 break; | |
| 2650 } | |
| 2651 | |
| 2652 window = tem; | |
| 2653 | |
| 2654 /* If we're in a combination window, find its first child and | |
| 2655 recurse on that. Otherwise, we've found the window we want. */ | |
| 2656 while (1) | |
| 2657 { | |
| 2658 if (!NILP (XWINDOW (window)->hchild)) | |
| 2659 window = XWINDOW (window)->hchild; | |
| 2660 else if (!NILP (XWINDOW (window)->vchild)) | |
| 2661 window = XWINDOW (window)->vchild; | |
| 2662 else break; | |
| 2663 while (tem = XWINDOW (window)->next, !NILP (tem)) | |
| 2664 window = tem; | |
| 2665 } | |
| 2666 } | |
| 2667 /* Which windows are acceptable? | |
| 2668 Exit the loop and accept this window if | |
| 2669 this isn't a minibuffer window, | |
| 2670 or we're accepting all minibuffer windows, | |
| 2671 or this is the active minibuffer and we are accepting that one, or | |
| 2672 we've come all the way around and we're back at the original window. */ | |
| 2673 while (MINI_WINDOW_P (XWINDOW (window)) | |
| 2674 && ! EQ (minibuf, Qt) | |
| 2675 && ! EQ (minibuf, window) | |
| 2676 && ! EQ (window, start_window)); | |
| 2677 | |
| 2678 return window; | |
| 2679 } | |
| 2680 | |
| 2681 DEFUN ("next-vertical-window", Fnext_vertical_window, 0, 1, 0, /* | |
| 2682 Return the next window which is vertically after WINDOW. | |
| 2683 */ | |
| 2684 (window)) | |
| 2685 { | |
| 2686 Lisp_Object root; | |
| 2687 struct window *w = decode_window (window); | |
| 793 | 2688 window = wrap_window (w); |
| 428 | 2689 |
| 2690 if (MINI_WINDOW_P (XWINDOW (window))) | |
| 2691 return Qnil; | |
| 2692 | |
| 2693 root = FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (XWINDOW (window)))); | |
| 2694 | |
| 2695 if (EQ (window, root)) | |
| 2696 { | |
| 2697 while (1) | |
| 2698 if (!NILP (XWINDOW (window)->hchild)) | |
| 2699 window = XWINDOW (window)->hchild; | |
| 2700 else if (!NILP (XWINDOW (window)->vchild)) | |
| 2701 window = XWINDOW (window)->vchild; | |
| 2702 else | |
| 2703 return window; | |
| 2704 } | |
| 2705 | |
| 2706 do | |
| 2707 { | |
| 2708 if (!NILP (XWINDOW (window)->parent) && | |
| 2709 !NILP (XWINDOW (XWINDOW (window)->parent)->vchild)) | |
| 2710 { | |
| 2711 if (!NILP (XWINDOW (window)->next)) | |
| 2712 return XWINDOW (window)->next; | |
| 2713 else | |
| 2714 window = XWINDOW (window)->parent; | |
| 2715 } | |
| 2716 else | |
| 2717 window = XWINDOW (window)->parent; | |
| 2718 } | |
| 2719 while (!EQ (window, root)); | |
| 2720 | |
| 2721 while (1) | |
| 2722 if (!NILP (XWINDOW (window)->hchild)) | |
| 2723 window = XWINDOW (window)->hchild; | |
| 2724 else if (!NILP (XWINDOW (window)->vchild)) | |
| 2725 window = XWINDOW (window)->vchild; | |
| 2726 else | |
| 2727 return window; | |
| 2728 } | |
| 2729 | |
| 2730 DEFUN ("other-window", Fother_window, 1, 3, "p", /* | |
| 444 | 2731 Select the COUNT'th different window on this frame. |
| 428 | 2732 All windows on current frame are arranged in a cyclic order. |
| 444 | 2733 This command selects the window COUNT steps away in that order. |
| 2734 A negative COUNT moves in the opposite order. | |
| 2735 | |
| 2736 By default, only the windows in the selected frame are considered. | |
| 2737 The optional argument WHICH-FRAMES changes this behavior: | |
| 2738 WHICH-FRAMES = `visible' means search windows on all visible frames. | |
| 448 | 2739 WHICH-FRAMES = 0 means search windows on all visible and iconified frames. |
| 444 | 2740 WHICH-FRAMES = t means search windows on all frames including invisible frames. |
| 2741 WHICH-FRAMES = a frame means search only windows on that frame. | |
| 2742 Anything else means restrict to the selected frame. | |
| 2743 | |
| 2744 The optional argument WHICH-DEVICES further clarifies on which devices | |
| 2745 to search for frames as specified by WHICH-FRAMES. This value is only | |
| 2746 meaningful if WHICH-FRAMES is non-nil. | |
| 2747 If nil or omitted, search all devices on the selected console. | |
| 2748 If a device, only search that device. | |
| 2749 If a console, search all devices on that console. | |
| 2750 If a device type, search all devices of that type. | |
| 2751 If `window-system', search all window-system devices. | |
| 2752 Any other non-nil value means search all devices. | |
| 428 | 2753 */ |
| 444 | 2754 (count, which_frames, which_devices)) |
| 428 | 2755 { |
| 2756 int i; | |
| 2757 Lisp_Object w; | |
| 2758 | |
| 444 | 2759 CHECK_INT (count); |
| 428 | 2760 w = Fselected_window (Qnil); |
| 444 | 2761 i = XINT (count); |
| 428 | 2762 |
| 2763 while (i > 0) | |
| 2764 { | |
| 444 | 2765 w = Fnext_window (w, Qnil, which_frames, which_devices); |
| 428 | 2766 i--; |
| 2767 } | |
| 2768 while (i < 0) | |
| 2769 { | |
| 444 | 2770 w = Fprevious_window (w, Qnil, which_frames, which_devices); |
| 428 | 2771 i++; |
| 2772 } | |
| 2773 Fselect_window (w, Qnil); | |
| 2774 return Qnil; | |
| 2775 } | |
| 2776 | |
| 2777 | |
| 2778 /* Look at all windows, performing an operation specified by TYPE | |
| 2779 with argument OBJ. | |
| 2780 | |
| 2781 If FRAMES is Qt, look at all frames, if Qnil, look at just the selected | |
| 2782 frame. If FRAMES is a frame, just look at windows on that frame. | |
| 2783 If MINI is non-zero, perform the operation on minibuffer windows too. | |
| 2784 */ | |
| 2785 | |
| 2786 enum window_loop | |
| 2787 { | |
| 2788 WINDOW_LOOP_UNUSED, | |
| 2789 GET_BUFFER_WINDOW, /* Arg is buffer */ | |
| 2790 GET_LRU_WINDOW, /* Arg is t for full-width windows only */ | |
| 2791 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */ | |
| 2792 DELETE_BUFFER_WINDOWS, /* Arg is buffer */ | |
| 2793 GET_LARGEST_WINDOW, | |
| 2794 GET_BUFFER_WINDOW_COUNT, /* Arg is buffer */ | |
| 2795 GET_BUFFER_MRU_WINDOW /* Arg is buffer */ | |
| 2796 }; | |
| 2797 | |
| 2798 static Lisp_Object | |
| 2799 window_loop (enum window_loop type, | |
| 2800 Lisp_Object obj, | |
| 2801 int mini, | |
| 444 | 2802 Lisp_Object which_frames, |
| 428 | 2803 int dedicated_too, |
| 444 | 2804 Lisp_Object which_devices) |
| 428 | 2805 { |
| 448 | 2806 /* This function can GC if type == DELETE_BUFFER_WINDOWS */ |
| 428 | 2807 Lisp_Object w; |
| 2808 Lisp_Object best_window = Qnil; | |
| 2809 Lisp_Object next_window; | |
| 2810 Lisp_Object last_window; | |
| 2811 struct frame *frame; | |
| 2812 Lisp_Object frame_arg = Qt; | |
| 2813 int count = 0; /* for GET_BUFFER_WINDOW_COUNT */ | |
| 2814 /* #### I think the change of "precomputing" last_window and next_window | |
| 2815 * #### catch the lossage this is meant(?) to punt on... | |
| 2816 */ | |
| 2817 int lose_lose = 0; | |
| 2818 Lisp_Object devcons, concons; | |
| 2819 | |
| 2820 /* If we're only looping through windows on a particular frame, | |
| 2821 FRAME points to that frame. If we're looping through windows | |
| 2822 on all frames, FRAME is 0. */ | |
| 444 | 2823 if (FRAMEP (which_frames)) |
| 2824 frame = XFRAME (which_frames); | |
| 2825 else if (NILP (which_frames)) | |
| 428 | 2826 frame = selected_frame (); |
| 2827 else | |
| 2828 frame = 0; | |
| 442 | 2829 |
| 2830 /* FRAME_ARG is Qlambda to stick to one frame, | |
| 2831 Qvisible to consider all visible frames, | |
| 2832 or Qt otherwise. */ | |
| 428 | 2833 if (frame) |
| 2834 frame_arg = Qlambda; | |
| 444 | 2835 else if (ZEROP (which_frames)) |
| 2836 frame_arg = which_frames; | |
| 2837 else if (EQ (which_frames, Qvisible)) | |
| 2838 frame_arg = which_frames; | |
| 428 | 2839 |
| 2840 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
| 2841 { | |
| 2842 Lisp_Object device = XCAR (devcons); | |
| 2843 Lisp_Object the_frame; | |
| 2844 | |
| 2845 if (frame) | |
| 793 | 2846 the_frame = wrap_frame (frame); |
| 428 | 2847 else |
| 2848 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device)); | |
| 2849 | |
| 2850 if (NILP (the_frame)) | |
| 2851 continue; | |
| 2852 | |
| 444 | 2853 if (!device_matches_device_spec (device, |
| 2854 NILP (which_devices) ? | |
| 2855 FRAME_CONSOLE (XFRAME (the_frame)) : | |
| 2856 which_devices)) | |
| 428 | 2857 continue; |
| 2858 | |
| 2859 /* Pick a window to start with. */ | |
| 2860 if (WINDOWP (obj)) | |
| 2861 w = obj; | |
| 2862 else | |
| 2863 w = FRAME_SELECTED_WINDOW (XFRAME (the_frame)); | |
| 2864 | |
| 2865 /* Figure out the last window we're going to mess with. Since | |
| 2866 Fnext_window, given the same options, is guaranteed to go in a | |
| 2867 ring, we can just use Fprevious_window to find the last one. | |
| 2868 | |
| 2869 We can't just wait until we hit the first window again, | |
| 2870 because it might be deleted. */ | |
| 2871 | |
| 707 | 2872 last_window = Fprevious_window (w, mini ? Qt : Qnil, frame_arg, device); |
| 428 | 2873 |
| 2874 best_window = Qnil; | |
| 2875 for (;;) | |
| 2876 { | |
| 2877 struct window *p = XWINDOW (w); | |
| 2878 | |
| 2879 /* Pick the next window now, since some operations will delete | |
| 2880 the current window. */ | |
| 442 | 2881 next_window = Fnext_window (w, mini ? Qt : Qnil, frame_arg, device); |
| 428 | 2882 |
| 2883 /* #### Still needed ?? */ | |
| 2884 /* Given the outstanding quality of the rest of this code, | |
| 2885 I feel no shame about putting this piece of shit in. */ | |
| 2886 if (++lose_lose >= 500) | |
| 707 | 2887 { |
| 2500 | 2888 /* Call to ABORT() added by Darryl Okahata (16 Nov. 2001), |
| 707 | 2889 at Ben's request, to catch any remaining bugs. |
| 2890 | |
| 2891 If you find that XEmacs is aborting here, and you | |
| 2892 need to be up and running ASAP, it should be safe to | |
| 2500 | 2893 comment out the following ABORT(), as long as you |
| 707 | 2894 leave the "break;" alone. */ |
| 2500 | 2895 ABORT(); |
| 707 | 2896 break; /* <--- KEEP THIS HERE! Do not delete! */ |
| 2897 } | |
| 428 | 2898 |
| 2899 /* Note that we do not pay attention here to whether | |
| 2900 the frame is visible, since Fnext_window skips non-visible frames | |
| 2901 if that is desired, under the control of frame_arg. */ | |
| 2902 if (! MINI_WINDOW_P (p) | |
| 2903 || (mini && minibuf_level > 0)) | |
| 2904 switch (type) | |
| 2905 { | |
| 2906 case GET_BUFFER_WINDOW: | |
| 2907 { | |
| 2908 if (XBUFFER (p->buffer) == XBUFFER (obj)) | |
| 2909 return w; | |
| 2910 break; | |
| 2911 } | |
| 2912 | |
| 2913 case GET_BUFFER_WINDOW_COUNT: | |
| 2914 { | |
| 2915 if (XBUFFER (p->buffer) == XBUFFER (obj)) | |
| 2916 count++; | |
| 2917 break; | |
| 2918 } | |
| 2919 | |
| 2920 case GET_LRU_WINDOW: | |
| 2921 { | |
| 2922 /* t as arg means consider only full-width windows */ | |
| 2923 if (!NILP (obj) | |
| 2924 && !window_full_width_p (p)) | |
| 2925 break; | |
| 2926 /* Ignore dedicated windows and minibuffers. */ | |
| 2927 if (MINI_WINDOW_P (p) | |
| 2928 || (dedicated_too ? 0 : !NILP (p->dedicated))) | |
| 2929 break; | |
| 2930 if (NILP (best_window) | |
| 2931 || (XINT (XWINDOW (best_window)->use_time) | |
| 2932 > XINT (p->use_time))) | |
| 2933 best_window = w; | |
| 2934 break; | |
| 2935 } | |
| 2936 | |
| 2937 case GET_BUFFER_MRU_WINDOW: | |
| 2938 { | |
| 2939 /* #### what about the first check in GET_LRU_WINDOW? */ | |
| 2940 /* Ignore dedicated windows and minibuffers. */ | |
| 2941 if (MINI_WINDOW_P (p) | |
| 2942 || (dedicated_too ? 0 : !NILP (p->dedicated))) | |
| 2943 break; | |
| 2944 | |
| 2945 if (XBUFFER (p->buffer) == XBUFFER (obj)) | |
| 2946 { | |
| 2947 if (NILP (best_window) | |
| 2948 || (XINT (XWINDOW (best_window)->use_time) | |
| 2949 < XINT (p->use_time))) | |
| 2950 best_window = w; | |
| 2951 } | |
| 2952 break; | |
| 2953 } | |
| 2954 | |
| 2955 case DELETE_OTHER_WINDOWS: | |
| 2956 { | |
| 2957 /* Don't delete the last window on a frame; this can | |
| 2958 happen when the minibuffer is selected, and would | |
| 2959 cause the frame to be deleted. */ | |
| 2960 if (p != XWINDOW (obj) && !TOP_LEVEL_WINDOW_P (XWINDOW (w))) | |
| 2961 Fdelete_window (w, Qnil); | |
| 2962 break; | |
| 2963 } | |
| 2964 | |
| 2965 case DELETE_BUFFER_WINDOWS: | |
| 2966 { | |
| 2967 if (EQ (p->buffer, obj)) | |
| 2968 { | |
| 2969 struct frame *f = XFRAME (WINDOW_FRAME (p)); | |
| 2970 | |
| 2971 /* If this window is dedicated, and in a frame | |
| 2972 of its own, kill the frame. */ | |
| 2973 if (EQ (w, FRAME_ROOT_WINDOW (f)) | |
| 2974 && !NILP (p->dedicated) | |
| 1979 | 2975 && (allow_deletion_of_last_visible_frame |
| 2976 || other_visible_frames (f))) | |
| 428 | 2977 { |
| 2978 /* Skip the other windows on this frame. | |
| 2979 There might be one, the minibuffer! */ | |
| 2980 if (! EQ (w, last_window)) | |
| 2981 while (f == XFRAME (WINDOW_FRAME | |
| 2982 (XWINDOW (next_window)))) | |
| 2983 { | |
| 2984 /* As we go, check for the end of the | |
| 2985 loop. We mustn't start going | |
| 2986 around a second time. */ | |
| 2987 if (EQ (next_window, last_window)) | |
| 2988 { | |
| 2989 last_window = w; | |
| 2990 break; | |
| 2991 } | |
| 2992 next_window = Fnext_window (next_window, | |
| 2993 mini ? Qt : Qnil, | |
| 2994 frame_arg, Qt); | |
| 2995 } | |
| 2996 /* Now we can safely delete the frame. */ | |
| 2997 Fdelete_frame (WINDOW_FRAME (p), Qnil); | |
| 2998 } | |
| 2999 else | |
| 3000 /* If we're deleting the buffer displayed in | |
| 3001 the only window on the frame, find a new | |
| 3002 buffer to display there. */ | |
| 3003 if (NILP (p->parent)) | |
| 3004 { | |
| 3005 Lisp_Object new_buffer; | |
| 3006 new_buffer = Fother_buffer (obj, Qnil, Qnil); | |
| 3007 if (NILP (new_buffer)) | |
| 3008 new_buffer = Fget_buffer_create (QSscratch); | |
| 440 | 3009 Fset_window_buffer (w, new_buffer, Qnil); |
| 428 | 3010 if (EQ (w, Fselected_window (Qnil))) |
| 3011 Fset_buffer (p->buffer); | |
| 3012 } | |
| 3013 else | |
| 3014 Fdelete_window (w, Qnil); | |
| 3015 } | |
| 3016 break; | |
| 3017 } | |
| 3018 | |
| 3019 case GET_LARGEST_WINDOW: | |
| 3020 { | |
| 3021 /* Ignore dedicated windows and minibuffers. */ | |
| 3022 if (MINI_WINDOW_P (p) | |
| 3023 || (dedicated_too ? 0 : !NILP (p->dedicated))) | |
| 3024 break; | |
| 3025 { | |
| 3026 /* write the check as follows to avoid tripping | |
| 3027 error_check_window() --ben */ | |
| 3028 struct window *b = NILP (best_window) ? 0 : | |
| 3029 XWINDOW (best_window); | |
| 3030 if (NILP (best_window) | |
| 3031 || ((WINDOW_HEIGHT (p) * WINDOW_WIDTH (p)) | |
| 3032 > (WINDOW_HEIGHT (b) * WINDOW_WIDTH (b)))) | |
| 3033 best_window = w; | |
| 3034 } | |
| 3035 break; | |
| 3036 } | |
| 3037 | |
| 3038 default: | |
| 2500 | 3039 ABORT (); |
| 428 | 3040 } |
| 3041 | |
| 3042 if (EQ (w, last_window)) | |
| 3043 break; | |
| 3044 | |
| 3045 w = next_window; | |
| 3046 } | |
| 3047 } | |
| 3048 | |
| 3049 return type == GET_BUFFER_WINDOW_COUNT ? make_int (count) : best_window; | |
| 3050 } | |
| 3051 | |
| 3052 #if 0 /* not currently used */ | |
| 3053 | |
| 3054 int | |
| 3055 buffer_window_count (struct buffer *b, struct frame *f) | |
| 3056 { | |
| 3057 Lisp_Object buffer, frame; | |
| 3058 | |
| 793 | 3059 frame = wrap_frame (f); |
| 3060 buffer = wrap_buffer (b); | |
| 428 | 3061 |
| 3062 return XINT (window_loop (GET_BUFFER_WINDOW_COUNT, buffer, 0, frame, 1, | |
| 3063 Qnil)); | |
| 3064 } | |
| 3065 | |
| 3066 int | |
| 3067 buffer_window_mru (struct window *w) | |
| 3068 { | |
| 3069 Lisp_Object window = | |
| 3070 window_loop (GET_BUFFER_MRU_WINDOW, w->buffer, 0, w->frame, 1, Qnil); | |
| 3071 | |
| 3072 if (NILP (window)) | |
| 3073 return 0; | |
| 3074 else if (XWINDOW (window) == w) | |
| 3075 return 1; | |
| 3076 else | |
| 3077 return 0; | |
| 3078 } | |
| 3079 | |
| 3080 #endif | |
| 3081 | |
| 3082 | |
| 3083 DEFUN ("get-lru-window", Fget_lru_window, 0, 2, 0, /* | |
| 3084 Return the window least recently selected or used for display. | |
| 444 | 3085 |
| 3086 By default, only the windows in the selected frame are considered. | |
| 3087 The optional argument WHICH-FRAMES changes this behavior: | |
| 3088 If optional argument WHICH-FRAMES is `visible', search all visible frames. | |
| 3089 If WHICH-FRAMES is 0, search all visible and iconified frames. | |
| 3090 If WHICH-FRAMES is t, search all frames. | |
| 3091 If WHICH-FRAMES is nil, search only the selected frame. | |
| 3092 If WHICH-FRAMES is a frame, search only that frame. | |
| 3093 | |
| 3094 The optional argument WHICH-DEVICES further clarifies on which devices | |
| 3095 to search for frames as specified by WHICH-FRAMES. This value is only | |
| 3096 meaningful if WHICH-FRAMES is non-nil. | |
| 3097 If nil or omitted, search all devices on the selected console. | |
| 3098 If a device, only search that device. | |
| 3099 If a console, search all devices on that console. | |
| 3100 If a device type, search all devices of that type. | |
| 3101 If `window-system', search all devices on window-system consoles. | |
| 3102 Any other non-nil value means search all devices. | |
| 428 | 3103 */ |
| 444 | 3104 (which_frames, which_devices)) |
| 428 | 3105 { |
| 3106 Lisp_Object w; | |
| 3107 /* First try for a non-dedicated window that is full-width */ | |
| 444 | 3108 w = window_loop (GET_LRU_WINDOW, Qt, 0, which_frames, 0, which_devices); |
| 428 | 3109 if (!NILP (w) && !EQ (w, Fselected_window (Qnil))) |
| 3110 return w; | |
| 3111 | |
| 3112 /* Then try for any non-dedicated window */ | |
| 444 | 3113 w = window_loop (GET_LRU_WINDOW, Qnil, 0, which_frames, 0, which_devices); |
| 428 | 3114 if (!NILP (w) && !EQ (w, Fselected_window (Qnil))) |
| 3115 return w; | |
| 3116 | |
| 3117 #if 0 | |
| 3118 /* FSFmacs never returns a dedicated window here. If we do, | |
| 3119 it makes `display-buffer' not work right. #### All of this | |
| 3120 shit is so disgusting and awful that it needs to be rethought | |
| 3121 from scratch. */ | |
| 3122 /* then try for a dedicated window that is full-width */ | |
| 444 | 3123 w = window_loop (GET_LRU_WINDOW, Qt, 0, which_frames, 1, which_devices); |
| 428 | 3124 if (!NILP (w) && !EQ (w, Fselected_window (Qnil))) |
| 3125 return w; | |
| 3126 | |
| 3127 /* If none of them, then all windows, dedicated or not. */ | |
| 444 | 3128 w = window_loop (GET_LRU_WINDOW, Qnil, 0, which_frames, 1, which_devices); |
| 428 | 3129 |
| 3130 /* At this point we damn well better have found something. */ | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4967
diff
changeset
|
3131 assert (!NILP (w)); |
| 428 | 3132 #endif |
| 3133 | |
| 3134 return w; | |
| 3135 } | |
| 3136 | |
| 3137 DEFUN ("get-largest-window", Fget_largest_window, 0, 2, 0, /* | |
| 3138 Return the window largest in area. | |
| 444 | 3139 |
| 3140 By default, only the windows in the selected frame are considered. | |
| 3141 The optional argument WHICH-FRAMES changes this behavior: | |
| 3142 If optional argument WHICH-FRAMES is `visible', search all visible frames. | |
| 3143 If WHICH-FRAMES is 0, search all visible and iconified frames. | |
| 3144 If WHICH-FRAMES is t, search all frames. | |
| 3145 If WHICH-FRAMES is nil, search only the selected frame. | |
| 3146 If WHICH-FRAMES is a frame, search only that frame. | |
| 3147 | |
| 3148 The optional argument WHICH-DEVICES further clarifies on which devices | |
| 3149 to search for frames as specified by WHICH-FRAMES. This value is only | |
| 3150 meaningful if WHICH-FRAMES is non-nil. | |
| 3151 If nil or omitted, search all devices on the selected console. | |
| 3152 If a device, only search that device. | |
| 3153 If a console, search all devices on that console. | |
| 3154 If a device type, search all devices of that type. | |
| 3155 If `window-system', search all devices on window-system consoles. | |
| 3156 Any other non-nil value means search all devices. | |
| 428 | 3157 */ |
| 444 | 3158 (which_frames, which_devices)) |
| 428 | 3159 { |
| 3160 /* Don't search dedicated windows because FSFmacs doesn't. | |
| 3161 This stuff is all black magic so don't try to apply common | |
| 3162 sense to it. */ | |
| 444 | 3163 return window_loop (GET_LARGEST_WINDOW, Qnil, 0, |
| 3164 which_frames, 0, which_devices); | |
| 428 | 3165 } |
| 3166 | |
| 3167 DEFUN ("get-buffer-window", Fget_buffer_window, 1, 3, 0, /* | |
| 3168 Return a window currently displaying BUFFER, or nil if none. | |
| 444 | 3169 |
| 3170 By default, only the windows in the selected frame are considered. | |
| 3171 The optional argument WHICH-FRAMES changes this behavior: | |
| 3172 If optional argument WHICH-FRAMES is `visible', search all visible frames. | |
| 3173 If WHICH-FRAMES is 0, search all visible and iconified frames. | |
| 3174 If WHICH-FRAMES is t, search all frames. | |
| 3175 If WHICH-FRAMES is nil, search only the selected frame. | |
| 3176 If WHICH-FRAMES is a frame, search only that frame. | |
| 3177 | |
| 3178 The optional argument WHICH-DEVICES further clarifies on which devices | |
| 3179 to search for frames as specified by WHICH-FRAMES. This value is only | |
| 3180 meaningful if WHICH-FRAMES is non-nil. | |
| 3181 If nil or omitted, search all devices on the selected console. | |
| 3182 If a device, only search that device. | |
| 3183 If a console, search all devices on that console. | |
| 3184 If a device type, search all devices of that type. | |
| 3185 If `window-system', search all devices on window-system consoles. | |
| 3186 Any other non-nil value means search all devices. | |
| 428 | 3187 */ |
| 444 | 3188 (buffer, which_frames, which_devices)) |
| 428 | 3189 { |
| 3190 buffer = Fget_buffer (buffer); | |
| 3191 if (BUFFERP (buffer)) | |
| 3192 /* Search dedicated windows too. (Doesn't matter here anyway.) */ | |
| 444 | 3193 return window_loop (GET_BUFFER_WINDOW, buffer, 1, |
| 3194 which_frames, 1, which_devices); | |
| 428 | 3195 else |
| 3196 return Qnil; | |
| 3197 } | |
| 3198 | |
| 3199 /* These functions used to be `buffer-left-margin-pixel-width', etc. | |
| 3200 but there is no sensible way to implement those functions, since | |
| 3201 you can't in general derive a window from a buffer. */ | |
| 3202 | |
| 3203 DEFUN ("window-left-margin-pixel-width", Fwindow_left_margin_pixel_width, | |
| 3204 0, 1, 0, /* | |
| 3205 Return the width in pixels of the left outside margin of window WINDOW. | |
| 3206 If WINDOW is nil, the selected window is assumed. | |
| 3207 */ | |
| 3208 (window)) | |
| 3209 { | |
| 3210 return make_int (window_left_margin_width (decode_window (window))); | |
| 3211 } | |
| 3212 | |
| 3213 DEFUN ("window-right-margin-pixel-width", Fwindow_right_margin_pixel_width, | |
| 3214 0, 1, 0, /* | |
| 3215 Return the width in pixels of the right outside margin of window WINDOW. | |
| 3216 If WINDOW is nil, the selected window is assumed. | |
| 3217 */ | |
| 3218 (window)) | |
| 3219 { | |
| 3220 return make_int (window_right_margin_width (decode_window (window))); | |
| 3221 } | |
| 3222 | |
| 3223 DEFUN ("delete-other-windows", Fdelete_other_windows, 0, 1, "", /* | |
| 3224 Make WINDOW (or the selected window) fill its frame. | |
| 3225 Only the frame WINDOW is on is affected. | |
| 3226 This function tries to reduce display jumps | |
| 3227 by keeping the text previously visible in WINDOW | |
| 3228 in the same place on the frame. Doing this depends on | |
| 3229 the value of (window-start WINDOW), so if calling this function | |
| 3230 in a program gives strange scrolling, make sure the window-start | |
| 3231 value is reasonable when this function is called. | |
| 3232 */ | |
| 3233 (window)) | |
| 3234 { | |
| 3235 struct window *w = decode_window (window); | |
| 1207 | 3236 struct buffer *b; |
| 665 | 3237 Charbpos start_pos; |
| 428 | 3238 int old_top = WINDOW_TOP (w); |
| 3239 | |
| 1207 | 3240 if (NILP (WINDOW_BUFFER (w))) |
| 3241 invalid_operation ("Can't delete other windows of combination", window); | |
| 3242 | |
| 793 | 3243 window = wrap_window (w); |
| 1207 | 3244 b = XBUFFER (WINDOW_BUFFER (w)); |
| 428 | 3245 |
| 3246 if (MINI_WINDOW_P (w) && old_top > 0) | |
| 563 | 3247 invalid_operation ("Can't expand minibuffer to full frame", Qunbound); |
| 428 | 3248 |
| 3249 /* Ignore dedicated windows. */ | |
| 3250 window_loop (DELETE_OTHER_WINDOWS, window, 0, w->frame, 0, Qnil); | |
| 3251 | |
| 3252 start_pos = marker_position (w->start[CURRENT_DISP]); | |
| 3253 | |
| 3254 /* Try to minimize scrolling, by setting the window start to the | |
| 3255 point which will cause the text at the old window start to be at | |
| 3256 the same place on the frame. But don't try to do this if the | |
| 3257 window start is outside the visible portion (as might happen when | |
| 3258 the display is not current, due to typeahead). */ | |
| 3259 if (start_pos >= BUF_BEGV (b) && start_pos <= BUF_ZV (b) | |
| 3260 && !MINI_WINDOW_P (w)) | |
| 3261 { | |
| 665 | 3262 Charbpos new_start = start_with_line_at_pixpos (w, start_pos, old_top); |
| 428 | 3263 |
| 3264 if (new_start >= BUF_BEGV (b) && new_start <= BUF_ZV (b)) | |
| 3265 { | |
| 3266 Fset_marker (w->start[CURRENT_DISP], make_int (new_start), | |
| 3267 w->buffer); | |
| 3268 w->start_at_line_beg = beginning_of_line_p (b, new_start); | |
| 3269 } | |
| 3270 /* We need to do this, so that the window-scroll-functions | |
| 3271 get called. */ | |
| 3272 w->force_start = 1; | |
| 3273 } | |
| 3274 | |
| 3275 return Qnil; | |
| 3276 } | |
| 3277 | |
| 3278 DEFUN ("delete-windows-on", Fdelete_windows_on, 1, 3, | |
| 3279 "bDelete windows on (buffer): ", /* | |
| 3280 Delete all windows showing BUFFER. | |
| 444 | 3281 |
| 3282 Optional second argument WHICH-FRAMES controls which frames are affected. | |
| 428 | 3283 If nil or omitted, delete all windows showing BUFFER in any frame. |
| 3284 If t, delete only windows showing BUFFER in the selected frame. | |
| 3285 If `visible', delete all windows showing BUFFER in any visible frame. | |
| 3286 If a frame, delete only windows showing BUFFER in that frame. | |
| 444 | 3287 Warning: WHICH-FRAMES has the same meaning as with `next-window', |
| 3288 except that the meanings of nil and t are reversed. | |
| 3289 | |
| 3290 The optional third argument WHICH-DEVICES further clarifies on which | |
| 3291 devices to search for frames as specified by WHICH-FRAMES. This value | |
| 3292 is only meaningful if WHICH-FRAMES is not t. | |
| 3293 If nil or omitted, search only the selected console. | |
| 3294 If a device, only search that device. | |
| 3295 If a console, search all devices on that console. | |
| 3296 If a device type, search all devices of that type. | |
| 3297 If `window-system', search all devices on a window system. | |
| 3298 Any other non-nil value means search all devices. | |
| 428 | 3299 */ |
| 444 | 3300 (buffer, which_frames, which_devices)) |
| 428 | 3301 { |
| 3302 /* This function can GC */ | |
| 444 | 3303 buffer = Fget_buffer (buffer); |
| 3304 CHECK_BUFFER (buffer); | |
| 3305 | |
| 3306 /* WHICH-FRAMES values t and nil mean the opposite of what | |
| 3307 window_loop expects. */ | |
| 3308 if (EQ (which_frames, Qnil)) | |
| 3309 which_frames = Qt; | |
| 3310 else if (EQ (which_frames, Qt)) | |
| 3311 which_frames = Qnil; | |
| 3312 | |
| 3313 /* Ignore dedicated windows. */ | |
| 3314 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, | |
| 3315 which_frames, 0, which_devices); | |
| 428 | 3316 return Qnil; |
| 3317 } | |
| 3318 | |
| 448 | 3319 static Lisp_Object |
| 3320 list_windows (struct window *w, Lisp_Object value) | |
| 3321 { | |
| 3322 for (;;) | |
| 3323 { | |
| 3324 if (!NILP (w->hchild)) | |
| 3325 value = list_windows (XWINDOW (w->hchild), value); | |
| 3326 else if (!NILP (w->vchild)) | |
| 3327 value = list_windows (XWINDOW (w->vchild), value); | |
| 3328 else | |
| 3329 { | |
| 793 | 3330 Lisp_Object window = wrap_window (w); |
| 3331 | |
| 448 | 3332 value = Fcons (window, value); |
| 3333 } | |
| 3334 if (NILP (w->next)) | |
| 3335 break; | |
| 3336 w = XWINDOW (w->next); | |
| 3337 } | |
| 3338 return value; | |
| 3339 } | |
| 3340 | |
| 3341 static Lisp_Object | |
| 3342 list_all_windows (Lisp_Object frame_spec, Lisp_Object device_spec) | |
| 3343 { | |
| 3344 Lisp_Object devcons, concons; | |
| 3345 Lisp_Object retval = Qnil; | |
| 3346 | |
| 3347 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
| 3348 { | |
| 3349 Lisp_Object frame_list, the_window; | |
| 3350 Lisp_Object device, tail; | |
| 3351 | |
| 3352 device = XCAR (devcons); | |
| 3353 frame_list = DEVICE_FRAME_LIST (XDEVICE (device)); | |
| 3354 | |
| 3355 LIST_LOOP (tail, frame_list) | |
| 3356 { | |
| 3357 if ((NILP (frame_spec) | |
| 3358 && !EQ (XCAR (tail), DEVICE_SELECTED_FRAME (XDEVICE (device)))) | |
| 3359 || (EQ (frame_spec, Qvisible) | |
| 3360 && !FRAME_VISIBLE_P (XFRAME (XCAR (tail)))) | |
| 3361 || (FRAMEP (frame_spec) | |
| 3362 && !EQ (frame_spec, XCAR (tail))) | |
| 3363 || (!NILP (frame_spec) | |
| 3364 && !device_matches_device_spec (device, | |
| 3365 NILP (device_spec) ? | |
| 3366 Vselected_console : | |
| 3367 device_spec))) | |
| 3368 continue; | |
| 3369 the_window = FRAME_ROOT_WINDOW (XFRAME (XCAR (tail))); | |
| 3370 retval = list_windows (XWINDOW (the_window), retval); | |
| 3371 } | |
| 3372 } | |
| 3373 return Fnreverse (retval); | |
| 3374 } | |
| 3375 | |
| 444 | 3376 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, 1, 3, |
| 428 | 3377 "bReplace buffer in windows: ", /* |
| 3378 Replace BUFFER with some other buffer in all windows showing it. | |
| 444 | 3379 |
| 3380 Optional second argument WHICH-FRAMES controls which frames are affected. | |
| 3381 If nil or omitted, all frames are affected. | |
| 3382 If t, only the selected frame is affected. | |
| 3383 If `visible', all visible frames are affected. | |
| 3384 If a frame, only that frame is affected. | |
| 3385 Warning: WHICH-FRAMES has the same meaning as with `next-window', | |
| 3386 except that the meanings of nil and t are reversed. | |
| 3387 | |
| 3388 The optional third argument WHICH-DEVICES further clarifies on which | |
| 3389 devices to search for frames as specified by WHICH-FRAMES. This value | |
| 3390 is only meaningful if WHICH-FRAMES is not t. | |
| 3391 If nil or omitted, search only the selected console. | |
| 3392 If a device, only search that device. | |
| 3393 If a console, search all devices on that console. | |
| 3394 If a device type, search all devices of that type. | |
| 3395 If `window-system', search all devices on a window system. | |
| 3396 Any other non-nil value means search all devices. | |
| 428 | 3397 */ |
| 444 | 3398 (buffer, which_frames, which_devices)) |
| 428 | 3399 { |
| 3400 /* This function can GC */ | |
| 448 | 3401 Lisp_Object window_list; |
| 3402 Lisp_Object tail; | |
| 3403 struct gcpro gcpro1, gcpro2; | |
| 3404 | |
| 444 | 3405 if (EQ (which_frames, Qnil)) |
| 3406 which_frames = Qt; | |
| 3407 else if (EQ (which_frames, Qt)) | |
| 3408 which_frames = Qnil; | |
| 448 | 3409 window_list = list_all_windows (which_frames, which_devices); |
| 3410 | |
| 3411 buffer = Fget_buffer (buffer); | |
| 3412 CHECK_BUFFER (buffer); | |
| 3413 | |
| 3414 GCPRO2 (window_list, buffer); | |
| 3415 LIST_LOOP (tail, window_list) | |
| 3416 { | |
| 3417 Lisp_Object window = XCAR (tail); | |
| 3418 if (!MINI_WINDOW_P (XWINDOW (window)) | |
| 3419 && EQ (XWINDOW (window)->buffer, buffer)) | |
| 3420 { | |
| 3421 Lisp_Object another_buffer = Fother_buffer (buffer, Qnil, Qnil); | |
| 3422 Lisp_Object frame = WINDOW_FRAME (XWINDOW (window)); | |
| 3423 if (NILP (another_buffer)) | |
| 3424 another_buffer = Fget_buffer_create (QSscratch); | |
| 3425 if (!NILP (XWINDOW (window)->dedicated) | |
| 3426 && EQ (window, | |
| 3427 FRAME_ROOT_WINDOW (XFRAME (frame))) | |
| 1979 | 3428 && (allow_deletion_of_last_visible_frame |
| 3429 || other_visible_frames (XFRAME (frame)))) | |
| 448 | 3430 { |
| 3431 delete_frame_internal (XFRAME (frame), 0, 0, 0); /* GC */ | |
| 3432 } | |
| 3433 else | |
| 3434 { | |
| 3435 Fset_window_buffer (window, another_buffer, Qnil); | |
| 3436 if (EQ (window, Fselected_window (Qnil))) | |
| 3437 Fset_buffer (XWINDOW (window)->buffer); | |
| 3438 } | |
| 3439 } | |
| 3440 } | |
| 3441 UNGCPRO; | |
| 428 | 3442 return Qnil; |
| 3443 } | |
| 3444 | |
| 3445 /* The smallest acceptable dimensions for a window. Anything smaller | |
| 3446 might crash Emacs. */ | |
| 3447 #define MIN_SAFE_WINDOW_WIDTH (2) | |
| 3448 #define MIN_SAFE_WINDOW_HEIGHT (2) | |
| 3449 | |
| 3450 /* Make sure that window_min_height and window_min_width are | |
| 3451 not too small; if they are, set them to safe minima. */ | |
| 3452 | |
| 3453 static void | |
| 3454 check_min_window_sizes (void) | |
| 3455 { | |
| 3456 /* Smaller values might permit a crash. */ | |
| 3457 if (window_min_width < MIN_SAFE_WINDOW_WIDTH) | |
| 3458 window_min_width = MIN_SAFE_WINDOW_WIDTH; | |
| 3459 if (window_min_height < MIN_SAFE_WINDOW_HEIGHT) | |
| 3460 window_min_height = MIN_SAFE_WINDOW_HEIGHT; | |
| 3461 } | |
| 3462 | |
| 440 | 3463 static int |
| 3464 frame_min_height (struct frame *frame) | |
| 3465 { | |
| 3466 /* For height, we have to see whether the frame has a minibuffer, and | |
| 3467 whether it wants a modeline. */ | |
| 3468 return (FRAME_MINIBUF_ONLY_P (frame) ? MIN_SAFE_WINDOW_HEIGHT - 1 | |
| 3469 : (! FRAME_HAS_MINIBUF_P (frame)) ? MIN_SAFE_WINDOW_HEIGHT | |
| 3470 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); | |
| 3471 } | |
| 3472 | |
| 3473 /* Return non-zero if both frame sizes are less than or equal to | |
| 3474 minimal allowed values. ROWS and COLS are in characters */ | |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3475 static int |
|
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3476 frame_size_valid_p (struct frame *frame, int cols, int rows) |
| 440 | 3477 { |
| 3478 return (rows >= frame_min_height (frame) | |
| 3479 && cols >= MIN_SAFE_WINDOW_WIDTH); | |
| 3480 } | |
| 3481 | |
| 3482 /* Return non-zero if both frame sizes are less than or equal to | |
| 3483 minimal allowed values. WIDTH and HEIGHT are in pixels */ | |
| 3484 int | |
| 3485 frame_pixsize_valid_p (struct frame *frame, int width, int height) | |
| 3486 { | |
| 3487 int rows, cols; | |
| 5043 | 3488 pixel_to_char_size (frame, width, height, &cols, &rows); |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3489 return frame_size_valid_p (frame, cols, rows); |
| 440 | 3490 } |
| 3491 | |
| 428 | 3492 /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
| 3493 minimum allowable size. */ | |
| 3494 void | |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3495 check_frame_size (struct frame *frame, int *cols, int *rows) |
| 428 | 3496 { |
| 440 | 3497 int min_height = frame_min_height (frame); |
| 5043 | 3498 int min_pixwidth, min_pixheight; |
| 3499 int min_geomwidth, min_geomheight; | |
| 3500 | |
| 3501 /* There is no char_to_frame_unit_size(). This can be done with | |
| 3502 frame_conversion_internal(), but that's currently static, and we can | |
| 3503 do it fine with two steps, as follows. */ | |
| 3504 char_to_pixel_size (frame, MIN_SAFE_WINDOW_WIDTH, min_height, | |
| 3505 &min_pixwidth, &min_pixheight); | |
| 3506 pixel_to_frame_unit_size (frame, min_pixwidth, min_pixheight, | |
| 3507 &min_geomwidth, &min_geomheight); | |
| 3508 if (*rows < min_geomheight) | |
| 3509 *rows = min_geomheight; | |
| 3510 if (*cols < min_geomwidth) | |
| 3511 *cols = min_geomwidth; | |
| 428 | 3512 } |
| 3513 | |
| 3514 /* Normally the window is deleted if it gets too small. | |
| 3515 nodelete nonzero means do not do this. | |
| 3516 (The caller should check later and do so if appropriate) */ | |
| 3517 static void | |
| 3518 set_window_pixsize (Lisp_Object window, int new_pixsize, int nodelete, | |
| 3519 int set_height) | |
| 3520 { | |
| 3521 struct window *w = XWINDOW (window); | |
| 3522 struct frame *f = XFRAME (w->frame); | |
| 3523 struct window *c; | |
| 3524 int old_pixsize = (set_height ? WINDOW_HEIGHT (w) : WINDOW_WIDTH (w)); | |
| 3525 Lisp_Object child, minor_kid, major_kid; | |
| 3526 int minsize; | |
| 3527 int line_size; | |
| 3528 int defheight, defwidth; | |
| 3529 | |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3530 default_face_width_and_height (window, &defwidth, &defheight); |
| 428 | 3531 line_size = (set_height ? defheight : defwidth); |
| 3532 | |
| 3533 check_min_window_sizes (); | |
| 3534 | |
| 3535 minsize = (set_height ? window_min_height : window_min_width); | |
| 3536 minsize *= line_size; | |
| 3537 | |
| 3538 if (!nodelete | |
| 3539 && !TOP_LEVEL_WINDOW_P (w) | |
|
4375
74e0e1131e01
Update window-size computation.
Mike Sperber <sperber@deinprogramm.de>
parents:
3707
diff
changeset
|
3540 && (new_pixsize + window_modeline_height (w)) < minsize) |
| 428 | 3541 { |
| 3542 Fdelete_window (window, Qnil); | |
| 3543 return; | |
| 3544 } | |
| 3545 | |
| 3546 SET_LAST_MODIFIED (w, 0); | |
| 3547 SET_LAST_FACECHANGE (w); | |
| 3548 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); /* multiple windows affected */ | |
| 3549 if (set_height) | |
| 3550 { | |
| 3551 WINDOW_HEIGHT (w) = new_pixsize; | |
| 3552 major_kid = w->vchild; | |
| 3553 minor_kid = w->hchild; | |
| 3554 } | |
| 3555 else | |
| 3556 { | |
| 3557 WINDOW_WIDTH (w) = new_pixsize; | |
| 3558 major_kid = w->hchild; | |
| 3559 minor_kid = w->vchild; | |
| 3560 } | |
| 3561 | |
| 3562 if (!NILP (minor_kid)) | |
| 3563 { | |
| 3564 for (child = minor_kid; !NILP (child); child = XWINDOW (child)->next) | |
| 3565 { | |
| 3566 if (set_height) | |
| 3567 WINDOW_TOP (XWINDOW (child)) = WINDOW_TOP (w); | |
| 3568 else | |
| 3569 WINDOW_LEFT (XWINDOW (child)) = WINDOW_LEFT (w); | |
| 3570 | |
| 3571 set_window_pixsize (child, new_pixsize, nodelete, set_height); | |
| 3572 } | |
| 3573 } | |
| 3574 else if (!NILP (major_kid)) | |
| 3575 { | |
| 3576 int last_pos, last_old_pos, pos, old_pos, first; | |
| 3577 int pixel_adj_left = new_pixsize - old_pixsize; | |
| 3578 int div_val = old_pixsize << 1; | |
| 3579 | |
| 3580 /* | |
| 3581 * Previously we bailed out here if there was no size change. | |
| 3582 * (pixel_adj_left == 0) But this broke toolbar updates. If a | |
| 3583 * toolbar appears or disappears, windows may not change size, | |
| 3584 * but their top and left coordinates need to be updated. | |
| 3585 * | |
| 3586 * So we don't bail until after the loop below. | |
| 3587 */ | |
| 3588 | |
| 3589 last_pos = first = (set_height ? WINDOW_TOP (w) : WINDOW_LEFT (w)); | |
| 3590 last_old_pos = 0; | |
| 3591 | |
| 3592 for (child = major_kid; !NILP (child); child = c->next) | |
| 3593 { | |
| 3594 c = XWINDOW (child); | |
| 3595 | |
| 3596 if (set_height) | |
| 3597 { | |
| 3598 old_pos = last_old_pos + WINDOW_HEIGHT (c); | |
| 3599 WINDOW_TOP (c) = last_pos; | |
| 3600 } | |
| 3601 else | |
| 3602 { | |
| 3603 old_pos = last_old_pos + WINDOW_WIDTH (c); | |
| 3604 WINDOW_LEFT (c) = last_pos; | |
| 3605 } | |
| 3606 | |
| 3607 pos = (((old_pos * new_pixsize) << 1) + old_pixsize) / div_val; | |
| 3608 /* All but the last window should have a height which is | |
| 3609 a multiple of the default line height. */ | |
| 3610 if (!NILP (c->next)) | |
|
4446
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3611 { |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3612 /* |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3613 * Round up when we're shrinking, down when we're growing |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3614 * to make sure that pairs of grow / shrink meant to |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3615 * cancel out actually do cancel out. |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3616 */ |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3617 if (pixel_adj_left < 0) |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3618 pos = ((pos + line_size -1) / line_size) * line_size; |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3619 else |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3620 pos = (pos / line_size) * line_size; |
|
c32b3d10c56b
Fix problem with `resize-minibuffer-mode'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4375
diff
changeset
|
3621 } |
| 428 | 3622 |
| 3623 /* Avoid confusion: don't delete child if it becomes too small */ | |
| 3624 set_window_pixsize (child, pos + first - last_pos, 1, set_height); | |
| 3625 | |
| 3626 last_pos = pos + first; | |
| 3627 last_old_pos = old_pos; | |
| 3628 } | |
| 3629 | |
| 3630 /* Sometimes we may get called with our old size. In that case | |
| 3631 we don't need to do anything else. */ | |
| 3632 if (!pixel_adj_left) | |
| 3633 return; | |
| 3634 | |
| 3635 /* Now delete any children that became too small. */ | |
| 3636 if (!nodelete) | |
| 3637 for (child = major_kid; !NILP (child); child = XWINDOW (child)->next) | |
| 3638 { | |
| 3639 if (set_height) | |
| 3640 set_window_pixheight (child, WINDOW_HEIGHT (XWINDOW (child)), 0); | |
| 3641 else | |
| 3642 set_window_pixwidth (child, WINDOW_WIDTH (XWINDOW (child)), 0); | |
| 3643 } | |
| 3644 } | |
| 3645 } | |
| 3646 | |
| 3647 /* Set the height of WINDOW and all its inferiors. */ | |
| 3648 void | |
| 3649 set_window_pixheight (Lisp_Object window, int new_pixheight, int nodelete) | |
| 3650 { | |
| 3651 set_window_pixsize (window, new_pixheight, nodelete, 1); | |
| 3652 } | |
| 3653 | |
| 3654 /* Recursively set width of WINDOW and its inferiors. */ | |
| 3655 void | |
| 3656 set_window_pixwidth (Lisp_Object window, int new_pixwidth, int nodelete) | |
| 3657 { | |
| 3658 set_window_pixsize (window, new_pixwidth, nodelete, 0); | |
| 3659 } | |
| 3660 | |
| 3661 | |
| 3662 static int window_select_count; | |
| 3663 | |
| 440 | 3664 DEFUN ("set-window-buffer", Fset_window_buffer, 2, 3, 0, /* |
| 428 | 3665 Make WINDOW display BUFFER as its contents. |
| 3666 BUFFER can be a buffer or buffer name. | |
| 440 | 3667 |
| 442 | 3668 With non-nil optional argument NORECORD, do not modify the |
| 440 | 3669 global or per-frame buffer ordering. |
| 428 | 3670 */ |
| 440 | 3671 (window, buffer, norecord)) |
| 428 | 3672 { |
| 3673 Lisp_Object tem; | |
| 3674 struct window *w = decode_window (window); | |
| 448 | 3675 int old_buffer_local_face_property = 0; |
| 428 | 3676 |
| 3677 buffer = Fget_buffer (buffer); | |
| 3678 CHECK_BUFFER (buffer); | |
| 3679 | |
| 3680 if (!BUFFER_LIVE_P (XBUFFER (buffer))) | |
| 563 | 3681 invalid_operation ("Attempt to display deleted buffer", Qunbound); |
| 428 | 3682 |
| 3683 tem = w->buffer; | |
| 3684 if (NILP (tem)) | |
| 563 | 3685 invalid_operation ("Window is deleted", Qunbound); |
| 428 | 3686 else if (EQ (tem, buffer)) |
| 3687 return Qnil; | |
| 3688 else if (! EQ (tem, Qt)) /* w->buffer is t when the window | |
| 3689 is first being set up. */ | |
| 3690 { | |
| 3691 if (!NILP (w->dedicated) && !EQ (tem, buffer)) | |
| 563 | 3692 signal_error (Qinvalid_operation, "Window is dedicated to buffer", tem); |
| 428 | 3693 |
| 448 | 3694 old_buffer_local_face_property = |
| 3695 XBUFFER (w->buffer)->buffer_local_face_property; | |
| 428 | 3696 unshow_buffer (w); |
| 3697 } | |
| 3698 | |
| 3699 w->buffer = buffer; | |
| 3700 w->window_end_pos[CURRENT_DISP] = 0; | |
| 3701 w->hscroll = 0; | |
| 3702 w->modeline_hscroll = 0; | |
| 844 | 3703 #if 0 /* pre point caches */ |
| 428 | 3704 Fset_marker (w->pointm[CURRENT_DISP], |
| 3705 make_int (BUF_PT (XBUFFER (buffer))), | |
| 3706 buffer); | |
| 3707 set_marker_restricted (w->start[CURRENT_DISP], | |
| 3708 make_int (XBUFFER (buffer)->last_window_start), | |
| 3709 buffer); | |
| 844 | 3710 #else |
| 3711 { | |
| 3712 Lisp_Object marker = Fgethash (buffer, w->saved_point_cache, Qnil); | |
| 3713 Lisp_Object newpoint = | |
| 3714 !NILP (marker) ? make_int (marker_position (marker)) : | |
| 3715 make_int (BUF_PT (XBUFFER (buffer))); | |
| 3716 /* Previously, we had in here set-window-point, which did one of the | |
| 3717 following two, but not both. However, that could result in pointm | |
| 3718 being in a different buffer from the window's buffer! Probably | |
| 3719 not a travesty since it always occurred when the window was | |
| 3720 selected, meaning its value of point was ignored in favor of the | |
| 3721 buffer's; but it tripped an assert() in unshow_buffer(). */ | |
| 3722 set_marker_restricted (w->pointm[CURRENT_DISP], newpoint, buffer); | |
| 3723 if (EQ (wrap_window (w), Fselected_window (Qnil))) | |
| 3724 Fgoto_char (newpoint, buffer); /* this will automatically clip to | |
| 3725 accessible */ | |
| 3726 marker = Fgethash (buffer, w->saved_last_window_start_cache, Qnil); | |
| 3727 set_marker_restricted (w->start[CURRENT_DISP], | |
| 3728 !NILP (marker) ? | |
| 3729 make_int (marker_position (marker)) : | |
| 3730 make_int (XBUFFER (buffer)->last_window_start), | |
| 3731 buffer); | |
| 3732 } | |
| 3733 #endif | |
| 3734 | |
| 428 | 3735 Fset_marker (w->sb_point, w->start[CURRENT_DISP], buffer); |
| 3736 /* set start_at_line_beg correctly. GE */ | |
| 844 | 3737 w->start_at_line_beg = |
| 3738 beginning_of_line_p (XBUFFER (buffer), | |
| 3739 marker_position (w->start[CURRENT_DISP])); | |
| 3740 w->force_start = 0; /* XEmacs fix */ | |
| 428 | 3741 SET_LAST_MODIFIED (w, 1); |
| 3742 SET_LAST_FACECHANGE (w); | |
| 3743 MARK_WINDOWS_CHANGED (w); | |
| 448 | 3744 { |
| 3745 int new_buffer_local_face_property = | |
| 3746 XBUFFER (w->buffer)->buffer_local_face_property; | |
| 3747 | |
| 3748 if (new_buffer_local_face_property | |
| 3749 || new_buffer_local_face_property != old_buffer_local_face_property) | |
| 3750 MARK_WINDOW_FACES_CHANGED (w); | |
| 3751 } | |
| 428 | 3752 recompute_all_cached_specifiers_in_window (w); |
| 3753 if (EQ (window, Fselected_window (Qnil))) | |
| 3754 { | |
| 440 | 3755 if (NILP (norecord)) |
| 3756 Frecord_buffer (buffer); | |
| 3757 | |
| 428 | 3758 Fset_buffer (buffer); |
| 3759 } | |
|
5214
0b4d355771bd
Import buffer-display-count, buffer-display-time; thank you, Jeff Sparkes.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
3760 if (NILP (XBUFFER (buffer)->display_count)) |
|
0b4d355771bd
Import buffer-display-count, buffer-display-time; thank you, Jeff Sparkes.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
3761 XBUFFER (buffer)->display_count = make_int (1); |
|
0b4d355771bd
Import buffer-display-count, buffer-display-time; thank you, Jeff Sparkes.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
3762 else |
|
0b4d355771bd
Import buffer-display-count, buffer-display-time; thank you, Jeff Sparkes.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
3763 XBUFFER (buffer)->display_count = make_int (1 + XINT (XBUFFER (buffer)->display_count)); |
|
0b4d355771bd
Import buffer-display-count, buffer-display-time; thank you, Jeff Sparkes.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
3764 XBUFFER (buffer)->display_time = Fcurrent_time(); |
| 428 | 3765 return Qnil; |
| 3766 } | |
| 3767 | |
| 3768 DEFUN ("select-window", Fselect_window, 1, 2, 0, /* | |
| 3769 Select WINDOW. Most editing will apply to WINDOW's buffer. | |
| 3770 The main editor command loop selects the buffer of the selected window | |
| 3771 before each command. | |
| 3772 | |
| 442 | 3773 With non-nil optional argument NORECORD, do not modify the |
| 428 | 3774 global or per-frame buffer ordering. |
| 3775 */ | |
| 3776 (window, norecord)) | |
| 3777 { | |
| 3778 struct window *w; | |
| 3779 Lisp_Object old_selected_window = Fselected_window (Qnil); | |
| 3780 | |
| 3781 CHECK_LIVE_WINDOW (window); | |
| 3782 w = XWINDOW (window); | |
| 3783 | |
| 3784 /* we have already caught dead-window errors */ | |
| 3785 if (!NILP (w->hchild) || !NILP (w->vchild)) | |
| 563 | 3786 invalid_operation ("Trying to select non-leaf window", Qunbound); |
| 428 | 3787 |
| 3788 w->use_time = make_int (++window_select_count); | |
| 442 | 3789 |
| 428 | 3790 if (EQ (window, old_selected_window)) |
| 3791 return window; | |
| 3792 | |
| 3793 /* deselect the old window, if it exists (it might not exist if | |
| 3794 the selected device has no frames, which occurs at startup) */ | |
| 3795 if (!NILP (old_selected_window)) | |
| 3796 { | |
| 3797 struct window *ow = XWINDOW (old_selected_window); | |
| 3798 | |
| 3799 Fset_marker (ow->pointm[CURRENT_DISP], | |
| 3800 make_int (BUF_PT (XBUFFER (ow->buffer))), | |
| 3801 ow->buffer); | |
| 3802 | |
| 3803 MARK_WINDOWS_CHANGED (ow); | |
| 3804 } | |
| 3805 | |
| 3806 /* now select the window's frame */ | |
| 3807 set_frame_selected_window (XFRAME (WINDOW_FRAME (w)), window); | |
| 3808 | |
| 3809 select_frame_1 (WINDOW_FRAME (w)); | |
| 3810 | |
| 3811 /* also select the window's buffer */ | |
| 3812 if (NILP (norecord)) | |
| 3813 Frecord_buffer (w->buffer); | |
| 3814 Fset_buffer (w->buffer); | |
| 3815 | |
| 3816 /* Go to the point recorded in the window. | |
| 3817 This is important when the buffer is in more | |
| 3818 than one window. It also matters when | |
| 3819 redisplay_window has altered point after scrolling, | |
| 3820 because it makes the change only in the window. */ | |
| 3821 { | |
| 665 | 3822 Charbpos new_point = marker_position (w->pointm[CURRENT_DISP]); |
| 428 | 3823 if (new_point < BUF_BEGV (current_buffer)) |
| 3824 new_point = BUF_BEGV (current_buffer); | |
| 3825 else if (new_point > BUF_ZV (current_buffer)) | |
| 3826 new_point = BUF_ZV (current_buffer); | |
| 3827 | |
| 3828 BUF_SET_PT (current_buffer, new_point); | |
| 3829 } | |
| 3830 | |
| 3831 MARK_WINDOWS_CHANGED (w); | |
| 3832 | |
| 3833 return window; | |
| 3834 } | |
| 3835 | |
| 3836 Lisp_Object | |
| 3837 display_buffer (Lisp_Object buffer, Lisp_Object not_this_window_p, | |
| 3838 Lisp_Object override_frame) | |
| 3839 { | |
| 3840 return call3 (Qdisplay_buffer, buffer, not_this_window_p, override_frame); | |
| 3841 } | |
| 3842 | |
| 3843 void | |
| 3844 temp_output_buffer_show (Lisp_Object buf, Lisp_Object same_frame) | |
| 3845 { | |
| 3846 /* This function can GC */ | |
| 3847 Lisp_Object window; | |
| 3848 struct window *w; | |
| 3849 struct buffer *b = XBUFFER (buf); | |
| 3850 | |
| 3851 BUF_SAVE_MODIFF (XBUFFER (buf)) = BUF_MODIFF (b); | |
| 3852 widen_buffer (b, 0); | |
| 3853 BUF_SET_PT (b, BUF_BEG (b)); | |
| 3854 | |
| 3855 if (!NILP (Vtemp_buffer_show_function)) | |
| 3856 call1 (Vtemp_buffer_show_function, buf); | |
| 3857 else | |
| 3858 { | |
| 3859 window = display_buffer (buf, Qnil, same_frame); | |
| 3860 | |
| 3861 if (!EQ (XWINDOW (window)->frame, Fselected_frame (Qnil))) | |
| 3862 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); | |
| 3863 | |
| 3864 Vminibuffer_scroll_window = window; | |
| 3865 w = XWINDOW (window); | |
| 3866 w->hscroll = 0; | |
| 3867 w->modeline_hscroll = 0; | |
| 3868 set_marker_restricted (w->start[CURRENT_DISP], make_int (1), buf); | |
| 3869 set_marker_restricted (w->pointm[CURRENT_DISP], make_int (1), buf); | |
| 3870 set_marker_restricted (w->sb_point, make_int (1), buf); | |
| 3871 } | |
| 3872 } | |
| 3873 | |
| 3874 static void | |
| 3875 make_dummy_parent (Lisp_Object window) | |
| 3876 { | |
| 3877 struct window *o = XWINDOW (window); | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
3878 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (window); |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
3879 struct window *p = XWINDOW (obj); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
3880 |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
3881 copy_lisp_object (obj, window); |
| 428 | 3882 |
| 3883 /* Don't copy the pointers to the line start cache or the face | |
| 3884 instances. */ | |
| 3885 p->line_start_cache = Dynarr_new (line_start_cache); | |
| 3092 | 3886 #ifdef NEW_GC |
| 3887 p->face_cachels = Dynarr_lisp_new (face_cachel, | |
| 3888 &lrecord_face_cachel_dynarr, | |
| 3889 &lrecord_face_cachel); | |
| 3890 p->glyph_cachels = Dynarr_lisp_new (glyph_cachel, | |
| 3891 &lrecord_glyph_cachel_dynarr, | |
| 3892 &lrecord_glyph_cachel); | |
| 3893 #else /* not NEW_GC */ | |
| 428 | 3894 p->face_cachels = Dynarr_new (face_cachel); |
| 3895 p->glyph_cachels = Dynarr_new (glyph_cachel); | |
| 3092 | 3896 #endif /* not NEW_GC */ |
| 442 | 3897 p->subwindow_instance_cache = |
| 450 | 3898 make_image_instance_cache_hash_table (); |
| 428 | 3899 |
| 3900 /* Put new into window structure in place of window */ | |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
3901 replace_window (window, obj); |
| 428 | 3902 |
| 3903 o->next = Qnil; | |
| 3904 o->prev = Qnil; | |
| 3905 o->vchild = Qnil; | |
| 3906 o->hchild = Qnil; | |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
3907 o->parent = obj; |
| 428 | 3908 |
| 3909 p->start[CURRENT_DISP] = Qnil; | |
| 3910 p->start[DESIRED_DISP] = Qnil; | |
| 3911 p->start[CMOTION_DISP] = Qnil; | |
| 3912 p->pointm[CURRENT_DISP] = Qnil; | |
| 3913 p->pointm[DESIRED_DISP] = Qnil; | |
| 3914 p->pointm[CMOTION_DISP] = Qnil; | |
| 3915 p->sb_point = Qnil; | |
| 844 | 3916 p->saved_point_cache = make_saved_buffer_point_cache (); |
| 3917 p->saved_last_window_start_cache = make_saved_buffer_point_cache (); | |
| 428 | 3918 p->buffer = Qnil; |
| 3919 } | |
| 3920 | |
| 3921 DEFUN ("split-window", Fsplit_window, 0, 3, "", /* | |
| 3922 Split WINDOW, putting SIZE lines in the first of the pair. | |
| 444 | 3923 WINDOW defaults to the selected one and SIZE to half its size. |
| 707 | 3924 If optional third arg HORFLAG is non-nil, split side by side and put |
| 3925 SIZE columns in the first of the pair. The newly created window is | |
| 3926 returned. | |
| 428 | 3927 */ |
| 444 | 3928 (window, size, horflag)) |
| 428 | 3929 { |
| 3025 | 3930 Lisp_Object new_; |
| 428 | 3931 struct window *o, *p; |
| 3932 struct frame *f; | |
| 444 | 3933 int csize; |
| 428 | 3934 int psize; |
| 3935 | |
| 3936 if (NILP (window)) | |
| 3937 window = Fselected_window (Qnil); | |
| 3938 else | |
| 3939 CHECK_LIVE_WINDOW (window); | |
| 3940 | |
| 3941 o = XWINDOW (window); | |
| 3942 f = XFRAME (WINDOW_FRAME (o)); | |
| 3943 | |
| 444 | 3944 if (NILP (size)) |
| 428 | 3945 { |
| 3946 if (!NILP (horflag)) | |
| 3947 /* In the new scheme, we are symmetric with respect to separators | |
| 3948 so there is no need to do weird things here. */ | |
| 3949 { | |
| 956 | 3950 psize = (WINDOW_WIDTH (o) + window_divider_width (o)) >> 1; |
| 444 | 3951 csize = window_pixel_width_to_char_width (o, psize, 0); |
| 428 | 3952 } |
| 3953 else | |
| 3954 { | |
| 3955 psize = WINDOW_HEIGHT (o) >> 1; | |
| 444 | 3956 csize = window_pixel_height_to_char_height (o, psize, 1); |
| 428 | 3957 } |
| 3958 } | |
| 3959 else | |
| 3960 { | |
| 444 | 3961 CHECK_INT (size); |
| 3962 csize = XINT (size); | |
| 428 | 3963 if (!NILP (horflag)) |
| 444 | 3964 psize = window_char_width_to_pixel_width (o, csize, 0); |
| 428 | 3965 else |
| 444 | 3966 psize = window_char_height_to_pixel_height (o, csize, 1); |
| 428 | 3967 } |
| 3968 | |
| 3969 if (MINI_WINDOW_P (o)) | |
| 563 | 3970 invalid_operation ("Attempt to split minibuffer window", Qunbound); |
| 428 | 3971 else if (FRAME_NO_SPLIT_P (XFRAME (WINDOW_FRAME (o)))) |
| 563 | 3972 invalid_operation ("Attempt to split unsplittable frame", Qunbound); |
| 428 | 3973 |
| 3974 check_min_window_sizes (); | |
| 3975 | |
| 3976 if (NILP (horflag)) | |
| 3977 { | |
| 444 | 3978 if (csize < window_min_height) |
| 563 | 3979 signal_error (Qinvalid_operation, "Window height too small (after splitting)", make_int (csize)); |
| 444 | 3980 if (csize + window_min_height > window_char_height (o, 1)) |
| 563 | 3981 signal_error (Qinvalid_operation, "Window height too small (after splitting)", |
| 3982 make_int (window_char_height (o, 1) - csize)); | |
| 428 | 3983 if (NILP (o->parent) |
| 3984 || NILP (XWINDOW (o->parent)->vchild)) | |
| 3985 { | |
| 3986 make_dummy_parent (window); | |
| 448 | 3987 #if 0 |
| 3988 /* #### I can't understand why you have to reset face | |
| 3989 cachels here. This can cause crash so let's disable it | |
| 3990 and see the difference. See redisplay-tests.el --yh */ | |
| 428 | 3991 reset_face_cachels (XWINDOW (window)); |
| 448 | 3992 #endif |
| 3025 | 3993 new_ = o->parent; |
| 3994 XWINDOW (new_)->vchild = window; | |
| 428 | 3995 XFRAME (o->frame)->mirror_dirty = 1; |
| 3996 } | |
| 3997 } | |
| 3998 else | |
| 3999 { | |
| 444 | 4000 if (csize < window_min_width) |
| 563 | 4001 signal_error (Qinvalid_operation, "Window width too small (after splitting)", make_int (csize)); |
| 444 | 4002 if (csize + window_min_width > window_char_width (o, 0)) |
| 563 | 4003 signal_error (Qinvalid_operation, "Window width too small (after splitting)", |
| 4004 make_int (window_char_width (o, 0) - csize)); | |
| 428 | 4005 if (NILP (o->parent) |
| 4006 || NILP (XWINDOW (o->parent)->hchild)) | |
| 4007 { | |
| 4008 make_dummy_parent (window); | |
| 448 | 4009 #if 0 |
| 4010 /* #### See above. */ | |
| 428 | 4011 reset_face_cachels (XWINDOW (window)); |
| 448 | 4012 #endif |
| 3025 | 4013 new_ = o->parent; |
| 4014 XWINDOW (new_)->hchild = window; | |
| 428 | 4015 XFRAME (o->frame)->mirror_dirty = 1; |
| 4016 } | |
| 4017 } | |
| 4018 | |
| 4019 /* Now we know that window's parent is a vertical combination | |
| 4020 if we are dividing vertically, or a horizontal combination | |
| 4021 if we are making side-by-side windows */ | |
| 4022 | |
| 4023 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); | |
| 3025 | 4024 new_ = allocate_window (); |
| 4025 p = XWINDOW (new_); | |
| 428 | 4026 |
| 4027 p->frame = o->frame; | |
| 4028 p->next = o->next; | |
| 4029 if (!NILP (p->next)) | |
| 3025 | 4030 XWINDOW (p->next)->prev = new_; |
| 428 | 4031 p->prev = window; |
| 3025 | 4032 o->next = new_; |
| 428 | 4033 p->parent = o->parent; |
| 4034 p->buffer = Qt; | |
| 4035 | |
| 4036 reset_face_cachels (p); | |
| 4037 reset_glyph_cachels (p); | |
| 4038 | |
| 4039 | |
| 4040 /* Apportion the available frame space among the two new windows */ | |
| 4041 | |
| 4042 if (!NILP (horflag)) | |
| 4043 { | |
| 4044 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o); | |
| 4045 WINDOW_TOP (p) = WINDOW_TOP (o); | |
| 4046 WINDOW_WIDTH (p) = WINDOW_WIDTH (o) - psize; | |
| 4047 WINDOW_WIDTH (o) = psize; | |
| 4048 WINDOW_LEFT (p) = WINDOW_LEFT (o) + psize; | |
| 4049 } | |
| 4050 else | |
| 4051 { | |
| 4052 WINDOW_LEFT (p) = WINDOW_LEFT (o); | |
| 4053 WINDOW_WIDTH (p) = WINDOW_WIDTH (o); | |
| 4054 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o) - psize; | |
| 4055 WINDOW_HEIGHT (o) = psize; | |
| 4056 WINDOW_TOP (p) = WINDOW_TOP (o) + psize; | |
| 4057 } | |
| 4058 | |
| 4059 XFRAME (p->frame)->mirror_dirty = 1; | |
| 853 | 4060 |
| 3025 | 4061 note_object_created (new_); |
| 853 | 4062 |
| 428 | 4063 /* do this last (after the window is completely initialized and |
| 4064 the mirror-dirty flag is set) so that specifier recomputation | |
| 4065 caused as a result of this will work properly and not abort. */ | |
| 3025 | 4066 Fset_window_buffer (new_, o->buffer, Qt); |
| 4067 return new_; | |
| 428 | 4068 } |
| 4069 | |
| 4070 | |
| 4071 DEFUN ("enlarge-window", Fenlarge_window, 1, 3, "_p", /* | |
| 444 | 4072 Make the selected window COUNT lines taller. |
| 4073 From program, optional second arg HORIZONTALP non-nil means grow | |
| 4074 sideways COUNT columns, and optional third arg WINDOW specifies the | |
| 4075 window to change instead of the selected window. | |
| 428 | 4076 */ |
| 444 | 4077 (count, horizontalp, window)) |
| 4078 { | |
| 4079 CHECK_INT (count); | |
| 4080 change_window_height (window, XINT (count), horizontalp, /* inpixels */ 0); | |
| 428 | 4081 return Qnil; |
| 4082 } | |
| 4083 | |
| 4084 DEFUN ("enlarge-window-pixels", Fenlarge_window_pixels, 1, 3, "_p", /* | |
| 444 | 4085 Make the selected window COUNT pixels taller. |
| 4086 From program, optional second arg HORIZONTALP non-nil means grow | |
| 4087 sideways COUNT pixels, and optional third arg WINDOW specifies the | |
| 4088 window to change instead of the selected window. | |
| 428 | 4089 */ |
| 444 | 4090 (count, horizontalp, window)) |
| 4091 { | |
| 4092 CHECK_INT (count); | |
| 4093 change_window_height (window, XINT (count), horizontalp, /* inpixels */ 1); | |
| 428 | 4094 return Qnil; |
| 4095 } | |
| 4096 | |
| 4097 DEFUN ("shrink-window", Fshrink_window, 1, 3, "_p", /* | |
| 444 | 4098 Make the selected window COUNT lines shorter. |
| 4099 From program, optional second arg HORIZONTALP non-nil means shrink | |
| 4100 sideways COUNT columns, and optional third arg WINDOW specifies the | |
| 4101 window to change instead of the selected window. | |
| 428 | 4102 */ |
| 444 | 4103 (count, horizontalp, window)) |
| 4104 { | |
| 4105 CHECK_INT (count); | |
| 4106 change_window_height (window, -XINT (count), horizontalp, /* inpixels */ 0); | |
| 428 | 4107 return Qnil; |
| 4108 } | |
| 4109 | |
| 4110 DEFUN ("shrink-window-pixels", Fshrink_window_pixels, 1, 3, "_p", /* | |
| 444 | 4111 Make the selected window COUNT pixels smaller. |
| 4112 From program, optional second arg HORIZONTALP non-nil means shrink | |
| 4113 sideways COUNT pixels, and optional third arg WINDOW specifies the | |
| 4114 window to change instead of the selected window. | |
| 428 | 4115 */ |
| 444 | 4116 (count, horizontalp, window)) |
| 4117 { | |
| 4118 CHECK_INT (count); | |
| 4119 change_window_height (window, -XINT (count), horizontalp, /* inpixels */ 1); | |
| 428 | 4120 return Qnil; |
| 4121 } | |
| 4122 | |
| 4123 static int | |
| 4124 window_pixel_height_to_char_height (struct window *w, int pixel_height, | |
| 4125 int include_gutters_p) | |
| 4126 { | |
| 4127 int avail_height; | |
| 4128 int defheight, defwidth; | |
| 3687 | 4129 int char_height = 0; |
| 793 | 4130 Lisp_Object window = wrap_window (w); |
| 4131 | |
| 428 | 4132 |
| 4133 avail_height = (pixel_height - | |
| 4134 (include_gutters_p ? 0 : | |
| 442 | 4135 window_top_window_gutter_height (w) + |
| 4136 window_bottom_window_gutter_height (w))); | |
| 428 | 4137 |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
4138 default_face_width_and_height (window, &defwidth, &defheight); |
| 428 | 4139 |
| 3687 | 4140 if (defheight) |
| 4141 char_height = avail_height / defheight; | |
| 428 | 4142 |
| 4143 /* It's the calling function's responsibility to check these values | |
| 4144 and make sure they're not out of range. | |
| 4145 | |
| 4146 #### We need to go through the calling functions and actually | |
| 4147 do this. */ | |
| 4148 return max (0, char_height); | |
| 4149 } | |
| 4150 | |
| 4151 static int | |
| 4152 window_char_height_to_pixel_height (struct window *w, int char_height, | |
| 4153 int include_gutters_p) | |
| 4154 { | |
| 4155 int avail_height; | |
| 4156 int defheight, defwidth; | |
| 4157 int pixel_height; | |
| 4158 | |
| 793 | 4159 Lisp_Object window = wrap_window (w); |
| 4160 | |
| 428 | 4161 |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
4162 default_face_width_and_height (window, &defwidth, &defheight); |
| 428 | 4163 |
| 4164 avail_height = char_height * defheight; | |
| 4165 pixel_height = (avail_height + | |
| 4166 (include_gutters_p ? 0 : | |
| 442 | 4167 window_top_window_gutter_height (w) + |
| 4168 window_bottom_window_gutter_height (w))); | |
| 428 | 4169 |
| 4170 /* It's the calling function's responsibility to check these values | |
| 4171 and make sure they're not out of range. | |
| 4172 | |
| 4173 #### We need to go through the calling functions and actually | |
| 4174 do this. */ | |
| 4175 return max (0, pixel_height); | |
| 4176 } | |
| 4177 | |
| 4178 /* Return number of default lines of text can fit in the window W. | |
| 4179 If INCLUDE_GUTTERS_P is 1, include "gutter" space (modeline plus | |
| 4180 horizontal scrollbar) in the space that is used for the calculation. | |
| 442 | 4181 This doesn't include space used by the frame gutters. |
| 428 | 4182 */ |
| 4183 int | |
| 4184 window_char_height (struct window *w, int include_gutters_p) | |
| 4185 { | |
| 442 | 4186 return window_pixel_height_to_char_height (w, window_pixel_height (w), |
| 428 | 4187 include_gutters_p); |
| 4188 } | |
| 4189 | |
| 4190 /* | |
| 4191 * Return number of lines currently displayed in window w. If | |
| 4192 * end-of-buffer is displayed then the area below end-of-buffer is assume | |
| 4193 * to be blank lines of default height. | |
| 4194 * Does not include the modeline. | |
| 4195 */ | |
| 4196 int | |
| 4197 window_displayed_height (struct window *w) | |
| 4198 { | |
| 4199 struct buffer *b = XBUFFER (w->buffer); | |
| 4200 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP); | |
| 4201 int num_lines; | |
| 4202 Charcount end_pos = (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b) | |
| 4203 ? -1 | |
| 4204 : w->window_end_pos[CURRENT_DISP]); | |
| 4205 | |
| 4206 if (!Dynarr_length (dla)) | |
| 4207 return window_char_height (w, 0); | |
| 4208 | |
| 4209 num_lines = Dynarr_length (dla); | |
| 4210 | |
| 4211 /* #### Document and assert somewhere that w->window_end_pos == -1 | |
| 4212 indicates that end-of-buffer is being displayed. */ | |
| 4213 if (end_pos == -1) | |
| 4214 { | |
| 4967 | 4215 struct display_line *dl = Dynarr_begin (dla); |
| 428 | 4216 int ypos1 = dl->ypos + dl->descent; |
| 4217 int ypos2 = WINDOW_TEXT_BOTTOM (w); | |
| 4218 Lisp_Object window; | |
| 4219 int defheight, defwidth; | |
| 4220 | |
| 793 | 4221 window = wrap_window (w); |
| 428 | 4222 |
| 4223 if (dl->modeline) | |
| 4224 { | |
| 4225 num_lines--; | |
| 4226 | |
| 4227 if (Dynarr_length (dla) == 1) | |
| 4228 ypos1 = WINDOW_TEXT_TOP (w); | |
| 4229 else | |
| 4230 { | |
| 4231 dl = Dynarr_atp (dla, Dynarr_length (dla) - 1); | |
| 4232 /* If this line is clipped then we know that there is no | |
| 4233 blank room between eob and the modeline. If we are | |
| 4234 scrolling on clipped lines just know off the clipped | |
| 4235 line and return .*/ | |
| 4236 if (scroll_on_clipped_lines && dl->clip) | |
| 4237 return num_lines - 1; | |
| 4238 ypos1 = dl->ypos + dl->descent - dl->clip; | |
| 4239 } | |
| 4240 } | |
| 4241 | |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
4242 default_face_width_and_height (window, &defwidth, &defheight); |
| 428 | 4243 /* #### This probably needs to know about the clipping area once a |
| 4244 final definition is decided on. */ | |
| 3707 | 4245 if (defheight) |
| 4246 num_lines += ((ypos2 - ypos1) / defheight); | |
| 428 | 4247 } |
| 4248 else | |
| 4249 { | |
| 4967 | 4250 if (num_lines > 1 && Dynarr_begin (dla)->modeline) |
| 428 | 4251 num_lines--; |
| 4252 | |
| 4253 if (scroll_on_clipped_lines | |
| 4254 && Dynarr_atp (dla, Dynarr_length (dla) - 1)->clip) | |
| 4255 num_lines--; | |
| 4256 } | |
| 4257 | |
| 4258 return num_lines; | |
| 4259 } | |
| 4260 | |
| 4261 static int | |
| 4262 window_pixel_width (Lisp_Object window) | |
| 4263 { | |
| 4264 return WINDOW_WIDTH (XWINDOW (window)); | |
| 4265 } | |
| 4266 | |
| 442 | 4267 /* Calculate the pixel of a window, optionally including margin space |
| 4268 but no vertical gutters. */ | |
| 428 | 4269 static int |
| 4270 window_pixel_width_to_char_width (struct window *w, int pixel_width, | |
| 4271 int include_margins_p) | |
| 4272 { | |
| 4273 int avail_width; | |
| 3676 | 4274 int char_width = 0; |
| 428 | 4275 int defheight, defwidth; |
| 793 | 4276 Lisp_Object window = wrap_window (w); |
| 4277 | |
| 428 | 4278 |
| 4279 avail_width = (pixel_width - | |
| 4280 window_left_gutter_width (w, 0) - | |
| 4281 window_right_gutter_width (w, 0) - | |
| 4282 (include_margins_p ? 0 : window_left_margin_width (w)) - | |
| 4283 (include_margins_p ? 0 : window_right_margin_width (w))); | |
| 4284 | |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
4285 default_face_width_and_height (window, &defwidth, &defheight); |
| 428 | 4286 |
| 3676 | 4287 if (defwidth) |
| 4288 char_width = (avail_width / defwidth); | |
| 428 | 4289 |
| 4290 /* It's the calling function's responsibility to check these values | |
| 4291 and make sure they're not out of range. | |
| 4292 | |
| 4293 #### We need to go through the calling functions and actually | |
| 4294 do this. */ | |
| 4295 return max (0, char_width); | |
| 4296 } | |
| 4297 | |
| 4298 static int | |
| 4299 window_char_width_to_pixel_width (struct window *w, int char_width, | |
| 4300 int include_margins_p) | |
| 4301 { | |
| 4302 int avail_width; | |
| 4303 int pixel_width; | |
| 4304 int defheight, defwidth; | |
| 793 | 4305 Lisp_Object window = wrap_window (w); |
| 4306 | |
| 428 | 4307 |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
4308 default_face_width_and_height (window, &defwidth, &defheight); |
| 428 | 4309 |
| 4310 avail_width = char_width * defwidth; | |
| 4311 pixel_width = (avail_width + | |
| 442 | 4312 window_left_window_gutter_width (w, 0) + |
| 4313 window_right_window_gutter_width (w, 0) + | |
| 428 | 4314 (include_margins_p ? 0 : window_left_margin_width (w)) + |
| 4315 (include_margins_p ? 0 : window_right_margin_width (w))); | |
| 4316 | |
| 4317 /* It's the calling function's responsibility to check these values | |
| 4318 and make sure they're not out of range. | |
| 4319 | |
| 4320 #### We need to go through the calling functions and actually | |
| 4321 do this. */ | |
| 4322 return max (0, pixel_width); | |
| 4323 } | |
| 4324 | |
| 4325 /* This returns the usable space which doesn't include space needed by | |
| 4326 scrollbars or divider lines. */ | |
| 4327 int | |
| 4328 window_char_width (struct window *w, int include_margins_p) | |
| 4329 { | |
| 4330 return window_pixel_width_to_char_width (w, WINDOW_WIDTH (w), | |
| 4331 include_margins_p); | |
| 4332 } | |
| 4333 | |
| 4334 #define MINSIZE(w) \ | |
| 4335 (widthflag \ | |
| 4336 ? window_min_width * defwidth \ | |
| 4337 : (defheight * (MINI_WINDOW_P (XWINDOW (w)) ? 1 : window_min_height))) | |
| 4338 | |
| 4339 #define CURBEG(w) \ | |
| 4340 *(widthflag ? (int *) &WINDOW_LEFT (w) : (int *) &WINDOW_TOP (w)) | |
| 4341 | |
| 4342 #define CURSIZE(w) \ | |
| 4343 *(widthflag ? (int *) &WINDOW_WIDTH (w) : (int *) &WINDOW_HEIGHT (w)) | |
| 4344 | |
| 4345 #define CURCHARSIZE(w) \ | |
| 4346 (widthflag ? window_char_width (w, 0) : window_char_height (w, 1)) | |
| 4347 | |
| 4348 #define MINCHARSIZE(window) \ | |
| 4349 (widthflag ? window_min_width : MINI_WINDOW_P (XWINDOW (window)) \ | |
| 4350 ? 1 : window_min_height) | |
| 4351 | |
| 442 | 4352 static int |
| 4353 window_pixheight (Lisp_Object w) | |
| 4354 { | |
| 4355 return window_pixel_height (XWINDOW (w)); | |
| 4356 } | |
| 4357 | |
| 428 | 4358 /* Unlike set_window_pixheight, this function |
| 4359 also changes the heights of the siblings so as to | |
| 4360 keep everything consistent. */ | |
| 4361 | |
| 4362 static void | |
| 444 | 4363 change_window_height (Lisp_Object window, int delta, Lisp_Object horizontalp, |
| 428 | 4364 int inpixels) |
| 4365 { | |
| 444 | 4366 struct window *win = decode_window (window); |
| 4367 int widthflag = !NILP (horizontalp); | |
| 428 | 4368 Lisp_Object parent; |
| 4369 struct window *w; | |
| 4370 struct frame *f; | |
| 4371 int *sizep; | |
| 4372 int (*sizefun) (Lisp_Object) = (widthflag | |
| 4373 ? window_pixel_width | |
| 442 | 4374 : window_pixheight); |
| 428 | 4375 void (*setsizefun) (Lisp_Object, int, int) = (widthflag |
| 4376 ? set_window_pixwidth | |
| 4377 : set_window_pixheight); | |
| 4378 int dim; | |
| 4379 int defheight, defwidth; | |
| 4380 | |
| 4381 if (delta == 0) | |
| 4382 return; | |
| 4383 | |
| 4384 check_min_window_sizes (); | |
| 4385 | |
| 793 | 4386 window = wrap_window (win); |
| 428 | 4387 f = XFRAME (win->frame); |
| 4388 if (EQ (window, FRAME_ROOT_WINDOW (f))) | |
| 563 | 4389 invalid_operation ("Won't change only window", Qunbound); |
| 428 | 4390 |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
4391 default_face_width_and_height (window, &defwidth, &defheight); |
| 428 | 4392 |
| 4393 while (1) | |
| 4394 { | |
| 4395 w = XWINDOW (window); | |
| 4396 parent = w->parent; | |
| 4397 if (NILP (parent)) | |
| 4398 { | |
| 4399 if (widthflag) | |
| 3078 | 4400 { |
| 4401 int new_pixsize; | |
| 4402 sizep = &CURSIZE (w); | |
| 3466 | 4403 dim = CURCHARSIZE (w); |
| 3078 | 4404 new_pixsize = inpixels?(*sizep + delta):(dim+delta); |
| 4405 set_window_pixsize (window, new_pixsize, 0, 0); | |
| 4406 return; | |
| 4407 } | |
| 428 | 4408 break; |
| 4409 } | |
| 4410 if (widthflag | |
| 4411 ? !NILP (XWINDOW (parent)->hchild) | |
| 4412 : !NILP (XWINDOW (parent)->vchild)) | |
| 4413 break; | |
| 4414 window = parent; | |
| 4415 } | |
| 4416 | |
| 4417 sizep = &CURSIZE (w); | |
| 4418 dim = CURCHARSIZE (w); | |
| 4419 | |
| 4420 if ((inpixels && (*sizep + delta) < MINSIZE (window)) || | |
| 4421 (!inpixels && (dim + delta) < MINCHARSIZE (window))) | |
| 4422 { | |
| 4423 if (MINI_WINDOW_P (XWINDOW (window))) | |
| 4424 return; | |
| 4425 else if (!NILP (parent)) | |
| 4426 { | |
| 4427 Fdelete_window (window, Qnil); | |
| 4428 return; | |
| 4429 } | |
| 4430 } | |
| 4431 | |
| 4432 if (!inpixels) | |
| 4433 delta *= (widthflag ? defwidth : defheight); | |
| 4434 | |
| 4435 { | |
| 4436 int maxdelta; | |
| 4437 | |
| 4438 maxdelta = ((!NILP (parent)) | |
| 4439 ? (*sizefun) (parent) - *sizep | |
| 4440 : ((!NILP (w->next)) | |
| 4441 ? (*sizefun) (w->next) - MINSIZE (w->next) | |
| 4442 : ((!NILP (w->prev)) | |
| 4443 ? (*sizefun) (w->prev) - MINSIZE (w->prev) | |
| 4444 /* This is a frame with only one window, | |
| 4445 a minibuffer-only or a minibufferless frame. */ | |
| 4446 : (delta = 0)))); | |
| 4447 | |
| 4448 if (delta > maxdelta) | |
| 4449 /* This case traps trying to make the minibuffer | |
| 4450 the full frame, or make the only window aside from the | |
| 4451 minibuffer the full frame. */ | |
| 4452 delta = maxdelta; | |
| 4453 | |
| 4454 if (delta == 0) | |
| 4455 return; | |
| 4456 | |
| 4457 #if 0 /* FSFmacs */ | |
| 4458 /* #### Chuck: is this correct? */ | |
| 4459 if (*sizep + delta < MINSIZE (window)) | |
| 4460 { | |
| 4461 Fdelete_window (window); | |
| 4462 return; | |
| 4463 } | |
| 4464 #endif | |
| 4465 } | |
| 4466 | |
| 4467 if (!NILP (w->next) && | |
| 4468 (*sizefun) (w->next) - delta >= (int) MINSIZE (w->next)) | |
| 4469 { | |
| 4470 CURBEG (XWINDOW (w->next)) += delta; | |
| 4471 (*setsizefun) (w->next, (*sizefun) (w->next) - delta, 0); | |
| 4472 (*setsizefun) (window, *sizep + delta, 0); | |
| 4473 } | |
| 4474 else if (!NILP (w->prev) && | |
| 4475 (*sizefun) (w->prev) - delta >= (int) MINSIZE (w->prev)) | |
| 4476 { | |
| 4477 (*setsizefun) (w->prev, (*sizefun) (w->prev) - delta, 0); | |
| 4478 CURBEG (w) -= delta; | |
| 4479 (*setsizefun) (window, *sizep + delta, 0); | |
| 4480 } | |
| 4481 else | |
| 4482 { | |
| 4483 int delta1; | |
| 4484 int opht = (*sizefun) (parent); | |
| 4485 | |
| 4486 /* If trying to grow this window to or beyond size of the parent, | |
| 4487 make delta1 so big that, on shrinking back down, | |
| 4488 all the siblings end up with less than one line and are deleted. */ | |
| 4489 if (opht <= *sizep + delta) | |
| 4490 delta1 = opht * opht * 2; | |
| 4491 /* Otherwise, make delta1 just right so that if we add delta1 | |
| 4492 lines to this window and to the parent, and then shrink | |
| 4493 the parent back to its original size, the new proportional | |
| 4494 size of this window will increase by delta. */ | |
| 4495 else | |
| 4496 delta1 = (delta * opht * 100) / ((opht - *sizep - delta) * 100); | |
| 4497 | |
| 4498 /* Add delta1 lines or columns to this window, and to the parent, | |
| 4499 keeping things consistent while not affecting siblings. */ | |
| 4500 CURSIZE (XWINDOW (parent)) = opht + delta1; | |
| 4501 (*setsizefun) (window, *sizep + delta1, 0); | |
| 4502 | |
| 4503 /* Squeeze out delta1 lines or columns from our parent, | |
| 4504 shrinking this window and siblings proportionately. | |
| 4505 This brings parent back to correct size. | |
| 4506 Delta1 was calculated so this makes this window the desired size, | |
| 4507 taking it all out of the siblings. */ | |
| 4508 (*setsizefun) (parent, opht, 0); | |
| 4509 } | |
| 4510 | |
| 4511 SET_LAST_MODIFIED (w, 0); | |
| 4512 SET_LAST_FACECHANGE (w); | |
| 4513 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); | |
| 4514 /* overkill maybe, but better to be correct */ | |
| 4515 MARK_FRAME_GUTTERS_CHANGED (f); | |
| 4516 } | |
| 4517 #undef MINSIZE | |
| 4518 #undef CURBEG | |
| 4519 #undef CURSIZE | |
| 4520 #undef CURCHARSIZE | |
| 4521 #undef MINCHARSIZE | |
| 4522 | |
| 4523 | |
| 4524 | |
| 444 | 4525 /* Scroll contents of window WINDOW up COUNT lines. |
| 4526 If COUNT < (top line height / average line height) then we just adjust | |
| 4527 the top clip. */ | |
| 428 | 4528 void |
| 444 | 4529 window_scroll (Lisp_Object window, Lisp_Object count, int direction, |
| 578 | 4530 Error_Behavior errb) |
| 428 | 4531 { |
| 4532 struct window *w = XWINDOW (window); | |
| 4533 struct buffer *b = XBUFFER (w->buffer); | |
| 4534 int selected = EQ (window, Fselected_window (Qnil)); | |
| 4535 int value = 0; | |
| 4536 Lisp_Object point, tem; | |
| 4537 display_line_dynarr *dla; | |
| 4538 int fheight, fwidth, modeline = 0; | |
| 4539 struct display_line* dl; | |
| 4540 | |
| 4541 if (selected) | |
| 4542 point = make_int (BUF_PT (b)); | |
| 4543 else | |
| 4544 { | |
| 665 | 4545 Charbpos pos = marker_position (w->pointm[CURRENT_DISP]); |
| 428 | 4546 |
| 4547 if (pos < BUF_BEGV (b)) | |
| 4548 pos = BUF_BEGV (b); | |
| 4549 else if (pos > BUF_ZV (b)) | |
| 4550 pos = BUF_ZV (b); | |
| 4551 | |
| 4552 point = make_int (pos); | |
| 4553 } | |
| 4554 | |
| 4555 /* Always set force_start so that redisplay_window will run | |
| 4556 the window-scroll-functions. */ | |
| 4557 w->force_start = 1; | |
| 4558 | |
| 4559 /* #### When the fuck does this happen? I'm so glad that history has | |
| 4560 completely documented the behavior of the scrolling functions under | |
| 4561 all circumstances. */ | |
| 1708 | 4562 tem = Fpos_visible_in_window_p (point, window, Qnil); |
| 428 | 4563 if (NILP (tem)) |
| 4564 { | |
| 4565 Fvertical_motion (make_int (-window_char_height (w, 0) / 2), | |
| 4566 window, Qnil); | |
| 4567 Fset_marker (w->start[CURRENT_DISP], point, w->buffer); | |
| 4568 w->start_at_line_beg = beginning_of_line_p (b, XINT (point)); | |
| 4569 WINDOW_TEXT_TOP_CLIP (w) = 0; | |
| 4570 MARK_WINDOWS_CHANGED (w); | |
| 4571 } | |
| 4572 | |
| 444 | 4573 if (!NILP (count)) |
| 428 | 4574 { |
| 444 | 4575 if (EQ (count, Qminus)) |
| 428 | 4576 direction *= -1; |
| 4577 else | |
| 4578 { | |
| 444 | 4579 count = Fprefix_numeric_value (count); |
| 4580 value = XINT (count) * direction; | |
| 428 | 4581 |
| 4582 if (!value) | |
| 4583 return; /* someone just made a pointless call */ | |
| 4584 } | |
| 4585 } | |
| 4586 | |
| 4587 /* If the user didn't specify how far to scroll then we have to figure it | |
| 4588 out by ourselves. */ | |
| 444 | 4589 if (NILP (count) || EQ (count, Qminus)) |
| 428 | 4590 { |
| 4591 /* Going forwards is easy. If that is what we are doing then just | |
| 4592 set value and the section which handles the user specifying a | |
| 4593 positive value will work. */ | |
| 4594 if (direction == 1) | |
| 4595 { | |
| 4596 value = window_displayed_height (w) - next_screen_context_lines; | |
| 4597 value = (value < 1 ? 1 : value); | |
| 4598 } | |
| 4599 | |
| 4600 /* Going backwards is hard. We can't use the same loop used if the | |
| 4601 user specified a negative value because we care about | |
| 4602 next_screen_context_lines. In a variable height world you don't | |
| 4603 know how many lines above you can actually be displayed and still | |
| 4604 have the context lines appear. So we leave value set to 0 and add | |
| 4605 a separate section to deal with this. */ | |
| 4606 | |
| 4607 } | |
| 4608 | |
| 4609 if (direction == 1 && !value) | |
| 4610 { | |
| 4611 return; | |
| 4612 } | |
| 4613 | |
| 4614 /* Determine parameters to test for partial line scrolling with. */ | |
| 4615 dla = window_display_lines (w, CURRENT_DISP); | |
| 4616 | |
| 4617 if (INTP (Vwindow_pixel_scroll_increment)) | |
| 4618 fheight = XINT (Vwindow_pixel_scroll_increment); | |
| 440 | 4619 else if (!NILP (Vwindow_pixel_scroll_increment)) |
|
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
4620 default_face_width_and_height (window, &fwidth, &fheight); |
| 438 | 4621 |
| 428 | 4622 if (Dynarr_length (dla) >= 1) |
| 4967 | 4623 modeline = Dynarr_begin (dla)->modeline; |
| 428 | 4624 |
| 4625 dl = Dynarr_atp (dla, modeline); | |
| 438 | 4626 |
| 428 | 4627 if (value > 0) |
| 4628 { | |
| 4629 /* Go for partial display line scrolling. This just means bumping | |
| 4630 the clip by a reasonable amount and redisplaying, everything else | |
| 4631 remains unchanged. */ | |
| 4632 if (!NILP (Vwindow_pixel_scroll_increment) | |
| 4633 && | |
| 4634 Dynarr_length (dla) >= (1 + modeline) | |
| 4635 && | |
| 458 | 4636 (dl->ascent - dl->top_clip) > fheight * value) |
| 428 | 4637 { |
| 4638 WINDOW_TEXT_TOP_CLIP (w) += value * fheight; | |
| 4639 MARK_WINDOWS_CHANGED (w); | |
| 4640 } | |
| 4641 else | |
| 4642 { | |
| 4643 int vtarget; | |
| 665 | 4644 Charbpos startp, old_start; |
| 438 | 4645 |
| 428 | 4646 if (WINDOW_TEXT_TOP_CLIP (w)) |
| 4647 { | |
| 4648 WINDOW_TEXT_TOP_CLIP (w) = 0; | |
| 4649 MARK_WINDOWS_CHANGED (w); | |
| 4650 } | |
| 4651 | |
| 4652 old_start = marker_position (w->start[CURRENT_DISP]); | |
| 4653 startp = vmotion (w, old_start, value, &vtarget); | |
| 438 | 4654 |
| 428 | 4655 if (vtarget < value && |
| 4656 (w->window_end_pos[CURRENT_DISP] == -1 | |
| 4657 || (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b)))) | |
| 4658 { | |
| 563 | 4659 maybe_signal_error_1 (Qend_of_buffer, Qnil, Qwindow, errb); |
| 428 | 4660 return; |
| 4661 } | |
| 4662 else | |
| 4663 { | |
| 4664 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp), | |
| 4665 w->buffer); | |
| 4666 w->force_start = 1; | |
| 4667 w->start_at_line_beg = beginning_of_line_p (b, startp); | |
| 4668 MARK_WINDOWS_CHANGED (w); | |
| 438 | 4669 |
| 1708 | 4670 if (!point_would_be_visible (w, startp, XINT (point), 0)) |
| 844 | 4671 Fset_window_point (wrap_window (w), make_int (startp)); |
| 428 | 4672 } |
| 4673 } | |
| 4674 } | |
| 4675 else if (value < 0) | |
| 4676 { | |
| 4677 /* Go for partial display line scrolling. This just means bumping | |
| 4678 the clip by a reasonable amount and redisplaying, everything else | |
| 4679 remains unchanged. */ | |
| 4680 if (!NILP (Vwindow_pixel_scroll_increment) | |
| 4681 && | |
| 4682 Dynarr_length (dla) >= (1 + modeline) | |
| 4683 && | |
| 4684 (dl->ascent - dl->top_clip) - fheight * value < | |
| 4685 (dl->ascent + dl->descent - dl->clip) | |
| 4686 && | |
| 4687 WINDOW_TEXT_TOP_CLIP (w) + value * fheight > 0) | |
| 4688 { | |
| 4689 WINDOW_TEXT_TOP_CLIP (w) += value * fheight; | |
| 4690 MARK_WINDOWS_CHANGED (w); | |
| 4691 } | |
| 4692 else | |
| 4693 { | |
| 4694 int vtarget; | |
| 665 | 4695 Charbpos startp, old_start; |
| 438 | 4696 |
| 428 | 4697 if (WINDOW_TEXT_TOP_CLIP (w)) |
| 4698 { | |
| 4699 WINDOW_TEXT_TOP_CLIP (w) = 0; | |
| 4700 MARK_WINDOWS_CHANGED (w); | |
| 4701 } | |
| 438 | 4702 |
| 428 | 4703 old_start = marker_position (w->start[CURRENT_DISP]); |
| 4704 startp = vmotion (w, old_start, value, &vtarget); | |
| 438 | 4705 |
| 428 | 4706 if (vtarget > value |
| 4707 && marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b)) | |
| 4708 { | |
| 563 | 4709 maybe_signal_error_1 (Qbeginning_of_buffer, Qnil, Qwindow, errb); |
| 428 | 4710 return; |
| 4711 } | |
| 4712 else | |
| 4713 { | |
| 4714 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp), | |
| 4715 w->buffer); | |
| 4716 w->force_start = 1; | |
| 4717 w->start_at_line_beg = beginning_of_line_p (b, startp); | |
| 4718 MARK_WINDOWS_CHANGED (w); | |
| 438 | 4719 |
| 440 | 4720 /* #### Scroll back by less than a line. This code was |
| 4721 originally for scrolling over large pixmaps and it | |
| 4722 loses when a line being *exposed* at the top of the | |
| 4723 window is bigger than the current one. However, for | |
| 4724 pixel based scrolling in general we can guess that | |
| 4725 the line we are going to display is probably the same | |
| 4726 size as the one we are on. In that instance we can | |
| 4727 have a reasonable stab at a suitable top clip. Fixing | |
| 4728 this properly is hard (and probably slow) as we would | |
| 4729 have to call redisplay to figure out the exposed line | |
| 4730 size. */ | |
| 4731 if (!NILP (Vwindow_pixel_scroll_increment) | |
| 4732 && Dynarr_length (dla) >= (1 + modeline) | |
| 4733 && dl->ascent + fheight * value > 0) | |
| 4734 { | |
| 4735 WINDOW_TEXT_TOP_CLIP (w) = (dl->ascent + fheight * value); | |
| 4736 } | |
| 4737 | |
| 1708 | 4738 if (!point_would_be_visible (w, startp, XINT (point), 0)) |
| 428 | 4739 { |
| 665 | 4740 Charbpos new_point; |
| 438 | 4741 |
| 428 | 4742 if (MINI_WINDOW_P (w)) |
| 4743 new_point = startp; | |
| 4744 else | |
| 4745 new_point = start_of_last_line (w, startp); | |
| 438 | 4746 |
| 844 | 4747 Fset_window_point (wrap_window (w), make_int (new_point)); |
| 428 | 4748 } |
| 4749 } | |
| 4750 } | |
| 4751 } | |
| 4752 else /* value == 0 && direction == -1 */ | |
| 4753 { | |
| 4754 if (WINDOW_TEXT_TOP_CLIP (w)) | |
| 4755 { | |
| 4756 WINDOW_TEXT_TOP_CLIP (w) = 0; | |
| 4757 MARK_WINDOWS_CHANGED (w); | |
| 4758 } | |
| 4759 if (marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b)) | |
| 4760 { | |
| 563 | 4761 maybe_signal_error_1 (Qbeginning_of_buffer, Qnil, Qwindow, errb); |
| 428 | 4762 return; |
| 4763 } | |
| 4764 else | |
| 4765 { | |
| 4766 int vtarget; | |
| 4767 int movement = next_screen_context_lines - 1; | |
| 665 | 4768 Charbpos old_startp = marker_position (w->start[CURRENT_DISP]); |
| 4769 Charbpos bottom = vmotion (w, old_startp, movement, &vtarget); | |
| 4770 Charbpos startp = | |
| 428 | 4771 start_with_point_on_display_line (w, bottom, |
| 4772 -1 - (movement - vtarget)); | |
| 4773 | |
| 4774 if (startp >= old_startp) | |
| 4775 startp = vmotion (w, old_startp, -1, NULL); | |
| 4776 | |
| 4777 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp), | |
| 4778 w->buffer); | |
| 4779 w->force_start = 1; | |
| 4780 w->start_at_line_beg = beginning_of_line_p (b, startp); | |
| 4781 MARK_WINDOWS_CHANGED (w); | |
| 4782 | |
| 1708 | 4783 if (!point_would_be_visible (w, startp, XINT (point), 0)) |
| 428 | 4784 { |
| 665 | 4785 Charbpos new_point = start_of_last_line (w, startp); |
| 428 | 4786 |
| 844 | 4787 Fset_window_point (wrap_window (w), make_int (new_point)); |
| 428 | 4788 } |
| 4789 } | |
| 4790 } | |
| 4791 } | |
| 4792 | |
| 4793 DEFUN ("scroll-up", Fscroll_up, 0, 1, "_P", /* | |
| 444 | 4794 Scroll text of current window up COUNT lines; or near full screen if no arg. |
| 428 | 4795 A near full screen is `next-screen-context-lines' less than a full screen. |
| 444 | 4796 Negative COUNT means scroll downward. |
| 428 | 4797 When calling from a program, supply an integer as argument or nil. |
| 4798 On attempt to scroll past end of buffer, `end-of-buffer' is signaled. | |
| 4799 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is | |
| 4800 signaled. | |
| 462 | 4801 |
| 4802 The characters that are moved over may be added to the current selection | |
| 4803 \(i.e. active region) if the Shift key is held down, a motion key is used | |
| 4804 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
| 4805 the documentation for this variable for more details. | |
| 428 | 4806 */ |
| 444 | 4807 (count)) |
| 4808 { | |
| 4809 window_scroll (Fselected_window (Qnil), count, 1, ERROR_ME); | |
| 428 | 4810 return Qnil; |
| 4811 } | |
| 4812 | |
| 4813 DEFUN ("scroll-down", Fscroll_down, 0, 1, "_P", /* | |
| 444 | 4814 Scroll text of current window down COUNT lines; or near full screen if no arg. |
| 428 | 4815 A near full screen is `next-screen-context-lines' less than a full screen. |
| 444 | 4816 Negative COUNT means scroll upward. |
| 428 | 4817 When calling from a program, supply a number as argument or nil. |
| 4818 On attempt to scroll past end of buffer, `end-of-buffer' is signaled. | |
| 4819 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is | |
| 4820 signaled. | |
| 462 | 4821 |
| 4822 The characters that are moved over may be added to the current selection | |
| 4823 \(i.e. active region) if the Shift key is held down, a motion key is used | |
| 4824 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
| 4825 the documentation for this variable for more details. | |
| 428 | 4826 */ |
| 444 | 4827 (count)) |
| 4828 { | |
| 4829 window_scroll (Fselected_window (Qnil), count, -1, ERROR_ME); | |
| 428 | 4830 return Qnil; |
| 4831 } | |
| 4832 | |
| 4833 DEFUN ("other-window-for-scrolling", Fother_window_for_scrolling, 0, 0, 0, /* | |
| 4834 Return the other window for "other window scroll" commands. | |
| 4835 If in the minibuffer, `minibuffer-scroll-window' if non-nil | |
| 4836 specifies the window. | |
| 4837 If `other-window-scroll-buffer' is non-nil, a window | |
| 4838 showing that buffer is used. | |
| 4839 */ | |
| 4840 ()) | |
| 4841 { | |
| 4842 Lisp_Object window; | |
| 4843 Lisp_Object selected_window = Fselected_window (Qnil); | |
| 4844 | |
| 4845 if (MINI_WINDOW_P (XWINDOW (selected_window)) | |
| 4846 && !NILP (Vminibuffer_scroll_window)) | |
| 4847 window = Vminibuffer_scroll_window; | |
| 4848 /* If buffer is specified, scroll that buffer. */ | |
| 4849 else if (!NILP (Vother_window_scroll_buffer)) | |
| 4850 { | |
| 4851 window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil, Qnil); | |
| 4852 if (NILP (window)) | |
| 4853 window = display_buffer (Vother_window_scroll_buffer, Qt, Qnil); | |
| 4854 } | |
| 4855 else | |
| 4856 { | |
| 4857 /* Nothing specified; look for a neighboring window on the same | |
| 4858 frame. */ | |
| 4859 window = Fnext_window (selected_window, Qnil, Qnil, Qnil); | |
| 4860 | |
| 4861 if (EQ (window, selected_window)) | |
| 4862 /* That didn't get us anywhere; look for a window on another | |
| 4863 visible frame. */ | |
| 4864 do | |
| 4865 window = Fnext_window (window, Qnil, Qt, Qnil); | |
| 4866 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window)))) | |
| 4867 && ! EQ (window, selected_window)); | |
| 4868 } | |
| 4869 | |
| 4870 CHECK_LIVE_WINDOW (window); | |
| 4871 | |
| 4872 if (EQ (window, selected_window)) | |
| 563 | 4873 invalid_operation ("There is no other window", Qunbound); |
| 428 | 4874 |
| 4875 return window; | |
| 4876 } | |
| 4877 | |
| 4878 DEFUN ("scroll-other-window", Fscroll_other_window, 0, 1, "_P", /* | |
| 444 | 4879 Scroll next window upward COUNT lines; or near full frame if no arg. |
| 428 | 4880 The next window is the one below the current one; or the one at the top |
| 444 | 4881 if the current one is at the bottom. Negative COUNT means scroll downward. |
| 428 | 4882 When calling from a program, supply a number as argument or nil. |
| 4883 | |
| 4884 If in the minibuffer, `minibuffer-scroll-window' if non-nil | |
| 4885 specifies the window to scroll. | |
| 4886 If `other-window-scroll-buffer' is non-nil, scroll the window | |
| 4887 showing that buffer, popping the buffer up if necessary. | |
| 4888 */ | |
| 444 | 4889 (count)) |
| 4890 { | |
| 4891 window_scroll (Fother_window_for_scrolling (), count, 1, ERROR_ME); | |
| 428 | 4892 return Qnil; |
| 4893 } | |
| 4894 | |
| 4895 DEFUN ("scroll-left", Fscroll_left, 0, 1, "_P", /* | |
| 444 | 4896 Scroll selected window display COUNT columns left. |
| 4897 Default for COUNT is window width minus 2. | |
| 462 | 4898 |
| 4899 The characters that are moved over may be added to the current selection | |
| 4900 \(i.e. active region) if the Shift key is held down, a motion key is used | |
| 4901 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
| 4902 the documentation for this variable for more details. | |
| 428 | 4903 */ |
| 444 | 4904 (count)) |
| 428 | 4905 { |
| 4906 Lisp_Object window = Fselected_window (Qnil); | |
| 4907 struct window *w = XWINDOW (window); | |
| 444 | 4908 int n = (NILP (count) ? |
| 4909 window_char_width (w, 0) - 2 : | |
| 4910 XINT (Fprefix_numeric_value (count))); | |
| 4911 | |
| 4912 return Fset_window_hscroll (window, make_int (w->hscroll + n)); | |
| 428 | 4913 } |
| 4914 | |
| 4915 DEFUN ("scroll-right", Fscroll_right, 0, 1, "_P", /* | |
| 444 | 4916 Scroll selected window display COUNT columns right. |
| 4917 Default for COUNT is window width minus 2. | |
| 462 | 4918 |
| 4919 The characters that are moved over may be added to the current selection | |
| 4920 \(i.e. active region) if the Shift key is held down, a motion key is used | |
| 4921 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
| 4922 the documentation for this variable for more details. | |
| 428 | 4923 */ |
| 444 | 4924 (count)) |
| 428 | 4925 { |
| 4926 Lisp_Object window = Fselected_window (Qnil); | |
| 4927 struct window *w = XWINDOW (window); | |
| 444 | 4928 int n = (NILP (count) ? |
| 4929 window_char_width (w, 0) - 2 : | |
| 4930 XINT (Fprefix_numeric_value (count))); | |
| 4931 | |
| 4932 return Fset_window_hscroll (window, make_int (w->hscroll - n)); | |
| 428 | 4933 } |
| 4934 | |
| 4935 DEFUN ("center-to-window-line", Fcenter_to_window_line, 0, 2, "_P", /* | |
| 4936 Center point in WINDOW. With N, put point on line N. | |
| 4937 The desired position of point is always relative to the window. | |
| 4938 If WINDOW is nil, the selected window is used. | |
| 4939 */ | |
| 4940 (n, window)) | |
| 4941 { | |
| 4942 struct window *w = decode_window (window); | |
| 4943 struct buffer *b = XBUFFER (w->buffer); | |
| 665 | 4944 Charbpos opoint = BUF_PT (b); |
| 4945 Charbpos startp; | |
| 428 | 4946 |
| 4947 if (NILP (n)) | |
| 4948 startp = start_with_line_at_pixpos (w, opoint, window_half_pixpos (w)); | |
| 4949 else | |
| 4950 { | |
| 4951 n = Fprefix_numeric_value (n); | |
| 4952 CHECK_INT (n); | |
| 4953 startp = start_with_point_on_display_line (w, opoint, XINT (n)); | |
| 4954 } | |
| 4955 | |
| 4956 Fset_marker (w->start[CURRENT_DISP], make_int (startp), w->buffer); | |
| 4957 | |
| 4958 w->start_at_line_beg = beginning_of_line_p (b, startp); | |
| 4959 w->force_start = 1; | |
| 4960 MARK_WINDOWS_CHANGED (w); | |
| 4961 return Qnil; | |
| 4962 } | |
| 4963 | |
| 4964 DEFUN ("move-to-window-line", Fmove_to_window_line, 1, 2, "_P", /* | |
| 4965 Position point relative to WINDOW. | |
| 4966 With no argument, position text at center of window. | |
| 4967 An argument specifies window line; zero means top of window, | |
| 4968 negative means relative to bottom of window. | |
| 4969 If WINDOW is nil, the selected window is used. | |
| 4970 */ | |
| 4971 (arg, window)) | |
| 4972 { | |
| 4973 struct window *w; | |
| 4974 struct buffer *b; | |
| 4975 int height; | |
| 665 | 4976 Charbpos start, new_point; |
| 428 | 4977 int selected; |
| 4978 | |
| 4979 /* Don't use decode_window() because we need the new value of | |
| 4980 WINDOW. */ | |
| 4981 if (NILP (window)) | |
| 4982 window = Fselected_window (Qnil); | |
| 4983 else | |
| 4984 CHECK_LIVE_WINDOW (window); | |
| 4985 w = XWINDOW (window); | |
| 4986 b = XBUFFER (w->buffer); | |
| 4987 | |
| 4988 height = window_displayed_height (w); | |
| 4989 selected = EQ (window, Fselected_window (w->frame)); | |
| 4990 | |
| 4991 if (NILP (arg)) | |
| 4992 { | |
| 4993 int retval; | |
| 4994 | |
| 4995 if (XINT (w->last_modified[CURRENT_DISP]) >= BUF_MODIFF (b) | |
| 4996 && XINT (w->last_facechange[CURRENT_DISP]) >= BUF_FACECHANGE (b)) | |
| 4997 { | |
| 4998 new_point = point_at_center (w, CURRENT_DISP, 0, 0); | |
| 4999 | |
| 844 | 5000 /* #### Here we are checking the selected window of the frame |
| 5001 instead of the selected window period. Elsewhere we check | |
| 5002 the selected window of the device. What a mess! */ | |
| 428 | 5003 if (selected) |
| 5004 BUF_SET_PT (b, new_point); | |
| 5005 else | |
| 5006 Fset_window_point (window, make_int (new_point)); | |
| 5007 | |
| 5008 retval = line_at_center (w, CURRENT_DISP, 0, 0); | |
| 5009 } | |
| 5010 else | |
| 5011 { | |
| 5012 start = marker_position (w->start[CURRENT_DISP]); | |
| 5013 if (start < BUF_BEGV (b)) | |
| 5014 start = BUF_BEGV (b); | |
| 5015 else if (start > BUF_ZV (b)) | |
| 5016 start = BUF_ZV (b); | |
| 5017 | |
| 5018 if (selected) | |
| 5019 new_point = BUF_PT (b); | |
| 5020 else | |
| 5021 new_point = marker_position (w->pointm[CURRENT_DISP]); | |
| 5022 | |
| 5023 new_point = point_at_center (w, CMOTION_DISP, start, BUF_PT (b)); | |
| 5024 | |
| 5025 if (selected) | |
| 5026 BUF_SET_PT (b, new_point); | |
| 5027 else | |
| 5028 Fset_window_point (window, make_int (new_point)); | |
| 5029 | |
| 5030 retval = line_at_center (w, CMOTION_DISP, start, BUF_PT (b)); | |
| 5031 } | |
| 5032 | |
| 5033 return make_int (retval); | |
| 5034 } | |
| 5035 else | |
| 5036 { | |
| 5037 /* #### Is this going to work right when at eob? */ | |
| 5038 arg = Fprefix_numeric_value (arg); | |
| 5039 if (XINT (arg) < 0) | |
| 793 | 5040 arg = make_int (XINT (arg) + height); |
| 428 | 5041 } |
| 5042 | |
| 5043 start = marker_position (w->start[CURRENT_DISP]); | |
| 5044 if (start < BUF_BEGV (b) || start > BUF_ZV (b)) | |
| 5045 { | |
| 5046 if (selected) | |
| 5047 new_point = BUF_PT (b); | |
| 5048 else | |
| 5049 new_point = marker_position (w->pointm[CURRENT_DISP]); | |
| 5050 | |
| 5051 new_point = vmotion (XWINDOW (window), new_point, -height / 2, 0); | |
| 5052 | |
| 5053 if (selected) | |
| 5054 BUF_SET_PT (b, new_point); | |
| 5055 else | |
| 5056 Fset_window_point (window, make_int (new_point)); | |
| 5057 | |
| 5058 Fset_marker (w->start[CURRENT_DISP], make_int (new_point), | |
| 5059 w->buffer); | |
| 5060 w->start_at_line_beg = beginning_of_line_p (b, new_point); | |
| 5061 w->force_start = 1; | |
| 5062 } | |
| 5063 else | |
| 5064 { | |
| 5065 if (selected) | |
| 5066 BUF_SET_PT (b, start); | |
| 5067 else | |
| 5068 Fset_window_point (window, make_int (start)); | |
| 5069 } | |
| 5070 | |
| 5071 if (selected) | |
| 5072 return Fvertical_motion (arg, window, Qnil); | |
| 5073 else | |
| 5074 { | |
| 5075 int vpos; | |
| 5076 new_point = vmotion (XWINDOW (window), | |
| 5077 marker_position (w->pointm[CURRENT_DISP]), | |
| 5078 XINT (arg), &vpos); | |
| 5079 Fset_window_point (window, make_int (new_point)); | |
| 5080 return make_int (vpos); | |
| 5081 } | |
| 5082 } | |
| 5083 | |
| 5084 | |
| 5085 static int | |
| 5086 map_windows_1 (Lisp_Object window, | |
| 5087 int (*mapfun) (struct window *w, void *closure), | |
| 5088 void *closure) | |
| 5089 { | |
| 5090 for (; !NILP (window); window = XWINDOW (window)->next) | |
| 5091 { | |
| 5092 int retval; | |
| 5093 struct window *w = XWINDOW (window); | |
| 5094 | |
| 5095 if (!NILP (w->vchild)) | |
| 5096 retval = map_windows_1 (w->vchild, mapfun, closure); | |
| 5097 else if (!NILP (w->hchild)) | |
| 5098 retval = map_windows_1 (w->hchild, mapfun, closure); | |
| 5099 else | |
| 5100 retval = (mapfun) (w, closure); | |
| 5101 | |
| 5102 if (retval) | |
| 5103 return retval; | |
| 5104 } | |
| 5105 | |
| 5106 return 0; | |
| 5107 } | |
| 5108 | |
| 5109 /* Map MAPFUN over the windows in F. CLOSURE is passed to each | |
| 5110 invocation of MAPFUN. If any invocation of MAPFUN returns | |
| 5111 non-zero, the mapping is halted. Otherwise, map_windows() maps | |
| 5112 over all windows in F. | |
| 5113 | |
| 800 | 5114 If F is null, map over all frames on all devices and consoles. |
| 5115 | |
| 428 | 5116 If MAPFUN creates or deletes windows, the behavior is undefined. */ |
| 5117 | |
| 5118 int | |
| 5119 map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure), | |
| 5120 void *closure) | |
| 5121 { | |
| 5122 if (f) | |
| 5123 return map_windows_1 (FRAME_ROOT_WINDOW (f), mapfun, closure); | |
| 5124 else | |
| 5125 { | |
| 5126 Lisp_Object frmcons, devcons, concons; | |
| 5127 | |
| 5128 FRAME_LOOP_NO_BREAK(frmcons, devcons, concons) | |
| 5129 { | |
| 5130 int v = map_windows_1 (FRAME_ROOT_WINDOW (XFRAME (XCAR (frmcons))), | |
| 5131 mapfun, closure); | |
| 5132 if (v) | |
| 5133 return v; | |
| 5134 } | |
| 5135 } | |
| 5136 | |
| 5137 return 0; | |
| 5138 } | |
| 5139 | |
| 5140 | |
| 5141 static void | |
| 2286 | 5142 modeline_shadow_thickness_changed (Lisp_Object UNUSED (specifier), |
| 5143 struct window *w, | |
| 5144 Lisp_Object UNUSED (oldval)) | |
| 428 | 5145 { |
| 5146 w->shadow_thickness_changed = 1; | |
| 5147 MARK_WINDOWS_CHANGED (w); | |
| 5148 } | |
| 5149 | |
| 5150 static void | |
| 2286 | 5151 vertical_divider_changed_in_window (Lisp_Object UNUSED (specifier), |
| 428 | 5152 struct window *w, |
| 2286 | 5153 Lisp_Object UNUSED (oldval)) |
| 428 | 5154 { |
| 5155 MARK_WINDOWS_CHANGED (w); | |
| 5156 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (XFRAME (WINDOW_FRAME (w))); | |
| 5157 } | |
| 5158 | |
| 5159 /* also used in scrollbar.c */ | |
| 5160 void | |
| 2286 | 5161 some_window_value_changed (Lisp_Object UNUSED (specifier), |
| 5162 struct window *w, | |
| 5163 Lisp_Object UNUSED (oldval)) | |
| 428 | 5164 { |
| 5165 MARK_WINDOWS_CHANGED (w); | |
| 5166 } | |
| 5167 | |
| 5168 #ifdef MEMORY_USAGE_STATS | |
| 5169 | |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5170 struct window_mirror_stats |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5171 { |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5172 struct usage_stats u; |
|
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
5217
diff
changeset
|
5173 /* Ancillary non-lisp */ |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5174 Bytecount redisplay_structs; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5175 #ifdef HAVE_SCROLLBARS |
|
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
5217
diff
changeset
|
5176 /* Ancillary Lisp */ |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5177 Bytecount scrollbar; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5178 #endif |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5179 }; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5180 |
| 428 | 5181 struct window_stats |
| 5182 { | |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5183 struct usage_stats u; |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5184 /* Ancillary non-Lisp */ |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5185 Bytecount line_start; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5186 /* The next two: ancillary non-Lisp under old-GC, ancillary Lisp under |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5187 NEW_GC */ |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5188 Bytecount face; |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5189 Bytecount glyph; |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5190 /* The next two are copied out of the window mirror, which is an ancillary |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5191 Lisp structure; the first is non-Lisp, the second Lisp, but from our |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5192 perspective, they are both counted as Lisp */ |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5193 Bytecount redisplay_structs; |
| 428 | 5194 #ifdef HAVE_SCROLLBARS |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5195 Bytecount scrollbar; |
| 428 | 5196 #endif |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5197 /* Remaining memory associated with window mirror (ancillary Lisp) */ |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5198 Bytecount window_mirror; |
| 428 | 5199 }; |
| 5200 | |
| 5201 static void | |
| 5202 compute_window_mirror_usage (struct window_mirror *mir, | |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5203 struct window_mirror_stats *stats) |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5204 { |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5205 stats->redisplay_structs = |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5206 compute_display_line_dynarr_usage (mir->current_display_lines, &stats->u) |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5207 + |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5208 compute_display_line_dynarr_usage (mir->desired_display_lines, &stats->u); |
| 428 | 5209 #ifdef HAVE_SCROLLBARS |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5210 stats->scrollbar = |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5211 compute_all_scrollbar_instance_usage (mir->scrollbar_vertical_instance) + |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5212 compute_all_scrollbar_instance_usage (mir->scrollbar_horizontal_instance); |
| 428 | 5213 #endif /* HAVE_SCROLLBARS */ |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5214 } |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5215 |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5216 |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5217 static void |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5218 window_mirror_memory_usage (Lisp_Object window_mirror, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5219 struct generic_usage_stats *gustats) |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5220 { |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5221 struct window_mirror_stats *stats = (struct window_mirror_stats *) gustats; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5222 |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5223 compute_window_mirror_usage (XWINDOW_MIRROR (window_mirror), stats); |
| 428 | 5224 } |
| 5225 | |
| 5226 static void | |
| 5227 compute_window_usage (struct window *w, struct window_stats *stats, | |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5228 struct usage_stats *ustats) |
| 428 | 5229 { |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5230 stats->line_start = |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5231 compute_line_start_cache_dynarr_usage (w->line_start_cache, ustats); |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5232 stats->face = compute_face_cachel_usage (w->face_cachels, |
|
5217
c0f518284a68
Unbreak `show-memory-usage' for NEW_GC.
Marcus Crestani <crestani@informatik.uni-tuebingen.de>
parents:
5214
diff
changeset
|
5233 ustats); |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5234 stats->glyph = compute_glyph_cachel_usage (w->glyph_cachels, |
|
5217
c0f518284a68
Unbreak `show-memory-usage' for NEW_GC.
Marcus Crestani <crestani@informatik.uni-tuebingen.de>
parents:
5214
diff
changeset
|
5235 ustats); |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5236 { |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5237 struct window_mirror *wm; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5238 |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5239 wm = find_window_mirror_maybe (w); |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5240 if (wm) |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5241 { |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5242 struct generic_usage_stats gustats; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5243 struct window_mirror_stats *wmstats; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5244 Bytecount total; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5245 total = lisp_object_memory_usage_full (wrap_window_mirror (wm), |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5246 NULL, NULL, NULL, &gustats); |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5247 wmstats = (struct window_mirror_stats *) &gustats; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5248 stats->redisplay_structs = wmstats->redisplay_structs; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5249 total -= stats->redisplay_structs; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5250 #ifdef HAVE_SCROLLBARS |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5251 stats->scrollbar = wmstats->scrollbar; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5252 total -= stats->scrollbar; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5253 #endif |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5254 stats->window_mirror = total; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5255 } |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5256 } |
| 428 | 5257 } |
| 5258 | |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5259 static void |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5260 window_memory_usage (Lisp_Object window, struct generic_usage_stats *gustats) |
| 428 | 5261 { |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5262 struct window_stats *stats = (struct window_stats *) gustats; |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5263 |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5264 compute_window_usage (XWINDOW (window), stats, &stats->u); |
| 428 | 5265 } |
| 5266 | |
| 5267 #endif /* MEMORY_USAGE_STATS */ | |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5268 |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5269 |
| 428 | 5270 |
| 5271 /* Mark all subwindows of a window as deleted. The argument | |
| 5272 W is actually the subwindow tree of the window in question. */ | |
| 5273 | |
| 5274 void | |
| 5275 delete_all_subwindows (struct window *w) | |
| 5276 { | |
| 5277 if (!NILP (w->next)) delete_all_subwindows (XWINDOW (w->next)); | |
| 5278 if (!NILP (w->vchild)) delete_all_subwindows (XWINDOW (w->vchild)); | |
| 5279 if (!NILP (w->hchild)) delete_all_subwindows (XWINDOW (w->hchild)); | |
| 5280 | |
| 5281 mark_window_as_deleted (w); | |
| 5282 } | |
| 5283 | |
| 1149 | 5284 |
| 2289 | 5285 static int |
| 5286 get_current_pixel_pos (Lisp_Object window, Lisp_Object pos, | |
| 5287 struct window **w, | |
| 5288 struct rune **rb, struct display_line **dl) | |
| 428 | 5289 { |
| 2289 | 5290 display_line_dynarr *dla; |
| 5291 struct display_block *db = NULL; | |
| 5292 int x, y; | |
| 5293 | |
| 5294 *rb = NULL; | |
| 5295 *dl = NULL; | |
| 5296 *w = decode_window (window); | |
| 5297 dla = window_display_lines (*w, CURRENT_DISP); | |
| 5298 x = (*w)->last_point_x[CURRENT_DISP]; | |
| 5299 y = (*w)->last_point_y[CURRENT_DISP]; | |
| 5300 if (MINI_WINDOW_P (*w)) | |
| 5301 return 0; | |
| 428 | 5302 |
| 5303 if (y<0 || x<0 || y >= Dynarr_length (dla) || !NILP (pos)) | |
| 5304 { | |
| 5305 int first_line, i; | |
| 665 | 5306 Charbpos point; |
| 428 | 5307 |
| 5308 if (NILP (pos)) | |
| 5309 pos = Fwindow_point (window); | |
| 438 | 5310 |
| 428 | 5311 CHECK_INT (pos); |
| 5312 point = XINT (pos); | |
| 5313 | |
| 4967 | 5314 if (Dynarr_length (dla) && Dynarr_begin (dla)->modeline) |
| 428 | 5315 first_line = 1; |
| 5316 else | |
| 5317 first_line = 0; | |
| 5318 | |
| 5319 for (i = first_line; i < Dynarr_length (dla); i++) | |
| 5320 { | |
| 2289 | 5321 *dl = Dynarr_atp (dla, i); |
| 428 | 5322 /* find the vertical location first */ |
| 2289 | 5323 if (point >= (*dl)->charpos && point <= (*dl)->end_charpos) |
| 428 | 5324 { |
| 2289 | 5325 db = get_display_block_from_line (*dl, TEXT); |
| 428 | 5326 for (i = 0; i < Dynarr_length (db->runes); i++) |
| 5327 { | |
| 2289 | 5328 *rb = Dynarr_atp (db->runes, i); |
| 2290 | 5329 if (point <= (*rb)->charpos) |
| 826 | 5330 goto found_charpos; |
| 428 | 5331 } |
| 2289 | 5332 return 0; |
| 428 | 5333 } |
| 5334 } | |
| 2289 | 5335 return 0; |
| 826 | 5336 found_charpos: |
| 428 | 5337 ; |
| 5338 } | |
| 5339 else | |
| 5340 { | |
| 442 | 5341 /* optimized case */ |
| 2289 | 5342 *dl = Dynarr_atp (dla, y); |
| 5343 db = get_display_block_from_line (*dl, TEXT); | |
| 428 | 5344 |
| 5345 if (x >= Dynarr_length (db->runes)) | |
| 2289 | 5346 return 0; |
| 5347 | |
| 5348 *rb = Dynarr_atp (db->runes, x); | |
| 428 | 5349 } |
| 5350 | |
| 2289 | 5351 return 1; |
| 5352 } | |
| 5353 | |
| 5354 DEFUN ("current-pixel-column", Fcurrent_pixel_column, 0, 2, 0, /* | |
| 5355 Return the horizontal pixel position of point POS in window. | |
| 5356 Beginning of line is column 0. If WINDOW is nil, the current window | |
| 5357 is assumed. If POS is nil, point is assumed. Note that POS must be | |
| 5358 visible for a non-nil result to be returned. This is calculated using | |
| 5359 the redisplay display tables; because of this, the returned value will | |
| 5360 only be correct if the redisplay tables are up-to-date. Use | |
| 5361 \"(sit-for 0)\" to insure that they are; however, if WINDOW is part of | |
| 5362 a new frame, use the following instead: | |
| 5363 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
| 5364 */ | |
| 5365 (window, pos)) | |
| 5366 { | |
| 5367 struct window* w; | |
| 5368 struct display_line *dl; | |
| 5369 struct rune* rb; | |
| 5370 | |
| 5371 if (!get_current_pixel_pos(window, pos, &w, &rb, &dl)) | |
| 5372 return Qnil; | |
| 5373 | |
| 428 | 5374 return make_int (rb->xpos - WINDOW_LEFT (w)); |
| 5375 } | |
| 5376 | |
| 2289 | 5377 DEFUN ("current-pixel-row", Fcurrent_pixel_row, 0, 2, 0, /* |
| 5378 Return the vertical pixel position of point POS in window. Top of | |
| 5379 window is row 0. If WINDOW is nil, the current window is assumed. If | |
| 5380 POS is nil, point is assumed. Note that POS must be visible for a | |
| 5381 non-nil result to be returned. This is calculated using the redisplay | |
| 5382 display tables; because of this, the returned value will only be | |
| 5383 correct if the redisplay tables are up-to-date. Use \"(sit-for 0)\" | |
| 5384 to insure that they are; however, if WINDOW is part of a new frame, | |
| 5385 use the following instead: | |
| 5386 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
| 5387 */ | |
| 5388 (window, pos)) | |
| 5389 { | |
| 5390 struct window* w; | |
| 5391 struct display_line *dl; | |
| 5392 struct rune* rb; | |
| 5393 | |
| 5394 if (!get_current_pixel_pos(window, pos, &w, &rb, &dl)) | |
| 5395 return Qnil; | |
| 5396 | |
| 5397 return make_int (dl->ypos - dl->ascent - WINDOW_TOP (w)); | |
| 5398 } | |
| 5399 | |
| 428 | 5400 |
| 5401 #ifdef DEBUG_XEMACS | |
| 5402 /* This is short and simple in elisp, but... it was written to debug | |
| 5403 problems purely on the C side. That is where we need to call it so | |
| 5404 here it is. */ | |
| 5405 static void | |
| 5406 debug_print_window (Lisp_Object window, int level) | |
| 5407 { | |
| 5408 int i; | |
| 5409 Lisp_Object child = Fwindow_first_vchild (window); | |
| 5410 | |
| 5411 if (NILP (child)) | |
| 5412 child = Fwindow_first_hchild (window); | |
| 5413 | |
| 5414 for (i = level; i > 0; i--) | |
| 442 | 5415 stderr_out ("\t"); |
| 5416 | |
| 5417 stderr_out ("#<window"); | |
| 428 | 5418 { |
| 5419 Lisp_Object buffer = XWINDOW (window)->buffer; | |
| 5420 if (!NILP (buffer) && BUFFERP (buffer)) | |
| 442 | 5421 stderr_out (" on %s", XSTRING_DATA (XBUFFER (buffer)->name)); |
| 428 | 5422 } |
|
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
5423 stderr_out (" 0x%x>", LISP_OBJECT_UID (window)); |
| 428 | 5424 |
| 5425 while (!NILP (child)) | |
| 5426 { | |
| 5427 debug_print_window (child, level + 1); | |
| 5428 child = Fwindow_next_child (child); | |
| 5429 } | |
| 5430 } | |
| 5431 | |
| 5432 void debug_print_windows (struct frame *f); | |
| 5433 void | |
| 5434 debug_print_windows (struct frame *f) | |
| 5435 { | |
| 5436 debug_print_window (f->root_window, 0); | |
| 5437 putc ('\n', stderr); | |
| 5438 } | |
| 5439 #endif /* DEBUG_XEMACS */ | |
| 5440 | |
| 5441 | |
| 5442 /************************************************************************/ | |
| 5443 /* initialization */ | |
| 5444 /************************************************************************/ | |
| 5445 | |
| 5446 void | |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5447 window_objects_create (void) |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5448 { |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5449 #ifdef MEMORY_USAGE_STATS |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5450 OBJECT_HAS_METHOD (window, memory_usage); |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5451 OBJECT_HAS_METHOD (window_mirror, memory_usage); |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5452 #endif |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5453 } |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5454 |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5455 void |
| 428 | 5456 syms_of_window (void) |
| 5457 { | |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
5458 INIT_LISP_OBJECT (window); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3078
diff
changeset
|
5459 INIT_LISP_OBJECT (window_mirror); |
| 3092 | 5460 #ifdef NEW_GC |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
5461 INIT_LISP_OBJECT (face_cachel); |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
5462 INIT_LISP_OBJECT (face_cachel_dynarr); |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
5463 INIT_LISP_OBJECT (glyph_cachel); |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
5464 INIT_LISP_OBJECT (glyph_cachel_dynarr); |
| 3092 | 5465 #endif /* NEW_GC */ |
| 442 | 5466 |
| 563 | 5467 DEFSYMBOL (Qwindowp); |
| 5468 DEFSYMBOL (Qwindow_live_p); | |
| 5469 DEFSYMBOL (Qdisplay_buffer); | |
| 428 | 5470 |
| 5471 #ifdef MEMORY_USAGE_STATS | |
| 563 | 5472 DEFSYMBOL (Qface_cache); |
| 5473 DEFSYMBOL (Qglyph_cache); | |
| 5474 DEFSYMBOL (Qline_start_cache); | |
| 428 | 5475 #ifdef HAVE_SCROLLBARS |
| 563 | 5476 DEFSYMBOL (Qscrollbar_instances); |
| 428 | 5477 #endif |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5478 DEFSYMBOL (Qredisplay_structs); |
| 428 | 5479 #endif |
| 5480 | |
| 707 | 5481 DEFSYMBOL (Qtruncate_partial_width_windows); |
| 1149 | 5482 DEFSYMBOL (Qcurrent_window_configuration); |
| 5483 DEFSYMBOL (Qset_window_configuration); | |
| 707 | 5484 |
| 428 | 5485 DEFSUBR (Fselected_window); |
| 5486 DEFSUBR (Flast_nonminibuf_window); | |
| 5487 DEFSUBR (Fminibuffer_window); | |
| 5488 DEFSUBR (Fwindow_minibuffer_p); | |
| 5489 DEFSUBR (Fwindowp); | |
| 5490 DEFSUBR (Fwindow_live_p); | |
| 5491 DEFSUBR (Fwindow_first_hchild); | |
| 5492 DEFSUBR (Fwindow_first_vchild); | |
| 5493 DEFSUBR (Fwindow_next_child); | |
| 5494 DEFSUBR (Fwindow_previous_child); | |
| 5495 DEFSUBR (Fwindow_parent); | |
| 5496 DEFSUBR (Fwindow_lowest_p); | |
| 5497 DEFSUBR (Fwindow_truncated_p); | |
| 5498 DEFSUBR (Fwindow_highest_p); | |
| 5499 DEFSUBR (Fwindow_leftmost_p); | |
| 5500 DEFSUBR (Fwindow_rightmost_p); | |
| 5501 DEFSUBR (Fpos_visible_in_window_p); | |
| 5502 DEFSUBR (Fwindow_buffer); | |
| 5503 DEFSUBR (Fwindow_frame); | |
| 5504 DEFSUBR (Fwindow_height); | |
| 5505 DEFSUBR (Fwindow_displayed_height); | |
| 5506 DEFSUBR (Fwindow_width); | |
| 442 | 5507 DEFSUBR (Fwindow_full_width); |
| 428 | 5508 DEFSUBR (Fwindow_pixel_height); |
| 5509 DEFSUBR (Fwindow_pixel_width); | |
| 442 | 5510 DEFSUBR (Fwindow_text_area_height); |
| 428 | 5511 DEFSUBR (Fwindow_text_area_pixel_height); |
| 5512 DEFSUBR (Fwindow_displayed_text_pixel_height); | |
| 5513 DEFSUBR (Fwindow_text_area_pixel_width); | |
| 5514 DEFSUBR (Fwindow_hscroll); | |
| 438 | 5515 DEFSUBR (Fset_window_hscroll); |
| 428 | 5516 DEFSUBR (Fmodeline_hscroll); |
| 5517 DEFSUBR (Fset_modeline_hscroll); | |
| 5518 DEFSUBR (Fwindow_pixel_edges); | |
| 5519 DEFSUBR (Fwindow_text_area_pixel_edges); | |
| 5520 DEFSUBR (Fwindow_point); | |
| 5521 DEFSUBR (Fwindow_start); | |
| 5522 DEFSUBR (Fwindow_end); | |
| 442 | 5523 DEFSUBR (Fwindow_last_line_visible_height); |
| 428 | 5524 DEFSUBR (Fset_window_point); |
| 5525 DEFSUBR (Fset_window_start); | |
| 5526 DEFSUBR (Fwindow_dedicated_p); | |
| 5527 DEFSUBR (Fset_window_dedicated_p); | |
| 5528 DEFSUBR (Fnext_window); | |
| 5529 DEFSUBR (Fprevious_window); | |
| 5530 DEFSUBR (Fnext_vertical_window); | |
| 5531 DEFSUBR (Fother_window); | |
| 5532 DEFSUBR (Fget_lru_window); | |
| 5533 DEFSUBR (Fget_largest_window); | |
| 5534 DEFSUBR (Fget_buffer_window); | |
| 5535 DEFSUBR (Fwindow_left_margin_pixel_width); | |
| 5536 DEFSUBR (Fwindow_right_margin_pixel_width); | |
| 5537 DEFSUBR (Fdelete_other_windows); | |
| 5538 DEFSUBR (Fdelete_windows_on); | |
| 5539 DEFSUBR (Freplace_buffer_in_windows); | |
| 5540 DEFSUBR (Fdelete_window); | |
| 5541 DEFSUBR (Fset_window_buffer); | |
| 5542 DEFSUBR (Fselect_window); | |
| 5543 DEFSUBR (Fsplit_window); | |
| 5544 DEFSUBR (Fenlarge_window); | |
| 5545 DEFSUBR (Fenlarge_window_pixels); | |
| 5546 DEFSUBR (Fshrink_window); | |
| 5547 DEFSUBR (Fshrink_window_pixels); | |
| 5548 DEFSUBR (Fscroll_up); | |
| 5549 DEFSUBR (Fscroll_down); | |
| 5550 DEFSUBR (Fscroll_left); | |
| 5551 DEFSUBR (Fscroll_right); | |
| 5552 DEFSUBR (Fother_window_for_scrolling); | |
| 5553 DEFSUBR (Fscroll_other_window); | |
| 5554 DEFSUBR (Fcenter_to_window_line); | |
| 5555 DEFSUBR (Fmove_to_window_line); | |
| 5556 DEFSUBR (Fcurrent_pixel_column); | |
| 2289 | 5557 DEFSUBR (Fcurrent_pixel_row); |
| 428 | 5558 } |
| 5559 | |
| 5560 void | |
| 5561 reinit_vars_of_window (void) | |
| 5562 { | |
| 5563 /* Make sure all windows get marked */ | |
| 5564 minibuf_window = Qnil; | |
| 5565 staticpro_nodump (&minibuf_window); | |
| 5566 } | |
| 5567 | |
| 5568 void | |
| 5569 vars_of_window (void) | |
| 5570 { | |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5571 #ifdef MEMORY_USAGE_STATS |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5572 Lisp_Object l; |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5573 |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5574 l = listu (Qline_start_cache, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5575 #ifdef NEW_GC |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5576 Qt, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5577 #endif |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5578 Qface_cache, Qglyph_cache, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5579 #ifndef NEW_GC |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5580 Qt, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5581 #endif |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5582 Qredisplay_structs, |
|
5164
8bf9e67e06ec
Fix broken compile of window.c under Visual Studio 6.
Vin Shelton <acs@xemacs.org>
parents:
5157
diff
changeset
|
5583 #ifdef HAVE_SCROLLBARS |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5584 Qscrollbar_instances, |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5585 #endif |
|
5170
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5586 intern ("window-mirror"), |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5587 Qunbound); |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5588 |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5589 OBJECT_HAS_PROPERTY (window, memusage_stats_list, l); |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5590 |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5591 l = listu (Qredisplay_structs, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5592 #ifdef HAVE_SCROLLBARS |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5593 Qt, Qscrollbar_instances, |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5594 #endif |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5595 Qunbound); |
|
5ddbab03b0e6
various fixes to memory-usage stats
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
5596 OBJECT_HAS_PROPERTY (window_mirror, memusage_stats_list, l); |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5597 #endif /* MEMORY_USAGE_STATS */ |
|
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
5598 |
| 428 | 5599 DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /* |
| 5600 *Non-nil means to scroll if point lands on a line which is clipped. | |
| 5601 */ ); | |
| 5602 scroll_on_clipped_lines = 1; | |
| 5603 | |
| 5604 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function /* | |
| 5605 Non-nil means call as function to display a help buffer. | |
| 5606 The function is called with one argument, the buffer to be displayed. | |
| 5607 Used by `with-output-to-temp-buffer'. | |
| 5608 If this function is used, then it must do the entire job of showing | |
| 5609 the buffer; `temp-buffer-show-hook' is not run unless this function runs it. | |
| 442 | 5610 \(`temp-buffer-show-hook' is obsolete. Do not use in new code.) |
| 428 | 5611 */ ); |
| 5612 Vtemp_buffer_show_function = Qnil; | |
| 5613 | |
| 5614 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuffer_scroll_window /* | |
| 5615 Non-nil means it is the window that \\<minibuffer-local-map>\\[scroll-other-window] in minibuffer should scroll. | |
| 5616 */ ); | |
| 5617 Vminibuffer_scroll_window = Qnil; | |
| 5618 | |
| 5619 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer /* | |
| 5620 If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. | |
| 5621 */ ); | |
| 5622 Vother_window_scroll_buffer = Qnil; | |
| 5623 | |
| 5624 DEFVAR_LISP ("window-pixel-scroll-increment", &Vwindow_pixel_scroll_increment /* | |
| 5625 *Number of pixels to scroll by per requested line. | |
| 5626 If nil then normal line scrolling occurs regardless of line height. | |
| 5627 If t then scrolling is done in increments equal to the height of the default face. | |
| 5628 */ ); | |
| 5629 Vwindow_pixel_scroll_increment = Qt; | |
| 5630 | |
| 5631 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines /* | |
| 5632 *Number of lines of continuity when scrolling by screenfuls. | |
| 5633 */ ); | |
| 5634 next_screen_context_lines = 2; | |
| 5635 | |
| 5636 DEFVAR_INT ("window-min-height", &window_min_height /* | |
| 5637 *Delete any window less than this tall (including its modeline). | |
| 5638 */ ); | |
| 5639 window_min_height = 4; | |
| 5640 | |
| 5641 DEFVAR_INT ("window-min-width", &window_min_width /* | |
| 5642 *Delete any window less than this wide. | |
| 5643 */ ); | |
| 5644 window_min_width = 10; | |
| 5645 } | |
| 5646 | |
| 5647 void | |
| 5648 specifier_vars_of_window (void) | |
| 5649 { | |
| 5650 DEFVAR_SPECIFIER ("modeline-shadow-thickness", &Vmodeline_shadow_thickness /* | |
| 5651 *How thick to draw 3D shadows around modelines. | |
| 5652 If this is set to 0, modelines will be the traditional 2D. Sizes above | |
| 5653 10 will be accepted but the maximum thickness that will be drawn is 10. | |
| 5654 This is a specifier; use `set-specifier' to change it. | |
| 5655 */ ); | |
| 5656 Vmodeline_shadow_thickness = Fmake_specifier (Qinteger); | |
| 5657 /* The initial value for modeline-shadow-thickness is 2, but if the | |
| 5658 user removes all specifications we provide a fallback value of 0, | |
| 5659 which is probably what was expected. */ | |
| 5660 set_specifier_fallback (Vmodeline_shadow_thickness, | |
| 5661 list1 (Fcons (Qnil, Qzero))); | |
| 5662 Fadd_spec_to_specifier (Vmodeline_shadow_thickness, make_int (2), | |
| 5663 Qnil, Qnil, Qnil); | |
| 5664 set_specifier_caching (Vmodeline_shadow_thickness, | |
| 438 | 5665 offsetof (struct window, modeline_shadow_thickness), |
| 428 | 5666 modeline_shadow_thickness_changed, |
| 444 | 5667 0, 0, 0); |
| 428 | 5668 |
| 5669 DEFVAR_SPECIFIER ("has-modeline-p", &Vhas_modeline_p /* | |
| 5670 *Whether the modeline should be displayed. | |
| 5671 This is a specifier; use `set-specifier' to change it. | |
| 5672 */ ); | |
| 5673 Vhas_modeline_p = Fmake_specifier (Qboolean); | |
| 5674 set_specifier_fallback (Vhas_modeline_p, | |
| 5675 list1 (Fcons (Qnil, Qt))); | |
| 5676 set_specifier_caching (Vhas_modeline_p, | |
| 438 | 5677 offsetof (struct window, has_modeline_p), |
| 428 | 5678 /* #### It's strange that we need a special |
| 5679 flag to indicate that the shadow-thickness | |
| 5680 has changed, but not one to indicate that | |
| 5681 the modeline has been turned off or on. */ | |
| 5682 some_window_value_changed, | |
| 444 | 5683 0, 0, 0); |
| 428 | 5684 |
| 5685 DEFVAR_SPECIFIER ("vertical-divider-always-visible-p", | |
| 5686 &Vvertical_divider_always_visible_p /* | |
| 5687 *Should XEmacs always display vertical dividers between windows. | |
| 5688 | |
| 5689 When this is non-nil, vertical dividers are always shown, and are | |
| 5690 draggable. When it is nil, vertical dividers are shown only when | |
| 5691 there are no scrollbars in between windows, and are not draggable. | |
| 5692 | |
| 5693 This is a specifier; use `set-specifier' to change it. | |
| 5694 */ ); | |
| 5695 Vvertical_divider_always_visible_p = Fmake_specifier (Qboolean); | |
| 5696 set_specifier_fallback (Vvertical_divider_always_visible_p, | |
| 5697 list1 (Fcons (Qnil, Qt))); | |
| 5698 set_specifier_caching (Vvertical_divider_always_visible_p, | |
| 438 | 5699 offsetof (struct window, |
| 5700 vertical_divider_always_visible_p), | |
| 428 | 5701 vertical_divider_changed_in_window, |
| 444 | 5702 0, 0, 0); |
| 428 | 5703 |
| 5704 DEFVAR_SPECIFIER ("vertical-divider-shadow-thickness", &Vvertical_divider_shadow_thickness /* | |
| 5705 *How thick to draw 3D shadows around vertical dividers. | |
| 5706 This is a specifier; use `set-specifier' to change it. | |
| 5707 */ ); | |
| 5708 Vvertical_divider_shadow_thickness = Fmake_specifier (Qinteger); | |
| 5709 set_specifier_fallback (Vvertical_divider_shadow_thickness, | |
| 5710 list1 (Fcons (Qnil, Qzero))); | |
| 5711 Fadd_spec_to_specifier (Vvertical_divider_shadow_thickness, make_int (2), | |
| 5712 Qnil, Qnil, Qnil); | |
| 5713 set_specifier_caching (Vvertical_divider_shadow_thickness, | |
| 438 | 5714 offsetof (struct window, |
| 5715 vertical_divider_shadow_thickness), | |
| 428 | 5716 vertical_divider_changed_in_window, |
| 444 | 5717 0, 0, 0); |
| 428 | 5718 DEFVAR_SPECIFIER ("vertical-divider-line-width", &Vvertical_divider_line_width /* |
| 5719 *The width of the vertical dividers, not including shadows. | |
| 5720 | |
| 5721 For TTY windows, divider line is always one character wide. When | |
| 5722 instance of this specifier is zero in a TTY window, no divider is | |
| 5723 drawn at all between windows. When non-zero, a one character wide | |
| 5724 divider is displayed. | |
| 5725 | |
| 5726 This is a specifier; use `set-specifier' to change it. | |
| 5727 */ ); | |
| 5728 | |
| 5729 Vvertical_divider_line_width = Fmake_specifier (Qnatnum); | |
| 5730 { | |
| 5731 Lisp_Object fb = Qnil; | |
| 5732 #ifdef HAVE_TTY | |
| 5733 fb = Fcons (Fcons (list1 (Qtty), make_int (1)), fb); | |
| 5734 #endif | |
| 462 | 5735 #ifdef HAVE_GTK |
| 5736 fb = Fcons (Fcons (list1 (Qgtk), make_int (3)), fb); | |
| 5737 #endif | |
| 428 | 5738 #ifdef HAVE_X_WINDOWS |
| 5739 fb = Fcons (Fcons (list1 (Qx), make_int (3)), fb); | |
| 5740 #endif | |
| 5741 #ifdef HAVE_MS_WINDOWS | |
| 5742 /* #### This should be made magic and made to obey system settings */ | |
| 5743 fb = Fcons (Fcons (list1 (Qmswindows), make_int (3)), fb); | |
| 5744 #endif | |
| 5745 set_specifier_fallback (Vvertical_divider_line_width, fb); | |
| 5746 } | |
| 5747 set_specifier_caching (Vvertical_divider_line_width, | |
| 438 | 5748 offsetof (struct window, |
| 5749 vertical_divider_line_width), | |
| 428 | 5750 vertical_divider_changed_in_window, |
| 444 | 5751 0, 0, 0); |
| 428 | 5752 |
| 5753 DEFVAR_SPECIFIER ("vertical-divider-spacing", &Vvertical_divider_spacing /* | |
| 5754 *How much space to leave around the vertical dividers. | |
| 5755 | |
| 5756 In TTY windows, spacing is always zero, and the value of this | |
| 5757 specifier is ignored. | |
| 5758 | |
| 5759 This is a specifier; use `set-specifier' to change it. | |
| 5760 */ ); | |
| 5761 Vvertical_divider_spacing = Fmake_specifier (Qnatnum); | |
| 5762 { | |
| 5763 Lisp_Object fb = Qnil; | |
| 5764 #ifdef HAVE_TTY | |
| 5765 fb = Fcons (Fcons (list1 (Qtty), Qzero), fb); | |
| 5766 #endif | |
| 5767 #ifdef HAVE_X_WINDOWS | |
| 5768 /* #### 3D dividers look great on MS Windows with spacing = 0. | |
| 5769 Should not the same value be the fallback under X? - kkm */ | |
| 5770 fb = Fcons (Fcons (list1 (Qx), make_int (2)), fb); | |
| 5771 #endif | |
| 462 | 5772 #ifdef HAVE_GTK |
| 5773 fb = Fcons (Fcons (list1 (Qgtk), Qzero), fb); | |
| 5774 #endif | |
| 428 | 5775 #ifdef HAVE_MS_WINDOWS |
| 5776 fb = Fcons (Fcons (list1 (Qmswindows), Qzero), fb); | |
| 5777 #endif | |
| 5778 set_specifier_fallback (Vvertical_divider_spacing, fb); | |
| 5779 } | |
| 5780 set_specifier_caching (Vvertical_divider_spacing, | |
| 438 | 5781 offsetof (struct window, vertical_divider_spacing), |
| 428 | 5782 vertical_divider_changed_in_window, |
| 444 | 5783 0, 0, 0); |
| 5784 } |
