Mercurial > emacs
annotate src/window.c @ 3794:ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
to treat two-character comment enders with a special shortcut.
(scan_sexps_forward): Set state.comstart to before the
comment starter, not after.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Thu, 17 Jun 1993 04:09:15 +0000 |
| parents | 3455cbb3339d |
| children | c267c2431d92 |
| rev | line source |
|---|---|
| 265 | 1 /* Window creation, deletion and examination for GNU Emacs. |
| 2 Does not include redisplay. | |
| 2961 | 3 Copyright (C) 1985, 1986, 1987, 1993 Free Software Foundation, Inc. |
| 265 | 4 |
| 5 This file is part of GNU Emacs. | |
| 6 | |
| 7 GNU Emacs is free software; you can redistribute it and/or modify | |
| 8 it under the terms of the GNU General Public License as published by | |
| 708 | 9 the Free Software Foundation; either version 2, or (at your option) |
| 265 | 10 any later version. |
| 11 | |
| 12 GNU Emacs is distributed in the hope that it will be useful, | |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 GNU General Public License for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
| 18 along with GNU Emacs; see the file COPYING. If not, write to | |
| 19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
| 20 | |
| 21 #include "config.h" | |
| 22 #include "lisp.h" | |
| 23 #include "buffer.h" | |
| 769 | 24 #include "frame.h" |
| 265 | 25 #include "window.h" |
| 26 #include "commands.h" | |
| 27 #include "indent.h" | |
| 28 #include "termchar.h" | |
| 29 #include "disptab.h" | |
| 522 | 30 #include "keyboard.h" |
| 265 | 31 |
|
2210
22d78dbb3cc7
Rename `live-window-p' to `window-live-p', for consistency with
Jim Blandy <jimb@redhat.com>
parents:
2190
diff
changeset
|
32 Lisp_Object Qwindowp, Qwindow_live_p; |
|
3785
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
33 Lisp_Object Qvisible; |
| 265 | 34 |
| 35 Lisp_Object Fnext_window (), Fdelete_window (), Fselect_window (); | |
| 36 Lisp_Object Fset_window_buffer (), Fsplit_window (), Frecenter (); | |
| 37 | |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
38 void delete_all_subwindows (); |
| 265 | 39 static struct window *decode_window(); |
| 40 | |
| 41 /* This is the window in which the terminal's cursor should | |
| 42 be left when nothing is being done with it. This must | |
| 43 always be a leaf window, and its buffer is selected by | |
| 44 the top level editing loop at the end of each command. | |
| 45 | |
| 46 This value is always the same as | |
| 769 | 47 FRAME_SELECTED_WINDOW (selected_frame). */ |
| 265 | 48 |
| 49 Lisp_Object selected_window; | |
| 50 | |
| 769 | 51 /* The minibuffer window of the selected frame. |
| 265 | 52 Note that you cannot test for minibufferness of an arbitrary window |
| 53 by comparing against this; but you can test for minibufferness of | |
| 54 the selected window. */ | |
| 55 Lisp_Object minibuf_window; | |
| 56 | |
| 57 /* Non-nil means it is the window for C-M-v to scroll | |
| 58 when the minibuffer is selected. */ | |
| 59 Lisp_Object Vminibuf_scroll_window; | |
| 60 | |
| 61 /* Non-nil means this is the buffer whose window C-M-v should scroll. */ | |
| 62 Lisp_Object Vother_window_scroll_buffer; | |
| 63 | |
| 64 /* Non-nil means it's function to call to display temp buffers. */ | |
| 65 Lisp_Object Vtemp_buffer_show_function; | |
| 66 | |
| 67 /* If a window gets smaller than either of these, it is removed. */ | |
| 68 int window_min_height; | |
| 69 int window_min_width; | |
| 70 | |
| 71 /* Nonzero implies Fdisplay_buffer should create windows. */ | |
| 72 int pop_up_windows; | |
| 73 | |
| 769 | 74 /* Nonzero implies make new frames for Fdisplay_buffer. */ |
| 75 int pop_up_frames; | |
| 265 | 76 |
| 77 /* Non-nil means use this function instead of default */ | |
| 769 | 78 Lisp_Object Vpop_up_frame_function; |
| 265 | 79 |
| 80 /* Function to call to handle Fdisplay_buffer. */ | |
| 81 Lisp_Object Vdisplay_buffer_function; | |
| 82 | |
| 83 /* Fdisplay_buffer always splits the largest window | |
| 84 if that window is more than this high. */ | |
| 85 int split_height_threshold; | |
| 86 | |
| 87 /* Number of lines of continuity in scrolling by screenfuls. */ | |
| 88 int next_screen_context_lines; | |
| 89 | |
| 90 /* Incremented for each window created. */ | |
| 91 static int sequence_number; | |
| 92 | |
| 93 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
| 94 | |
| 95 DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, | |
| 96 "Returns t if OBJ is a window.") | |
| 97 (obj) | |
| 98 Lisp_Object obj; | |
| 99 { | |
| 100 return XTYPE (obj) == Lisp_Window ? Qt : Qnil; | |
| 101 } | |
| 102 | |
|
2210
22d78dbb3cc7
Rename `live-window-p' to `window-live-p', for consistency with
Jim Blandy <jimb@redhat.com>
parents:
2190
diff
changeset
|
103 DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
104 "Returns t if OBJ is a window which is currently visible.") |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
105 (obj) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
106 Lisp_Object obj; |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
107 { |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
108 return ((XTYPE (obj) == Lisp_Window |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
109 && ! NILP (XWINDOW (obj)->buffer)) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
110 ? Qt : Qnil); |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
111 } |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
112 |
| 265 | 113 Lisp_Object |
| 114 make_window () | |
| 115 { | |
| 116 register Lisp_Object val; | |
| 117 register struct window *p; | |
| 118 | |
| 119 /* Add sizeof (Lisp_Object) here because sizeof (struct Lisp_Vector) | |
| 120 includes the first element. */ | |
| 121 val = Fmake_vector ( | |
| 122 make_number ((sizeof (struct window) - sizeof (struct Lisp_Vector) | |
| 123 + sizeof (Lisp_Object)) | |
| 124 / sizeof (Lisp_Object)), | |
| 125 Qnil); | |
| 126 XSETTYPE (val, Lisp_Window); | |
| 127 p = XWINDOW (val); | |
| 128 XFASTINT (p->sequence_number) = ++sequence_number; | |
| 129 XFASTINT (p->left) = XFASTINT (p->top) | |
| 130 = XFASTINT (p->height) = XFASTINT (p->width) | |
| 131 = XFASTINT (p->hscroll) = 0; | |
| 132 XFASTINT (p->last_point_x) = XFASTINT (p->last_point_y) = 0; | |
| 133 p->start = Fmake_marker (); | |
| 134 p->pointm = Fmake_marker (); | |
| 135 XFASTINT (p->use_time) = 0; | |
| 769 | 136 p->frame = Qnil; |
| 265 | 137 p->display_table = Qnil; |
| 138 p->dedicated = Qnil; | |
| 139 return val; | |
| 140 } | |
| 141 | |
| 142 DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, | |
| 143 "Return the window that the cursor now appears in and commands apply to.") | |
| 144 () | |
| 145 { | |
| 146 return selected_window; | |
| 147 } | |
| 148 | |
|
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
149 DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
150 "Return the window used now for minibuffers.\n\ |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
151 If the optional argument FRAME is specified, return the minibuffer window\n\ |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
152 used by that frame.") |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
153 (frame) |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
154 Lisp_Object frame; |
| 265 | 155 { |
| 769 | 156 #ifdef MULTI_FRAME |
|
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
157 if (NILP (frame)) |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
158 XSET (frame, Lisp_Frame, selected_frame); |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
159 else |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
160 CHECK_LIVE_FRAME (frame, 0); |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
161 #endif |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
162 |
|
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
163 return FRAME_MINIBUF_WINDOW (XFRAME (frame)); |
| 265 | 164 } |
| 165 | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
166 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, Swindow_minibuffer_p, 0, 1, 0, |
| 265 | 167 "Returns non-nil if WINDOW is a minibuffer window.") |
| 168 (window) | |
| 169 Lisp_Object window; | |
| 170 { | |
| 171 struct window *w = decode_window (window); | |
| 172 return (MINI_WINDOW_P (w) ? Qt : Qnil); | |
| 173 } | |
| 174 | |
| 175 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, | |
| 176 Spos_visible_in_window_p, 0, 2, 0, | |
| 769 | 177 "Return t if position POS is currently on the frame in WINDOW.\n\ |
| 265 | 178 Returns nil if that position is scrolled vertically out of view.\n\ |
| 179 POS defaults to point; WINDOW, to the selected window.") | |
| 180 (pos, window) | |
| 181 Lisp_Object pos, window; | |
| 182 { | |
| 183 register struct window *w; | |
| 184 register int top; | |
| 185 register int height; | |
| 186 register int posint; | |
| 187 register struct buffer *buf; | |
| 188 struct position posval; | |
| 189 | |
| 485 | 190 if (NILP (pos)) |
| 265 | 191 posint = point; |
| 192 else | |
| 193 { | |
| 194 CHECK_NUMBER_COERCE_MARKER (pos, 0); | |
| 195 posint = XINT (pos); | |
| 196 } | |
| 197 | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
198 w = decode_window (window); |
| 265 | 199 top = marker_position (w->start); |
| 200 | |
| 201 if (posint < top) | |
| 202 return Qnil; | |
| 203 | |
| 204 height = XFASTINT (w->height) - ! MINI_WINDOW_P (w); | |
| 205 | |
| 206 buf = XBUFFER (w->buffer); | |
| 207 if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf)) | |
| 208 { | |
| 769 | 209 /* If frame is up to date, |
| 265 | 210 use the info recorded about how much text fit on it. */ |
| 211 if (posint < BUF_Z (buf) - XFASTINT (w->window_end_pos) | |
| 212 || (XFASTINT (w->window_end_vpos) < height)) | |
| 213 return Qt; | |
| 214 return Qnil; | |
| 215 } | |
| 216 else | |
| 217 { | |
| 218 if (posint > BUF_Z (buf)) | |
| 219 return Qnil; | |
| 220 | |
| 221 /* If that info is not correct, calculate afresh */ | |
| 222 posval = *compute_motion (top, 0, 0, posint, height, 0, | |
|
1783
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
223 window_internal_width (w) - 1, |
| 265 | 224 XINT (w->hscroll), 0); |
| 225 | |
| 226 return posval.vpos < height ? Qt : Qnil; | |
| 227 } | |
| 228 } | |
| 229 | |
| 230 static struct window * | |
| 231 decode_window (window) | |
| 232 register Lisp_Object window; | |
| 233 { | |
| 485 | 234 if (NILP (window)) |
| 265 | 235 return XWINDOW (selected_window); |
| 236 | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
237 CHECK_LIVE_WINDOW (window, 0); |
| 265 | 238 return XWINDOW (window); |
| 239 } | |
| 240 | |
| 241 DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, | |
| 242 "Return the buffer that WINDOW is displaying.") | |
| 243 (window) | |
| 244 Lisp_Object window; | |
| 245 { | |
| 246 return decode_window (window)->buffer; | |
| 247 } | |
| 248 | |
| 249 DEFUN ("window-height", Fwindow_height, Swindow_height, 0, 1, 0, | |
| 250 "Return the number of lines in WINDOW (including its mode line).") | |
| 251 (window) | |
| 252 Lisp_Object window; | |
| 253 { | |
| 254 return decode_window (window)->height; | |
| 255 } | |
| 256 | |
| 257 DEFUN ("window-width", Fwindow_width, Swindow_width, 0, 1, 0, | |
| 258 "Return the number of columns in WINDOW.") | |
| 259 (window) | |
| 260 Lisp_Object window; | |
| 261 { | |
| 262 register struct window *w = decode_window (window); | |
|
1525
f79a22ad87d0
* window.c (Fwindow_width, Fset_window_hscroll): Use accessors on
Jim Blandy <jimb@redhat.com>
parents:
1444
diff
changeset
|
263 register int width = XFASTINT (w->width); |
| 265 | 264 |
|
1783
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
265 return make_number (window_internal_width (w)); |
| 265 | 266 } |
| 267 | |
| 268 DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, | |
| 269 "Return the number of columns by which WINDOW is scrolled from left margin.") | |
| 270 (window) | |
| 271 Lisp_Object window; | |
| 272 { | |
| 273 return decode_window (window)->hscroll; | |
| 274 } | |
| 275 | |
| 276 DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, | |
| 277 "Set number of columns WINDOW is scrolled from left margin to NCOL.\n\ | |
| 278 NCOL should be zero or positive.") | |
| 279 (window, ncol) | |
| 280 register Lisp_Object window, ncol; | |
| 281 { | |
| 282 register struct window *w; | |
| 283 | |
| 284 CHECK_NUMBER (ncol, 1); | |
| 285 if (XINT (ncol) < 0) XFASTINT (ncol) = 0; | |
| 286 if (XFASTINT (ncol) >= (1 << (SHORTBITS - 1))) | |
| 287 args_out_of_range (ncol, Qnil); | |
| 288 w = decode_window (window); | |
|
1525
f79a22ad87d0
* window.c (Fwindow_width, Fset_window_hscroll): Use accessors on
Jim Blandy <jimb@redhat.com>
parents:
1444
diff
changeset
|
289 if (XINT (w->hscroll) != XINT (ncol)) |
| 265 | 290 clip_changed = 1; /* Prevent redisplay shortcuts */ |
| 291 w->hscroll = ncol; | |
| 292 return ncol; | |
| 293 } | |
| 294 | |
| 295 DEFUN ("window-edges", Fwindow_edges, Swindow_edges, 0, 1, 0, | |
| 296 "Return a list of the edge coordinates of WINDOW.\n\ | |
| 769 | 297 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.\n\ |
| 265 | 298 RIGHT is one more than the rightmost column used by WINDOW,\n\ |
| 299 and BOTTOM is one more than the bottommost row used by WINDOW\n\ | |
| 300 and its mode-line.") | |
| 301 (window) | |
| 302 Lisp_Object window; | |
| 303 { | |
| 304 register struct window *w = decode_window (window); | |
| 305 | |
| 306 return Fcons (w->left, Fcons (w->top, | |
| 307 Fcons (make_number (XFASTINT (w->left) + XFASTINT (w->width)), | |
| 308 Fcons (make_number (XFASTINT (w->top) | |
| 309 + XFASTINT (w->height)), | |
| 310 Qnil)))); | |
| 311 } | |
| 312 | |
| 432 | 313 /* Test if the character at column *x, row *y is within window *w. |
| 314 If it is not, return 0; | |
| 315 if it is in the window's text area, | |
| 316 set *x and *y to its location relative to the upper left corner | |
| 317 of the window, and | |
| 318 return 1; | |
| 319 if it is on the window's modeline, return 2; | |
| 320 if it is on the border between the window and its right sibling, | |
| 321 return 3. */ | |
| 322 static int | |
| 323 coordinates_in_window (w, x, y) | |
| 324 register struct window *w; | |
| 325 register int *x, *y; | |
| 326 { | |
| 327 register int left = XINT (w->left); | |
| 328 register int width = XINT (w->width); | |
| 329 register int window_height = XINT (w->height); | |
| 330 register int top = XFASTINT (w->top); | |
| 331 | |
| 332 if ( *x < left || *x >= left + width | |
| 333 || *y < top || *y >= top + window_height) | |
| 334 return 0; | |
| 335 | |
| 336 /* Is the character is the mode line? */ | |
| 337 if (*y == top + window_height - 1 | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
338 && ! MINI_WINDOW_P (w)) |
| 432 | 339 return 2; |
| 340 | |
| 341 /* Is the character in the right border? */ | |
| 342 if (*x == left + width - 1 | |
| 769 | 343 && left + width != FRAME_WIDTH (XFRAME (w->frame))) |
| 432 | 344 return 3; |
| 345 | |
| 346 *x -= left; | |
| 347 *y -= top; | |
| 348 return 1; | |
| 349 } | |
| 350 | |
| 351 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | |
| 352 Scoordinates_in_window_p, 2, 2, 0, | |
| 353 "Return non-nil if COORDINATES are in WINDOW.\n\ | |
| 708 | 354 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ |
| 769 | 355 measured in characters from the upper-left corner of the frame.\n\ |
| 708 | 356 (0 . 0) denotes the character in the upper left corner of the\n\ |
| 769 | 357 frame.\n\ |
| 432 | 358 If COORDINATES are in the text portion of WINDOW,\n\ |
| 359 the coordinates relative to the window are returned.\n\ | |
| 732 | 360 If they are in the mode line of WINDOW, `mode-line' is returned.\n\ |
| 432 | 361 If they are on the border between WINDOW and its right sibling,\n\ |
| 732 | 362 `vertical-line' is returned.") |
| 432 | 363 (coordinates, window) |
| 364 register Lisp_Object coordinates, window; | |
| 365 { | |
| 366 int x, y; | |
| 367 | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
368 CHECK_LIVE_WINDOW (window, 0); |
| 432 | 369 CHECK_CONS (coordinates, 1); |
| 370 x = XINT (Fcar (coordinates)); | |
| 371 y = XINT (Fcdr (coordinates)); | |
| 372 | |
| 373 switch (coordinates_in_window (XWINDOW (window), &x, &y)) | |
| 374 { | |
| 375 case 0: /* NOT in window at all. */ | |
| 376 return Qnil; | |
| 377 | |
| 378 case 1: /* In text part of window. */ | |
| 379 return Fcons (x, y); | |
| 380 | |
| 381 case 2: /* In mode line of window. */ | |
| 382 return Qmode_line; | |
| 383 | |
| 384 case 3: /* On right border of window. */ | |
| 732 | 385 return Qvertical_line; |
| 432 | 386 |
| 387 default: | |
| 388 abort (); | |
| 389 } | |
| 390 } | |
| 391 | |
| 265 | 392 /* Find the window containing column x, row y, and return it as a |
| 432 | 393 Lisp_Object. If x, y is on the window's modeline, set *part |
| 394 to 1; if it is on the separating line between the window and its | |
| 395 right sibling, set it to 2; otherwise set it to 0. If there is no | |
| 396 window under x, y return nil and leave *part unmodified. */ | |
| 265 | 397 Lisp_Object |
| 769 | 398 window_from_coordinates (frame, x, y, part) |
| 399 FRAME_PTR frame; | |
| 265 | 400 int x, y; |
| 432 | 401 int *part; |
| 265 | 402 { |
| 403 register Lisp_Object tem, first; | |
| 404 | |
| 769 | 405 tem = first = FRAME_SELECTED_WINDOW (frame); |
| 265 | 406 |
| 432 | 407 do |
| 265 | 408 { |
| 409 int found = coordinates_in_window (XWINDOW (tem), &x, &y); | |
| 410 | |
| 411 if (found) | |
| 412 { | |
| 432 | 413 *part = found - 1; |
| 265 | 414 return tem; |
| 415 } | |
| 416 | |
| 432 | 417 tem = Fnext_window (tem, Qt, Qlambda); |
| 265 | 418 } |
| 432 | 419 while (! EQ (tem, first)); |
| 420 | |
| 421 return Qnil; | |
| 265 | 422 } |
| 423 | |
|
681
026f978690be
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
555
diff
changeset
|
424 DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, |
| 1798 | 425 "Return window containing coordinates X and Y on FRAME.\n\ |
| 769 | 426 If omitted, FRAME defaults to the currently selected frame.\n\ |
| 427 The top left corner of the frame is considered to be row 0,\n\ | |
| 548 | 428 column 0.") |
| 1798 | 429 (x, y, frame) |
| 430 Lisp_Object x, y, frame; | |
| 265 | 431 { |
| 432 int part; | |
| 433 | |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
434 #ifdef MULTI_FRAME |
| 769 | 435 if (NILP (frame)) |
| 436 XSET (frame, Lisp_Frame, selected_frame); | |
| 432 | 437 else |
| 769 | 438 CHECK_LIVE_FRAME (frame, 2); |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
439 #endif |
| 1798 | 440 CHECK_NUMBER (x, 0); |
| 441 CHECK_NUMBER (y, 1); | |
| 265 | 442 |
| 769 | 443 return window_from_coordinates (XFRAME (frame), |
| 1798 | 444 XINT (x), XINT (y), |
| 265 | 445 &part); |
| 446 } | |
| 447 | |
| 448 DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, | |
| 449 "Return current value of point in WINDOW.\n\ | |
| 450 For a nonselected window, this is the value point would have\n\ | |
| 451 if that window were selected.\n\ | |
| 452 \n\ | |
| 453 Note that, when WINDOW is the selected window and its buffer\n\ | |
| 454 is also currently selected, the value returned is the same as (point).\n\ | |
| 455 It would be more strictly correct to return the `top-level' value\n\ | |
| 456 of point, outside of any save-excursion forms.\n\ | |
| 457 But that is hard to define.") | |
| 458 (window) | |
| 459 Lisp_Object window; | |
| 460 { | |
| 461 register struct window *w = decode_window (window); | |
| 462 | |
| 463 if (w == XWINDOW (selected_window) | |
| 464 && current_buffer == XBUFFER (w->buffer)) | |
| 465 return Fpoint (); | |
| 466 return Fmarker_position (w->pointm); | |
| 467 } | |
| 468 | |
| 469 DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, | |
| 470 "Return position at which display currently starts in WINDOW.") | |
| 471 (window) | |
| 472 Lisp_Object window; | |
| 473 { | |
| 474 return Fmarker_position (decode_window (window)->start); | |
| 475 } | |
| 476 | |
| 477 DEFUN ("window-end", Fwindow_end, Swindow_end, 0, 1, 0, | |
| 478 "Return position at which display currently ends in WINDOW.") | |
| 479 (window) | |
| 480 Lisp_Object window; | |
| 481 { | |
| 482 Lisp_Object value; | |
| 483 struct window *w = decode_window (window); | |
| 484 | |
| 485 XSET (value, Lisp_Int, | |
| 486 BUF_Z (current_buffer) - XFASTINT (w->window_end_pos)); | |
| 487 | |
| 488 return value; | |
| 489 } | |
| 490 | |
| 491 DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, | |
| 492 "Make point value in WINDOW be at position POS in WINDOW's buffer.") | |
| 493 (window, pos) | |
| 494 Lisp_Object window, pos; | |
| 495 { | |
| 496 register struct window *w = decode_window (window); | |
| 497 | |
| 498 CHECK_NUMBER_COERCE_MARKER (pos, 1); | |
| 499 if (w == XWINDOW (selected_window)) | |
| 500 Fgoto_char (pos); | |
| 501 else | |
| 502 set_marker_restricted (w->pointm, pos, w->buffer); | |
| 503 | |
| 504 return pos; | |
| 505 } | |
| 506 | |
| 507 DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, | |
| 508 "Make display in WINDOW start at position POS in WINDOW's buffer.\n\ | |
| 509 Optional third arg NOFORCE non-nil inhibits next redisplay\n\ | |
| 510 from overriding motion of point in order to display at this exact start.") | |
| 511 (window, pos, noforce) | |
| 512 Lisp_Object window, pos, noforce; | |
| 513 { | |
| 514 register struct window *w = decode_window (window); | |
| 515 | |
| 516 CHECK_NUMBER_COERCE_MARKER (pos, 1); | |
| 517 set_marker_restricted (w->start, pos, w->buffer); | |
| 518 /* this is not right, but much easier than doing what is right. */ | |
| 519 w->start_at_line_beg = Qnil; | |
| 485 | 520 if (NILP (noforce)) |
| 265 | 521 w->force_start = Qt; |
| 522 w->update_mode_line = Qt; | |
| 523 XFASTINT (w->last_modified) = 0; | |
| 338 | 524 if (!EQ (window, selected_window)) |
| 525 windows_or_buffers_changed++; | |
| 265 | 526 return pos; |
| 527 } | |
| 528 | |
| 529 DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, | |
| 530 1, 1, 0, | |
| 531 "Return WINDOW's dedicated object, usually t or nil.\n\ | |
|
2865
427eadecebd6
* window.c (window-dedicated-p): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
2693
diff
changeset
|
532 See also `set-window-dedicated-p'.") |
| 265 | 533 (window) |
| 534 Lisp_Object window; | |
| 535 { | |
| 536 return decode_window (window)->dedicated; | |
| 537 } | |
| 538 | |
|
722
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
539 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, |
|
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
540 Sset_window_dedicated_p, 2, 2, 0, |
|
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
541 "Control whether WINDOW is dedicated to the buffer it displays.\n\ |
|
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
542 If it is dedicated, Emacs will not automatically change\n\ |
|
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
543 which buffer appears in it.\n\ |
|
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
544 The second argument is the new value for the dedication flag;\n\ |
|
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
545 non-nil means yes.") |
| 265 | 546 (window, arg) |
| 547 Lisp_Object window, arg; | |
| 548 { | |
| 549 register struct window *w = decode_window (window); | |
| 550 | |
| 485 | 551 if (NILP (arg)) |
| 265 | 552 w->dedicated = Qnil; |
| 553 else | |
|
722
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
554 w->dedicated = Qt; |
| 265 | 555 |
| 556 return w->dedicated; | |
| 557 } | |
| 558 | |
| 559 DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, | |
| 560 0, 1, 0, | |
| 561 "Return the display-table that WINDOW is using.") | |
| 562 (window) | |
| 563 Lisp_Object window; | |
| 564 { | |
| 565 return decode_window (window)->display_table; | |
| 566 } | |
| 567 | |
| 568 /* Get the display table for use currently on window W. | |
| 569 This is either W's display table or W's buffer's display table. | |
| 570 Ignore the specified tables if they are not valid; | |
| 571 if no valid table is specified, return 0. */ | |
| 572 | |
| 573 struct Lisp_Vector * | |
| 574 window_display_table (w) | |
| 575 struct window *w; | |
| 576 { | |
| 577 Lisp_Object tem; | |
| 578 tem = w->display_table; | |
| 579 if (XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == DISP_TABLE_SIZE) | |
| 580 return XVECTOR (tem); | |
| 581 tem = XBUFFER (w->buffer)->display_table; | |
| 582 if (XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == DISP_TABLE_SIZE) | |
| 583 return XVECTOR (tem); | |
| 584 tem = Vstandard_display_table; | |
| 585 if (XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == DISP_TABLE_SIZE) | |
| 586 return XVECTOR (tem); | |
| 587 return 0; | |
| 588 } | |
| 589 | |
| 555 | 590 DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0, |
| 265 | 591 "Set WINDOW's display-table to TABLE.") |
| 592 (window, table) | |
| 593 register Lisp_Object window, table; | |
| 594 { | |
| 595 register struct window *w; | |
| 596 register Lisp_Object z; /* Return value. */ | |
| 597 | |
| 598 w = decode_window (window); | |
| 599 w->display_table = table; | |
| 600 return table; | |
| 601 } | |
| 602 | |
| 603 /* Record info on buffer window w is displaying | |
| 604 when it is about to cease to display that buffer. */ | |
| 605 static | |
| 606 unshow_buffer (w) | |
| 607 register struct window *w; | |
| 608 { | |
| 609 Lisp_Object buf = w->buffer; | |
| 610 | |
| 611 if (XBUFFER (buf) != XMARKER (w->pointm)->buffer) | |
| 612 abort (); | |
| 613 | |
| 614 if (w == XWINDOW (selected_window) | |
| 615 || ! EQ (buf, XWINDOW (selected_window)->buffer)) | |
| 616 /* Do this except when the selected window's buffer | |
| 617 is being removed from some other window. */ | |
| 618 XBUFFER (buf)->last_window_start = marker_position (w->start); | |
| 619 | |
| 620 /* Point in the selected window's buffer | |
| 621 is actually stored in that buffer, and the window's pointm isn't used. | |
| 622 So don't clobber point in that buffer. */ | |
| 623 if (! EQ (buf, XWINDOW (selected_window)->buffer)) | |
| 624 BUF_PT (XBUFFER (buf)) | |
| 625 = clip_to_bounds (BUF_BEGV (XBUFFER (buf)), | |
| 626 marker_position (w->pointm), | |
| 627 BUF_ZV (XBUFFER (buf))); | |
| 628 } | |
| 629 | |
| 630 /* Put replacement into the window structure in place of old. */ | |
| 631 static | |
| 632 replace_window (old, replacement) | |
| 633 Lisp_Object old, replacement; | |
| 634 { | |
| 635 register Lisp_Object tem; | |
| 636 register struct window *o = XWINDOW (old), *p = XWINDOW (replacement); | |
| 637 | |
| 769 | 638 /* If OLD is its frame's root_window, then replacement is the new |
| 639 root_window for that frame. */ | |
| 265 | 640 |
|
1525
f79a22ad87d0
* window.c (Fwindow_width, Fset_window_hscroll): Use accessors on
Jim Blandy <jimb@redhat.com>
parents:
1444
diff
changeset
|
641 if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) |
| 769 | 642 FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement; |
| 265 | 643 |
| 644 p->left = o->left; | |
| 645 p->top = o->top; | |
| 646 p->width = o->width; | |
| 647 p->height = o->height; | |
| 648 | |
| 649 p->next = tem = o->next; | |
| 485 | 650 if (!NILP (tem)) |
| 265 | 651 XWINDOW (tem)->prev = replacement; |
| 652 | |
| 653 p->prev = tem = o->prev; | |
| 485 | 654 if (!NILP (tem)) |
| 265 | 655 XWINDOW (tem)->next = replacement; |
| 656 | |
| 657 p->parent = tem = o->parent; | |
| 485 | 658 if (!NILP (tem)) |
| 265 | 659 { |
| 660 if (EQ (XWINDOW (tem)->vchild, old)) | |
| 661 XWINDOW (tem)->vchild = replacement; | |
| 662 if (EQ (XWINDOW (tem)->hchild, old)) | |
| 663 XWINDOW (tem)->hchild = replacement; | |
| 664 } | |
| 665 | |
| 666 /*** Here, if replacement is a vertical combination | |
| 667 and so is its new parent, we should make replacement's | |
| 668 children be children of that parent instead. ***/ | |
| 669 } | |
| 670 | |
| 671 DEFUN ("delete-window", Fdelete_window, Sdelete_window, 0, 1, "", | |
| 672 "Remove WINDOW from the display. Default is selected window.") | |
| 673 (window) | |
| 674 register Lisp_Object window; | |
| 675 { | |
| 676 register Lisp_Object tem, parent, sib; | |
| 677 register struct window *p; | |
| 678 register struct window *par; | |
| 679 | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
680 /* Because this function is called by other C code on non-leaf |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
681 windows, the CHECK_LIVE_WINDOW macro would choke inappropriately, |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
682 so we can't decode_window here. */ |
| 485 | 683 if (NILP (window)) |
| 265 | 684 window = selected_window; |
| 685 else | |
| 686 CHECK_WINDOW (window, 0); | |
| 687 p = XWINDOW (window); | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
688 |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
689 /* It's okay to delete an already-deleted window. */ |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
690 if (NILP (p->buffer) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
691 && NILP (p->hchild) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
692 && NILP (p->vchild)) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
693 return Qnil; |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
694 |
| 265 | 695 parent = p->parent; |
| 485 | 696 if (NILP (parent)) |
| 265 | 697 error ("Attempt to delete minibuffer or sole ordinary window"); |
| 698 par = XWINDOW (parent); | |
| 699 | |
| 700 windows_or_buffers_changed++; | |
| 701 | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
702 /* Are we trying to delete any frame's selected window? */ |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
703 { |
|
3723
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
704 Lisp_Object frame, pwindow; |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
705 |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
706 /* See if the frame's selected window is either WINDOW |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
707 or any subwindow of it, by finding all that window's parents |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
708 and comparing each one with WINDOW. */ |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
709 frame = WINDOW_FRAME (XWINDOW (window)); |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
710 pwindow = FRAME_SELECTED_WINDOW (XFRAME (frame)); |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
711 |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
712 while (!NILP (pwindow)) |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
713 { |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
714 if (EQ (window, pwindow)) |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
715 break; |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
716 pwindow = XWINDOW (pwindow)->parent; |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
717 } |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
718 |
|
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
719 if (EQ (window, pwindow)) |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
720 { |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
721 Lisp_Object alternative = Fnext_window (window, Qlambda, Qnil); |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
722 |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
723 /* If we're about to delete the selected window on the |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
724 selected frame, then we should use Fselect_window to select |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
725 the new window. On the other hand, if we're about to |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
726 delete the selected window on any other frame, we shouldn't do |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
727 anything but set the frame's selected_window slot. */ |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
728 if (EQ (window, selected_window)) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
729 Fselect_window (alternative); |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
730 else |
|
3723
ccb9c93aac80
(Fdelete_window): Handle deleting a parent of the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
3688
diff
changeset
|
731 FRAME_SELECTED_WINDOW (XFRAME (frame)) = alternative; |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
732 } |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
733 } |
| 265 | 734 |
| 735 tem = p->buffer; | |
| 736 /* tem is null for dummy parent windows | |
| 737 (which have inferiors but not any contents themselves) */ | |
| 485 | 738 if (!NILP (tem)) |
| 265 | 739 { |
| 740 unshow_buffer (p); | |
| 741 unchain_marker (p->pointm); | |
| 742 unchain_marker (p->start); | |
| 743 } | |
| 744 | |
| 745 tem = p->next; | |
| 485 | 746 if (!NILP (tem)) |
| 265 | 747 XWINDOW (tem)->prev = p->prev; |
| 748 | |
| 749 tem = p->prev; | |
| 485 | 750 if (!NILP (tem)) |
| 265 | 751 XWINDOW (tem)->next = p->next; |
| 752 | |
| 753 if (EQ (window, par->hchild)) | |
| 754 par->hchild = p->next; | |
| 755 if (EQ (window, par->vchild)) | |
| 756 par->vchild = p->next; | |
| 757 | |
| 758 /* Find one of our siblings to give our space to. */ | |
| 759 sib = p->prev; | |
| 485 | 760 if (NILP (sib)) |
| 265 | 761 { |
| 762 /* If p gives its space to its next sibling, that sibling needs | |
| 763 to have its top/left side pulled back to where p's is. | |
| 764 set_window_{height,width} will re-position the sibling's | |
| 765 children. */ | |
| 766 sib = p->next; | |
|
1525
f79a22ad87d0
* window.c (Fwindow_width, Fset_window_hscroll): Use accessors on
Jim Blandy <jimb@redhat.com>
parents:
1444
diff
changeset
|
767 XWINDOW (sib)->top = p->top; |
|
f79a22ad87d0
* window.c (Fwindow_width, Fset_window_hscroll): Use accessors on
Jim Blandy <jimb@redhat.com>
parents:
1444
diff
changeset
|
768 XWINDOW (sib)->left = p->left; |
| 265 | 769 } |
| 770 | |
| 771 /* Stretch that sibling. */ | |
| 485 | 772 if (!NILP (par->vchild)) |
| 265 | 773 set_window_height (sib, |
| 774 XFASTINT (XWINDOW (sib)->height) + XFASTINT (p->height), | |
| 775 1); | |
| 485 | 776 if (!NILP (par->hchild)) |
| 265 | 777 set_window_width (sib, |
| 778 XFASTINT (XWINDOW (sib)->width) + XFASTINT (p->width), | |
| 779 1); | |
| 780 | |
| 781 /* If parent now has only one child, | |
| 782 put the child into the parent's place. */ | |
| 783 tem = par->hchild; | |
| 485 | 784 if (NILP (tem)) |
| 265 | 785 tem = par->vchild; |
| 485 | 786 if (NILP (XWINDOW (tem)->next)) |
| 265 | 787 replace_window (parent, tem); |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
788 |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
789 /* Since we may be deleting combination windows, we must make sure that |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
790 not only p but all its children have been marked as deleted. */ |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
791 if (! NILP (p->hchild)) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
792 delete_all_subwindows (XWINDOW (p->hchild)); |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
793 else if (! NILP (p->vchild)) |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
794 delete_all_subwindows (XWINDOW (p->vchild)); |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
795 |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
796 /* Mark this window as deleted. */ |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
797 p->buffer = p->hchild = p->vchild = Qnil; |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
798 |
| 265 | 799 return Qnil; |
| 800 } | |
| 801 | |
| 432 | 802 |
| 769 | 803 extern Lisp_Object next_frame (), prev_frame (); |
| 432 | 804 |
| 805 DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0, | |
| 806 "Return next window after WINDOW in canonical ordering of windows.\n\ | |
| 807 If omitted, WINDOW defaults to the selected window.\n\ | |
| 808 \n\ | |
| 809 Optional second arg MINIBUF t means count the minibuffer window even\n\ | |
| 810 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\ | |
| 811 it is active. MINIBUF neither t nor nil means not to count the\n\ | |
| 812 minibuffer even if it is active.\n\ | |
| 813 \n\ | |
| 769 | 814 Several frames may share a single minibuffer; if the minibuffer\n\ |
| 815 counts, all windows on all frames that share that minibuffer count\n\ | |
| 432 | 816 too. This means that next-window may be used to iterate through the\n\ |
| 769 | 817 set of windows even when the minibuffer is on another frame. If the\n\ |
| 818 minibuffer does not count, only windows from WINDOW's frame count.\n\ | |
| 432 | 819 \n\ |
| 769 | 820 Optional third arg ALL-FRAMES t means include windows on all frames.\n\ |
| 821 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\ | |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
822 above. If neither nil nor t, restrict to WINDOW's frame.\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
823 \n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
824 If you use consistent values for MINIBUF and ALL-FRAMES, you can use\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
825 `next-window' to iterate through the entire cycle of acceptable\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
826 windows, eventually ending up back at the window you started with.\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
827 `previous-window' traverses the same cycle, in the reverse order.") |
| 769 | 828 (window, minibuf, all_frames) |
| 829 register Lisp_Object window, minibuf, all_frames; | |
| 265 | 830 { |
| 432 | 831 register Lisp_Object tem; |
| 832 Lisp_Object start_window; | |
| 265 | 833 |
| 485 | 834 if (NILP (window)) |
| 432 | 835 window = selected_window; |
| 836 else | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
837 CHECK_LIVE_WINDOW (window, 0); |
| 432 | 838 |
| 839 start_window = window; | |
| 840 | |
| 841 /* minibuf == nil may or may not include minibuffers. | |
| 842 Decide if it does. */ | |
| 485 | 843 if (NILP (minibuf)) |
| 432 | 844 minibuf = (minibuf_level ? Qt : Qlambda); |
| 845 | |
| 769 | 846 /* all_frames == nil doesn't specify which frames to include. |
| 847 Decide which frames it includes. */ | |
| 848 if (NILP (all_frames)) | |
| 849 all_frames = (EQ (minibuf, Qt) | |
| 850 ? (FRAME_MINIBUF_WINDOW | |
| 851 (XFRAME | |
| 852 (WINDOW_FRAME | |
| 432 | 853 (XWINDOW (window))))) |
| 854 : Qnil); | |
| 769 | 855 else if (! EQ (all_frames, Qt)) |
| 856 all_frames = Qnil; | |
|
3621
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
857 /* Now all_frames is t meaning search all frames, |
|
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
858 nil meaning search just current frame, |
|
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
859 or a window, meaning search the frame that window belongs to. */ |
| 432 | 860 |
| 265 | 861 /* Do this loop at least once, to get the next window, and perhaps |
| 862 again, if we hit the minibuffer and that is not acceptable. */ | |
| 863 do | |
| 864 { | |
| 865 /* Find a window that actually has a next one. This loop | |
| 866 climbs up the tree. */ | |
| 485 | 867 while (tem = XWINDOW (window)->next, NILP (tem)) |
| 868 if (tem = XWINDOW (window)->parent, !NILP (tem)) | |
| 265 | 869 window = tem; |
| 432 | 870 else |
| 265 | 871 { |
| 769 | 872 /* We've reached the end of this frame. |
| 873 Which other frames are acceptable? */ | |
| 874 tem = WINDOW_FRAME (XWINDOW (window)); | |
| 875 #ifdef MULTI_FRAME | |
| 876 if (! NILP (all_frames)) | |
| 877 tem = next_frame (tem, all_frames); | |
| 432 | 878 #endif |
| 769 | 879 tem = FRAME_ROOT_WINDOW (XFRAME (tem)); |
| 432 | 880 |
| 265 | 881 break; |
| 882 } | |
| 883 | |
| 884 window = tem; | |
| 432 | 885 |
| 265 | 886 /* If we're in a combination window, find its first child and |
| 887 recurse on that. Otherwise, we've found the window we want. */ | |
| 888 while (1) | |
| 889 { | |
| 485 | 890 if (!NILP (XWINDOW (window)->hchild)) |
| 265 | 891 window = XWINDOW (window)->hchild; |
| 485 | 892 else if (!NILP (XWINDOW (window)->vchild)) |
| 265 | 893 window = XWINDOW (window)->vchild; |
| 894 else break; | |
| 895 } | |
| 896 } | |
| 432 | 897 /* Which windows are acceptible? |
| 898 Exit the loop and accept this window if | |
| 265 | 899 this isn't a minibuffer window, or |
| 432 | 900 we're accepting minibuffer windows, or |
| 901 we've come all the way around and we're back at the original window. */ | |
| 265 | 902 while (MINI_WINDOW_P (XWINDOW (window)) |
| 432 | 903 && ! EQ (minibuf, Qt) |
|
1525
f79a22ad87d0
* window.c (Fwindow_width, Fset_window_hscroll): Use accessors on
Jim Blandy <jimb@redhat.com>
parents:
1444
diff
changeset
|
904 && ! EQ (window, start_window)); |
| 265 | 905 |
| 906 return window; | |
| 907 } | |
| 908 | |
| 432 | 909 DEFUN ("previous-window", Fprevious_window, Sprevious_window, 0, 3, 0, |
| 910 "Return the window preceeding WINDOW in canonical ordering of windows.\n\ | |
| 911 If omitted, WINDOW defaults to the selected window.\n\ | |
| 912 \n\ | |
| 913 Optional second arg MINIBUF t means count the minibuffer window even\n\ | |
| 914 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\ | |
| 915 it is active. MINIBUF neither t nor nil means not to count the\n\ | |
| 916 minibuffer even if it is active.\n\ | |
| 917 \n\ | |
| 769 | 918 Several frames may share a single minibuffer; if the minibuffer\n\ |
| 919 counts, all windows on all frames that share that minibuffer count\n\ | |
| 432 | 920 too. This means that previous-window may be used to iterate through\n\ |
| 769 | 921 the set of windows even when the minibuffer is on another frame. If\n\ |
| 922 the minibuffer does not count, only windows from WINDOW's frame\n\ | |
| 432 | 923 count.\n\ |
| 924 \n\ | |
| 769 | 925 Optional third arg ALL-FRAMES t means include windows on all frames.\n\ |
| 926 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\ | |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
927 above. If neither nil nor t, restrict to WINDOW's frame.\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
928 \n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
929 If you use consistent values for MINIBUF and ALL-FRAMES, you can use\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
930 `previous-window' to iterate through the entire cycle of acceptable\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
931 windows, eventually ending up back at the window you started with.\n\ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
932 `next-window' traverses the same cycle, in the reverse order.") |
| 769 | 933 (window, minibuf, all_frames) |
| 934 register Lisp_Object window, minibuf, all_frames; | |
| 265 | 935 { |
| 936 register Lisp_Object tem; | |
| 432 | 937 Lisp_Object start_window; |
| 265 | 938 |
| 485 | 939 if (NILP (window)) |
| 265 | 940 window = selected_window; |
| 941 else | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
942 CHECK_LIVE_WINDOW (window, 0); |
| 265 | 943 |
| 432 | 944 start_window = window; |
| 265 | 945 |
| 432 | 946 /* minibuf == nil may or may not include minibuffers. |
| 947 Decide if it does. */ | |
| 485 | 948 if (NILP (minibuf)) |
| 432 | 949 minibuf = (minibuf_level ? Qt : Qlambda); |
| 265 | 950 |
| 769 | 951 /* all_frames == nil doesn't specify which frames to include. |
| 952 Decide which frames it includes. */ | |
| 953 if (NILP (all_frames)) | |
| 954 all_frames = (EQ (minibuf, Qt) | |
| 955 ? (FRAME_MINIBUF_WINDOW | |
| 956 (XFRAME | |
| 957 (WINDOW_FRAME | |
| 432 | 958 (XWINDOW (window))))) |
| 959 : Qnil); | |
| 769 | 960 else if (! EQ (all_frames, Qt)) |
| 961 all_frames = Qnil; | |
|
3621
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
962 /* Now all_frames is t meaning search all frames, |
|
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
963 nil meaning search just current frame, |
|
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
964 or a window, meaning search the frame that window belongs to. */ |
| 265 | 965 |
| 966 /* Do this loop at least once, to get the previous window, and perhaps | |
| 967 again, if we hit the minibuffer and that is not acceptable. */ | |
| 968 do | |
| 969 { | |
| 970 /* Find a window that actually has a previous one. This loop | |
| 971 climbs up the tree. */ | |
| 485 | 972 while (tem = XWINDOW (window)->prev, NILP (tem)) |
| 973 if (tem = XWINDOW (window)->parent, !NILP (tem)) | |
| 265 | 974 window = tem; |
| 432 | 975 else |
| 265 | 976 { |
| 769 | 977 /* We have found the top window on the frame. |
| 978 Which frames are acceptable? */ | |
| 979 tem = WINDOW_FRAME (XWINDOW (window)); | |
| 980 #ifdef MULTI_FRAME | |
| 981 if (! NILP (all_frames)) | |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
982 /* It's actually important that we use prev_frame here, |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
983 rather than next_frame. All the windows acceptable |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
984 according to the given parameters should form a ring; |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
985 Fnext_window and Fprevious_window should go back and |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
986 forth around the ring. If we use next_frame here, |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
987 then Fnext_window and Fprevious_window take different |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
988 paths through the set of acceptable windows. |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
989 window_loop assumes that these `ring' requirement are |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
990 met. */ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
991 tem = prev_frame (tem, all_frames); |
| 265 | 992 #endif |
|
3621
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
993 /* If this frame has a minibuffer, find that window first, |
|
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
994 because it is conceptually the last window in that frame. */ |
|
3678
01941fa99c91
* window.c (Fprevious_window): Use FRAME_HAS_MINIBUF_P to decide
Jim Blandy <jimb@redhat.com>
parents:
3645
diff
changeset
|
995 if (FRAME_HAS_MINIBUF_P (XFRAME (tem))) |
|
01941fa99c91
* window.c (Fprevious_window): Use FRAME_HAS_MINIBUF_P to decide
Jim Blandy <jimb@redhat.com>
parents:
3645
diff
changeset
|
996 tem = FRAME_MINIBUF_WINDOW (XFRAME (tem)); |
|
01941fa99c91
* window.c (Fprevious_window): Use FRAME_HAS_MINIBUF_P to decide
Jim Blandy <jimb@redhat.com>
parents:
3645
diff
changeset
|
997 else |
|
3621
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
998 tem = FRAME_ROOT_WINDOW (XFRAME (tem)); |
| 432 | 999 |
| 265 | 1000 break; |
| 1001 } | |
| 1002 | |
| 1003 window = tem; | |
| 1004 /* If we're in a combination window, find its last child and | |
| 1005 recurse on that. Otherwise, we've found the window we want. */ | |
| 1006 while (1) | |
| 1007 { | |
| 485 | 1008 if (!NILP (XWINDOW (window)->hchild)) |
| 265 | 1009 window = XWINDOW (window)->hchild; |
| 485 | 1010 else if (!NILP (XWINDOW (window)->vchild)) |
| 265 | 1011 window = XWINDOW (window)->vchild; |
| 1012 else break; | |
| 485 | 1013 while (tem = XWINDOW (window)->next, !NILP (tem)) |
| 265 | 1014 window = tem; |
| 1015 } | |
| 1016 } | |
| 432 | 1017 /* Which windows are acceptable? |
| 1018 Exit the loop and accept this window if | |
| 265 | 1019 this isn't a minibuffer window, or |
| 432 | 1020 we're accepting minibuffer windows, or |
| 1021 we've come all the way around and we're back at the original window. */ | |
| 265 | 1022 while (MINI_WINDOW_P (XWINDOW (window)) |
| 432 | 1023 && !EQ (minibuf, Qt) |
|
1525
f79a22ad87d0
* window.c (Fwindow_width, Fset_window_hscroll): Use accessors on
Jim Blandy <jimb@redhat.com>
parents:
1444
diff
changeset
|
1024 && !EQ (window, start_window)); |
| 265 | 1025 |
| 1026 return window; | |
| 1027 } | |
| 1028 | |
| 338 | 1029 DEFUN ("other-window", Fother_window, Sother_window, 1, 2, "p", |
| 769 | 1030 "Select the ARG'th different window on this frame.\n\ |
| 1031 All windows on current frame are arranged in a cyclic order.\n\ | |
| 265 | 1032 This command selects the window ARG steps away in that order.\n\ |
| 1033 A negative ARG moves in the opposite order. If the optional second\n\ | |
| 769 | 1034 argument ALL_FRAMES is non-nil, cycle through all frames.") |
| 1035 (n, all_frames) | |
| 1036 register Lisp_Object n, all_frames; | |
| 265 | 1037 { |
| 1038 register int i; | |
| 1039 register Lisp_Object w; | |
| 1040 | |
| 1041 CHECK_NUMBER (n, 0); | |
| 1042 w = selected_window; | |
| 1043 i = XINT (n); | |
| 1044 | |
| 1045 while (i > 0) | |
| 1046 { | |
| 769 | 1047 w = Fnext_window (w, Qnil, all_frames); |
| 265 | 1048 i--; |
| 1049 } | |
| 1050 while (i < 0) | |
| 1051 { | |
| 769 | 1052 w = Fprevious_window (w, Qnil, all_frames); |
| 265 | 1053 i++; |
| 1054 } | |
| 1055 Fselect_window (w); | |
| 1056 return Qnil; | |
| 1057 } | |
| 1058 | |
| 1059 /* Look at all windows, performing an operation specified by TYPE | |
| 1060 with argument OBJ. | |
|
3785
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1061 If FRAMES is Qt, look at all frames; |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1062 Qvisible, look at visible frames (GET_BUFFER_WINDOW only); |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1063 Qnil, look at just the selected frame; |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1064 a frame, just look at windows on that frame. |
| 265 | 1065 If MINI is non-zero, perform the operation on minibuffer windows too. |
| 1066 */ | |
| 1067 | |
| 1068 enum window_loop | |
| 1069 { | |
| 1070 WINDOW_LOOP_UNUSED, | |
| 1071 GET_BUFFER_WINDOW, /* Arg is buffer */ | |
| 1072 GET_LRU_WINDOW, /* Arg is t for full-width windows only */ | |
| 1073 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */ | |
| 1074 DELETE_BUFFER_WINDOWS, /* Arg is buffer */ | |
| 1075 GET_LARGEST_WINDOW, | |
| 1076 UNSHOW_BUFFER, /* Arg is buffer */ | |
| 1077 }; | |
| 1078 | |
| 1079 static Lisp_Object | |
| 769 | 1080 window_loop (type, obj, mini, frames) |
| 265 | 1081 enum window_loop type; |
| 769 | 1082 register Lisp_Object obj, frames; |
| 265 | 1083 int mini; |
| 1084 { | |
| 1085 register Lisp_Object w; | |
| 1086 register Lisp_Object best_window; | |
| 1087 register Lisp_Object next_window; | |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1088 register Lisp_Object last_window; |
| 769 | 1089 FRAME_PTR frame; |
| 265 | 1090 |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1091 #ifdef MULTI_FRAME |
| 769 | 1092 /* If we're only looping through windows on a particular frame, |
| 1093 frame points to that frame. If we're looping through windows | |
| 1094 on all frames, frame is 0. */ | |
| 1095 if (FRAMEP (frames)) | |
| 1096 frame = XFRAME (frames); | |
| 1097 else if (NILP (frames)) | |
| 1098 frame = selected_frame; | |
| 265 | 1099 else |
| 769 | 1100 frame = 0; |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1101 #else |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1102 frame = 0; |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1103 #endif |
| 265 | 1104 |
| 1105 /* Pick a window to start with. */ | |
| 1106 if (XTYPE (obj) == Lisp_Window) | |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1107 w = obj; |
| 769 | 1108 else if (frame) |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1109 w = FRAME_SELECTED_WINDOW (frame); |
| 265 | 1110 else |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1111 w = FRAME_SELECTED_WINDOW (selected_frame); |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1112 |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1113 /* Figure out the last window we're going to mess with. Since |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1114 Fnext_window, given the same options, is guaranteed to go in a |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1115 ring, we can just use Fprevious_window to find the last one. |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1116 |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1117 We can't just wait until we hit the first window again, because |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1118 it might be deleted. */ |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1119 |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1120 #ifdef MULTI_FRAME |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1121 if (frame) |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1122 last_window = Fprevious_window (w, (mini ? Qt : Qnil), Qlambda); |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1123 else |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1124 #endif /* MULTI_FRAME */ |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1125 /* We know frame is 0, so we're looping through all frames. |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1126 Or we know this isn't a MULTI_FRAME Emacs, so who cares? */ |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1127 last_window = Fprevious_window (w, mini ? Qt : Qnil, Qt); |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1128 |
| 265 | 1129 best_window = Qnil; |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1130 for (;;) |
| 265 | 1131 { |
|
3785
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1132 FRAME_PTR w_frame = XFRAME (WINDOW_FRAME (XWINDOW (w))); |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1133 |
| 265 | 1134 /* Pick the next window now, since some operations will delete |
| 1135 the current window. */ | |
| 769 | 1136 #ifdef MULTI_FRAME |
| 1137 if (frame) | |
| 432 | 1138 next_window = Fnext_window (w, (mini ? Qt : Qnil), Qlambda); |
| 265 | 1139 else |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1140 #endif /* MULTI_FRAME */ |
| 769 | 1141 /* We know frame is 0, so we're looping through all frames. |
| 1142 Or we know this isn't a MULTI_FRAME Emacs, so who cares? */ | |
| 265 | 1143 next_window = Fnext_window (w, mini ? Qt : Qnil, Qt); |
| 1144 | |
|
3785
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1145 if (! MINI_WINDOW_P (XWINDOW (w)) |
| 265 | 1146 || (mini && minibuf_level > 0)) |
| 1147 switch (type) | |
| 1148 { | |
| 1149 case GET_BUFFER_WINDOW: | |
|
3785
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1150 /* Perhaps ignore invisible and iconified frames. */ |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1151 if (EQ (frames, Qvisible) |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1152 && (! FRAME_VISIBLE_P (w_frame) |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1153 || FRAME_ICONIFIED_P (w_frame))) |
| 265 | 1154 break; |
| 1155 if (XBUFFER (XWINDOW (w)->buffer) == XBUFFER (obj)) | |
| 1156 return w; | |
| 1157 break; | |
| 1158 | |
| 1159 case GET_LRU_WINDOW: | |
| 1160 /* t as arg means consider only full-width windows */ | |
| 732 | 1161 if (!NILP (obj) && XFASTINT (XWINDOW (w)->width) |
|
3164
40590cba332a
(window_loop, case GET_LRU_WINDOW): Get frame's width properly.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1162 != FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (w))))) |
| 265 | 1163 break; |
| 1164 #if 0 | |
| 769 | 1165 /* Ignore invisible and iconified frames. */ |
| 1166 if (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (w)))) | |
| 1167 || FRAME_ICONIFIED_P (XFRAME (WINDOW_FRAME (XWINDOW (w))))) | |
| 265 | 1168 break; |
| 1169 #endif | |
| 1170 /* Ignore dedicated windows and minibuffers. */ | |
| 1171 if (MINI_WINDOW_P (XWINDOW (w)) | |
| 485 | 1172 || !NILP (XWINDOW (w)->dedicated)) |
| 265 | 1173 break; |
| 485 | 1174 if (NILP (best_window) |
| 265 | 1175 || (XFASTINT (XWINDOW (best_window)->use_time) |
| 1176 > XFASTINT (XWINDOW (w)->use_time))) | |
| 1177 best_window = w; | |
| 1178 break; | |
| 1179 | |
| 1180 case DELETE_OTHER_WINDOWS: | |
| 1181 if (XWINDOW (w) != XWINDOW (obj)) | |
| 1182 Fdelete_window (w); | |
| 1183 break; | |
| 1184 | |
| 1185 case DELETE_BUFFER_WINDOWS: | |
| 1186 if (EQ (XWINDOW (w)->buffer, obj)) | |
| 1187 { | |
| 1188 /* If we're deleting the buffer displayed in the only window | |
| 769 | 1189 on the frame, find a new buffer to display there. */ |
| 485 | 1190 if (NILP (XWINDOW (w)->parent)) |
| 265 | 1191 { |
|
1345
9596a1866aee
(window_loop): Pass 2nd arg to Fother_buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1339
diff
changeset
|
1192 Lisp_Object new_buffer = Fother_buffer (obj, Qnil); |
| 485 | 1193 if (NILP (new_buffer)) |
| 265 | 1194 new_buffer |
| 1195 = Fget_buffer_create (build_string ("*scratch*")); | |
| 1196 Fset_window_buffer (w, new_buffer); | |
| 1197 Fset_buffer (XWINDOW (w)->buffer); | |
| 1198 } | |
| 1199 else | |
| 1200 Fdelete_window (w); | |
| 1201 } | |
| 1202 break; | |
| 1203 | |
| 1204 case GET_LARGEST_WINDOW: | |
| 1205 #if 0 | |
| 769 | 1206 /* Ignore invisible and iconified frames. */ |
| 1207 if (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (w)))) | |
| 1208 || FRAME_ICONIFIED_P (XFRAME (WINDOW_FRAME (XWINDOW (w))))) | |
| 265 | 1209 break; |
| 1210 #endif | |
| 1211 /* Ignore dedicated windows and minibuffers. */ | |
| 1212 if (MINI_WINDOW_P (XWINDOW (w)) | |
| 485 | 1213 || !NILP (XWINDOW (w)->dedicated)) |
| 265 | 1214 break; |
| 1215 { | |
| 1216 struct window *best_window_ptr = XWINDOW (best_window); | |
| 1217 struct window *w_ptr = XWINDOW (w); | |
| 485 | 1218 if (NILP (best_window) || |
| 265 | 1219 (XFASTINT (w_ptr->height) * XFASTINT (w_ptr->width)) |
| 1220 > (XFASTINT (best_window_ptr->height) | |
| 1221 * XFASTINT (best_window_ptr->width))) | |
| 1222 best_window = w; | |
| 1223 } | |
| 1224 break; | |
| 1225 | |
| 1226 case UNSHOW_BUFFER: | |
| 1227 if (EQ (XWINDOW (w)->buffer, obj)) | |
| 1228 { | |
| 1229 /* Find another buffer to show in this window. */ | |
|
1345
9596a1866aee
(window_loop): Pass 2nd arg to Fother_buffer.
Richard M. Stallman <rms@gnu.org>
parents:
1339
diff
changeset
|
1230 Lisp_Object another_buffer = Fother_buffer (obj, Qnil); |
| 485 | 1231 if (NILP (another_buffer)) |
| 265 | 1232 another_buffer |
| 1233 = Fget_buffer_create (build_string ("*scratch*")); | |
| 1234 Fset_window_buffer (w, another_buffer); | |
| 1235 if (EQ (w, selected_window)) | |
| 1236 Fset_buffer (XWINDOW (w)->buffer); | |
| 1237 } | |
| 1238 break; | |
| 1239 } | |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1240 |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1241 if (EQ (w, last_window)) |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1242 break; |
|
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1243 |
| 265 | 1244 w = next_window; |
| 1245 } | |
| 1246 | |
| 1247 return best_window; | |
| 1248 } | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
1249 |
| 265 | 1250 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0, |
| 1251 "Return the window least recently selected or used for display.\n\ | |
| 769 | 1252 If optional argument FRAMES is t, search all frames. If FRAME is a\n\ |
| 1253 frame, search only that frame.\n") | |
| 1254 (frames) | |
| 1255 Lisp_Object frames; | |
| 265 | 1256 { |
| 1257 register Lisp_Object w; | |
| 1258 /* First try for a window that is full-width */ | |
| 769 | 1259 w = window_loop (GET_LRU_WINDOW, Qt, 0, frames); |
| 485 | 1260 if (!NILP (w) && !EQ (w, selected_window)) |
| 265 | 1261 return w; |
| 1262 /* If none of them, try the rest */ | |
| 769 | 1263 return window_loop (GET_LRU_WINDOW, Qnil, 0, frames); |
| 265 | 1264 } |
| 1265 | |
| 1266 DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0, | |
| 1267 "Return the largest window in area.\n\ | |
| 769 | 1268 If optional argument FRAMES is t, search all frames. If FRAME is a\n\ |
| 1269 frame, search only that frame.\n") | |
| 1270 (frame) | |
| 1271 Lisp_Object frame; | |
| 265 | 1272 { |
| 1273 return window_loop (GET_LARGEST_WINDOW, Qnil, 0, | |
| 769 | 1274 frame); |
| 265 | 1275 } |
| 1276 | |
| 1277 DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 1, 2, 0, | |
| 1278 "Return a window currently displaying BUFFER, or nil if none.\n\ | |
|
3785
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1279 If optional argument FRAME is t, search all frames.\n\ |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1280 If FRAME is `visible', search all visible frames.\n\ |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
1281 If FRAME is a frame, search only that frame.\n") |
| 769 | 1282 (buffer, frame) |
| 1283 Lisp_Object buffer, frame; | |
| 265 | 1284 { |
| 1285 buffer = Fget_buffer (buffer); | |
| 1286 if (XTYPE (buffer) == Lisp_Buffer) | |
| 769 | 1287 return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame); |
| 265 | 1288 else |
| 1289 return Qnil; | |
| 1290 } | |
| 1291 | |
| 1292 DEFUN ("delete-other-windows", Fdelete_other_windows, Sdelete_other_windows, | |
| 1293 0, 1, "", | |
| 769 | 1294 "Make WINDOW (or the selected window) fill its frame.\n\ |
| 1295 Only the frame WINDOW is on is affected.") | |
| 265 | 1296 (window) |
| 1297 Lisp_Object window; | |
| 1298 { | |
| 1299 struct window *w; | |
| 1300 int opoint = point; | |
| 1301 struct buffer *obuf = current_buffer; | |
| 1302 int top; | |
| 1303 | |
| 485 | 1304 if (NILP (window)) |
| 265 | 1305 window = selected_window; |
| 1306 else | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
1307 CHECK_LIVE_WINDOW (window, 0); |
| 265 | 1308 |
| 1309 w = XWINDOW (window); | |
| 1310 top = XFASTINT (w->top); | |
| 1311 | |
|
2190
482c7827b968
(Fdelete_other_windows): Handle FRAME_MENU_BAR_LINES.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
1312 window_loop (DELETE_OTHER_WINDOWS, window, 0, WINDOW_FRAME (w)); |
| 265 | 1313 |
| 1314 Fset_buffer (w->buffer); | |
| 1315 SET_PT (marker_position (w->start)); | |
|
2190
482c7827b968
(Fdelete_other_windows): Handle FRAME_MENU_BAR_LINES.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
1316 Frecenter (make_number (top - FRAME_MENU_BAR_LINES (XFRAME (WINDOW_FRAME (w))))); |
| 265 | 1317 |
| 1318 set_buffer_internal (obuf); | |
| 1319 SET_PT (opoint); | |
| 1320 return Qnil; | |
| 1321 } | |
| 1322 | |
| 1323 DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on, | |
| 1324 1, 1, "bDelete windows on (buffer): ", | |
| 1325 "Delete all windows showing BUFFER.") | |
| 1326 (buffer) | |
| 1327 Lisp_Object buffer; | |
| 1328 { | |
| 485 | 1329 if (!NILP (buffer)) |
| 265 | 1330 { |
| 1331 buffer = Fget_buffer (buffer); | |
| 1332 CHECK_BUFFER (buffer, 0); | |
| 1333 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, Qt); | |
| 1334 } | |
| 1335 return Qnil; | |
| 1336 } | |
| 1337 | |
| 1338 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, | |
| 1339 Sreplace_buffer_in_windows, | |
| 1340 1, 1, "bReplace buffer in windows: ", | |
| 1341 "Replace BUFFER with some other buffer in all windows showing it.") | |
| 1342 (buffer) | |
| 1343 Lisp_Object buffer; | |
| 1344 { | |
| 485 | 1345 if (!NILP (buffer)) |
| 265 | 1346 { |
| 1347 buffer = Fget_buffer (buffer); | |
| 1348 CHECK_BUFFER (buffer, 0); | |
| 1349 window_loop (UNSHOW_BUFFER, buffer, 0, Qt); | |
| 1350 } | |
| 1351 return Qnil; | |
| 1352 } | |
| 1353 | |
| 1354 /* Set the height of WINDOW and all its inferiors. */ | |
|
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1355 |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1356 /* The smallest acceptable dimensions for a window. Anything smaller |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1357 might crash Emacs. */ |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1358 #define MIN_SAFE_WINDOW_WIDTH (2) |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1359 #define MIN_SAFE_WINDOW_HEIGHT (2) |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1360 |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1361 /* Make sure that window_min_height and window_min_width are |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1362 not too small; if they are, set them to safe minima. */ |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1363 |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1364 static void |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1365 check_min_window_sizes () |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1366 { |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1367 /* Smaller values might permit a crash. */ |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1368 if (window_min_width < MIN_SAFE_WINDOW_WIDTH) |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1369 window_min_width = MIN_SAFE_WINDOW_WIDTH; |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1370 if (window_min_height < MIN_SAFE_WINDOW_HEIGHT) |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1371 window_min_height = MIN_SAFE_WINDOW_HEIGHT; |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1372 } |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1373 |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1374 /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1375 minimum allowable size. */ |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
1376 void |
|
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1377 check_frame_size (frame, rows, cols) |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
1378 FRAME_PTR frame; |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
1379 int *rows, *cols; |
|
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1380 { |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1381 /* For height, we have to see whether the frame has a minibuffer, and |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1382 whether it wants a mode line. */ |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1383 int min_height = |
|
3765
bde2da377085
* window.c (check_frame_size): Allow minibuffer-only frames to be
Jim Blandy <jimb@redhat.com>
parents:
3723
diff
changeset
|
1384 (FRAME_MINIBUF_ONLY_P (frame) ? MIN_SAFE_WINDOW_HEIGHT - 1 |
|
bde2da377085
* window.c (check_frame_size): Allow minibuffer-only frames to be
Jim Blandy <jimb@redhat.com>
parents:
3723
diff
changeset
|
1385 : (! FRAME_HAS_MINIBUF_P (frame)) ? MIN_SAFE_WINDOW_HEIGHT |
|
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1386 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1387 |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1388 if (*rows < min_height) |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1389 *rows = min_height; |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1390 if (*cols < MIN_SAFE_WINDOW_WIDTH) |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1391 *cols = MIN_SAFE_WINDOW_WIDTH; |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1392 } |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1393 |
| 265 | 1394 /* Normally the window is deleted if it gets too small. |
| 1395 nodelete nonzero means do not do this. | |
| 1396 (The caller should check later and do so if appropriate) */ | |
| 1397 | |
| 1398 set_window_height (window, height, nodelete) | |
| 1399 Lisp_Object window; | |
| 1400 int height; | |
| 1401 int nodelete; | |
| 1402 { | |
| 1403 register struct window *w = XWINDOW (window); | |
| 1404 register struct window *c; | |
| 1405 int oheight = XFASTINT (w->height); | |
| 1406 int top, pos, lastbot, opos, lastobot; | |
| 1407 Lisp_Object child; | |
| 1408 | |
|
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1409 check_min_window_sizes (); |
|
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1410 |
| 265 | 1411 if (!nodelete |
| 485 | 1412 && ! NILP (w->parent) |
| 265 | 1413 && height < window_min_height) |
| 1414 { | |
| 1415 Fdelete_window (window); | |
| 1416 return; | |
| 1417 } | |
| 1418 | |
| 1419 XFASTINT (w->last_modified) = 0; | |
| 1420 windows_or_buffers_changed++; | |
| 1421 XFASTINT (w->height) = height; | |
| 485 | 1422 if (!NILP (w->hchild)) |
| 265 | 1423 { |
| 485 | 1424 for (child = w->hchild; !NILP (child); child = XWINDOW (child)->next) |
| 265 | 1425 { |
| 1426 XWINDOW (child)->top = w->top; | |
| 1427 set_window_height (child, height, nodelete); | |
| 1428 } | |
| 1429 } | |
| 485 | 1430 else if (!NILP (w->vchild)) |
| 265 | 1431 { |
| 1432 lastbot = top = XFASTINT (w->top); | |
| 1433 lastobot = 0; | |
| 485 | 1434 for (child = w->vchild; !NILP (child); child = c->next) |
| 265 | 1435 { |
| 1436 c = XWINDOW (child); | |
| 1437 | |
| 1438 opos = lastobot + XFASTINT (c->height); | |
| 1439 | |
| 1440 XFASTINT (c->top) = lastbot; | |
| 1441 | |
| 1442 pos = (((opos * height) << 1) + oheight) / (oheight << 1); | |
| 1443 | |
| 1444 /* Avoid confusion: inhibit deletion of child if becomes too small */ | |
| 1445 set_window_height (child, pos + top - lastbot, 1); | |
| 1446 | |
| 1447 /* Now advance child to next window, | |
| 1448 and set lastbot if child was not just deleted. */ | |
| 1449 lastbot = pos + top; | |
| 1450 lastobot = opos; | |
| 1451 } | |
| 1452 /* Now delete any children that became too small. */ | |
| 1453 if (!nodelete) | |
| 485 | 1454 for (child = w->vchild; !NILP (child); child = XWINDOW (child)->next) |
| 265 | 1455 { |
| 1456 set_window_height (child, XINT (XWINDOW (child)->height), 0); | |
| 1457 } | |
| 1458 } | |
| 1459 } | |
| 1460 | |
| 1461 /* Recursively set width of WINDOW and its inferiors. */ | |
| 1462 | |
| 1463 set_window_width (window, width, nodelete) | |
| 1464 Lisp_Object window; | |
| 1465 int width; | |
| 1466 int nodelete; | |
| 1467 { | |
| 1468 register struct window *w = XWINDOW (window); | |
| 1469 register struct window *c; | |
| 1470 int owidth = XFASTINT (w->width); | |
| 1471 int left, pos, lastright, opos, lastoright; | |
| 1472 Lisp_Object child; | |
| 1473 | |
| 1474 if (!nodelete && width < window_min_width) | |
| 1475 { | |
| 1476 Fdelete_window (window); | |
| 1477 return; | |
| 1478 } | |
| 1479 | |
| 1480 XFASTINT (w->last_modified) = 0; | |
| 1481 windows_or_buffers_changed++; | |
| 1482 XFASTINT (w->width) = width; | |
| 485 | 1483 if (!NILP (w->vchild)) |
| 265 | 1484 { |
| 485 | 1485 for (child = w->vchild; !NILP (child); child = XWINDOW (child)->next) |
| 265 | 1486 { |
| 1487 XWINDOW (child)->left = w->left; | |
| 1488 set_window_width (child, width, nodelete); | |
| 1489 } | |
| 1490 } | |
| 485 | 1491 else if (!NILP (w->hchild)) |
| 265 | 1492 { |
| 1493 lastright = left = XFASTINT (w->left); | |
| 1494 lastoright = 0; | |
| 485 | 1495 for (child = w->hchild; !NILP (child); child = c->next) |
| 265 | 1496 { |
| 1497 c = XWINDOW (child); | |
| 1498 | |
| 1499 opos = lastoright + XFASTINT (c->width); | |
| 1500 | |
| 1501 XFASTINT (c->left) = lastright; | |
| 1502 | |
| 1503 pos = (((opos * width) << 1) + owidth) / (owidth << 1); | |
| 1504 | |
| 1505 /* Inhibit deletion for becoming too small */ | |
| 1506 set_window_width (child, pos + left - lastright, 1); | |
| 1507 | |
| 1508 /* Now advance child to next window, | |
| 1509 and set lastright if child was not just deleted. */ | |
| 1510 lastright = pos + left, lastoright = opos; | |
| 1511 } | |
| 1512 /* Delete children that became too small */ | |
| 1513 if (!nodelete) | |
| 485 | 1514 for (child = w->hchild; !NILP (child); child = XWINDOW (child)->next) |
| 265 | 1515 { |
| 1516 set_window_width (child, XINT (XWINDOW (child)->width), 0); | |
| 1517 } | |
| 1518 } | |
| 1519 } | |
| 1520 | |
| 362 | 1521 int window_select_count; |
| 265 | 1522 |
| 1523 DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 2, 0, | |
| 1524 "Make WINDOW display BUFFER as its contents.\n\ | |
| 1525 BUFFER can be a buffer or buffer name.") | |
| 1526 (window, buffer) | |
| 1527 register Lisp_Object window, buffer; | |
| 1528 { | |
| 1529 register Lisp_Object tem; | |
| 1530 register struct window *w = decode_window (window); | |
| 1531 | |
| 1532 buffer = Fget_buffer (buffer); | |
| 1533 CHECK_BUFFER (buffer, 1); | |
| 1534 | |
| 485 | 1535 if (NILP (XBUFFER (buffer)->name)) |
| 265 | 1536 error ("Attempt to display deleted buffer"); |
| 1537 | |
| 1538 tem = w->buffer; | |
| 485 | 1539 if (NILP (tem)) |
| 265 | 1540 error ("Window is deleted"); |
| 1541 else if (! EQ (tem, Qt)) /* w->buffer is t when the window | |
| 1542 is first being set up. */ | |
| 1543 { | |
| 485 | 1544 if (!NILP (w->dedicated) && !EQ (tem, buffer)) |
| 265 | 1545 error ("Window is dedicated to %s\n", tem); |
| 1546 | |
| 1547 unshow_buffer (w); | |
| 1548 } | |
| 1549 | |
| 1550 w->buffer = buffer; | |
|
2579
5d55e3b47227
(Fset-window-buffer): Set horizontal-scrolling on a window to zero when
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2297
diff
changeset
|
1551 w->hscroll = 0; |
| 265 | 1552 Fset_marker (w->pointm, |
| 1553 make_number (BUF_PT (XBUFFER (buffer))), | |
| 1554 buffer); | |
| 1555 set_marker_restricted (w->start, | |
| 1556 make_number (XBUFFER (buffer)->last_window_start), | |
| 1557 buffer); | |
| 1558 w->start_at_line_beg = Qnil; | |
|
3354
0b71a5329961
(Fset_window_buffer): Set window's force_start to Qnil.
Richard M. Stallman <rms@gnu.org>
parents:
3164
diff
changeset
|
1559 w->force_start = Qnil; |
| 265 | 1560 XFASTINT (w->last_modified) = 0; |
| 1561 windows_or_buffers_changed++; | |
| 1562 if (EQ (window, selected_window)) | |
| 1563 Fset_buffer (buffer); | |
| 1564 | |
| 1565 return Qnil; | |
| 1566 } | |
| 1567 | |
| 1568 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 1, 0, | |
| 1569 "Select WINDOW. Most editing will apply to WINDOW's buffer.\n\ | |
| 1570 The main editor command loop selects the buffer of the selected window\n\ | |
| 1571 before each command.") | |
| 1572 (window) | |
| 1573 register Lisp_Object window; | |
| 1574 { | |
| 1575 register struct window *w; | |
| 1576 register struct window *ow = XWINDOW (selected_window); | |
| 1577 | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
1578 CHECK_LIVE_WINDOW (window, 0); |
| 265 | 1579 |
| 1580 w = XWINDOW (window); | |
| 1581 | |
| 485 | 1582 if (NILP (w->buffer)) |
| 265 | 1583 error ("Trying to select deleted window or non-leaf window"); |
| 1584 | |
| 1585 XFASTINT (w->use_time) = ++window_select_count; | |
| 1586 if (EQ (window, selected_window)) | |
| 1587 return window; | |
| 1588 | |
| 1589 Fset_marker (ow->pointm, make_number (BUF_PT (XBUFFER (ow->buffer))), | |
| 1590 ow->buffer); | |
| 1591 | |
| 1592 selected_window = window; | |
| 769 | 1593 #ifdef MULTI_FRAME |
| 1594 if (XFRAME (WINDOW_FRAME (w)) != selected_frame) | |
| 265 | 1595 { |
| 769 | 1596 XFRAME (WINDOW_FRAME (w))->selected_window = window; |
|
2297
bb88d48c290f
(Fselect_window): Use Fhandle_switch_frame.
Richard M. Stallman <rms@gnu.org>
parents:
2210
diff
changeset
|
1597 Fhandle_switch_frame (WINDOW_FRAME (w), Qnil); |
| 265 | 1598 } |
| 1599 else | |
| 769 | 1600 selected_frame->selected_window = window; |
| 265 | 1601 #endif |
| 1602 | |
| 1603 record_buffer (w->buffer); | |
| 1604 Fset_buffer (w->buffer); | |
| 1605 | |
| 1606 /* Go to the point recorded in the window. | |
| 1607 This is important when the buffer is in more | |
| 1608 than one window. It also matters when | |
| 1609 redisplay_window has altered point after scrolling, | |
| 1610 because it makes the change only in the window. */ | |
| 1611 { | |
| 1612 register int new_point = marker_position (w->pointm); | |
| 1613 if (new_point < BEGV) | |
| 1614 SET_PT (BEGV); | |
| 1615 if (new_point > ZV) | |
| 1616 SET_PT (ZV); | |
| 1617 else | |
| 1618 SET_PT (new_point); | |
| 1619 } | |
| 1620 | |
| 1621 windows_or_buffers_changed++; | |
| 1622 return window; | |
| 1623 } | |
| 1624 | |
| 735 | 1625 DEFUN ("display-buffer", Fdisplay_buffer, Sdisplay_buffer, 1, 2, |
|
2668
33761a44c172
(Fdisplay_buffer): Add space to prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2579
diff
changeset
|
1626 "BDisplay buffer: \nP", |
| 265 | 1627 "Make BUFFER appear in some window but don't select it.\n\ |
| 1628 BUFFER can be a buffer or a buffer name.\n\ | |
| 1629 If BUFFER is shown already in some window, just use that one,\n\ | |
| 1630 unless the window is the selected window and the optional second\n\ | |
|
1805
7ba5cfe280eb
(Fdisplay_buffer): Doc fix.
Roland McGrath <roland@gnu.org>
parents:
1798
diff
changeset
|
1631 argument NOT-THIS-WINDOW is non-nil (interactively, with prefix arg).\n\ |
| 265 | 1632 Returns the window displaying BUFFER.") |
| 1633 (buffer, not_this_window) | |
| 1634 register Lisp_Object buffer, not_this_window; | |
| 1635 { | |
| 1636 register Lisp_Object window; | |
| 1637 | |
| 1638 buffer = Fget_buffer (buffer); | |
| 1639 CHECK_BUFFER (buffer, 0); | |
| 1640 | |
| 485 | 1641 if (!NILP (Vdisplay_buffer_function)) |
| 265 | 1642 return call2 (Vdisplay_buffer_function, buffer, not_this_window); |
| 1643 | |
| 485 | 1644 if (NILP (not_this_window) |
| 265 | 1645 && XBUFFER (XWINDOW (selected_window)->buffer) == XBUFFER (buffer)) |
| 1646 return selected_window; | |
| 1647 | |
| 1648 window = Fget_buffer_window (buffer, Qnil); | |
| 485 | 1649 if (!NILP (window) |
| 1650 && (NILP (not_this_window) || !EQ (window, selected_window))) | |
| 265 | 1651 return window; |
| 1652 | |
| 769 | 1653 #ifdef MULTI_FRAME |
| 1654 /* If there are no frames open that have more than a minibuffer, | |
| 1655 we need to create a new frame. */ | |
| 1656 if (pop_up_frames || last_nonminibuf_frame == 0) | |
| 265 | 1657 { |
| 1658 window | |
| 769 | 1659 = Fframe_selected_window (call0 (Vpop_up_frame_function)); |
| 265 | 1660 Fset_window_buffer (window, buffer); |
| 1661 #if 0 | |
|
2297
bb88d48c290f
(Fselect_window): Use Fhandle_switch_frame.
Richard M. Stallman <rms@gnu.org>
parents:
2210
diff
changeset
|
1662 Fhandle_switch_frame (XWINDOW (window)->frame, Qnil); |
| 265 | 1663 #endif |
| 1664 return window; | |
| 1665 } | |
| 769 | 1666 #endif /* MULTI_FRAME */ |
| 265 | 1667 |
| 358 | 1668 if (pop_up_windows |
| 769 | 1669 #ifdef MULTI_FRAME |
| 1670 || FRAME_MINIBUF_ONLY_P (selected_frame) | |
| 358 | 1671 #endif |
| 1672 ) | |
| 1673 { | |
| 769 | 1674 Lisp_Object frames = Qnil; |
| 358 | 1675 |
| 769 | 1676 #ifdef MULTI_FRAME |
| 1677 if (FRAME_MINIBUF_ONLY_P (selected_frame)) | |
| 1678 XSET (frames, Lisp_Frame, last_nonminibuf_frame); | |
| 265 | 1679 #endif |
| 1680 /* Don't try to create a window if would get an error */ | |
| 1681 if (split_height_threshold < window_min_height << 1) | |
| 1682 split_height_threshold = window_min_height << 1; | |
| 1683 | |
| 769 | 1684 window = Fget_largest_window (frames); |
| 265 | 1685 |
| 485 | 1686 if (!NILP (window) |
| 265 | 1687 && window_height (window) >= split_height_threshold |
|
1783
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
1688 && (XFASTINT (XWINDOW (window)->width) |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
1689 == FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (window)))))) |
| 265 | 1690 window = Fsplit_window (window, Qnil, Qnil); |
| 1691 else | |
| 1692 { | |
| 769 | 1693 window = Fget_lru_window (frames); |
| 265 | 1694 if ((EQ (window, selected_window) |
| 1695 || EQ (XWINDOW (window)->parent, Qnil)) | |
| 1696 && window_height (window) >= window_min_height << 1) | |
| 1697 window = Fsplit_window (window, Qnil, Qnil); | |
| 1698 } | |
| 1699 } | |
| 1700 else | |
| 1701 window = Fget_lru_window (Qnil); | |
| 1702 | |
| 1703 Fset_window_buffer (window, buffer); | |
| 1704 return window; | |
| 1705 } | |
| 1706 | |
| 1707 void | |
| 1708 temp_output_buffer_show (buf) | |
| 1709 register Lisp_Object buf; | |
| 1710 { | |
| 1711 register struct buffer *old = current_buffer; | |
| 1712 register Lisp_Object window; | |
| 1713 register struct window *w; | |
| 1714 | |
| 1715 Fset_buffer (buf); | |
| 1716 XBUFFER (buf)->save_modified = MODIFF; | |
| 1717 BEGV = BEG; | |
| 1718 ZV = Z; | |
| 1719 SET_PT (BEG); | |
| 1720 clip_changed = 1; | |
| 1721 set_buffer_internal (old); | |
| 1722 | |
| 1723 if (!EQ (Vtemp_buffer_show_function, Qnil)) | |
| 1724 call1 (Vtemp_buffer_show_function, buf); | |
| 1725 else | |
| 1726 { | |
| 1727 window = Fdisplay_buffer (buf, Qnil); | |
| 1728 | |
| 769 | 1729 #ifdef MULTI_FRAME |
| 1730 if (XFRAME (XWINDOW (window)->frame) != selected_frame) | |
| 1731 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); | |
| 1732 #endif /* MULTI_FRAME */ | |
| 265 | 1733 Vminibuf_scroll_window = window; |
| 1734 w = XWINDOW (window); | |
| 1735 XFASTINT (w->hscroll) = 0; | |
| 1736 set_marker_restricted (w->start, make_number (1), buf); | |
| 1737 set_marker_restricted (w->pointm, make_number (1), buf); | |
| 1738 } | |
| 1739 } | |
| 1740 | |
| 1741 static | |
| 1742 make_dummy_parent (window) | |
| 1743 Lisp_Object window; | |
| 1744 { | |
| 1745 register Lisp_Object old, new; | |
| 1746 register struct window *o, *p; | |
| 1747 | |
| 1748 old = window; | |
| 1749 XSETTYPE (old, Lisp_Vector); | |
| 1750 new = Fcopy_sequence (old); | |
| 1751 XSETTYPE (new, Lisp_Window); | |
| 1752 | |
| 1753 o = XWINDOW (old); | |
| 1754 p = XWINDOW (new); | |
| 1755 XFASTINT (p->sequence_number) = ++sequence_number; | |
| 1756 | |
| 1757 /* Put new into window structure in place of window */ | |
| 1758 replace_window (window, new); | |
| 1759 | |
| 1760 o->next = Qnil; | |
| 1761 o->prev = Qnil; | |
| 1762 o->vchild = Qnil; | |
| 1763 o->hchild = Qnil; | |
| 1764 o->parent = new; | |
| 1765 | |
| 1766 p->start = Qnil; | |
| 1767 p->pointm = Qnil; | |
| 1768 p->buffer = Qnil; | |
| 1769 } | |
| 1770 | |
| 1771 DEFUN ("split-window", Fsplit_window, Ssplit_window, 0, 3, "", | |
| 1772 "Split WINDOW, putting SIZE lines in the first of the pair.\n\ | |
| 1773 WINDOW defaults to selected one and SIZE to half its size.\n\ | |
| 1774 If optional third arg HOR-FLAG is non-nil, split side by side\n\ | |
| 1775 and put SIZE columns in the first of the pair.") | |
| 1776 (window, chsize, horflag) | |
| 1777 Lisp_Object window, chsize, horflag; | |
| 1778 { | |
| 1779 register Lisp_Object new; | |
| 1780 register struct window *o, *p; | |
| 1781 register int size; | |
| 1782 | |
| 485 | 1783 if (NILP (window)) |
| 265 | 1784 window = selected_window; |
| 1785 else | |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
1786 CHECK_LIVE_WINDOW (window, 0); |
| 265 | 1787 |
| 1788 o = XWINDOW (window); | |
| 1789 | |
| 485 | 1790 if (NILP (chsize)) |
| 265 | 1791 { |
| 485 | 1792 if (!NILP (horflag)) |
| 265 | 1793 /* Round odd size up, since this is for the left-hand window, |
| 1794 and it will lose a column for the separators. */ | |
| 1795 size = ((XFASTINT (o->width) + 1) & -2) >> 1; | |
| 1796 else | |
| 1797 size = XFASTINT (o->height) >> 1; | |
| 1798 } | |
| 1799 else | |
| 1800 { | |
| 1801 CHECK_NUMBER (chsize, 1); | |
| 1802 size = XINT (chsize); | |
| 1803 } | |
| 1804 | |
| 1805 if (MINI_WINDOW_P (o)) | |
| 1806 error ("Attempt to split minibuffer window"); | |
| 769 | 1807 else if (FRAME_NO_SPLIT_P (XFRAME (WINDOW_FRAME (o)))) |
| 1808 error ("Attempt to split unsplittable frame"); | |
| 265 | 1809 |
|
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1810 check_min_window_sizes (); |
| 265 | 1811 |
| 485 | 1812 if (NILP (horflag)) |
| 265 | 1813 { |
| 1814 if (size < window_min_height | |
| 1815 || size + window_min_height > XFASTINT (o->height)) | |
| 1816 args_out_of_range_3 (window, chsize, horflag); | |
| 485 | 1817 if (NILP (o->parent) |
| 1818 || NILP (XWINDOW (o->parent)->vchild)) | |
| 265 | 1819 { |
| 1820 make_dummy_parent (window); | |
| 1821 new = o->parent; | |
| 1822 XWINDOW (new)->vchild = window; | |
| 1823 } | |
| 1824 } | |
| 1825 else | |
| 1826 { | |
| 1827 if (size < window_min_width | |
| 1828 || size + window_min_width > XFASTINT (o->width)) | |
| 1829 args_out_of_range_3 (window, chsize, horflag); | |
| 485 | 1830 if (NILP (o->parent) |
| 1831 || NILP (XWINDOW (o->parent)->hchild)) | |
| 265 | 1832 { |
| 1833 make_dummy_parent (window); | |
| 1834 new = o->parent; | |
| 1835 XWINDOW (new)->hchild = window; | |
| 1836 } | |
| 1837 } | |
| 1838 | |
| 1839 /* Now we know that window's parent is a vertical combination | |
| 1840 if we are dividing vertically, or a horizontal combination | |
| 1841 if we are making side-by-side windows */ | |
| 1842 | |
| 1843 windows_or_buffers_changed++; | |
| 1844 new = make_window (); | |
| 1845 p = XWINDOW (new); | |
| 1846 | |
| 769 | 1847 p->frame = o->frame; |
| 265 | 1848 p->next = o->next; |
| 485 | 1849 if (!NILP (p->next)) |
| 265 | 1850 XWINDOW (p->next)->prev = new; |
| 1851 p->prev = window; | |
| 1852 o->next = new; | |
| 1853 p->parent = o->parent; | |
| 1854 p->buffer = Qt; | |
| 1855 | |
| 1856 Fset_window_buffer (new, o->buffer); | |
| 1857 | |
| 769 | 1858 /* Apportion the available frame space among the two new windows */ |
| 265 | 1859 |
| 485 | 1860 if (!NILP (horflag)) |
| 265 | 1861 { |
| 1862 p->height = o->height; | |
| 1863 p->top = o->top; | |
| 1864 XFASTINT (p->width) = XFASTINT (o->width) - size; | |
| 1865 XFASTINT (o->width) = size; | |
| 1866 XFASTINT (p->left) = XFASTINT (o->left) + size; | |
| 1867 } | |
| 1868 else | |
| 1869 { | |
| 1870 p->left = o->left; | |
| 1871 p->width = o->width; | |
| 1872 XFASTINT (p->height) = XFASTINT (o->height) - size; | |
| 1873 XFASTINT (o->height) = size; | |
| 1874 XFASTINT (p->top) = XFASTINT (o->top) + size; | |
| 1875 } | |
| 1876 | |
| 1877 return new; | |
| 1878 } | |
| 1879 | |
| 1880 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 2, "p", | |
| 1881 "Make current window ARG lines bigger.\n\ | |
| 1882 From program, optional second arg non-nil means grow sideways ARG columns.") | |
| 1883 (n, side) | |
| 1884 register Lisp_Object n, side; | |
| 1885 { | |
| 1886 CHECK_NUMBER (n, 0); | |
| 485 | 1887 change_window_height (XINT (n), !NILP (side)); |
| 265 | 1888 return Qnil; |
| 1889 } | |
| 1890 | |
| 1891 DEFUN ("shrink-window", Fshrink_window, Sshrink_window, 1, 2, "p", | |
| 1892 "Make current window ARG lines smaller.\n\ | |
| 1893 From program, optional second arg non-nil means shrink sideways ARG columns.") | |
| 1894 (n, side) | |
| 1895 register Lisp_Object n, side; | |
| 1896 { | |
| 1897 CHECK_NUMBER (n, 0); | |
| 485 | 1898 change_window_height (-XINT (n), !NILP (side)); |
| 265 | 1899 return Qnil; |
| 1900 } | |
| 1901 | |
| 1902 int | |
| 1903 window_height (window) | |
| 1904 Lisp_Object window; | |
| 1905 { | |
| 1906 register struct window *p = XWINDOW (window); | |
| 1907 return XFASTINT (p->height); | |
| 1908 } | |
| 1909 | |
| 1910 int | |
| 1911 window_width (window) | |
| 1912 Lisp_Object window; | |
| 1913 { | |
| 1914 register struct window *p = XWINDOW (window); | |
| 1915 return XFASTINT (p->width); | |
| 1916 } | |
| 1917 | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1918 #define MINSIZE(w) \ |
|
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1919 (widthflag \ |
|
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1920 ? window_min_width \ |
|
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1921 : (MINI_WINDOW_P (XWINDOW (w)) ? 1 : window_min_height)) |
| 265 | 1922 |
| 1923 #define CURBEG(w) \ | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1924 *(widthflag ? (int *) &(XWINDOW (w)->left) : (int *) &(XWINDOW (w)->top)) |
| 265 | 1925 |
| 1926 #define CURSIZE(w) \ | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1927 *(widthflag ? (int *) &(XWINDOW (w)->width) : (int *) &(XWINDOW (w)->height)) |
| 265 | 1928 |
| 1929 /* Unlike set_window_height, this function | |
| 1930 also changes the heights of the siblings so as to | |
| 1931 keep everything consistent. */ | |
| 1932 | |
| 1933 change_window_height (delta, widthflag) | |
| 1934 register int delta; | |
| 1935 int widthflag; | |
| 1936 { | |
| 1937 register Lisp_Object parent; | |
| 1938 Lisp_Object window; | |
| 1939 register struct window *p; | |
| 1940 int *sizep; | |
| 1941 int (*sizefun) () = widthflag ? window_width : window_height; | |
| 1942 register int (*setsizefun) () = (widthflag | |
| 1943 ? set_window_width | |
| 1944 : set_window_height); | |
| 1945 | |
|
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1946 check_min_window_sizes (); |
| 265 | 1947 |
| 1948 window = selected_window; | |
| 1949 while (1) | |
| 1950 { | |
| 1951 p = XWINDOW (window); | |
| 1952 parent = p->parent; | |
| 485 | 1953 if (NILP (parent)) |
| 265 | 1954 { |
| 1955 if (widthflag) | |
| 1956 error ("No other window to side of this one"); | |
| 1957 break; | |
| 1958 } | |
| 485 | 1959 if (widthflag ? !NILP (XWINDOW (parent)->hchild) |
| 1960 : !NILP (XWINDOW (parent)->vchild)) | |
| 265 | 1961 break; |
| 1962 window = parent; | |
| 1963 } | |
| 1964 | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1965 sizep = &CURSIZE (window); |
|
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1966 |
|
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1967 if (*sizep + delta < MINSIZE (window)) |
| 265 | 1968 { |
| 1969 Fdelete_window (window); | |
| 1970 return; | |
| 1971 } | |
| 1972 | |
| 1973 { | |
| 1974 register int maxdelta; | |
| 1975 | |
| 485 | 1976 maxdelta = (!NILP (parent) ? (*sizefun) (parent) - *sizep |
| 1977 : !NILP (p->next) ? (*sizefun) (p->next) - MINSIZE (p->next) | |
| 1978 : !NILP (p->prev) ? (*sizefun) (p->prev) - MINSIZE (p->prev) | |
| 769 | 1979 /* This is a frame with only one window, a minibuffer-only |
| 1980 or a minibufferless frame. */ | |
| 432 | 1981 : (delta = 0)); |
| 265 | 1982 |
| 1983 if (delta > maxdelta) | |
| 1984 /* This case traps trying to make the minibuffer | |
| 769 | 1985 the full frame, or make the only window aside from the |
| 1986 minibuffer the full frame. */ | |
| 265 | 1987 delta = maxdelta; |
| 432 | 1988 |
| 1989 if (delta == 0) | |
| 1990 return; | |
| 265 | 1991 } |
| 1992 | |
| 485 | 1993 if (!NILP (p->next) && |
| 265 | 1994 (*sizefun) (p->next) - delta >= MINSIZE (p->next)) |
| 1995 { | |
| 1996 (*setsizefun) (p->next, (*sizefun) (p->next) - delta, 0); | |
| 1997 (*setsizefun) (window, *sizep + delta, 0); | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1998 CURBEG (p->next) += delta; |
| 265 | 1999 /* This does not change size of p->next, |
| 2000 but it propagates the new top edge to its children */ | |
| 2001 (*setsizefun) (p->next, (*sizefun) (p->next), 0); | |
| 2002 } | |
| 485 | 2003 else if (!NILP (p->prev) && |
| 265 | 2004 (*sizefun) (p->prev) - delta >= MINSIZE (p->prev)) |
| 2005 { | |
| 2006 (*setsizefun) (p->prev, (*sizefun) (p->prev) - delta, 0); | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
2007 CURBEG (window) -= delta; |
| 265 | 2008 (*setsizefun) (window, *sizep + delta, 0); |
| 2009 } | |
| 2010 else | |
| 2011 { | |
| 2012 register int delta1; | |
| 2013 register int opht = (*sizefun) (parent); | |
| 2014 | |
| 2015 /* If trying to grow this window to or beyond size of the parent, | |
| 2016 make delta1 so big that, on shrinking back down, | |
| 2017 all the siblings end up with less than one line and are deleted. */ | |
| 2018 if (opht <= *sizep + delta) | |
| 2019 delta1 = opht * opht * 2; | |
| 2020 /* Otherwise, make delta1 just right so that if we add delta1 | |
| 2021 lines to this window and to the parent, and then shrink | |
| 2022 the parent back to its original size, the new proportional | |
| 2023 size of this window will increase by delta. */ | |
| 2024 else | |
| 2025 delta1 = (delta * opht * 100) / ((opht - *sizep - delta) * 100); | |
| 2026 | |
| 2027 /* Add delta1 lines or columns to this window, and to the parent, | |
| 2028 keeping things consistent while not affecting siblings. */ | |
|
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
2029 CURSIZE (parent) = opht + delta1; |
| 265 | 2030 (*setsizefun) (window, *sizep + delta1, 0); |
| 2031 | |
| 2032 /* Squeeze out delta1 lines or columns from our parent, | |
| 2033 shriking this window and siblings proportionately. | |
| 2034 This brings parent back to correct size. | |
| 2035 Delta1 was calculated so this makes this window the desired size, | |
| 2036 taking it all out of the siblings. */ | |
| 2037 (*setsizefun) (parent, opht, 0); | |
| 2038 } | |
| 2039 | |
| 2040 XFASTINT (p->last_modified) = 0; | |
| 2041 } | |
| 2042 #undef MINSIZE | |
| 2043 #undef CURBEG | |
| 2044 #undef CURSIZE | |
| 2045 | |
| 2046 | |
| 2047 /* Return number of lines of text (not counting mode line) in W. */ | |
| 2048 | |
| 2049 int | |
| 2050 window_internal_height (w) | |
| 2051 struct window *w; | |
| 2052 { | |
| 2053 int ht = XFASTINT (w->height); | |
| 2054 | |
| 2055 if (MINI_WINDOW_P (w)) | |
| 2056 return ht; | |
| 2057 | |
| 485 | 2058 if (!NILP (w->parent) || !NILP (w->vchild) || !NILP (w->hchild) |
| 2059 || !NILP (w->next) || !NILP (w->prev) | |
| 769 | 2060 || FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME (w)))) |
| 265 | 2061 return ht - 1; |
| 2062 | |
| 2063 return ht; | |
| 2064 } | |
| 2065 | |
|
1783
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2066 |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2067 /* Return the number of columns in W. |
|
1994
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1931
diff
changeset
|
2068 Don't count columns occupied by scroll bars or the vertical bar |
|
1783
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2069 separating W from the sibling to its right. */ |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2070 int |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2071 window_internal_width (w) |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2072 struct window *w; |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2073 { |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2074 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2075 int left = XINT (w->left); |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2076 int width = XINT (w->width); |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2077 |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2078 /* If this window is flush against the right edge of the frame, its |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2079 internal width is its full width. */ |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2080 if (left + width >= FRAME_WIDTH (f)) |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2081 return width; |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2082 |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2083 /* If we are not flush right, then our rightmost columns are |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2084 occupied by some sort of separator. */ |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2085 |
|
1994
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1931
diff
changeset
|
2086 /* Scroll bars occupy a few columns. */ |
|
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1931
diff
changeset
|
2087 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
|
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1931
diff
changeset
|
2088 return width - VERTICAL_SCROLL_BAR_WIDTH; |
|
1783
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2089 |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2090 /* The column of `|' characters separating side-by-side windows |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2091 occupies one column only. */ |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2092 return width - 1; |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2093 } |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2094 |
|
8e7932110418
* window.c (window_internal_width): New function, which accounts
Jim Blandy <jimb@redhat.com>
parents:
1716
diff
changeset
|
2095 |
| 265 | 2096 /* Scroll contents of window WINDOW up N lines. */ |
| 2097 | |
| 2098 void | |
| 522 | 2099 window_scroll (window, n, noerror) |
| 265 | 2100 Lisp_Object window; |
| 2101 int n; | |
| 522 | 2102 int noerror; |
| 265 | 2103 { |
| 2104 register struct window *w = XWINDOW (window); | |
| 2105 register int opoint = point; | |
| 2106 register int pos; | |
| 2107 register int ht = window_internal_height (w); | |
| 2108 register Lisp_Object tem; | |
| 2109 int lose; | |
| 2110 Lisp_Object bolp, nmoved; | |
| 2111 | |
| 2112 XFASTINT (tem) = point; | |
| 2113 tem = Fpos_visible_in_window_p (tem, window); | |
| 2114 | |
| 485 | 2115 if (NILP (tem)) |
| 265 | 2116 { |
| 2117 Fvertical_motion (make_number (- ht / 2)); | |
| 2118 XFASTINT (tem) = point; | |
| 2119 Fset_marker (w->start, tem, w->buffer); | |
| 2120 w->force_start = Qt; | |
| 2121 } | |
| 2122 | |
| 2123 SET_PT (marker_position (w->start)); | |
| 2124 lose = n < 0 && point == BEGV; | |
| 2125 Fvertical_motion (make_number (n)); | |
| 2126 pos = point; | |
| 2127 bolp = Fbolp (); | |
| 2128 SET_PT (opoint); | |
| 2129 | |
| 2130 if (lose) | |
| 522 | 2131 { |
| 2132 if (noerror) | |
| 2133 return; | |
| 2134 else | |
| 2135 Fsignal (Qbeginning_of_buffer, Qnil); | |
| 2136 } | |
| 265 | 2137 |
| 2138 if (pos < ZV) | |
| 2139 { | |
| 2140 set_marker_restricted (w->start, make_number (pos), w->buffer); | |
| 2141 w->start_at_line_beg = bolp; | |
| 2142 w->update_mode_line = Qt; | |
| 2143 XFASTINT (w->last_modified) = 0; | |
| 2144 if (pos > opoint) | |
| 2145 SET_PT (pos); | |
| 2146 if (n < 0) | |
| 2147 { | |
| 2148 SET_PT (pos); | |
| 2149 tem = Fvertical_motion (make_number (ht)); | |
| 2150 if (point > opoint || XFASTINT (tem) < ht) | |
| 2151 SET_PT (opoint); | |
| 2152 else | |
| 2153 Fvertical_motion (make_number (-1)); | |
| 2154 } | |
| 2155 } | |
| 2156 else | |
| 522 | 2157 { |
| 2158 if (noerror) | |
| 2159 return; | |
| 2160 else | |
| 2161 Fsignal (Qend_of_buffer, Qnil); | |
| 2162 } | |
| 265 | 2163 } |
| 2164 | |
| 2165 /* This is the guts of Fscroll_up and Fscroll_down. */ | |
| 2166 | |
| 2167 static void | |
| 2168 scroll_command (n, direction) | |
| 2169 register Lisp_Object n; | |
| 2170 int direction; | |
| 2171 { | |
| 2172 register int defalt; | |
| 2173 int count = specpdl_ptr - specpdl; | |
| 2174 | |
| 548 | 2175 /* If selected window's buffer isn't current, make it current for the moment. |
| 2176 But don't screw up if window_scroll gets an error. */ | |
| 265 | 2177 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) |
| 548 | 2178 { |
| 2179 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
| 2180 Fset_buffer (XWINDOW (selected_window)->buffer); | |
| 2181 } | |
| 265 | 2182 |
| 2183 defalt = (window_internal_height (XWINDOW (selected_window)) | |
| 2184 - next_screen_context_lines); | |
| 2185 defalt = direction * (defalt < 1 ? 1 : defalt); | |
| 2186 | |
| 485 | 2187 if (NILP (n)) |
| 522 | 2188 window_scroll (selected_window, defalt, 0); |
| 265 | 2189 else if (EQ (n, Qminus)) |
| 522 | 2190 window_scroll (selected_window, - defalt, 0); |
| 265 | 2191 else |
| 2192 { | |
| 2193 n = Fprefix_numeric_value (n); | |
| 522 | 2194 window_scroll (selected_window, XINT (n) * direction, 0); |
| 265 | 2195 } |
| 548 | 2196 |
| 2197 unbind_to (count, Qnil); | |
| 265 | 2198 } |
| 2199 | |
| 2200 DEFUN ("scroll-up", Fscroll_up, Sscroll_up, 0, 1, "P", | |
| 2201 "Scroll text of current window upward ARG lines; or near full screen if no ARG.\n\ | |
| 2202 A near full screen is `next-screen-context-lines' less than a full screen.\n\ | |
| 2203 When calling from a program, supply a number as argument or nil.") | |
| 2204 (n) | |
| 2205 Lisp_Object n; | |
| 2206 { | |
| 2207 scroll_command (n, 1); | |
| 2208 return Qnil; | |
| 2209 } | |
| 2210 | |
| 2211 DEFUN ("scroll-down", Fscroll_down, Sscroll_down, 0, 1, "P", | |
| 2212 "Scroll text of current window downward ARG lines; or near full screen if no ARG.\n\ | |
| 2213 A near full screen is `next-screen-context-lines' less than a full screen.\n\ | |
| 2214 When calling from a program, supply a number as argument or nil.") | |
| 2215 (n) | |
| 2216 Lisp_Object n; | |
| 2217 { | |
| 2218 scroll_command (n, -1); | |
| 2219 return Qnil; | |
| 2220 } | |
| 2221 | |
| 2222 DEFUN ("scroll-other-window", Fscroll_other_window, Sscroll_other_window, 0, 1, "P", | |
| 1339 | 2223 "Scroll next window upward ARG lines; or near full screen if no ARG.\n\ |
| 265 | 2224 The next window is the one below the current one; or the one at the top\n\ |
| 2225 if the current one is at the bottom.\n\ | |
| 2226 When calling from a program, supply a number as argument or nil.\n\ | |
| 2227 \n\ | |
| 2228 If in the minibuffer, `minibuf-scroll-window' if non-nil\n\ | |
| 2229 specifies the window to scroll.\n\ | |
| 2230 If `other-window-scroll-buffer' is non-nil, scroll the window\n\ | |
| 2231 showing that buffer, popping the buffer up if necessary.") | |
| 2232 (n) | |
| 2233 register Lisp_Object n; | |
| 2234 { | |
| 2235 register Lisp_Object window; | |
| 2236 register int ht; | |
| 2237 register struct window *w; | |
| 2238 register int count = specpdl_ptr - specpdl; | |
| 2239 | |
| 2240 if (MINI_WINDOW_P (XWINDOW (selected_window)) | |
| 485 | 2241 && !NILP (Vminibuf_scroll_window)) |
| 265 | 2242 window = Vminibuf_scroll_window; |
| 2243 /* If buffer is specified, scroll that buffer. */ | |
| 485 | 2244 else if (!NILP (Vother_window_scroll_buffer)) |
| 265 | 2245 { |
| 2246 window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil); | |
| 485 | 2247 if (NILP (window)) |
| 265 | 2248 window = Fdisplay_buffer (Vother_window_scroll_buffer, Qt); |
| 2249 } | |
| 2250 else | |
|
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2251 { |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2252 /* Nothing specified; look for a neighboring window on the same |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2253 frame. */ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2254 window = Fnext_window (selected_window, Qnil, Qnil); |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2255 |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2256 if (EQ (window, selected_window)) |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2257 /* That didn't get us anywhere; look for a window on another |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2258 visible frame. */ |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2259 do |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2260 window = Fnext_window (window, Qnil, Qt); |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2261 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window)))) |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2262 && ! EQ (window, selected_window)); |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2263 } |
|
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1805
diff
changeset
|
2264 |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2265 CHECK_LIVE_WINDOW (window, 0); |
| 265 | 2266 |
| 2267 if (EQ (window, selected_window)) | |
| 2268 error ("There is no other window"); | |
| 2269 | |
| 2270 w = XWINDOW (window); | |
| 2271 ht = window_internal_height (w); | |
| 2272 | |
| 2273 /* Don't screw up if window_scroll gets an error. */ | |
| 2274 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
| 2275 | |
| 2276 Fset_buffer (w->buffer); | |
| 2277 SET_PT (marker_position (w->pointm)); | |
| 2278 | |
| 485 | 2279 if (NILP (n)) |
| 522 | 2280 window_scroll (window, ht - next_screen_context_lines, 1); |
| 265 | 2281 else if (EQ (n, Qminus)) |
| 522 | 2282 window_scroll (window, next_screen_context_lines - ht, 1); |
| 265 | 2283 else |
| 2284 { | |
| 2285 if (XTYPE (n) == Lisp_Cons) | |
| 2286 n = Fcar (n); | |
| 2287 CHECK_NUMBER (n, 0); | |
| 522 | 2288 window_scroll (window, XINT (n), 1); |
| 265 | 2289 } |
| 2290 | |
| 2291 Fset_marker (w->pointm, make_number (point), Qnil); | |
|
1931
129d8225f748
* keyboard.c (recursive_edit_1, command_loop_1): Pass the proper
Jim Blandy <jimb@redhat.com>
parents:
1829
diff
changeset
|
2292 unbind_to (count, Qnil); |
| 265 | 2293 |
| 2294 return Qnil; | |
| 2295 } | |
| 2296 | |
|
3621
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
2297 DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 0, 1, "P", |
| 265 | 2298 "Scroll selected window display ARG columns left.\n\ |
| 2299 Default for ARG is window width minus 2.") | |
| 2300 (arg) | |
| 2301 register Lisp_Object arg; | |
| 2302 { | |
| 2303 | |
| 485 | 2304 if (NILP (arg)) |
|
1829
514384c3689d
* window.c (Fscroll_left, Fscroll_right): Don't forget to apply
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
2305 XFASTINT (arg) = window_internal_width (XWINDOW (selected_window)) - 2; |
| 265 | 2306 else |
| 2307 arg = Fprefix_numeric_value (arg); | |
| 2308 | |
| 2309 return | |
| 2310 Fset_window_hscroll (selected_window, | |
| 2311 make_number (XINT (XWINDOW (selected_window)->hscroll) | |
| 2312 + XINT (arg))); | |
| 2313 } | |
| 2314 | |
|
3621
0576930165ed
(Fscroll_left): Make argument optional.
Richard M. Stallman <rms@gnu.org>
parents:
3535
diff
changeset
|
2315 DEFUN ("scroll-right", Fscroll_right, Sscroll_right, 0, 1, "P", |
| 265 | 2316 "Scroll selected window display ARG columns right.\n\ |
| 2317 Default for ARG is window width minus 2.") | |
| 2318 (arg) | |
| 2319 register Lisp_Object arg; | |
| 2320 { | |
| 485 | 2321 if (NILP (arg)) |
|
1829
514384c3689d
* window.c (Fscroll_left, Fscroll_right): Don't forget to apply
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
2322 XFASTINT (arg) = window_internal_width (XWINDOW (selected_window)) - 2; |
| 265 | 2323 else |
| 2324 arg = Fprefix_numeric_value (arg); | |
| 2325 | |
| 2326 return | |
| 2327 Fset_window_hscroll (selected_window, | |
| 2328 make_number (XINT (XWINDOW (selected_window)->hscroll) | |
| 2329 - XINT (arg))); | |
| 2330 } | |
| 2331 | |
| 2332 DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", | |
| 769 | 2333 "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\ |
| 265 | 2334 The desired position of point is always relative to the current window.\n\ |
| 769 | 2335 Just C-u as prefix means put point in the center of the window.\n\ |
| 2336 No arg (i.e., it is nil) erases the entire frame and then\n\ | |
| 2337 redraws with point in the center of the current window.") | |
| 265 | 2338 (n) |
| 2339 register Lisp_Object n; | |
| 2340 { | |
| 2341 register struct window *w = XWINDOW (selected_window); | |
| 2342 register int ht = window_internal_height (w); | |
| 2343 register int opoint = point; | |
| 2344 | |
| 485 | 2345 if (NILP (n)) |
| 265 | 2346 { |
| 769 | 2347 extern int frame_garbaged; |
| 265 | 2348 |
| 769 | 2349 SET_FRAME_GARBAGED (XFRAME (WINDOW_FRAME (w))); |
| 265 | 2350 XFASTINT (n) = ht / 2; |
| 2351 } | |
| 2352 else if (XTYPE (n) == Lisp_Cons) /* Just C-u. */ | |
| 2353 { | |
| 2354 XFASTINT (n) = ht / 2; | |
| 2355 } | |
| 2356 else | |
| 2357 { | |
| 2358 n = Fprefix_numeric_value (n); | |
| 2359 CHECK_NUMBER (n, 0); | |
| 2360 } | |
| 2361 | |
| 2362 if (XINT (n) < 0) | |
| 2363 XSETINT (n, XINT (n) + ht); | |
| 2364 | |
| 2365 XSETINT (n, - XINT (n)); | |
| 2366 | |
| 2367 Fvertical_motion (n); | |
| 2368 Fset_marker (w->start, make_number (point), w->buffer); | |
| 2369 w->start_at_line_beg = Fbolp (); | |
| 2370 | |
| 2371 SET_PT (opoint); | |
| 2372 w->force_start = Qt; | |
| 2373 | |
| 2374 return Qnil; | |
| 2375 } | |
| 2376 | |
| 2377 DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line, | |
| 2378 1, 1, "P", | |
| 2379 "Position point relative to window.\n\ | |
| 2380 With no argument, position text at center of window.\n\ | |
| 769 | 2381 An argument specifies frame line; zero means top of window,\n\ |
| 265 | 2382 negative means relative to bottom of window.") |
| 2383 (arg) | |
| 2384 register Lisp_Object arg; | |
| 2385 { | |
| 2386 register struct window *w = XWINDOW (selected_window); | |
| 2387 register int height = window_internal_height (w); | |
| 2388 register int start; | |
| 2389 | |
| 485 | 2390 if (NILP (arg)) |
| 265 | 2391 XFASTINT (arg) = height / 2; |
| 2392 else | |
| 2393 { | |
| 2394 arg = Fprefix_numeric_value (arg); | |
| 2395 if (XINT (arg) < 0) | |
| 2396 XSETINT (arg, XINT (arg) + height); | |
| 2397 } | |
| 2398 | |
| 2399 start = marker_position (w->start); | |
| 2400 if (start < BEGV || start > ZV) | |
| 2401 { | |
| 2402 Fvertical_motion (make_number (- height / 2)); | |
| 2403 Fset_marker (w->start, make_number (point), w->buffer); | |
| 2404 w->start_at_line_beg = Fbolp (); | |
| 2405 w->force_start = Qt; | |
| 2406 } | |
| 2407 else | |
| 2408 SET_PT (start); | |
| 2409 | |
| 2410 return Fvertical_motion (arg); | |
| 2411 } | |
| 2412 | |
| 2413 struct save_window_data | |
| 2414 { | |
| 2415 int size_from_Lisp_Vector_struct; | |
| 2416 struct Lisp_Vector *next_from_Lisp_Vector_struct; | |
| 769 | 2417 Lisp_Object frame_width, frame_height; |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2418 Lisp_Object selected_frame; |
| 265 | 2419 Lisp_Object current_window; |
| 2420 Lisp_Object current_buffer; | |
| 2421 Lisp_Object minibuf_scroll_window; | |
| 2422 Lisp_Object root_window; | |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2423 Lisp_Object focus_frame; |
| 265 | 2424 /* A vector, interpreted as a struct saved_window */ |
| 2425 Lisp_Object saved_windows; | |
| 2426 }; | |
|
1326
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2427 |
|
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2428 /* Arg to Fmake_vector */ |
|
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2429 #define SAVE_WINDOW_DATA_SIZE \ |
|
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2430 ((sizeof (struct save_window_data) \ |
|
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2431 - (sizeof (struct Lisp_Vector) \ |
|
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2432 /* Don't count the contents member of the struct Lisp_Vector */ \ |
|
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2433 - sizeof (Lisp_Object))) \ |
|
709532b86646
* window.c (SAVE_WINDOW_DATA_SIZE): Define this using sizeof,
Jim Blandy <jimb@redhat.com>
parents:
1325
diff
changeset
|
2434 / sizeof (Lisp_Object)) |
| 265 | 2435 |
| 2436 /* This is saved as a Lisp_Vector */ | |
| 2437 struct saved_window | |
| 2438 { | |
| 2439 /* these first two must agree with struct Lisp_Vector in lisp.h */ | |
| 2440 int size_from_Lisp_Vector_struct; | |
| 2441 struct Lisp_Vector *next_from_Lisp_Vector_struct; | |
| 2442 | |
| 2443 Lisp_Object window; | |
| 2444 Lisp_Object buffer, start, pointm, mark; | |
| 2445 Lisp_Object left, top, width, height, hscroll; | |
| 2446 Lisp_Object parent, prev; | |
| 2447 Lisp_Object start_at_line_beg; | |
| 2448 Lisp_Object display_table; | |
| 2449 }; | |
| 2450 #define SAVED_WINDOW_VECTOR_SIZE 14 /* Arg to Fmake_vector */ | |
| 2451 | |
| 2452 #define SAVED_WINDOW_N(swv,n) \ | |
| 2453 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)]))) | |
| 2454 | |
| 2455 DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0, | |
| 2456 "T if OBJECT is a window-configration object.") | |
| 2457 (obj) | |
| 2458 Lisp_Object obj; | |
| 2459 { | |
| 2460 if (XTYPE (obj) == Lisp_Window_Configuration) | |
| 2461 return Qt; | |
| 2462 return Qnil; | |
| 2463 } | |
| 2464 | |
| 2465 | |
|
2297
bb88d48c290f
(Fselect_window): Use Fhandle_switch_frame.
Richard M. Stallman <rms@gnu.org>
parents:
2210
diff
changeset
|
2466 DEFUN ("set-window-configuration", Fset_window_configuration, |
|
bb88d48c290f
(Fselect_window): Use Fhandle_switch_frame.
Richard M. Stallman <rms@gnu.org>
parents:
2210
diff
changeset
|
2467 Sset_window_configuration, 1, 1, 0, |
| 265 | 2468 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\ |
| 2469 CONFIGURATION must be a value previously returned\n\ | |
| 2470 by `current-window-configuration' (which see).") | |
|
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2471 (configuration) |
|
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2472 Lisp_Object configuration; |
| 265 | 2473 { |
| 2474 register struct save_window_data *data; | |
| 2475 struct Lisp_Vector *saved_windows; | |
| 2476 Lisp_Object new_current_buffer; | |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2477 Lisp_Object frame; |
| 769 | 2478 FRAME_PTR f; |
| 265 | 2479 |
|
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2480 while (XTYPE (configuration) != Lisp_Window_Configuration) |
| 265 | 2481 { |
|
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2482 configuration = wrong_type_argument (intern ("window-configuration-p"), |
|
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2483 configuration); |
| 265 | 2484 } |
| 2485 | |
|
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2486 data = (struct save_window_data *) XVECTOR (configuration); |
| 265 | 2487 saved_windows = XVECTOR (data->saved_windows); |
| 2488 | |
| 2489 new_current_buffer = data->current_buffer; | |
| 485 | 2490 if (NILP (XBUFFER (new_current_buffer)->name)) |
| 265 | 2491 new_current_buffer = Qnil; |
| 2492 | |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2493 frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2494 f = XFRAME (frame); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2495 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2496 /* If f is a dead frame, don't bother rebuilding its window tree. |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2497 However, there is other stuff we should still try to do below. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2498 if (FRAME_LIVE_P (f)) |
| 265 | 2499 { |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2500 register struct window *w; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2501 register struct saved_window *p; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2502 int k; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2503 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2504 /* If the frame has been resized since this window configuration was |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2505 made, we change the frame to the size specified in the |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2506 configuration, restore the configuration, and then resize it |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2507 back. We keep track of the prevailing height in these variables. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2508 int previous_frame_height = FRAME_HEIGHT (f); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2509 int previous_frame_width = FRAME_WIDTH (f); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2510 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2511 if (XFASTINT (data->frame_height) != previous_frame_height |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2512 || XFASTINT (data->frame_width) != previous_frame_width) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2513 change_frame_size (f, data->frame_height, data->frame_width, 0, 0); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2514 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2515 windows_or_buffers_changed++; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2516 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2517 /* Kludge Alert! |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2518 Mark all windows now on frame as "deleted". |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2519 Restoring the new configuration "undeletes" any that are in it. |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2520 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2521 Save their current buffers in their height fields, since we may |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2522 need it later, if a buffer saved in the configuration is now |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2523 dead. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2524 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f))); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2525 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2526 for (k = 0; k < saved_windows->size; k++) |
| 265 | 2527 { |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2528 p = SAVED_WINDOW_N (saved_windows, k); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2529 w = XWINDOW (p->window); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2530 w->next = Qnil; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2531 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2532 if (!NILP (p->parent)) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2533 w->parent = SAVED_WINDOW_N (saved_windows, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2534 XFASTINT (p->parent))->window; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2535 else |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2536 w->parent = Qnil; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2537 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2538 if (!NILP (p->prev)) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2539 { |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2540 w->prev = SAVED_WINDOW_N (saved_windows, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2541 XFASTINT (p->prev))->window; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2542 XWINDOW (w->prev)->next = p->window; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2543 } |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2544 else |
| 265 | 2545 { |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2546 w->prev = Qnil; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2547 if (!NILP (w->parent)) |
| 265 | 2548 { |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2549 if (EQ (p->width, XWINDOW (w->parent)->width)) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2550 { |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2551 XWINDOW (w->parent)->vchild = p->window; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2552 XWINDOW (w->parent)->hchild = Qnil; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2553 } |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2554 else |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2555 { |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2556 XWINDOW (w->parent)->hchild = p->window; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2557 XWINDOW (w->parent)->vchild = Qnil; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2558 } |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2559 } |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2560 } |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2561 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2562 /* If we squirreled away the buffer in the window's height, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2563 restore it now. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2564 if (XTYPE (w->height) == Lisp_Buffer) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2565 w->buffer = w->height; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2566 w->left = p->left; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2567 w->top = p->top; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2568 w->width = p->width; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2569 w->height = p->height; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2570 w->hscroll = p->hscroll; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2571 w->display_table = p->display_table; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2572 XFASTINT (w->last_modified) = 0; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2573 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2574 /* Reinstall the saved buffer and pointers into it. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2575 if (NILP (p->buffer)) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2576 w->buffer = p->buffer; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2577 else |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2578 { |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2579 if (!NILP (XBUFFER (p->buffer)->name)) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2580 /* If saved buffer is alive, install it. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2581 { |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2582 w->buffer = p->buffer; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2583 w->start_at_line_beg = p->start_at_line_beg; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2584 set_marker_restricted (w->start, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2585 Fmarker_position (p->start), |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2586 w->buffer); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2587 set_marker_restricted (w->pointm, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2588 Fmarker_position (p->pointm), |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2589 w->buffer); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2590 Fset_marker (XBUFFER (w->buffer)->mark, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2591 Fmarker_position (p->mark), w->buffer); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2592 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2593 /* As documented in Fcurrent_window_configuration, don't |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2594 save the location of point in the buffer which was current |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2595 when the window configuration was recorded. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2596 if (!EQ (p->buffer, new_current_buffer) && |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2597 XBUFFER (p->buffer) == current_buffer) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2598 Fgoto_char (w->pointm); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2599 } |
|
3535
581c09f72dbd
(Fset_window_configuration): If a window is supposed
Richard M. Stallman <rms@gnu.org>
parents:
3354
diff
changeset
|
2600 else if (NILP (w->buffer) || NILP (XBUFFER (w->buffer)->name)) |
|
581c09f72dbd
(Fset_window_configuration): If a window is supposed
Richard M. Stallman <rms@gnu.org>
parents:
3354
diff
changeset
|
2601 /* Else unless window has a live buffer, get one. */ |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2602 { |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2603 w->buffer = Fcdr (Fcar (Vbuffer_alist)); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2604 /* This will set the markers to beginning of visible |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2605 range. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2606 set_marker_restricted (w->start, make_number (0), w->buffer); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2607 set_marker_restricted (w->pointm, make_number (0),w->buffer); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2608 w->start_at_line_beg = Qt; |
| 265 | 2609 } |
| 2610 else | |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2611 /* Keeping window's old buffer; make sure the markers |
|
3535
581c09f72dbd
(Fset_window_configuration): If a window is supposed
Richard M. Stallman <rms@gnu.org>
parents:
3354
diff
changeset
|
2612 are real. */ |
| 265 | 2613 { |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2614 /* Set window markers at start of visible range. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2615 if (XMARKER (w->start)->buffer == 0) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2616 set_marker_restricted (w->start, make_number (0), |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2617 w->buffer); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2618 if (XMARKER (w->pointm)->buffer == 0) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2619 set_marker_restricted (w->pointm, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2620 (make_number |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2621 (BUF_PT (XBUFFER (w->buffer)))), |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2622 w->buffer); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2623 w->start_at_line_beg = Qt; |
| 265 | 2624 } |
| 2625 } | |
| 2626 } | |
|
1237
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2627 |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2628 FRAME_ROOT_WINDOW (f) = data->root_window; |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2629 Fselect_window (data->current_window); |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2630 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2631 #ifdef MULTI_FRAME |
|
1716
95db936d47c0
* keyboard.c (Qscrollbar_movement, Qvertical_scrollbar,
Jim Blandy <jimb@redhat.com>
parents:
1685
diff
changeset
|
2632 if (NILP (data->focus_frame) |
|
95db936d47c0
* keyboard.c (Qscrollbar_movement, Qvertical_scrollbar,
Jim Blandy <jimb@redhat.com>
parents:
1685
diff
changeset
|
2633 || (XTYPE (data->focus_frame) == Lisp_Frame |
|
95db936d47c0
* keyboard.c (Qscrollbar_movement, Qvertical_scrollbar,
Jim Blandy <jimb@redhat.com>
parents:
1685
diff
changeset
|
2634 && FRAME_LIVE_P (XFRAME (data->focus_frame)))) |
|
95db936d47c0
* keyboard.c (Qscrollbar_movement, Qvertical_scrollbar,
Jim Blandy <jimb@redhat.com>
parents:
1685
diff
changeset
|
2635 Fredirect_frame_focus (frame, data->focus_frame); |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2636 #endif |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2637 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2638 #if 0 /* I don't understand why this is needed, and it causes problems |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2639 when the frame's old selected window has been deleted. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2640 #ifdef MULTI_FRAME |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2641 if (f != selected_frame && ! FRAME_TERMCAP_P (f)) |
|
2297
bb88d48c290f
(Fselect_window): Use Fhandle_switch_frame.
Richard M. Stallman <rms@gnu.org>
parents:
2210
diff
changeset
|
2642 Fhandle_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)), Qnil); |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2643 #endif |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2644 #endif |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2645 |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2646 /* Set the screen height to the value it had before this function. */ |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2647 if (previous_frame_height != FRAME_HEIGHT (f) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2648 || previous_frame_width != FRAME_WIDTH (f)) |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2649 change_frame_size (f, previous_frame_height, previous_frame_width, |
|
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2650 0, 0); |
| 265 | 2651 } |
| 2652 | |
|
1572
04c1b4719e60
* window.c (Fset_window_configuration): Protect call to
Jim Blandy <jimb@redhat.com>
parents:
1525
diff
changeset
|
2653 #ifdef MULTI_FRAME |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2654 /* Fselect_window will have made f the selected frame, so we |
|
2297
bb88d48c290f
(Fselect_window): Use Fhandle_switch_frame.
Richard M. Stallman <rms@gnu.org>
parents:
2210
diff
changeset
|
2655 reselect the proper frame here. Fhandle_switch_frame will change the |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2656 selected window too, but that doesn't make the call to |
|
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2657 Fselect_window above totally superfluous; it still sets f's |
|
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2658 selected window. */ |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2659 if (FRAME_LIVE_P (XFRAME (data->selected_frame))) |
|
2297
bb88d48c290f
(Fselect_window): Use Fhandle_switch_frame.
Richard M. Stallman <rms@gnu.org>
parents:
2210
diff
changeset
|
2660 Fhandle_switch_frame (data->selected_frame, Qnil); |
|
1572
04c1b4719e60
* window.c (Fset_window_configuration): Protect call to
Jim Blandy <jimb@redhat.com>
parents:
1525
diff
changeset
|
2661 #endif |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2662 |
|
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2663 if (!NILP (new_current_buffer)) |
|
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2664 Fset_buffer (new_current_buffer); |
|
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2665 |
| 265 | 2666 Vminibuf_scroll_window = data->minibuf_scroll_window; |
| 2667 return (Qnil); | |
| 2668 } | |
| 2669 | |
| 769 | 2670 /* Mark all windows now on frame as deleted |
| 265 | 2671 by setting their buffers to nil. */ |
| 2672 | |
|
1685
8d7fc70d3103
* window.c (Fset_window_configuration): If we're restoring the
Jim Blandy <jimb@redhat.com>
parents:
1572
diff
changeset
|
2673 void |
| 265 | 2674 delete_all_subwindows (w) |
| 2675 register struct window *w; | |
| 2676 { | |
| 485 | 2677 if (!NILP (w->next)) |
| 265 | 2678 delete_all_subwindows (XWINDOW (w->next)); |
| 485 | 2679 if (!NILP (w->vchild)) |
| 265 | 2680 delete_all_subwindows (XWINDOW (w->vchild)); |
| 485 | 2681 if (!NILP (w->hchild)) |
| 265 | 2682 delete_all_subwindows (XWINDOW (w->hchild)); |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2683 |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2684 w->height = w->buffer; /* See Fset_window_configuration for excuse. */ |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2685 |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2686 /* We set all three of these fields to nil, to make sure that we can |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2687 distinguish this dead window from any live window. Live leaf |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2688 windows will have buffer set, and combination windows will have |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2689 vchild or hchild set. */ |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2690 w->buffer = Qnil; |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2691 w->vchild = Qnil; |
|
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2692 w->hchild = Qnil; |
| 265 | 2693 } |
| 2694 | |
| 2695 static int | |
| 2696 count_windows (window) | |
| 2697 register struct window *window; | |
| 2698 { | |
| 2699 register int count = 1; | |
| 485 | 2700 if (!NILP (window->next)) |
| 265 | 2701 count += count_windows (XWINDOW (window->next)); |
| 485 | 2702 if (!NILP (window->vchild)) |
| 265 | 2703 count += count_windows (XWINDOW (window->vchild)); |
| 485 | 2704 if (!NILP (window->hchild)) |
| 265 | 2705 count += count_windows (XWINDOW (window->hchild)); |
| 2706 return count; | |
| 2707 } | |
| 2708 | |
| 2709 static int | |
| 2710 save_window_save (window, vector, i) | |
| 2711 Lisp_Object window; | |
| 2712 struct Lisp_Vector *vector; | |
| 2713 int i; | |
| 2714 { | |
| 2715 register struct saved_window *p; | |
| 2716 register struct window *w; | |
| 2717 register Lisp_Object tem; | |
| 2718 | |
| 485 | 2719 for (;!NILP (window); window = w->next) |
| 265 | 2720 { |
| 2721 p = SAVED_WINDOW_N (vector, i); | |
| 2722 w = XWINDOW (window); | |
| 2723 | |
| 2724 XFASTINT (w->temslot) = i++; | |
| 2725 p->window = window; | |
| 2726 p->buffer = w->buffer; | |
| 2727 p->left = w->left; | |
| 2728 p->top = w->top; | |
| 2729 p->width = w->width; | |
| 2730 p->height = w->height; | |
| 2731 p->hscroll = w->hscroll; | |
| 2732 p->display_table = w->display_table; | |
| 485 | 2733 if (!NILP (w->buffer)) |
| 265 | 2734 { |
| 2735 /* Save w's value of point in the window configuration. | |
| 2736 If w is the selected window, then get the value of point | |
| 2737 from the buffer; pointm is garbage in the selected window. */ | |
| 2738 if (EQ (window, selected_window)) | |
| 2739 { | |
| 2740 p->pointm = Fmake_marker (); | |
| 2741 Fset_marker (p->pointm, BUF_PT (XBUFFER (w->buffer)), | |
| 2742 w->buffer); | |
| 2743 } | |
| 2744 else | |
| 2745 p->pointm = Fcopy_marker (w->pointm); | |
| 2746 | |
| 2747 p->start = Fcopy_marker (w->start); | |
| 2748 p->start_at_line_beg = w->start_at_line_beg; | |
| 2749 | |
| 2750 tem = XBUFFER (w->buffer)->mark; | |
| 2751 p->mark = Fcopy_marker (tem); | |
| 2752 } | |
| 2753 else | |
| 2754 { | |
| 2755 p->pointm = Qnil; | |
| 2756 p->start = Qnil; | |
| 2757 p->mark = Qnil; | |
| 2758 p->start_at_line_beg = Qnil; | |
| 2759 } | |
| 2760 | |
| 485 | 2761 if (NILP (w->parent)) |
| 265 | 2762 p->parent = Qnil; |
| 2763 else | |
| 2764 p->parent = XWINDOW (w->parent)->temslot; | |
| 2765 | |
| 485 | 2766 if (NILP (w->prev)) |
| 265 | 2767 p->prev = Qnil; |
| 2768 else | |
| 2769 p->prev = XWINDOW (w->prev)->temslot; | |
| 2770 | |
| 485 | 2771 if (!NILP (w->vchild)) |
| 265 | 2772 i = save_window_save (w->vchild, vector, i); |
| 485 | 2773 if (!NILP (w->hchild)) |
| 265 | 2774 i = save_window_save (w->hchild, vector, i); |
| 2775 } | |
| 2776 | |
| 2777 return i; | |
| 2778 } | |
| 2779 | |
| 2780 DEFUN ("current-window-configuration", | |
| 358 | 2781 Fcurrent_window_configuration, Scurrent_window_configuration, 0, 1, 0, |
| 769 | 2782 "Return an object representing the current window configuration of FRAME.\n\ |
| 2783 If FRAME is nil or omitted, use the selected frame.\n\ | |
| 265 | 2784 This describes the number of windows, their sizes and current buffers,\n\ |
| 2785 and for each displayed buffer, where display starts, and the positions of\n\ | |
| 2786 point and mark. An exception is made for point in the current buffer:\n\ | |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2787 its value is -not- saved.\n\ |
|
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2788 This also records the currently selected frame, and FRAME's focus\n\ |
|
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2789 redirection (see `redirect-frame-focus').") |
| 769 | 2790 (frame) |
| 2791 Lisp_Object frame; | |
| 265 | 2792 { |
| 2793 register Lisp_Object tem; | |
| 2794 register int n_windows; | |
| 2795 register struct save_window_data *data; | |
| 2796 register int i; | |
| 769 | 2797 FRAME_PTR f; |
| 265 | 2798 |
| 769 | 2799 if (NILP (frame)) |
| 2800 f = selected_frame; | |
| 358 | 2801 else |
| 2802 { | |
| 769 | 2803 CHECK_LIVE_FRAME (frame, 0); |
| 2804 f = XFRAME (frame); | |
| 358 | 2805 } |
| 2806 | |
| 769 | 2807 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); |
| 265 | 2808 data = (struct save_window_data *) |
| 2809 XVECTOR (Fmake_vector (make_number (SAVE_WINDOW_DATA_SIZE), | |
| 2810 Qnil)); | |
| 769 | 2811 XFASTINT (data->frame_width) = FRAME_WIDTH (f); |
| 2812 XFASTINT (data->frame_height) = FRAME_HEIGHT (f); | |
|
1572
04c1b4719e60
* window.c (Fset_window_configuration): Protect call to
Jim Blandy <jimb@redhat.com>
parents:
1525
diff
changeset
|
2813 #ifdef MULTI_FRAME |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2814 XSET (data->selected_frame, Lisp_Frame, selected_frame); |
|
1572
04c1b4719e60
* window.c (Fset_window_configuration): Protect call to
Jim Blandy <jimb@redhat.com>
parents:
1525
diff
changeset
|
2815 #endif |
| 769 | 2816 data->current_window = FRAME_SELECTED_WINDOW (f); |
| 265 | 2817 XSET (data->current_buffer, Lisp_Buffer, current_buffer); |
| 2818 data->minibuf_scroll_window = Vminibuf_scroll_window; | |
| 769 | 2819 data->root_window = FRAME_ROOT_WINDOW (f); |
|
1325
f03e559aac3e
* window.c (struct save_window_data): Save the currently selected
Jim Blandy <jimb@redhat.com>
parents:
1280
diff
changeset
|
2820 data->focus_frame = FRAME_FOCUS_FRAME (f); |
| 265 | 2821 tem = Fmake_vector (make_number (n_windows), Qnil); |
| 2822 data->saved_windows = tem; | |
| 2823 for (i = 0; i < n_windows; i++) | |
| 2824 XVECTOR (tem)->contents[i] | |
| 2825 = Fmake_vector (make_number (SAVED_WINDOW_VECTOR_SIZE), Qnil); | |
| 769 | 2826 save_window_save (FRAME_ROOT_WINDOW (f), |
| 265 | 2827 XVECTOR (tem), 0); |
| 2828 XSET (tem, Lisp_Window_Configuration, data); | |
| 2829 return (tem); | |
| 2830 } | |
| 2831 | |
| 2832 DEFUN ("save-window-excursion", Fsave_window_excursion, Ssave_window_excursion, | |
| 2833 0, UNEVALLED, 0, | |
| 2834 "Execute body, preserving window sizes and contents.\n\ | |
| 2835 Restores which buffer appears in which window, where display starts,\n\ | |
| 2836 as well as the current buffer.\n\ | |
| 2837 Does not restore the value of point in current buffer.") | |
| 2838 (args) | |
| 2839 Lisp_Object args; | |
| 2840 { | |
| 2841 register Lisp_Object val; | |
| 2842 register int count = specpdl_ptr - specpdl; | |
| 2843 | |
| 2844 record_unwind_protect (Fset_window_configuration, | |
| 358 | 2845 Fcurrent_window_configuration (Qnil)); |
| 265 | 2846 val = Fprogn (args); |
| 2847 return unbind_to (count, val); | |
| 2848 } | |
| 2849 | |
| 2850 init_window_once () | |
| 2851 { | |
| 769 | 2852 #ifdef MULTI_FRAME |
| 2853 selected_frame = make_terminal_frame (); | |
| 2854 minibuf_window = selected_frame->minibuffer_window; | |
| 2855 selected_window = selected_frame->selected_window; | |
| 2856 last_nonminibuf_frame = selected_frame; | |
| 2857 #else /* not MULTI_FRAME */ | |
| 265 | 2858 extern Lisp_Object get_minibuffer (); |
| 2859 | |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
2860 minibuf_window = make_window (); |
| 769 | 2861 FRAME_ROOT_WINDOW (selected_frame) = make_window (); |
| 265 | 2862 |
| 769 | 2863 XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->next = minibuf_window; |
| 2864 XWINDOW (minibuf_window)->prev = FRAME_ROOT_WINDOW (selected_frame); | |
|
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
2865 XWINDOW (minibuf_window)->mini_p = Qt; |
| 265 | 2866 |
| 2867 /* These values 9 and 10 are arbitrary, | |
| 2868 just so that there is "something there." | |
| 2869 Correct values are put in in init_xdisp */ | |
| 2870 | |
| 769 | 2871 XFASTINT (XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->width) = 10; |
| 265 | 2872 XFASTINT (XWINDOW (minibuf_window)->width) = 10; |
| 2873 | |
| 769 | 2874 XFASTINT (XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->height) = 9; |
| 265 | 2875 XFASTINT (XWINDOW (minibuf_window)->top) = 9; |
| 2876 XFASTINT (XWINDOW (minibuf_window)->height) = 1; | |
| 2877 | |
| 2878 /* Prevent error in Fset_window_buffer. */ | |
| 769 | 2879 XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->buffer = Qt; |
| 265 | 2880 XWINDOW (minibuf_window)->buffer = Qt; |
| 2881 | |
| 2882 /* Now set them up for real. */ | |
| 769 | 2883 Fset_window_buffer (FRAME_ROOT_WINDOW (selected_frame), |
| 732 | 2884 Fcurrent_buffer ()); |
| 265 | 2885 Fset_window_buffer (minibuf_window, get_minibuffer (0)); |
| 2886 | |
| 769 | 2887 selected_window = FRAME_ROOT_WINDOW (selected_frame); |
| 362 | 2888 /* Make sure this window seems more recently used than |
| 2889 a newly-created, never-selected window. Increment | |
| 2890 window_select_count so the first selection ever will get | |
| 2891 something newer than this. */ | |
| 2892 XFASTINT (XWINDOW (selected_window)->use_time) = ++window_select_count; | |
| 769 | 2893 #endif /* not MULTI_FRAME */ |
| 265 | 2894 } |
| 2895 | |
| 2896 syms_of_window () | |
| 2897 { | |
| 2898 Qwindowp = intern ("windowp"); | |
| 2899 staticpro (&Qwindowp); | |
| 2900 | |
|
2210
22d78dbb3cc7
Rename `live-window-p' to `window-live-p', for consistency with
Jim Blandy <jimb@redhat.com>
parents:
2190
diff
changeset
|
2901 Qwindow_live_p = intern ("window-live-p"); |
|
22d78dbb3cc7
Rename `live-window-p' to `window-live-p', for consistency with
Jim Blandy <jimb@redhat.com>
parents:
2190
diff
changeset
|
2902 staticpro (&Qwindow_live_p); |
|
1444
559d2f2119aa
* window.c: Try to deal coherently with deleted windows:
Jim Blandy <jimb@redhat.com>
parents:
1345
diff
changeset
|
2903 |
|
3785
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
2904 Qvisible = intern ("Qvisible"); |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
2905 staticpro (&Qvisible); |
|
3455cbb3339d
Don't let the 'B' interactive spec default to buffers viewed in
Jim Blandy <jimb@redhat.com>
parents:
3765
diff
changeset
|
2906 |
|
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2907 #ifndef MULTI_FRAME |
| 265 | 2908 /* Make sure all windows get marked */ |
| 2909 staticpro (&minibuf_window); | |
|
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2910 #endif |
| 265 | 2911 |
| 2912 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, | |
| 2913 "Non-nil means call as function to display a help buffer.\n\ | |
| 2914 Used by `with-output-to-temp-buffer'."); | |
| 2915 Vtemp_buffer_show_function = Qnil; | |
| 2916 | |
| 2917 DEFVAR_LISP ("display-buffer-function", &Vdisplay_buffer_function, | |
| 2918 "If non-nil, function to call to handle `display-buffer'.\n\ | |
| 2919 It will receive two args, the buffer and a flag which if non-nil means\n\ | |
| 2920 that the currently selected window is not acceptable.\n\ | |
| 2921 Commands such as `switch-to-buffer-other-window' and `find-file-other-window'\n\ | |
| 2922 work using this function."); | |
| 2923 Vdisplay_buffer_function = Qnil; | |
| 2924 | |
| 2925 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window, | |
| 2926 "Non-nil means it is the window that C-M-v in minibuffer should scroll."); | |
| 2927 Vminibuf_scroll_window = Qnil; | |
| 2928 | |
| 2929 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer, | |
| 2930 "If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window."); | |
| 2931 Vother_window_scroll_buffer = Qnil; | |
| 2932 | |
| 769 | 2933 DEFVAR_BOOL ("pop-up-frames", &pop_up_frames, |
| 780 | 2934 "*Non-nil means `display-buffer' should make a separate frame."); |
| 769 | 2935 pop_up_frames = 0; |
| 265 | 2936 |
| 769 | 2937 DEFVAR_LISP ("pop-up-frame-function", &Vpop_up_frame_function, |
| 2938 "*If non-nil, function to call to handle automatic new frame creation.\n\ | |
| 2939 It is called with no arguments and should return a newly created frame.\n\ | |
| 265 | 2940 \n\ |
| 769 | 2941 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'\n\ |
| 2942 where `pop-up-frame-alist' would hold the default frame parameters."); | |
| 2943 Vpop_up_frame_function = Qnil; | |
| 265 | 2944 |
| 2945 DEFVAR_BOOL ("pop-up-windows", &pop_up_windows, | |
| 2946 "*Non-nil means display-buffer should make new windows."); | |
| 2947 pop_up_windows = 1; | |
| 2948 | |
| 2949 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines, | |
| 2950 "*Number of lines of continuity when scrolling by screenfuls."); | |
| 2951 next_screen_context_lines = 2; | |
| 2952 | |
| 2953 DEFVAR_INT ("split-height-threshold", &split_height_threshold, | |
| 2954 "*display-buffer would prefer to split the largest window if this large.\n\ | |
| 2955 If there is only one window, it is split regardless of this value."); | |
| 2956 split_height_threshold = 500; | |
| 2957 | |
| 2958 DEFVAR_INT ("window-min-height", &window_min_height, | |
| 2959 "*Delete any window less than this tall (including its mode line)."); | |
| 2960 window_min_height = 4; | |
| 2961 | |
| 2962 DEFVAR_INT ("window-min-width", &window_min_width, | |
| 2963 "*Delete any window less than this wide."); | |
| 2964 window_min_width = 10; | |
| 2965 | |
| 2966 defsubr (&Sselected_window); | |
| 2967 defsubr (&Sminibuffer_window); | |
| 2968 defsubr (&Swindow_minibuffer_p); | |
| 2969 defsubr (&Swindowp); | |
|
2210
22d78dbb3cc7
Rename `live-window-p' to `window-live-p', for consistency with
Jim Blandy <jimb@redhat.com>
parents:
2190
diff
changeset
|
2970 defsubr (&Swindow_live_p); |
| 265 | 2971 defsubr (&Spos_visible_in_window_p); |
| 2972 defsubr (&Swindow_buffer); | |
| 2973 defsubr (&Swindow_height); | |
| 2974 defsubr (&Swindow_width); | |
| 2975 defsubr (&Swindow_hscroll); | |
| 2976 defsubr (&Sset_window_hscroll); | |
| 2977 defsubr (&Swindow_edges); | |
| 432 | 2978 defsubr (&Scoordinates_in_window_p); |
| 2979 defsubr (&Swindow_at); | |
| 265 | 2980 defsubr (&Swindow_point); |
| 2981 defsubr (&Swindow_start); | |
| 2982 defsubr (&Swindow_end); | |
| 2983 defsubr (&Sset_window_point); | |
| 2984 defsubr (&Sset_window_start); | |
| 2985 defsubr (&Swindow_dedicated_p); | |
|
722
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
2986 defsubr (&Sset_window_dedicated_p); |
| 265 | 2987 defsubr (&Swindow_display_table); |
| 2988 defsubr (&Sset_window_display_table); | |
| 2989 defsubr (&Snext_window); | |
| 2990 defsubr (&Sprevious_window); | |
| 2991 defsubr (&Sother_window); | |
| 2992 defsubr (&Sget_lru_window); | |
| 2993 defsubr (&Sget_largest_window); | |
| 2994 defsubr (&Sget_buffer_window); | |
| 2995 defsubr (&Sdelete_other_windows); | |
| 2996 defsubr (&Sdelete_windows_on); | |
| 2997 defsubr (&Sreplace_buffer_in_windows); | |
| 2998 defsubr (&Sdelete_window); | |
| 2999 defsubr (&Sset_window_buffer); | |
| 3000 defsubr (&Sselect_window); | |
| 3001 defsubr (&Sdisplay_buffer); | |
| 3002 defsubr (&Ssplit_window); | |
| 3003 defsubr (&Senlarge_window); | |
| 3004 defsubr (&Sshrink_window); | |
| 3005 defsubr (&Sscroll_up); | |
| 3006 defsubr (&Sscroll_down); | |
| 3007 defsubr (&Sscroll_left); | |
| 3008 defsubr (&Sscroll_right); | |
| 3009 defsubr (&Sscroll_other_window); | |
| 3010 defsubr (&Srecenter); | |
| 3011 defsubr (&Smove_to_window_line); | |
| 3012 defsubr (&Swindow_configuration_p); | |
| 3013 defsubr (&Sset_window_configuration); | |
| 3014 defsubr (&Scurrent_window_configuration); | |
| 3015 defsubr (&Ssave_window_excursion); | |
| 3016 } | |
| 3017 | |
| 3018 keys_of_window () | |
| 3019 { | |
| 3020 initial_define_key (control_x_map, '1', "delete-other-windows"); | |
| 3021 initial_define_key (control_x_map, '2', "split-window"); | |
| 3022 initial_define_key (control_x_map, '0', "delete-window"); | |
| 3023 initial_define_key (control_x_map, 'o', "other-window"); | |
| 3024 initial_define_key (control_x_map, '^', "enlarge-window"); | |
| 3025 initial_define_key (control_x_map, '<', "scroll-left"); | |
| 3026 initial_define_key (control_x_map, '>', "scroll-right"); | |
| 3027 | |
| 3028 initial_define_key (global_map, Ctl ('V'), "scroll-up"); | |
| 3029 initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); | |
| 3030 initial_define_key (meta_map, 'v', "scroll-down"); | |
| 3031 | |
| 3032 initial_define_key (global_map, Ctl('L'), "recenter"); | |
| 3033 initial_define_key (meta_map, 'r', "move-to-window-line"); | |
| 3034 } |
