annotate src/window.c @ 332:3cb8418b827a

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