comparison src/window.c @ 367:a4f53d9b3154 r21-1-13

Import from CVS: tag r21-1-13
author cvs
date Mon, 13 Aug 2007 11:01:07 +0200
parents 30d2cfa1092a
children cc15677e0335
comparison
equal deleted inserted replaced
366:83d76f480a59 367:a4f53d9b3154
78 Lisp_Object Vvertical_divider_shadow_thickness; 78 Lisp_Object Vvertical_divider_shadow_thickness;
79 79
80 /* Divider surface width (not counting 3-d borders) */ 80 /* Divider surface width (not counting 3-d borders) */
81 Lisp_Object Vvertical_divider_line_width; 81 Lisp_Object Vvertical_divider_line_width;
82 82
83 /* Spacing between outer egde of divider border and window edge */ 83 /* Spacing between outer edge of divider border and window edge */
84 Lisp_Object Vvertical_divider_spacing; 84 Lisp_Object Vvertical_divider_spacing;
85 85
86 /* Scroll if point lands on the bottom line and that line is partially 86 /* Scroll if point lands on the bottom line and that line is partially
87 clipped. */ 87 clipped. */
88 int scroll_on_clipped_lines; 88 int scroll_on_clipped_lines;
1560 make_int (bottom)); 1560 make_int (bottom));
1561 } 1561 }
1562 1562
1563 DEFUN ("window-point", Fwindow_point, 0, 1, 0, /* 1563 DEFUN ("window-point", Fwindow_point, 0, 1, 0, /*
1564 Return current value of point in WINDOW. 1564 Return current value of point in WINDOW.
1565 For a nonselected window, this is the value point would have 1565 For a non-selected window, this is the value point would have
1566 if that window were selected. 1566 if that window were selected.
1567 1567
1568 Note that, when WINDOW is the selected window and its buffer 1568 Note that, when WINDOW is the selected window and its buffer
1569 is also currently selected, the value returned is the same as (point). 1569 is also currently selected, the value returned is the same as (point).
1570 It would be more strictly correct to return the `top-level' value 1570 It would be more strictly correct to return the `top-level' value
1978 return Qnil; 1978 return Qnil;
1979 } 1979 }
1980 1980
1981 1981
1982 DEFUN ("next-window", Fnext_window, 0, 4, 0, /* 1982 DEFUN ("next-window", Fnext_window, 0, 4, 0, /*
1983 Return next window after WINDOW in canonical ordering of windows. 1983 Return the next window after WINDOW in the canonical ordering of windows.
1984 If omitted, WINDOW defaults to the selected window. 1984 If omitted, WINDOW defaults to the selected window.
1985 1985
1986 Optional second arg MINIBUF t means count the minibuffer window even 1986 Optional second arg MINIBUF t means count the minibuffer window even
1987 if not active. MINIBUF nil or omitted means count the minibuffer iff 1987 if not active. MINIBUF nil or omitted means count the minibuffer iff
1988 it is active. MINIBUF neither t nor nil means not to count the 1988 it is active. MINIBUF neither t nor nil means not to count the
1999 above. ALL-FRAMES = `visible' means include windows on all visible frames. 1999 above. ALL-FRAMES = `visible' means include windows on all visible frames.
2000 ALL-FRAMES = 0 means include windows on all visible and iconified frames. 2000 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
2001 If ALL-FRAMES is a frame, restrict search to windows on that frame. 2001 If ALL-FRAMES is a frame, restrict search to windows on that frame.
2002 Anything else means restrict to WINDOW's frame. 2002 Anything else means restrict to WINDOW's frame.
2003 2003
2004 Optional fourth argument CONSOLE controls which consoles or devices the 2004 Optional fourth arg CONSOLE controls which consoles or devices the
2005 returned window may be on. If CONSOLE is a console, return windows only 2005 returned window may be on. If CONSOLE is a console, return windows only
2006 on that console. If CONSOLE is a device, return windows only on that 2006 on that console. If CONSOLE is a device, return windows only on that
2007 device. If CONSOLE is a console type, return windows only on consoles 2007 device. If CONSOLE is a console type, return windows only on consoles
2008 of that type. If CONSOLE is 'window-system, return any windows on any 2008 of that type. If CONSOLE is 'window-system, return any windows on any
2009 window-system consoles. If CONSOLE is nil or omitted, return windows only 2009 window-system consoles. If CONSOLE is nil or omitted, return windows only
2030 Decide if it does. */ 2030 Decide if it does. */
2031 if (NILP (minibuf)) 2031 if (NILP (minibuf))
2032 minibuf = (minibuf_level ? minibuf_window : Qlambda); 2032 minibuf = (minibuf_level ? minibuf_window : Qlambda);
2033 else if (! EQ (minibuf, Qt)) 2033 else if (! EQ (minibuf, Qt))
2034 minibuf = Qlambda; 2034 minibuf = Qlambda;
2035 /* Now minibuf can be t => count all minibuffer windows, 2035 /* Now `minibuf' is one of:
2036 lambda => count none of them, 2036 t => count all minibuffer windows
2037 lambda => count none of them
2037 or a specific minibuffer window (the active one) to count. */ 2038 or a specific minibuffer window (the active one) to count. */
2038 2039
2039 /* all_frames == nil doesn't specify which frames to include. */ 2040 /* all_frames == nil doesn't specify which frames to include. */
2040 if (NILP (all_frames)) 2041 if (NILP (all_frames))
2041 all_frames = (! EQ (minibuf, Qlambda) 2042 all_frames = (! EQ (minibuf, Qlambda)
2052 /* If all_frames is a frame and window arg isn't on that frame, just 2053 /* If all_frames is a frame and window arg isn't on that frame, just
2053 return the first window on the frame. */ 2054 return the first window on the frame. */
2054 return frame_first_window (XFRAME (all_frames)); 2055 return frame_first_window (XFRAME (all_frames));
2055 else if (! EQ (all_frames, Qt)) 2056 else if (! EQ (all_frames, Qt))
2056 all_frames = Qnil; 2057 all_frames = Qnil;
2057 /* Now all_frames is t meaning search all frames, 2058 /* Now `all_frames' is one of:
2058 nil meaning search just current frame, 2059 t => search all frames
2059 visible meaning search just visible frames, 2060 nil => search just the current frame
2060 0 meaning search visible and iconified frames, 2061 visible => search just visible frames
2061 or a window, meaning search the frame that window belongs to. */ 2062 0 => search visible and iconified frames
2063 a window => search the frame that window belongs to. */
2062 2064
2063 /* Do this loop at least once, to get the next window, and perhaps 2065 /* Do this loop at least once, to get the next window, and perhaps
2064 again, if we hit the minibuffer and that is not acceptable. */ 2066 again, if we hit the minibuffer and that is not acceptable. */
2065 do 2067 do
2066 { 2068 {
2075 Which other frames are acceptable? */ 2077 Which other frames are acceptable? */
2076 tem = WINDOW_FRAME (XWINDOW (window)); 2078 tem = WINDOW_FRAME (XWINDOW (window));
2077 2079
2078 if (! NILP (all_frames)) 2080 if (! NILP (all_frames))
2079 { 2081 {
2080 Lisp_Object tem1; 2082 Lisp_Object tem1 = tem;
2081
2082 tem1 = tem;
2083 tem = next_frame (tem, all_frames, console); 2083 tem = next_frame (tem, all_frames, console);
2084
2084 /* In the case where the minibuffer is active, 2085 /* In the case where the minibuffer is active,
2085 and we include its frame as well as the selected one, 2086 and we include its frame as well as the selected one,
2086 next_frame may get stuck in that frame. 2087 next_frame may get stuck in that frame.
2087 If that happens, go back to the selected frame 2088 If that happens, go back to the selected frame
2088 so we can complete the cycle. */ 2089 so we can complete the cycle. */
2105 else if (!NILP (XWINDOW (window)->vchild)) 2106 else if (!NILP (XWINDOW (window)->vchild))
2106 window = XWINDOW (window)->vchild; 2107 window = XWINDOW (window)->vchild;
2107 else break; 2108 else break;
2108 } 2109 }
2109 } 2110 }
2110 /* "acceptable" is the correct spelling. */
2111 /* Which windows are acceptable? 2111 /* Which windows are acceptable?
2112 Exit the loop and accept this window if 2112 Exit the loop and accept this window if
2113 this isn't a minibuffer window, 2113 this isn't a minibuffer window,
2114 or we're accepting all minibuffer windows, 2114 or we're accepting all minibuffer windows,
2115 or this is the active minibuffer and we are accepting that one, or 2115 or this is the active minibuffer and we are accepting that one, or
2121 2121
2122 return window; 2122 return window;
2123 } 2123 }
2124 2124
2125 DEFUN ("previous-window", Fprevious_window, 0, 4, 0, /* 2125 DEFUN ("previous-window", Fprevious_window, 0, 4, 0, /*
2126 Return the window preceding WINDOW in canonical ordering of windows. 2126 Return the window preceding WINDOW in the canonical ordering of windows.
2127 If omitted, WINDOW defaults to the selected window. 2127 If omitted, WINDOW defaults to the selected window.
2128 2128
2129 Optional second arg MINIBUF t means count the minibuffer window even 2129 Optional second arg MINIBUF t means count the minibuffer window even
2130 if not active. MINIBUF nil or omitted means count the minibuffer iff 2130 if not active. MINIBUF nil or omitted means count the minibuffer iff
2131 it is active. MINIBUF neither t nor nil means not to count the 2131 it is active. MINIBUF neither t nor nil means not to count the
2133 2133
2134 Several frames may share a single minibuffer; if the minibuffer 2134 Several frames may share a single minibuffer; if the minibuffer
2135 counts, all windows on all frames that share that minibuffer count 2135 counts, all windows on all frames that share that minibuffer count
2136 too. Therefore, `previous-window' can be used to iterate through 2136 too. Therefore, `previous-window' can be used to iterate through
2137 the set of windows even when the minibuffer is on another frame. If 2137 the set of windows even when the minibuffer is on another frame. If
2138 the minibuffer does not count, only windows from WINDOW's frame count 2138 the minibuffer does not count, only windows from WINDOW's frame count.
2139 2139
2140 If optional third arg ALL-FRAMES t means include windows on all frames. 2140 Optional third arg ALL-FRAMES t means include windows on all frames.
2141 ALL-FRAMES nil or omitted means cycle within the frames as specified 2141 ALL-FRAMES nil or omitted means cycle within the frames as specified
2142 above. ALL-FRAMES = `visible' means include windows on all visible frames. 2142 above. ALL-FRAMES = `visible' means include windows on all visible frames.
2143 ALL-FRAMES = 0 means include windows on all visible and iconified frames. 2143 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
2144 If ALL-FRAMES is a frame, restrict search to windows on that frame. 2144 If ALL-FRAMES is a frame, restrict search to windows on that frame.
2145 Anything else means restrict to WINDOW's frame. 2145 Anything else means restrict to WINDOW's frame.
2146 2146
2147 Optional fourth argument CONSOLE controls which consoles or devices the 2147 Optional fourth arg CONSOLE controls which consoles or devices the
2148 returned window may be on. If CONSOLE is a console, return windows only 2148 returned window may be on. If CONSOLE is a console, return windows only
2149 on that console. If CONSOLE is a device, return windows only on that 2149 on that console. If CONSOLE is a device, return windows only on that
2150 device. If CONSOLE is a console type, return windows only on consoles 2150 device. If CONSOLE is a console type, return windows only on consoles
2151 of that type. If CONSOLE is 'window-system, return any windows on any 2151 of that type. If CONSOLE is 'window-system, return any windows on any
2152 window-system consoles. If CONSOLE is nil or omitted, return windows only 2152 window-system consoles. If CONSOLE is nil or omitted, return windows only
2173 Decide if it does. */ 2173 Decide if it does. */
2174 if (NILP (minibuf)) 2174 if (NILP (minibuf))
2175 minibuf = (minibuf_level ? minibuf_window : Qlambda); 2175 minibuf = (minibuf_level ? minibuf_window : Qlambda);
2176 else if (! EQ (minibuf, Qt)) 2176 else if (! EQ (minibuf, Qt))
2177 minibuf = Qlambda; 2177 minibuf = Qlambda;
2178 /* Now minibuf can be t => count all minibuffer windows, 2178 /* Now `minibuf' is one of:
2179 lambda => count none of them, 2179 t => count all minibuffer windows
2180 lambda => count none of them
2180 or a specific minibuffer window (the active one) to count. */ 2181 or a specific minibuffer window (the active one) to count. */
2181 2182
2182 /* all_frames == nil doesn't specify which frames to include. 2183 /* all_frames == nil doesn't specify which frames to include.
2183 Decide which frames it includes. */ 2184 Decide which frames it includes. */
2184 if (NILP (all_frames)) 2185 if (NILP (all_frames))
2196 /* If all_frames is a frame and window arg isn't on that frame, just 2197 /* If all_frames is a frame and window arg isn't on that frame, just
2197 return the first window on the frame. */ 2198 return the first window on the frame. */
2198 return frame_first_window (XFRAME (all_frames)); 2199 return frame_first_window (XFRAME (all_frames));
2199 else if (! EQ (all_frames, Qt)) 2200 else if (! EQ (all_frames, Qt))
2200 all_frames = Qnil; 2201 all_frames = Qnil;
2201 /* Now all_frames is t meaning search all frames, 2202 /* Now `all_frames' is one of:
2202 nil meaning search just current frame, 2203 t => search all frames
2203 visible meaning search just visible frames, 2204 nil => search just the current frame
2204 0 meaning search visible and iconified frames, 2205 visible => search just visible frames
2205 or a window, meaning search the frame that window belongs to. */ 2206 0 => search visible and iconified frames
2207 a window => search the frame that window belongs to. */
2206 2208
2207 /* Do this loop at least once, to get the next window, and perhaps 2209 /* Do this loop at least once, to get the next window, and perhaps
2208 again, if we hit the minibuffer and that is not acceptable. */ 2210 again, if we hit the minibuffer and that is not acceptable. */
2209 do 2211 do
2210 { 2212 {
2218 /* We have found the top window on the frame. 2220 /* We have found the top window on the frame.
2219 Which frames are acceptable? */ 2221 Which frames are acceptable? */
2220 tem = WINDOW_FRAME (XWINDOW (window)); 2222 tem = WINDOW_FRAME (XWINDOW (window));
2221 2223
2222 if (! NILP (all_frames)) 2224 if (! NILP (all_frames))
2223 /* It's actually important that we use prev_frame here, 2225 /* It's actually important that we use previous_frame here,
2224 rather than next_frame. All the windows acceptable 2226 rather than next_frame. All the windows acceptable
2225 according to the given parameters should form a ring; 2227 according to the given parameters should form a ring;
2226 Fnext_window and Fprevious_window should go back and 2228 Fnext_window and Fprevious_window should go back and
2227 forth around the ring. If we use next_frame here, 2229 forth around the ring. If we use next_frame here,
2228 then Fnext_window and Fprevious_window take different 2230 then Fnext_window and Fprevious_window take different
2229 paths through the set of acceptable windows. 2231 paths through the set of acceptable windows.
2230 window_loop assumes that these `ring' requirement are 2232 window_loop assumes that these `ring' requirement are
2231 met. */ 2233 met. */
2232 { 2234 {
2233 Lisp_Object tem1; 2235 Lisp_Object tem1 = tem;
2234 2236 tem = previous_frame (tem, all_frames, console);
2235 tem1 = tem;
2236 tem = prev_frame (tem, all_frames, console);
2237 /* In the case where the minibuffer is active, 2237 /* In the case where the minibuffer is active,
2238 and we include its frame as well as the selected one, 2238 and we include its frame as well as the selected one,
2239 next_frame may get stuck in that frame. 2239 next_frame may get stuck in that frame.
2240 If that happens, go back to the selected frame 2240 If that happens, go back to the selected frame
2241 so we can complete the cycle. */ 2241 so we can complete the cycle. */
2417 * #### catch the lossage this is meant(?) to punt on... 2417 * #### catch the lossage this is meant(?) to punt on...
2418 */ 2418 */
2419 int lose_lose = 0; 2419 int lose_lose = 0;
2420 Lisp_Object devcons, concons; 2420 Lisp_Object devcons, concons;
2421 2421
2422 /* FRAME_ARG is Qlambda to stick to one frame,
2423 Qvisible to consider all visible frames,
2424 or Qt otherwise. */
2425
2426 /* If we're only looping through windows on a particular frame, 2422 /* If we're only looping through windows on a particular frame,
2427 FRAME points to that frame. If we're looping through windows 2423 FRAME points to that frame. If we're looping through windows
2428 on all frames, FRAME is 0. */ 2424 on all frames, FRAME is 0. */
2429
2430 if (FRAMEP (frames)) 2425 if (FRAMEP (frames))
2431 frame = XFRAME (frames); 2426 frame = XFRAME (frames);
2432 else if (NILP (frames)) 2427 else if (NILP (frames))
2433 frame = selected_frame (); 2428 frame = selected_frame ();
2434 else 2429 else
2435 frame = 0; 2430 frame = 0;
2431
2432 /* FRAME_ARG is Qlambda to stick to one frame,
2433 Qvisible to consider all visible frames,
2434 or Qt otherwise. */
2436 if (frame) 2435 if (frame)
2437 frame_arg = Qlambda; 2436 frame_arg = Qlambda;
2438 else if (ZEROP (frames)) 2437 else if (ZEROP (frames))
2439 frame_arg = frames; 2438 frame_arg = frames;
2440 else if (EQ (frames, Qvisible)) 2439 else if (EQ (frames, Qvisible))
2451 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device)); 2450 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
2452 2451
2453 if (NILP (the_frame)) 2452 if (NILP (the_frame))
2454 continue; 2453 continue;
2455 2454
2456 if (!device_matches_console_spec (the_frame, device, console)) 2455 if (!device_matches_console_spec (device,
2456 NILP (console) ?
2457 FRAME_CONSOLE (XFRAME (the_frame)) :
2458 console))
2457 continue; 2459 continue;
2458 2460
2459 /* Pick a window to start with. */ 2461 /* Pick a window to start with. */
2460 if (WINDOWP (obj)) 2462 if (WINDOWP (obj))
2461 w = obj; 2463 w = obj;
2477 struct window *p = XWINDOW (w); 2479 struct window *p = XWINDOW (w);
2478 struct frame *w_frame = XFRAME (WINDOW_FRAME (p)); 2480 struct frame *w_frame = XFRAME (WINDOW_FRAME (p));
2479 2481
2480 /* Pick the next window now, since some operations will delete 2482 /* Pick the next window now, since some operations will delete
2481 the current window. */ 2483 the current window. */
2482 next_window = Fnext_window (w, mini ? Qt : Qnil, frame_arg, Qt); 2484 next_window = Fnext_window (w, mini ? Qt : Qnil, frame_arg, device);
2483 2485
2484 /* #### Still needed ?? */ 2486 /* #### Still needed ?? */
2485 /* Given the outstanding quality of the rest of this code, 2487 /* Given the outstanding quality of the rest of this code,
2486 I feel no shame about putting this piece of shit in. */ 2488 I feel no shame about putting this piece of shit in. */
2487 if (++lose_lose >= 500) 2489 if (++lose_lose >= 500)
3200 DEFUN ("select-window", Fselect_window, 1, 2, 0, /* 3202 DEFUN ("select-window", Fselect_window, 1, 2, 0, /*
3201 Select WINDOW. Most editing will apply to WINDOW's buffer. 3203 Select WINDOW. Most editing will apply to WINDOW's buffer.
3202 The main editor command loop selects the buffer of the selected window 3204 The main editor command loop selects the buffer of the selected window
3203 before each command. 3205 before each command.
3204 3206
3205 With non-nil optional argument `norecord', do not modify the 3207 With non-nil optional argument NORECORD, do not modify the
3206 global or per-frame buffer ordering. 3208 global or per-frame buffer ordering.
3207 */ 3209 */
3208 (window, norecord)) 3210 (window, norecord))
3209 { 3211 {
3210 struct window *w; 3212 struct window *w;
3362 } 3364 }
3363 3365
3364 DEFUN ("split-window", Fsplit_window, 0, 3, "", /* 3366 DEFUN ("split-window", Fsplit_window, 0, 3, "", /*
3365 Split WINDOW, putting SIZE lines in the first of the pair. 3367 Split WINDOW, putting SIZE lines in the first of the pair.
3366 WINDOW defaults to selected one and SIZE to half its size. 3368 WINDOW defaults to selected one and SIZE to half its size.
3367 If optional third arg HOR-FLAG is non-nil, split side by side 3369 If optional third arg HORFLAG is non-nil, split side by side
3368 and put SIZE columns in the first of the pair. 3370 and put SIZE columns in the first of the pair.
3369 */ 3371 */
3370 (window, chsize, horflag)) 3372 (window, chsize, horflag))
3371 { 3373 {
3372 Lisp_Object new; 3374 Lisp_Object new;
4445 /* Map MAPFUN over the windows in F. CLOSURE is passed to each 4447 /* Map MAPFUN over the windows in F. CLOSURE is passed to each
4446 invocation of MAPFUN. If any invocation of MAPFUN returns 4448 invocation of MAPFUN. If any invocation of MAPFUN returns
4447 non-zero, the mapping is halted. Otherwise, map_windows() maps 4449 non-zero, the mapping is halted. Otherwise, map_windows() maps
4448 over all windows in F. 4450 over all windows in F.
4449 4451
4450 If MAPFUN creates or deletes windows, the behaviour is undefined. */ 4452 If MAPFUN creates or deletes windows, the behavior is undefined. */
4451 4453
4452 int 4454 int
4453 map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure), 4455 map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure),
4454 void *closure) 4456 void *closure)
4455 { 4457 {