0
|
1 /* TTY frame functions.
|
149
|
2 Copyright (C) 1995 Free Software Foundation, Inc.
|
0
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
149
|
4 Copyright (C) 1997 Free Software Foundation, Inc.
|
0
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
149
|
25 /* Written by Ben Wing.
|
|
26 Multi-frame support added by Hrvoje Niksic. */
|
0
|
27
|
|
28 #include <config.h>
|
|
29 #include "lisp.h"
|
|
30
|
|
31 #include "console-tty.h"
|
|
32 #include "frame.h"
|
|
33
|
153
|
34 #ifdef HAVE_GPM
|
|
35 #include <gpm.h>
|
|
36 #endif
|
|
37
|
149
|
38
|
|
39 /* Default properties to use when creating frames. */
|
0
|
40 Lisp_Object Vdefault_tty_frame_plist;
|
|
41
|
149
|
42 /* The count of frame number. */
|
|
43 static int tty_frame_count;
|
|
44
|
|
45 static void tty_make_frame_visible (struct frame *);
|
|
46 static void tty_make_frame_invisible (struct frame *);
|
|
47
|
|
48
|
0
|
49 static void
|
|
50 tty_init_frame_1 (struct frame *f, Lisp_Object props)
|
|
51 {
|
|
52 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
53 struct console *c = XCONSOLE (DEVICE_CONSOLE (d));
|
|
54
|
149
|
55 ++CONSOLE_TTY_DATA (c)->frame_count;
|
|
56 f->order_count = CONSOLE_TTY_DATA (c)->frame_count;
|
0
|
57 f->height = CONSOLE_TTY_DATA (c)->height;
|
|
58 f->width = CONSOLE_TTY_DATA (c)->width;
|
|
59 #ifdef HAVE_SCROLLBARS
|
|
60 f->scrollbar_on_left = 1;
|
|
61 f->scrollbar_on_top = 0;
|
|
62 #endif
|
149
|
63 }
|
|
64
|
|
65 static void
|
|
66 tty_init_frame_3 (struct frame *f)
|
|
67 {
|
|
68 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
69 Lisp_Object tail = DEVICE_FRAME_LIST (d);
|
|
70
|
|
71 while (CONSP (tail))
|
|
72 {
|
|
73 tty_make_frame_invisible (decode_frame (XCAR (tail)));
|
|
74 tail = XCDR (tail);
|
|
75 }
|
|
76 select_frame_2 (make_frame (f));
|
0
|
77 SET_FRAME_CLEAR (f);
|
149
|
78 tty_make_frame_visible (f);
|
0
|
79 }
|
|
80
|
|
81 static void
|
|
82 tty_after_init_frame (struct frame *f, int first_on_device,
|
|
83 int first_on_console)
|
|
84 {
|
|
85 if (first_on_console)
|
149
|
86 call1 (Qinit_post_tty_win, FRAME_CONSOLE (f));
|
0
|
87 }
|
|
88
|
153
|
89 #ifdef HAVE_GPM
|
|
90 static int
|
|
91 tty_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y)
|
|
92 {
|
|
93 Gpm_Event ev;
|
|
94 int num_buttons;
|
|
95
|
|
96 num_buttons = Gpm_GetSnapshot(&ev);
|
|
97 *x = ev.x;
|
|
98 *y = ev.y;
|
|
99 *frame = DEVICE_SELECTED_FRAME (d);
|
|
100 return (1);
|
|
101 }
|
|
102
|
|
103 static void
|
|
104 tty_set_mouse_position (struct window *w, int x, int y)
|
|
105 {
|
|
106 /* XXX
|
|
107 I couldn't find any GPM functions that set the mouse position.
|
|
108 Mr. Perry had left this function empty; that must be why.
|
|
109 karlheg
|
|
110 */
|
|
111 }
|
|
112
|
|
113 #endif
|
|
114
|
|
115
|
108
|
116 /* Change from withdrawn state to mapped state. */
|
|
117 static void
|
|
118 tty_make_frame_visible (struct frame *f)
|
|
119 {
|
|
120 if (!FRAME_VISIBLE_P(f))
|
|
121 {
|
|
122 SET_FRAME_CLEAR(f);
|
|
123 f->visible = 1;
|
|
124 }
|
|
125 }
|
|
126
|
|
127 /* Change from mapped state to withdrawn state. */
|
|
128 static void
|
|
129 tty_make_frame_invisible (struct frame *f)
|
|
130 {
|
149
|
131 f->visible = 0;
|
108
|
132 }
|
|
133
|
|
134 static int
|
|
135 tty_frame_visible_p (struct frame *f)
|
|
136 {
|
149
|
137 return FRAME_VISIBLE_P (f);
|
|
138 }
|
|
139
|
|
140 /* Raise the frame. This means that it becomes visible, and all the
|
|
141 others become invisible. */
|
|
142 static void
|
|
143 tty_raise_frame (struct frame *f)
|
|
144 {
|
|
145 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
146 Lisp_Object frame_list = DEVICE_FRAME_LIST (d);
|
|
147 Lisp_Object tail = frame_list;
|
|
148
|
|
149 while (CONSP (tail))
|
|
150 {
|
|
151 if (decode_frame (XCAR (tail)) != f)
|
|
152 tty_make_frame_invisible (XFRAME (XCAR (tail)));
|
|
153 tail = XCDR (tail);
|
|
154 }
|
|
155 select_frame_2 (make_frame (f));
|
|
156 tty_make_frame_visible (f);
|
|
157 }
|
|
158
|
|
159 /* Lower the frame. This means that it becomes invisible, while the
|
|
160 one after it in the frame list becomes visible. */
|
|
161 static void
|
|
162 tty_lower_frame (struct frame *f)
|
|
163 {
|
|
164 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
165 Lisp_Object frame_list = DEVICE_FRAME_LIST (d);
|
|
166 Lisp_Object tail;
|
|
167 Lisp_Object new;
|
|
168
|
|
169 if (!FRAME_VISIBLE_P (f))
|
|
170 return;
|
|
171
|
|
172 tail = frame_list;
|
|
173 while (CONSP (tail))
|
|
174 {
|
|
175 if (decode_frame (XCAR (tail)) == f)
|
|
176 break;
|
|
177 tail = XCDR (tail);
|
|
178 }
|
|
179 if (!CONSP (tail))
|
|
180 {
|
|
181 error ("Cannot find frame to lower");
|
|
182 }
|
|
183
|
|
184 tty_make_frame_invisible (f);
|
|
185 if (CONSP (XCDR (tail)))
|
|
186 new = XCAR (XCDR (tail));
|
|
187 else
|
|
188 new = XCAR (frame_list);
|
|
189 tty_make_frame_visible (XFRAME (new));
|
|
190 select_frame_2 (new);
|
108
|
191 }
|
|
192
|
0
|
193
|
|
194 /************************************************************************/
|
|
195 /* initialization */
|
|
196 /************************************************************************/
|
|
197
|
|
198 void
|
|
199 console_type_create_frame_tty (void)
|
|
200 {
|
|
201 CONSOLE_HAS_METHOD (tty, init_frame_1);
|
149
|
202 CONSOLE_HAS_METHOD (tty, init_frame_3);
|
0
|
203 CONSOLE_HAS_METHOD (tty, after_init_frame);
|
153
|
204 #ifdef HAVE_GPM
|
|
205 CONSOLE_HAS_METHOD (tty, get_mouse_position);
|
|
206 CONSOLE_HAS_METHOD (tty, set_mouse_position);
|
|
207 #endif
|
108
|
208 CONSOLE_HAS_METHOD (tty, make_frame_visible);
|
|
209 CONSOLE_HAS_METHOD (tty, make_frame_invisible);
|
|
210 CONSOLE_HAS_METHOD (tty, frame_visible_p);
|
149
|
211 CONSOLE_HAS_METHOD (tty, raise_frame);
|
|
212 CONSOLE_HAS_METHOD (tty, lower_frame);
|
0
|
213 }
|
|
214
|
|
215 void
|
|
216 vars_of_frame_tty (void)
|
|
217 {
|
|
218 DEFVAR_LISP ("default-tty-frame-plist", &Vdefault_tty_frame_plist /*
|
|
219 Plist of default frame-creation properties for tty frames.
|
|
220 These are in addition to and override what is specified in
|
|
221 `default-frame-plist', but are overridden by the arguments to the
|
|
222 particular call to `make-frame'.
|
|
223 */ );
|
|
224 Vdefault_tty_frame_plist = Qnil;
|
|
225
|
|
226 tty_console_methods->device_specific_frame_props =
|
|
227 &Vdefault_tty_frame_plist;
|
153
|
228
|
|
229 /* Tty frames are now supported. Advertise a feature to indicate this. */
|
|
230 Fprovide (intern ("tty-frames"));
|
0
|
231 }
|