comparison src/console.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children ec9a17fef872
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
202 if (decode_console_type (type, ERROR_ME_NOT)) 202 if (decode_console_type (type, ERROR_ME_NOT))
203 return 1; 203 return 1;
204 return 0; 204 return 0;
205 } 205 }
206 206
207 DEFUN ("valid-console-type-p", Fvalid_console_type_p, Svalid_console_type_p, 207 DEFUN ("valid-console-type-p", Fvalid_console_type_p, 1, 1, 0, /*
208 1, 1, 0 /*
209 Given a CONSOLE-TYPE, return t if it is valid. 208 Given a CONSOLE-TYPE, return t if it is valid.
210 Valid types are 'x, 'tty, and 'stream. 209 Valid types are 'x, 'tty, and 'stream.
211 */ ) 210 */
212 (console_type) 211 (console_type))
213 Lisp_Object console_type;
214 { 212 {
215 if (valid_console_type_p (console_type)) 213 if (valid_console_type_p (console_type))
216 return Qt; 214 return Qt;
217 else 215 else
218 return Qnil; 216 return Qnil;
219 } 217 }
220 218
221 DEFUN ("console-type-list", Fconsole_type_list, Sconsole_type_list, 219 DEFUN ("console-type-list", Fconsole_type_list, 0, 0, 0, /*
222 0, 0, 0 /*
223 Return a list of valid console types. 220 Return a list of valid console types.
224 */ ) 221 */
225 () 222 ())
226 { 223 {
227 return Fcopy_sequence (Vconsole_type_list); 224 return Fcopy_sequence (Vconsole_type_list);
228 } 225 }
229 226
230 DEFUN ("cdfw-console", Fcdfw_console, Scdfw_console, 1, 1, 0 /* 227 DEFUN ("cdfw-console", Fcdfw_console, 1, 1, 0, /*
231 Given a console, device, frame, or window, return the associated console. 228 Given a console, device, frame, or window, return the associated console.
232 Return nil otherwise. 229 Return nil otherwise.
233 */ ) 230 */
234 (obj) 231 (obj))
235 Lisp_Object obj;
236 { 232 {
237 return CDFW_CONSOLE (obj); 233 return CDFW_CONSOLE (obj);
238 } 234 }
239 235
240 236
241 DEFUN ("selected-console", Fselected_console, Sselected_console, 0, 0, 0 /* 237 DEFUN ("selected-console", Fselected_console, 0, 0, 0, /*
242 Return the console which is currently active. 238 Return the console which is currently active.
243 */ ) 239 */
244 () 240 ())
245 { 241 {
246 return Vselected_console; 242 return Vselected_console;
247 } 243 }
248 244
249 /* Called from selected_device_1(), called from selected_frame_1(), 245 /* Called from selected_device_1(), called from selected_frame_1(),
266 else 262 else
267 #endif 263 #endif
268 Vwindow_system = Qnil; 264 Vwindow_system = Qnil;
269 } 265 }
270 266
271 DEFUN ("select-console", Fselect_console, Sselect_console, 1, 1, 0 /* 267 DEFUN ("select-console", Fselect_console, 1, 1, 0, /*
272 Select the console CONSOLE. 268 Select the console CONSOLE.
273 Subsequent editing commands apply to its selected device, selected frame, 269 Subsequent editing commands apply to its selected device, selected frame,
274 and selected window. The selection of CONSOLE lasts until the next time 270 and selected window. The selection of CONSOLE lasts until the next time
275 the user does something to select a different console, or until the next 271 the user does something to select a different console, or until the next
276 time this function is called. 272 time this function is called.
277 */ ) 273 */
278 (console) 274 (console))
279 Lisp_Object console;
280 { 275 {
281 CHECK_LIVE_CONSOLE (console); 276 CHECK_LIVE_CONSOLE (console);
282 277
283 /* select the console's selected frame's selected window. This will call 278 /* select the console's selected frame's selected window. This will call
284 selected_frame_1(). */ 279 selected_frame_1(). */
294 Lisp_Object frame) 289 Lisp_Object frame)
295 { 290 {
296 con->_last_nonminibuf_frame = frame; 291 con->_last_nonminibuf_frame = frame;
297 } 292 }
298 293
299 DEFUN ("consolep", Fconsolep, Sconsolep, 1, 1, 0 /* 294 DEFUN ("consolep", Fconsolep, 1, 1, 0, /*
300 Return non-nil if OBJECT is a console. 295 Return non-nil if OBJECT is a console.
301 */ ) 296 */
302 (object) 297 (object))
303 Lisp_Object object;
304 { 298 {
305 if (!CONSOLEP (object)) 299 if (!CONSOLEP (object))
306 return Qnil; 300 return Qnil;
307 return Qt; 301 return Qt;
308 } 302 }
309 303
310 DEFUN ("console-live-p", Fconsole_live_p, Sconsole_live_p, 1, 1, 0 /* 304 DEFUN ("console-live-p", Fconsole_live_p, 1, 1, 0, /*
311 Return non-nil if OBJECT is a console that has not been deleted. 305 Return non-nil if OBJECT is a console that has not been deleted.
312 */ ) 306 */
313 (object) 307 (object))
314 Lisp_Object object;
315 { 308 {
316 if (!CONSOLEP (object) || !CONSOLE_LIVE_P (XCONSOLE (object))) 309 if (!CONSOLEP (object) || !CONSOLE_LIVE_P (XCONSOLE (object)))
317 return Qnil; 310 return Qnil;
318 return Qt; 311 return Qt;
319 } 312 }
320 313
321 DEFUN ("console-type", Fconsole_type, Sconsole_type, 0, 1, 0 /* 314 DEFUN ("console-type", Fconsole_type, 0, 1, 0, /*
322 Return the type of the specified console (e.g. `x' or `tty'). 315 Return the type of the specified console (e.g. `x' or `tty').
323 Value is `tty' for a tty console (a character-only terminal), 316 Value is `tty' for a tty console (a character-only terminal),
324 `x' for a console that is an X display, 317 `x' for a console that is an X display,
325 `ns' for a console that is a NeXTstep connection (not yet implemeted), 318 `ns' for a console that is a NeXTstep connection (not yet implemeted),
326 `win32' for a console that is a Windows or Windows NT connection (not yet 319 `win32' for a console that is a Windows or Windows NT connection (not yet
327 implemented), 320 implemented),
328 `pc' for a console that is a direct-write MS-DOS connection (not yet 321 `pc' for a console that is a direct-write MS-DOS connection (not yet
329 implemented), 322 implemented),
330 `stream' for a stream console (which acts like a stdio stream), and 323 `stream' for a stream console (which acts like a stdio stream), and
331 `dead' for a deleted console. 324 `dead' for a deleted console.
332 */ ) 325 */
333 (console) 326 (console))
334 Lisp_Object console;
335 { 327 {
336 /* don't call decode_console() because we want to allow for dead 328 /* don't call decode_console() because we want to allow for dead
337 consoles. */ 329 consoles. */
338 if (NILP (console)) 330 if (NILP (console))
339 console = Fselected_console (); 331 console = Fselected_console ();
340 CHECK_CONSOLE (console); 332 CHECK_CONSOLE (console);
341 return CONSOLE_TYPE (XCONSOLE (console)); 333 return CONSOLE_TYPE (XCONSOLE (console));
342 } 334 }
343 335
344 DEFUN ("console-name", Fconsole_name, Sconsole_name, 0, 1, 0 /* 336 DEFUN ("console-name", Fconsole_name, 0, 1, 0, /*
345 Return the name of the specified console. 337 Return the name of the specified console.
346 */ ) 338 */
347 (console) 339 (console))
348 Lisp_Object console;
349 { 340 {
350 return CONSOLE_NAME (decode_console (console)); 341 return CONSOLE_NAME (decode_console (console));
351 } 342 }
352 343
353 DEFUN ("console-connection", Fconsole_connection, Sconsole_connection, 344 DEFUN ("console-connection", Fconsole_connection, 0, 1, 0, /*
354 0, 1, 0 /*
355 Return the connection of the specified console. 345 Return the connection of the specified console.
356 CONSOLE defaults to the selected console if omitted. 346 CONSOLE defaults to the selected console if omitted.
357 */ ) 347 */
358 (console) 348 (console))
359 Lisp_Object console;
360 { 349 {
361 return CONSOLE_CONNECTION (decode_console (console)); 350 return CONSOLE_CONNECTION (decode_console (console));
362 } 351 }
363 352
364 Lisp_Object 353 Lisp_Object
401 } 390 }
402 391
403 return Qnil; 392 return Qnil;
404 } 393 }
405 394
406 DEFUN ("find-console", Ffind_console, Sfind_console, 1, 2, 0 /* 395 DEFUN ("find-console", Ffind_console, 1, 2, 0, /*
407 Look for an existing console attached to connection CONNECTION. 396 Look for an existing console attached to connection CONNECTION.
408 Return the console if found; otherwise, return nil. 397 Return the console if found; otherwise, return nil.
409 398
410 If TYPE is specified, only return consoles of that type; otherwise, 399 If TYPE is specified, only return consoles of that type; otherwise,
411 return consoles of any type. (It is possible, although unlikely, 400 return consoles of any type. (It is possible, although unlikely,
412 that two consoles of different types could have the same connection 401 that two consoles of different types could have the same connection
413 name; in such a case, the first console found is returned.) 402 name; in such a case, the first console found is returned.)
414 */ ) 403 */
415 (connection, type) 404 (connection, type))
416 Lisp_Object connection, type;
417 { 405 {
418 Lisp_Object canon = Qnil; 406 Lisp_Object canon = Qnil;
419 struct gcpro gcpro1; 407 struct gcpro gcpro1;
420 408
421 GCPRO1 (canon); 409 GCPRO1 (canon);
451 439
452 RETURN_UNGCPRO (Qnil); 440 RETURN_UNGCPRO (Qnil);
453 } 441 }
454 } 442 }
455 443
456 DEFUN ("get-console", Fget_console, Sget_console, 1, 2, 0 /* 444 DEFUN ("get-console", Fget_console, 1, 2, 0, /*
457 Look for an existing console attached to connection CONNECTION. 445 Look for an existing console attached to connection CONNECTION.
458 Return the console if found; otherwise, signal an error. 446 Return the console if found; otherwise, signal an error.
459 447
460 If TYPE is specified, only return consoles of that type; otherwise, 448 If TYPE is specified, only return consoles of that type; otherwise,
461 return consoles of any type. (It is possible, although unlikely, 449 return consoles of any type. (It is possible, although unlikely,
462 that two consoles of different types could have the same connection 450 that two consoles of different types could have the same connection
463 name; in such a case, the first console found is returned.) 451 name; in such a case, the first console found is returned.)
464 */ ) 452 */
465 (connection, type) 453 (connection, type))
466 Lisp_Object connection, type;
467 { 454 {
468 Lisp_Object console = Ffind_console (connection, type); 455 Lisp_Object console = Ffind_console (connection, type);
469 if (NILP (console)) 456 if (NILP (console))
470 { 457 {
471 if (NILP (type)) 458 if (NILP (type))
737 io_error_delete_console (Lisp_Object console) 724 io_error_delete_console (Lisp_Object console)
738 { 725 {
739 delete_console_internal (XCONSOLE (console), 1, 0, 1); 726 delete_console_internal (XCONSOLE (console), 1, 0, 1);
740 } 727 }
741 728
742 DEFUN ("delete-console", Fdelete_console, Sdelete_console, 1, 2, 0 /* 729 DEFUN ("delete-console", Fdelete_console, 1, 2, 0, /*
743 Delete CONSOLE, permanently eliminating it from use. 730 Delete CONSOLE, permanently eliminating it from use.
744 Normally, you cannot delete the last non-minibuffer-only frame (you must 731 Normally, you cannot delete the last non-minibuffer-only frame (you must
745 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional 732 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional
746 second argument FORCE is non-nil, you can delete the last frame. (This 733 second argument FORCE is non-nil, you can delete the last frame. (This
747 will automatically call `save-buffers-kill-emacs'.) 734 will automatically call `save-buffers-kill-emacs'.)
748 */ ) 735 */
749 (console, force) 736 (console, force))
750 Lisp_Object console, force;
751 { 737 {
752 CHECK_CONSOLE (console); 738 CHECK_CONSOLE (console);
753 delete_console_internal (XCONSOLE (console), !NILP (force), 0, 0); 739 delete_console_internal (XCONSOLE (console), !NILP (force), 0, 0);
754 return Qnil; 740 return Qnil;
755 } 741 }
756 742
757 DEFUN ("console-list", Fconsole_list, Sconsole_list, 0, 0, 0 /* 743 DEFUN ("console-list", Fconsole_list, 0, 0, 0, /*
758 Return a list of all consoles. 744 Return a list of all consoles.
759 */ ) 745 */
760 () 746 ())
761 { 747 {
762 return Fcopy_sequence (Vconsole_list); 748 return Fcopy_sequence (Vconsole_list);
763 } 749 }
764 750
765 DEFUN ("console-device-list", Fconsole_device_list, Sconsole_device_list, 751 DEFUN ("console-device-list", Fconsole_device_list, 0, 1, 0, /*
766 0, 1, 0 /*
767 Return a list of all devices on CONSOLE. 752 Return a list of all devices on CONSOLE.
768 If CONSOLE is nil, the selected console will be used. 753 If CONSOLE is nil, the selected console will be used.
769 */ ) 754 */
770 (console) 755 (console))
771 Lisp_Object console;
772 { 756 {
773 return Fcopy_sequence (CONSOLE_DEVICE_LIST (decode_console (console))); 757 return Fcopy_sequence (CONSOLE_DEVICE_LIST (decode_console (console)));
774 } 758 }
775 759
776 DEFUN ("console-enable-input", Fconsole_enable_input, Sconsole_enable_input, 760 DEFUN ("console-enable-input", Fconsole_enable_input, 1, 1, 0, /*
777 1, 1, 0 /*
778 Enable input on console CONSOLE. 761 Enable input on console CONSOLE.
779 */ ) 762 */
780 (console) 763 (console))
781 Lisp_Object console;
782 { 764 {
783 struct console *con = decode_console (console); 765 struct console *con = decode_console (console);
784 if (!con->input_enabled) 766 if (!con->input_enabled)
785 event_stream_select_console (con); 767 event_stream_select_console (con);
786 return Qnil; 768 return Qnil;
787 } 769 }
788 770
789 DEFUN ("console-disable-input", Fconsole_disable_input, 771 DEFUN ("console-disable-input", Fconsole_disable_input, 1, 1, 0, /*
790 Sconsole_disable_input,
791 1, 1, 0 /*
792 Disable input on console CONSOLE. 772 Disable input on console CONSOLE.
793 */ ) 773 */
794 (console) 774 (console))
795 Lisp_Object console;
796 { 775 {
797 struct console *con = decode_console (console); 776 struct console *con = decode_console (console);
798 if (con->input_enabled) 777 if (con->input_enabled)
799 event_stream_unselect_console (con); 778 event_stream_unselect_console (con);
800 return Qnil; 779 return Qnil;
801 } 780 }
802 781
803 DEFUN ("console-on-window-system-p", Fconsole_on_window_system_p, 782 DEFUN ("console-on-window-system-p", Fconsole_on_window_system_p, 0, 1, 0, /*
804 Sconsole_on_window_system_p, 0, 1, 0 /*
805 Return non-nil if this console is on a window system. 783 Return non-nil if this console is on a window system.
806 This generally means that there is support for the mouse, the menubar, 784 This generally means that there is support for the mouse, the menubar,
807 the toolbar, glyphs, etc. 785 the toolbar, glyphs, etc.
808 */ ) 786 */
809 (console) 787 (console))
810 Lisp_Object console;
811 { 788 {
812 struct console *con = decode_console (console); 789 struct console *con = decode_console (console);
813 790
814 if (EQ (CONSOLE_TYPE (con), Qtty) || EQ (CONSOLE_TYPE (con), Qstream)) 791 if (EQ (CONSOLE_TYPE (con), Qtty) || EQ (CONSOLE_TYPE (con), Qstream))
815 return Qnil; 792 return Qnil;
835 (XDEVICE (CONSOLE_SELECTED_DEVICE (XCONSOLE (console)))))); 812 (XDEVICE (CONSOLE_SELECTED_DEVICE (XCONSOLE (console))))));
836 } 813 }
837 return Qnil; 814 return Qnil;
838 } 815 }
839 816
840 DEFUN ("suspend-emacs", Fsuspend_emacs, Ssuspend_emacs, 0, 1, "" /* 817 DEFUN ("suspend-emacs", Fsuspend_emacs, 0, 1, "", /*
841 Stop Emacs and return to superior process. You can resume later. 818 Stop Emacs and return to superior process. You can resume later.
842 On systems that don't have job control, run a subshell instead. 819 On systems that don't have job control, run a subshell instead.
843 820
844 If optional arg STUFFSTRING is non-nil, its characters are stuffed 821 If optional arg STUFFSTRING is non-nil, its characters are stuffed
845 to be read as terminal input by Emacs's superior shell. 822 to be read as terminal input by Emacs's superior shell.
848 Otherwise, suspend normally and after resumption call 825 Otherwise, suspend normally and after resumption call
849 `suspend-resume-hook' if that is bound and non-nil. 826 `suspend-resume-hook' if that is bound and non-nil.
850 827
851 Some operating systems cannot stop the Emacs process and resume it later. 828 Some operating systems cannot stop the Emacs process and resume it later.
852 On such systems, Emacs will start a subshell and wait for it to exit. 829 On such systems, Emacs will start a subshell and wait for it to exit.
853 */ ) 830 */
854 (stuffstring) 831 (stuffstring))
855 Lisp_Object stuffstring;
856 { 832 {
857 int speccount = specpdl_depth (); 833 int speccount = specpdl_depth ();
858 struct gcpro gcpro1; 834 struct gcpro gcpro1;
859 835
860 if (!NILP (stuffstring)) 836 if (!NILP (stuffstring))
926 } 902 }
927 # endif 903 # endif
928 #endif /* BSD */ 904 #endif /* BSD */
929 } 905 }
930 906
931 DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 5, 0 /* 907 DEFUN ("set-input-mode", Fset_input_mode, 3, 5, 0, /*
932 Set mode of reading keyboard input. 908 Set mode of reading keyboard input.
933 First arg is ignored, for backward compatibility. 909 First arg is ignored, for backward compatibility.
934 Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal 910 Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal
935 (no effect except in CBREAK mode). 911 (no effect except in CBREAK mode).
936 Third arg META t means accept 8-bit input (for a Meta key). 912 Third arg META t means accept 8-bit input (for a Meta key).
939 First three arguments only apply to TTY consoles. 915 First three arguments only apply to TTY consoles.
940 Optional fourth arg QUIT if non-nil specifies character to use for quitting. 916 Optional fourth arg QUIT if non-nil specifies character to use for quitting.
941 Optional fifth arg CONSOLE specifies console to make changes to; nil means 917 Optional fifth arg CONSOLE specifies console to make changes to; nil means
942 the selected console. 918 the selected console.
943 See also `current-input-mode'. 919 See also `current-input-mode'.
944 */ ) 920 */
945 (ignored, flow, meta, quit, console) 921 (ignored, flow, meta, quit, console))
946 Lisp_Object ignored, flow, meta, quit, console;
947 { 922 {
948 struct console *con = decode_console (console); 923 struct console *con = decode_console (console);
949 int meta_key = 1; 924 int meta_key = 1;
950 925
951 if (CONSOLE_TTY_P (con)) 926 if (CONSOLE_TTY_P (con))
974 } 949 }
975 950
976 return Qnil; 951 return Qnil;
977 } 952 }
978 953
979 DEFUN ("current-input-mode", Fcurrent_input_mode, Scurrent_input_mode, 954 DEFUN ("current-input-mode", Fcurrent_input_mode, 0, 1, 0, /*
980 0, 1, 0 /*
981 Return information about the way Emacs currently reads keyboard input. 955 Return information about the way Emacs currently reads keyboard input.
982 Optional arg CONSOLE specifies console to return information about; nil means 956 Optional arg CONSOLE specifies console to return information about; nil means
983 the selected console. 957 the selected console.
984 The value is a list of the form (nil FLOW META QUIT), where 958 The value is a list of the form (nil FLOW META QUIT), where
985 FLOW is non-nil if Emacs uses ^S/^Q flow control for output to the 959 FLOW is non-nil if Emacs uses ^S/^Q flow control for output to the
990 all 8 bits as the character code. 964 all 8 bits as the character code.
991 QUIT is the character Emacs currently uses to quit. 965 QUIT is the character Emacs currently uses to quit.
992 FLOW, and META are only meaningful for TTY consoles. 966 FLOW, and META are only meaningful for TTY consoles.
993 The elements of this list correspond to the arguments of 967 The elements of this list correspond to the arguments of
994 `set-input-mode'. 968 `set-input-mode'.
995 */ ) 969 */
996 (console) 970 (console))
997 Lisp_Object console;
998 { 971 {
999 Lisp_Object val[4]; 972 Lisp_Object val[4];
1000 struct console *con = decode_console (console); 973 struct console *con = decode_console (console);
1001 974
1002 val[0] = Qnil; 975 val[0] = Qnil;
1014 /************************************************************************/ 987 /************************************************************************/
1015 988
1016 void 989 void
1017 syms_of_console (void) 990 syms_of_console (void)
1018 { 991 {
1019 defsubr (&Svalid_console_type_p); 992 DEFSUBR (Fvalid_console_type_p);
1020 defsubr (&Sconsole_type_list); 993 DEFSUBR (Fconsole_type_list);
1021 defsubr (&Scdfw_console); 994 DEFSUBR (Fcdfw_console);
1022 defsubr (&Sselected_console); 995 DEFSUBR (Fselected_console);
1023 defsubr (&Sselect_console); 996 DEFSUBR (Fselect_console);
1024 defsubr (&Sconsolep); 997 DEFSUBR (Fconsolep);
1025 defsubr (&Sconsole_live_p); 998 DEFSUBR (Fconsole_live_p);
1026 defsubr (&Sconsole_type); 999 DEFSUBR (Fconsole_type);
1027 defsubr (&Sconsole_name); 1000 DEFSUBR (Fconsole_name);
1028 defsubr (&Sconsole_connection); 1001 DEFSUBR (Fconsole_connection);
1029 defsubr (&Sfind_console); 1002 DEFSUBR (Ffind_console);
1030 defsubr (&Sget_console); 1003 DEFSUBR (Fget_console);
1031 defsubr (&Sdelete_console); 1004 DEFSUBR (Fdelete_console);
1032 defsubr (&Sconsole_list); 1005 DEFSUBR (Fconsole_list);
1033 defsubr (&Sconsole_device_list); 1006 DEFSUBR (Fconsole_device_list);
1034 defsubr (&Sconsole_enable_input); 1007 DEFSUBR (Fconsole_enable_input);
1035 defsubr (&Sconsole_disable_input); 1008 DEFSUBR (Fconsole_disable_input);
1036 defsubr (&Sconsole_on_window_system_p); 1009 DEFSUBR (Fconsole_on_window_system_p);
1037 1010
1038 defsubr (&Ssuspend_emacs); 1011 DEFSUBR (Fsuspend_emacs);
1039 defsubr (&Sset_input_mode); 1012 DEFSUBR (Fset_input_mode);
1040 defsubr (&Scurrent_input_mode); 1013 DEFSUBR (Fcurrent_input_mode);
1041 1014
1042 defsymbol (&Qconsolep, "consolep"); 1015 defsymbol (&Qconsolep, "consolep");
1043 defsymbol (&Qconsole_live_p, "console-live-p"); 1016 defsymbol (&Qconsole_live_p, "console-live-p");
1044 1017
1045 defsymbol (&Qcreate_console_hook, "create-console-hook"); 1018 defsymbol (&Qcreate_console_hook, "create-console-hook");