comparison src/console.c @ 5495:1f0b15040456

Merge.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 01 May 2011 18:44:03 +0100
parents 308d34e9f07d
children 3d1f8f0e690f
comparison
equal deleted inserted replaced
5494:861f2601a38b 5495:1f0b15040456
1 /* The console object. 1 /* The console object.
2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. 2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
3 Copyright (C) 1996, 2002 Ben Wing. 3 Copyright (C) 1996, 2002, 2010 Ben Wing.
4 4
5 This file is part of XEmacs. 5 This file is part of XEmacs.
6 6
7 XEmacs is free software; you can redistribute it and/or modify it 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 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 9 Free Software Foundation, either version 3 of the License, or (at your
10 later version. 10 option) any later version.
11 11
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT 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 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details. 15 for more details.
16 16
17 You should have received a copy of the GNU General Public License 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 18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21 19
22 /* Synched up with: Not in FSF. */ 20 /* Synched up with: Not in FSF. */
23 21
24 /* Written by Ben Wing, late 1995?. 22 /* Written by Ben Wing, late 1995?.
25 suspend-console, set-input-mode, and related stuff largely based on 23 suspend-console, set-input-mode, and related stuff largely based on
39 #include "window.h" 37 #include "window.h"
40 38
41 #include "console-stream-impl.h" 39 #include "console-stream-impl.h"
42 #ifdef HAVE_TTY 40 #ifdef HAVE_TTY
43 #include "console-tty-impl.h" 41 #include "console-tty-impl.h"
44 #endif
45
46 #ifdef HAVE_TTY
47 #define USED_IF_TTY(decl) decl
48 #else
49 #define USED_IF_TTY(decl) UNUSED (decl)
50 #endif 42 #endif
51 43
52 Lisp_Object Vconsole_list, Vselected_console; 44 Lisp_Object Vconsole_list, Vselected_console;
53 45
54 Lisp_Object Vcreate_console_hook, Vdelete_console_hook; 46 Lisp_Object Vcreate_console_hook, Vdelete_console_hook;
167 int UNUSED (escapeflag)) 159 int UNUSED (escapeflag))
168 { 160 {
169 struct console *con = XCONSOLE (obj); 161 struct console *con = XCONSOLE (obj);
170 162
171 if (print_readably) 163 if (print_readably)
172 printing_unreadable_lcrecord (obj, XSTRING_DATA (con->name)); 164 printing_unreadable_lisp_object (obj, XSTRING_DATA (con->name));
173 165
174 write_fmt_string (printcharfun, "#<%s-console", 166 write_fmt_string (printcharfun, "#<%s-console",
175 !CONSOLE_LIVE_P (con) ? "dead" : CONSOLE_TYPE_NAME (con)); 167 !CONSOLE_LIVE_P (con) ? "dead" : CONSOLE_TYPE_NAME (con));
176 if (CONSOLE_LIVE_P (con) && !NILP (CONSOLE_CONNECTION (con))) 168 if (CONSOLE_LIVE_P (con) && !NILP (CONSOLE_CONNECTION (con)))
177 write_fmt_string_lisp (printcharfun, " on %S", 1, 169 write_fmt_string_lisp (printcharfun, " on %S", 1,
178 CONSOLE_CONNECTION (con)); 170 CONSOLE_CONNECTION (con));
179 write_fmt_string (printcharfun, " 0x%x>", con->header.uid); 171 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
180 } 172 }
181 173
182 DEFINE_LRECORD_IMPLEMENTATION ("console", console, 174 DEFINE_NODUMP_LISP_OBJECT ("console", console, mark_console,
183 0, /*dumpable-flag*/ 175 print_console, 0, 0, 0,
184 mark_console, print_console, 0, 0, 0, 176 console_description,
185 console_description, 177 struct console);
186 struct console);
187 178
188 179
189 static void 180 static void
190 set_quit_events (struct console *con, Lisp_Object key) 181 set_quit_events (struct console *con, Lisp_Object key)
191 { 182 {
198 } 189 }
199 190
200 static struct console * 191 static struct console *
201 allocate_console (Lisp_Object type) 192 allocate_console (Lisp_Object type)
202 { 193 {
203 Lisp_Object console; 194 Lisp_Object console = ALLOC_NORMAL_LISP_OBJECT (console);
204 struct console *con = ALLOC_LCRECORD_TYPE (struct console, &lrecord_console); 195 struct console *con = XCONSOLE (console);
205 struct gcpro gcpro1; 196 struct gcpro gcpro1;
206 197
207 COPY_LCRECORD (con, XCONSOLE (Vconsole_defaults)); 198 copy_lisp_object (console, Vconsole_defaults);
208 199
209 console = wrap_console (con);
210 GCPRO1 (console); 200 GCPRO1 (console);
211 201
212 con->conmeths = decode_console_type (type, ERROR_ME); 202 con->conmeths = decode_console_type (type, ERROR_ME);
213 con->contype = get_console_variant (type); 203 con->contype = get_console_variant (type);
214 con->command_builder = allocate_command_builder (console, 1); 204 con->command_builder = allocate_command_builder (console, 1);
667 } 657 }
668 658
669 static void 659 static void
670 nuke_all_console_slots (struct console *con, Lisp_Object zap) 660 nuke_all_console_slots (struct console *con, Lisp_Object zap)
671 { 661 {
672 ZERO_LCRECORD (con); 662 zero_nonsized_lisp_object (wrap_console (con));
673 663
674 #define MARKED_SLOT(x) con->x = zap; 664 #define MARKED_SLOT(x) con->x = zap;
675 #include "conslots.h" 665 #include "conslots.h"
676 } 666 }
677 667
1191 /************************************************************************/ 1181 /************************************************************************/
1192 1182
1193 void 1183 void
1194 syms_of_console (void) 1184 syms_of_console (void)
1195 { 1185 {
1196 INIT_LRECORD_IMPLEMENTATION (console); 1186 INIT_LISP_OBJECT (console);
1197 #ifdef NEW_GC 1187 #ifdef NEW_GC
1198 #ifdef HAVE_TTY 1188 #ifdef HAVE_TTY
1199 INIT_LRECORD_IMPLEMENTATION (tty_console); 1189 INIT_LISP_OBJECT (tty_console);
1200 #endif 1190 #endif
1201 INIT_LRECORD_IMPLEMENTATION (stream_console); 1191 INIT_LISP_OBJECT (stream_console);
1202 #endif /* NEW_GC */ 1192 #endif /* NEW_GC */
1203 1193
1204 DEFSUBR (Fvalid_console_type_p); 1194 DEFSUBR (Fvalid_console_type_p);
1205 DEFSUBR (Fconsole_type_list); 1195 DEFSUBR (Fconsole_type_list);
1206 DEFSUBR (Fcdfw_console); 1196 DEFSUBR (Fcdfw_console);
1324 /* The docstrings for DEFVAR_* are recorded externally by make-docfile. */ 1314 /* The docstrings for DEFVAR_* are recorded externally by make-docfile. */
1325 #ifdef NEW_GC 1315 #ifdef NEW_GC
1326 #define DEFVAR_CONSOLE_LOCAL_1(lname, field_name, forward_type, magic_fun) \ 1316 #define DEFVAR_CONSOLE_LOCAL_1(lname, field_name, forward_type, magic_fun) \
1327 do { \ 1317 do { \
1328 struct symbol_value_forward *I_hate_C = \ 1318 struct symbol_value_forward *I_hate_C = \
1329 alloc_lrecord_type (struct symbol_value_forward, \ 1319 XSYMBOL_VALUE_FORWARD (ALLOC_NORMAL_LISP_OBJECT (symbol_value_forward)); \
1330 &lrecord_symbol_value_forward); \ 1320 /*mcpro ((Lisp_Object) I_hate_C);*/ \
1331 /*mcpro ((Lisp_Object) I_hate_C);*/ \
1332 \ 1321 \
1333 I_hate_C->magic.value = &(console_local_flags.field_name); \ 1322 I_hate_C->magic.value = &(console_local_flags.field_name); \
1334 I_hate_C->magic.type = forward_type; \ 1323 I_hate_C->magic.type = forward_type; \
1335 I_hate_C->magicfun = magic_fun; \ 1324 I_hate_C->magicfun = magic_fun; \
1336 \ 1325 \
1358 1, /* mark bit */ \ 1347 1, /* mark bit */ \
1359 1, /* c_readonly bit */ \ 1348 1, /* c_readonly bit */ \
1360 1 /* lisp_readonly bit */ \ 1349 1 /* lisp_readonly bit */ \
1361 }, \ 1350 }, \
1362 0, /* next */ \ 1351 0, /* next */ \
1363 0, /* uid */ \
1364 0 /* free */ \
1365 }, \ 1352 }, \
1366 &(console_local_flags.field_name), \ 1353 &(console_local_flags.field_name), \
1367 forward_type \ 1354 forward_type \
1368 }, \ 1355 }, \
1369 magicfun \ 1356 magicfun \
1402 common_init_complex_vars_of_console (void) 1389 common_init_complex_vars_of_console (void)
1403 { 1390 {
1404 /* Make sure all markable slots in console_defaults 1391 /* Make sure all markable slots in console_defaults
1405 are initialized reasonably, so mark_console won't choke. 1392 are initialized reasonably, so mark_console won't choke.
1406 */ 1393 */
1407 struct console *defs = ALLOC_LCRECORD_TYPE (struct console, &lrecord_console); 1394 Lisp_Object defobj = ALLOC_NORMAL_LISP_OBJECT (console);
1408 struct console *syms = ALLOC_LCRECORD_TYPE (struct console, &lrecord_console); 1395 struct console *defs = XCONSOLE (defobj);
1396 Lisp_Object symobj = ALLOC_NORMAL_LISP_OBJECT (console);
1397 struct console *syms = XCONSOLE (symobj);
1409 1398
1410 staticpro_nodump (&Vconsole_defaults); 1399 staticpro_nodump (&Vconsole_defaults);
1411 staticpro_nodump (&Vconsole_local_symbols); 1400 staticpro_nodump (&Vconsole_local_symbols);
1412 Vconsole_defaults = wrap_console (defs); 1401 Vconsole_defaults = defobj;
1413 Vconsole_local_symbols = wrap_console (syms); 1402 Vconsole_local_symbols = symobj;
1414 1403
1415 nuke_all_console_slots (syms, Qnil); 1404 nuke_all_console_slots (syms, Qnil);
1416 nuke_all_console_slots (defs, Qnil); 1405 nuke_all_console_slots (defs, Qnil);
1417 1406
1418 /* Set up the non-nil default values of various console slots. 1407 /* Set up the non-nil default values of various console slots.
1446 The local flag is a bit that is used in the console 1435 The local flag is a bit that is used in the console
1447 to say that it has its own local value for the slot. 1436 to say that it has its own local value for the slot.
1448 The local flag bits are in the local_var_flags slot of the 1437 The local flag bits are in the local_var_flags slot of the
1449 console. */ 1438 console. */
1450 1439
1440 set_lheader_implementation ((struct lrecord_header *)
1441 &console_local_flags, &lrecord_console);
1451 nuke_all_console_slots (&console_local_flags, make_int (-2)); 1442 nuke_all_console_slots (&console_local_flags, make_int (-2));
1452 console_local_flags.defining_kbd_macro = always_local_resettable; 1443 console_local_flags.defining_kbd_macro = always_local_resettable;
1453 console_local_flags.last_kbd_macro = always_local_resettable; 1444 console_local_flags.last_kbd_macro = always_local_resettable;
1454 console_local_flags.prefix_arg = always_local_resettable; 1445 console_local_flags.prefix_arg = always_local_resettable;
1455 console_local_flags.default_minibuffer_frame = always_local_resettable; 1446 console_local_flags.default_minibuffer_frame = always_local_resettable;
1596 */ ); 1587 */ );
1597 1588
1598 /* Check for DEFVAR_CONSOLE_LOCAL without initializing the corresponding 1589 /* Check for DEFVAR_CONSOLE_LOCAL without initializing the corresponding
1599 slot of console_local_flags and vice-versa. Must be done after all 1590 slot of console_local_flags and vice-versa. Must be done after all
1600 DEFVAR_CONSOLE_LOCAL() calls. */ 1591 DEFVAR_CONSOLE_LOCAL() calls. */
1601 #define MARKED_SLOT(slot) \ 1592 #define MARKED_SLOT(slot) \
1602 if ((XINT (console_local_flags.slot) != -2 && \ 1593 assert ((XINT (console_local_flags.slot) != -2 && \
1603 XINT (console_local_flags.slot) != -3) \ 1594 XINT (console_local_flags.slot) != -3) \
1604 != !(NILP (XCONSOLE (Vconsole_local_symbols)->slot))) \ 1595 == !(NILP (XCONSOLE (Vconsole_local_symbols)->slot)));
1605 ABORT ();
1606 #include "conslots.h" 1596 #include "conslots.h"
1607 } 1597 }