428
|
1 /* TTY frame functions.
|
771
|
2 Copyright (C) 1995, 1997 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995, 1996, 2002 Ben Wing.
|
428
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
|
24 /* Written by Ben Wing.
|
|
25 Multi-frame support added by Hrvoje Niksic. */
|
|
26
|
|
27 #include <config.h>
|
|
28 #include "lisp.h"
|
|
29
|
|
30 #include "console-tty.h"
|
|
31 #include "frame.h"
|
|
32
|
|
33 #include "events.h"
|
|
34
|
|
35
|
|
36 /* Default properties to use when creating frames. */
|
|
37 Lisp_Object Vdefault_tty_frame_plist;
|
|
38
|
771
|
39 Lisp_Object Qframe_number;
|
|
40
|
428
|
41 static void tty_raise_frame (struct frame *);
|
|
42
|
|
43
|
|
44 static void
|
771
|
45 tty_init_frame_1 (struct frame *f, Lisp_Object props,
|
|
46 int frame_name_is_defaulted)
|
428
|
47 {
|
|
48 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
49 struct console *c = XCONSOLE (DEVICE_CONSOLE (d));
|
|
50
|
|
51 ++CONSOLE_TTY_DATA (c)->frame_count;
|
|
52 f->order_count = CONSOLE_TTY_DATA (c)->frame_count;
|
|
53 f->height = CONSOLE_TTY_DATA (c)->height;
|
|
54 f->width = CONSOLE_TTY_DATA (c)->width;
|
771
|
55 if (frame_name_is_defaulted)
|
|
56 f->name = emacs_sprintf_string ("F%d", f->order_count);
|
428
|
57 }
|
|
58
|
|
59 static void
|
|
60 tty_init_frame_3 (struct frame *f)
|
|
61 {
|
|
62 tty_raise_frame (f);
|
|
63 }
|
|
64
|
|
65 static void
|
|
66 tty_select_frame_if_unhidden (Lisp_Object frame)
|
|
67 {
|
|
68 if (FRAME_REPAINT_P (XFRAME (frame)))
|
|
69 select_frame_1 (frame);
|
|
70 }
|
|
71
|
|
72 static void
|
|
73 tty_schedule_frame_select (struct frame *f)
|
|
74 {
|
793
|
75 Lisp_Object frame = wrap_frame (f);
|
428
|
76
|
|
77 enqueue_magic_eval_event (tty_select_frame_if_unhidden, frame);
|
|
78 }
|
|
79
|
|
80 static void
|
|
81 tty_after_init_frame (struct frame *f, int first_on_device,
|
|
82 int first_on_console)
|
|
83 {
|
|
84 if (first_on_console)
|
|
85 call1 (Qinit_post_tty_win, FRAME_CONSOLE (f));
|
|
86 }
|
|
87
|
|
88 /* Change from withdrawn state to mapped state. */
|
|
89 static void
|
|
90 tty_make_frame_visible (struct frame *f)
|
|
91 {
|
771
|
92 if (!FRAME_VISIBLE_P (f))
|
428
|
93 {
|
|
94 f->visible = -1;
|
|
95 }
|
|
96 }
|
|
97
|
|
98 /* Change from mapped state to withdrawn state. */
|
|
99 static void
|
|
100 tty_make_frame_invisible (struct frame *f)
|
|
101 {
|
|
102 f->visible = 0;
|
|
103 }
|
|
104
|
|
105 static void
|
|
106 tty_make_frame_hidden (struct frame *f)
|
|
107 {
|
|
108 f->visible = -1;
|
|
109 }
|
|
110
|
|
111 static void
|
|
112 tty_make_frame_unhidden (struct frame *f)
|
|
113 {
|
771
|
114 if (!FRAME_REPAINT_P (f))
|
428
|
115 {
|
771
|
116 SET_FRAME_CLEAR (f);
|
428
|
117 f->visible = 1;
|
|
118 }
|
|
119 }
|
|
120
|
|
121 static int
|
|
122 tty_frame_visible_p (struct frame *f)
|
|
123 {
|
|
124 return FRAME_VISIBLE_P (f);
|
|
125 }
|
|
126
|
|
127 static void
|
|
128 tty_raise_frame_no_select (struct frame *f)
|
|
129 {
|
|
130 LIST_LOOP_2 (frame, DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f))))
|
|
131 {
|
|
132 struct frame *o = XFRAME (frame);
|
|
133 if (o != f && FRAME_REPAINT_P (o))
|
|
134 {
|
|
135 tty_make_frame_hidden (o);
|
|
136 break;
|
|
137 }
|
|
138 }
|
|
139 tty_make_frame_unhidden (f);
|
|
140 }
|
|
141
|
|
142 static void
|
|
143 tty_raise_frame (struct frame *f)
|
|
144 {
|
|
145 tty_raise_frame_no_select (f);
|
|
146 tty_schedule_frame_select (f);
|
|
147 }
|
|
148
|
|
149 static void
|
|
150 tty_lower_frame (struct frame *f)
|
|
151 {
|
|
152 Lisp_Object frame_list = DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)));
|
|
153 Lisp_Object tail, new;
|
|
154
|
|
155 if (!FRAME_REPAINT_P (f))
|
|
156 return;
|
|
157
|
|
158 LIST_LOOP (tail, frame_list)
|
|
159 {
|
|
160 if (f == XFRAME (XCAR (tail)))
|
|
161 break;
|
|
162 }
|
|
163
|
|
164 /* To lower this frame, another frame has to be raised. Return if
|
|
165 there is no other frame. */
|
771
|
166 if (NILP (tail) && EQ (frame_list, tail))
|
428
|
167 return;
|
|
168
|
|
169 tty_make_frame_hidden (f);
|
|
170 if (CONSP (XCDR (tail)))
|
|
171 new = XCAR (XCDR (tail));
|
|
172 else
|
|
173 new = XCAR (frame_list);
|
|
174 tty_make_frame_unhidden (XFRAME (new));
|
|
175 tty_schedule_frame_select (XFRAME (new));
|
|
176 }
|
|
177
|
|
178 static void
|
|
179 tty_delete_frame (struct frame *f)
|
|
180 {
|
|
181 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
182
|
|
183 if (!NILP (DEVICE_SELECTED_FRAME (d)))
|
|
184 tty_raise_frame (XFRAME (DEVICE_SELECTED_FRAME (d)));
|
|
185 }
|
771
|
186
|
|
187 static Lisp_Object
|
|
188 tty_frame_property (struct frame *f, Lisp_Object property)
|
|
189 {
|
|
190 if (EQ (Qframe_number, property))
|
|
191 return make_int (f->order_count);
|
|
192
|
|
193 return Qunbound;
|
|
194 }
|
|
195
|
|
196 static int
|
|
197 tty_internal_frame_property_p (struct frame *f, Lisp_Object property)
|
|
198 {
|
|
199 return EQ (property, Qframe_number);
|
|
200 }
|
|
201
|
|
202 static Lisp_Object
|
|
203 tty_frame_properties (struct frame *f)
|
|
204 {
|
|
205 Lisp_Object props = Qnil;
|
|
206
|
|
207 props = cons3 (Qframe_number, make_int (f->order_count), props);
|
|
208
|
|
209 return props;
|
|
210 }
|
428
|
211
|
|
212 /************************************************************************/
|
|
213 /* initialization */
|
|
214 /************************************************************************/
|
|
215
|
|
216 void
|
|
217 console_type_create_frame_tty (void)
|
|
218 {
|
|
219 CONSOLE_HAS_METHOD (tty, init_frame_1);
|
|
220 CONSOLE_HAS_METHOD (tty, init_frame_3);
|
|
221 CONSOLE_HAS_METHOD (tty, after_init_frame);
|
|
222 CONSOLE_HAS_METHOD (tty, make_frame_visible);
|
|
223 CONSOLE_HAS_METHOD (tty, make_frame_invisible);
|
|
224 CONSOLE_HAS_METHOD (tty, frame_visible_p);
|
|
225 CONSOLE_HAS_METHOD (tty, raise_frame);
|
|
226 CONSOLE_HAS_METHOD (tty, lower_frame);
|
|
227 CONSOLE_HAS_METHOD (tty, delete_frame);
|
771
|
228 CONSOLE_HAS_METHOD (tty, frame_property);
|
|
229 CONSOLE_HAS_METHOD (tty, internal_frame_property_p);
|
|
230 CONSOLE_HAS_METHOD (tty, frame_properties);
|
|
231 }
|
|
232
|
|
233 void
|
|
234 syms_of_frame_tty (void)
|
|
235 {
|
|
236 DEFSYMBOL (Qframe_number);
|
428
|
237 }
|
|
238
|
|
239 void
|
|
240 vars_of_frame_tty (void)
|
|
241 {
|
|
242 DEFVAR_LISP ("default-tty-frame-plist", &Vdefault_tty_frame_plist /*
|
|
243 Plist of default frame-creation properties for tty frames.
|
|
244 These are in addition to and override what is specified in
|
|
245 `default-frame-plist', but are overridden by the arguments to the
|
|
246 particular call to `make-frame'.
|
|
247 */ );
|
|
248 Vdefault_tty_frame_plist = Qnil;
|
|
249
|
|
250 tty_console_methods->device_specific_frame_props =
|
|
251 &Vdefault_tty_frame_plist;
|
|
252
|
|
253 /* Tty frames are now supported. Advertise a feature to indicate this. */
|
|
254 Fprovide (intern ("tty-frames"));
|
|
255 }
|