1 /* TTY frame functions.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996 Ben Wing.
4 Copyright (C) 1997 Free Software Foundation, Inc.
6 This file is part of SXEmacs
8 SXEmacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 SXEmacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* Synched up with: Not in FSF. */
24 /* Written by Ben Wing.
25 Multi-frame support added by Hrvoje Niksic. */
30 #include "console-tty.h"
33 #include "events/events.h"
35 /* Default properties to use when creating frames. */
36 Lisp_Object Vdefault_tty_frame_plist;
38 static void tty_raise_frame(struct frame *);
40 static void tty_init_frame_1(struct frame *f, Lisp_Object props)
42 struct device *d = XDEVICE(FRAME_DEVICE(f));
43 struct console *c = XCONSOLE(DEVICE_CONSOLE(d));
45 ++CONSOLE_TTY_DATA(c)->frame_count;
46 f->order_count = CONSOLE_TTY_DATA(c)->frame_count;
47 f->height = CONSOLE_TTY_DATA(c)->height;
48 f->width = CONSOLE_TTY_DATA(c)->width;
51 static void tty_init_frame_3(struct frame *f)
56 static void tty_select_frame_if_unhidden(Lisp_Object frame)
58 if (FRAME_REPAINT_P(XFRAME(frame)))
59 select_frame_1(frame);
62 static void tty_schedule_frame_select(struct frame *f)
67 enqueue_magic_eval_event(tty_select_frame_if_unhidden, frame);
71 tty_after_init_frame(struct frame *f, int first_on_device, int first_on_console)
74 call1(Qinit_post_tty_win, FRAME_CONSOLE(f));
77 /* Change from withdrawn state to mapped state. */
78 static void tty_make_frame_visible(struct frame *f)
80 if (!FRAME_VISIBLE_P(f)) {
85 /* Change from mapped state to withdrawn state. */
86 static void tty_make_frame_invisible(struct frame *f)
91 static void tty_make_frame_hidden(struct frame *f)
96 static void tty_make_frame_unhidden(struct frame *f)
98 if (!FRAME_REPAINT_P(f)) {
104 static int tty_frame_visible_p(struct frame *f)
106 return FRAME_VISIBLE_P(f);
109 static void tty_raise_frame_no_select(struct frame *f)
111 LIST_LOOP_2(frame, DEVICE_FRAME_LIST(XDEVICE(FRAME_DEVICE(f)))) {
112 struct frame *o = XFRAME(frame);
113 if (o != f && FRAME_REPAINT_P(o)) {
114 tty_make_frame_hidden(o);
118 tty_make_frame_unhidden(f);
121 static void tty_raise_frame(struct frame *f)
123 tty_raise_frame_no_select(f);
124 tty_schedule_frame_select(f);
127 static void tty_lower_frame(struct frame *f)
129 Lisp_Object frame_list = DEVICE_FRAME_LIST(XDEVICE(FRAME_DEVICE(f)));
130 Lisp_Object tail, new;
132 if (!FRAME_REPAINT_P(f))
135 LIST_LOOP(tail, frame_list) {
136 if (f == XFRAME(XCAR(tail)))
140 /* To lower this frame, another frame has to be raised. Return if
141 there is no other frame. */
142 if (NILP(tail) && EQ(frame_list, tail))
145 tty_make_frame_hidden(f);
146 if (CONSP(XCDR(tail)))
147 new = XCAR(XCDR(tail));
149 new = XCAR(frame_list);
150 tty_make_frame_unhidden(XFRAME(new));
151 tty_schedule_frame_select(XFRAME(new));
154 static void tty_delete_frame(struct frame *f)
156 struct device *d = XDEVICE(FRAME_DEVICE(f));
158 if (!NILP(DEVICE_SELECTED_FRAME(d)))
159 tty_raise_frame(XFRAME(DEVICE_SELECTED_FRAME(d)));
162 /************************************************************************/
164 /************************************************************************/
166 void console_type_create_frame_tty(void)
168 CONSOLE_HAS_METHOD(tty, init_frame_1);
169 CONSOLE_HAS_METHOD(tty, init_frame_3);
170 CONSOLE_HAS_METHOD(tty, after_init_frame);
171 CONSOLE_HAS_METHOD(tty, make_frame_visible);
172 CONSOLE_HAS_METHOD(tty, make_frame_invisible);
173 CONSOLE_HAS_METHOD(tty, frame_visible_p);
174 CONSOLE_HAS_METHOD(tty, raise_frame);
175 CONSOLE_HAS_METHOD(tty, lower_frame);
176 CONSOLE_HAS_METHOD(tty, delete_frame);
179 void vars_of_frame_tty(void)
181 DEFVAR_LISP("default-tty-frame-plist", &Vdefault_tty_frame_plist /*
182 Plist of default frame-creation properties for tty frames.
183 These are in addition to and override what is specified in
184 `default-frame-plist', but are overridden by the arguments to the
185 particular call to `make-frame'.
187 Vdefault_tty_frame_plist = Qnil;
189 tty_console_methods->device_specific_frame_props =
190 &Vdefault_tty_frame_plist;
192 /* Tty frames are now supported. Advertise a feature to indicate this. */
193 Fprovide(intern("tty-frames"));