Mercurial > hg > xemacs-beta
annotate src/console.c @ 5486:58e320bde005
Handle redisplay edge case.
With motion events when entering a frame and the minibuffer is
active, row and column can be zero, and there aren't any runes.
| author | Mike Kupfer <mike.kupfer@xemacs.org> |
|---|---|
| date | Sat, 30 Apr 2011 13:30:47 +0900 |
| parents | 308d34e9f07d |
| children | 3d1f8f0e690f |
| rev | line source |
|---|---|
| 428 | 1 /* The console object. |
| 2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. | |
| 5046 | 3 Copyright (C) 1996, 2002, 2010 Ben Wing. |
| 428 | 4 |
| 5 This file is part of XEmacs. | |
| 6 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5146
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
| 428 | 8 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5146
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5146
diff
changeset
|
10 option) any later version. |
| 428 | 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 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5146
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 428 | 19 |
| 20 /* Synched up with: Not in FSF. */ | |
| 21 | |
| 853 | 22 /* Written by Ben Wing, late 1995?. |
| 23 suspend-console, set-input-mode, and related stuff largely based on | |
| 24 existing code. | |
| 25 */ | |
| 428 | 26 |
| 27 #include <config.h> | |
| 28 #include "lisp.h" | |
| 29 | |
| 30 #include "buffer.h" | |
| 872 | 31 #include "console-impl.h" |
| 32 #include "device-impl.h" | |
| 428 | 33 #include "events.h" |
| 872 | 34 #include "frame-impl.h" |
| 428 | 35 #include "redisplay.h" |
| 36 #include "sysdep.h" | |
| 37 #include "window.h" | |
| 38 | |
| 1204 | 39 #include "console-stream-impl.h" |
| 872 | 40 #ifdef HAVE_TTY |
| 41 #include "console-tty-impl.h" | |
| 42 #endif | |
| 800 | 43 |
| 428 | 44 Lisp_Object Vconsole_list, Vselected_console; |
| 45 | |
| 46 Lisp_Object Vcreate_console_hook, Vdelete_console_hook; | |
| 47 | |
| 48 Lisp_Object Qconsolep, Qconsole_live_p; | |
| 49 Lisp_Object Qcreate_console_hook; | |
| 50 Lisp_Object Qdelete_console_hook; | |
| 51 | |
| 52 Lisp_Object Qsuspend_hook; | |
| 53 Lisp_Object Qsuspend_resume_hook; | |
| 54 | |
| 55 /* This structure holds the default values of the console-local | |
| 56 variables defined with DEFVAR_CONSOLE_LOCAL, that have special | |
| 57 slots in each console. The default value occupies the same slot | |
| 58 in this structure as an individual console's value occupies in | |
| 59 that console. Setting the default value also goes through the | |
| 60 list of consoles and stores into each console that does not say | |
| 61 it has a local value. */ | |
| 62 Lisp_Object Vconsole_defaults; | |
| 63 static void *console_defaults_saved_slots; | |
| 64 | |
| 65 /* This structure marks which slots in a console have corresponding | |
| 66 default values in console_defaults. | |
| 67 Each such slot has a nonzero value in this structure. | |
| 68 The value has only one nonzero bit. | |
| 69 | |
| 70 When a console has its own local value for a slot, | |
| 71 the bit for that slot (found in the same slot in this structure) | |
| 72 is turned on in the console's local_var_flags slot. | |
| 73 | |
| 74 If a slot in this structure is 0, then there is a DEFVAR_CONSOLE_LOCAL | |
| 75 for the slot, but there is no default value for it; the corresponding | |
| 76 slot in console_defaults is not used except to initialize newly-created | |
| 77 consoles. | |
| 78 | |
| 79 If a slot is -1, then there is a DEFVAR_CONSOLE_LOCAL for it | |
| 80 as well as a default value which is used to initialize newly-created | |
| 81 consoles and as a reset-value when local-vars are killed. | |
| 82 | |
| 83 If a slot is -2, there is no DEFVAR_CONSOLE_LOCAL for it. | |
| 84 (The slot is always local, but there's no lisp variable for it.) | |
| 85 The default value is only used to initialize newly-creation consoles. | |
| 86 | |
| 87 If a slot is -3, then there is no DEFVAR_CONSOLE_LOCAL for it but | |
| 88 there is a default which is used to initialize newly-creation | |
| 89 consoles and as a reset-value when local-vars are killed. | |
| 90 | |
| 91 | |
| 92 */ | |
| 93 struct console console_local_flags; | |
| 94 | |
| 95 /* This structure holds the names of symbols whose values may be | |
| 96 console-local. It is indexed and accessed in the same way as the above. */ | |
| 97 static Lisp_Object Vconsole_local_symbols; | |
| 98 static void *console_local_symbols_saved_slots; | |
| 99 | |
| 100 DEFINE_CONSOLE_TYPE (dead); | |
| 101 | |
| 102 Lisp_Object Vconsole_type_list; | |
| 103 | |
| 104 console_type_entry_dynarr *the_console_type_entry_dynarr; | |
| 105 | |
| 106 | |
| 934 | 107 |
| 1204 | 108 static const struct memory_description console_data_description_1 []= { |
| 109 #ifdef HAVE_TTY | |
| 3092 | 110 #ifdef NEW_GC |
| 111 { XD_LISP_OBJECT, tty_console }, | |
| 112 #else /* not NEW_GC */ | |
| 2551 | 113 { XD_BLOCK_PTR, tty_console, 1, { &tty_console_data_description} }, |
| 3092 | 114 #endif /* not NEW_GC */ |
| 1204 | 115 #endif |
| 3092 | 116 #ifdef NEW_GC |
| 117 { XD_LISP_OBJECT, stream_console }, | |
| 118 #else /* not NEW_GC */ | |
| 2551 | 119 { XD_BLOCK_PTR, stream_console, 1, { &stream_console_data_description} }, |
| 3092 | 120 #endif /* not NEW_GC */ |
| 934 | 121 { XD_END } |
| 122 }; | |
| 123 | |
| 1204 | 124 static const struct sized_memory_description console_data_description = { |
| 125 sizeof (void *), console_data_description_1 | |
| 934 | 126 }; |
| 127 | |
| 1204 | 128 static const struct memory_description console_description [] = { |
| 934 | 129 { XD_INT, offsetof (struct console, contype) }, |
| 1204 | 130 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (struct console, x) }, |
| 131 #include "conslots.h" | |
| 2367 | 132 { XD_BLOCK_PTR, offsetof (struct console, conmeths), 1, |
| 2551 | 133 { &console_methods_description } }, |
| 934 | 134 { XD_UNION, offsetof (struct console, console_data), |
| 2551 | 135 XD_INDIRECT (0, 0), { &console_data_description } }, |
| 934 | 136 { XD_END } |
| 137 }; | |
| 138 | |
| 428 | 139 static Lisp_Object |
| 140 mark_console (Lisp_Object obj) | |
| 141 { | |
| 142 struct console *con = XCONSOLE (obj); | |
| 143 | |
| 1204 | 144 #define MARKED_SLOT(x) mark_object (con->x); |
| 428 | 145 #include "conslots.h" |
| 146 | |
| 147 /* Can be zero for Vconsole_defaults, Vconsole_local_symbols */ | |
| 148 if (con->conmeths) | |
| 149 { | |
| 150 mark_object (con->conmeths->symbol); | |
| 151 MAYBE_CONMETH (con, mark_console, (con)); | |
| 152 } | |
| 153 | |
| 154 return Qnil; | |
| 155 } | |
| 156 | |
| 157 static void | |
| 2286 | 158 print_console (Lisp_Object obj, Lisp_Object printcharfun, |
| 159 int UNUSED (escapeflag)) | |
| 428 | 160 { |
| 161 struct console *con = XCONSOLE (obj); | |
| 162 | |
| 163 if (print_readably) | |
|
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
164 printing_unreadable_lisp_object (obj, XSTRING_DATA (con->name)); |
| 428 | 165 |
| 800 | 166 write_fmt_string (printcharfun, "#<%s-console", |
| 167 !CONSOLE_LIVE_P (con) ? "dead" : CONSOLE_TYPE_NAME (con)); | |
| 440 | 168 if (CONSOLE_LIVE_P (con) && !NILP (CONSOLE_CONNECTION (con))) |
| 800 | 169 write_fmt_string_lisp (printcharfun, " on %S", 1, |
| 170 CONSOLE_CONNECTION (con)); | |
|
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5142
diff
changeset
|
171 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); |
| 428 | 172 } |
| 173 | |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
174 DEFINE_NODUMP_LISP_OBJECT ("console", console, mark_console, |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
175 print_console, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
176 console_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
177 struct console); |
| 428 | 178 |
| 1204 | 179 |
| 180 static void | |
| 181 set_quit_events (struct console *con, Lisp_Object key) | |
| 182 { | |
| 183 /* Make sure to run Fcharacter_to_event() *BEFORE* setting QUIT_CHAR, | |
| 184 so that nothing is changed when invalid values trigger an error! */ | |
| 185 con->quit_event = Fcharacter_to_event (key, Qnil, wrap_console (con), Qnil); | |
| 186 con->quit_char = key; | |
| 187 con->critical_quit_event = Fcopy_event (con->quit_event, Qnil); | |
| 188 upshift_event (con->critical_quit_event); | |
| 189 } | |
| 190 | |
| 428 | 191 static struct console * |
| 1204 | 192 allocate_console (Lisp_Object type) |
| 428 | 193 { |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
194 Lisp_Object console = ALLOC_NORMAL_LISP_OBJECT (console); |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
195 struct console *con = XCONSOLE (console); |
| 428 | 196 struct gcpro gcpro1; |
| 197 | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
198 copy_lisp_object (console, Vconsole_defaults); |
| 428 | 199 |
| 200 GCPRO1 (console); | |
| 201 | |
| 1204 | 202 con->conmeths = decode_console_type (type, ERROR_ME); |
| 203 con->contype = get_console_variant (type); | |
| 771 | 204 con->command_builder = allocate_command_builder (console, 1); |
| 428 | 205 con->function_key_map = Fmake_sparse_keymap (Qnil); |
| 1204 | 206 set_quit_events (con, make_char (7)); /* C-g */ |
| 428 | 207 |
| 208 UNGCPRO; | |
| 209 return con; | |
| 210 } | |
| 211 | |
| 212 struct console * | |
| 213 decode_console (Lisp_Object console) | |
| 214 { | |
| 215 if (NILP (console)) | |
| 216 console = Fselected_console (); | |
| 217 /* quietly accept devices and frames for the console arg */ | |
| 218 if (DEVICEP (console) || FRAMEP (console)) | |
| 219 console = DEVICE_CONSOLE (decode_device (console)); | |
| 220 CHECK_LIVE_CONSOLE (console); | |
| 221 return XCONSOLE (console); | |
| 222 } | |
| 223 | |
| 224 | |
| 225 struct console_methods * | |
| 578 | 226 decode_console_type (Lisp_Object type, Error_Behavior errb) |
| 428 | 227 { |
| 228 int i; | |
| 229 | |
| 230 for (i = 0; i < Dynarr_length (the_console_type_entry_dynarr); i++) | |
| 231 if (EQ (type, Dynarr_at (the_console_type_entry_dynarr, i).symbol)) | |
| 232 return Dynarr_at (the_console_type_entry_dynarr, i).meths; | |
| 233 | |
| 563 | 234 maybe_invalid_constant ("Invalid console type", type, Qconsole, errb); |
| 428 | 235 |
| 236 return 0; | |
| 237 } | |
| 238 | |
| 934 | 239 enum console_variant |
| 240 get_console_variant (Lisp_Object type) | |
| 241 { | |
| 242 if (EQ (type, Qtty)) | |
| 1204 | 243 return tty_console; |
| 934 | 244 |
| 245 if (EQ (type, Qgtk)) | |
| 1204 | 246 return gtk_console; |
| 934 | 247 |
| 248 if (EQ (type, Qx)) | |
| 1204 | 249 return x_console; |
| 934 | 250 |
| 251 if (EQ (type, Qmswindows)) | |
| 1204 | 252 return mswindows_console; |
| 934 | 253 |
| 1346 | 254 if (EQ (type, Qmsprinter)) |
| 255 return msprinter_console; | |
| 256 | |
| 934 | 257 if (EQ (type, Qstream)) |
| 1204 | 258 return stream_console; |
| 934 | 259 |
| 2500 | 260 ABORT (); /* should never happen */ |
| 934 | 261 return dead_console; |
| 262 } | |
| 263 | |
| 428 | 264 int |
| 265 valid_console_type_p (Lisp_Object type) | |
| 266 { | |
| 267 return decode_console_type (type, ERROR_ME_NOT) != 0; | |
| 268 } | |
| 269 | |
| 270 DEFUN ("valid-console-type-p", Fvalid_console_type_p, 1, 1, 0, /* | |
| 444 | 271 Return t if CONSOLE-TYPE is a valid console type. |
| 3025 | 272 Valid types are `x', `tty', `mswindows', `msprinter', `gtk', and `stream'. |
| 428 | 273 */ |
| 274 (console_type)) | |
| 275 { | |
| 276 return valid_console_type_p (console_type) ? Qt : Qnil; | |
| 277 } | |
| 278 | |
| 279 DEFUN ("console-type-list", Fconsole_type_list, 0, 0, 0, /* | |
| 280 Return a list of valid console types. | |
| 281 */ | |
| 282 ()) | |
| 283 { | |
| 284 return Fcopy_sequence (Vconsole_type_list); | |
| 285 } | |
| 286 | |
| 287 DEFUN ("cdfw-console", Fcdfw_console, 1, 1, 0, /* | |
| 288 Given a console, device, frame, or window, return the associated console. | |
| 289 Return nil otherwise. | |
| 290 */ | |
| 444 | 291 (object)) |
| 428 | 292 { |
| 444 | 293 return CDFW_CONSOLE (object); |
| 428 | 294 } |
| 295 | |
| 872 | 296 int |
| 297 console_live_p (struct console *c) | |
| 298 { | |
| 299 return CONSOLE_LIVE_P (c); | |
| 300 } | |
| 301 | |
| 302 Lisp_Object | |
| 303 console_device_list (struct console *c) | |
| 304 { | |
| 305 return CONSOLE_DEVICE_LIST (c); | |
| 306 } | |
| 307 | |
| 428 | 308 |
| 309 DEFUN ("selected-console", Fselected_console, 0, 0, 0, /* | |
| 310 Return the console which is currently active. | |
| 311 */ | |
| 312 ()) | |
| 313 { | |
| 314 return Vselected_console; | |
| 315 } | |
| 316 | |
| 317 /* Called from selected_device_1(), called from selected_frame_1(), | |
| 318 called from Fselect_window() */ | |
| 319 void | |
| 320 select_console_1 (Lisp_Object console) | |
| 321 { | |
| 322 /* perhaps this should do something more complicated */ | |
| 323 Vselected_console = console; | |
| 324 | |
| 325 /* #### Schedule this to be removed in 19.14 */ | |
| 326 #ifdef HAVE_X_WINDOWS | |
| 327 if (CONSOLE_X_P (XCONSOLE (console))) | |
| 328 Vwindow_system = Qx; | |
| 329 else | |
| 330 #endif | |
| 462 | 331 #ifdef HAVE_GTK |
| 332 if (CONSOLE_GTK_P (XCONSOLE (console))) | |
| 333 Vwindow_system = Qgtk; | |
| 334 else | |
| 335 #endif | |
| 428 | 336 #ifdef HAVE_MS_WINDOWS |
| 337 if (CONSOLE_MSWINDOWS_P (XCONSOLE (console))) | |
| 338 Vwindow_system = Qmswindows; | |
| 339 else | |
| 340 #endif | |
| 341 Vwindow_system = Qnil; | |
| 342 } | |
| 343 | |
| 344 DEFUN ("select-console", Fselect_console, 1, 1, 0, /* | |
| 345 Select the console CONSOLE. | |
| 346 Subsequent editing commands apply to its selected device, selected frame, | |
| 347 and selected window. The selection of CONSOLE lasts until the next time | |
| 348 the user does something to select a different console, or until the next | |
| 349 time this function is called. | |
| 350 */ | |
| 351 (console)) | |
| 352 { | |
| 353 Lisp_Object device; | |
| 354 | |
| 355 CHECK_LIVE_CONSOLE (console); | |
| 356 | |
| 357 device = CONSOLE_SELECTED_DEVICE (XCONSOLE (console)); | |
| 358 if (!NILP (device)) | |
| 359 { | |
| 360 struct device *d = XDEVICE (device); | |
| 361 Lisp_Object frame = DEVICE_SELECTED_FRAME (d); | |
| 362 if (!NILP (frame)) | |
| 363 { | |
| 364 struct frame *f = XFRAME(frame); | |
| 365 Fselect_window (FRAME_SELECTED_WINDOW (f), Qnil); | |
| 366 } | |
| 367 else | |
| 563 | 368 invalid_operation ("Can't select console with no frames", Qunbound); |
| 428 | 369 } |
| 370 else | |
| 563 | 371 invalid_operation ("Can't select a console with no devices", Qunbound); |
| 428 | 372 return Qnil; |
| 373 } | |
| 374 | |
| 375 void | |
| 376 set_console_last_nonminibuf_frame (struct console *con, | |
| 377 Lisp_Object frame) | |
| 378 { | |
| 379 con->last_nonminibuf_frame = frame; | |
| 380 } | |
| 381 | |
| 382 DEFUN ("consolep", Fconsolep, 1, 1, 0, /* | |
| 383 Return non-nil if OBJECT is a console. | |
| 384 */ | |
| 385 (object)) | |
| 386 { | |
| 387 return CONSOLEP (object) ? Qt : Qnil; | |
| 388 } | |
| 389 | |
| 390 DEFUN ("console-live-p", Fconsole_live_p, 1, 1, 0, /* | |
| 391 Return non-nil if OBJECT is a console that has not been deleted. | |
| 392 */ | |
| 393 (object)) | |
| 394 { | |
| 395 return CONSOLEP (object) && CONSOLE_LIVE_P (XCONSOLE (object)) ? Qt : Qnil; | |
| 396 } | |
| 397 | |
| 398 DEFUN ("console-type", Fconsole_type, 0, 1, 0, /* | |
| 444 | 399 Return the console type (e.g. `x' or `tty') of CONSOLE. |
| 1346 | 400 Value is |
| 401 `tty' for a tty console (a character-only terminal), | |
| 428 | 402 `x' for a console that is an X display, |
| 1346 | 403 `mswindows' for a console that is an MS Windows connection, |
| 404 `msprinter' for a console that is an MS Windows printer connection, | |
| 405 `gtk' for a console that is a GTK connection, | |
| 428 | 406 `stream' for a stream console (which acts like a stdio stream), and |
| 407 `dead' for a deleted console. | |
| 408 */ | |
| 409 (console)) | |
| 410 { | |
| 411 /* don't call decode_console() because we want to allow for dead | |
| 412 consoles. */ | |
| 413 if (NILP (console)) | |
| 414 console = Fselected_console (); | |
| 415 CHECK_CONSOLE (console); | |
| 416 return CONSOLE_TYPE (XCONSOLE (console)); | |
| 417 } | |
| 418 | |
| 419 DEFUN ("console-name", Fconsole_name, 0, 1, 0, /* | |
| 444 | 420 Return the name of CONSOLE. |
| 428 | 421 */ |
| 422 (console)) | |
| 423 { | |
| 424 return CONSOLE_NAME (decode_console (console)); | |
| 425 } | |
| 426 | |
| 427 DEFUN ("console-connection", Fconsole_connection, 0, 1, 0, /* | |
| 428 Return the connection of the specified console. | |
| 429 CONSOLE defaults to the selected console if omitted. | |
| 430 */ | |
| 431 (console)) | |
| 432 { | |
| 433 return CONSOLE_CONNECTION (decode_console (console)); | |
| 434 } | |
| 435 | |
| 436 static Lisp_Object | |
| 437 semi_canonicalize_console_connection (struct console_methods *meths, | |
| 578 | 438 Lisp_Object name, Error_Behavior errb) |
| 428 | 439 { |
| 440 | 440 if (HAS_CONTYPE_METH_P (meths, semi_canonicalize_console_connection)) |
| 441 return CONTYPE_METH (meths, semi_canonicalize_console_connection, | |
| 442 (name, errb)); | |
| 443 else | |
| 444 return CONTYPE_METH_OR_GIVEN (meths, canonicalize_console_connection, | |
| 445 (name, errb), name); | |
| 428 | 446 } |
| 447 | |
| 448 static Lisp_Object | |
| 449 canonicalize_console_connection (struct console_methods *meths, | |
| 578 | 450 Lisp_Object name, Error_Behavior errb) |
| 428 | 451 { |
| 440 | 452 if (HAS_CONTYPE_METH_P (meths, canonicalize_console_connection)) |
| 453 return CONTYPE_METH (meths, canonicalize_console_connection, | |
| 454 (name, errb)); | |
| 455 else | |
| 456 return CONTYPE_METH_OR_GIVEN (meths, semi_canonicalize_console_connection, | |
| 457 (name, errb), name); | |
| 428 | 458 } |
| 459 | |
| 460 static Lisp_Object | |
| 461 find_console_of_type (struct console_methods *meths, Lisp_Object canon) | |
| 462 { | |
| 463 Lisp_Object concons; | |
| 464 | |
| 465 CONSOLE_LOOP (concons) | |
| 466 { | |
| 467 Lisp_Object console = XCAR (concons); | |
| 468 | |
| 469 if (EQ (CONMETH_TYPE (meths), CONSOLE_TYPE (XCONSOLE (console))) | |
| 470 && internal_equal (CONSOLE_CANON_CONNECTION (XCONSOLE (console)), | |
| 471 canon, 0)) | |
| 472 return console; | |
| 473 } | |
| 474 | |
| 475 return Qnil; | |
| 476 } | |
| 477 | |
| 478 DEFUN ("find-console", Ffind_console, 1, 2, 0, /* | |
| 479 Look for an existing console attached to connection CONNECTION. | |
| 480 Return the console if found; otherwise, return nil. | |
| 481 | |
| 482 If TYPE is specified, only return consoles of that type; otherwise, | |
| 483 return consoles of any type. (It is possible, although unlikely, | |
| 484 that two consoles of different types could have the same connection | |
| 485 name; in such a case, the first console found is returned.) | |
| 486 */ | |
| 487 (connection, type)) | |
| 488 { | |
| 489 Lisp_Object canon = Qnil; | |
| 490 struct gcpro gcpro1; | |
| 491 | |
| 492 GCPRO1 (canon); | |
| 493 | |
| 494 if (!NILP (type)) | |
| 495 { | |
| 496 struct console_methods *conmeths = decode_console_type (type, ERROR_ME); | |
| 497 canon = canonicalize_console_connection (conmeths, connection, | |
| 498 ERROR_ME_NOT); | |
| 499 if (UNBOUNDP (canon)) | |
| 500 RETURN_UNGCPRO (Qnil); | |
| 501 | |
| 502 RETURN_UNGCPRO (find_console_of_type (conmeths, canon)); | |
| 503 } | |
| 504 else | |
| 505 { | |
| 506 int i; | |
| 507 | |
| 508 for (i = 0; i < Dynarr_length (the_console_type_entry_dynarr); i++) | |
| 509 { | |
| 510 struct console_methods *conmeths = | |
| 511 Dynarr_at (the_console_type_entry_dynarr, i).meths; | |
| 512 canon = canonicalize_console_connection (conmeths, connection, | |
| 513 ERROR_ME_NOT); | |
| 514 if (!UNBOUNDP (canon)) | |
| 515 { | |
| 516 Lisp_Object console = find_console_of_type (conmeths, canon); | |
| 517 if (!NILP (console)) | |
| 518 RETURN_UNGCPRO (console); | |
| 519 } | |
| 520 } | |
| 521 | |
| 522 RETURN_UNGCPRO (Qnil); | |
| 523 } | |
| 524 } | |
| 525 | |
| 526 DEFUN ("get-console", Fget_console, 1, 2, 0, /* | |
| 527 Look for an existing console attached to connection CONNECTION. | |
| 528 Return the console if found; otherwise, signal an error. | |
| 529 | |
| 530 If TYPE is specified, only return consoles of that type; otherwise, | |
| 531 return consoles of any type. (It is possible, although unlikely, | |
| 532 that two consoles of different types could have the same connection | |
| 533 name; in such a case, the first console found is returned.) | |
| 534 */ | |
| 535 (connection, type)) | |
| 536 { | |
| 537 Lisp_Object console = Ffind_console (connection, type); | |
| 538 if (NILP (console)) | |
| 539 { | |
| 540 if (NILP (type)) | |
| 563 | 541 invalid_argument ("No such console", connection); |
| 428 | 542 else |
| 563 | 543 invalid_argument_2 ("No such console", type, connection); |
| 428 | 544 } |
| 545 return console; | |
| 546 } | |
| 547 | |
| 548 Lisp_Object | |
| 549 create_console (Lisp_Object name, Lisp_Object type, Lisp_Object connection, | |
| 550 Lisp_Object props) | |
| 551 { | |
| 552 /* This function can GC */ | |
| 553 struct console *con; | |
| 554 Lisp_Object console; | |
| 555 struct gcpro gcpro1; | |
| 556 | |
| 557 console = Ffind_console (connection, type); | |
| 558 if (!NILP (console)) | |
| 559 return console; | |
| 560 | |
| 1204 | 561 con = allocate_console (type); |
| 793 | 562 console = wrap_console (con); |
| 428 | 563 |
| 564 GCPRO1 (console); | |
| 565 | |
| 566 CONSOLE_NAME (con) = name; | |
| 567 CONSOLE_CONNECTION (con) = | |
| 568 semi_canonicalize_console_connection (con->conmeths, connection, | |
| 569 ERROR_ME); | |
| 570 CONSOLE_CANON_CONNECTION (con) = | |
| 571 canonicalize_console_connection (con->conmeths, connection, | |
| 572 ERROR_ME); | |
| 573 | |
| 574 MAYBE_CONMETH (con, init_console, (con, props)); | |
| 575 | |
| 576 /* Do it this way so that the console list is in order of creation */ | |
| 577 Vconsole_list = nconc2 (Vconsole_list, Fcons (console, Qnil)); | |
| 853 | 578 note_object_created (console); |
| 428 | 579 |
| 440 | 580 if (CONMETH_OR_GIVEN (con, initially_selected_for_input, (con), 0)) |
| 428 | 581 event_stream_select_console (con); |
| 582 | |
| 583 UNGCPRO; | |
| 584 return console; | |
| 585 } | |
| 586 | |
| 587 void | |
| 588 add_entry_to_console_type_list (Lisp_Object symbol, | |
| 589 struct console_methods *meths) | |
| 590 { | |
| 591 struct console_type_entry entry; | |
| 592 | |
| 593 entry.symbol = symbol; | |
| 594 entry.meths = meths; | |
| 595 Dynarr_add (the_console_type_entry_dynarr, entry); | |
| 596 Vconsole_type_list = Fcons (symbol, Vconsole_type_list); | |
| 597 } | |
| 598 | |
| 599 /* find a console other than the selected one. Prefer non-stream | |
| 600 consoles over stream consoles. */ | |
| 601 | |
| 602 static Lisp_Object | |
| 603 find_other_console (Lisp_Object console) | |
| 604 { | |
| 605 Lisp_Object concons; | |
| 606 | |
| 607 /* look for a non-stream console */ | |
| 608 CONSOLE_LOOP (concons) | |
| 609 { | |
| 610 Lisp_Object con = XCAR (concons); | |
| 611 if (!CONSOLE_STREAM_P (XCONSOLE (con)) | |
| 612 && !EQ (con, console) | |
| 613 && !NILP (CONSOLE_SELECTED_DEVICE (XCONSOLE (con))) | |
| 614 && !NILP (DEVICE_SELECTED_FRAME | |
| 615 (XDEVICE (CONSOLE_SELECTED_DEVICE (XCONSOLE (con)))))) | |
| 616 break; | |
| 617 } | |
| 618 if (!NILP (concons)) | |
| 619 return XCAR (concons); | |
| 620 | |
| 621 /* OK, now look for a stream console */ | |
| 622 CONSOLE_LOOP (concons) | |
| 623 { | |
| 624 Lisp_Object con = XCAR (concons); | |
| 625 if (!EQ (con, console) | |
| 626 && !NILP (CONSOLE_SELECTED_DEVICE (XCONSOLE (con))) | |
| 627 && !NILP (DEVICE_SELECTED_FRAME | |
| 628 (XDEVICE (CONSOLE_SELECTED_DEVICE (XCONSOLE (con)))))) | |
| 629 break; | |
| 630 } | |
| 631 if (!NILP (concons)) | |
| 632 return XCAR (concons); | |
| 633 | |
| 634 /* Sorry, there ain't none */ | |
| 635 return Qnil; | |
| 636 } | |
| 637 | |
| 638 static int | |
| 639 find_nonminibuffer_frame_not_on_console_predicate (Lisp_Object frame, | |
| 640 void *closure) | |
| 641 { | |
| 642 Lisp_Object console; | |
| 643 | |
| 5013 | 644 console = GET_LISP_FROM_VOID (closure); |
| 428 | 645 if (FRAME_MINIBUF_ONLY_P (XFRAME (frame))) |
| 646 return 0; | |
| 647 if (EQ (console, FRAME_CONSOLE (XFRAME (frame)))) | |
| 648 return 0; | |
| 649 return 1; | |
| 650 } | |
| 651 | |
| 652 static Lisp_Object | |
| 653 find_nonminibuffer_frame_not_on_console (Lisp_Object console) | |
| 654 { | |
| 655 return find_some_frame (find_nonminibuffer_frame_not_on_console_predicate, | |
| 5013 | 656 STORE_LISP_IN_VOID (console)); |
| 428 | 657 } |
| 658 | |
| 617 | 659 static void |
| 660 nuke_all_console_slots (struct console *con, Lisp_Object zap) | |
| 661 { | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
662 zero_nonsized_lisp_object (wrap_console (con)); |
| 617 | 663 |
| 1204 | 664 #define MARKED_SLOT(x) con->x = zap; |
| 617 | 665 #include "conslots.h" |
| 666 } | |
| 667 | |
| 428 | 668 /* Delete console CON. |
| 669 | |
| 670 If FORCE is non-zero, allow deletion of the only frame. | |
| 671 | |
| 672 If CALLED_FROM_KILL_EMACS is non-zero, then, if | |
| 673 deleting the last console, just delete it, | |
| 674 instead of calling `save-buffers-kill-emacs'. | |
| 675 | |
| 676 If FROM_IO_ERROR is non-zero, then the console is gone due | |
| 677 to an I/O error. This affects what happens if we exit | |
| 678 (we do an emergency exit instead of `save-buffers-kill-emacs'.) | |
| 679 */ | |
| 680 | |
| 681 void | |
| 682 delete_console_internal (struct console *con, int force, | |
| 683 int called_from_kill_emacs, int from_io_error) | |
| 684 { | |
| 685 /* This function can GC */ | |
| 686 Lisp_Object console; | |
| 687 struct gcpro gcpro1; | |
| 688 | |
| 689 /* OK to delete an already-deleted console. */ | |
| 690 if (!CONSOLE_LIVE_P (con)) | |
| 691 return; | |
| 692 | |
| 793 | 693 console = wrap_console (con); |
| 853 | 694 |
| 695 if (!force) | |
| 696 check_allowed_operation (OPERATION_DELETE_OBJECT, console, Qnil); | |
| 697 | |
| 428 | 698 GCPRO1 (console); |
| 699 | |
| 700 if (!called_from_kill_emacs) | |
| 701 { | |
| 702 int down_we_go = 0; | |
| 703 | |
| 704 if ((XINT (Flength (Vconsole_list)) == 1) | |
| 705 /* if we just created the console, it might not be listed, | |
| 706 or something ... */ | |
| 707 && !NILP (memq_no_quit (console, Vconsole_list))) | |
| 708 down_we_go = 1; | |
| 709 /* If there aren't any nonminibuffer frames that would | |
| 710 be left, then exit. */ | |
| 711 else if (NILP (find_nonminibuffer_frame_not_on_console (console))) | |
| 712 down_we_go = 1; | |
| 713 | |
| 714 if (down_we_go) | |
| 715 { | |
| 716 if (!force) | |
| 563 | 717 invalid_operation ("Attempt to delete the only frame", Qunbound); |
| 428 | 718 else if (from_io_error) |
| 719 { | |
| 720 /* Mayday mayday! We're going down! */ | |
| 721 stderr_out (" Autosaving and exiting...\n"); | |
| 722 Vwindow_system = Qnil; /* let it lie! */ | |
| 723 preparing_for_armageddon = 1; | |
| 724 Fkill_emacs (make_int (70)); | |
| 725 } | |
| 726 else | |
| 727 { | |
| 728 call0 (Qsave_buffers_kill_emacs); | |
| 729 UNGCPRO; | |
| 730 /* If we get here, the user said they didn't want | |
| 731 to exit, so don't. */ | |
| 732 return; | |
| 733 } | |
| 734 } | |
| 735 } | |
| 736 | |
| 737 /* Breathe a sigh of relief. We're still alive. */ | |
| 738 | |
| 739 { | |
| 740 Lisp_Object frmcons, devcons; | |
| 741 | |
| 742 /* First delete all frames without their own minibuffers, | |
| 743 to avoid errors coming from attempting to delete a frame | |
| 744 that is a surrogate for another frame. | |
| 745 | |
| 746 We don't set "called_from_delete_console" because we want the | |
| 747 device to go ahead and get deleted if we delete the last frame | |
| 748 on a device. We won't run into trouble here because for any | |
| 749 frame without a minibuffer, there has to be another one on | |
| 750 the same console with a minibuffer, and we're not deleting that, | |
| 751 so delete_console_internal() won't get recursively called. | |
| 752 | |
| 753 WRONG! With surrogate minibuffers this isn't true. Frames | |
| 754 with only a minibuffer are not enough to prevent | |
| 755 delete_frame_internal from triggering a device deletion. */ | |
| 756 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, con) | |
| 757 { | |
| 758 struct frame *f = XFRAME (XCAR (frmcons)); | |
| 759 /* delete_frame_internal() might do anything such as run hooks, | |
| 760 so be defensive. */ | |
| 761 if (FRAME_LIVE_P (f) && !FRAME_HAS_MINIBUF_P (f)) | |
| 762 delete_frame_internal (f, 1, 1, from_io_error); | |
| 763 | |
| 764 if (!CONSOLE_LIVE_P (con)) /* make sure the delete-*-hook didn't | |
| 765 go ahead and delete anything */ | |
| 766 { | |
| 767 UNGCPRO; | |
| 768 return; | |
| 769 } | |
| 770 } | |
| 771 | |
| 772 CONSOLE_DEVICE_LOOP (devcons, con) | |
| 773 { | |
| 774 struct device *d = XDEVICE (XCAR (devcons)); | |
| 775 /* delete_device_internal() might do anything such as run hooks, | |
| 776 so be defensive. */ | |
| 777 if (DEVICE_LIVE_P (d)) | |
| 778 delete_device_internal (d, 1, 1, from_io_error); | |
| 779 if (!CONSOLE_LIVE_P (con)) /* make sure the delete-*-hook didn't | |
| 780 go ahead and delete anything */ | |
| 781 { | |
| 782 UNGCPRO; | |
| 783 return; | |
| 784 } | |
| 785 } | |
| 786 } | |
| 787 | |
| 788 CONSOLE_SELECTED_DEVICE (con) = Qnil; | |
| 789 | |
| 790 /* try to select another console */ | |
| 791 | |
| 792 if (EQ (console, Fselected_console ())) | |
| 793 { | |
| 794 Lisp_Object other_dev = find_other_console (console); | |
| 795 if (!NILP (other_dev)) | |
| 796 Fselect_console (other_dev); | |
| 797 else | |
| 798 { | |
| 799 /* necessary? */ | |
| 800 Vselected_console = Qnil; | |
| 801 Vwindow_system = Qnil; | |
| 802 } | |
| 803 } | |
| 804 | |
| 805 if (con->input_enabled) | |
| 806 event_stream_unselect_console (con); | |
| 807 | |
| 808 MAYBE_CONMETH (con, delete_console, (con)); | |
| 809 | |
| 810 Vconsole_list = delq_no_quit (console, Vconsole_list); | |
| 617 | 811 |
| 428 | 812 RESET_CHANGED_SET_FLAGS; |
| 617 | 813 |
| 814 /* Nobody should be accessing anything in this object any more, and | |
| 815 making all Lisp_Objects Qnil allows for better GC'ing in case a | |
| 816 pointer to the dead console continues to hang around. Zero all | |
| 817 other structs in case someone tries to access something through | |
| 818 them. */ | |
| 819 nuke_all_console_slots (con, Qnil); | |
| 428 | 820 con->conmeths = dead_console_methods; |
| 1204 | 821 con->contype = dead_console; |
| 853 | 822 note_object_deleted (console); |
| 428 | 823 |
| 824 UNGCPRO; | |
| 825 } | |
| 826 | |
| 827 void | |
| 828 io_error_delete_console (Lisp_Object console) | |
| 829 { | |
| 830 delete_console_internal (XCONSOLE (console), 1, 0, 1); | |
| 831 } | |
| 832 | |
| 833 DEFUN ("delete-console", Fdelete_console, 1, 2, 0, /* | |
| 834 Delete CONSOLE, permanently eliminating it from use. | |
| 835 Normally, you cannot delete the last non-minibuffer-only frame (you must | |
| 836 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional | |
| 837 second argument FORCE is non-nil, you can delete the last frame. (This | |
| 838 will automatically call `save-buffers-kill-emacs'.) | |
| 839 */ | |
| 840 (console, force)) | |
| 841 { | |
| 842 CHECK_CONSOLE (console); | |
| 843 delete_console_internal (XCONSOLE (console), !NILP (force), 0, 0); | |
| 844 return Qnil; | |
| 845 } | |
| 846 | |
| 847 DEFUN ("console-list", Fconsole_list, 0, 0, 0, /* | |
| 848 Return a list of all consoles. | |
| 849 */ | |
| 850 ()) | |
| 851 { | |
| 852 return Fcopy_sequence (Vconsole_list); | |
| 853 } | |
| 854 | |
| 855 DEFUN ("console-device-list", Fconsole_device_list, 0, 1, 0, /* | |
| 856 Return a list of all devices on CONSOLE. | |
| 444 | 857 If CONSOLE is nil, the selected console is used. |
| 428 | 858 */ |
| 859 (console)) | |
| 860 { | |
| 861 return Fcopy_sequence (CONSOLE_DEVICE_LIST (decode_console (console))); | |
| 862 } | |
| 863 | |
| 864 DEFUN ("console-enable-input", Fconsole_enable_input, 1, 1, 0, /* | |
| 865 Enable input on console CONSOLE. | |
| 866 */ | |
| 867 (console)) | |
| 868 { | |
| 869 struct console *con = decode_console (console); | |
| 870 if (!con->input_enabled) | |
| 871 event_stream_select_console (con); | |
| 872 return Qnil; | |
| 873 } | |
| 874 | |
| 875 DEFUN ("console-disable-input", Fconsole_disable_input, 1, 1, 0, /* | |
| 876 Disable input on console CONSOLE. | |
| 877 */ | |
| 878 (console)) | |
| 879 { | |
| 880 struct console *con = decode_console (console); | |
| 881 if (con->input_enabled) | |
| 882 event_stream_unselect_console (con); | |
| 883 return Qnil; | |
| 884 } | |
| 885 | |
| 886 DEFUN ("console-on-window-system-p", Fconsole_on_window_system_p, 0, 1, 0, /* | |
| 444 | 887 Return t if CONSOLE is on a window system. |
| 888 If CONSOLE is nil, the selected console is used. | |
| 428 | 889 This generally means that there is support for the mouse, the menubar, |
| 890 the toolbar, glyphs, etc. | |
| 891 */ | |
| 892 (console)) | |
| 893 { | |
| 894 Lisp_Object type = CONSOLE_TYPE (decode_console (console)); | |
| 895 | |
| 896 return !EQ (type, Qtty) && !EQ (type, Qstream) ? Qt : Qnil; | |
| 897 } | |
| 898 | |
| 899 | |
| 900 | |
| 901 /**********************************************************************/ | |
| 902 /* Miscellaneous low-level functions */ | |
| 903 /**********************************************************************/ | |
| 904 | |
| 905 static Lisp_Object | |
| 906 unwind_init_sys_modes (Lisp_Object console) | |
| 907 { | |
| 908 reinit_initial_console (); | |
| 909 | |
| 910 if (!no_redraw_on_reenter && | |
| 911 CONSOLEP (console) && | |
| 912 CONSOLE_LIVE_P (XCONSOLE (console))) | |
| 913 { | |
| 914 struct frame *f = | |
| 915 XFRAME (DEVICE_SELECTED_FRAME | |
| 916 (XDEVICE (CONSOLE_SELECTED_DEVICE (XCONSOLE (console))))); | |
| 917 MARK_FRAME_CHANGED (f); | |
| 918 } | |
| 919 return Qnil; | |
| 920 } | |
| 921 | |
| 922 DEFUN ("suspend-emacs", Fsuspend_emacs, 0, 1, "", /* | |
| 923 Stop Emacs and return to superior process. You can resume later. | |
| 924 On systems that don't have job control, run a subshell instead. | |
| 925 | |
| 926 If optional arg STUFFSTRING is non-nil, its characters are stuffed | |
| 927 to be read as terminal input by Emacs's superior shell. | |
| 928 | |
| 929 Before suspending, run the normal hook `suspend-hook'. | |
| 930 After resumption run the normal hook `suspend-resume-hook'. | |
| 931 | |
| 932 Some operating systems cannot stop the Emacs process and resume it later. | |
| 933 On such systems, Emacs will start a subshell and wait for it to exit. | |
| 934 */ | |
| 935 (stuffstring)) | |
| 936 { | |
| 937 int speccount = specpdl_depth (); | |
| 938 struct gcpro gcpro1; | |
| 939 | |
| 940 if (!NILP (stuffstring)) | |
| 941 CHECK_STRING (stuffstring); | |
| 942 GCPRO1 (stuffstring); | |
| 943 | |
| 944 /* There used to be a check that the initial console is TTY. | |
| 945 This is bogus. Even checking to see whether any console | |
| 946 is a controlling terminal is not correct -- maybe | |
| 947 the user used the -t option or something. If we want to | |
| 948 suspend, then we suspend. Period. */ | |
| 949 | |
| 950 /* Call value of suspend-hook. */ | |
| 951 run_hook (Qsuspend_hook); | |
| 952 | |
| 953 reset_initial_console (); | |
| 954 /* sys_suspend can get an error if it tries to fork a subshell | |
| 955 and the system resources aren't available for that. */ | |
| 956 record_unwind_protect (unwind_init_sys_modes, Vcontrolling_terminal); | |
| 957 stuff_buffered_input (stuffstring); | |
| 958 sys_suspend (); | |
| 959 /* the console is un-reset inside of the unwind-protect. */ | |
| 771 | 960 unbind_to (speccount); |
| 428 | 961 |
| 962 #ifdef SIGWINCH | |
| 963 /* It is possible that a size change occurred while we were | |
| 964 suspended. Assume one did just to be safe. It won't hurt | |
| 965 anything if one didn't. */ | |
| 966 asynch_device_change_pending++; | |
| 967 #endif | |
| 968 | |
| 969 /* Call value of suspend-resume-hook | |
| 970 if it is bound and value is non-nil. */ | |
| 971 run_hook (Qsuspend_resume_hook); | |
| 972 | |
| 973 UNGCPRO; | |
| 974 return Qnil; | |
| 975 } | |
| 976 | |
| 977 /* If STUFFSTRING is a string, stuff its contents as pending terminal input. | |
| 978 Then in any case stuff anything Emacs has read ahead and not used. */ | |
| 979 | |
| 980 void | |
| 2286 | 981 stuff_buffered_input ( |
| 3146 | 982 #if defined(BSD) && defined(HAVE_TTY) |
| 2286 | 983 Lisp_Object stuffstring |
| 984 #else | |
| 985 Lisp_Object UNUSED (stuffstring) | |
| 986 #endif | |
| 987 ) | |
| 428 | 988 { |
| 989 /* stuff_char works only in BSD, versions 4.2 and up. */ | |
| 3146 | 990 #if defined(BSD) && defined(HAVE_TTY) |
| 428 | 991 if (!CONSOLEP (Vcontrolling_terminal) || |
| 992 !CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal))) | |
| 993 return; | |
| 994 | |
| 995 if (STRINGP (stuffstring)) | |
| 996 { | |
| 665 | 997 Bytecount count; |
| 428 | 998 Extbyte *p; |
| 999 | |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
1000 LISP_STRING_TO_SIZED_EXTERNAL (stuffstring, p, count, Qkeyboard); |
| 428 | 1001 while (count-- > 0) |
| 1002 stuff_char (XCONSOLE (Vcontrolling_terminal), *p++); | |
| 1003 stuff_char (XCONSOLE (Vcontrolling_terminal), '\n'); | |
| 1004 } | |
| 1005 /* Anything we have read ahead, put back for the shell to read. */ | |
| 1006 # if 0 /* oh, who cares about this silliness */ | |
| 1007 while (kbd_fetch_ptr != kbd_store_ptr) | |
| 1008 { | |
| 1009 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) | |
| 1010 kbd_fetch_ptr = kbd_buffer; | |
| 1011 stuff_char (XCONSOLE (Vcontrolling_terminal), *kbd_fetch_ptr++); | |
| 1012 } | |
| 1013 # endif | |
| 3146 | 1014 #endif /* BSD && HAVE_TTY */ |
| 428 | 1015 } |
| 1016 | |
| 1017 DEFUN ("suspend-console", Fsuspend_console, 0, 1, "", /* | |
| 1018 Suspend a console. For tty consoles, it sends a signal to suspend | |
| 1019 the process in charge of the tty, and removes the devices and | |
| 1020 frames of that console from the display. | |
| 1021 | |
| 1022 If optional arg CONSOLE is non-nil, it is the console to be suspended. | |
| 1023 Otherwise it is assumed to be the selected console. | |
| 1024 | |
| 1025 Some operating systems cannot stop processes and resume them later. | |
| 1026 On such systems, who knows what will happen. | |
| 1027 */ | |
| 2340 | 1028 (USED_IF_TTY (console))) |
| 428 | 1029 { |
| 1030 #ifdef HAVE_TTY | |
| 1031 struct console *con = decode_console (console); | |
| 1032 | |
| 1033 if (CONSOLE_TTY_P (con)) | |
| 1034 { | |
| 1035 /* | |
| 1036 * hide all the unhidden frames so the display code won't update | |
| 1037 * them while the console is suspended. | |
| 1038 */ | |
| 1039 Lisp_Object device = CONSOLE_SELECTED_DEVICE (con); | |
| 1040 if (!NILP (device)) | |
| 1041 { | |
| 1042 struct device *d = XDEVICE (device); | |
| 1043 Lisp_Object frame_list = DEVICE_FRAME_LIST (d); | |
| 1044 while (CONSP (frame_list)) | |
| 1045 { | |
| 1046 struct frame *f = XFRAME (XCAR (frame_list)); | |
| 1047 if (FRAME_REPAINT_P (f)) | |
| 1048 f->visible = -1; | |
| 1049 frame_list = XCDR (frame_list); | |
| 1050 } | |
| 1051 } | |
| 1052 reset_one_console (con); | |
| 1053 event_stream_unselect_console (con); | |
| 1054 sys_suspend_process (XINT (Fconsole_tty_controlling_process (console))); | |
| 1055 } | |
| 1056 #endif /* HAVE_TTY */ | |
| 1057 | |
| 1058 return Qnil; | |
| 1059 } | |
| 1060 | |
| 1061 DEFUN ("resume-console", Fresume_console, 1, 1, "", /* | |
| 1062 Re-initialize a previously suspended console. | |
| 1063 For tty consoles, do stuff to the tty to make it sane again. | |
| 1064 */ | |
| 2340 | 1065 (USED_IF_TTY (console))) |
| 428 | 1066 { |
| 1067 #ifdef HAVE_TTY | |
| 1068 struct console *con = decode_console (console); | |
| 1069 | |
| 1070 if (CONSOLE_TTY_P (con)) | |
| 1071 { | |
| 1072 /* raise the selected frame */ | |
| 1073 Lisp_Object device = CONSOLE_SELECTED_DEVICE (con); | |
| 1074 if (!NILP (device)) | |
| 1075 { | |
| 1076 struct device *d = XDEVICE (device); | |
| 1077 Lisp_Object frame = DEVICE_SELECTED_FRAME (d); | |
| 1078 if (!NILP (frame)) | |
| 1079 { | |
| 1080 /* force the frame to be cleared */ | |
| 1081 SET_FRAME_CLEAR (XFRAME (frame)); | |
| 1082 Fraise_frame (frame); | |
| 1083 } | |
| 1084 } | |
| 1085 init_one_console (con); | |
| 1086 event_stream_select_console (con); | |
| 1087 #ifdef SIGWINCH | |
| 1088 /* The same as in Fsuspend_emacs: it is possible that a size | |
| 1089 change occurred while we were suspended. Assume one did just | |
| 1090 to be safe. It won't hurt anything if one didn't. */ | |
| 1091 asynch_device_change_pending++; | |
| 1092 #endif | |
| 1093 } | |
| 1094 #endif /* HAVE_TTY */ | |
| 1095 | |
| 1096 return Qnil; | |
| 1097 } | |
| 1098 | |
| 1099 DEFUN ("set-input-mode", Fset_input_mode, 3, 5, 0, /* | |
| 1100 Set mode of reading keyboard input. | |
| 1204 | 1101 First arg (formerly INTERRUPT-INPUT) is ignored, for backward compatibility. |
| 428 | 1102 Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal |
| 1103 (no effect except in CBREAK mode). | |
| 1104 Third arg META t means accept 8-bit input (for a Meta key). | |
| 1105 META nil means ignore the top bit, on the assumption it is parity. | |
| 1106 Otherwise, accept 8-bit input and don't use the top bit for Meta. | |
| 1107 First three arguments only apply to TTY consoles. | |
| 1108 Optional fourth arg QUIT if non-nil specifies character to use for quitting. | |
| 1109 Optional fifth arg CONSOLE specifies console to make changes to; nil means | |
| 1110 the selected console. | |
| 1111 See also `current-input-mode'. | |
| 1112 */ | |
| 2340 | 1113 (UNUSED (ignored), USED_IF_TTY (flow), meta, quit, console)) |
| 428 | 1114 { |
| 1115 struct console *con = decode_console (console); | |
| 1116 int meta_key = (!CONSOLE_TTY_P (con) ? 1 : | |
| 1117 EQ (meta, Qnil) ? 0 : | |
| 1118 EQ (meta, Qt) ? 1 : | |
| 1119 2); | |
| 1120 | |
| 1121 if (!NILP (quit)) | |
| 1122 { | |
| 1204 | 1123 if (CHAR_OR_CHAR_INTP (quit) && !meta_key) |
| 1124 set_quit_events (con, make_char (XCHAR_OR_CHAR_INT (quit) & 0177)); | |
| 1125 else | |
| 1126 set_quit_events (con, quit); | |
| 428 | 1127 } |
| 1128 | |
| 1129 #ifdef HAVE_TTY | |
| 1130 if (CONSOLE_TTY_P (con)) | |
| 1131 { | |
| 1132 reset_one_console (con); | |
| 1133 TTY_FLAGS (con).flow_control = !NILP (flow); | |
| 1134 TTY_FLAGS (con).meta_key = meta_key; | |
| 1135 init_one_console (con); | |
| 444 | 1136 MARK_FRAME_CHANGED (XFRAME (CONSOLE_SELECTED_FRAME (con))); |
| 428 | 1137 } |
| 1138 #endif | |
| 1139 | |
| 1140 return Qnil; | |
| 1141 } | |
| 1142 | |
| 1143 DEFUN ("current-input-mode", Fcurrent_input_mode, 0, 1, 0, /* | |
| 1144 Return information about the way Emacs currently reads keyboard input. | |
| 1145 Optional arg CONSOLE specifies console to return information about; nil means | |
| 1146 the selected console. | |
| 1147 The value is a list of the form (nil FLOW META QUIT), where | |
| 1148 FLOW is non-nil if Emacs uses ^S/^Q flow control for output to the | |
| 1149 terminal; this does not apply if Emacs uses interrupt-driven input. | |
| 1150 META is t if accepting 8-bit input with 8th bit as Meta flag. | |
| 1151 META nil means ignoring the top bit, on the assumption it is parity. | |
| 1152 META is neither t nor nil if accepting 8-bit input and using | |
| 1153 all 8 bits as the character code. | |
| 1154 QUIT is the character Emacs currently uses to quit. | |
| 1155 FLOW, and META are only meaningful for TTY consoles. | |
| 1156 The elements of this list correspond to the arguments of | |
| 1157 `set-input-mode'. | |
| 1158 */ | |
| 1159 (console)) | |
| 1160 { | |
| 1161 struct console *con = decode_console (console); | |
| 1204 | 1162 Lisp_Object flow, meta; |
| 428 | 1163 |
| 1164 #ifdef HAVE_TTY | |
| 1165 flow = CONSOLE_TTY_P (con) && TTY_FLAGS (con).flow_control ? Qt : Qnil; | |
| 1166 meta = (!CONSOLE_TTY_P (con) ? Qt : | |
| 1167 TTY_FLAGS (con).meta_key == 1 ? Qt : | |
| 1168 TTY_FLAGS (con).meta_key == 2 ? Qzero : | |
| 1169 Qnil); | |
| 1170 #else | |
| 1171 flow = Qnil; | |
| 1172 meta = Qt; | |
| 1173 #endif | |
| 1174 | |
| 1204 | 1175 return list4 (Qnil, flow, meta, CONSOLE_QUIT_CHAR (con)); |
| 428 | 1176 } |
| 1177 | |
| 1178 | |
| 1179 /************************************************************************/ | |
| 1180 /* initialization */ | |
| 1181 /************************************************************************/ | |
| 1182 | |
| 1183 void | |
| 1184 syms_of_console (void) | |
| 1185 { | |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
1186 INIT_LISP_OBJECT (console); |
| 3092 | 1187 #ifdef NEW_GC |
| 1188 #ifdef HAVE_TTY | |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1189 INIT_LISP_OBJECT (tty_console); |
| 3092 | 1190 #endif |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
1191 INIT_LISP_OBJECT (stream_console); |
| 3263 | 1192 #endif /* NEW_GC */ |
| 442 | 1193 |
| 428 | 1194 DEFSUBR (Fvalid_console_type_p); |
| 1195 DEFSUBR (Fconsole_type_list); | |
| 1196 DEFSUBR (Fcdfw_console); | |
| 1197 DEFSUBR (Fselected_console); | |
| 1198 DEFSUBR (Fselect_console); | |
| 1199 DEFSUBR (Fconsolep); | |
| 1200 DEFSUBR (Fconsole_live_p); | |
| 1201 DEFSUBR (Fconsole_type); | |
| 1202 DEFSUBR (Fconsole_name); | |
| 1203 DEFSUBR (Fconsole_connection); | |
| 1204 DEFSUBR (Ffind_console); | |
| 1205 DEFSUBR (Fget_console); | |
| 1206 DEFSUBR (Fdelete_console); | |
| 1207 DEFSUBR (Fconsole_list); | |
| 1208 DEFSUBR (Fconsole_device_list); | |
| 1209 DEFSUBR (Fconsole_enable_input); | |
| 1210 DEFSUBR (Fconsole_disable_input); | |
| 1211 DEFSUBR (Fconsole_on_window_system_p); | |
| 1212 DEFSUBR (Fsuspend_console); | |
| 1213 DEFSUBR (Fresume_console); | |
| 1214 | |
| 1215 DEFSUBR (Fsuspend_emacs); | |
| 1216 DEFSUBR (Fset_input_mode); | |
| 1217 DEFSUBR (Fcurrent_input_mode); | |
| 1218 | |
| 563 | 1219 DEFSYMBOL (Qconsolep); |
| 1220 DEFSYMBOL (Qconsole_live_p); | |
| 428 | 1221 |
| 563 | 1222 DEFSYMBOL (Qcreate_console_hook); |
| 1223 DEFSYMBOL (Qdelete_console_hook); | |
| 428 | 1224 |
| 563 | 1225 DEFSYMBOL (Qsuspend_hook); |
| 1226 DEFSYMBOL (Qsuspend_resume_hook); | |
| 428 | 1227 } |
| 1228 | |
| 1204 | 1229 static const struct memory_description cte_description_1[] = { |
| 440 | 1230 { XD_LISP_OBJECT, offsetof (console_type_entry, symbol) }, |
| 2551 | 1231 { XD_BLOCK_PTR, offsetof (console_type_entry, meths), 1, |
| 1232 { &console_methods_description } }, | |
| 428 | 1233 { XD_END } |
| 1234 }; | |
| 1235 | |
| 1204 | 1236 static const struct sized_memory_description cte_description = { |
| 440 | 1237 sizeof (console_type_entry), |
| 428 | 1238 cte_description_1 |
| 1239 }; | |
| 1240 | |
| 1204 | 1241 static const struct memory_description cted_description_1[] = { |
| 440 | 1242 XD_DYNARR_DESC (console_type_entry_dynarr, &cte_description), |
| 428 | 1243 { XD_END } |
| 1244 }; | |
| 1245 | |
| 1204 | 1246 const struct sized_memory_description cted_description = { |
| 440 | 1247 sizeof (console_type_entry_dynarr), |
| 428 | 1248 cted_description_1 |
| 1249 }; | |
| 1250 | |
| 1204 | 1251 static const struct memory_description console_methods_description_1[] = { |
| 440 | 1252 { XD_LISP_OBJECT, offsetof (struct console_methods, symbol) }, |
| 1253 { XD_LISP_OBJECT, offsetof (struct console_methods, predicate_symbol) }, | |
| 1254 { XD_LISP_OBJECT, offsetof (struct console_methods, image_conversion_list) }, | |
| 428 | 1255 { XD_END } |
| 1256 }; | |
| 1257 | |
| 1204 | 1258 const struct sized_memory_description console_methods_description = { |
| 440 | 1259 sizeof (struct console_methods), |
| 428 | 1260 console_methods_description_1 |
| 1261 }; | |
| 1262 | |
| 1263 | |
| 1264 void | |
| 1265 console_type_create (void) | |
| 1266 { | |
| 1267 the_console_type_entry_dynarr = Dynarr_new (console_type_entry); | |
| 2367 | 1268 dump_add_root_block_ptr (&the_console_type_entry_dynarr, &cted_description); |
| 428 | 1269 |
| 1270 Vconsole_type_list = Qnil; | |
| 1271 staticpro (&Vconsole_type_list); | |
| 1272 | |
| 1273 /* Initialize the dead console type */ | |
| 1274 INITIALIZE_CONSOLE_TYPE (dead, "dead", "console-dead-p"); | |
| 1275 | |
| 1276 /* then reset the console-type lists, because `dead' is not really | |
| 1277 a valid console type */ | |
| 1278 Dynarr_reset (the_console_type_entry_dynarr); | |
| 1279 Vconsole_type_list = Qnil; | |
| 1280 } | |
| 1281 | |
| 1282 void | |
| 1283 reinit_vars_of_console (void) | |
| 1284 { | |
| 1285 staticpro_nodump (&Vconsole_list); | |
| 1286 Vconsole_list = Qnil; | |
| 1287 staticpro_nodump (&Vselected_console); | |
| 1288 Vselected_console = Qnil; | |
| 1289 } | |
| 1290 | |
| 1291 void | |
| 1292 vars_of_console (void) | |
| 1293 { | |
| 1294 DEFVAR_LISP ("create-console-hook", &Vcreate_console_hook /* | |
| 1295 Function or functions to call when a console is created. | |
| 1296 One argument, the newly-created console. | |
| 1297 This is called after the first frame has been created, but before | |
| 1298 calling the `create-device-hook' or `create-frame-hook'. | |
| 1299 Note that in general the console will not be selected. | |
| 1300 */ ); | |
| 1301 Vcreate_console_hook = Qnil; | |
| 1302 | |
| 1303 DEFVAR_LISP ("delete-console-hook", &Vdelete_console_hook /* | |
| 1304 Function or functions to call when a console is deleted. | |
| 1305 One argument, the to-be-deleted console. | |
| 1306 */ ); | |
| 1307 Vdelete_console_hook = Qnil; | |
| 1308 | |
| 1309 #ifdef HAVE_WINDOW_SYSTEM | |
| 1310 Fprovide (intern ("window-system")); | |
| 1311 #endif | |
| 1312 } | |
| 1313 | |
| 643 | 1314 /* The docstrings for DEFVAR_* are recorded externally by make-docfile. */ |
| 3263 | 1315 #ifdef NEW_GC |
| 2720 | 1316 #define DEFVAR_CONSOLE_LOCAL_1(lname, field_name, forward_type, magic_fun) \ |
| 1317 do { \ | |
| 1318 struct symbol_value_forward *I_hate_C = \ | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1319 XSYMBOL_VALUE_FORWARD (ALLOC_NORMAL_LISP_OBJECT (symbol_value_forward)); \ |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
1320 /*mcpro ((Lisp_Object) I_hate_C);*/ \ |
| 2720 | 1321 \ |
| 1322 I_hate_C->magic.value = &(console_local_flags.field_name); \ | |
| 1323 I_hate_C->magic.type = forward_type; \ | |
| 1324 I_hate_C->magicfun = magic_fun; \ | |
| 1325 \ | |
| 1326 MARK_LRECORD_AS_LISP_READONLY (I_hate_C); \ | |
| 1327 \ | |
| 1328 { \ | |
| 1329 int offset = ((char *)symbol_value_forward_forward (I_hate_C) \ | |
| 1330 - (char *)&console_local_flags); \ | |
| 1331 \ | |
| 1332 defvar_magic (lname, I_hate_C); \ | |
| 1333 \ | |
| 1334 *((Lisp_Object *)(offset + (char *)XCONSOLE (Vconsole_local_symbols))) \ | |
| 1335 = intern (lname); \ | |
| 1336 } \ | |
| 1337 } while (0) | |
| 3263 | 1338 #else /* not NEW_GC */ |
| 617 | 1339 #define DEFVAR_CONSOLE_LOCAL_1(lname, field_name, forward_type, magicfun) \ |
| 1340 do { \ | |
| 1341 static const struct symbol_value_forward I_hate_C = \ | |
| 1342 { /* struct symbol_value_forward */ \ | |
| 1343 { /* struct symbol_value_magic */ \ | |
| 3024 | 1344 { /* struct old_lcrecord_header */ \ |
| 617 | 1345 { /* struct lrecord_header */ \ |
| 1346 lrecord_type_symbol_value_forward, /* lrecord_type_index */ \ | |
| 1347 1, /* mark bit */ \ | |
| 1348 1, /* c_readonly bit */ \ | |
| 1349 1 /* lisp_readonly bit */ \ | |
| 1350 }, \ | |
| 1351 0, /* next */ \ | |
| 1352 }, \ | |
| 1353 &(console_local_flags.field_name), \ | |
| 1354 forward_type \ | |
| 1355 }, \ | |
| 1356 magicfun \ | |
| 1357 }; \ | |
| 1358 \ | |
| 1359 { \ | |
| 1360 int offset = ((char *)symbol_value_forward_forward (&I_hate_C) \ | |
| 1361 - (char *)&console_local_flags); \ | |
| 1362 \ | |
| 1363 defvar_magic (lname, &I_hate_C); \ | |
| 1364 \ | |
| 1365 *((Lisp_Object *)(offset + (char *)XCONSOLE (Vconsole_local_symbols))) \ | |
| 1366 = intern (lname); \ | |
| 1367 } \ | |
| 428 | 1368 } while (0) |
| 3263 | 1369 #endif /* not NEW_GC */ |
| 428 | 1370 |
| 1371 #define DEFVAR_CONSOLE_LOCAL_MAGIC(lname, field_name, magicfun) \ | |
| 1372 DEFVAR_CONSOLE_LOCAL_1 (lname, field_name, \ | |
| 1373 SYMVAL_SELECTED_CONSOLE_FORWARD, magicfun) | |
| 1374 #define DEFVAR_CONSOLE_LOCAL(lname, field_name) \ | |
| 1375 DEFVAR_CONSOLE_LOCAL_MAGIC (lname, field_name, 0) | |
| 1376 #define DEFVAR_CONST_CONSOLE_LOCAL_MAGIC(lname, field_name, magicfun) \ | |
| 1377 DEFVAR_CONSOLE_LOCAL_1 (lname, field_name, \ | |
| 1378 SYMVAL_CONST_SELECTED_CONSOLE_FORWARD, magicfun) | |
| 1379 #define DEFVAR_CONST_CONSOLE_LOCAL(lname, field_name) \ | |
| 1380 DEFVAR_CONST_CONSOLE_LOCAL_MAGIC (lname, field_name, 0) | |
| 1381 | |
| 1382 #define DEFVAR_CONSOLE_DEFAULTS_MAGIC(lname, field_name, magicfun) \ | |
| 1383 DEFVAR_SYMVAL_FWD(lname, &(console_local_flags.field_name), \ | |
| 1384 SYMVAL_DEFAULT_CONSOLE_FORWARD, magicfun) | |
| 1385 #define DEFVAR_CONSOLE_DEFAULTS(lname, field_name) \ | |
| 1386 DEFVAR_CONSOLE_DEFAULTS_MAGIC (lname, field_name, 0) | |
| 1387 | |
| 1388 static void | |
| 1389 common_init_complex_vars_of_console (void) | |
| 1390 { | |
| 1391 /* Make sure all markable slots in console_defaults | |
| 1392 are initialized reasonably, so mark_console won't choke. | |
| 1393 */ | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1394 Lisp_Object defobj = ALLOC_NORMAL_LISP_OBJECT (console); |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
1395 struct console *defs = XCONSOLE (defobj); |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1396 Lisp_Object symobj = ALLOC_NORMAL_LISP_OBJECT (console); |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
1397 struct console *syms = XCONSOLE (symobj); |
| 428 | 1398 |
| 1399 staticpro_nodump (&Vconsole_defaults); | |
| 1400 staticpro_nodump (&Vconsole_local_symbols); | |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
1401 Vconsole_defaults = defobj; |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
1402 Vconsole_local_symbols = symobj; |
| 428 | 1403 |
| 1404 nuke_all_console_slots (syms, Qnil); | |
| 1405 nuke_all_console_slots (defs, Qnil); | |
| 1406 | |
| 1407 /* Set up the non-nil default values of various console slots. | |
| 1408 Must do these before making the first console. | |
| 1409 */ | |
| 1204 | 1410 |
| 1411 /* ... Nothing here for the moment. | |
| 1412 #### Console-local variables should probably be eliminated.*/ | |
| 428 | 1413 |
| 1414 { | |
| 1415 /* 0 means var is always local. Default used only at creation. | |
| 1416 * -1 means var is always local. Default used only at reset and | |
| 1417 * creation. | |
| 1418 * -2 means there's no lisp variable corresponding to this slot | |
| 1419 * and the default is only used at creation. | |
| 1420 * -3 means no Lisp variable. Default used only at reset and creation. | |
| 1421 * >0 is mask. Var is local if ((console->local_var_flags & mask) != 0) | |
| 1422 * Otherwise default is used. | |
| 1423 * | |
| 1424 * #### We don't currently ever reset console variables, so there | |
| 1425 * is no current distinction between 0 and -1, and between -2 and -3. | |
| 1426 */ | |
| 1427 Lisp_Object always_local_resettable = make_int (-1); | |
| 1428 | |
| 1429 #if 0 /* not used */ | |
| 1430 Lisp_Object always_local_no_default = make_int (0); | |
| 1431 Lisp_Object resettable = make_int (-3); | |
| 1432 #endif | |
| 1433 | |
| 1434 /* Assign the local-flags to the slots that have default values. | |
| 1435 The local flag is a bit that is used in the console | |
| 1436 to say that it has its own local value for the slot. | |
| 1437 The local flag bits are in the local_var_flags slot of the | |
| 1438 console. */ | |
| 1439 | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1440 set_lheader_implementation ((struct lrecord_header *) |
|
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
1441 &console_local_flags, &lrecord_console); |
| 428 | 1442 nuke_all_console_slots (&console_local_flags, make_int (-2)); |
| 1443 console_local_flags.defining_kbd_macro = always_local_resettable; | |
| 1444 console_local_flags.last_kbd_macro = always_local_resettable; | |
| 1445 console_local_flags.prefix_arg = always_local_resettable; | |
| 1446 console_local_flags.default_minibuffer_frame = always_local_resettable; | |
| 1447 console_local_flags.overriding_terminal_local_map = | |
| 1448 always_local_resettable; | |
| 1449 #ifdef HAVE_TTY | |
| 1450 console_local_flags.tty_erase_char = always_local_resettable; | |
| 1451 #endif | |
| 1452 | |
| 1453 console_local_flags.function_key_map = make_int (1); | |
| 1454 | |
| 1455 /* #### Warning, 0x4000000 (that's six zeroes) is the largest number | |
| 1456 currently allowable due to the XINT() handling of this value. | |
| 1457 With some rearrangement you can get 4 more bits. */ | |
| 1458 } | |
| 1459 } | |
| 1460 | |
| 1461 | |
| 1462 #define CONSOLE_SLOTS_SIZE (offsetof (struct console, CONSOLE_SLOTS_LAST_NAME) - offsetof (struct console, CONSOLE_SLOTS_FIRST_NAME) + sizeof (Lisp_Object)) | |
| 1463 #define CONSOLE_SLOTS_COUNT (CONSOLE_SLOTS_SIZE / sizeof (Lisp_Object)) | |
| 1464 | |
| 1465 void | |
| 771 | 1466 reinit_complex_vars_of_console_runtime_only (void) |
| 428 | 1467 { |
| 1468 struct console *defs, *syms; | |
| 1469 | |
| 1470 common_init_complex_vars_of_console (); | |
| 1471 | |
| 1472 defs = XCONSOLE (Vconsole_defaults); | |
| 1473 syms = XCONSOLE (Vconsole_local_symbols); | |
| 1474 memcpy (&defs->CONSOLE_SLOTS_FIRST_NAME, | |
| 1475 console_defaults_saved_slots, | |
| 1476 CONSOLE_SLOTS_SIZE); | |
| 1477 memcpy (&syms->CONSOLE_SLOTS_FIRST_NAME, | |
| 1478 console_local_symbols_saved_slots, | |
| 1479 CONSOLE_SLOTS_SIZE); | |
| 1480 } | |
| 1481 | |
| 1482 | |
| 1204 | 1483 static const struct memory_description console_slots_description_1[] = { |
| 440 | 1484 { XD_LISP_OBJECT_ARRAY, 0, CONSOLE_SLOTS_COUNT }, |
| 428 | 1485 { XD_END } |
| 1486 }; | |
| 1487 | |
| 1204 | 1488 static const struct sized_memory_description console_slots_description = { |
| 428 | 1489 CONSOLE_SLOTS_SIZE, |
| 1490 console_slots_description_1 | |
| 1491 }; | |
| 1492 | |
| 1493 void | |
| 1494 complex_vars_of_console (void) | |
| 1495 { | |
| 1496 struct console *defs, *syms; | |
| 1497 | |
| 1498 common_init_complex_vars_of_console (); | |
| 1499 | |
| 1500 defs = XCONSOLE (Vconsole_defaults); | |
| 1501 syms = XCONSOLE (Vconsole_local_symbols); | |
| 1502 console_defaults_saved_slots = &defs->CONSOLE_SLOTS_FIRST_NAME; | |
| 1503 console_local_symbols_saved_slots = &syms->CONSOLE_SLOTS_FIRST_NAME; | |
| 2367 | 1504 dump_add_root_block_ptr (&console_defaults_saved_slots, &console_slots_description); |
| 1505 dump_add_root_block_ptr (&console_local_symbols_saved_slots, &console_slots_description); | |
| 428 | 1506 |
| 1507 DEFVAR_CONSOLE_DEFAULTS ("default-function-key-map", function_key_map /* | |
| 1508 Default value of `function-key-map' for consoles that don't override it. | |
| 1509 This is the same as (default-value 'function-key-map). | |
| 1510 */ ); | |
| 1511 | |
| 1512 DEFVAR_CONSOLE_LOCAL ("function-key-map", function_key_map /* | |
| 1513 Keymap mapping ASCII function key sequences onto their preferred forms. | |
| 1514 This allows Emacs to recognize function keys sent from ASCII | |
| 1515 terminals at any point in a key sequence. | |
| 1516 | |
| 1517 The `read-key-sequence' function replaces any subsequence bound by | |
| 1518 `function-key-map' with its binding. More precisely, when the active | |
| 1519 keymaps have no binding for the current key sequence but | |
| 1520 `function-key-map' binds a suffix of the sequence to a vector or string, | |
| 1521 `read-key-sequence' replaces the matching suffix with its binding, and | |
| 2027 | 1522 continues with the new sequence. See `key-binding'. |
| 428 | 1523 |
| 1524 The events that come from bindings in `function-key-map' are not | |
| 1525 themselves looked up in `function-key-map'. | |
| 1526 | |
| 1527 For example, suppose `function-key-map' binds `ESC O P' to [f1]. | |
| 1528 Typing `ESC O P' to `read-key-sequence' would return | |
| 1529 \[#<keypress-event f1>]. Typing `C-x ESC O P' would return | |
| 1530 \[#<keypress-event control-X> #<keypress-event f1>]. If [f1] | |
| 1531 were a prefix key, typing `ESC O P x' would return | |
| 1532 \[#<keypress-event f1> #<keypress-event x>]. | |
| 1533 */ ); | |
| 1534 | |
| 1535 #ifdef HAVE_TTY | |
| 440 | 1536 /* #### Should this somehow go to TTY data? How do we make it |
| 428 | 1537 accessible from Lisp, then? */ |
| 1538 DEFVAR_CONSOLE_LOCAL ("tty-erase-char", tty_erase_char /* | |
| 1539 The ERASE character as set by the user with stty. | |
| 1540 When this value cannot be determined or would be meaningless (on non-TTY | |
| 1541 consoles, for example), it is set to nil. | |
| 1542 */ ); | |
| 1543 #endif | |
| 1544 | |
| 442 | 1545 /* While this should be const it can't be because some things |
| 428 | 1546 (i.e. edebug) do manipulate it. */ |
| 1547 DEFVAR_CONSOLE_LOCAL ("defining-kbd-macro", defining_kbd_macro /* | |
| 442 | 1548 Non-nil while a keyboard macro is being defined. Don't set this! |
| 428 | 1549 */ ); |
| 1550 | |
| 1551 DEFVAR_CONSOLE_LOCAL ("last-kbd-macro", last_kbd_macro /* | |
| 442 | 1552 Last keyboard macro defined, as a vector of events; nil if none defined. |
| 428 | 1553 */ ); |
| 1554 | |
| 1555 DEFVAR_CONSOLE_LOCAL ("prefix-arg", prefix_arg /* | |
| 1556 The value of the prefix argument for the next editing command. | |
| 1557 It may be a number, or the symbol `-' for just a minus sign as arg, | |
| 1558 or a list whose car is a number for just one or more C-U's | |
| 1559 or nil if no argument has been specified. | |
| 1560 | |
| 1561 You cannot examine this variable to find the argument for this command | |
| 1562 since it has been set to nil by the time you can look. | |
| 1563 Instead, you should use the variable `current-prefix-arg', although | |
| 1564 normally commands can get this prefix argument with (interactive "P"). | |
| 1565 */ ); | |
| 1566 | |
| 1567 DEFVAR_CONSOLE_LOCAL ("default-minibuffer-frame", | |
| 1568 default_minibuffer_frame /* | |
| 1569 Minibufferless frames use this frame's minibuffer. | |
| 1570 | |
| 1571 Emacs cannot create minibufferless frames unless this is set to an | |
| 1572 appropriate surrogate. | |
| 1573 | |
| 1574 XEmacs consults this variable only when creating minibufferless | |
| 1575 frames; once the frame is created, it sticks with its assigned | |
| 1576 minibuffer, no matter what this variable is set to. This means that | |
| 1577 this variable doesn't necessarily say anything meaningful about the | |
| 1578 current set of frames, or where the minibuffer is currently being | |
| 1579 displayed. | |
| 1580 */ ); | |
| 1581 | |
| 1582 DEFVAR_CONSOLE_LOCAL ("overriding-terminal-local-map", | |
| 1583 overriding_terminal_local_map /* | |
| 1584 Keymap that overrides all other local keymaps, for the selected console only. | |
| 1585 If this variable is non-nil, it is used as a keymap instead of the | |
| 1586 buffer's local map, and the minor mode keymaps and text property keymaps. | |
| 1587 */ ); | |
| 1588 | |
| 1589 /* Check for DEFVAR_CONSOLE_LOCAL without initializing the corresponding | |
| 1590 slot of console_local_flags and vice-versa. Must be done after all | |
| 1591 DEFVAR_CONSOLE_LOCAL() calls. */ | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
5013
diff
changeset
|
1592 #define MARKED_SLOT(slot) \ |
|
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
5013
diff
changeset
|
1593 assert ((XINT (console_local_flags.slot) != -2 && \ |
|
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
5013
diff
changeset
|
1594 XINT (console_local_flags.slot) != -3) \ |
|
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
5013
diff
changeset
|
1595 == !(NILP (XCONSOLE (Vconsole_local_symbols)->slot))); |
| 428 | 1596 #include "conslots.h" |
| 1597 } |
