GOAL
----
-The ultimate goal of this branch is to implement support for opening
-multiple, different tty devices and simultaneous X and tty frames from
-a single Emacs session.
+The goal of this branch is to implement support for opening multiple,
+different tty devices and simultaneous X and tty frames from a single
+Emacs session.
Some use cases:
I'm Károly Lőrentey. My address: lorentey@elte.hu.
-Patches or suggestions are welcome!
+Comments, bug reports, suggestions and patches are welcome!
Retrieving the latest version of the branch:
------
Multi-tty support is stable, I think most of the problems were fixed.
-(It still needs testing on other architectures, though.) Please let
-me know if you find any bugs in it. Emacsclient has been extended to
-support opening a new terminal frame.
+(It still needs testing on other architectures, though.) Simultaneous
+X and tty frame support works fine, although there are some small
+issues. Emacsclient has been extended to support opening a new
+terminal frame.
+
+
+Please let me know if you find any bugs in this branch.
To try it out, compile and run the multi-tty branch with the following
commands:
cd +build
../configure
make bootstrap
- src/emacs -nw
+ src/emacs -nw # You can also try without -nw
M-x server-start
and then (from a shell prompt on another terminal) start emacsclient
This is work in progress, and probably full of bugs. You should
always run emacs from gdb, so that you'll have a live instance to
-debug if something goes wrong. Please send me your reports.
+debug if something goes wrong. Please send me your bug reports.
Problems:
devices. Also, there is no way to suspend emacsclient. This
will be fixed.
- * X support is (I hope) working, but at the moment there are
- problems with simultaneous X and tty devices, so don't do
- that - start a separate Emacs with -nw and run the server
- there.
-
* Mac, Windows and DOS support is broken, probably doesn't
even compile -- this will be solved later.
- * Only tested on my GNU/Linux box.
+ * Only tested on my GNU/Linux box and on Solaris 8.
NEWS
----
For the NEWS file:
-** Support for multiple terminal devices has been added. You can
- specify a terminal device (`tty' parameter) and a terminal type
- (`tty-type' parameter) to `make-terminal-frame'. `tty' must be a
- terminal device created by the updated emacsclient, or there will
- be problems with terminal input and window resizes.
+** Support for multiple terminal devices has been added.
- You can test for the presence of multiple terminal support by
- testing for the `multi-tty' feature.
+*** You can specify a terminal device (`tty' parameter) and a terminal
+ type (`tty-type' parameter) to `make-terminal-frame'.
-** A make-frame-on-tty function has been added to make it easier to
- create frames on new terminals.
+*** You can test for the presence of multiple terminal support by
+ testing for the `multi-tty' feature.
-** New functions: frame-tty-name, frame-tty-type for accessing
- terminal parameters, and delete-tty for closing the terminal
- device.
+*** Emacsclient has been extended to support opening a new terminal
+ frame (see -t option).
+
+*** A make-frame-on-tty function has been added to make it easier to
+ create frames on new terminals.
+
+*** New functions: frame-tty-name, frame-tty-type for accessing
+ terminal parameters, and delete-tty for closing the terminal
+ device.
+
+*** talk.el has been extended for multiple tty support.
+
+
+** Support for simultaneous graphical and terminal frames has been
+ added.
+
+*** The function `make-frame-on-display' now works during a terminal
+ session, and `make-frame-on-tty' works during a graphical session.
+
+*** The `window-system' variable has been made frame-local.
+
+*** The new `initial-window-system' variable contains the
+ `window-system' value for the first frame.
-** Emacsclient has been extended to support opening a new terminal
- frame.
CHANGELOG
---------
THINGS TO DO
------------
-** Fix color handling during X+tty combo sessions. (It seems that tty
+** Fix color handling during tty+X combo sessions. (It seems that tty
sessions automatically convert the face colors to terminal colors
when the face is loaded. This conversion must happen instead on
the fly in write_glyphs, which might be problematic, as color
approximation is currently done in lisp (term/tty-colors.el).)
+ (Update: hm, colors seem to work fine if I start emacs with -nw and
+ then create an X frame. Maybe it's just a small buglet somewhere.)
** Fix interactive use of temacs. There are face-related SEGVs, most
likely because of changes in realize_default_face, realize_face.
** Very strange bug: visible-bell does not work on secondary
terminals. This might be something xterm (konsole) specific.
-** Allow opening an X session after -nw.
-
** Find out the best way to support suspending Emacs with multiple
ttys. My guess: disable it on the controlling tty, but from other
ttys pass it on to emacsclient somehow. (It is (I hope) trivial to
extend emacsclient to handle suspend/resume. A `kill -STOP' almost
works right now.)
-** Exiting Emacs while there are emacsclient frames doesn't restore the
- ttys to their default states.
-
** Move baud_rate to struct display.
** Implement support for starting an interactive Emacs session without
single_kboard mode, and is not easily solvable. The best thing to
do is to simply refuse to create a tty frame of type `eterm'.
+** Maybe standard-display-table should be display-local.
+
DIARY OF CHANGES
----------------
Note that the above strace output seems to be an unrelated but
similar bug. I think that is now fixed.)
+-- Exiting Emacs while there are emacsclient frames doesn't restore the
+ ttys to their default states.
+
+ (This seems to be fixed by some previous change.)
+
+-- Allow opening an X session after -nw.
+
+ (Done.)
+
+
;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
;; If the user has already created the face, respect that.
(let ((value (or (get face 'saved-face) spec))
(frames (frame-list))
+ (have-window-system (memq initial-window-system '(x w32)))
frame)
;; Create global face.
(make-empty-face face)
(while frames
(setq frame (car frames)
frames (cdr frames))
- (face-spec-set face value frame)))
- ;; When making a face after frames already exist
- (if (memq window-system '(x w32))
- (make-face-x-resource-internal face))))
+ (face-spec-set face value frame)
+ (when (memq (window-system frame) '(x w32))
+ (setq have-window-system t)))
+ ;; When making a face after frames already exist
+ (if have-window-system
+ (make-face-x-resource-internal face)))))
;; Don't record SPEC until we see it causes no errors.
(put face 'face-defface-spec spec)
(when (and doc (null (face-documentation face)))
(setq parameters (x-handle-named-frame-geometry parameters))
(let ((visibility-spec (assq 'visibility parameters))
(frame-list (frame-list))
- (frame (x-create-frame `((frame-creation-function . x-create-frame-with-faces)
- (visibility . nil) . ,parameters)))
+ (frame (x-create-frame `((window-system . x) (visibility . nil) . ,parameters)))
success)
(unwind-protect
(progn
`default-frame-alist'. If either PARAMETERS or `default-frame-alist'
contains a `reverse' parameter, handle that. Value is the new frame
created."
- (let ((frame (make-terminal-frame `((frame-creation-function . tty-create-frame-with-faces) .
- ,parameters)))
+ (let ((frame (make-terminal-frame `((window-system . nil) . ,parameters)))
success)
(unwind-protect
(progn
;;; Code:
-(defvar frame-creation-function nil
- "Window-system dependent function to call to create a new frame.
-The window system startup file should set this to its frame creation
-function, which should take an alist of parameters as its argument.")
-
-(make-variable-frame-local 'frame-creation-function)
+(defvar frame-creation-function-alist
+ (list (cons nil
+ (if (fboundp 'tty-create-frame-with-faces)
+ 'tty-create-frame-with-faces
+ (function
+ (lambda (parameters)
+ (error "Can't create multiple frames without a window system"))))))
+ "Alist of window-system dependent functions to call to create a new frame.
+The window system startup file should add its frame creation
+function to this list, which should take an alist of parameters
+as its argument.")
;; The initial value given here used to ask for a minibuffer.
;; But that's not necessary, because the default is to have one.
(defun frame-initialize ()
"Create an initial frame if necessary."
;; Are we actually running under a window system at all?
- (if (and window-system (not noninteractive) (not (eq window-system 'pc)))
+ (if (and initial-window-system
+ (not noninteractive)
+ (not (eq initial-window-system 'pc)))
(progn
;; Turn on special-display processing only if there's a window system.
(setq special-display-function 'special-display-popup-frame)
(setq frame-initial-frame-alist
(cons '(horizontal-scroll-bars . t)
frame-initial-frame-alist)))
+ (setq frame-initial-frame-alist
+ (cons (cons 'window-system initial-window-system)
+ frame-initial-frame-alist))
(setq default-minibuffer-frame
(setq frame-initial-frame
(make-frame frame-initial-frame-alist)))
;; At this point, we know that we have a frame open, so we
;; can delete the terminal frame.
(delete-frame terminal-frame)
- (setq terminal-frame nil))
-
- ;; No, we're not running a window system. Use make-terminal-frame if
- ;; we support that feature, otherwise arrange to cause errors.
- (or (eq window-system 'pc)
- (setq frame-creation-function
- (if (fboundp 'tty-create-frame-with-faces)
- 'tty-create-frame-with-faces
- (function
- (lambda (parameters)
- (error
- "Can't create multiple frames without a window system"))))))))
+ (setq terminal-frame nil))))
(defvar frame-notice-user-settings t
"Non-nil means function `frame-notice-user-settings' wasn't run yet.")
;; Can't modify the minibuffer parameter, so don't try.
(setq parms (delq (assq 'minibuffer parms) parms))
(modify-frame-parameters nil
- (if (null window-system)
+ (if (null initial-window-system)
(append initial-frame-alist
default-frame-alist
parms
;; default-frame-alist were already
;; applied in pc-win.el.
parms))
- (if (null window-system) ;; MS-DOS does this differently in pc-win.el
+ (if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el
(let ((newparms (frame-parameters))
(frame (selected-frame)))
(tty-handle-reverse-video frame newparms)
(interactive "sMake frame on display: ")
(or (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
(error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
- (make-frame (cons (cons 'display display) parameters)))
+ (load (concat term-file-prefix "x-win"))
+ (make-frame `((window-system . x) (display . ,display) . ,parameters)))
-;;;###autoload
(defun make-frame-on-tty (device type &optional parameters)
"Make a frame on terminal DEVICE which is of type TYPE (e.g., \"xterm\").
-The optional third argument PARAMETERS specifies additional frame parameters.
-
-DEVICE must be a proxy psudo terminal created by emacsclient,
-otherwise there will be problems with terminal input and window
-resizes. (The kernel notifies processes about pending input or
-terminal resizes only on the controlling terminal, so we need
-emacsclient to sit on the real terminal device, create SIGIO
-signals upon terminal input, and forward SIGWINCH signals to
-us.)"
+The optional third argument PARAMETERS specifies additional frame parameters."
(interactive "fOpen frame on tty device: \nsTerminal type of %s: ")
(unless device
(error "Invalid terminal device"))
(unless type
(error "Invalid terminal type"))
- (tty-create-frame-with-faces (append (list (cons 'tty device) (cons 'tty-type type)) parameters)))
+ (make-frame `((window-system . nil) (tty . ,device) (tty-type . ,type) . ,parameters)))
(defun make-frame-command ()
"Make a new frame, and select it if the terminal displays only one frame."
(minibuffer . only) The frame should contain only a minibuffer.
(minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
-Before the frame is created (via `frame-creation-function'), functions on the
+ (window-system . nil) The frame should be displayed on a terminal device.
+ (window-system . x) The frame should be displayed in an X window.
+
+Before the frame is created (via `frame-creation-function-alist'), functions on the
hook `before-make-frame-hook' are run. After the frame is created, functions
on `after-make-frame-functions' are run with one arg, the newly created frame."
(interactive)
- (run-hooks 'before-make-frame-hook)
- (let ((frame (funcall frame-creation-function parameters)))
+ (let* ((w (if (assq 'window-system parameters)
+ (cdr (assq 'window-system parameters))
+ window-system))
+ (frame-creation-function (cdr (assq w frame-creation-function-alist)))
+ frame)
+ (unless frame-creation-function
+ (error "Don't know how to create a frame on window system %s" w))
+ (run-hooks 'before-make-frame-hook)
+ (funcall frame-creation-function parameters)
(run-hook-with-args 'after-make-frame-functions frame)
frame))
(raise-frame frame)
(select-frame frame)
;; Ensure, if possible, that frame gets input focus.
- (cond ((eq window-system 'x)
+ (cond ((eq (window-system frame) 'x)
(x-focus-frame frame))
- ((eq window-system 'w32)
+ ((eq (window-system frame) 'w32)
(w32-focus-frame frame)))
(when focus-follows-mouse
(set-mouse-position frame (1- (frame-width frame)) 0))))
(setq load-source-file-function 'load-with-code-conversion)
(load "files")
+(load "startup")
+
(load "cus-face")
(load "faces") ; after here, `defface' may be used.
(message "%s" (garbage-collect))
(load "menu-bar")
(load "paths.el") ;Don't get confused if someone compiled paths by mistake.
-(load "startup")
(load "emacs-lisp/lisp")
(load "textmodes/page")
(load "register")
(defvar command-line-processed nil
"Non-nil once command line has been processed.")
+(defvar window-system initial-window-system
+ "Name of window system the selected frame is displaying through.
+The value is a symbol--for instance, `x' for X windows.
+The value is nil if the selected frame is on a text-only-terminal.")
+
+(make-variable-frame-local 'window-system)
+
(defgroup initialization nil
"Emacs start-up procedure"
:group 'internal)
;; for instance due to a dense colormap.
(when (or frame-initial-frame
;; If frame-initial-frame has no meaning, do this anyway.
- (not (and window-system
+ (not (and initial-window-system
(not noninteractive)
- (not (eq window-system 'pc)))))
+ (not (eq initial-window-system 'pc)))))
;; Modify the initial frame based on what .emacs puts into
;; ...-frame-alist.
(if (fboundp 'frame-notice-user-settings)
(let ((frame-background-mode frame-background-mode)
(frame (selected-frame))
term)
- (when (and (null window-system)
+ (when (and (null initial-window-system)
;; Don't override a possibly customized value.
(null frame-background-mode)
;; Don't override user specifications.
;; Read window system's init file if using a window system.
(condition-case error
- (if (and window-system (not noninteractive))
+ (if (and initial-window-system (not noninteractive))
(load (concat term-file-prefix
- (symbol-name window-system)
+ (symbol-name initial-window-system)
"-win")
;; Every window system should have a startup file;
;; barf if we can't find it.
(cdr error) ", "))))
'external-debugging-output)
(terpri 'external-debugging-output)
- (setq window-system nil)
+ (setq initial-window-system nil)
(kill-emacs)))
;; Windowed displays do this inside their *-win.el.
;; If frame was created with a menu bar, set menu-bar-mode on.
(unless (or noninteractive
- (and (memq window-system '(x w32))
+ (and (memq initial-window-system '(x w32))
(<= (frame-parameter nil 'menu-bar-lines) 0)))
(menu-bar-mode 1))
(<= (frame-parameter nil 'tool-bar-lines) 0))
(tool-bar-mode 1))
- ;; Can't do this init in defcustom because window-system isn't set.
+ ;; Can't do this init in defcustom because initial-window-system isn't set.
(unless (or noninteractive
(eq system-type 'ms-dos)
- (not (memq window-system '(x w32))))
+ (not (memq initial-window-system '(x w32))))
(setq-default blink-cursor t)
(blink-cursor-mode 1))
;; DOS/Windows systems have a PC-type keyboard which has both
;; <delete> and <backspace> keys.
(when (or (memq system-type '(ms-dos windows-nt))
- (and (memq window-system '(x))
+ (and (memq initial-window-system '(x))
(fboundp 'x-backspace-delete-keys-p)
(x-backspace-delete-keys-p))
;; If the terminal Emacs is running on has erase char
;; set to ^H, use the Backspace key for deleting
;; backward and, and the Delete key for deleting forward.
- (and (null window-system)
+ (and (null initial-window-system)
(eq tty-erase-char 8)))
(setq-default normal-erase-is-backspace t)
(normal-erase-is-backspace-mode 1)))
;; Register default TTY colors for the case the terminal hasn't a
;; terminal init file.
- (unless (memq window-system '(x w32))
+ (unless (memq initial-window-system '(x w32))
;; We do this regardles of whether the terminal supports colors
;; or not, since they can switch that support on or off in
;; mid-session by setting the tty-color-mode frame parameter.
;; Load library for our terminal type.
;; User init file can set term-file-prefix to nil to prevent this.
(unless (or noninteractive
- window-system
+ initial-window-system
(null term-file-prefix))
(let ((term (getenv "TERM"))
hyphend)
;; An alist of X options and the function which handles them. See
;; ../startup.el.
-(if (not (eq window-system 'x))
+(if (not (fboundp 'x-create-frame))
(error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
(require 'frame)
\f
;;;; Function keys
+;;; XXX This might be wrong with multi-tty support.
(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
global-map)
(x-open-connection (or x-display-name
(setq x-display-name (getenv "DISPLAY")))
x-command-line-resources
- ;; Exit Emacs with fatal error if this fails.
- t)
+ ;; Exit Emacs with fatal error if this fails and we
+ ;; are the initial display.
+ (eq initial-window-system 'x))
-(setq frame-creation-function 'x-create-frame-with-faces)
+(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
x-cut-buffer-max))
(if res-selection-timeout
(setq x-selection-timeout (string-to-number res-selection-timeout))))
+;; XXX This is wrong with multi-tty support.
(defun x-win-suspend-error ()
(error "Suspending an Emacs running under X makes no sense"))
(add-hook 'suspend-hook 'x-win-suspend-error)
;; Turn on support for mouse wheels.
(mouse-wheel-mode 1)
+(provide 'x-win)
+
;;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
;;; x-win.el ends here
EMACS_INT baud_rate;
/* Either nil or a symbol naming the window system under which Emacs
- is running. */
+ creates the first frame. */
-Lisp_Object Vwindow_system;
+Lisp_Object Vinitial_window_system;
/* Version number of X windows: 10, 11 or nil. */
/* Now is the time to initialize this; it's used by init_sys_modes
during startup. */
- Vwindow_system = Qnil;
+ Vinitial_window_system = Qnil;
/* If the user wants to use a window system, we shouldn't bother
initializing the terminal. This is especially important when the
#endif
)
{
- Vwindow_system = intern ("x");
+ Vinitial_window_system = intern ("x");
#ifdef HAVE_X11
Vwindow_system_version = make_number (11);
#else
#ifdef HAVE_NTGUI
if (!inhibit_window_system)
{
- Vwindow_system = intern ("w32");
+ Vinitial_window_system = intern ("w32");
Vwindow_system_version = make_number (1);
adjust_frame_glyphs_initially ();
return;
#ifdef MAC_OS
if (!inhibit_window_system)
{
- Vwindow_system = intern ("mac");
+ Vinitial_window_system = intern ("mac");
Vwindow_system_version = make_number (1);
adjust_frame_glyphs_initially ();
return;
and internal_terminal_init. */
&& (strcmp (terminal_type, "internal") != 0 || inhibit_window_system)
#endif
- && NILP (Vwindow_system))
+ && NILP (Vinitial_window_system))
{
/* For the initial frame, we don't have any way of knowing what
are the foreground and background colors of the terminal. */
Emacs's frame display when you reenter Emacs.
It is up to you to set this variable if your terminal can do that. */);
- DEFVAR_LISP ("window-system", &Vwindow_system,
- doc: /* Name of window system that Emacs is displaying through.
+ DEFVAR_LISP ("initial-window-system", &Vinitial_window_system,
+ doc: /* Name of the window system that Emacs uses for the first frame.
The value is a symbol--for instance, `x' for X windows.
The value is nil if Emacs is using a text-only terminal. */);
if (noninteractive)
#endif
{
- Vwindow_system = Qnil;
+ Vinitial_window_system = Qnil;
Vwindow_system_version = Qnil;
}
}
char *stack_bottom;
#ifdef HAVE_WINDOW_SYSTEM
-extern Lisp_Object Vwindow_system;
+extern Lisp_Object Vinitial_window_system;
#endif /* HAVE_WINDOW_SYSTEM */
extern Lisp_Object Vauto_save_list_file_name;
#if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
#ifdef HAVE_X_WINDOWS
/* It's not safe to call intern here. Maybe we are crashing. */
- if (!noninteractive && SYMBOLP (Vwindow_system)
- && SCHARS (SYMBOL_NAME (Vwindow_system)) == 1
- && SREF (SYMBOL_NAME (Vwindow_system), 0) == 'x'
+ if (!noninteractive && SYMBOLP (Vinitial_window_system)
+ && SCHARS (SYMBOL_NAME (Vinitial_window_system)) == 1
+ && SREF (SYMBOL_NAME (Vinitial_window_system), 0) == 'x'
&& ! no_x)
Fx_close_current_connection ();
#endif /* HAVE_X_WINDOWS */
#ifndef DOS_NT
/* this causes startup screen to be restored and messes with the mouse */
- if (FRAME_TERMCAP_P (SELECTED_FRAME ()))
- reset_sys_modes (CURTTY ());
+ reset_all_sys_modes ();
#endif
#ifdef SIGIO
tty->meta_key = 2;
}
- if (FRAME_TERMCAP_P (XFRAME (selected_frame)) && !NILP (quit))
+ if (!NILP (quit))
/* Don't let this value be out of range. */
- quit_char = XINT (quit) & (CURTTY ()->meta_key ? 0377 : 0177);
+ quit_char = XINT (quit) & (NILP (meta) ? 0177 : 0377);
#ifndef DOS_NT
- if (FRAME_TERMCAP_P (XFRAME (selected_frame)) && CURTTY ()->type)
- init_sys_modes (CURTTY ());
+ init_all_sys_modes ();
#endif
#ifdef POLL_FOR_INPUT
#if 0
/* read_socket_hook is not global anymore. I think doing this
unconditionally will not cause any problems. */
- if (! read_socket_hook && EQ (Vwindow_system, Qnil))
+ if (! read_socket_hook && EQ (Vinitial_window_system, Qnil))
#endif
narrow_foreground_group (fileno (TTY_INPUT (tty_out)));
#endif
-#ifdef HAVE_WINDOW_SYSTEM
- /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
- needs the initialization code below. */
- if (tty_out->input != stdin || EQ (Vwindow_system, Qnil))
-#endif
- {
- if (! tty_out->old_tty)
- tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
+ if (! tty_out->old_tty)
+ tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
- EMACS_GET_TTY (fileno (TTY_INPUT (tty_out)), tty_out->old_tty);
+ EMACS_GET_TTY (fileno (TTY_INPUT (tty_out)), tty_out->old_tty);
- tty = *tty_out->old_tty;
+ tty = *tty_out->old_tty;
#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
- XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
+ XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
#ifdef DGUX
- /* This allows meta to be sent on 8th bit. */
- tty.main.c_iflag &= ~INPCK; /* don't check input for parity */
+ /* This allows meta to be sent on 8th bit. */
+ tty.main.c_iflag &= ~INPCK; /* don't check input for parity */
#endif
- tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */
- tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */
+ tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */
+ tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */
#ifdef INLCR /* I'm just being cautious,
since I can't check how widespread INLCR is--rms. */
- tty.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */
+ tty.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */
#endif
#ifdef ISTRIP
- tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */
+ tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */
#endif
- tty.main.c_lflag &= ~ECHO; /* Disable echo */
- tty.main.c_lflag &= ~ICANON; /* Disable erase/kill processing */
+ tty.main.c_lflag &= ~ECHO; /* Disable echo */
+ tty.main.c_lflag &= ~ICANON; /* Disable erase/kill processing */
#ifdef IEXTEN
- tty.main.c_lflag &= ~IEXTEN; /* Disable other editing characters. */
+ tty.main.c_lflag &= ~IEXTEN; /* Disable other editing characters. */
#endif
- tty.main.c_lflag |= ISIG; /* Enable signals */
- if (tty_out->flow_control)
- {
- tty.main.c_iflag |= IXON; /* Enable start/stop output control */
+ tty.main.c_lflag |= ISIG; /* Enable signals */
+ if (tty_out->flow_control)
+ {
+ tty.main.c_iflag |= IXON; /* Enable start/stop output control */
#ifdef IXANY
- tty.main.c_iflag &= ~IXANY;
+ tty.main.c_iflag &= ~IXANY;
#endif /* IXANY */
- }
- else
- tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */
- tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL
- on output */
- tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */
+ }
+ else
+ tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */
+ tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL
+ on output */
+ tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */
#ifdef CS8
- if (tty_out->meta_key)
- {
- tty.main.c_cflag |= CS8; /* allow 8th bit on input */
- tty.main.c_cflag &= ~PARENB;/* Don't check parity */
- }
+ if (tty_out->meta_key)
+ {
+ tty.main.c_cflag |= CS8; /* allow 8th bit on input */
+ tty.main.c_cflag &= ~PARENB;/* Don't check parity */
+ }
#endif
- if (tty_out->input == stdin)
- {
- tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */
- /* Set up C-g for both SIGQUIT and SIGINT.
- We don't know which we will get, but we handle both alike
- so which one it really gives us does not matter. */
- tty.main.c_cc[VQUIT] = quit_char;
- }
- else
- {
- /* We normally don't get interrupt or quit signals from tty
- devices other than our controlling terminal; therefore,
- we must handle C-g as normal input. Unfortunately, this
- means that the interrupt and quit feature must be
- disabled on secondary ttys, or we would not even see the
- keypress.
-
- Note that even though emacsclient could have special code
- to pass SIGINT to Emacs, we should _not_ enable
- interrupt/quit keys for emacsclient frames. This means
- that we can't break out of loops in C code from a
- secondary tty frame, but we can always decide what
- display the C-g came from, which is more important from a
- usability point of view. (Consider the case when two
- people work together using the same Emacs instance.) */
- tty.main.c_cc[VINTR] = CDISABLE;
- tty.main.c_cc[VQUIT] = CDISABLE;
- }
- tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */
- tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */
+ if (tty_out->input == stdin)
+ {
+ tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */
+ /* Set up C-g for both SIGQUIT and SIGINT.
+ We don't know which we will get, but we handle both alike
+ so which one it really gives us does not matter. */
+ tty.main.c_cc[VQUIT] = quit_char;
+ }
+ else
+ {
+ /* We normally don't get interrupt or quit signals from tty
+ devices other than our controlling terminal; therefore,
+ we must handle C-g as normal input. Unfortunately, this
+ means that the interrupt and quit feature must be
+ disabled on secondary ttys, or we would not even see the
+ keypress.
+
+ Note that even though emacsclient could have special code
+ to pass SIGINT to Emacs, we should _not_ enable
+ interrupt/quit keys for emacsclient frames. This means
+ that we can't break out of loops in C code from a
+ secondary tty frame, but we can always decide what
+ display the C-g came from, which is more important from a
+ usability point of view. (Consider the case when two
+ people work together using the same Emacs instance.) */
+ tty.main.c_cc[VINTR] = CDISABLE;
+ tty.main.c_cc[VQUIT] = CDISABLE;
+ }
+ tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */
+ tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */
#ifdef VSWTCH
- tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use
+ tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use
of C-z */
#endif /* VSWTCH */
-
+
#if defined (mips) || defined (HAVE_TCATTR)
#ifdef VSUSP
- tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */
+ tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */
#endif /* VSUSP */
#ifdef V_DSUSP
- tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */
+ tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */
#endif /* V_DSUSP */
#ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */
- tty.main.c_cc[VDSUSP] = CDISABLE;
+ tty.main.c_cc[VDSUSP] = CDISABLE;
#endif /* VDSUSP */
#ifdef VLNEXT
- tty.main.c_cc[VLNEXT] = CDISABLE;
+ tty.main.c_cc[VLNEXT] = CDISABLE;
#endif /* VLNEXT */
#ifdef VREPRINT
- tty.main.c_cc[VREPRINT] = CDISABLE;
+ tty.main.c_cc[VREPRINT] = CDISABLE;
#endif /* VREPRINT */
#ifdef VWERASE
- tty.main.c_cc[VWERASE] = CDISABLE;
+ tty.main.c_cc[VWERASE] = CDISABLE;
#endif /* VWERASE */
#ifdef VDISCARD
- tty.main.c_cc[VDISCARD] = CDISABLE;
+ tty.main.c_cc[VDISCARD] = CDISABLE;
#endif /* VDISCARD */
- if (tty_out->flow_control)
- {
+ if (tty_out->flow_control)
+ {
#ifdef VSTART
- tty.main.c_cc[VSTART] = '\021';
+ tty.main.c_cc[VSTART] = '\021';
#endif /* VSTART */
#ifdef VSTOP
- tty.main.c_cc[VSTOP] = '\023';
+ tty.main.c_cc[VSTOP] = '\023';
#endif /* VSTOP */
- }
- else
- {
+ }
+ else
+ {
#ifdef VSTART
- tty.main.c_cc[VSTART] = CDISABLE;
+ tty.main.c_cc[VSTART] = CDISABLE;
#endif /* VSTART */
#ifdef VSTOP
- tty.main.c_cc[VSTOP] = CDISABLE;
+ tty.main.c_cc[VSTOP] = CDISABLE;
#endif /* VSTOP */
- }
+ }
#endif /* mips or HAVE_TCATTR */
#ifdef SET_LINE_DISCIPLINE
- /* Need to explicitly request TERMIODISC line discipline or
- Ultrix's termios does not work correctly. */
- tty.main.c_line = SET_LINE_DISCIPLINE;
+ /* Need to explicitly request TERMIODISC line discipline or
+ Ultrix's termios does not work correctly. */
+ tty.main.c_line = SET_LINE_DISCIPLINE;
#endif
#ifdef AIX
#ifndef IBMR2AIX
- /* AIX enhanced edit loses NULs, so disable it. */
- tty.main.c_line = 0;
- tty.main.c_iflag &= ~ASCEDIT;
+ /* AIX enhanced edit loses NULs, so disable it. */
+ tty.main.c_line = 0;
+ tty.main.c_iflag &= ~ASCEDIT;
#else
- tty.main.c_cc[VSTRT] = 255;
- tty.main.c_cc[VSTOP] = 255;
- tty.main.c_cc[VSUSP] = 255;
- tty.main.c_cc[VDSUSP] = 255;
+ tty.main.c_cc[VSTRT] = 255;
+ tty.main.c_cc[VSTOP] = 255;
+ tty.main.c_cc[VSUSP] = 255;
+ tty.main.c_cc[VDSUSP] = 255;
#endif /* IBMR2AIX */
- if (tty_out->flow_control)
- {
+ if (tty_out->flow_control)
+ {
#ifdef VSTART
- tty.main.c_cc[VSTART] = '\021';
+ tty.main.c_cc[VSTART] = '\021';
#endif /* VSTART */
#ifdef VSTOP
- tty.main.c_cc[VSTOP] = '\023';
+ tty.main.c_cc[VSTOP] = '\023';
#endif /* VSTOP */
- }
- /* Also, PTY overloads NUL and BREAK.
- don't ignore break, but don't signal either, so it looks like NUL.
- This really serves a purpose only if running in an XTERM window
- or via TELNET or the like, but does no harm elsewhere. */
- tty.main.c_iflag &= ~IGNBRK;
- tty.main.c_iflag &= ~BRKINT;
+ }
+ /* Also, PTY overloads NUL and BREAK.
+ don't ignore break, but don't signal either, so it looks like NUL.
+ This really serves a purpose only if running in an XTERM window
+ or via TELNET or the like, but does no harm elsewhere. */
+ tty.main.c_iflag &= ~IGNBRK;
+ tty.main.c_iflag &= ~BRKINT;
#endif
#else /* if not HAVE_TERMIO */
#ifdef VMS
- tty.main.tt_char |= TT$M_NOECHO;
- if (meta_key)
- tty.main.tt_char |= TT$M_EIGHTBIT;
- if (tty_out->flow_control)
- tty.main.tt_char |= TT$M_TTSYNC;
- else
- tty.main.tt_char &= ~TT$M_TTSYNC;
- tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON;
+ tty.main.tt_char |= TT$M_NOECHO;
+ if (meta_key)
+ tty.main.tt_char |= TT$M_EIGHTBIT;
+ if (tty_out->flow_control)
+ tty.main.tt_char |= TT$M_TTSYNC;
+ else
+ tty.main.tt_char &= ~TT$M_TTSYNC;
+ tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON;
#else /* not VMS (BSD, that is) */
#ifndef DOS_NT
- XSETINT (Vtty_erase_char, tty.main.sg_erase);
- tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
- if (meta_key)
- tty.main.sg_flags |= ANYP;
- tty.main.sg_flags |= interrupt_input ? RAW : CBREAK;
+ XSETINT (Vtty_erase_char, tty.main.sg_erase);
+ tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
+ if (meta_key)
+ tty.main.sg_flags |= ANYP;
+ tty.main.sg_flags |= interrupt_input ? RAW : CBREAK;
#endif /* not DOS_NT */
#endif /* not VMS (BSD, that is) */
#endif /* not HAVE_TERMIO */
- /* If going to use CBREAK mode, we must request C-g to interrupt
- and turn off start and stop chars, etc. If not going to use
- CBREAK mode, do this anyway so as to turn off local flow
- control for user coming over network on 4.2; in this case,
- only t_stopc and t_startc really matter. */
+ /* If going to use CBREAK mode, we must request C-g to interrupt
+ and turn off start and stop chars, etc. If not going to use
+ CBREAK mode, do this anyway so as to turn off local flow
+ control for user coming over network on 4.2; in this case,
+ only t_stopc and t_startc really matter. */
#ifndef HAVE_TERMIO
#ifdef HAVE_TCHARS
- /* Note: if not using CBREAK mode, it makes no difference how we
- set this */
- tty.tchars = new_tchars;
- tty.tchars.t_intrc = quit_char;
- if (tty_out->flow_control)
- {
- tty.tchars.t_startc = '\021';
- tty.tchars.t_stopc = '\023';
- }
-
- tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
+ /* Note: if not using CBREAK mode, it makes no difference how we
+ set this */
+ tty.tchars = new_tchars;
+ tty.tchars.t_intrc = quit_char;
+ if (tty_out->flow_control)
+ {
+ tty.tchars.t_startc = '\021';
+ tty.tchars.t_stopc = '\023';
+ }
+
+ tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
#ifdef ultrix
- /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
- anything, and leaving it in breaks the meta key. Go figure. */
- tty.lmode &= ~LLITOUT;
+ /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
+ anything, and leaving it in breaks the meta key. Go figure. */
+ tty.lmode &= ~LLITOUT;
#endif
-
+
#ifdef BSD4_1
- lmode = tty.lmode;
+ lmode = tty.lmode;
#endif
#endif /* HAVE_TCHARS */
#endif /* not HAVE_TERMIO */
#ifdef HAVE_LTCHARS
- tty.ltchars = new_ltchars;
+ tty.ltchars = new_ltchars;
#endif /* HAVE_LTCHARS */
#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
- if (!tty_out->term_initted)
- internal_terminal_init ();
- dos_ttraw ();
+ if (!tty_out->term_initted)
+ internal_terminal_init ();
+ dos_ttraw ();
#endif
- EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)), &tty, 0);
+ EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)), &tty, 0);
- /* This code added to insure that, if flow-control is not to be used,
- we have an unlocked terminal at the start. */
+ /* This code added to insure that, if flow-control is not to be used,
+ we have an unlocked terminal at the start. */
#ifdef TCXONC
- if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TCXONC, 1);
+ if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TCXONC, 1);
#endif
#ifndef APOLLO
#ifdef TIOCSTART
- if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TIOCSTART, 0);
+ if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TIOCSTART, 0);
#endif
#endif
#if defined (HAVE_TERMIOS) || defined (HPUX9)
#ifdef TCOON
- if (!tty_out->flow_control) tcflow (fileno (TTY_INPUT (tty_out)), TCOON);
+ if (!tty_out->flow_control) tcflow (fileno (TTY_INPUT (tty_out)), TCOON);
#endif
#endif
#ifdef AIXHFT
- hft_init (tty_out);
+ hft_init (tty_out);
#ifdef IBMR2AIX
- {
- /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it
- to be only LF. This is the way that is done. */
- struct termio tty;
-
- if (ioctl (1, HFTGETID, &tty) != -1)
- write (1, "\033[20l", 5);
- }
+ {
+ /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it
+ to be only LF. This is the way that is done. */
+ struct termio tty;
+
+ if (ioctl (1, HFTGETID, &tty) != -1)
+ write (1, "\033[20l", 5);
+ }
#endif
#endif /* AIXHFT */
SYS$QIOW (0, fileno (TTY_INPUT (tty_out)), IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0,
interrupt_signal, oob_chars, 0, 0, 0, 0);
*/
- queue_kbd_input (0);
+ queue_kbd_input (0);
#endif /* VMS */
- }
#ifdef F_SETFL
#ifndef F_SETOWN_BUG
#ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */
- if (interrupt_input
- && (tty_out->input != stdin || EQ (Vwindow_system, Qnil)))
+ if (interrupt_input)
{
old_fcntl_owner[fileno (TTY_INPUT (tty_out))] =
fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0);
setbuf (TTY_OUTPUT (tty_out), (char *) _sobuf);
#endif
-#if 0 /* We always need this with multi-tty support. */
-#ifdef HAVE_WINDOW_SYSTEM
- /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
- needs the initialization code below. */
- if (EQ (Vwindow_system, Qnil)
-#ifndef WINDOWSNT
- /* When running in tty mode on NT/Win95, we have a read_socket
- hook, but still need the rest of the initialization code below. */
- && (! read_socket_hook)
-#endif
- )
-#endif
-#endif
- tty_set_terminal_modes (tty_out->display);
+ tty_set_terminal_modes (tty_out->display);
if (!tty_out->term_initted)
{
}
if (!tty_out->term_initted)
return;
-#if 0 /* We always need to do this with multi-tty support. */
-#ifdef HAVE_WINDOW_SYSTEM
- /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
- needs the clean-up code below. */
- if (tty_out->input != stdin
- || (!EQ (Vwindow_system, Qnil)
-#ifndef WINDOWSNT
- /* When running in tty mode on NT/Win95, we have a read_socket
- hook, but still need the rest of the clean-up code below. */
- || read_socket_hook
-#endif
- ))
- return;
-#endif
-#endif
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
#if 0 /* XXX This doesn't work anymore, the signature has changed. */
SELECT_TYPE *rfds, *wfds, *efds;
EMACS_TIME *timeout;
{
- int ravail = 0;
+ /* XXX This needs to be updated for multi-tty support. Is there
+ anybody who needs to emulate select these days? */
+ int ravail = 0;
SELECT_TYPE orfds;
int timeoutval;
int *local_timeout;
#if defined (HAVE_SELECT) && defined (HAVE_X_WINDOWS)
/* If we're using X, then the native select will work; we only need the
emulation for non-X usage. */
- if (!NILP (Vwindow_system))
+ if (!NILP (Vinitial_window_system))
return select (nfds, rfds, wfds, efds, timeout);
#endif
timeoutval = timeout ? EMACS_SECS (*timeout) : 100000;
void
read_input_waiting ()
{
- /* XXX This needs to be updated for multi-tty support. Does
- anybody need to emulate select these days? */
+ /* XXX This needs to be updated for multi-tty support. Is there
+ anybody who needs to emulate select these days? */
int nread, i;
extern int quit_char;
/* Nil or a symbol naming the window system under which emacs is
running ('x is the only current possibility) */
-extern Lisp_Object Vwindow_system;
+extern Lisp_Object Vinitial_window_system;
/* Version number of X windows: 10, 11 or nil. */
Lisp_Object parent;
struct kboard *kb;
- check_x ();
-
/* Use this general default value to start with
until we know if this frame has a specified name. */
Vx_resource_name = Vinvocation_name;
CHECK_STRING (name);
- if (! EQ (Vwindow_system, intern ("x")))
- error ("Not using X Windows");
+#if 0
+ if (! EQ (Vinitial_window_system, intern ("x")))
+ error ("Not using X Windows"); /* That doesn't stop us anymore. */
+#endif
for (dpyinfo = x_display_list, names = x_display_name_list;
dpyinfo;
if (! NILP (xrm_string))
CHECK_STRING (xrm_string);
- if (! EQ (Vwindow_system, intern ("x")))
- error ("Not using X Windows");
+#if 0
+ if (! EQ (Vinitial_window_system, intern ("x")))
+ error ("Not using X Windows"); /* That doesn't stop us anymore. */
+#endif
if (! NILP (xrm_string))
xrm_option = (unsigned char *) SDATA (xrm_string);