Mercurial > emacs
changeset 82993:0abaf12fa706
Merged in changes from CVS HEAD
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-10
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-11
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-12
Add section on button package to lisp reference manual
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-13
Minor tweaks to Buttons section in lispref/display.texi
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-14
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-33
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Fri, 02 Jan 2004 04:37:46 +0000 |
parents | 5de4189e659d (diff) e93d01ecd023 (current diff) |
children | 44ffe551079c |
files | lisp/ChangeLog src/print.c src/process.c src/w32term.c |
diffstat | 128 files changed, 3749 insertions(+), 2227 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.multi-tty Fri Jan 02 04:37:46 2004 +0000 @@ -0,0 +1,439 @@ + -*- coding: utf-8; -*- +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. + +Some use cases: + +Emacs is notoriously slow at startup, so most people use another +editor or emacsclient for quick editing jobs from the console. +Unfortunately, emacsclient was very awkward to use, because it did not +support opening a new Emacs frame on the current virtual console. +Now, with multi-tty support, it can do that. (Emacsclient starts up +faster than vi!) + +Some Gnus users (including me) run Gnus in an X frame in its own Emacs +instance, which they typically leave running for weeks. It would be +nice if they could connect to this instance from a remote ssh session +and check their messages without opening a remote X frame or resorting +to gnus-slave. + + +WHO IS DOING IT +--------------- + +I'm Károly Lőrentey. My address: lorentey@elte.hu. + +Patches or suggestions are welcome! + +Retrieving the latest version of the branch: + + tla register-archive lorentey@elte.hu--2004 http://lorentey.web.elte.hu/arch/2004/ + tla get lorentey@elte.hu--2004/emacs--multi-tty <directory> + +(I use a recent arch development snapshot, but any of the released +versions of arch will do fine, I think.) + +If you don't have arch, the branch has a homepage from which you can +download conventional patches against Emacs CVS HEAD: + + http://lorentey.web.elte.hu/project/emacs.html + +STATUS +------ + +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. + +To try it out, compile and run the multi-tty branch with the following +commands: + + mkdir +build + cd +build + ../configure + make bootstrap + src/emacs -nw + M-x server-start + +and then (from a shell prompt on another terminal) start emacsclient +with + + lib-src/emacsclient -t /optional/file/names... + +You'll hopefully have two fully working, independent frames on +separate terminals. The new frame is closed automatically when you +have finished editing the specified files (C-x #), but delete-frame +(C-x 5 0) also works. Of course, you can create frames on more than +two tty devices. + +Creating new frames on the same tty with C-x 5 2 works, and they +behave the same way as in previous Emacs versions. If you exit emacs, +all terminals should be restored to their previous states. + +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. + +Problems: + + * Suspending Emacs is disabled if there are multiple tty + 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. + +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. + + You can test for the presence of multiple terminal support by + testing for the `multi-tty' feature. + +** 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. + +** Emacsclient has been extended to support opening a new terminal + frame. + +CHANGELOG +--------- + +See arch logs. + +THINGS TO DO +------------ + +** Something with (maybe) multi-keyboard support broke function keys + and arrows on ttys during X+tty combo sessions. Debug this. + +** Fix faces on tty frames during X-tty combo sessions. + +** During an X-tty combo session, a (message "Hello") from a tty frame + goes to the X frame. Fix this. + +** 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.) + +** Move baud_rate to tty_output. + +** Do tty output through term_hooks, like graphical display backends. + +** Implement support for starting an interactive Emacs session without + an initial frame. (The user would connect to it and open frames + later, with emacsclient.) Not necessarily a good idea. + +** Fix input from raw ttys (again). + +** Fix Mac support (I can't do this myself). + +** Fix W32 support (I can't do this myself). + +** Fix DOS support (I can't do this myself). + +** Do a grep on XXX and ?? for more issues. + +** Understand Emacs's low-level input system (it seems complicated) :-) + +** What does interrupt_input do? I tried to disable it for raw + secondary tty support, but it does not seem to do anything useful. + (Update: Look again. X unconditionally enables this, maybe that's + why raw terminal support is broken again. I really do need to + understand input.) + +** Make sure C-g goes to the right frame. This is hard, as SIGINT + doesn't have a tty parameter. :-( + +** I have seen a case when Emacs with multiple ttys fell into a loop + eating 100% of CPU time. Strace showed this loop: + + getpid() = 30284 + kill(30284, SIGIO) = 0 + --- SIGIO (I/O possible) @ 0 (0) --- + ioctl(6, FIONREAD, [0]) = -1 EIO (Input/output error) + ioctl(5, FIONREAD, [0]) = -1 EIO (Input/output error) + ioctl(0, FIONREAD, [0]) = 0 + sigreturn() = ? (mask now []) + gettimeofday({1072842297, 747760}, NULL) = 0 + gettimeofday({1072842297, 747806}, NULL) = 0 + select(9, [0 3 5 6], NULL, NULL, {0, 0}) = 2 (in [5 6], left {0, 0}) + select(9, [0 3 5 6], NULL, NULL, {0, 0}) = 2 (in [5 6], left {0, 0}) + gettimeofday({1072842297, 748245}, NULL) = 0 + + I have not been able to reproduce this. + +** Define a output_initial value for output_method for the initial + frame that is dumped with Emacs. Checking for this frame (e.g. in + cmd_error_internal) is ugly. + +** emacsclient -t from an Emacs term buffer does not work, complains + about face problems. This can even lock up Emacs (if the recursive + frame sets single_kboard). + +DIARY OF CHANGES +---------------- + +(ex-TODO items with explanations.) + +-- Introduce a new struct for terminal devices. + + (Done, see struct tty_output. The list of members is not yet + complete.) + +-- Change the bootstrap procedure to initialize tty_list. + + (Done, but needs review.) + +-- Change make-terminal-frame to support specifying another tty. + + (Done, new frame parameters: `tty' and `tty-type'.) + +-- Implement support for reading from multiple terminals. + + (Done, read_avail_input tries to read from each terminal, until one + succeeds. MULTI_KBOARD is not used. Secondary terminals don't send + SIGIO!) + + (Update: They do, now.) + + (Update2: After enabling X, they don't.) + +-- other-frame should cycle through the frames on the `current' + terminal only. + + (Done, by trivially modifiying next_frame and prev_frame.) + +-- Support different terminal sizes. + + (Done, no problem.) + +-- Make sure terminal resizes are handled gracefully. (Could be + problematic.) + + (Done. We don't get automatic SIGWINCH for additional ttys, + though.) + +-- Extend emacsclient to automatically open a new tty when it connects + to Emacs. + + (Done. It's an ugly hack, needs more work.) + +-- Redisplay must refresh the topmost frame on *all* terminals, not + just the initial terminal. + + (Done, but introduced an ugly redisplay problems. Ugh.) + +-- Fix redisplay problems. + + (Done; it turned out that the entire Wcm structure must be moved + inside tty_output. Why didn't I catch this earlier?) + +-- Provide a way for emacsclient to tell Emacs that the tty has been + resized. + + (Done, simply forward the SIGWINCH signal.) + +-- Each keypress should automatically select the frame corresponding + to the terminal that it was coming from. This means that Emacs + must know from which terminal the last keyboard event came from. + + (Done, it was quite simple, the input event system already + supported multiple frames.) + +-- Fix SIGIO issue with secondary terminals. + + (Done, emacsclient signals Emacs after writing to the proxy pseudo + terminal. Note that this means that multi-tty does not work with + raw ttys!) + + (Update: This is bullshit. There is a read_input_waiting function, + extend that somehow.) + + (Update of update: The first update was not right either, extending + read_input_waiting was not necessary. Secondary ttys do seem to + send signals on input.) + + (Update^3: Not any more.) + +-- Make make-terminal-frame look up the `tty' and `tty-type' frame + parameters from the currently selected terminal before the global + default. + + (Done.) + +-- Put all cached terminal escape sequences into struct tty_output. + Currently, they are still stored in global variables, so we don't + really support multiple terminal types. + + (Done. It was not fun.) + +-- Implement sane error handling after initialization. (Currently + emacs exits if you specify a bad terminal type.) The helpful error + messages must still be provided when Emacs starts. + + (Done.) + +-- Implement terminal deletion, i.e., deleting local frames, closing + the tty device and restoring its previous state without exiting + Emacs. + + (Done, but at the moment only called when an error happens during + initialization. There is a memory corruption error around this + somewhere.) (Update: now it is fully enabled.) + +-- Implement automatic deletion of terminals when the last frame on + that terminal is closed. + + (Done.) + +-- Restore tty screen after closing the terminal. + + (Done, we do the same as Emacs 21.2 for all terminals.) + +-- 'TERM=dumb src/emacs' does not restore the terminal state. + + (Done.) + +-- C-g should work on secondary terminals. + + (Done, but the binding is not configurable.) + +-- Deal with SIGHUP in Emacs and in emacsclient. (After this, the + server-frames may be removed from server.el.) + + (Done, nothing to do. It seems that Emacs does not receive SIGHUP + from secondary ttys, which is actually a good thing.) (Update: I + think it would be a bad idea to remove server-frames.) + +-- Change emacsclient/server.el to support the -t argument better, + i.e. automatically close the socket when the frame is closed. + + (Seems to be working OK.) + +-- Fix mysterious memory corruption error with tty deletion. To + trigger it, try the following shell command: + + while true; do TERM=no-such-terminal-definition emacsclient -h; done + + Emacs usually dumps core after a few dozen iterations. (The bug + seems to be related to the xfree()ing or bzero()ing of + tty_output.Wcm. Maybe there are outside references to struct Wcm? + Why were these vars collected into a struct before multi-tty + support?) + + (Done. Whew. It turned out that the problem had nothing to do + with hypothetical external references to Wcm, or any other + tty_output component; it was simply that delete_tty closed the + filehandles of secondary ttys twice, resulting in fclose doubly + free()ing memory. Utterly trivial matter. I love the C's memory + management, it puts hair on your chest.) + +-- Support raw secondary terminals. (Note that SIGIO works only on + the controlling terminal.) Hint: extend read_input_waiting() for + multiple ttys and hopefully this will be fixed. + + (Done, it seems to have been working already for some time. It + seems F_SETOWN does work, after all. Not sure what made it fail + earlier, but it seems to be fixed (there were several changes + around request_sigio, maybe one of them did it). + read_input_waiting() is only used in sys_select(), don't change + it.) (Update: After adding X support, it's broken again.) + +-- Find out why does Emacs abort when it wants to close its + controlling tty. Hint: chan_process[] array. Hey, maybe + noninterrupt-IO would work, too? Update: no, there is no process + for stdin/out. + + (Done. Added add/delete_keyboard_wait_descriptor to + term_init/delete_tty. The hint was right, in a way.) + +-- Issue with SIGIO: it needs to be disabled during redisplay. See if + fcntl() kernel behaviour could be emulated by emacsclient. + + (Done. Simply disabled the SIGIO emulation hack in emacsclient.) + (Update: it was added back.) + +-- server.el: There are issues with saving files in buffers of closed + clients. Try editing a file with emacsclient -f, and (without + saving it) do a delete-frame. The frame is closed without + question, and a surprising confirmation prompt appears in another + frame. + + (Done. delete-frame now asks for confirmation if it still has + pending buffers, and modified buffers don't seem to be deleted.) + +-- emacsclient.el, server.el: Handle eval or file open errors when + doing -t. + + (Done.) + +-- Make parts of struct tty_output accessible from Lisp. The device + name and the type is sufficient. + + (Done, see frame-tty-name and frame-tty-type.) + +-- Export delete_tty to the Lisp environment, for emacsclient. + + (Done, see delete-tty.) + +-- Get rid of the accessor macros in termchar.h, or define macros for + all members. + + (Done.) + +-- Move device-specific parameters (like costs) commonly used by + device backends to a common, device-dependent structure. + + (Done. See struct display_method in termhooks.h.) + +-- Fix X support. + + (Done. Well, it seems to be working.) + +-- Allow simultaneous X and tty frames. (Handling input could be + tricky. Or maybe not.) + + (Done. Allowed, that is. It is currently extremely unstable, to + the point of being unusable. The rif variable causes constant + core dumps. Handling input is indeed tricky.) + +-- Rewrite multi-tty input in terms of MULTI_KBOARD. + + (Done. In fact, there was no need to rewrite anything, I just + added a kboard member to tty_display_info, and initialized the + frame's kboard from there.) + +-- Fix rif issue with X-tty combo sessions. IMHO the best thing to do + is to get rid of that global variable (and use the value value in + display_method, which is guaranteed to be correct). + + (Done, did exactly that. Core dumps during combo sessions became + much rarer. In fact, I have not yet met a single one.) + +;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
--- a/etc/ONEWS Thu Jan 01 23:44:00 2004 +0000 +++ b/etc/ONEWS Fri Jan 02 04:37:46 2004 +0000 @@ -1029,7 +1029,7 @@ *** RCS customization. There is a new variable vc-consult-headers. If it is t (the default), -VC searches for RCS headers in working files (like `$Id: ONEWS,v 1.8 2003/02/04 14:30:40 lektu Exp $') and +VC searches for RCS headers in working files (like `$Id: ONEWS,v 1.9 2003/09/01 15:44:58 miles Exp $') and determines the state of the file from them, not from the master file. This is fast and more reliable when you use branches. (The variable was already present in Emacs 19.29, but didn't get mentioned in the
--- a/etc/TODO Thu Jan 01 23:44:00 2004 +0000 +++ b/etc/TODO Fri Jan 02 04:37:46 2004 +0000 @@ -137,7 +137,10 @@ * Highlight rectangles (`mouse-track-rectangle-p' in XEmacs). Already in CUA, but it's a valuable feature worth making more general. -* Support simultaneous tty and X frames. +* Support simultaneous tty and X frames. [For a partial + implementation, see tla branch + lorentey@elte.hu--2004/emacs--multi-tty--0 at + http://lorentey.web.elte.hu/arch/2004] * Provide MIME support for Rmail using the Gnus MIME library. [Maybe not now feasible, given Gnus maintenance decisions. fx looked at
--- a/etc/cs-survival.tex Thu Jan 01 23:44:00 2004 +0000 +++ b/etc/cs-survival.tex Fri Jan 02 04:37:46 2004 +0000 @@ -2,8 +2,8 @@ % Title: GNU Emacs Survival Card % Author: Wlodek Bzyl <matwb@univ.gda.pl> % -% $Revision: 1.2 $ -% $Date: 2003/02/04 14:30:41 $ +% $Revision: 1.3 $ +% $Date: 2003/09/01 15:44:59 $ % %**start of header
--- a/etc/fr-survival.tex Thu Jan 01 23:44:00 2004 +0000 +++ b/etc/fr-survival.tex Fri Jan 02 04:37:46 2004 +0000 @@ -3,8 +3,8 @@ % Title: GNU Emacs Survival Card % Author: Wlodek Bzyl <matwb@univ.gda.pl> % -% $Revision: 1.2 $ -% $Date: 2003/02/04 14:30:41 $ +% $Revision: 1.3 $ +% $Date: 2003/09/01 15:44:59 $ % %**start of header
--- a/etc/pl-refcard.tex Thu Jan 01 23:44:00 2004 +0000 +++ b/etc/pl-refcard.tex Fri Jan 02 04:37:46 2004 +0000 @@ -1,7 +1,7 @@ %&mex %===================================================================== -% $Revision: 1.3 $ -% $Date: 2003/02/04 14:30:42 $ +% $Revision: 1.4 $ +% $Date: 2003/09/01 15:44:59 $ %===================================================================== % Reference Card for GNU Emacs version 20 on Unix systems was % translated into Polish language by W{\l}odek Bzyl (matwb@univ.gda.pl)
--- a/etc/sk-survival.tex Thu Jan 01 23:44:00 2004 +0000 +++ b/etc/sk-survival.tex Fri Jan 02 04:37:46 2004 +0000 @@ -2,8 +2,8 @@ % Title: GNU Emacs Survival Card % Author: Wlodek Bzyl <matwb@univ.gda.pl> % -% $Revision: 1.2 $ -% $Date: 2003/02/04 14:30:42 $ +% $Revision: 1.3 $ +% $Date: 2003/09/01 15:44:59 $ % %**start of header
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/survival.log Fri Jan 02 04:37:46 2004 +0000 @@ -0,0 +1,10 @@ +This is TeX, Version 3.14159 (Web2C 7.3.1) (format=tex 2000.12.11) 12 DEC 2000 10:16 +**survival +(survival.tex +\intercolumnskip=\dimen16 +\leftcolumn=\box16 +\defwidth=\dimen17 +\raggedstretch=\dimen18 +\raggedparfill=\skip18 + [1] [2] ) +Output written on survival.dvi (2 pages, 11216 bytes).
--- a/etc/termcap.src Thu Jan 01 23:44:00 2004 +0000 +++ b/etc/termcap.src Fri Jan 02 04:37:46 2004 +0000 @@ -10,7 +10,7 @@ # #------------------------------------------------------------------------------ # Version 10.2.1 -# $Date: 2002/04/20 07:38:53 $ +# $Date: 2003/02/04 14:30:42 $ # terminfo syntax # # Eric S. Raymond (current maintainer)
--- a/info/.cvsignore Thu Jan 01 23:44:00 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -emacs -emacs-[1-9]* -emacs-mime -ccmode -ccmode-[1-9]* -cl -cl-[1-9]* -dired-x -ediff -ediff-[1-9]* -eshell -forms -gnus -gnus-[1-9]* -info -message -mh-e -mh-e-[1-9]* -reftex -reftex-[1-9]* -sc -sc-[1-9]* -vip -vip-[1-9]* -viper -viper-[1-9]* -widget -ada-mode -eudc -autotype -efaq -efaq-[1-9]* -idlwave -idlwave-[1-9]* -ebrowse -pcl-cvs -woman -woman-[1-9]* -speedbar -elisp -elisp-[1-9]* -calc -calc-[1-9]* -eintr -eintr-[1-9]* -tramp -tramp-[1-9]* -ses -smtpmail
--- a/info/COPYING Thu Jan 01 23:44:00 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License.
--- a/info/dir Thu Jan 01 23:44:00 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ --*- Text -*- -This is the file .../info/dir, which contains the topmost node of the -Info hierarchy. The first time you invoke Info you start off -looking at that node, which is (dir)Top. - -File: dir Node: Top This is the top of the INFO tree - -The Info Directory -****************** - - The Info Directory is the top-level menu of major Info topics. - Type "d" in Info to return to the Info Directory. Type "q" to exit Info. - Type "?" for a list of Info commands, or "h" to visit an Info tutorial. - Type "m" to choose a menu item--for instance, - "mEmacs<Return>" visits the Emacs manual. - In Emacs Info, you can click mouse button 2 on a menu item - or cross reference to follow it to its target. - -* Menu: Each line that starts with a * is a topic you can select with "m". - Every third topic has a red *. - -* Info: (info). How to use the documentation browsing system. - -Emacs -* Emacs: (emacs). The extensible self-documenting text editor. -* Emacs FAQ: (efaq). Frequently Asked Questions about Emacs. -* Emacs Lisp Introduction: (eintr). - A simple introduction to Emacs Lisp programming. -* Elisp: (elisp). The Emacs Lisp Reference Manual. - -* CL: (cl). Partial Common Lisp support for Emacs Lisp. -* Dired-X: (dired-x). Dired Extra Features. -* Ediff: (ediff). A visual interface for comparing and merging programs. -* PCL-CVS: (pcl-cvs). Emacs front-end to CVS. -* Speedbar: (speedbar). File/Tag summarizing utility. - -* Ada mode: (ada-mode). Emacs mode for editing Ada code. -* CC mode: (ccmode). Emacs mode for editing C, C++, Objective-C, - Java, Pike, and IDL code. -* Ebrowse: (ebrowse). A C++ class browser for Emacs. -* IDLWAVE: (idlwave). Major mode and shell for IDL and WAVE/CL files. - -* Gnus: (gnus). The news reader Gnus. -* Message: (message). Mail and news composition mode that goes with Gnus. -* MH-E: (mh-e). Emacs interface to the MH mail system. -* MIME: (emacs-mime). Emacs MIME de/composition library. -* SC: (sc). Supercite lets you cite parts of messages you're - replying to, in flexible ways. - -* Autotype: (autotype). Convenient features for text that you enter frequently - in Emacs. -* Calc: (calc). Advanced desk calculator and mathematical tool. -* Eshell: (eshell). A command shell implemented in Emacs Lisp. -* EUDC: (eudc). An Emacs client for directory servers (LDAP, PH). -* Forms: (forms). Emacs package for editing data bases - by filling in forms. -* RefTeX: (reftex). Emacs support for LaTeX cross-references and citations. -* Tramp: (tramp). Transparent Remote (file) Access, Multiple Protocol. - Edit remote files via a remote shell (rsh, - ssh, telnet). -* Widget: (widget). The "widget" package used by the Emacs Customization - facility. -* WoMan: (woman). Browse UN*X Manual Pages "Wo (without) Man". - -* VIPER: (viper). The newest Emacs VI-emulation mode. - (also, A VI Plan for Emacs Rescue - or the VI PERil.) -* VIP: (vip). An older VI-emulation for Emacs.
--- a/leim/CXTERM-DIC/4Corner.tit Thu Jan 01 23:44:00 2004 +0000 +++ b/leim/CXTERM-DIC/4Corner.tit Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: 4Corner.tit,v 1.2 2001/03/06 13:29:34 handa Exp $ +# $Id: 4Corner.tit,v 1.3 2003/09/01 15:44:59 miles Exp $ # HANZI input table for cxterm # To be used by cxterm, convert me to .cit format first # .cit version 2
--- a/leim/CXTERM-DIC/CCDOSPY.tit Thu Jan 01 23:44:00 2004 +0000 +++ b/leim/CXTERM-DIC/CCDOSPY.tit Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: CCDOSPY.tit,v 1.1 1999/10/08 20:06:27 fx Exp $ +# $Id: CCDOSPY.tit,v 1.2 2003/09/01 15:44:59 miles Exp $ # HANZI input table for cxterm # To be used by cxterm, convert me to .cit format first # .cit version 1
--- a/leim/CXTERM-DIC/Punct.tit Thu Jan 01 23:44:00 2004 +0000 +++ b/leim/CXTERM-DIC/Punct.tit Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: Punct.tit,v 1.1 1999/10/08 20:06:50 fx Exp $ +# $Id: Punct.tit,v 1.2 2003/09/01 15:44:59 miles Exp $ # HANZI input table for cxterm # To be used by cxterm, convert me to .cit format first # .cit version 1
--- a/leim/CXTERM-DIC/QJ.tit Thu Jan 01 23:44:00 2004 +0000 +++ b/leim/CXTERM-DIC/QJ.tit Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: QJ.tit,v 1.1 1999/10/08 20:06:51 fx Exp $ +# $Id: QJ.tit,v 1.2 2003/09/01 15:44:59 miles Exp $ # HANZI input table for cxterm # To be used by cxterm, convert me to .cit format first # .cit version 1
--- a/leim/CXTERM-DIC/SW.tit Thu Jan 01 23:44:00 2004 +0000 +++ b/leim/CXTERM-DIC/SW.tit Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: SW.tit,v 1.1 1999/10/08 20:06:53 fx Exp $ +# $Id: SW.tit,v 1.2 2003/09/01 15:44:59 miles Exp $ # HANZI input table for cxterm # To be used by cxterm, convert me to .cit format first # .cit version 1
--- a/leim/CXTERM-DIC/TONEPY.tit Thu Jan 01 23:44:00 2004 +0000 +++ b/leim/CXTERM-DIC/TONEPY.tit Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: TONEPY.tit,v 1.1 1999/10/08 20:06:56 fx Exp $ +# $Id: TONEPY.tit,v 1.2 2003/09/01 15:44:59 miles Exp $ # HANZI input table for cxterm # To be used by cxterm, convert me to .cit format first # .cit version 1
--- a/lib-src/b2m.pl Thu Jan 01 23:44:00 2004 +0000 +++ b/lib-src/b2m.pl Fri Jan 02 04:37:46 2004 +0000 @@ -30,7 +30,7 @@ use Date::Parse; my($whoami) = basename $0; -my($version) = '$Revision: 1.5 $'; +my($version) = '$Revision: 1.6 $'; my($usage) = "Usage: $whoami [--help] [--version] [--[no]full-headers] [Babyl-file] \tBy default, full headers are printed.\n";
--- a/lib-src/emacsclient.c Thu Jan 01 23:44:00 2004 +0000 +++ b/lib-src/emacsclient.c Fri Jan 02 04:37:46 2004 +0000 @@ -41,6 +41,54 @@ # include <pwd.h> #endif /* not VMS */ + +/****************************************/ + +#include <errno.h> +#include <signal.h> + +#ifndef INCLUDED_FCNTL +#define INCLUDED_FCNTL +#include <fcntl.h> +#endif + +#ifdef HAVE_TERMIOS +#ifndef NO_TERMIO +#include <termio.h> +#endif +#include <termios.h> +#endif /* not HAVE_TERMIOS */ + +#ifdef __GNU_LIBRARY__ +#include <sys/ioctl.h> +#include <termios.h> +#endif + +#if (defined (POSIX) || defined (NEED_UNISTD_H)) && defined (HAVE_UNISTD_H) +#include <unistd.h> +#endif + + + +/* Try to establish the correct character to disable terminal functions + in a system-independent manner. Note that USG (at least) define + _POSIX_VDISABLE as 0! */ + +#ifdef _POSIX_VDISABLE +#define CDISABLE _POSIX_VDISABLE +#else /* not _POSIX_VDISABLE */ +#ifdef CDEL +#undef CDISABLE +#define CDISABLE CDEL +#else /* not CDEL */ +#define CDISABLE 255 +#endif /* not CDEL */ +#endif /* not _POSIX_VDISABLE */ + + + +/****************************************/ + char *getenv (), *getwd (); char *getcwd (); @@ -54,6 +102,12 @@ /* Name used to invoke this program. */ char *progname; +/* The first argument to main. */ +int main_argc; + +/* The second argument to main. */ +char **main_argv; + /* Nonzero means don't wait for a response from Emacs. --no-wait. */ int nowait = 0; @@ -63,6 +117,9 @@ /* The display on which Emacs should work. --display. */ char *display = NULL; +/* Nonzero means open a new Emacs frame on the current terminal. */ +int frame = 0; + /* If non-NULL, the name of an editor to fallback to if the server is not running. --alternate-editor. */ const char * alternate_editor = NULL; @@ -78,6 +135,7 @@ { "eval", no_argument, NULL, 'e' }, { "help", no_argument, NULL, 'H' }, { "version", no_argument, NULL, 'V' }, + { "frame", no_argument, NULL, 'f' }, { "alternate-editor", required_argument, NULL, 'a' }, { "socket-name", required_argument, NULL, 's' }, { "display", required_argument, NULL, 'd' }, @@ -95,7 +153,7 @@ while (1) { int opt = getopt_long (argc, argv, - "VHnea:s:d:", longopts, 0); + "VHnea:s:d:t", longopts, 0); if (opt == EOF) break; @@ -134,6 +192,10 @@ exit (0); break; + case 't': + frame = 1; + break; + case 'H': print_help_and_exit (); break; @@ -144,6 +206,12 @@ break; } } + + if (frame) { + nowait = 0; + display = 0; + } + } void @@ -157,6 +225,7 @@ The following OPTIONS are accepted:\n\ -V, --version Just print a version info and return\n\ -H, --help Print this usage information message\n\ +-t, --tty Open a new Emacs frame on the current terminal\n\ -n, --no-wait Don't wait for the server to return\n\ -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ -d, --display=DISPLAY Visit the file in the given display\n\ @@ -231,14 +300,12 @@ defined-- exit with an errorcode. */ void -fail (argc, argv) - int argc; - char **argv; +fail (void) { if (alternate_editor) { int i = optind - 1; - execvp (alternate_editor, argv + i); + execvp (alternate_editor, main_argv + i); return; } else @@ -247,6 +314,531 @@ } } + +#ifdef HAVE_TERMIOS + +/* Adapted from emacs_get_tty() in sysdep.c. */ +int +ec_get_tty (int fd, struct termios *settings) +{ + bzero (settings, sizeof (struct termios)); + if (tcgetattr (fd, settings) < 0) + return -1; + return 0; +} + +/* Adapted from emacs_set_tty() in sysdep.c. */ +int +ec_set_tty (int fd, struct termios *settings, int flushp) +{ + /* Set the primary parameters - baud rate, character size, etcetera. */ + + int i; + /* We have those nifty POSIX tcmumbleattr functions. + William J. Smith <wjs@wiis.wang.com> writes: + "POSIX 1003.1 defines tcsetattr to return success if it was + able to perform any of the requested actions, even if some + of the requested actions could not be performed. + We must read settings back to ensure tty setup properly. + AIX requires this to keep tty from hanging occasionally." */ + /* This make sure that we don't loop indefinitely in here. */ + for (i = 0 ; i < 10 ; i++) + if (tcsetattr (fd, flushp ? TCSAFLUSH : TCSADRAIN, settings) < 0) + { + if (errno == EINTR) + continue; + else + return -1; + } + else + { + struct termios new; + + bzero (&new, sizeof (new)); + /* Get the current settings, and see if they're what we asked for. */ + tcgetattr (fd, &new); + /* We cannot use memcmp on the whole structure here because under + * aix386 the termios structure has some reserved field that may + * not be filled in. + */ + if ( new.c_iflag == settings->c_iflag + && new.c_oflag == settings->c_oflag + && new.c_cflag == settings->c_cflag + && new.c_lflag == settings->c_lflag + && memcmp (new.c_cc, settings->c_cc, NCCS) == 0) + break; + else + continue; + } + return 0; +} + +int master; +char *pty_name; + +struct termios old_tty; +struct termios tty; +int old_tty_valid; + +int tty_erase_char; +int quit_char = 'g' & 037; +int flow_control = 0; +int meta_key = 0; +char _sobuf[BUFSIZ]; +int emacs_pid; + +/* Adapted from init_sys_modes() in sysdep.c. */ +int +init_tty () +{ + if (! isatty (0)) + { + fprintf (stderr, "%s: Input is not a terminal", "init_tty"); + return 0; + } + + ec_get_tty (0, &old_tty); + old_tty_valid = 1; + tty = old_tty; + + tty_erase_char = old_tty.c_cc[VERASE]; + + tty.c_iflag |= (IGNBRK); /* Ignore break condition */ + tty.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ +#ifdef INLCR + tty.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */ +#endif +#ifdef ISTRIP + tty.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ +#endif + tty.c_lflag &= ~ECHO; /* Disable echo */ + tty.c_lflag &= ~ICANON; /* Disable erase/kill processing */ +#ifdef IEXTEN + tty.c_lflag &= ~IEXTEN; /* Disable other editing characters. */ +#endif + tty.c_lflag |= ISIG; /* Enable signals */ + if (flow_control) + { + tty.c_iflag |= IXON; /* Enable start/stop output control */ +#ifdef IXANY + tty.c_iflag &= ~IXANY; +#endif /* IXANY */ + } + else + tty.c_iflag &= ~IXON; /* Disable start/stop output control */ + tty.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL + on output */ + tty.c_oflag &= ~TAB3; /* Disable tab expansion */ +#ifdef CS8 + if (meta_key) + { + tty.c_cflag |= CS8; /* allow 8th bit on input */ + tty.c_cflag &= ~PARENB; /* Don't check parity */ + } +#endif + tty.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.c_cc[VQUIT] = quit_char; + tty.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */ + tty.c_cc[VTIME] = 0; /* no matter how long that takes. */ +#ifdef VSWTCH + tty.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use of C-z */ +#endif + +#ifdef VSUSP + tty.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ +#endif /* VSUSP */ +#ifdef V_DSUSP + tty.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.c_cc[VDSUSP] = CDISABLE; +#endif /* VDSUSP */ +#ifdef VLNEXT + tty.c_cc[VLNEXT] = CDISABLE; +#endif /* VLNEXT */ +#ifdef VREPRINT + tty.c_cc[VREPRINT] = CDISABLE; +#endif /* VREPRINT */ +#ifdef VWERASE + tty.c_cc[VWERASE] = CDISABLE; +#endif /* VWERASE */ +#ifdef VDISCARD + tty.c_cc[VDISCARD] = CDISABLE; +#endif /* VDISCARD */ + + if (flow_control) + { +#ifdef VSTART + tty.c_cc[VSTART] = '\021'; +#endif /* VSTART */ +#ifdef VSTOP + tty.c_cc[VSTOP] = '\023'; +#endif /* VSTOP */ + } + else + { +#ifdef VSTART + tty.c_cc[VSTART] = CDISABLE; +#endif /* VSTART */ +#ifdef VSTOP + tty.c_cc[VSTOP] = CDISABLE; +#endif /* VSTOP */ + } + +#ifdef SET_LINE_DISCIPLINE + /* Need to explicitly request TERMIODISC line discipline or + Ultrix's termios does not work correctly. */ + tty.c_line = SET_LINE_DISCIPLINE; +#endif + +#ifdef AIX +#ifndef IBMR2AIX + /* AIX enhanced edit loses NULs, so disable it. */ + tty.c_line = 0; + tty.c_iflag &= ~ASCEDIT; +#else + tty.c_cc[VSTRT] = 255; + tty.c_cc[VSTOP] = 255; + tty.c_cc[VSUSP] = 255; + tty.c_cc[VDSUSP] = 255; +#endif /* IBMR2AIX */ + if (flow_control) + { +#ifdef VSTART + tty.c_cc[VSTART] = '\021'; +#endif /* VSTART */ +#ifdef VSTOP + tty.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.c_iflag &= ~IGNBRK; + tty.c_iflag &= ~BRKINT; +#endif /* AIX */ + + ec_set_tty (0, &tty, 0); + + /* 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 (!flow_control) ioctl (0, TCXONC, 1); +#endif +#ifndef APOLLO +#ifdef TIOCSTART + if (!flow_control) ioctl (0, TIOCSTART, 0); +#endif +#endif + +#if defined (HAVE_TERMIOS) || defined (HPUX9) +#ifdef TCOON + if (!flow_control) tcflow (0, TCOON); +#endif +#endif + +#ifdef _IOFBF + /* This symbol is defined on recent USG systems. + Someone says without this call USG won't really buffer the file + even with a call to setbuf. */ + setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof _sobuf); +#else + setbuf (stdout, (char *) _sobuf); +#endif + + return 1; +} + +void +window_change () +{ + int width = 0, height = 0; + +#ifdef TIOCGWINSZ + { + /* BSD-style. */ + struct winsize size; + + if (ioctl (0, TIOCGWINSZ, &size) == -1) + width = height = 0; + else + { + width = size.ws_col; + height = size.ws_row; + } + } +#else +#ifdef TIOCGSIZE + { + /* SunOS - style. */ + struct ttysize size; + + if (ioctl (0, TIOCGSIZE, &size) == -1) + width = height = 0; + else + { + width = size.ts_cols; + height = size.ts_lines; + } + } +#endif /* not SunOS-style */ +#endif /* not BSD-style */ + +#ifdef TIOCSWINSZ + { + /* BSD-style. */ + struct winsize size; + size.ws_row = height; + size.ws_col = width; + + ioctl (master, TIOCSWINSZ, &size); + } +#else +#ifdef TIOCSSIZE + { + /* SunOS - style. */ + struct ttysize size; + size.ts_lines = height; + size.ts_cols = width; + + ioctl (master, TIOCGSIZE, &size); + } +#endif /* not SunOS-style */ +#endif /* not BSD-style */ + + if (emacs_pid && width && height) + kill (emacs_pid, SIGWINCH); +} + +int in_conversation = 0; +int quit_conversation = 0; + +SIGTYPE +hang_up_signal (int signalnum) +{ + int old_errno = errno; + + if (! in_conversation) + return; + + quit_conversation = 1; + + errno = old_errno; +} + +SIGTYPE +window_change_signal (int signalnum) +{ + int old_errno = errno; + + if (! in_conversation) + goto end; + + window_change(); + + end: + signal (SIGWINCH, window_change_signal); + errno = old_errno; +} + +SIGTYPE +interrupt_signal (int signalnum) +{ + int old_errno = errno; + + /* Forward it to Emacs. */ + if (emacs_pid) + kill (emacs_pid, SIGINT); + + errno = old_errno; +} + +int +init_signals () +{ + /* Set up signal handlers. */ + signal (SIGWINCH, window_change_signal); + signal (SIGHUP, hang_up_signal); + signal (SIGINT, interrupt_signal); + return 1; +} + + + +/* Adapted from reset_sys_modes in sysdep.c. */ +int +reset_tty () +{ + fflush (stdout); +#ifdef BSD_SYSTEM +#ifndef BSD4_1 + /* Avoid possible loss of output when changing terminal modes. */ + fsync (fileno (stdout)); +#endif +#endif + +#ifdef F_SETFL +#ifdef O_NDELAY + fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NDELAY); +#endif +#endif /* F_SETFL */ + + if (old_tty_valid) + while (ec_set_tty (0, &old_tty, 0) < 0 && errno == EINTR) + ; + + return 1; +} + + +int +init_pty () +{ + master = getpt (); + if (master < 0) + return 0; + + if (grantpt (master) < 0 || unlockpt (master) < 0) + goto close_master; + pty_name = strdup (ptsname (master)); + if (! pty_name) + goto close_master; + + /* Propagate window size. */ + window_change (); + + return 1; + + close_master: + close (master); + return 0; +} + +int +copy_from_to (int in, int out, int sigio) +{ + static char buf[BUFSIZ]; + int nread = read (in, &buf, BUFSIZ); + if (nread == 0) + return 1; /* EOF */ + else if (nread < 0 && errno != EAGAIN) + return 0; + else if (nread > 0) + { + int r = 0; + int written = 0; + + do { + r = write (out, &buf, nread); + } while ((r < 0 && errno == EINTR) + || (r > 0 && (written += r) && written != nread)); + + if (r < 0) + return 0; + + if (sigio && emacs_pid) + kill (emacs_pid, SIGIO); + } + return 1; +} + +int +pty_conversation (FILE *in) +{ + char *str; + char string[BUFSIZ]; + fd_set set, rset; + int res; + + FD_ZERO (&set); + FD_SET (master, &set); + FD_SET (1, &set); + FD_SET (fileno (in), &set); + + in_conversation = 1; + + while (! quit_conversation) { + rset = set; + res = select (FD_SETSIZE, &rset, NULL, NULL, NULL); + if (res < 0 && errno != EINTR) + { + reset_tty (); + fprintf (stderr, "%s: ", progname); + perror ("select"); + return 0; /* Error */ + } + else if (res > 0) + { + if (FD_ISSET (master, &rset)) + { + /* Copy Emacs output to stdout. */ + if (! copy_from_to (master, 0, 0)) + { + FD_CLR (master, &set); + } + } + if (FD_ISSET (1, &rset)) + { + /* Forward user input to Emacs. */ + if (! copy_from_to (1, master, 1)) + { + FD_CLR (master, &set); + } + } + if (FD_ISSET (fileno (in), &rset)) + { + do { + res = read (fileno (in), string, BUFSIZ-1); + } while (res < 0 && errno == EINTR); + if (res < 0) + { + reset_tty (); + fprintf (stderr, "%s: ", progname); + perror ("read"); + return 0; + } + if (!res) + { + return 1; + } + + string[res] = 0; + if (string[res-1] == '\n') + string[res-1] = 0; + + if (! emacs_pid) + { + /* Get the pid of the Emacs process. + XXX Is there some nifty libc/kernel feature for doing this? + */ + if (! string[0]) + { + reset_tty (); + fprintf (stderr, "%s: could not get Emacs process id\n" + "Maybe this Emacs does not support multiple terminals.\n", progname); + return 0; + } + emacs_pid = strtol (string, NULL, 10); + } + + if (! emacs_pid) /* emacs_pid should be set above */ + { + reset_tty (); + fprintf (stderr, "%s: %s\n", progname, string); + return 0; + } + } + } + } + return 1; +} + +#endif /* HAVE_TERMIOS */ #if !defined (HAVE_SOCKETS) || defined (NO_SOCKETS_IN_FILE_SYSTEM) @@ -260,7 +852,7 @@ argv[0]); fprintf (stderr, "on systems with Berkeley sockets.\n"); - fail (argc, argv); + fail (); } #else /* HAVE_SOCKETS */ @@ -307,12 +899,14 @@ char *cwd, *str; char string[BUFSIZ]; + main_argc = argc; + main_argv = argv; progname = argv[0]; /* Process options. */ decode_options (argc, argv); - if ((argc - optind < 1) && !eval) + if ((argc - optind < 1) && !eval && !frame) { fprintf (stderr, "%s: file name or argument required\n", progname); fprintf (stderr, "Try `%s --help' for more information\n", progname); @@ -327,7 +921,7 @@ { fprintf (stderr, "%s: ", argv[0]); perror ("socket"); - fail (argc, argv); + fail (); } server.sun_family = AF_UNIX; @@ -358,7 +952,8 @@ { int sock_status = 0; - + int oerrno = 0; + if (! socket_name) { socket_name = alloca (system_name_length + 100); @@ -369,11 +964,15 @@ if (strlen (socket_name) < sizeof (server.sun_path)) strcpy (server.sun_path, socket_name); else - fprintf (stderr, "%s: socket-name %s too long", - argv[0], socket_name); + { + fprintf (stderr, "%s: socket-name %s too long", + argv[0], socket_name); + fail (); + } /* See if the socket exists, and if it's owned by us. */ sock_status = socket_status (server.sun_path); + oerrno = errno; if (sock_status) { /* Failing that, see if LOGNAME or USER exist and differ from @@ -394,6 +993,7 @@ sprintf (server.sun_path, "/tmp/esrv%d-%s", (int) pw->pw_uid, system_name); sock_status = socket_status (server.sun_path); + oerrno = errno; } } } @@ -406,7 +1006,7 @@ if (0 != geteuid ()) { fprintf (stderr, "%s: Invalid socket owner\n", argv[0]); - fail (argc, argv); + fail (); } break; @@ -414,13 +1014,13 @@ /* `stat' failed */ if (errno == ENOENT) fprintf (stderr, - "%s: can't find socket; have you started the server?\n\ + "%s: Can't find socket; have you started the server?\n\ To start the server in Emacs, type \"M-x server-start\".\n", argv[0]); else - fprintf (stderr, "%s: can't stat %s: %s\n", - argv[0], server.sun_path, strerror (errno)); - fail (argc, argv); + fprintf (stderr, "%s: Can't stat %s: %s\n", + argv[0], server.sun_path, strerror (oerrno)); + fail (); break; } } @@ -430,7 +1030,7 @@ { fprintf (stderr, "%s: ", argv[0]); perror ("connect"); - fail (argc, argv); + fail (); } /* We use the stream OUT to send our command to the server. */ @@ -438,7 +1038,7 @@ { fprintf (stderr, "%s: ", argv[0]); perror ("fdopen"); - fail (argc, argv); + fail (); } /* We use the stream IN to read the response. @@ -450,7 +1050,7 @@ { fprintf (stderr, "%s: ", argv[0]); perror ("fdopen"); - fail (argc, argv); + fail (); } #ifdef HAVE_GETCWD @@ -468,7 +1068,7 @@ #else fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno)); #endif - fail (argc, argv); + fail (); } if (nowait) @@ -484,6 +1084,38 @@ fprintf (out, " "); } + if (frame) + { + if (! init_signals ()) + { + fprintf (stderr, "%s: ", argv[0]); + perror ("fdopen"); + fail (); + } + + if (! init_tty ()) + { + reset_tty (); + fprintf (stderr, "%s: ", argv[0]); + perror ("fdopen"); + fail (); + } + + if (! init_pty ()) + { + reset_tty (); + fprintf (stderr, "%s: ", argv[0]); + perror ("fdopen"); + fail (); + } + + fprintf (out, "-tty "); + quote_file_name (pty_name, out); + fprintf (out, " "); + quote_file_name (getenv("TERM"), out); + fprintf (out, " "); + } + if ((argc - optind > 0)) { for (i = optind; i < argc; i++) @@ -512,11 +1144,14 @@ } else { - while ((str = fgets (string, BUFSIZ, stdin))) - { - quote_file_name (str, out); - } - fprintf (out, " "); + if (!frame) + { + while ((str = fgets (string, BUFSIZ, stdin))) + { + quote_file_name (str, out); + } + fprintf (out, " "); + } } fprintf (out, "\n"); @@ -524,8 +1159,22 @@ /* Maybe wait for an answer. */ if (nowait) - return 0; + { + reset_tty (); + return 0; + } + if (frame) + { + if (! pty_conversation (out)) + { + reset_tty (); + fail (); + } + reset_tty (); + return 0; + } + if (!eval) { printf ("Waiting for Emacs..."); @@ -546,6 +1195,7 @@ printf ("\n"); fflush (stdout); + reset_tty (); return 0; }
--- a/lib-src/rcs2log Thu Jan 01 23:44:00 2004 +0000 +++ b/lib-src/rcs2log Fri Jan 02 04:37:46 2004 +0000 @@ -29,7 +29,7 @@ Report bugs to <bug-gnu-emacs@gnu.org>.' -Id='$Id: rcs2log,v 1.51 2003/09/01 15:45:03 miles Exp $' +Id='$Id: rcs2log,v 1.52 2003/12/27 08:18:08 uid65632 Exp $' # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003 # Free Software Foundation, Inc.
--- a/lib-src/vcdiff Thu Jan 01 23:44:00 2004 +0000 +++ b/lib-src/vcdiff Fri Jan 02 04:37:46 2004 +0000 @@ -23,7 +23,7 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # -# $Id: vcdiff,v 1.7 2001/02/20 12:36:28 gerd Exp $ +# $Id: vcdiff,v 1.8 2003/09/01 15:45:03 miles Exp $ # DIFF="diff"
--- a/lisp/allout.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/allout.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Author: Ken Manheimer <klm@zope.com> ;; Maintainer: Ken Manheimer <klm@zope.com> ;; Created: Dec 1991 - first release to usenet -;; Version: $Id: allout.el,v 1.44 2003/09/01 15:45:04 miles Exp $|| +;; Version: $Id: allout.el,v 1.45 2003/10/16 16:28:30 eliz Exp $|| ;; Keywords: outlines mode wp languages ;; This file is part of GNU Emacs. @@ -508,7 +508,7 @@ ;;;_ : Version ;;;_ = allout-version (defvar allout-version - (let ((rcs-rev "$Revision: 1.44 $")) + (let ((rcs-rev "$Revision: 1.45 $")) (condition-case err (save-match-data (string-match "Revision: \\([0-9]+\\.[0-9]+\\)" rcs-rev)
--- a/lisp/calendar/todo-mode.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/calendar/todo-mode.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Author: Oliver Seidel <os10000@seidel-space.de> ;; [Not clear the above works, July 2000] ;; Created: 2 Aug 1997 -;; Version: $Id: todo-mode.el,v 1.50 2001/12/11 07:36:30 pj Exp $ +;; Version: $Id: todo-mode.el,v 1.51 2003/09/01 15:45:19 miles Exp $ ;; Keywords: calendar, todo ;; This file is part of GNU Emacs. @@ -97,7 +97,7 @@ ;; ;; Which version of todo-mode.el does this documentation refer to? ;; -;; $Id: todo-mode.el,v 1.50 2001/12/11 07:36:30 pj Exp $ +;; $Id: todo-mode.el,v 1.51 2003/09/01 15:45:19 miles Exp $ ;; ;; Pre-Requisites ;;
--- a/lisp/emacs-lisp/bytecomp.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/emacs-lisp/bytecomp.el Fri Jan 02 04:37:46 2004 +0000 @@ -10,7 +10,7 @@ ;;; This version incorporates changes up to version 2.10 of the ;;; Zawinski-Furuseth compiler. -(defconst byte-compile-version "$Revision: 2.138 $") +(defconst byte-compile-version "$Revision: 2.139 $") ;; This file is part of GNU Emacs.
--- a/lisp/emacs-lisp/cl-specs.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/emacs-lisp/cl-specs.el Fri Jan 02 04:37:46 2004 +0000 @@ -7,7 +7,7 @@ ;; LCD Archive Entry: ;; cl-specs.el|Daniel LaLiberte|liberte@holonexus.org ;; |Edebug specs for cl.el -;; |$Date: 2003/06/16 16:27:27 $|1.1| +;; |$Date: 2003/09/01 15:45:20 $|1.1| ;; This file is part of GNU Emacs.
--- a/lisp/emacs-lisp/eldoc.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/emacs-lisp/eldoc.el Fri Jan 02 04:37:46 2004 +0000 @@ -7,7 +7,7 @@ ;; Keywords: extensions ;; Created: 1995-10-06 -;; $Id: eldoc.el,v 1.26 2003/09/01 15:45:22 miles Exp $ +;; $Id: eldoc.el,v 1.27 2003/09/06 17:32:31 fx Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/forms.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/forms.el Fri Jan 02 04:37:46 2004 +0000 @@ -301,10 +301,10 @@ (provide 'forms) ;;; official (provide 'forms-mode) ;;; for compatibility -(defconst forms-version (substring "$Revision: 2.48 $" 11 -2) +(defconst forms-version (substring "$Revision: 2.49 $" 11 -2) "The version number of forms-mode (as string). The complete RCS id is: - $Id: forms.el,v 2.48 2003/05/29 23:53:21 monnier Exp $") + $Id: forms.el,v 2.49 2003/09/01 15:45:12 miles Exp $") (defcustom forms-mode-hook nil "Hook run upon entering Forms mode."
--- a/lisp/frame.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/frame.el Fri Jan 02 04:37:46 2004 +0000 @@ -571,6 +571,24 @@ (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN")) (make-frame (cons (cons '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.)" + (unless device + (error "Invalid terminal device")) + (unless type + (error "Invalid terminal type")) + (make-terminal-frame (append (list (cons 'tty device) (cons 'tty-type type)) parameters))) + (defun make-frame-command () "Make a new frame, and select it if the terminal displays only one frame." (interactive)
--- a/lisp/ldefs-boot.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/ldefs-boot.el Fri Jan 02 04:37:46 2004 +0000 @@ -78,7 +78,7 @@ (autoload (quote ada-mode) "ada-mode" "\ Ada mode is the major mode for editing Ada code. -This version was built on $Date: 2003/09/30 12:54:32 $. +This version was built on $Date: 2003/11/17 19:02:52 $. Bindings are as follows: (Note: 'LFD' is control-j.) \\{ada-mode-map}
--- a/lisp/mail/metamail.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/mail/metamail.el Fri Jan 02 04:37:46 2004 +0000 @@ -3,7 +3,7 @@ ;; Copyright (C) 1993, 1996 Free Software Foundation, Inc. ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp> -;; Version: $Id: metamail.el,v 1.15 2003/02/04 13:14:00 lektu Exp $ +;; Version: $Id: metamail.el,v 1.16 2003/09/01 15:45:30 miles Exp $ ;; Keywords: mail, news, mime, multimedia ;; This file is part of GNU Emacs.
--- a/lisp/net/rlogin.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/net/rlogin.el Fri Jan 02 04:37:46 2004 +0000 @@ -6,7 +6,7 @@ ;; Maintainer: Noah Friedman <friedman@splode.com> ;; Keywords: unix, comm -;; $Id: rlogin.el,v 1.4 2003/05/06 17:46:28 lektu Exp $ +;; $Id: rlogin.el,v 1.5 2003/09/01 15:45:33 miles Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/obsolete/rsz-mini.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/obsolete/rsz-mini.el Fri Jan 02 04:37:46 2004 +0000 @@ -7,7 +7,7 @@ ;; Maintainer: Noah Friedman <friedman@splode.com> ;; Keywords: minibuffer, window, frame, display -;; $Id: rsz-mini.el,v 1.1 2001/08/30 07:29:18 gerd Exp $ +;; $Id: rsz-mini.el,v 1.2 2003/09/01 15:45:33 miles Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/ada-mode.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/ada-mode.el Fri Jan 02 04:37:46 2004 +0000 @@ -1071,7 +1071,7 @@ ;;;###autoload (defun ada-mode () "Ada mode is the major mode for editing Ada code. -This version was built on $Date: 2003/09/01 15:45:34 $. +This version was built on $Date: 2003/09/30 12:54:32 $. Bindings are as follows: (Note: 'LFD' is control-j.) \\{ada-mode-map}
--- a/lisp/progmodes/ada-prj.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/ada-prj.el Fri Jan 02 04:37:46 2004 +0000 @@ -3,7 +3,7 @@ ;; Copyright (C) 1998, 99, 2000-2003 Free Software Foundation, Inc. ;; Author: Emmanuel Briot <briot@gnat.com> -;; Ada Core Technologies's version: $Revision: 1.12 $ +;; Ada Core Technologies's version: $Revision: 1.13 $ ;; Keywords: languages, ada, project file ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/ada-stmt.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/ada-stmt.el Fri Jan 02 04:37:46 2004 +0000 @@ -3,7 +3,7 @@ ;; Copyright(C) 1987, 93, 94, 96, 97, 98, 99, 2000 ;; Free Software Foundation, Inc. -;; Ada Core Technologies's version: $Revision: 1.16 $ +;; Ada Core Technologies's version: $Revision: 1.17 $ ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/autoconf.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/autoconf.el Fri Jan 02 04:37:46 2004 +0000 @@ -4,7 +4,7 @@ ;; Author: Dave Love <fx@gnu.org> ;; Keywords: languages -;; $Revision: 1.5 $ +;; $Revision: 1.6 $ ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/delphi.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/delphi.el Fri Jan 02 04:37:46 2004 +0000 @@ -65,7 +65,7 @@ (provide 'delphi) (defconst delphi-version - (let ((revision "$Revision: 3.10 $")) + (let ((revision "$Revision: 3.11 $")) (string-match ": \\([^ ]+\\)" revision) (match-string 1 revision)) "Version of this delphi mode.")
--- a/lisp/progmodes/idlw-shell.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/idlw-shell.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Chris Chase <chase@att.com> ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu> ;; Version: 4.15 -;; Date: $Date: 2002/10/17 15:41:01 $ +;; Date: $Date: 2003/09/01 15:45:35 $ ;; Keywords: processes ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/idlw-toolbar.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/idlw-toolbar.el Fri Jan 02 04:37:46 2004 +0000 @@ -4,7 +4,7 @@ ;; Author: Carsten Dominik <dominik@astro.uva.nl> ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu> ;; Version: 4.15 -;; Date: $Date: 2003/02/04 13:24:35 $ +;; Date: $Date: 2003/09/01 15:45:35 $ ;; Keywords: processes ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/idlwave.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/idlwave.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Chris Chase <chase@att.com> ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu> ;; Version: 4.15 -;; Date: $Date: 2003/07/21 21:36:29 $ +;; Date: $Date: 2003/09/01 15:45:35 $ ;; Keywords: languages ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/tcl.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/tcl.el Fri Jan 02 04:37:46 2004 +0000 @@ -6,7 +6,7 @@ ;; Author: Tom Tromey <tromey@redhat.com> ;; Chris Lindblad <cjl@lcs.mit.edu> ;; Keywords: languages tcl modes -;; Version: $Revision: 1.75 $ +;; Version: $Revision: 1.76 $ ;; This file is part of GNU Emacs.
--- a/lisp/progmodes/vhdl-mode.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/progmodes/vhdl-mode.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Authors: Reto Zimmermann <reto@gnu.org> ;; Rodney J. Whitby <software.vhdl-mode@rwhitby.net> ;; Maintainer: Reto Zimmermann <reto@gnu.org> -;; RCS: $Id: vhdl-mode.el,v 1.20 2003/03/05 07:50:38 lektu Exp $ +;; RCS: $Id: vhdl-mode.el,v 1.21 2003/09/01 15:45:35 miles Exp $ ;; Keywords: languages vhdl ;; WWW: http://opensource.ethz.ch/emacs/vhdl-mode.html
--- a/lisp/recentf.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/recentf.el Fri Jan 02 04:37:46 2004 +0000 @@ -8,7 +8,7 @@ ;; Maintainer: FSF ;; Keywords: files -(defconst recentf-version "$Revision: 1.27 $") +(defconst recentf-version "$Revision: 1.28 $") ;; This file is part of GNU Emacs.
--- a/lisp/server.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/server.el Fri Jan 02 04:37:46 2004 +0000 @@ -106,6 +106,13 @@ that can be given to the server process to identify a client. When a buffer is marked as \"done\", it is removed from this list.") +(defvar server-frames nil + "List of current server frames. +Each element is (CLIENTID FRAME) where CLIENTID is a string +that can be given to the server process to identify a client. +When all the buffers of the client are marked as \"done\", +the frame is deleted.") + (defvar server-buffer-clients nil "List of client ids for clients requesting editing of current buffer.") (make-variable-buffer-local 'server-buffer-clients) @@ -187,9 +194,24 @@ (or (and server-kill-new-buffers (not server-existing-buffer)) (server-temp-file-p))) - (kill-buffer (current-buffer))))))) + (kill-buffer (current-buffer))))) + (let ((frame (assq (car client) server-frames))) + (when frame + (setq server-frames (delq frame server-frames)) + (when (frame-live-p (cadr frame)) (delete-frame (cadr frame) 'force)))))) (server-log (format "Status changed to %s" (process-status proc)) proc)) +(defun server-handle-delete-frame (frame) + (dolist (entry server-frames) + (let ((proc (nth 0 entry)) + (f (nth 1 entry))) + (when (eq f frame) + (let ((client (assq proc server-clients))) + (if (and (cdr client) (not (yes-or-no-p "Frame has pending buffers; close anyway? "))) + (error "Frame deletion cancelled") + (setq server-frames (delq entry server-frames)) + (delete-process (car client)))))))) + (defun server-select-display (display) ;; If the current frame is on `display' we're all set. (unless (equal (frame-parameter (selected-frame) 'display) display) @@ -257,10 +279,16 @@ (while server-clients (let ((buffer (nth 1 (car server-clients)))) (server-buffer-done buffer))) + ;; Delete any remaining opened frames of the previous server. + (while server-frames + (let ((frame (cadar server-frames))) + (setq server-frames (cdr server-frames)) + (when (frame-live-p frame) (delete-frame frame 'force)))) (unless leave-dead (if server-process (server-log (message "Restarting server"))) (letf (((default-file-modes) ?\700)) + (add-to-list 'delete-frame-functions 'server-handle-delete-frame) (setq server-process (make-network-process :name "server" :family 'local :server t :noquery t @@ -299,7 +327,7 @@ (coding-system (and default-enable-multibyte-characters (or file-name-coding-system default-file-name-coding-system))) - client nowait eval + client nowait eval newframe (files nil) (lineno 1) (columnno 0)) @@ -319,6 +347,20 @@ (server-select-display display) (error (process-send-string proc (nth 1 err)) (setq request ""))))) + ;; Open a new frame at the client. ARG is the name of the pseudo tty. + ((and (equal "-tty" arg) (string-match "\\([^ ]*\\) \\([^ ]*\\) " request)) + (let ((tty (server-unquote-arg (match-string 1 request))) + (type (server-unquote-arg (match-string 2 request)))) + (setq request (substring request (match-end 0))) + (condition-case err + (let ((frame (make-frame-on-tty tty type))) + (setq server-frames (cons (list (car client) frame) server-frames)) + (sit-for 0) + (process-send-string proc (concat (number-to-string (emacs-pid)) "\n")) + (select-frame frame) + (setq newframe t)) + (error (ignore-errors (process-send-string proc (concat (nth 1 err) "\n"))) + (setq request ""))))) ;; ARG is a line number option. ((string-match "\\`\\+[0-9]+\\'" arg) (setq lineno (string-to-int (substring arg 1)))) @@ -334,12 +376,15 @@ (if coding-system (setq arg (decode-coding-string arg coding-system))) (if eval - (let ((v (eval (car (read-from-string arg))))) - (when v - (with-temp-buffer - (let ((standard-output (current-buffer))) - (pp v) - (process-send-region proc (point-min) (point-max)))))) + (condition-case err + (let ((v (eval (car (read-from-string arg))))) + (when (and (not newframe v)) + (with-temp-buffer + (let ((standard-output (current-buffer))) + (pp v) + (process-send-region proc (point-min) (point-max)))))) + (error (process-send-string proc (concat "*Error* " (error-message-string err))))) + ;; ARG is a file name. ;; Collapse multiple slashes to single slashes. (setq arg (command-line-normalize-file-name arg)) @@ -351,7 +396,7 @@ (server-visit-files files client nowait) (run-hooks 'post-command-hook)) ;; CLIENT is now a list (CLIENTNUM BUFFERS...) - (if (null (cdr client)) + (if (and (not newframe) (null (cdr client))) ;; This client is empty; get rid of it immediately. (progn (delete-process proc) @@ -359,11 +404,14 @@ ;; We visited some buffer for this client. (or nowait (push client server-clients)) (unless (or isearch-mode (minibufferp)) - (server-switch-buffer (nth 1 client)) - (run-hooks 'server-switch-hook) - (unless nowait - (message (substitute-command-keys - "When done with a buffer, type \\[server-edit]"))))))) + (if (and newframe (null (cdr client))) + (message (substitute-command-keys + "When done with this frame, type \\[delete-frame]")) + (server-switch-buffer (nth 1 client)) + (run-hooks 'server-switch-hook) + (unless nowait + (message (substitute-command-keys + "When done with a buffer, type \\[server-edit]")))))))) ;; Save for later any partial line that remains. (when (> (length string) 0) (process-put proc 'previous-string string))) @@ -570,7 +618,8 @@ ;; since we've already effectively done that. (if (null next-buffer) (if server-clients - (server-switch-buffer (nth 1 (car server-clients)) killed-one) + (let ((buffer (nth 1 (car server-clients)))) + (and buffer (server-switch-buffer buffer killed-one))) (unless (or killed-one (window-dedicated-p (selected-window))) (switch-to-buffer (other-buffer)) (message "No server buffers remain to edit")))
--- a/lisp/smerge-mode.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/smerge-mode.el Fri Jan 02 04:37:46 2004 +0000 @@ -4,7 +4,7 @@ ;; Author: Stefan Monnier <monnier@cs.yale.edu> ;; Keywords: merge diff3 cvs conflict -;; Revision: $Id$ +;; Revision: $Id: smerge-mode.el,v 1.24 2003/10/06 16:34:59 fx Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/type-break.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/type-break.el Fri Jan 02 04:37:46 2004 +0000 @@ -8,7 +8,7 @@ ;; Status: Works in GNU Emacs 19.25 or later, some versions of XEmacs ;; Created: 1994-07-13 -;; $Id: type-break.el,v 1.28 2003/05/28 11:25:44 rms Exp $ +;; $Id: type-break.el,v 1.29 2003/09/01 15:45:17 miles Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/vc-cvs.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/vc-cvs.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Author: FSF (see vc.el for full credits) ;; Maintainer: Andre Spiegel <spiegel@gnu.org> -;; $Id$ +;; $Id: vc-cvs.el,v 1.66 2003/10/01 13:22:53 fx Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/vc-hooks.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/vc-hooks.el Fri Jan 02 04:37:46 2004 +0000 @@ -6,7 +6,7 @@ ;; Author: FSF (see vc.el for full credits) ;; Maintainer: Andre Spiegel <spiegel@gnu.org> -;; $Id: vc-hooks.el,v 1.159 2003/08/30 10:56:38 eliz Exp $ +;; $Id: vc-hooks.el,v 1.160 2003/09/01 15:45:17 miles Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/vc-rcs.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/vc-rcs.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Author: FSF (see vc.el for full credits) ;; Maintainer: Andre Spiegel <spiegel@gnu.org> -;; $Id: vc-rcs.el,v 1.37 2003/05/08 19:24:56 monnier Exp $ +;; $Id: vc-rcs.el,v 1.38 2003/09/01 15:45:17 miles Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/vc-sccs.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/vc-sccs.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Author: FSF (see vc.el for full credits) ;; Maintainer: Andre Spiegel <spiegel@gnu.org> -;; $Id: vc-sccs.el,v 1.23 2003/08/12 18:01:21 spiegel Exp $ +;; $Id: vc-sccs.el,v 1.24 2003/09/01 15:45:17 miles Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/vc.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/vc.el Fri Jan 02 04:37:46 2004 +0000 @@ -7,7 +7,7 @@ ;; Maintainer: Andre Spiegel <spiegel@gnu.org> ;; Keywords: tools -;; $Id: vc.el,v 1.360 2003/09/01 15:45:17 miles Exp $ +;; $Id: vc.el,v 1.361 2003/12/24 23:18:10 uid66361 Exp $ ;; This file is part of GNU Emacs.
--- a/lisp/whitespace.el Thu Jan 01 23:44:00 2004 +0000 +++ b/lisp/whitespace.el Fri Jan 02 04:37:46 2004 +0000 @@ -5,7 +5,7 @@ ;; Author: Rajesh Vaidheeswarran <rv@gnu.org> ;; Keywords: convenience -;; $Id: whitespace.el,v 1.26 2003/09/01 15:45:18 miles Exp $ +;; $Id: whitespace.el,v 1.27 2003/09/29 18:05:31 rv Exp $ ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify
--- a/lispintro/mkinstalldirs Thu Jan 01 23:44:00 2004 +0000 +++ b/lispintro/mkinstalldirs Fri Jan 02 04:37:46 2004 +0000 @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.10 1996/05/03 07:37:52 friedman Exp $ +# $Id: mkinstalldirs,v 1.1 2001/11/24 08:45:51 eliz Exp $ errstatus=0
--- a/lispref/mkinstalldirs Thu Jan 01 23:44:00 2004 +0000 +++ b/lispref/mkinstalldirs Fri Jan 02 04:37:46 2004 +0000 @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.10 1996/05/03 07:37:52 friedman Exp $ +# $Id: mkinstalldirs,v 1.1 2000/07/28 12:48:04 gerd Exp $ errstatus=0
--- a/man/eshell.texi Thu Jan 01 23:44:00 2004 +0000 +++ b/man/eshell.texi Fri Jan 02 04:37:46 2004 +0000 @@ -1,5 +1,5 @@ \input texinfo @c -*-texinfo-*- -@c "@(#)$Name: $:$Id: eshell.texi,v 1.19 2003/09/01 15:45:45 miles Exp $" +@c "@(#)$Name: $:$Id: eshell.texi,v 1.20 2003/11/26 17:12:11 ttn Exp $" @c %**start of header @setfilename ../info/eshell @settitle Eshell: The Emacs Shell
--- a/man/info.texi Thu Jan 01 23:44:00 2004 +0000 +++ b/man/info.texi Fri Jan 02 04:37:46 2004 +0000 @@ -6,7 +6,7 @@ @syncodeindex vr cp @syncodeindex ky cp @comment %**end of header -@comment $Id: info.texi,v 1.36 2003/09/21 20:13:23 karl Exp $ +@comment $Id: info.texi,v 1.37 2003/10/27 00:01:25 karl Exp $ @copying This file describes how to use Info, the on-line, menu-driven GNU
--- a/man/mh-e.texi Thu Jan 01 23:44:00 2004 +0000 +++ b/man/mh-e.texi Fri Jan 02 04:37:46 2004 +0000 @@ -1,5 +1,5 @@ \input texinfo @c -*-texinfo-*- -@c $Id: mh-e.texi,v 1.14 2003/02/04 14:53:28 lektu Exp $ +@c $Id: mh-e.texi,v 1.15 2003/09/01 15:45:46 miles Exp $ @c %**start of header @setfilename ../info/mh-e @settitle mh-e
--- a/man/pcl-cvs.texi Thu Jan 01 23:44:00 2004 +0000 +++ b/man/pcl-cvs.texi Fri Jan 02 04:37:46 2004 +0000 @@ -1,5 +1,5 @@ \input texinfo @c -*-texinfo-*- -@c "@(#)$Name: $:$Id: pcl-cvs.texi,v 1.22 2003/09/29 13:44:26 ttn Exp $" +@c "@(#)$Name: $:$Id: pcl-cvs.texi,v 1.23 2003/09/30 20:40:50 rms Exp $" @c %**start of header @setfilename ../info/pcl-cvs @settitle PCL-CVS --- Emacs Front-End to CVS
--- a/man/speedbar.texi Thu Jan 01 23:44:00 2004 +0000 +++ b/man/speedbar.texi Fri Jan 02 04:37:46 2004 +0000 @@ -1,5 +1,5 @@ \input texinfo @c -*-texinfo-*- -@c $Id: speedbar.texi,v 1.12 2003/09/01 15:45:46 miles Exp $ +@c $Id: speedbar.texi,v 1.13 2003/10/08 22:02:52 nickrob Exp $ @setfilename ../info/speedbar @settitle Speedbar: File/Tag summarizing utility
--- a/man/woman.texi Thu Jan 01 23:44:00 2004 +0000 +++ b/man/woman.texi Fri Jan 02 04:37:46 2004 +0000 @@ -1,5 +1,5 @@ \input texinfo @c -*-texinfo-*- -@c $Id: woman.texi,v 1.15 2003/09/30 20:42:15 rms Exp $ +@c $Id: woman.texi,v 1.16 2003/11/02 07:01:19 eliz Exp $ @c %**start of header @setfilename ../info/woman @settitle WoMan: Browse Unix Manual Pages ``W.O. (without) Man''
--- a/mkinstalldirs Thu Jan 01 23:44:00 2004 +0000 +++ b/mkinstalldirs Fri Jan 02 04:37:46 2004 +0000 @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.1 2001/02/02 13:04:53 gerd Exp $ +# $Id: mkinstalldirs,v 1.2 2001/02/02 13:09:26 gerd Exp $ errstatus=0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nt/.arch-inventory Fri Jan 02 04:37:46 2004 +0000 @@ -0,0 +1,3 @@ +source ^subdirs\.el$ + +# arch-tag: 01b87183-9d94-4b6b-93cb-fece25c4eec9
--- a/oldXMenu/Activate.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Activate.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Activate.c,v 1.5 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Activate.c,v 1.6 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ #include "copyright.h"
--- a/oldXMenu/AddPane.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/AddPane.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/AddPane.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/AddPane.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/AddSel.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/AddSel.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/AddSel.c,v 1.3 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/AddSel.c,v 1.4 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/ChgPane.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/ChgPane.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/ChgPane.c,v 1.1 1999/10/03 19:34:53 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/ChgPane.c,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/ChgSel.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/ChgSel.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/ChgSel.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/ChgSel.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/Create.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Create.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Create.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Create.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ #include "copyright.h"
--- a/oldXMenu/DelPane.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/DelPane.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/DelPane.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/DelPane.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/DelSel.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/DelSel.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/DelSel.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/DelSel.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/Destroy.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Destroy.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Destroy.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Destroy.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/Error.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Error.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Error.c,v 1.1 1999/10/03 19:35:00 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Error.c,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/EvHand.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/EvHand.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/EvHand.c,v 1.1 1999/10/03 19:35:01 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/EvHand.c,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/FindPane.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/FindPane.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/FindPane.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/FindPane.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/FindSel.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/FindSel.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/FindSel.c,v 1.1 1999/10/03 19:35:03 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/FindSel.c,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/InsPane.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/InsPane.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/InsPane.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/InsPane.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/InsSel.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/InsSel.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/InsSel.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/InsSel.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/Internal.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Internal.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Internal.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Internal.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/Locate.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Locate.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Locate.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Locate.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/Post.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Post.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Post.c,v 1.3 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Post.c,v 1.4 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/Recomp.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/Recomp.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/Recomp.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/Recomp.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/SetAEQ.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/SetAEQ.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetAEQ.c,v 1.1 1999/10/03 19:35:12 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetAEQ.c,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/SetFrz.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/SetFrz.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetFrz.c,v 1.1 1999/10/03 19:35:13 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetFrz.c,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/SetPane.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/SetPane.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetPane.c,v 1.1 1999/10/03 19:35:14 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetPane.c,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/SetSel.c Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/SetSel.c Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetSel.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/SetSel.c,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/X10.h Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/X10.h Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/emacs/emacs/oldXMenu/X10.h,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/X10.h,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* * Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology *
--- a/oldXMenu/XMenu.h Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/XMenu.h Fri Jan 02 04:37:46 2004 +0000 @@ -1,6 +1,6 @@ #include "copyright.h" -/* $Header: /cvsroot/emacs/emacs/oldXMenu/XMenu.h,v 1.3 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/XMenu.h,v 1.4 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/XMenuInt.h Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/XMenuInt.h Fri Jan 02 04:37:46 2004 +0000 @@ -1,5 +1,5 @@ -/* $Header: /cvsroot/emacs/emacs/oldXMenu/XMenuInt.h,v 1.2 2003/02/04 14:19:01 lektu Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/XMenuInt.h,v 1.3 2003/09/01 15:45:47 miles Exp $ */ /* Copyright Massachusetts Institute of Technology 1985 */ /*
--- a/oldXMenu/copyright.h Thu Jan 01 23:44:00 2004 +0000 +++ b/oldXMenu/copyright.h Fri Jan 02 04:37:46 2004 +0000 @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/emacs/emacs/oldXMenu/copyright.h,v 1.1 1999/10/03 19:35:25 fx Exp $ */ +/* $Header: /cvsroot/emacs/emacs/oldXMenu/copyright.h,v 1.2 2003/09/01 15:45:47 miles Exp $ */ /* Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
--- a/src/.gdbinit Thu Jan 01 23:44:00 2004 +0000 +++ b/src/.gdbinit Fri Jan 02 04:37:46 2004 +0000 @@ -383,7 +383,7 @@ show environment DISPLAY show environment TERM -set args -geometry 80x40+0+0 +#set args -geometry 80x40+0+0 # Don't let abort actually run, as it will make # stdio stop working and therefore the `pr' command above as well.
--- a/src/Makefile.in Thu Jan 01 23:44:00 2004 +0000 +++ b/src/Makefile.in Fri Jan 02 04:37:46 2004 +0000 @@ -1047,7 +1047,7 @@ charset.o: charset.c charset.h buffer.h coding.h composite.h disptab.h \ $(config_h) coding.o: coding.c coding.h ccl.h buffer.h charset.h intervals.h composite.h window.h $(config_h) -cm.o: cm.c cm.h termhooks.h $(config_h) +cm.o: cm.c frame.h cm.h termhooks.h systty.h termchar.h $(config_h) cmds.o: cmds.c syntax.h buffer.h charset.h commands.h window.h $(config_h) \ msdos.h dispextern.h pre-crt0.o: pre-crt0.c @@ -1055,7 +1055,7 @@ CRT0_COMPILE ${srcdir}/ecrt0.c dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \ systime.h -dispnew.o: dispnew.c systty.h systime.h commands.h process.h frame.h \ +dispnew.o: dispnew.c systty.h systime.h commands.h process.h frame.h \ window.h buffer.h dispextern.h termchar.h termopts.h termhooks.h cm.h \ disptab.h \ xterm.h blockinput.h atimer.h charset.h msdos.h composite.h keyboard.h \ @@ -1073,12 +1073,12 @@ filelock.o: filelock.c buffer.h systime.h epaths.h $(config_h) filemode.o: filemode.c $(config_h) frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \ - blockinput.h atimer.h systime.h buffer.h charset.h fontset.h \ + blockinput.h systty.h atimer.h systime.h buffer.h charset.h fontset.h \ msdos.h dosfns.h dispextern.h $(config_h) fontset.o: dispextern.h fontset.h fontset.c ccl.h buffer.h charset.h frame.h \ - keyboard.h $(config_h) + keyboard.h termhooks.h $(config_h) getloadavg.o: getloadavg.c $(config_h) -indent.o: indent.c frame.h window.h indent.h buffer.h $(config_h) termchar.h \ +indent.o: indent.c frame.h window.h systty.h indent.h buffer.h $(config_h) termchar.h \ termopts.h disptab.h region-cache.h charset.h composite.h dispextern.h \ keyboard.h insdel.o: insdel.c window.h buffer.h $(INTERVAL_SRC) blockinput.h charset.h \ @@ -1099,7 +1099,7 @@ marker.o: marker.c buffer.h charset.h $(config_h) md5.o: md5.c md5.h $(config_h) minibuf.o: minibuf.c syntax.h dispextern.h frame.h window.h keyboard.h \ - buffer.h commands.h charset.h msdos.h $(config_h) + buffer.h commands.h charset.h msdos.h termhooks.h $(config_h) mktime.o: mktime.c $(config_h) msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \ termopts.h termchar.h charset.h coding.h ccl.h disptab.h window.h \ @@ -1110,8 +1110,8 @@ keyboard.h $(config_h) regex.o: regex.c syntax.h buffer.h $(config_h) regex.h category.h charset.h region-cache.o: region-cache.c buffer.h region-cache.h -scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \ - $(config_h) +scroll.o: scroll.c systty.h termchar.h dispextern.h frame.h msdos.h keyboard.h \ + termhooks.h $(config_h) search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \ blockinput.h atimer.h systime.h category.h charset.h composite.h $(config_h) strftime.o: strftime.c $(config_h) @@ -1119,8 +1119,8 @@ composite.h $(config_h) sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ process.h dispextern.h termhooks.h termchar.h termopts.h \ - frame.h atimer.h window.h msdos.h dosfns.h keyboard.h $(config_h) -term.o: term.c termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \ + frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h $(config_h) +term.o: term.c systty.h termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \ disptab.h dispextern.h keyboard.h charset.h coding.h ccl.h msdos.h termcap.o: termcap.c $(config_h) terminfo.o: terminfo.c $(config_h) @@ -1134,17 +1134,18 @@ msdos.h $(config_h) widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \ $(srcdir)/../lwlib/lwlib.h $(config_h) -window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \ +window.o: window.c indent.h commands.h frame.h window.h buffer.h systty.h termchar.h \ termhooks.h disptab.h keyboard.h dispextern.h msdos.h composite.h \ $(config_h) xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h coding.h \ - termchar.h frame.h window.h disptab.h termhooks.h charset.h $(config_h) \ + systty.h termchar.h frame.h window.h disptab.h termhooks.h charset.h $(config_h) \ msdos.h composite.h fontset.h blockinput.h atimer.h systime.h keymap.h xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \ - window.h charset.h msdos.h dosfns.h composite.h atimer.h systime.h $(config_h) + window.h charset.h msdos.h dosfns.h composite.h atimer.h systime.h \ + systty.h termchar.h $(config_h) xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \ $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \ - charset.h gtkutil.h $(config_h) + charset.h gtkutil.h systty.h termchar.h $(config_h) xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \ keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h \ gtkutil.h msdos.h coding.h $(config_h) @@ -1176,7 +1177,7 @@ fns.o: fns.c commands.h $(config_h) frame.h buffer.h charset.h keyboard.h \ frame.h window.h dispextern.h $(INTERVAL_SRC) coding.h md5.h print.o: print.c process.h frame.h window.h buffer.h keyboard.h charset.h \ - $(config_h) dispextern.h msdos.h composite.h + $(config_h) dispextern.h msdos.h composite.h systty.h termchar.h intervals.h lread.o: lread.c commands.h keyboard.h buffer.h epaths.h charset.h $(config_h) \ termhooks.h coding.h msdos.h
--- a/src/alloc.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/alloc.c Fri Jan 02 04:37:46 2004 +0000 @@ -256,6 +256,7 @@ static void mark_buffer P_ ((Lisp_Object)); extern void mark_kboards P_ ((void)); +extern void mark_ttys P_ ((void)); static void gc_sweep P_ ((void)); static void mark_glyph_matrix P_ ((struct glyph_matrix *)); static void mark_face_cache P_ ((struct face_cache *)); @@ -4441,6 +4442,7 @@ mark_object (backlist->args[i]); } mark_kboards (); + mark_ttys (); /* Look thru every buffer's undo list for elements that update markers that were not marked,
--- a/src/cm.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/cm.c Fri Jan 02 04:37:46 2004 +0000 @@ -22,8 +22,16 @@ #include <config.h> #include <stdio.h> + +/* For CURTTY */ +#include "lisp.h" +#include "frame.h" + #include "cm.h" #include "termhooks.h" +#include "systty.h" /* For emacs_tty in termchar.h */ +#include "termchar.h" + /* For now, don't try to include termcap.h. On some systems, configure finds a non-standard termcap.h that the main build @@ -41,6 +49,7 @@ extern char *BC, *UP; + int cost; /* sums up costs */ /* ARGSUSED */ @@ -52,13 +61,17 @@ return c; } +/* The terminal to use for low-level output. */ +struct tty_display_info *current_tty; + int cmputc (c) char c; { - if (termscript) - fputc (c & 0177, termscript); - putchar (c & 0177); + if (TTY_TERMSCRIPT (current_tty)) + putc (c & 0177, TTY_TERMSCRIPT (current_tty)); + if (putc (c & 0177, TTY_OUTPUT (current_tty)) == EOF) + abort (); /* XXX For testing only! */ return c; } @@ -71,9 +84,9 @@ */ static -at (row, col) { - curY = row; - curX = col; +at (tty, row, col) { + curY (tty) = row; + curX (tty) = col; } /* @@ -81,8 +94,8 @@ */ static -addcol (n) { - curX += n; +addcol (tty, n) { + curX (tty) += n; /* * If cursor hit edge of screen, what happened? @@ -92,21 +105,21 @@ * of the last line. */ - if (curX == Wcm.cm_cols) { + if (curX (tty) == tty->Wcm->cm_cols) { /* * Well, if magicwrap, still there, past the edge of the * screen (!). If autowrap, on the col 0 of the next line. * Otherwise on last column. */ - if (Wcm.cm_magicwrap) + if (tty->Wcm->cm_magicwrap) ; /* "limbo" */ - else if (Wcm.cm_autowrap) { - curX = 0; - curY++; /* Beware end of screen! */ + else if (tty->Wcm->cm_autowrap) { + curX (tty) = 0; + curY (tty) ++; /* Beware end of screen! */ } else - curX--; + curX (tty)--; } } #endif @@ -122,20 +135,20 @@ * after we reach the last column; this takes us to a known state. */ void -cmcheckmagic () +cmcheckmagic (struct tty_display_info *tty) { - if (curX == FrameCols) + if (curX (tty) == FrameCols (tty)) { - if (!MagicWrap || curY >= FrameRows - 1) + if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1) abort (); - if (termscript) - putc ('\r', termscript); - putchar ('\r'); - if (termscript) - putc ('\n', termscript); - putchar ('\n'); - curX = 0; - curY++; + if (TTY_TERMSCRIPT (tty)) + putc ('\r', TTY_TERMSCRIPT (tty)); + putc ('\r', TTY_OUTPUT (tty)); + if (TTY_TERMSCRIPT (tty)) + putc ('\n', TTY_TERMSCRIPT (tty)); + putc ('\n', TTY_OUTPUT (tty)); + curX (tty) = 0; + curY (tty)++; } } @@ -147,21 +160,21 @@ */ void -cmcostinit () +cmcostinit (struct tty_display_info *tty) { char *p; #define COST(x,e) (x ? (cost = 0, tputs (x, 1, e), cost) : BIG) #define CMCOST(x,e) ((x == 0) ? BIG : (p = tgoto(x, 0, 0), COST(p ,e))) - Wcm.cc_up = COST (Wcm.cm_up, evalcost); - Wcm.cc_down = COST (Wcm.cm_down, evalcost); - Wcm.cc_left = COST (Wcm.cm_left, evalcost); - Wcm.cc_right = COST (Wcm.cm_right, evalcost); - Wcm.cc_home = COST (Wcm.cm_home, evalcost); - Wcm.cc_cr = COST (Wcm.cm_cr, evalcost); - Wcm.cc_ll = COST (Wcm.cm_ll, evalcost); - Wcm.cc_tab = Wcm.cm_tabwidth ? COST (Wcm.cm_tab, evalcost) : BIG; + tty->Wcm->cc_up = COST (tty->Wcm->cm_up, evalcost); + tty->Wcm->cc_down = COST (tty->Wcm->cm_down, evalcost); + tty->Wcm->cc_left = COST (tty->Wcm->cm_left, evalcost); + tty->Wcm->cc_right = COST (tty->Wcm->cm_right, evalcost); + tty->Wcm->cc_home = COST (tty->Wcm->cm_home, evalcost); + tty->Wcm->cc_cr = COST (tty->Wcm->cm_cr, evalcost); + tty->Wcm->cc_ll = COST (tty->Wcm->cm_ll, evalcost); + tty->Wcm->cc_tab = tty->Wcm->cm_tabwidth ? COST (tty->Wcm->cm_tab, evalcost) : BIG; /* * These last three are actually minimum costs. When (if) they are @@ -172,9 +185,9 @@ * cursor motion seem to take straight numeric values. --ACT) */ - Wcm.cc_abs = CMCOST (Wcm.cm_abs, evalcost); - Wcm.cc_habs = CMCOST (Wcm.cm_habs, evalcost); - Wcm.cc_vabs = CMCOST (Wcm.cm_vabs, evalcost); + tty->Wcm->cc_abs = CMCOST (tty->Wcm->cm_abs, evalcost); + tty->Wcm->cc_habs = CMCOST (tty->Wcm->cm_habs, evalcost); + tty->Wcm->cc_vabs = CMCOST (tty->Wcm->cm_vabs, evalcost); #undef CMCOST #undef COST @@ -187,8 +200,8 @@ */ static int -calccost (srcy, srcx, dsty, dstx, doit) - int srcy, srcx, dsty, dstx, doit; +calccost (struct tty_display_info *tty, + int srcy, int srcx, int dsty, int dstx, int doit) { register int deltay, deltax, @@ -205,16 +218,16 @@ don't believe the cursor position: give up here and force use of absolute positioning. */ - if (curX == Wcm.cm_cols) + if (curX (tty) == tty->Wcm->cm_cols) goto fail; totalcost = 0; if ((deltay = dsty - srcy) == 0) goto x; if (deltay < 0) - p = Wcm.cm_up, c = Wcm.cc_up, deltay = -deltay; + p = tty->Wcm->cm_up, c = tty->Wcm->cc_up, deltay = -deltay; else - p = Wcm.cm_down, c = Wcm.cc_down; + p = tty->Wcm->cm_down, c = tty->Wcm->cc_down; if (c == BIG) { /* caint get thar from here */ if (doit) printf ("OOPS"); @@ -223,16 +236,16 @@ totalcost = c * deltay; if (doit) while (--deltay >= 0) - tputs (p, 1, cmputc); + emacs_tputs (tty, p, 1, cmputc); x: if ((deltax = dstx - srcx) == 0) goto done; if (deltax < 0) { - p = Wcm.cm_left, c = Wcm.cc_left, deltax = -deltax; + p = tty->Wcm->cm_left, c = tty->Wcm->cc_left, deltax = -deltax; goto dodelta; /* skip all the tab junk */ } /* Tabs (the toughie) */ - if (Wcm.cc_tab >= BIG || !Wcm.cm_usetabs) + if (tty->Wcm->cc_tab >= BIG || !tty->Wcm->cm_usetabs) goto olddelta; /* forget it! */ /* @@ -243,12 +256,12 @@ * we will put into tabx (for ntabs) and tab2x (for n2tabs)). */ - ntabs = (deltax + srcx % Wcm.cm_tabwidth) / Wcm.cm_tabwidth; + ntabs = (deltax + srcx % tty->Wcm->cm_tabwidth) / tty->Wcm->cm_tabwidth; n2tabs = ntabs + 1; - tabx = (srcx / Wcm.cm_tabwidth + ntabs) * Wcm.cm_tabwidth; - tab2x = tabx + Wcm.cm_tabwidth; + tabx = (srcx / tty->Wcm->cm_tabwidth + ntabs) * tty->Wcm->cm_tabwidth; + tab2x = tabx + tty->Wcm->cm_tabwidth; - if (tab2x >= Wcm.cm_cols) /* too far (past edge) */ + if (tab2x >= tty->Wcm->cm_cols) /* too far (past edge) */ n2tabs = 0; /* @@ -257,11 +270,11 @@ */ /* cost for ntabs + cost for right motion */ - tabcost = ntabs ? ntabs * Wcm.cc_tab + (dstx - tabx) * Wcm.cc_right + tabcost = ntabs ? ntabs * tty->Wcm->cc_tab + (dstx - tabx) * tty->Wcm->cc_right : BIG; /* cost for n2tabs + cost for left motion */ - c = n2tabs ? n2tabs * Wcm.cc_tab + (tab2x - dstx) * Wcm.cc_left + c = n2tabs ? n2tabs * tty->Wcm->cc_tab + (tab2x - dstx) * tty->Wcm->cc_left : BIG; if (c < tabcost) /* then cheaper to overshoot & back up */ @@ -274,11 +287,11 @@ * See if tabcost is less than just moving right */ - if (tabcost < (deltax * Wcm.cc_right)) { + if (tabcost < (deltax * tty->Wcm->cc_right)) { totalcost += tabcost; /* use the tabs */ if (doit) while (--ntabs >= 0) - tputs (Wcm.cm_tab, 1, cmputc); + emacs_tputs (tty, tty->Wcm->cm_tab, 1, cmputc); srcx = tabx; } @@ -291,9 +304,9 @@ goto done; olddelta: if (deltax > 0) - p = Wcm.cm_right, c = Wcm.cc_right; + p = tty->Wcm->cm_right, c = tty->Wcm->cc_right; else - p = Wcm.cm_left, c = Wcm.cc_left, deltax = -deltax; + p = tty->Wcm->cm_left, c = tty->Wcm->cc_left, deltax = -deltax; dodelta: if (c == BIG) { /* caint get thar from here */ @@ -305,7 +318,7 @@ totalcost += c * deltax; if (doit) while (--deltax >= 0) - tputs (p, 1, cmputc); + emacs_tputs (tty, p, 1, cmputc); done: return totalcost; } @@ -323,7 +336,8 @@ #define USECR 3 void -cmgoto (row, col) +cmgoto (tty, row, col) + struct tty_display_info *tty; int row, col; { int homecost, @@ -336,47 +350,47 @@ *dcm; /* First the degenerate case */ - if (row == curY && col == curX) /* already there */ + if (row == curY (tty) && col == curX (tty)) /* already there */ return; - if (curY >= 0 && curX >= 0) + if (curY (tty) >= 0 && curX (tty) >= 0) { /* We may have quick ways to go to the upper-left, bottom-left, * start-of-line, or start-of-next-line. Or it might be best to * start where we are. Examine the options, and pick the cheapest. */ - relcost = calccost (curY, curX, row, col, 0); + relcost = calccost (tty, curY (tty), curX (tty), row, col, 0); use = USEREL; - if ((homecost = Wcm.cc_home) < BIG) - homecost += calccost (0, 0, row, col, 0); + if ((homecost = tty->Wcm->cc_home) < BIG) + homecost += calccost (tty, 0, 0, row, col, 0); if (homecost < relcost) - relcost = homecost, use = USEHOME; - if ((llcost = Wcm.cc_ll) < BIG) - llcost += calccost (Wcm.cm_rows - 1, 0, row, col, 0); + relcost = homecost, use = USEHOME; + if ((llcost = tty->Wcm->cc_ll) < BIG) + llcost += calccost (tty, tty->Wcm->cm_rows - 1, 0, row, col, 0); if (llcost < relcost) - relcost = llcost, use = USELL; - if ((crcost = Wcm.cc_cr) < BIG) { - if (Wcm.cm_autolf) - if (curY + 1 >= Wcm.cm_rows) - crcost = BIG; + relcost = llcost, use = USELL; + if ((crcost = tty->Wcm->cc_cr) < BIG) { + if (tty->Wcm->cm_autolf) + if (curY (tty) + 1 >= tty->Wcm->cm_rows) + crcost = BIG; else - crcost += calccost (curY + 1, 0, row, col, 0); + crcost += calccost (tty, curY (tty) + 1, 0, row, col, 0); else - crcost += calccost (curY, 0, row, col, 0); + crcost += calccost (tty, curY (tty), 0, row, col, 0); } if (crcost < relcost) relcost = crcost, use = USECR; - directcost = Wcm.cc_abs, dcm = Wcm.cm_abs; - if (row == curY && Wcm.cc_habs < BIG) - directcost = Wcm.cc_habs, dcm = Wcm.cm_habs; - else if (col == curX && Wcm.cc_vabs < BIG) - directcost = Wcm.cc_vabs, dcm = Wcm.cm_vabs; + directcost = tty->Wcm->cc_abs, dcm = tty->Wcm->cm_abs; + if (row == curY (tty) && tty->Wcm->cc_habs < BIG) + directcost = tty->Wcm->cc_habs, dcm = tty->Wcm->cm_habs; + else if (col == curX (tty) && tty->Wcm->cc_vabs < BIG) + directcost = tty->Wcm->cc_vabs, dcm = tty->Wcm->cm_vabs; } else { directcost = 0, relcost = 100000; - dcm = Wcm.cm_abs; + dcm = tty->Wcm->cm_abs; } /* @@ -387,13 +401,14 @@ { /* compute REAL direct cost */ cost = 0; - p = dcm == Wcm.cm_habs ? tgoto (dcm, row, col) : - tgoto (dcm, col, row); - tputs (p, 1, evalcost); + p = dcm == tty->Wcm->cm_habs + ? tgoto (dcm, row, col) + : tgoto (dcm, col, row); + emacs_tputs (tty, p, 1, evalcost); if (cost <= relcost) { /* really is cheaper */ - tputs (p, 1, cmputc); - curY = row, curX = col; + emacs_tputs (tty, p, 1, cmputc); + curY (tty) = row, curX (tty) = col; return; } } @@ -401,25 +416,25 @@ switch (use) { case USEHOME: - tputs (Wcm.cm_home, 1, cmputc); - curY = 0, curX = 0; + emacs_tputs (tty, tty->Wcm->cm_home, 1, cmputc); + curY (tty) = 0, curX (tty) = 0; break; case USELL: - tputs (Wcm.cm_ll, 1, cmputc); - curY = Wcm.cm_rows - 1, curX = 0; + emacs_tputs (tty, tty->Wcm->cm_ll, 1, cmputc); + curY (tty) = tty->Wcm->cm_rows - 1, curX (tty) = 0; break; case USECR: - tputs (Wcm.cm_cr, 1, cmputc); - if (Wcm.cm_autolf) - curY++; - curX = 0; + emacs_tputs (tty, tty->Wcm->cm_cr, 1, cmputc); + if (tty->Wcm->cm_autolf) + curY (tty)++; + curX (tty) = 0; break; } - (void) calccost (curY, curX, row, col, 1); - curY = row, curX = col; + (void) calccost (tty, curY (tty), curX (tty), row, col, 1); + curY (tty) = row, curX (tty) = col; } /* Clear out all terminal info. @@ -427,9 +442,9 @@ */ void -Wcm_clear () +Wcm_clear (struct tty_display_info *tty) { - bzero (&Wcm, sizeof Wcm); + bzero (tty->Wcm, sizeof (struct cm)); UP = 0; BC = 0; } @@ -442,21 +457,21 @@ */ int -Wcm_init () +Wcm_init (struct tty_display_info *tty) { #if 0 - if (Wcm.cm_abs && !Wcm.cm_ds) + if (tty->Wcm->cm_abs && !tty->Wcm->cm_ds) return 0; #endif - if (Wcm.cm_abs) + if (tty->Wcm->cm_abs) return 0; /* Require up and left, and, if no absolute, down and right */ - if (!Wcm.cm_up || !Wcm.cm_left) + if (!tty->Wcm->cm_up || !tty->Wcm->cm_left) return - 1; - if (!Wcm.cm_abs && (!Wcm.cm_down || !Wcm.cm_right)) + if (!tty->Wcm->cm_abs && (!tty->Wcm->cm_down || !tty->Wcm->cm_right)) return - 1; /* Check that we know the size of the screen.... */ - if (Wcm.cm_rows <= 0 || Wcm.cm_cols <= 0) + if (tty->Wcm->cm_rows <= 0 || tty->Wcm->cm_cols <= 0) return - 2; return 0; }
--- a/src/cm.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/cm.h Fri Jan 02 04:37:46 2004 +0000 @@ -98,76 +98,78 @@ int cc_vabs; }; -extern struct cm Wcm; /* Terminal capabilities */ extern char PC; /* Pad character */ /* Shorthand */ #ifndef NoCMShortHand -#define curY Wcm.cm_curY -#define curX Wcm.cm_curX -#define Up Wcm.cm_up -#define Down Wcm.cm_down -#define Left Wcm.cm_left -#define Right Wcm.cm_right -#define Tab Wcm.cm_tab -#define BackTab Wcm.cm_backtab -#define TabWidth Wcm.cm_tabwidth -#define CR Wcm.cm_cr -#define Home Wcm.cm_home -#define LastLine Wcm.cm_ll -#define AbsPosition Wcm.cm_abs -#define ColPosition Wcm.cm_habs -#define RowPosition Wcm.cm_vabs -#define MultiUp Wcm.cm_multiup -#define MultiDown Wcm.cm_multidown -#define MultiLeft Wcm.cm_multileft -#define MultiRight Wcm.cm_multiright -#define AutoWrap Wcm.cm_autowrap -#define MagicWrap Wcm.cm_magicwrap -#define UseTabs Wcm.cm_usetabs -#define FrameRows Wcm.cm_rows -#define FrameCols Wcm.cm_cols +#define curY(tty) (tty)->Wcm->cm_curY +#define curX(tty) (tty)->Wcm->cm_curX +#define Up(tty) (tty)->Wcm->cm_up +#define Down(tty) (tty)->Wcm->cm_down +#define Left(tty) (tty)->Wcm->cm_left +#define Right(tty) (tty)->Wcm->cm_right +#define Tab(tty) (tty)->Wcm->cm_tab +#define BackTab(tty) (tty)->Wcm->cm_backtab +#define TabWidth(tty) (tty)->Wcm->cm_tabwidth +#define CR(tty) (tty)->Wcm->cm_cr +#define Home(tty) (tty)->Wcm->cm_home +#define LastLine(tty) (tty)->Wcm->cm_ll +#define AbsPosition(tty) (tty)->Wcm->cm_abs +#define ColPosition(tty) (tty)->Wcm->cm_habs +#define RowPosition(tty) (tty)->Wcm->cm_vabs +#define MultiUp(tty) (tty)->Wcm->cm_multiup +#define MultiDown(tty) (tty)->Wcm->cm_multidown +#define MultiLeft(tty) (tty)->Wcm->cm_multileft +#define MultiRight(tty) (tty)->Wcm->cm_multiright +#define AutoWrap(tty) (tty)->Wcm->cm_autowrap +#define MagicWrap(tty) (tty)->Wcm->cm_magicwrap +#define UseTabs(tty) (tty)->Wcm->cm_usetabs +#define FrameRows(tty) (tty)->Wcm->cm_rows +#define FrameCols(tty) (tty)->Wcm->cm_cols -#define UpCost Wcm.cc_up -#define DownCost Wcm.cc_down -#define LeftCost Wcm.cc_left -#define RightCost Wcm.cc_right -#define HomeCost Wcm.cc_home -#define CRCost Wcm.cc_cr -#define LastLineCost Wcm.cc_ll -#define TabCost Wcm.cc_tab -#define BackTabCost Wcm.cc_backtab -#define AbsPositionCost Wcm.cc_abs -#define ColPositionCost Wcm.cc_habs -#define RowPositionCost Wcm.cc_vabs -#define MultiUpCost Wcm.cc_multiup -#define MultiDownCost Wcm.cc_multidown -#define MultiLeftCost Wcm.cc_multileft -#define MultiRightCost Wcm.cc_multiright +#define UpCost(tty) (tty)->Wcm->cc_up +#define DownCost(tty) (tty)->Wcm->cc_down +#define LeftCost(tty) (tty)->Wcm->cc_left +#define RightCost(tty) (tty)->Wcm->cc_right +#define HomeCost(tty) (tty)->Wcm->cc_home +#define CRCost(tty) (tty)->Wcm->cc_cr +#define LastLineCost(tty) (tty)->Wcm->cc_ll +#define TabCost(tty) (tty)->Wcm->cc_tab +#define BackTabCost(tty) (tty)->Wcm->cc_backtab +#define AbsPositionCost(tty) (tty)->Wcm->cc_abs +#define ColPositionCost(tty) (tty)->Wcm->cc_habs +#define RowPositionCost(tty) (tty)->Wcm->cc_vabs +#define MultiUpCost(tty) (tty)->Wcm->cc_multiup +#define MultiDownCost(tty) (tty)->Wcm->cc_multidown +#define MultiLeftCost(tty) (tty)->Wcm->cc_multileft +#define MultiRightCost(tty) (tty)->Wcm->cc_multiright #endif -#define cmat(row,col) (curY = (row), curX = (col)) -#define cmplus(n) \ - { \ - if ((curX += (n)) >= FrameCols && !MagicWrap) \ - { \ - if (Wcm.cm_losewrap) losecursor (); \ - else if (AutoWrap) curX = 0, curY++; \ - else curX--; \ - } \ +#define cmat(tty,row,col) (curY(tty) = (row), curX(tty) = (col)) +#define cmplus(tty,n) \ + { \ + if ((curX (tty) += (n)) >= FrameCols (tty) && !MagicWrap (tty)) \ + { \ + if ((tty)->Wcm->cm_losewrap) losecursor (tty); \ + else if (AutoWrap (tty)) curX (tty) = 0, curY (tty)++; \ + else curX (tty)--; \ + } \ } -#define losecursor() (curX = -1, curY = -1) +#define losecursor(tty) (curX(tty) = -1, curY(tty) = -1) extern int cost; extern int evalcost (); -extern void cmcheckmagic (); -extern int cmputc (); -extern void cmcostinit (); -extern void cmgoto (); -extern void Wcm_clear (); -extern int Wcm_init (); +#define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc)) + +extern struct tty_display_info *current_tty; +extern void cmcheckmagic P_ ((struct tty_display_info *)); +extern int cmputc P_ ((int)); +extern void cmcostinit P_ ((struct tty_display_info *)); +extern void cmgoto P_ ((struct tty_display_info *, int, int)); +extern void Wcm_clear P_ ((struct tty_display_info *)); +extern int Wcm_init P_ ((struct tty_display_info *)); /* arch-tag: acc1535a-7136-49d6-b22d-9bc85702251b (do not change this comment) */
--- a/src/config.in Thu Jan 01 23:44:00 2004 +0000 +++ b/src/config.in Fri Jan 02 04:37:46 2004 +0000 @@ -863,6 +863,12 @@ #define HAVE_MOUSE #endif +/* Multi-tty support relies on MULTI_KBOARD. It seems safe to turn it + on unconditionally. */ +#ifndef MULTI_KBOARD +#define MULTI_KBOARD +#endif + /* Define USER_FULL_NAME to return a string that is the user's full name. It can assume that the variable `pw'
--- a/src/dispextern.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/dispextern.h Fri Jan 02 04:37:46 2004 +0000 @@ -2011,16 +2011,16 @@ /* Call produce_glyphs or produce_glyphs_hook, if set. Shortcut to avoid the function call overhead. */ -#define PRODUCE_GLYPHS(IT) \ - do { \ - extern int inhibit_free_realized_faces; \ - if (rif != NULL) \ - rif->produce_glyphs ((IT)); \ - else \ - produce_glyphs ((IT)); \ - if ((IT)->glyph_row != NULL) \ - inhibit_free_realized_faces = 1; \ - } while (0) +#define PRODUCE_GLYPHS(IT) \ + do { \ + extern int inhibit_free_realized_faces; \ + if (FRAME_RIF ((IT)->f) != NULL) \ + FRAME_RIF ((IT)->f)->produce_glyphs ((IT)); \ + else \ + produce_glyphs ((IT)); \ + if ((IT)->glyph_row != NULL) \ + inhibit_free_realized_faces = 1; \ + } while (0) /* Bit-flags indicating what operation move_it_to should perform. */ @@ -2189,10 +2189,6 @@ #endif /* HAVE_WINDOW_SYSTEM */ }; -/* The current interface for window-based redisplay. */ - -extern struct redisplay_interface *rif; - /*********************************************************************** Images @@ -2562,11 +2558,11 @@ /* Defined in sysdep.c */ -void get_frame_size P_ ((int *, int *)); +void get_tty_size P_ ((int, int *, int *)); void request_sigio P_ ((void)); void unrequest_sigio P_ ((void)); -int tabs_safe_p P_ ((void)); -void init_baud_rate P_ ((void)); +int tabs_safe_p P_ ((int)); +void init_baud_rate P_ ((int)); void init_sigio P_ ((int)); /* Defined in xfaces.c */ @@ -2738,23 +2734,25 @@ extern void update_end P_ ((struct frame *)); extern void set_terminal_window P_ ((int)); extern void set_scroll_region P_ ((int, int)); -extern void turn_off_insert P_ ((void)); -extern void turn_off_highlight P_ ((void)); -extern void background_highlight P_ ((void)); +extern void turn_off_insert P_ ((struct tty_display_info *)); +extern void turn_off_highlight P_ ((struct tty_display_info *)); +extern void background_highlight P_ ((struct tty_display_info *)); extern void clear_frame P_ ((void)); extern void clear_end_of_line P_ ((int)); extern void clear_end_of_line_raw P_ ((int)); +extern void tty_clear_end_of_line P_ ((struct tty_display_info *, int)); extern void delete_glyphs P_ ((int)); extern void ins_del_lines P_ ((int, int)); extern int string_cost P_ ((char *)); extern int per_line_cost P_ ((char *)); extern void calculate_costs P_ ((struct frame *)); extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); -extern void tty_setup_colors P_ ((int)); -extern void term_init P_ ((char *)); +extern void tty_setup_colors P_ ((struct tty_display_info *, int)); +extern struct tty_display_info *term_init P_ ((Lisp_Object, char *, char *)); +extern struct tty_display_info *term_dummy_init P_ ((void)); extern void fatal P_ ((/* char *, ... */)); void cursor_to P_ ((int, int)); -extern int tty_capable_p P_ ((struct frame *, unsigned, unsigned long, unsigned long)); +extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); /* Defined in scroll.c */
--- a/src/dispnew.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/dispnew.c Fri Jan 02 04:37:46 2004 +0000 @@ -29,6 +29,7 @@ #endif #include "lisp.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "termopts.h" #include "termhooks.h" @@ -258,14 +259,6 @@ struct frame *last_nonminibuf_frame; -/* Stdio stream being used for copy of all output. */ - -FILE *termscript; - -/* Structure for info on cursor positioning. */ - -struct cm Wcm; - /* 1 means SIGWINCH happened when not safe. */ int delayed_size_change; @@ -304,11 +297,6 @@ static struct frame *frame_matrix_frame; -/* Current interface for window-based redisplay. Set from init_xterm. - A null value means we are not using window-based redisplay. */ - -struct redisplay_interface *rif; - /* Non-zero means that fonts have been loaded since the last glyph matrix adjustments. Redisplay must stop, and glyph matrices must be adjusted when this flag becomes non-zero during display. The @@ -1397,7 +1385,7 @@ { int c = glyph->u.ch; int face_id = glyph->face_id; - if (must_write_spaces) + if (FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */ c -= SPACEGLYPH; hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c; hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id; @@ -1429,7 +1417,7 @@ int glyph_table_len = GLYPH_TABLE_LENGTH; /* Ignore trailing and leading spaces if we can. */ - if (!must_write_spaces) + if (!FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */ { /* Skip from the end over trailing spaces. */ while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1))) @@ -1643,8 +1631,10 @@ #if GLYPH_DEBUG -/* Flush standard output. This is sometimes useful to call from - the debugger. */ +/* Flush standard output. This is sometimes useful to call from the debugger. + XXX Maybe this should be changed to flush the current terminal instead of + stdout. +*/ void flush_stdout () @@ -3322,7 +3312,8 @@ clear_frame (); clear_current_matrices (f); update_end (f); - fflush (stdout); + if (FRAME_TERMCAP_P (f)) + fflush (TTY_OUTPUT (FRAME_TTY (f))); windows_or_buffers_changed++; /* Mark all windows as inaccurate, so that every window will have its redisplay done. */ @@ -3462,7 +3453,7 @@ /* If we can't insert glyphs, we can use this method only at the end of a line. */ - if (!char_ins_del_ok) + if (!FRAME_CHAR_INS_DEL_OK (f)) if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n') return 0; @@ -3612,17 +3603,17 @@ updated_row = glyph_row; updated_area = TEXT_AREA; update_begin (f); - if (rif) + if (FRAME_RIF (f)) { - rif->update_window_begin_hook (w); + FRAME_RIF (f)->update_window_begin_hook (w); if (glyphs == end - n /* In front of a space added by append_space. */ || (glyphs == end - n - 1 && (end - n)->charpos <= 0)) - rif->write_glyphs (glyphs, n); + FRAME_RIF (f)->write_glyphs (glyphs, n); else - rif->insert_glyphs (glyphs, n); + FRAME_RIF (f)->insert_glyphs (glyphs, n); } else { @@ -3642,8 +3633,8 @@ a frame matrix is used, cursor_to expects frame coordinates, and the X and Y parameters are not used. */ if (window_redisplay_p) - rif->cursor_to (w->cursor.vpos, w->cursor.hpos, - w->cursor.y, w->cursor.x); + FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos, + w->cursor.y, w->cursor.x); else { int x, y; @@ -3655,11 +3646,12 @@ cursor_to (y, x); } - if (rif) - rif->update_window_end_hook (w, 1, 0); + if (FRAME_RIF (f)) + FRAME_RIF (f)->update_window_end_hook (w, 1, 0); update_end (f); updated_row = NULL; - fflush (stdout); + if (FRAME_TERMCAP_P (f)) + fflush (TTY_OUTPUT (FRAME_TTY (f))); TRACE ((stderr, "direct output for insert\n")); mark_window_display_accurate (it.window, 1); @@ -3737,8 +3729,8 @@ && w->cursor.hpos < w->desired_matrix->matrix_w); if (FRAME_WINDOW_P (f)) - rif->cursor_to (w->cursor.vpos, w->cursor.hpos, - w->cursor.y, w->cursor.x); + FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos, + w->cursor.y, w->cursor.x); else { int x, y; @@ -3750,7 +3742,8 @@ cursor_to (y, x); } - fflush (stdout); + if (FRAME_TERMCAP_P (f)) + fflush (TTY_OUTPUT (FRAME_TTY (f))); redisplay_performed_directly_p = 1; return 1; } @@ -3824,7 +3817,7 @@ #if 0 /* This flush is a performance bottleneck under X, and it doesn't seem to be necessary anyway. */ - rif->flush_display (f); + FRAME_RIF (f)->flush_display (f); #endif } else @@ -3841,9 +3834,9 @@ paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p); update_end (f); - if (termscript) - fflush (termscript); - fflush (stdout); + if (TTY_TERMSCRIPT (FRAME_TTY (f))) + fflush (TTY_TERMSCRIPT (FRAME_TTY (f))); + fflush (TTY_OUTPUT (FRAME_TTY (f))); /* Check window matrices for lost pointers. */ #if GLYPH_DEBUG @@ -3926,7 +3919,8 @@ int yb; { int i; - + struct frame *f = XFRAME (WINDOW_FRAME (w)); + /* If rows overlapping others have been changed, the rows being overlapped have to be redrawn. This won't draw lines that have already been drawn in update_window_line because overlapped_p in @@ -3949,10 +3943,12 @@ { updated_row = row; updated_area = area; - rif->cursor_to (i, 0, row->y, area == TEXT_AREA ? row->x : 0); + FRAME_RIF (f)->cursor_to (i, 0, row->y, + area == TEXT_AREA ? row->x : 0); if (row->used[area]) - rif->write_glyphs (row->glyphs[area], row->used[area]); - rif->clear_end_of_line (-1); + FRAME_RIF (f)->write_glyphs (row->glyphs[area], + row->used[area]); + FRAME_RIF (f)->clear_end_of_line (-1); } row->overlapped_p = 0; @@ -3974,7 +3970,8 @@ { int i, bottom_y; struct glyph_row *row; - + struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); + for (i = 0; i < w->current_matrix->nrows; ++i) { row = w->current_matrix->rows + i; @@ -4054,6 +4051,7 @@ #if GLYPH_DEBUG struct frame *f = XFRAME (WINDOW_FRAME (w)); #endif + struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); /* Check that W's frame doesn't have glyph matrices. */ xassert (FRAME_WINDOW_P (f)); @@ -4221,6 +4219,7 @@ int area, vpos; { struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); + struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); /* Let functions in xterm.c know what area subsequent X positions will be relative to. */ @@ -4246,6 +4245,7 @@ { struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); + struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); int changed_p = 0; /* Let functions in xterm.c know what area subsequent X positions @@ -4467,6 +4467,7 @@ { struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); + struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); int changed_p = 0; /* Set the row being updated. This is important to let xterm.c @@ -4537,6 +4538,7 @@ struct window *w; { struct frame *f = XFRAME (w->frame); + struct redisplay_interface *rif = FRAME_RIF (f); int cx, cy, vpos, hpos; /* Not intended for frame matrix updates. */ @@ -4760,6 +4762,7 @@ int i, j, first_old, first_new, last_old, last_new; int nruns, nbytes, n, run_idx; struct row_entry *entry; + struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); /* Skip over rows equal at the start. */ for (i = header_line_p ? 1 : 0; i < current_matrix->nrows - 1; ++i) @@ -5075,7 +5078,7 @@ } /* If we cannot insert/delete lines, it's no use trying it. */ - if (!line_ins_del_ok) + if (!FRAME_LINE_INS_DEL_OK (f)) inhibit_id_p = 1; /* See if any of the desired lines are enabled; don't compute for @@ -5103,18 +5106,18 @@ Also flush out if likely to have more than 1k buffered otherwise. I'm told that some telnet connections get really screwed by more than 1k output at once. */ - int outq = PENDING_OUTPUT_COUNT (stdout); + int outq = PENDING_OUTPUT_COUNT (TTY_OUTPUT (FRAME_TTY (f))); if (outq > 900 || (outq > 20 && ((i - 1) % preempt_count == 0))) { - fflush (stdout); + fflush (TTY_OUTPUT (FRAME_TTY (f))); if (preempt_count == 1) { #ifdef EMACS_OUTQSIZE if (EMACS_OUTQSIZE (0, &outq) < 0) /* Probably not a tty. Ignore the error and reset the outq count. */ - outq = PENDING_OUTPUT_COUNT (stdout); + outq = PENDING_OUTPUT_COUNT (TTY_OUTPUT (FRAME_TTY (f))); #endif outq *= 10; if (baud_rate <= outq && baud_rate > 0) @@ -5293,21 +5296,23 @@ } /* If changed lines are few, don't allow preemption, don't scroll. */ - if ((!scroll_region_ok && changed_lines < baud_rate / 2400) + if ((!FRAME_SCROLL_REGION_OK (frame) + && changed_lines < baud_rate / 2400) || unchanged_at_bottom == FRAME_LINES (frame)) return 1; window_size = (FRAME_LINES (frame) - unchanged_at_top - unchanged_at_bottom); - if (scroll_region_ok) + if (FRAME_SCROLL_REGION_OK (frame)) free_at_end_vpos -= unchanged_at_bottom; - else if (memory_below_frame) + else if (FRAME_MEMORY_BELOW_FRAME (frame)) free_at_end_vpos = -1; /* If large window, fast terminal and few lines in common between current frame and desired frame, don't bother with i/d calc. */ - if (!scroll_region_ok && window_size >= 18 && baud_rate > 2400 + if (!FRAME_SCROLL_REGION_OK (frame) + && window_size >= 18 && baud_rate > 2400 && (window_size >= 10 * scrolling_max_lines_saved (unchanged_at_top, FRAME_LINES (frame) - unchanged_at_bottom, @@ -5387,7 +5392,7 @@ struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos); int must_write_whole_line_p; - int write_spaces_p = must_write_spaces; + int write_spaces_p = FRAME_MUST_WRITE_SPACES (f); int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background != FACE_TTY_DEFAULT_BG_COLOR); @@ -5466,7 +5471,7 @@ nlen--; /* If there's no i/d char, quickly do the best we can without it. */ - if (!char_ins_del_ok) + if (!FRAME_CHAR_INS_DEL_OK (f)) { int i, j; @@ -5569,7 +5574,8 @@ tem = (nlen - nsp) - (olen - osp); if (endmatch && tem - && (!char_ins_del_ok || endmatch <= char_ins_del_cost (f)[tem])) + && (!FRAME_CHAR_INS_DEL_OK (f) + || endmatch <= char_ins_del_cost (f)[tem])) endmatch = 0; /* nsp - osp is the distance to insert or delete. @@ -5578,7 +5584,7 @@ Is it worth it? */ if (nsp != osp - && (!char_ins_del_ok + && (!FRAME_CHAR_INS_DEL_OK (f) || begmatch + endmatch <= char_ins_del_cost (f)[nsp - osp])) { begmatch = 0; @@ -5918,28 +5924,35 @@ #endif int old_errno = errno; - get_frame_size (&width, &height); - - /* The frame size change obviously applies to a termcap-controlled - frame. Find such a frame in the list, and assume it's the only - one (since the redisplay code always writes to stdout, not a - FILE * specified in the frame structure). Record the new size, - but don't reallocate the data structures now. Let that be done - later outside of the signal handler. */ - - { - Lisp_Object tail, frame; - - FOR_EACH_FRAME (tail, frame) - { - if (FRAME_TERMCAP_P (XFRAME (frame))) - { - change_frame_size (XFRAME (frame), height, width, 0, 1, 0); - break; - } - } + struct tty_display_info *tty; + + /* The frame size change obviously applies to a single + termcap-controlled terminal, but we can't decide which. + Therefore, we resize the frames corresponding to each tty. + */ + for (tty = tty_list; tty; tty = tty->next) { + + if (! tty->term_initted) + continue; + + get_tty_size (fileno (TTY_INPUT (tty)), &width, &height); + + { + Lisp_Object tail, frame; + + FOR_EACH_FRAME (tail, frame) + { + if (FRAME_TERMCAP_P (XFRAME (frame)) && FRAME_TTY (XFRAME (frame)) == tty) + { + /* Record the new sizes, but don't reallocate the data structures + now. Let that be done later outside of the signal handler. */ + change_frame_size (XFRAME (frame), height, width, 0, 1, 0); + break; + } + } + } } - + signal (SIGWINCH, window_change_signal); errno = old_errno; } @@ -5994,10 +6007,11 @@ { Lisp_Object tail, frame; - if (! FRAME_WINDOW_P (f)) + if (FRAME_MSDOS_P (f)) { - /* When using termcap, or on MS-DOS, all frames use - the same screen, so a change in size affects all frames. */ + /* On MS-DOS, all frames use the same screen, so a change in + size affects all frames. Termcap now supports multiple + ttys. */ FOR_EACH_FRAME (tail, frame) if (! FRAME_WINDOW_P (XFRAME (frame))) change_frame_size_1 (XFRAME (frame), newheight, newwidth, @@ -6077,7 +6091,7 @@ newheight - FRAME_TOP_MARGIN (f), 0); if (FRAME_TERMCAP_P (f) && !pretend) - FrameRows = newheight; + FrameRows (FRAME_TTY (f)) = newheight; } if (new_frame_total_cols != FRAME_TOTAL_COLS (f)) @@ -6087,7 +6101,7 @@ set_window_width (FRAME_MINIBUF_WINDOW (f), new_frame_total_cols, 0); if (FRAME_TERMCAP_P (f) && !pretend) - FrameCols = newwidth; + FrameCols (FRAME_TTY (f)) = newwidth; if (WINDOWP (f->tool_bar_window)) XSETFASTINT (XWINDOW (f->tool_bar_window)->total_cols, newwidth); @@ -6137,14 +6151,15 @@ (file) Lisp_Object file; { - if (termscript != 0) fclose (termscript); - termscript = 0; + if (TTY_TERMSCRIPT (CURTTY ()) != 0) + fclose (TTY_TERMSCRIPT (CURTTY ())); + TTY_TERMSCRIPT (CURTTY ()) = 0; if (! NILP (file)) { file = Fexpand_file_name (file, Qnil); - termscript = fopen (SDATA (file), "w"); - if (termscript == 0) + TTY_TERMSCRIPT (CURTTY ()) = fopen (SDATA (file), "w"); + if (TTY_TERMSCRIPT (CURTTY ()) == 0) report_file_error ("Opening termscript", Fcons (file, Qnil)); } return Qnil; @@ -6160,14 +6175,18 @@ { /* ??? Perhaps we should do something special for multibyte strings here. */ CHECK_STRING (string); - fwrite (SDATA (string), 1, SBYTES (string), stdout); - fflush (stdout); - if (termscript) + if (! FRAME_TERMCAP_P (SELECTED_FRAME ())) + error ("Current frame is not on a tty device"); + + if (TTY_TERMSCRIPT (CURTTY ())) { fwrite (SDATA (string), 1, SBYTES (string), - termscript); - fflush (termscript); + TTY_TERMSCRIPT (CURTTY ())); + fflush (TTY_TERMSCRIPT (CURTTY ())); } + fwrite (SDATA (string), 1, SBYTES (string), + TTY_OUTPUT (CURTTY ())); + fflush (TTY_OUTPUT (CURTTY ())); return Qnil; } @@ -6185,7 +6204,8 @@ putchar (07); else ring_bell (); - fflush (stdout); + if (FRAME_TERMCAP_P (XFRAME (selected_frame))) + fflush (TTY_OUTPUT (CURTTY ())); } else bitch_at_user (); @@ -6202,7 +6222,8 @@ error ("Keyboard macro terminated by a command ringing the bell"); else ring_bell (); - fflush (stdout); + if (FRAME_TERMCAP_P (XFRAME (selected_frame))) + fflush (TTY_OUTPUT (CURTTY ())); } @@ -6487,8 +6508,6 @@ Initialization ***********************************************************************/ -char *terminal_type; - /* Initialization done when Emacs fork is started, before doing stty. Determine terminal type and set terminal_driver. Then invoke its decoding routine to set up variables in the terminal package. */ @@ -6496,6 +6515,8 @@ void init_display () { + char *terminal_type; + #ifdef HAVE_X_WINDOWS extern int display_arg; #endif @@ -6505,7 +6526,6 @@ SET_CHAR_GLYPH_FROM_GLYPH (space_glyph, ' '); space_glyph.charpos = -1; - meta_key = 0; inverse_video = 0; cursor_in_echo_area = 0; terminal_type = (char *) 0; @@ -6617,8 +6637,13 @@ } #endif /* VMS */ - term_init (terminal_type); - + { + struct tty_display_info *tty; + + tty = term_init (selected_frame, 0, terminal_type); + change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 1); + } + { struct frame *sf = SELECTED_FRAME (); int width = FRAME_TOTAL_COLS (sf);
--- a/src/emacs.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/emacs.c Fri Jan 02 04:37:46 2004 +0000 @@ -1561,13 +1561,6 @@ #endif /* end #ifdef HAVE_NTGUI */ } - if (!noninteractive) - { -#ifdef VMS - init_vms_input ();/* init_display calls get_frame_size, that needs this. */ -#endif /* VMS */ - init_display (); /* Determine terminal type. init_sys_modes uses results. */ - } #ifndef MAC_OS8 /* Called before init_window_once for Mac OS Classic. */ init_keyboard (); /* This too must precede init_sys_modes. */ @@ -1575,7 +1568,13 @@ #ifdef VMS init_vmsproc (); /* And this too. */ #endif /* VMS */ - init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.). */ + if (!noninteractive) + { +#ifdef VMS + init_vms_input ();/* init_display calls get_tty_size, that needs this. */ +#endif /* VMS */ + init_display (); /* Determine terminal type. Calls init_sys_modes. */ + } #if defined (HAVE_X_WINDOWS) || defined (WINDOWSNT) init_xfns (); #endif /* HAVE_X_WINDOWS */ @@ -1910,9 +1909,9 @@ bcopy (new, argv, sizeof (char *) * argc); - free (options); - free (new); - free (priority); + xfree (options); + xfree (new); + xfree (priority); } DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", @@ -1991,15 +1990,14 @@ if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1 && tpgrp == pgrp) { - fflush (stdout); - reset_sys_modes (); + reset_all_sys_modes (); if (sig && sig != SIGTERM) fprintf (stderr, "Fatal error (%d)", sig); } } #else fflush (stdout); - reset_sys_modes (); + reset_all_sys_modes (); #endif stuff_buffered_input (stuff);
--- a/src/fontset.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/fontset.c Fri Jan 02 04:37:46 2004 +0000 @@ -45,6 +45,7 @@ #ifdef MAC_OS #include "macterm.h" #endif +#include "termhooks.h" #ifdef FONTSET_DEBUG #undef xassert @@ -1279,7 +1280,7 @@ STORE_XCHAR2B (&char2b, c1, c2); else STORE_XCHAR2B (&char2b, 0, c1); - rif->encode_char (c, &char2b, fontp, NULL); + FRAME_RIF (f)->encode_char (c, &char2b, fontp, NULL); code = (XCHAR2B_BYTE1 (&char2b) << 8) | XCHAR2B_BYTE2 (&char2b); } return Fcons (build_string (face->font_name), make_number (code));
--- a/src/frame.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/frame.c Fri Jan 02 04:37:46 2004 +0000 @@ -42,6 +42,8 @@ #include "fontset.h" #endif #include "blockinput.h" +#include "systty.h" /* For emacs_tty in termchar.h */ +#include "termchar.h" #include "termhooks.h" #include "dispextern.h" #include "window.h" @@ -106,12 +108,12 @@ Lisp_Object Qleft_fringe, Qright_fringe; Lisp_Object Qbuffer_predicate, Qbuffer_list; Lisp_Object Qtty_color_mode; +Lisp_Object Qtty, Qtty_type; Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; Lisp_Object Qface_set_after_frame_default; - Lisp_Object Vterminal_frame; Lisp_Object Vdefault_frame_alist; Lisp_Object Vdefault_frame_scroll_bars; @@ -121,8 +123,8 @@ static void set_menu_bar_lines_1 (window, n) - Lisp_Object window; - int n; + Lisp_Object window; + int n; { struct window *w = XWINDOW (window); @@ -180,8 +182,6 @@ Lisp_Object Vemacs_iconified; Lisp_Object Vframe_list; -struct x_output tty_display; - extern Lisp_Object Vminibuffer_list; extern Lisp_Object get_minibuffer (); extern Lisp_Object Fhandle_switch_frame (); @@ -474,18 +474,21 @@ } #endif /* HAVE_WINDOW_SYSTEM */ -/* Construct a frame that refers to the terminal (stdin and stdout). */ +/* Construct a frame that refers to a terminal. */ static int terminal_frame_count; struct frame * -make_terminal_frame () +make_terminal_frame (tty_name, tty_type) + char *tty_name; + char *tty_type; { register struct frame *f; Lisp_Object frame; char name[20]; - + #ifdef MULTI_KBOARD + /* Create the initial keyboard. */ if (!initial_kboard) { initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); @@ -537,12 +540,39 @@ #else #ifdef WINDOWSNT f->output_method = output_termcap; - f->output_data.x = &tty_display; + f->output_data.x = &tty_display; /* XXX */ #else #ifdef MAC_OS8 make_mac_terminal_frame (f); #else - f->output_data.x = &tty_display; + { + struct tty_display_info *tty; + f->output_method = output_termcap; + + f->output_data.tty = (struct tty_output *) xmalloc (sizeof (struct tty_output)); + bzero (f->output_data.tty, sizeof (struct tty_output)); + + FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; + FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR; + + if (initialized) + { + /* Note that term_init may signal an error, but then it is its + responsibility to make sure this frame is deleted. */ + f->output_data.tty->display_info = term_init (frame, tty_name, tty_type); + } + else + { + /* init_display() will reinitialize the terminal with correct values after dump. */ + f->output_data.tty->display_info = term_dummy_init (); + } + FRAME_TTY (f)->reference_count++; + f->display_method = FRAME_TTY (f)->display_method; +#ifdef MULTI_KBOARD + f->kboard = FRAME_TTY (f)->kboard; +#endif + } + #ifdef CANNOT_DUMP FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR; FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR; @@ -559,11 +589,19 @@ DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame, 1, 1, 0, - doc: /* Create an additional terminal frame. -You can create multiple frames on a text-only terminal in this way. -Only the selected terminal frame is actually displayed. + doc: /* Create an additional terminal frame, possibly on another terminal. This function takes one argument, an alist specifying frame parameters. -In practice, generally you don't need to specify any parameters. + +You can create multiple frames on a single text-only terminal, but +only one of them (the selected terminal frame) is actually displayed. + +In practice, generally you don't need to specify any parameters, +except when you want to create a new frame on another terminal. +In that case, the `tty' parameter specifies the device file to open, +and the `tty-type' parameter specifies the terminal type. Example: + + (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm"))) + Note that changing the size of one terminal frame automatically affects all. */) (parms) Lisp_Object parms; @@ -582,15 +620,61 @@ if (sf->output_method != output_mac) error ("Not running on a Macintosh screen; cannot make a new Macintosh frame"); #else +#if 0 /* This should work now! */ if (sf->output_method != output_termcap) error ("Not using an ASCII terminal now; cannot make a new ASCII frame"); #endif +#endif #endif /* not MSDOS */ - f = make_terminal_frame (); - - change_frame_size (f, FRAME_LINES (sf), - FRAME_COLS (sf), 0, 0, 0); + { + Lisp_Object tty, tty_type; + char *name = 0, *type = 0; + + /* XXX Ugh, there must be a better way to do this. */ + tty = Fassq (Qtty, parms); + if (EQ (tty, Qnil)) + tty = Fassq (Qtty, XFRAME (selected_frame)->param_alist); + if (EQ (tty, Qnil)) + tty = Fassq (Qtty, Vdefault_frame_alist); + if (! EQ (tty, Qnil)) + tty = XCDR (tty); + if (EQ (tty, Qnil) || !STRINGP (tty)) + tty = Qnil; + + tty_type = Fassq (Qtty_type, parms); + if (EQ (tty_type, Qnil)) + tty_type = Fassq (Qtty_type, Vdefault_frame_alist); + if (EQ (tty_type, Qnil)) + tty_type = Fassq (Qtty, XFRAME (selected_frame)->param_alist); + if (! EQ (tty_type, Qnil)) + tty_type = XCDR (tty_type); + if (EQ (tty_type, Qnil) || !STRINGP (tty_type)) + tty_type = Qnil; + + if (! EQ (tty, Qnil)) + { + name = (char *) alloca (SBYTES (tty) + 1); + strncpy (name, SDATA (tty), SBYTES (tty)); + name[SBYTES (tty)] = 0; + } + + if (! EQ (tty_type, Qnil)) + { + type = (char *) alloca (SBYTES (tty_type) + 1); + strncpy (type, SDATA (tty_type), SBYTES (tty_type)); + type[SBYTES (tty_type)] = 0; + } + + f = make_terminal_frame (name, type); + } + + { + int width, height; + get_tty_size (fileno (TTY_INPUT (FRAME_TTY (f))), &width, &height); + change_frame_size (f, height, width, 0, 0, 0); + } + adjust_glyphs (f); calculate_costs (f); XSETFRAME (frame, f); @@ -694,6 +778,15 @@ if (!for_deletion && FRAME_HAS_MINIBUF_P (sf)) resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1); + if (FRAME_TERMCAP_P (XFRAME (selected_frame)) + && FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (selected_frame)) == FRAME_TTY (XFRAME (frame))) + { + XFRAME (selected_frame)->async_visible = 2; /* obscured */ + XFRAME (frame)->async_visible = 1; + FRAME_TTY (XFRAME (frame))->top_frame = frame; + } + selected_frame = frame; if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame))) last_nonminibuf_frame = XFRAME (selected_frame); @@ -927,7 +1020,10 @@ f = XCAR (tail); if (passed - && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame))))) { /* Decide whether this frame is eligible to be returned. */ @@ -1004,7 +1100,10 @@ if (EQ (frame, f) && !NILP (prev)) return prev; - if (FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + if ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame)))) { /* Decide whether this frame is eligible to be returned, according to minibuf. */ @@ -1231,7 +1330,7 @@ { FOR_EACH_FRAME (tail, frame1) { - if (! EQ (frame, frame1)) + if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1))) break; } } @@ -1304,7 +1403,24 @@ x_destroy_window (f); #endif - f->output_data.nothing = 0; + if (FRAME_TERMCAP_P (f)) + { + int delete = 1; + struct tty_display_info *tty = FRAME_TTY (f); + + if (! --tty->reference_count) + { + /* delete_tty would call us recursively if we don't kill the + frame now. */ + xfree (f->output_data.tty); + f->output_data.nothing = 0; + delete_tty (tty); + } + } + else + { + f->output_data.nothing = 0; + } /* If we've deleted the last_nonminibuf_frame, then try to find another one. */ @@ -1801,7 +1917,7 @@ XFRAME (frame)->focus_frame = focus_frame; - if (frame_rehighlight_hook) + if (!FRAME_TERMCAP_P (XFRAME (frame)) && frame_rehighlight_hook) (*frame_rehighlight_hook) (XFRAME (frame)); return Qnil; @@ -2691,8 +2807,8 @@ if (NATNUMP (param_index) && (XFASTINT (param_index) < sizeof (frame_parms)/sizeof (frame_parms[0])) - && rif->frame_parm_handlers[XINT (param_index)]) - (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); + && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)]) + (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); } } } @@ -2735,8 +2851,8 @@ if (NATNUMP (param_index) && (XFASTINT (param_index) < sizeof (frame_parms)/sizeof (frame_parms[0])) - && rif->frame_parm_handlers[XINT (param_index)]) - (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); + && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)]) + (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); } } @@ -3937,6 +4053,10 @@ staticpro (&Qbackground_mode); Qtty_color_mode = intern ("tty-color-mode"); staticpro (&Qtty_color_mode); + Qtty = intern ("tty"); + staticpro (&Qtty); + Qtty_type = intern ("tty-type"); + staticpro (&Qtty_type); Qface_set_after_frame_default = intern ("face-set-after-frame-default"); staticpro (&Qface_set_after_frame_default); @@ -4026,7 +4146,7 @@ staticpro (&Qinhibit_default_face_x_resources); DEFVAR_LISP ("terminal-frame", &Vterminal_frame, - doc: /* The initial frame-object, which represents Emacs's stdout. */); + doc: /* The initial frame-object, which represents Emacs's stdout. */); DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified, doc: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
--- a/src/frame.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/frame.h Fri Jan 02 04:37:46 2004 +0000 @@ -28,9 +28,7 @@ /* Miscellanea. */ -/* Nonzero means don't assume anything about current contents of - actual terminal frame */ - +/* Nonzero means there is at least one garbaged frame. */ extern int frame_garbaged; /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by @@ -67,30 +65,10 @@ HBAR_CURSOR }; -#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(MAC_OS) - -#if !defined(HAVE_X_WINDOWS) - -#define PIX_TYPE int +#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel) +#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel) -/* A (mostly empty) x_output structure definition for building Emacs - on Unix and GNU/Linux without X support. */ -struct x_output -{ - PIX_TYPE background_pixel; - PIX_TYPE foreground_pixel; -}; - -#endif /* ! HAVE_X_WINDOWS */ - - -#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel) -#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel) - -/* A structure describing a termcap frame display. */ -extern struct x_output tty_display; - -#endif /* ! MSDOS && ! WINDOWSNT && ! MAC_OS */ +struct device; struct frame { @@ -278,17 +256,23 @@ /* Canonical Y unit. Height of a line, in pixels. */ int line_height; + /* The display hooks to use with this frame. */ + struct display_method *display_method; + /* The output method says how the contents of this frame are displayed. It could be using termcap, or using an X window. */ enum output_method output_method; /* A structure of auxiliary data used for displaying the contents. + struct tty_output is used for termcap frames; + it is defined in term.h. struct x_output is used for X window frames; it is defined in xterm.h. struct w32_output is used for W32 window frames; it is defined in w32term.h. */ union output_data { + struct tty_output *tty; struct x_output *x; struct w32_output *w32; struct mac_output *mac; @@ -308,8 +292,10 @@ #ifdef MULTI_KBOARD /* A pointer to the kboard structure associated with this frame. - For termcap frames, this points to initial_kboard. For X frames, - it will be the same as display.x->display_info->kboard. */ + For termcap frames, it will be the same as + output_data.tty->display_info->kboard. + For X frames, it will be the same as + output_data.x->display_info->kboard. */ struct kboard *kboard; #endif @@ -336,13 +322,13 @@ frame becomes visible again, it must be marked as garbaged. The FRAME_SAMPLE_VISIBILITY macro takes care of this. - On Windows NT/9X, to avoid wasting effort updating visible frames - that are actually completely obscured by other windows on the - display, we bend the meaning of visible slightly: if greater than - 1, then the frame is obscured - we still consider it to be - "visible" as seen from lisp, but we don't bother updating it. We - must take care to garbage the frame when it ceaces to be obscured - though. Note that these semantics are only used on NT/9X. + On ttys and on Windows NT/9X, to avoid wasting effort updating + visible frames that are actually completely obscured by other + windows on the display, we bend the meaning of visible slightly: + if greater than 1, then the frame is obscured - we still consider + it to be "visible" as seen from lisp, but we don't bother + updating it. We must take care to garbage the frame when it + ceaces to be obscured though. iconified is nonzero if the frame is currently iconified. @@ -452,6 +438,10 @@ Clear the frame in clear_garbaged_frames if set. */ unsigned resized_p : 1; + /* All display backends seem to need these two pixel values. */ + unsigned long background_pixel; + unsigned long foreground_pixel; + /* Set to non-zero if the default face for the frame has been realized. Reset to zero whenever the default face changes. Used to see the difference between a font change and face change. */ @@ -736,7 +726,10 @@ Also, if a frame used to be invisible, but has just become visible, it must be marked as garbaged, since redisplay hasn't been keeping - up its contents. */ + up its contents. + + Note that a tty frame is visible if and only if it is the topmost + frame. */ #define FRAME_SAMPLE_VISIBILITY(f) \ (((f)->async_visible && (f)->visible != (f)->async_visible) ? \ @@ -779,7 +772,7 @@ extern struct frame *last_nonminibuf_frame; -extern struct frame *make_terminal_frame P_ ((void)); +extern struct frame *make_terminal_frame P_ ((char *tty, char *tty_type)); extern struct frame *make_frame P_ ((int)); #ifdef HAVE_WINDOW_SYSTEM extern struct frame *make_minibuffer_frame P_ ((void));
--- a/src/indent.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/indent.c Fri Jan 02 04:37:46 2004 +0000 @@ -28,6 +28,7 @@ #include "keyboard.h" #include "frame.h" #include "window.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "termopts.h" #include "disptab.h"
--- a/src/keyboard.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/keyboard.c Fri Jan 02 04:37:46 2004 +0000 @@ -22,9 +22,10 @@ #include <config.h> #include <signal.h> #include <stdio.h> +#include "lisp.h" +#include "systty.h" /* This must be included befor termchar.h. */ #include "termchar.h" #include "termopts.h" -#include "lisp.h" #include "termhooks.h" #include "macros.h" #include "keyboard.h" @@ -55,7 +56,6 @@ #endif /* not MSDOS */ #include "syssignal.h" -#include "systty.h" #include <sys/types.h> #ifdef HAVE_UNISTD_H @@ -89,9 +89,6 @@ int interrupt_input_pending; -/* File descriptor to use for input. */ -extern int input_fd; - #ifdef HAVE_WINDOW_SYSTEM /* Make all keyboard buffers much bigger when using X windows. */ #ifdef MAC_OS8 @@ -464,11 +461,6 @@ /* Nonzero if input is available. */ int input_pending; -/* 1 if should obey 0200 bit in input chars as "Meta", 2 if should - keep 0200 bit in input chars. 0 to ignore the 0200 bit. */ - -int meta_key; - /* Non-zero means force key bindings update in parse_menu_item. */ int update_menu_bindings; @@ -625,9 +617,6 @@ /* Nonzero while interrupts are temporarily deferred during redisplay. */ int interrupts_deferred; -/* Nonzero means use ^S/^Q for flow control. */ -int flow_control; - /* Allow m- file to inhibit use of FIONREAD. */ #ifdef BROKEN_FIONREAD #undef FIONREAD @@ -1216,7 +1205,8 @@ running under a window system. */ || (!NILP (Vwindow_system) && !inhibit_window_system - && FRAME_TERMCAP_P (sf)) + && FRAME_TERMCAP_P (sf) + && !FRAME_TTY (sf)->type) /* XXX This is ugly. */ || noninteractive) { stream = Qexternal_debugging_output; @@ -6487,7 +6477,7 @@ /* If input is being read as it arrives, and we have none, there is none. */ if (*addr > 0 || (interrupt_input && ! interrupts_deferred)) return; - + /* Try to read some input and see how much we get. */ gobble_input (0); *addr = (!NILP (Vquit_flag) @@ -6605,23 +6595,25 @@ { struct input_event buf[KBD_BUFFER_SIZE]; register int i; - int nread; - + int nread = 0; + for (i = 0; i < KBD_BUFFER_SIZE; i++) EVENT_INIT (buf[i]); if (read_socket_hook) /* No need for FIONREAD or fcntl; just say don't wait. */ - nread = (*read_socket_hook) (input_fd, buf, KBD_BUFFER_SIZE, expected); - else + nread = (*read_socket_hook) (buf, KBD_BUFFER_SIZE, expected); + + if (!nread && tty_list) { /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than the kbd_buffer can really hold. That may prevent loss of characters on some systems when input is stuffed at us. */ unsigned char cbuf[KBD_BUFFER_SIZE - 1]; int n_to_read; - - /* Determine how many characters we should *try* to read. */ + struct tty_display_info *tty; + Lisp_Object frame; + #ifdef WINDOWSNT return 0; #else /* not WINDOWSNT */ @@ -6629,99 +6621,143 @@ n_to_read = dos_keysns (); if (n_to_read == 0) return 0; + + cbuf[0] = dos_keyread (); + nread = 1; + #else /* not MSDOS */ + + nread = 0; + + /* Try to read from each available tty, until one succeeds. */ + for (tty = tty_list; tty; tty = tty->next) { + + if (! tty->term_initted) + continue; + + /* Determine how many characters we should *try* to read. */ #ifdef FIONREAD - /* Find out how much input is available. */ - if (ioctl (input_fd, FIONREAD, &n_to_read) < 0) - /* Formerly simply reported no input, but that sometimes led to - a failure of Emacs to terminate. - SIGHUP seems appropriate if we can't reach the terminal. */ - /* ??? Is it really right to send the signal just to this process - rather than to the whole process group? - Perhaps on systems with FIONREAD Emacs is alone in its group. */ - { - if (! noninteractive) - kill (getpid (), SIGHUP); - else - n_to_read = 0; - } - if (n_to_read == 0) - return 0; - if (n_to_read > sizeof cbuf) - n_to_read = sizeof cbuf; + /* Find out how much input is available. */ + if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0) + { + /* Formerly simply reported no input, but that sometimes led to + a failure of Emacs to terminate. + SIGHUP seems appropriate if we can't reach the terminal. */ + /* ??? Is it really right to send the signal just to this process + rather than to the whole process group? + Perhaps on systems with FIONREAD Emacs is alone in its group. */ + /* It appears to be the case, see narrow_foreground_group. */ + if (! noninteractive) + { + if (! tty_list->next) + kill (getpid (), SIGHUP); /* This was the last terminal. */ + else + n_to_read = 0; /* XXX tty should be closed here. */ + } + else + { + n_to_read = 0; + } + } + if (n_to_read == 0) + continue; + if (n_to_read > sizeof cbuf) + n_to_read = sizeof cbuf; #else /* no FIONREAD */ #if defined (USG) || defined (DGUX) || defined(CYGWIN) - /* Read some input if available, but don't wait. */ - n_to_read = sizeof cbuf; - fcntl (input_fd, F_SETFL, O_NDELAY); + /* Read some input if available, but don't wait. */ + n_to_read = sizeof cbuf; + fcntl (fileno (TTY_INPUT (tty)), F_SETFL, O_NDELAY); #else - you lose; -#endif -#endif + you lose; +#endif +#endif + + /* Now read; for one reason or another, this will not block. + NREAD is set to the number of chars read. */ + do + { + nread = emacs_read (fileno (TTY_INPUT (tty)), cbuf, n_to_read); + /* POSIX infers that processes which are not in the session leader's + process group won't get SIGHUP's at logout time. BSDI adheres to + this part standard and returns -1 from read (0) with errno==EIO + when the control tty is taken away. + Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ + if (nread == -1 && errno == EIO) + { + if (! tty_list->next) + kill (0, SIGHUP); /* This was the last terminal. */ + else + delete_tty (tty); /* XXX I wonder if this is safe here. */ + } +#if defined (AIX) && (! defined (aix386) && defined (_BSD)) + /* The kernel sometimes fails to deliver SIGHUP for ptys. + This looks incorrect, but it isn't, because _BSD causes + O_NDELAY to be defined in fcntl.h as O_NONBLOCK, + and that causes a value other than 0 when there is no input. */ + if (nread == 0) + { + if (! tty_list->next) + kill (0, SIGHUP); /* This was the last terminal. */ + else + delete_tty (tty); /* XXX I wonder if this is safe here. */ + } +#endif + } + while ( + /* We used to retry the read if it was interrupted. + But this does the wrong thing when O_NDELAY causes + an EAGAIN error. Does anybody know of a situation + where a retry is actually needed? */ +#if 0 + nread < 0 && (errno == EAGAIN +#ifdef EFAULT + || errno == EFAULT +#endif +#ifdef EBADSLT + || errno == EBADSLT +#endif + ) +#else + 0 +#endif + ); + +#ifndef FIONREAD +#if defined (USG) || defined (DGUX) || defined (CYGWIN) + fcntl (fileno (TTY_INPUT (tty)), F_SETFL, 0); +#endif /* USG or DGUX or CYGWIN */ +#endif /* no FIONREAD */ + + if (nread > 0) + break; + } /* for each tty */ + + if (nread <= 0) + return 0; + #endif /* not MSDOS */ #endif /* not WINDOWSNT */ - /* Now read; for one reason or another, this will not block. - NREAD is set to the number of chars read. */ - do - { -#ifdef MSDOS - cbuf[0] = dos_keyread (); - nread = 1; -#else - nread = emacs_read (input_fd, cbuf, n_to_read); -#endif - /* POSIX infers that processes which are not in the session leader's - process group won't get SIGHUP's at logout time. BSDI adheres to - this part standard and returns -1 from read (0) with errno==EIO - when the control tty is taken away. - Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ - if (nread == -1 && errno == EIO) - kill (0, SIGHUP); -#if defined (AIX) && (! defined (aix386) && defined (_BSD)) - /* The kernel sometimes fails to deliver SIGHUP for ptys. - This looks incorrect, but it isn't, because _BSD causes - O_NDELAY to be defined in fcntl.h as O_NONBLOCK, - and that causes a value other than 0 when there is no input. */ - if (nread == 0) - kill (0, SIGHUP); -#endif - } - while ( - /* We used to retry the read if it was interrupted. - But this does the wrong thing when O_NDELAY causes - an EAGAIN error. Does anybody know of a situation - where a retry is actually needed? */ -#if 0 - nread < 0 && (errno == EAGAIN -#ifdef EFAULT - || errno == EFAULT -#endif -#ifdef EBADSLT - || errno == EBADSLT -#endif - ) -#else - 0 -#endif - ); - -#ifndef FIONREAD -#if defined (USG) || defined (DGUX) || defined (CYGWIN) - fcntl (input_fd, F_SETFL, 0); -#endif /* USG or DGUX or CYGWIN */ -#endif /* no FIONREAD */ + if (!tty) + abort (); + + /* Select frame corresponding to the active tty. Note that the + value of selected_frame is not reliable here, redisplay tends + to temporarily change it. But tty should always be non-NULL. */ + frame = tty->top_frame; + for (i = 0; i < nread; i++) { buf[i].kind = ASCII_KEYSTROKE_EVENT; buf[i].modifiers = 0; - if (meta_key == 1 && (cbuf[i] & 0x80)) + if (tty->meta_key == 1 && (cbuf[i] & 0x80)) buf[i].modifiers = meta_modifier; - if (meta_key != 2) + if (tty->meta_key != 2) cbuf[i] &= ~0x80; - buf[i].code = cbuf[i]; - buf[i].frame_or_window = selected_frame; + buf[i].code = cbuf[i]; + buf[i].frame_or_window = frame; buf[i].arg = Qnil; } } @@ -9838,8 +9874,12 @@ from an idle timer function. The symptom of the bug is that the cursor sometimes doesn't become visible until the next X event is processed. --gerd. */ - if (rif) - rif->flush_display (NULL); + { + Lisp_Object tail, frame; + FOR_EACH_FRAME (tail, frame) + if (FRAME_RIF (XFRAME (frame))) + FRAME_RIF (XFRAME (frame))->flush_display (XFRAME (frame)); + } } return input_pending; @@ -10082,6 +10122,9 @@ int width, height; struct gcpro gcpro1; + if (tty_list && tty_list->next) + error ("Suspend is not supported with multiple ttys"); + if (!NILP (stuffstring)) CHECK_STRING (stuffstring); @@ -10090,12 +10133,12 @@ call1 (Vrun_hooks, intern ("suspend-hook")); GCPRO1 (stuffstring); - get_frame_size (&old_width, &old_height); - reset_sys_modes (); + get_tty_size (fileno (TTY_INPUT (CURTTY ())), &old_width, &old_height); + reset_all_sys_modes (); /* sys_suspend can get an error if it tries to fork a subshell and the system resources aren't available for that. */ record_unwind_protect ((Lisp_Object (*) P_ ((Lisp_Object))) init_sys_modes, - Qnil); + (Lisp_Object)CURTTY()); /* XXX */ stuff_buffered_input (stuffstring); if (cannot_suspend) sys_subshell (); @@ -10106,7 +10149,7 @@ /* Check if terminal/window size has changed. Note that this is not useful when we are running directly with a window system; but suspend should be disabled in that case. */ - get_frame_size (&width, &height); + get_tty_size (fileno (TTY_INPUT (CURTTY ())), &width, &height); if (width != old_width || height != old_height) change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0); @@ -10210,13 +10253,10 @@ struct frame *sf = SELECTED_FRAME (); #if defined (USG) && !defined (POSIX_SIGNALS) - if (!read_socket_hook && NILP (Vwindow_system)) - { - /* USG systems forget handlers when they are used; - must reestablish each time */ - signal (SIGINT, interrupt_signal); - signal (SIGQUIT, interrupt_signal); - } + /* USG systems forget handlers when they are used; + must reestablish each time */ + signal (SIGINT, interrupt_signal); + signal (SIGQUIT, interrupt_signal); #endif /* USG */ cancel_echoing (); @@ -10230,7 +10270,7 @@ sigblock (sigmask (SIGINT)); fflush (stdout); - reset_sys_modes (); + reset_all_sys_modes (); #ifdef SIGTSTP /* Support possible in later USG versions */ /* @@ -10309,7 +10349,7 @@ printf ("Continuing...\n"); #endif /* not MSDOS */ fflush (stdout); - init_sys_modes (); + init_all_sys_modes (); sigfree (); } else @@ -10396,7 +10436,8 @@ #ifndef DOS_NT /* this causes startup screen to be restored and messes with the mouse */ - reset_sys_modes (); + if (FRAME_TERMCAP_P (SELECTED_FRAME ())) + reset_sys_modes (CURTTY ()); #endif #ifdef SIGIO @@ -10422,19 +10463,25 @@ interrupt_input = 1; #endif - flow_control = !NILP (flow); - if (NILP (meta)) - meta_key = 0; - else if (EQ (meta, Qt)) - meta_key = 1; - else - meta_key = 2; + if (FRAME_TERMCAP_P (XFRAME (selected_frame))) + { + struct tty_display_info *tty = CURTTY (); + tty->flow_control = !NILP (flow); + if (NILP (meta)) + tty->meta_key = 0; + else if (EQ (meta, Qt)) + tty->meta_key = 1; + else + tty->meta_key = 2; + } + if (!NILP (quit)) /* Don't let this value be out of range. */ - quit_char = XINT (quit) & (meta_key ? 0377 : 0177); + quit_char = XINT (quit) & (CURTTY ()->meta_key ? 0377 : 0177); #ifndef DOS_NT - init_sys_modes (); + if (FRAME_TERMCAP_P (XFRAME (selected_frame))) + init_sys_modes (CURTTY ()); #endif #ifdef POLL_FOR_INPUT @@ -10461,10 +10508,21 @@ () { Lisp_Object val[4]; - + struct frame *sf = XFRAME (selected_frame); + val[0] = interrupt_input ? Qt : Qnil; - val[1] = flow_control ? Qt : Qnil; - val[2] = meta_key == 2 ? make_number (0) : meta_key == 1 ? Qt : Qnil; + if (FRAME_TERMCAP_P (sf)) + { + val[1] = FRAME_TTY (sf)->flow_control ? Qt : Qnil; + val[2] = FRAME_TTY (sf)->meta_key == 2 + ? make_number (0) + : CURTTY ()->meta_key == 1 ? Qt : Qnil; + } + else + { + val[1] = Qnil; + val[2] = Qt; + } XSETFASTINT (val[3], quit_char); return Flist (sizeof (val) / sizeof (val[0]), val); @@ -10573,7 +10631,7 @@ wipe_kboard (current_kboard); init_kboard (current_kboard); - if (!noninteractive && !read_socket_hook && NILP (Vwindow_system)) + if (!noninteractive) { signal (SIGINT, interrupt_signal); #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
--- a/src/keyboard.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/keyboard.h Fri Jan 02 04:37:46 2004 +0000 @@ -21,7 +21,7 @@ /* Length of echobuf field in each KBOARD. */ /* Each KBOARD represents one logical input stream from which Emacs gets input. - If we are using an ordinary terminal, it has one KBOARD object. + If we are using ordinary terminals, it has one KBOARD object for each terminal device. Usually each X display screen has its own KBOARD, but when two of them are on the same X server, we assume they share a keyboard and give them one KBOARD in common. @@ -152,7 +152,7 @@ }; #ifdef MULTI_KBOARD -/* Temporarily used before a frame has been opened, and for termcap frames */ +/* Temporarily used before a frame has been opened. */ extern KBOARD *initial_kboard; /* In the single-kboard state, this is the kboard
--- a/src/lisp.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/lisp.h Fri Jan 02 04:37:46 2004 +0000 @@ -2936,26 +2936,28 @@ EXFUN (Fx_popup_dialog, 2); extern void syms_of_xmenu P_ ((void)); +/* defined in termchar.h */ +struct tty_display_info; + +/* defined in termhooks.h */ +struct display; + /* defined in sysdep.c */ extern void stuff_char P_ ((char c)); extern void init_sigio P_ ((int)); -extern void request_sigio P_ ((void)); -extern void unrequest_sigio P_ ((void)); -extern void reset_sys_modes P_ ((void)); extern void sys_subshell P_ ((void)); extern void sys_suspend P_ ((void)); extern void discard_tty_input P_ ((void)); -extern void init_sys_modes P_ ((void)); -extern void reset_sys_modes P_ ((void)); -extern void get_frame_size P_ ((int *, int *)); +extern void init_sys_modes P_ ((struct tty_display_info *)); +extern void reset_sys_modes P_ ((struct tty_display_info *)); +extern void init_all_sys_modes P_ ((void)); +extern void reset_all_sys_modes P_ ((void)); extern void wait_for_termination P_ ((int)); extern void flush_pending_output P_ ((int)); extern void child_setup_tty P_ ((int)); extern void setup_pty P_ ((int)); extern int set_window_size P_ ((int, int, int)); extern void create_process P_ ((Lisp_Object, char **, Lisp_Object)); -extern int tabs_safe_p P_ ((void)); -extern void init_baud_rate P_ ((void)); extern int emacs_open P_ ((const char *, int, int)); extern int emacs_close P_ ((int)); extern int emacs_read P_ ((int, char *, unsigned int));
--- a/src/macterm.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/macterm.c Fri Jan 02 04:37:46 2004 +0000 @@ -7596,7 +7596,7 @@ /* Emacs calls this whenever it wants to read an input event from the user. */ int -XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) +XTread_socket (struct input_event *bufp, int numchars, int expected) { int count = 0; #if USE_CARBON_EVENTS @@ -8672,12 +8672,13 @@ redeem_scroll_bar_hook = XTredeem_scroll_bar; judge_scroll_bars_hook = XTjudge_scroll_bars; - scroll_region_ok = 1; /* we'll scroll partial frames */ - char_ins_del_ok = 1; - line_ins_del_ok = 1; /* we'll just blt 'em */ - fast_clear_end_of_line = 1; /* X does this well */ - memory_below_frame = 0; /* we don't remember what scrolls - off the bottom */ + TTY_SCROLL_REGION_OK (CURTTY ()) = 1; /* we'll scroll partial frames */ + TTY_CHAR_INS_DEL_OK (CURTTY ()) = 1; + TTY_LINE_INS_DEL_OK (CURTTY ()) = 1; /* we'll just blt 'em */ + TTY_FAST_CLEAR_END_OF_LINE (CURTTY ()) = 1; /* X does this well */ + TTY_MEMORY_BELOW_FRAME (CURTTY ()) = 0; /* we don't remember what + scrolls off the + bottom */ baud_rate = 19200; x_noop_count = 0;
--- a/src/macterm.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/macterm.h Fri Jan 02 04:37:46 2004 +0000 @@ -406,9 +406,6 @@ #define FRAME_MAC_WINDOW(f) ((f)->output_data.mac->mWP) #define FRAME_X_WINDOW(f) ((f)->output_data.mac->mWP) -#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel) -#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel) - #define FRAME_FONT(f) ((f)->output_data.mac->font) #define FRAME_FONTSET(f) ((f)->output_data.mac->fontset)
--- a/src/minibuf.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/minibuf.c Fri Jan 02 04:37:46 2004 +0000 @@ -34,6 +34,7 @@ #include "syntax.h" #include "intervals.h" #include "keymap.h" +#include "termhooks.h" extern int quit_char; @@ -692,8 +693,12 @@ XWINDOW (minibuf_window)->cursor.x = 0; XWINDOW (minibuf_window)->must_be_updated_p = 1; update_frame (XFRAME (selected_frame), 1, 1); - if (rif && rif->flush_display) - rif->flush_display (XFRAME (XWINDOW (minibuf_window)->frame)); + { + struct frame *f = XFRAME (XWINDOW (minibuf_window)->frame); + struct redisplay_interface *rif = FRAME_RIF (f); + if (rif && rif->flush_display) + rif->flush_display (f); + } } /* Make minibuffer contents into a string. */
--- a/src/msdos.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/msdos.c Fri Jan 02 04:37:46 2004 +0000 @@ -2580,7 +2580,7 @@ set_terminal_modes_hook = IT_set_terminal_modes; reset_terminal_modes_hook = IT_reset_terminal_modes; set_terminal_window_hook = IT_set_terminal_window; - char_ins_del_ok = 0; + TTY_CHAR_INS_DEL_OK (CURTTY ()) = 0; #endif } @@ -4858,7 +4858,7 @@ char *badfunc; { fprintf (stderr, "%s not yet implemented\r\n", badfunc); - reset_sys_modes (); + reset_all_sys_modes (); exit (1); }
--- a/src/print.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/print.c Fri Jan 02 04:37:46 2004 +0000 @@ -30,6 +30,7 @@ #include "window.h" #include "process.h" #include "dispextern.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "intervals.h"
--- a/src/process.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/process.c Fri Jan 02 04:37:46 2004 +0000 @@ -302,11 +302,11 @@ static SELECT_TYPE input_wait_mask; -/* Mask that excludes keyboard input descriptor (s). */ +/* Mask that excludes keyboard input descriptor(s). */ static SELECT_TYPE non_keyboard_wait_mask; -/* Mask that excludes process input descriptor (s). */ +/* Mask that excludes process input descriptor(s). */ static SELECT_TYPE non_process_wait_mask; @@ -6540,20 +6540,10 @@ -/* The first time this is called, assume keyboard input comes from DESC - instead of from where we used to expect it. - Subsequent calls mean assume input keyboard can come from DESC - in addition to other places. */ - -static int add_keyboard_wait_descriptor_called_flag; - void add_keyboard_wait_descriptor (desc) int desc; { - if (! add_keyboard_wait_descriptor_called_flag) - FD_CLR (0, &input_wait_mask); - add_keyboard_wait_descriptor_called_flag = 1; FD_SET (desc, &input_wait_mask); FD_SET (desc, &non_process_wait_mask); if (desc > max_keyboard_desc)
--- a/src/scroll.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/scroll.c Fri Jan 02 04:37:46 2004 +0000 @@ -22,12 +22,14 @@ #include <config.h> #include <stdio.h> #include <string.h> +#include "lisp.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" -#include "lisp.h" #include "dispextern.h" #include "keyboard.h" #include "frame.h" #include "window.h" +#include "termhooks.h" /* All costs measured in characters. So no cost can exceed the area of a frame, measured in characters. @@ -100,7 +102,8 @@ register struct matrix_elt *p, *p1; register int cost, cost1; - int lines_moved = window_size + (scroll_region_ok ? 0 : lines_below); + int lines_moved = window_size + + (FRAME_SCROLL_REGION_OK (frame) ? 0 : lines_below); /* first_insert_cost[I] is the cost of doing the first insert-line at the i'th line of the lines we are considering, where I is origin 1 (as it is below). */ @@ -466,7 +469,8 @@ /* Overhead of setting the scroll window, plus the extra cost cost of scrolling by a distance of one. The extra cost is added once for consistency with the cost vectors */ - scroll_overhead = scroll_region_cost + extra_cost; + scroll_overhead + = FRAME_SCROLL_REGION_COST (frame) + extra_cost; /* initialize the top left corner of the matrix */ matrix->writecost = 0; @@ -818,7 +822,7 @@ matrix = ((struct matrix_elt *) alloca ((window_size + 1) * (window_size + 1) * sizeof *matrix)); - if (scroll_region_ok) + if (FRAME_SCROLL_REGION_OK (frame)) { calculate_direct_scrolling (frame, matrix, window_size, unchanged_at_bottom, @@ -914,7 +918,7 @@ if (amount == 0) return 0; - if (! scroll_region_ok) + if (! FRAME_SCROLL_REGION_OK (frame)) limit = height; else if (amount > 0) limit += amount;
--- a/src/sysdep.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/sysdep.c Fri Jan 02 04:37:46 2004 +0000 @@ -45,6 +45,8 @@ #endif #endif +#include "sysselect.h" + #include "blockinput.h" #undef NULL @@ -184,6 +186,7 @@ #include "termopts.h" #include "dispextern.h" #include "process.h" +#include "cm.h" /* for reset_sys_modes */ #ifdef WINDOWSNT #include <direct.h> @@ -246,16 +249,11 @@ int emacs_ospeed; -/* The file descriptor for Emacs's input terminal. - Under Unix, this is normally zero except when using X; - under VMS, we place the input channel number here. */ -int input_fd; - void croak P_ ((char *)); #ifdef AIXHFT -void hft_init (); -void hft_reset (); +void hft_init P_ ((struct tty_display_info *)); +void hft_reset P_ ((struct tty_display_info *)); #endif /* Temporary used by `sigblock' when defined in terms of signprocmask. */ @@ -263,16 +261,7 @@ SIGMASKTYPE sigprocmask_set; -/* Specify a different file descriptor for further input operations. */ - -void -change_input_fd (fd) - int fd; -{ - input_fd = fd; -} - -/* Discard pending input on descriptor input_fd. */ +/* Discard pending input on all input descriptors. */ void discard_tty_input () @@ -290,47 +279,55 @@ #ifdef VMS end_kbd_input (); - SYS$QIOW (0, input_fd, IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, + SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, &buf.main, 0, 0, terminator_mask, 0, 0); queue_kbd_input (); #else /* not VMS */ #ifdef APOLLO { - int zero = 0; - ioctl (input_fd, TIOCFLUSH, &zero); + struct tty_display_info *tty; + for (tty = tty_list; tty; tty = tty->next) + { + int zero = 0; + ioctl (fileno (TTY_INPUT (tty)), TIOCFLUSH, &zero); + } } #else /* not Apollo */ #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ while (dos_keyread () != -1) ; #else /* not MSDOS */ - EMACS_GET_TTY (input_fd, &buf); - EMACS_SET_TTY (input_fd, &buf, 0); + { + struct tty_display_info *tty; + for (tty = tty_list; tty; tty = tty->next) + { + EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &buf); + EMACS_SET_TTY (fileno (TTY_INPUT (tty)), &buf, 0); + } + } #endif /* not MSDOS */ #endif /* not Apollo */ #endif /* not VMS */ #endif /* not WINDOWSNT */ } + #ifdef SIGTSTP /* Arrange for character C to be read as the next input from - the terminal. */ + the terminal. + XXX What if we have multiple ttys? +*/ void -#ifdef PROTOTYPES stuff_char (char c) -#else -stuff_char (c) - char c; -#endif { if (read_socket_hook) return; /* Should perhaps error if in batch mode */ #ifdef TIOCSTI - ioctl (input_fd, TIOCSTI, &c); + ioctl (fileno (TTY_INPUT (CURTTY())), TIOCSTI, &c); #else /* no TIOCSTI */ error ("Cannot stuff terminal input characters in this version of Unix"); #endif /* no TIOCSTI */ @@ -339,7 +336,7 @@ #endif /* SIGTSTP */ void -init_baud_rate () +init_baud_rate (int fd) { if (noninteractive) emacs_ospeed = 0; @@ -354,7 +351,7 @@ #ifdef VMS struct sensemode sg; - SYS$QIOW (0, input_fd, IO$_SENSEMODE, &sg, 0, 0, + SYS$QIOW (0, fd, IO$_SENSEMODE, &sg, 0, 0, &sg.class, 12, 0, 0, 0, 0 ); emacs_ospeed = sg.xmit_baud; #else /* not VMS */ @@ -362,7 +359,7 @@ struct termios sg; sg.c_cflag = B9600; - tcgetattr (input_fd, &sg); + tcgetattr (fd, &sg); emacs_ospeed = cfgetospeed (&sg); #if defined (USE_GETOBAUD) && defined (getobaud) /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ @@ -375,16 +372,16 @@ sg.c_cflag = B9600; #ifdef HAVE_TCATTR - tcgetattr (input_fd, &sg); + tcgetattr (fd, &sg); #else - ioctl (input_fd, TCGETA, &sg); + ioctl (fd, TCGETA, &sg); #endif emacs_ospeed = sg.c_cflag & CBAUD; #else /* neither VMS nor TERMIOS nor TERMIO */ struct sgttyb sg; sg.sg_ospeed = B9600; - if (ioctl (input_fd, TIOCGETP, &sg) < 0) + if (ioctl (fd, TIOCGETP, &sg) < 0) abort (); emacs_ospeed = sg.sg_ospeed; #endif /* not HAVE_TERMIO */ @@ -400,6 +397,7 @@ baud_rate = 1200; } + /*ARGSUSED*/ void set_exclusive_use (fd) @@ -658,7 +656,7 @@ #ifdef BSD4_1 if (interrupt_input) - reset_sigio (); + reset_sigio (0); #endif /* BSD4_1 */ #ifdef RTU { @@ -917,23 +915,24 @@ #ifdef F_SETFL -int old_fcntl_flags; +int old_fcntl_flags[MAXDESC]; void init_sigio (fd) int fd; { #ifdef FASYNC - old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC; - fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC); + old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; + fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); #endif interrupts_deferred = 0; } void -reset_sigio () +reset_sigio (fd) + int fd; { - unrequest_sigio (); + fcntl (fd, F_SETFL, old_fcntl_flags[fd]); } #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ @@ -947,13 +946,13 @@ #ifdef SIGWINCH sigunblock (sigmask (SIGWINCH)); #endif - fcntl (input_fd, F_SETFL, old_fcntl_flags | FASYNC); + sigunblock (sigmask (SIGIO)); interrupts_deferred = 0; } void -unrequest_sigio () +unrequest_sigio (void) { if (read_socket_hook) return; @@ -961,7 +960,7 @@ #ifdef SIGWINCH sigblock (sigmask (SIGWINCH)); #endif - fcntl (input_fd, F_SETFL, old_fcntl_flags); + sigblock (sigmask (SIGIO)); interrupts_deferred = 1; } @@ -976,7 +975,8 @@ if (read_socket_hook) return; - ioctl (input_fd, FIOASYNC, &on); + /* XXX CURTTY() is bogus here. */ + ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &on); interrupts_deferred = 0; } @@ -988,7 +988,8 @@ if (read_socket_hook) return; - ioctl (input_fd, FIOASYNC, &off); + /* XXX CURTTY() is bogus here. */ + ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &off); interrupts_deferred = 1; } @@ -1009,7 +1010,7 @@ sigemptyset (&st); sigaddset (&st, SIGIO); - ioctl (input_fd, FIOASYNC, &on); + ioctl (0, FIOASYNC, &on); /* XXX This fails for multiple ttys. */ interrupts_deferred = 0; sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0); } @@ -1022,7 +1023,7 @@ if (read_socket_hook) return; - ioctl (input_fd, FIOASYNC, &off); + ioctl (0, FIOASYNC, &off); /* XXX This fails for multiple ttys. */ interrupts_deferred = 1; } @@ -1082,23 +1083,25 @@ group, redirect the TTY to point to our own process group. We need to be in our own process group to receive SIGIO properly. */ void -narrow_foreground_group () +narrow_foreground_group (int fd) { int me = getpid (); - setpgrp (0, inherited_pgroup); + if (! inherited_pgroup) + inherited_pgroup = getpgid (0); + /* XXX This only works on the controlling tty. */ if (inherited_pgroup != me) - EMACS_SET_TTY_PGRP (input_fd, &me); - setpgrp (0, me); + EMACS_SET_TTY_PGRP (fd, &me); + setpgid (0, me); } /* Set the tty to our original foreground group. */ void -widen_foreground_group () +widen_foreground_group (int fd) { if (inherited_pgroup != getpid ()) - EMACS_SET_TTY_PGRP (input_fd, &inherited_pgroup); - setpgrp (0, inherited_pgroup); + EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); + setpgid (0, inherited_pgroup); } #endif /* BSD_PGRPS */ @@ -1255,14 +1258,6 @@ } -/* The initial tty mode bits */ -struct emacs_tty old_tty; - -/* 1 if we have been through init_sys_modes. */ -int term_initted; - -/* 1 if outer tty status has been recorded. */ -int old_tty_valid; #ifdef BSD4_1 /* BSD 4.1 needs to keep track of the lmode bits in order to start @@ -1272,7 +1267,7 @@ #ifndef F_SETOWN_BUG #ifdef F_SETOWN -int old_fcntl_owner; +int old_fcntl_owner[MAXDESC]; #endif /* F_SETOWN */ #endif /* F_SETOWN_BUG */ @@ -1298,7 +1293,16 @@ #endif void -init_sys_modes () +init_all_sys_modes (void) +{ + struct tty_display_info *tty; + for (tty = tty_list; tty; tty = tty->next) + init_sys_modes (tty); +} + +void +init_sys_modes (tty_out) + struct tty_display_info *tty_out; { struct emacs_tty tty; @@ -1354,27 +1358,28 @@ #ifndef VMS4_4 sys_access_reinit (); #endif -#endif /* not VMS */ +#endif /* VMS */ #ifdef BSD_PGRPS if (! read_socket_hook && EQ (Vwindow_system, Qnil)) - narrow_foreground_group (); + 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 (!read_socket_hook && EQ (Vwindow_system, Qnil)) + if (tty_out->input != stdin || (!read_socket_hook && EQ (Vwindow_system, Qnil))) #endif { - EMACS_GET_TTY (input_fd, &old_tty); - - old_tty_valid = 1; - - tty = old_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); + + tty = *tty_out->old_tty; #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) - XSETINT (Vtty_erase_char, old_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. */ @@ -1395,7 +1400,7 @@ tty.main.c_lflag &= ~IEXTEN; /* Disable other editing characters. */ #endif tty.main.c_lflag |= ISIG; /* Enable signals */ - if (flow_control) + if (tty_out->flow_control) { tty.main.c_iflag |= IXON; /* Enable start/stop output control */ #ifdef IXANY @@ -1408,7 +1413,7 @@ on output */ tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ #ifdef CS8 - if (meta_key) + if (tty_out->meta_key) { tty.main.c_cflag |= CS8; /* allow 8th bit on input */ tty.main.c_cflag &= ~PARENB;/* Don't check parity */ @@ -1449,7 +1454,7 @@ tty.main.c_cc[VDISCARD] = CDISABLE; #endif /* VDISCARD */ - if (flow_control) + if (tty_out->flow_control) { #ifdef VSTART tty.main.c_cc[VSTART] = '\021'; @@ -1485,7 +1490,7 @@ tty.main.c_cc[VSUSP] = 255; tty.main.c_cc[VDSUSP] = 255; #endif /* IBMR2AIX */ - if (flow_control) + if (tty_out->flow_control) { #ifdef VSTART tty.main.c_cc[VSTART] = '\021'; @@ -1506,7 +1511,7 @@ tty.main.tt_char |= TT$M_NOECHO; if (meta_key) tty.main.tt_char |= TT$M_EIGHTBIT; - if (flow_control) + if (tty_out->flow_control) tty.main.tt_char |= TT$M_TTSYNC; else tty.main.tt_char &= ~TT$M_TTSYNC; @@ -1533,13 +1538,13 @@ set this */ tty.tchars = new_tchars; tty.tchars.t_intrc = quit_char; - if (flow_control) + if (tty_out->flow_control) { tty.tchars.t_startc = '\021'; tty.tchars.t_stopc = '\023'; } - tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | old_tty.lmode; + 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. */ @@ -1557,33 +1562,33 @@ tty.ltchars = new_ltchars; #endif /* HAVE_LTCHARS */ #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ - if (!term_initted) + if (!tty_out->term_initted) internal_terminal_init (); dos_ttraw (); #endif - EMACS_SET_TTY (input_fd, &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. */ #ifdef TCXONC - if (!flow_control) ioctl (input_fd, TCXONC, 1); + if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TCXONC, 1); #endif #ifndef APOLLO #ifdef TIOCSTART - if (!flow_control) ioctl (input_fd, 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 (!flow_control) tcflow (input_fd, TCOON); + if (!tty_out->flow_control) tcflow (fileno (TTY_INPUT (tty_out)), TCOON); #endif #endif #ifdef AIXHFT - hft_init (); + hft_init (tty_out); #ifdef IBMR2AIX { /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it @@ -1598,7 +1603,7 @@ #ifdef VMS /* Appears to do nothing when in PASTHRU mode. - SYS$QIOW (0, input_fd, IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0, + 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); @@ -1611,9 +1616,10 @@ if (interrupt_input && ! read_socket_hook && EQ (Vwindow_system, Qnil)) { - old_fcntl_owner = fcntl (input_fd, F_GETOWN, 0); - fcntl (input_fd, F_SETOWN, getpid ()); - init_sigio (input_fd); + old_fcntl_owner[fileno (TTY_INPUT (tty_out))] = + fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0); + fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ()); + init_sigio (fileno (TTY_INPUT (tty_out))); } #endif /* F_GETOWN */ #endif /* F_SETOWN_BUG */ @@ -1621,7 +1627,7 @@ #ifdef BSD4_1 if (interrupt_input) - init_sigio (input_fd); + init_sigio (fileno (TTY_INPUT (tty_out))); #endif #ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */ @@ -1631,9 +1637,9 @@ /* This symbol is defined on recent USG systems. Someone says without this call USG won't really buffer the file even with a call to setbuf. */ - setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof _sobuf); + setvbuf (TTY_OUTPUT (tty_out), (char *) _sobuf, _IOFBF, sizeof _sobuf); #else - setbuf (stdout, (char *) _sobuf); + setbuf (TTY_OUTPUT (tty_out), (char *) _sobuf); #endif #ifdef HAVE_WINDOW_SYSTEM /* Emacs' window system on MSDOG uses the `internal terminal' and therefore @@ -1646,38 +1652,49 @@ #endif ) #endif - set_terminal_modes (); - - if (!term_initted - && FRAMEP (Vterminal_frame) - && FRAME_TERMCAP_P (XFRAME (Vterminal_frame))) - init_frame_faces (XFRAME (Vterminal_frame)); - - if (term_initted && no_redraw_on_reenter) + + if (!tty_out->term_initted) + { + Lisp_Object tail, frame; + FOR_EACH_FRAME (tail, frame) + { + /* XXX This needs to be revised. */ + if (FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (frame)) == tty_out) + init_frame_faces (XFRAME (frame)); + } + } + + if (tty_out->term_initted && no_redraw_on_reenter) { if (display_completed) direct_output_forward_char (0); } else { + Lisp_Object tail, frame; frame_garbaged = 1; - if (FRAMEP (Vterminal_frame)) - FRAME_GARBAGED_P (XFRAME (Vterminal_frame)) = 1; + FOR_EACH_FRAME (tail, frame) + { + if (FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (frame)) == tty_out) + FRAME_GARBAGED_P (XFRAME (frame)) = 1; + } } - term_initted = 1; + tty_out->term_initted = 1; } /* Return nonzero if safe to use tabs in output. At the time this is called, init_sys_modes has not been done yet. */ int -tabs_safe_p () +tabs_safe_p (int fd) { - struct emacs_tty tty; - - EMACS_GET_TTY (input_fd, &tty); - return EMACS_TTY_TABS_OK (&tty); + struct emacs_tty etty; + + EMACS_GET_TTY (fd, &etty); + return EMACS_TTY_TABS_OK (&etty); } /* Get terminal size from system. @@ -1685,8 +1702,7 @@ We store 0 if there's no valid information. */ void -get_frame_size (widthp, heightp) - int *widthp, *heightp; +get_tty_size (int fd, int *widthp, int *heightp) { #ifdef TIOCGWINSZ @@ -1694,7 +1710,7 @@ /* BSD-style. */ struct winsize size; - if (ioctl (input_fd, TIOCGWINSZ, &size) == -1) + if (ioctl (fd, TIOCGWINSZ, &size) == -1) *widthp = *heightp = 0; else { @@ -1708,7 +1724,7 @@ /* SunOS - style. */ struct ttysize size; - if (ioctl (input_fd, TIOCGSIZE, &size) == -1) + if (ioctl (fd, TIOCGSIZE, &size) == -1) *widthp = *heightp = 0; else { @@ -1721,7 +1737,7 @@ struct sensemode tty; - SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0, + SYS$QIOW (0, fd, IO$_SENSEMODE, &tty, 0, 0, &tty.class, 12, 0, 0, 0, 0); *widthp = tty.scr_wid; *heightp = tty.scr_len; @@ -1778,37 +1794,46 @@ } -/* Prepare the terminal for exiting Emacs; move the cursor to the +void +reset_all_sys_modes (void) +{ + struct tty_display_info *tty; + for (tty = tty_list; tty; tty = tty->next) + reset_sys_modes (tty); +} + +/* Prepare the terminal for closing it; move the cursor to the bottom of the frame, turn off interrupt-driven I/O, etc. */ void -reset_sys_modes () +reset_sys_modes (tty_out) + struct tty_display_info *tty_out; { - struct frame *sf; - if (noninteractive) { fflush (stdout); return; } - if (!term_initted) + if (!tty_out->term_initted) return; #ifdef HAVE_WINDOW_SYSTEM /* Emacs' window system on MSDOG uses the `internal terminal' and therefore needs the clean-up code below. */ - if (!EQ (Vwindow_system, Qnil) + 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 - sf = SELECTED_FRAME (); - cursor_to (FRAME_LINES (sf) - 1, 0); - clear_end_of_line (FRAME_COLS (sf)); - /* clear_end_of_line may move the cursor */ - cursor_to (FRAME_LINES (sf) - 1, 0); + + cmgoto (tty_out, FrameRows (tty_out) - 1, 0); + tty_clear_end_of_line (tty_out, FrameCols (tty_out)); + cmgoto (tty_out, FrameRows (tty_out) - 1, 0); + fflush (tty_out->output); + #if defined (IBMR2AIX) && defined (AIXHFT) { /* HFT devices normally use ^J as a LF/CR. We forced it to @@ -1820,12 +1845,12 @@ } #endif - reset_terminal_modes (); - fflush (stdout); + tty_reset_terminal_modes (tty_out); + fflush (TTY_OUTPUT (tty_out)); #ifdef BSD_SYSTEM #ifndef BSD4_1 /* Avoid possible loss of output when changing terminal modes. */ - fsync (fileno (stdout)); + fsync (fileno (TTY_OUTPUT (tty_out))); #endif #endif @@ -1834,22 +1859,25 @@ #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ if (interrupt_input) { - reset_sigio (); - fcntl (input_fd, F_SETOWN, old_fcntl_owner); + reset_sigio (fileno (TTY_INPUT (tty_out))); + fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, + old_fcntl_owner[fileno (TTY_INPUT (tty_out))]); } #endif /* F_SETOWN */ #endif /* F_SETOWN_BUG */ #ifdef O_NDELAY - fcntl (input_fd, F_SETFL, fcntl (input_fd, F_GETFL, 0) & ~O_NDELAY); + fcntl (fileno (TTY_INPUT (tty_out)), F_SETFL, + fcntl (fileno (TTY_INPUT (tty_out)), F_GETFL, 0) & ~O_NDELAY); #endif #endif /* F_SETFL */ #ifdef BSD4_1 if (interrupt_input) - reset_sigio (); + reset_sigio (fileno (TTY_INPUT (tty_out))); #endif /* BSD4_1 */ - if (old_tty_valid) - while (EMACS_SET_TTY (input_fd, &old_tty, 0) < 0 && errno == EINTR) + if (tty_out->old_tty) + while (EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)), + tty_out->old_tty, 0) < 0 && errno == EINTR) ; #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ @@ -1860,7 +1888,7 @@ /* Ultrix's termios *ignores* any line discipline except TERMIODISC. A different old line discipline is therefore not restored, yet. Restore the old line discipline by hand. */ - ioctl (0, TIOCSETD, &old_tty.main.c_line); + ioctl (0, TIOCSETD, &tty_out->old_tty.main.c_line); #endif #ifdef AIXHFT @@ -1868,7 +1896,7 @@ #endif #ifdef BSD_PGRPS - widen_foreground_group (); + widen_foreground_group (fileno (TTY_INPUT (tty_out))); #endif } @@ -1933,9 +1961,9 @@ { int status; - if (input_fd == 0) + if (fileno (TTY_INPUT (CURTTY())) == 0) { - status = SYS$ASSIGN (&input_dsc, &input_fd, 0, 0); + status = SYS$ASSIGN (&input_dsc, &fileno (TTY_INPUT (CURTTY())), 0, 0); if (! (status & 1)) LIB$STOP (status); } @@ -1946,7 +1974,7 @@ void stop_vms_input () { - return SYS$DASSGN (input_fd); + return SYS$DASSGN (fileno (TTY_INPUT (CURTTY()))); } short input_buffer; @@ -1962,7 +1990,7 @@ waiting_for_ast = 0; stop_input = 0; - status = SYS$QIO (0, input_fd, IO$_READVBLK, + status = SYS$QIO (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK, &input_iosb, kbd_input_ast, 1, &input_buffer, 1, 0, terminator_mask, 0, 0); } @@ -2079,7 +2107,7 @@ #endif if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */ { - SYS$CANCEL (input_fd); + SYS$CANCEL (fileno (TTY_INPUT (CURTTY()))); return; } @@ -2088,7 +2116,7 @@ SYS$CLREF (input_ef); waiting_for_ast = 1; stop_input = 1; - SYS$CANCEL (input_fd); + SYS$CANCEL (fileno (TTY_INPUT (CURTTY()))); SYS$SETAST (1); SYS$WAITFR (input_ef); waiting_for_ast = 0; @@ -2150,7 +2178,8 @@ request_sigio (); } -reset_sigio () +reset_sigio (fd) + int fd; { unrequest_sigio (); } @@ -2609,7 +2638,7 @@ } return ravail; } -#endif /* not WINDOWSNT */ +#endif not WINDOWSNT /* Read keyboard input into the standard buffer, waiting for at least one character. */ @@ -2684,6 +2713,10 @@ } } +#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X) +#define select sys_select +#endif + #endif /* not HAVE_SELECT */ #endif /* not VMS */ #endif /* not MSDOS */ @@ -2700,12 +2733,13 @@ } void -reset_sigio () +reset_sigio (fd) + int fd; { if (noninteractive) return; lmode = ~LINTRUP & lmode; - ioctl (0, TIOCLSET, &lmode); + ioctl (fd, TIOCLSET, &lmode); } void @@ -3153,7 +3187,7 @@ #undef abort sys_abort () { - reset_sys_modes (); + reset_all_sys_modes (); LIB$SIGNAL (SS$_DEBUG); } #endif /* abort */ @@ -3470,7 +3504,7 @@ char *badfunc; { printf ("%s not yet implemented\r\n", badfunc); - reset_sys_modes (); + reset_all_sys_modes (); exit (1); } @@ -5056,7 +5090,7 @@ char *badfunc; { printf ("%s not yet implemented\r\n", badfunc); - reset_sys_modes (); + reset_all_sys_modes (); exit (1); } @@ -5078,7 +5112,7 @@ /* Called from init_sys_modes. */ void -hft_init () +hft_init (struct tty_display_info *tty_out) { int junk; @@ -5124,15 +5158,12 @@ keymap.hfkey[1].hf_char = 127; hftctl (0, HFSKBD, &buf); } - /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly - at times. */ - line_ins_del_ok = char_ins_del_ok = 0; } /* Reset the rubout key to backspace. */ void -hft_reset () +hft_reset (struct tty_display_info *tty_out) { struct hfbuf buf; struct hfkeymap keymap;
--- a/src/term.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/term.c Fri Jan 02 04:37:46 2004 +0000 @@ -26,9 +26,12 @@ #include <ctype.h> #include <string.h> +#include <sys/file.h> + +#include "lisp.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "termopts.h" -#include "lisp.h" #include "charset.h" #include "coding.h" #include "keyboard.h" @@ -60,53 +63,55 @@ #include "macterm.h" #endif +#ifndef O_RDWR +#define O_RDWR 2 +#endif + static void turn_on_face P_ ((struct frame *, int face_id)); static void turn_off_face P_ ((struct frame *, int face_id)); -static void tty_show_cursor P_ ((void)); -static void tty_hide_cursor P_ ((void)); - -#define OUTPUT(a) \ - tputs (a, (int) (FRAME_LINES (XFRAME (selected_frame)) - curY), cmputc) -#define OUTPUT1(a) tputs (a, 1, cmputc) -#define OUTPUTL(a, lines) tputs (a, lines, cmputc) - -#define OUTPUT_IF(a) \ - do { \ - if (a) \ - tputs (a, (int) (FRAME_LINES (XFRAME (selected_frame)) \ - - curY), cmputc); \ - } while (0) - -#define OUTPUT1_IF(a) do { if (a) tputs (a, 1, cmputc); } while (0) +static void tty_show_cursor P_ ((struct tty_display_info *)); +static void tty_hide_cursor P_ ((struct tty_display_info *)); + +void delete_tty P_ ((struct tty_display_info *)); +static void delete_tty_1 P_ ((struct tty_display_info *)); + + +#define OUTPUT(tty, a) \ + emacs_tputs ((tty), a, \ + (int) (FRAME_LINES (XFRAME (selected_frame)) \ + - curY (tty)), \ + cmputc) + +#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc) +#define OUTPUTL(tty, a, lines) emacs_tputs ((tty), a, lines, cmputc) + +#define OUTPUT_IF(tty, a) \ + do { \ + if (a) \ + emacs_tputs ((tty), a, \ + (int) (FRAME_LINES (XFRAME (selected_frame)) \ + - curY (tty) ), \ + cmputc); \ + } while (0) + +#define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0) /* Function to use to ring the bell. */ Lisp_Object Vring_bell_function; -/* Terminal characteristics that higher levels want to look at. - These are all extern'd in termchar.h */ - -int must_write_spaces; /* Nonzero means spaces in the text - must actually be output; can't just skip - over some columns to leave them blank. */ -int min_padding_speed; /* Speed below which no padding necessary */ - -int line_ins_del_ok; /* Terminal can insert and delete lines */ -int char_ins_del_ok; /* Terminal can insert and delete chars */ -int scroll_region_ok; /* Terminal supports setting the - scroll window */ -int scroll_region_cost; /* Cost of setting a scroll window, - measured in characters */ -int memory_below_frame; /* Terminal remembers lines - scrolled off bottom */ -int fast_clear_end_of_line; /* Terminal has a `ce' string */ - -/* Nonzero means no need to redraw the entire frame on resuming - a suspended Emacs. This is useful on terminals with multiple pages, - where one page is used for Emacs and another for all else. */ - +/* Terminal characteristics that higher levels want to look at. */ + +struct tty_display_info *tty_list; + +/* Nonzero means no need to redraw the entire frame on resuming a + suspended Emacs. This is useful on terminals with multiple + pages, where one page is used for Emacs and another for all + else. */ int no_redraw_on_reenter; +Lisp_Object Qframe_tty_name, Qframe_tty_type; + /* Hook functions that you can set to snap out the functions in this file. These are all extern'd in termhooks.h */ @@ -131,7 +136,7 @@ void (*write_glyphs_hook) P_ ((struct glyph *, int)); void (*delete_glyphs_hook) P_ ((int)); -int (*read_socket_hook) P_ ((int, struct input_event *, int, int)); +int (*read_socket_hook) P_ ((struct input_event *, int, int)); void (*frame_up_to_date_hook) P_ ((struct frame *)); @@ -235,51 +240,6 @@ void (*judge_scroll_bars_hook) P_ ((FRAME_PTR FRAME)); -/* Strings, numbers and flags taken from the termcap entry. */ - -char *TS_ins_line; /* "al" */ -char *TS_ins_multi_lines; /* "AL" (one parameter, # lines to insert) */ -char *TS_bell; /* "bl" */ -char *TS_clr_to_bottom; /* "cd" */ -char *TS_clr_line; /* "ce", clear to end of line */ -char *TS_clr_frame; /* "cl" */ -char *TS_set_scroll_region; /* "cs" (2 params, first line and last line) */ -char *TS_set_scroll_region_1; /* "cS" (4 params: total lines, - lines above scroll region, lines below it, - total lines again) */ -char *TS_del_char; /* "dc" */ -char *TS_del_multi_chars; /* "DC" (one parameter, # chars to delete) */ -char *TS_del_line; /* "dl" */ -char *TS_del_multi_lines; /* "DL" (one parameter, # lines to delete) */ -char *TS_delete_mode; /* "dm", enter character-delete mode */ -char *TS_end_delete_mode; /* "ed", leave character-delete mode */ -char *TS_end_insert_mode; /* "ei", leave character-insert mode */ -char *TS_ins_char; /* "ic" */ -char *TS_ins_multi_chars; /* "IC" (one parameter, # chars to insert) */ -char *TS_insert_mode; /* "im", enter character-insert mode */ -char *TS_pad_inserted_char; /* "ip". Just padding, no commands. */ -char *TS_end_keypad_mode; /* "ke" */ -char *TS_keypad_mode; /* "ks" */ -char *TS_pad_char; /* "pc", char to use as padding */ -char *TS_repeat; /* "rp" (2 params, # times to repeat - and character to be repeated) */ -char *TS_end_standout_mode; /* "se" */ -char *TS_fwd_scroll; /* "sf" */ -char *TS_standout_mode; /* "so" */ -char *TS_rev_scroll; /* "sr" */ -char *TS_end_termcap_modes; /* "te" */ -char *TS_termcap_modes; /* "ti" */ -char *TS_visible_bell; /* "vb" */ -char *TS_cursor_normal; /* "ve" */ -char *TS_cursor_visible; /* "vs" */ -char *TS_cursor_invisible; /* "vi" */ -char *TS_set_window; /* "wi" (4 params, start and end of window, - each as vpos and hpos) */ - -/* Value of the "NC" (no_color_video) capability, or 0 if not - present. */ - -static int TN_no_color_video; /* Meaning of bits in no_color_video. Each bit set means that the corresponding attribute cannot be combined with colors. */ @@ -297,68 +257,6 @@ NC_ALT_CHARSET = 1 << 8 }; -/* "md" -- turn on bold (extra bright mode). */ - -char *TS_enter_bold_mode; - -/* "mh" -- turn on half-bright mode. */ - -char *TS_enter_dim_mode; - -/* "mb" -- enter blinking mode. */ - -char *TS_enter_blink_mode; - -/* "mr" -- enter reverse video mode. */ - -char *TS_enter_reverse_mode; - -/* "us"/"ue" -- start/end underlining. */ - -char *TS_exit_underline_mode, *TS_enter_underline_mode; - -/* "as"/"ae" -- start/end alternate character set. Not really - supported, yet. */ - -char *TS_enter_alt_charset_mode, *TS_exit_alt_charset_mode; - -/* "me" -- switch appearances off. */ - -char *TS_exit_attribute_mode; - -/* "Co" -- number of colors. */ - -int TN_max_colors; - -/* "pa" -- max. number of color pairs on screen. Not handled yet. - Could be a problem if not equal to TN_max_colors * TN_max_colors. */ - -int TN_max_pairs; - -/* "op" -- SVr4 set default pair to its original value. */ - -char *TS_orig_pair; - -/* "AF"/"AB" or "Sf"/"Sb"-- set ANSI or SVr4 foreground/background color. - 1 param, the color index. */ - -char *TS_set_foreground, *TS_set_background; - -int TF_hazeltine; /* termcap hz flag. */ -int TF_insmode_motion; /* termcap mi flag: can move while in insert mode. */ -int TF_standout_motion; /* termcap mi flag: can move while in standout mode. */ -int TF_underscore; /* termcap ul flag: _ underlines if over-struck on - non-blank position. Must clear before writing _. */ -int TF_teleray; /* termcap xt flag: many weird consequences. - For t1061. */ - -static int RPov; /* # chars to start a TS_repeat */ - -static int delete_in_insert_mode; /* delete mode == insert mode */ - -static int se_is_so; /* 1 if same string both enters and leaves - standout mode */ - /* internal state */ /* The largest frame width in any call to calculate_costs. */ @@ -369,19 +267,9 @@ int max_frame_lines; -static int costs_set; /* Nonzero if costs have been calculated. */ - -int insert_mode; /* Nonzero when in insert mode. */ -int standout_mode; /* Nonzero when in standout mode. */ - -/* Size of window specified by higher levels. - This is the number of lines, from the top of frame downwards, - which can participate in insert-line/delete-line operations. - - Effectively it excludes the bottom frame_lines - specified_window_size - lines from those operations. */ - -int specified_window; +/* A template for tty display methods, with common values + preinitialized. */ +static struct display_method tty_display_method_template; /* Frame currently being redisplayed; 0 if not currently redisplaying. (Direct output does not count). */ @@ -392,10 +280,6 @@ static int system_uses_terminfo; -/* Flag used in tty_show/hide_cursor. */ - -static int tty_cursor_hidden; - char *tparam (); extern char *tgetstr (); @@ -415,6 +299,8 @@ void ring_bell () { + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + if (!NILP (Vring_bell_function)) { Lisp_Object function; @@ -434,40 +320,51 @@ Vring_bell_function = function; } - else if (!FRAME_TERMCAP_P (XFRAME (selected_frame))) + else if (!FRAME_TERMCAP_P (f)) (*ring_bell_hook) (); - else - OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell); + else { + struct tty_display_info *tty = FRAME_TTY (f); + OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell); + } +} + +void tty_set_terminal_modes (struct tty_display_info *tty) +{ + OUTPUT_IF (tty, tty->TS_termcap_modes); + OUTPUT_IF (tty, tty->TS_cursor_visible); + OUTPUT_IF (tty, tty->TS_keypad_mode); + losecursor (tty); } void set_terminal_modes () { - if (FRAME_TERMCAP_P (XFRAME (selected_frame))) - { - OUTPUT_IF (TS_termcap_modes); - OUTPUT_IF (TS_cursor_visible); - OUTPUT_IF (TS_keypad_mode); - losecursor (); - } + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + if (FRAME_TERMCAP_P (f)) + tty_set_terminal_modes (FRAME_TTY (f)); else (*set_terminal_modes_hook) (); } +void tty_reset_terminal_modes (struct tty_display_info *tty) +{ + turn_off_highlight (tty); + turn_off_insert (tty); + OUTPUT_IF (tty, tty->TS_end_keypad_mode); + OUTPUT_IF (tty, tty->TS_cursor_normal); + OUTPUT_IF (tty, tty->TS_end_termcap_modes); + OUTPUT_IF (tty, tty->TS_orig_pair); + /* Output raw CR so kernel can track the cursor hpos. */ + current_tty = tty; + cmputc ('\r'); +} + void reset_terminal_modes () { - if (FRAME_TERMCAP_P (XFRAME (selected_frame))) - { - turn_off_highlight (); - turn_off_insert (); - OUTPUT_IF (TS_end_keypad_mode); - OUTPUT_IF (TS_cursor_normal); - OUTPUT_IF (TS_end_termcap_modes); - OUTPUT_IF (TS_orig_pair); - /* Output raw CR so kernel can track the cursor hpos. */ - cmputc ('\r'); - } + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + if (FRAME_TERMCAP_P (f)) + tty_reset_terminal_modes (FRAME_TTY (f)); else if (reset_terminal_modes_hook) (*reset_terminal_modes_hook) (); } @@ -487,10 +384,11 @@ { if (FRAME_TERMCAP_P (f)) { + struct tty_display_info *tty = FRAME_TTY (f); if (!XWINDOW (selected_window)->cursor_off_p) - tty_show_cursor (); - turn_off_insert (); - background_highlight (); + tty_show_cursor (tty); + turn_off_insert (tty); + background_highlight (tty); } else update_end_hook (f); @@ -502,11 +400,13 @@ set_terminal_window (size) int size; { - if (FRAME_TERMCAP_P (updating_frame)) + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + if (FRAME_TERMCAP_P (f)) { - specified_window = size ? size : FRAME_LINES (updating_frame); - if (scroll_region_ok) - set_scroll_region (0, specified_window); + struct tty_display_info *tty = FRAME_TTY (f); + tty->specified_window = size ? size : FRAME_LINES (f); + if (FRAME_SCROLL_REGION_OK (f)) + set_scroll_region (0, tty->specified_window); } else set_terminal_window_hook (size); @@ -517,77 +417,78 @@ int start, stop; { char *buf; - struct frame *sf = XFRAME (selected_frame); - - if (TS_set_scroll_region) - buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1); - else if (TS_set_scroll_region_1) - buf = tparam (TS_set_scroll_region_1, 0, 0, - FRAME_LINES (sf), start, - FRAME_LINES (sf) - stop, - FRAME_LINES (sf)); + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + struct tty_display_info *tty = FRAME_TTY (f); + + if (tty->TS_set_scroll_region) + buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1); + else if (tty->TS_set_scroll_region_1) + buf = tparam (tty->TS_set_scroll_region_1, 0, 0, + FRAME_LINES (f), start, + FRAME_LINES (f) - stop, + FRAME_LINES (f)); else - buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_COLS (sf)); - - OUTPUT (buf); + buf = tparam (tty->TS_set_window, 0, 0, start, 0, stop, FRAME_COLS (f)); + + OUTPUT (tty, buf); xfree (buf); - losecursor (); + losecursor (tty); } static void -turn_on_insert () +turn_on_insert (struct tty_display_info *tty) { - if (!insert_mode) - OUTPUT (TS_insert_mode); - insert_mode = 1; + if (!tty->insert_mode) + OUTPUT (tty, tty->TS_insert_mode); + tty->insert_mode = 1; } void -turn_off_insert () +turn_off_insert (struct tty_display_info *tty) { - if (insert_mode) - OUTPUT (TS_end_insert_mode); - insert_mode = 0; + if (tty->insert_mode) + OUTPUT (tty, tty->TS_end_insert_mode); + tty->insert_mode = 0; } /* Handle highlighting. */ void -turn_off_highlight () +turn_off_highlight (struct tty_display_info *tty) { - if (standout_mode) - OUTPUT_IF (TS_end_standout_mode); - standout_mode = 0; + if (tty->standout_mode) + OUTPUT_IF (tty, tty->TS_end_standout_mode); + tty->standout_mode = 0; } static void -turn_on_highlight () +turn_on_highlight (struct tty_display_info *tty) { - if (!standout_mode) - OUTPUT_IF (TS_standout_mode); - standout_mode = 1; + if (!tty->standout_mode) + OUTPUT_IF (tty, tty->TS_standout_mode); + tty->standout_mode = 1; } static void -toggle_highlight () +toggle_highlight (struct tty_display_info *tty) { - if (standout_mode) - turn_off_highlight (); + if (tty->standout_mode) + turn_off_highlight (tty); else - turn_on_highlight (); + turn_on_highlight (tty); } /* Make cursor invisible. */ static void -tty_hide_cursor () +tty_hide_cursor (struct tty_display_info *tty) { - if (tty_cursor_hidden == 0) + if (tty->cursor_hidden == 0) { - tty_cursor_hidden = 1; - OUTPUT_IF (TS_cursor_invisible); + tty->cursor_hidden = 1; + OUTPUT_IF (tty, tty->TS_cursor_invisible); } } @@ -595,13 +496,13 @@ /* Ensure that cursor is visible. */ static void -tty_show_cursor () +tty_show_cursor (struct tty_display_info *tty) { - if (tty_cursor_hidden) + if (tty->cursor_hidden) { - tty_cursor_hidden = 0; - OUTPUT_IF (TS_cursor_normal); - OUTPUT_IF (TS_cursor_visible); + tty->cursor_hidden = 0; + OUTPUT_IF (tty, tty->TS_cursor_normal); + OUTPUT_IF (tty, tty->TS_cursor_visible); } } @@ -611,23 +512,23 @@ depends on the user option inverse-video. */ void -background_highlight () +background_highlight (struct tty_display_info *tty) { if (inverse_video) - turn_on_highlight (); + turn_on_highlight (tty); else - turn_off_highlight (); + turn_off_highlight (tty); } /* Set standout mode to the mode specified for the text to be output. */ static void -highlight_if_desired () +highlight_if_desired (struct tty_display_info *tty) { if (inverse_video) - turn_on_highlight (); + turn_on_highlight (tty); else - turn_off_highlight (); + turn_off_highlight (tty); } @@ -638,7 +539,8 @@ cursor_to (vpos, hpos) int vpos, hpos; { - struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + struct tty_display_info *tty; if (! FRAME_TERMCAP_P (f) && cursor_to_hook) { @@ -646,18 +548,21 @@ return; } + tty = FRAME_TTY (f); + /* Detect the case where we are called from reset_sys_modes and the costs have never been calculated. Do nothing. */ - if (! costs_set) + if (! tty->costs_set) return; - if (curY == vpos && curX == hpos) + if (curY (tty) == vpos + && curX (tty) == hpos) return; - if (!TF_standout_motion) - background_highlight (); - if (!TF_insmode_motion) - turn_off_insert (); - cmgoto (vpos, hpos); + if (!tty->TF_standout_motion) + background_highlight (tty); + if (!tty->TF_insmode_motion) + turn_off_insert (tty); + cmgoto (tty, vpos, hpos); } /* Similar but don't take any account of the wasted characters. */ @@ -667,18 +572,21 @@ int row, col; { struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); + struct tty_display_info *tty; if (! FRAME_TERMCAP_P (f)) { (*raw_cursor_to_hook) (row, col); return; } - if (curY == row && curX == col) + tty = FRAME_TTY (f); + if (curY (tty) == row + && curX (tty) == col) return; - if (!TF_standout_motion) - background_highlight (); - if (!TF_insmode_motion) - turn_off_insert (); - cmgoto (row, col); + if (!tty->TF_standout_motion) + background_highlight (tty); + if (!tty->TF_insmode_motion) + turn_off_insert (tty); + cmgoto (tty, row, col); } /* Erase operations */ @@ -689,22 +597,26 @@ { register int i; - if (clear_to_end_hook && ! FRAME_TERMCAP_P (updating_frame)) + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + struct tty_display_info *tty; + + if (clear_to_end_hook && ! FRAME_TERMCAP_P (f)) { (*clear_to_end_hook) (); return; } - if (TS_clr_to_bottom) + tty = FRAME_TTY (f); + if (tty->TS_clr_to_bottom) { - background_highlight (); - OUTPUT (TS_clr_to_bottom); + background_highlight (tty); + OUTPUT (tty, tty->TS_clr_to_bottom); } else { - for (i = curY; i < FRAME_LINES (XFRAME (selected_frame)); i++) + for (i = curY (tty); i < FRAME_LINES (f); i++) { cursor_to (i, 0); - clear_end_of_line (FRAME_COLS (XFRAME (selected_frame))); + clear_end_of_line (FRAME_COLS (f)); } } } @@ -714,19 +626,20 @@ void clear_frame () { - struct frame *sf = XFRAME (selected_frame); - - if (clear_frame_hook - && ! FRAME_TERMCAP_P ((updating_frame ? updating_frame : sf))) + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + struct tty_display_info *tty; + + if (clear_frame_hook && ! FRAME_TERMCAP_P (f)) { (*clear_frame_hook) (); return; } - if (TS_clr_frame) + tty = FRAME_TTY (f); + if (tty->TS_clr_frame) { - background_highlight (); - OUTPUT (TS_clr_frame); - cmat (0, 0); + background_highlight (tty); + OUTPUT (tty, tty->TS_clr_frame); + cmat (tty, 0, 0); } else { @@ -744,46 +657,51 @@ clear_end_of_line (first_unused_hpos) int first_unused_hpos; { - register int i; - - if (clear_end_of_line_hook - && ! FRAME_TERMCAP_P ((updating_frame - ? updating_frame - : XFRAME (selected_frame)))) + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + struct tty_display_info *tty; + + if (clear_end_of_line_hook && ! FRAME_TERMCAP_P (f)) { (*clear_end_of_line_hook) (first_unused_hpos); return; } + tty_clear_end_of_line (FRAME_TTY (f), first_unused_hpos); +} + +void +tty_clear_end_of_line (struct tty_display_info *tty, int first_unused_hpos) +{ + register int i; /* Detect the case where we are called from reset_sys_modes and the costs have never been calculated. Do nothing. */ - if (! costs_set) + if (! tty->costs_set) return; - if (curX >= first_unused_hpos) + if (curX (tty) >= first_unused_hpos) return; - background_highlight (); - if (TS_clr_line) + background_highlight (tty); + if (tty->TS_clr_line) { - OUTPUT1 (TS_clr_line); + OUTPUT1 (tty, tty->TS_clr_line); } else { /* have to do it the hard way */ - struct frame *sf = XFRAME (selected_frame); - turn_off_insert (); + turn_off_insert (tty); /* Do not write in last row last col with Auto-wrap on. */ - if (AutoWrap && curY == FRAME_LINES (sf) - 1 - && first_unused_hpos == FRAME_COLS (sf)) + if (AutoWrap (tty) + && curY (tty) == FrameRows (tty) - 1 + && first_unused_hpos == FrameCols (tty)) first_unused_hpos--; - for (i = curX; i < first_unused_hpos; i++) + for (i = curX (tty); i < first_unused_hpos; i++) { - if (termscript) - fputc (' ', termscript); - putchar (' '); + if (TTY_TERMSCRIPT (tty)) + fputc (' ', TTY_TERMSCRIPT (tty)); + fputc (' ', TTY_OUTPUT (tty)); } - cmplus (first_unused_hpos - curX); + cmplus (tty, first_unused_hpos - curX (tty)); } } @@ -902,32 +820,33 @@ register int len; { int produced, consumed; - struct frame *sf = XFRAME (selected_frame); - struct frame *f = updating_frame ? updating_frame : sf; + struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); + struct tty_display_info *tty; unsigned char conversion_buffer[1024]; int conversion_buffer_size = sizeof conversion_buffer; - if (write_glyphs_hook - && ! FRAME_TERMCAP_P (f)) + if (write_glyphs_hook && ! FRAME_TERMCAP_P (f)) { (*write_glyphs_hook) (string, len); return; } - turn_off_insert (); - tty_hide_cursor (); + tty = FRAME_TTY (f); + + turn_off_insert (tty); + tty_hide_cursor (tty); /* Don't dare write in last column of bottom line, if Auto-Wrap, since that would scroll the whole frame on some terminals. */ - if (AutoWrap - && curY + 1 == FRAME_LINES (sf) - && (curX + len) == FRAME_COLS (sf)) + if (AutoWrap (tty) + && curY (tty) + 1 == FRAME_LINES (f) + && (curX (tty) + len) == FRAME_COLS (f)) len --; if (len <= 0) return; - cmplus (len); + cmplus (tty, len); /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at the tail. */ @@ -944,7 +863,7 @@ break; /* Turn appearance modes of the face of the run on. */ - highlight_if_desired (); + highlight_if_desired (tty); turn_on_face (f, face_id); while (n > 0) @@ -957,11 +876,13 @@ &consumed); if (produced > 0) { - fwrite (conversion_buffer, 1, produced, stdout); - if (ferror (stdout)) - clearerr (stdout); - if (termscript) - fwrite (conversion_buffer, 1, produced, termscript); + fwrite (conversion_buffer, 1, produced, + TTY_OUTPUT (tty)); + if (ferror (TTY_OUTPUT (tty))) + clearerr (TTY_OUTPUT (tty)); + if (TTY_TERMSCRIPT (tty)) + fwrite (conversion_buffer, 1, produced, + TTY_TERMSCRIPT (tty)); } len -= consumed; n -= consumed; @@ -970,7 +891,7 @@ /* Turn appearance modes off. */ turn_off_face (f, face_id); - turn_off_highlight (); + turn_off_highlight (tty); } /* We may have to output some codes to terminate the writing. */ @@ -981,16 +902,17 @@ 0, conversion_buffer_size); if (terminal_coding.produced > 0) { - fwrite (conversion_buffer, 1, terminal_coding.produced, stdout); - if (ferror (stdout)) - clearerr (stdout); - if (termscript) + fwrite (conversion_buffer, 1, terminal_coding.produced, + TTY_OUTPUT (tty)); + if (ferror (TTY_OUTPUT (tty))) + clearerr (TTY_OUTPUT (tty)); + if (TTY_TERMSCRIPT (tty)) fwrite (conversion_buffer, 1, terminal_coding.produced, - termscript); + TTY_TERMSCRIPT (tty)); } } - cmcheckmagic (); + cmcheckmagic (tty); } /* If start is zero, insert blanks instead of a string at start */ @@ -1002,32 +924,34 @@ { char *buf; struct glyph *glyph = NULL; - struct frame *f, *sf; + struct frame *f; + struct tty_display_info *tty; if (len <= 0) return; - if (insert_glyphs_hook) + f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + + if (insert_glyphs_hook && ! FRAME_TERMCAP_P (f)) { (*insert_glyphs_hook) (start, len); return; } - sf = XFRAME (selected_frame); - f = updating_frame ? updating_frame : sf; - - if (TS_ins_multi_chars) + tty = FRAME_TTY (f); + + if (tty->TS_ins_multi_chars) { - buf = tparam (TS_ins_multi_chars, 0, 0, len); - OUTPUT1 (buf); + buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); + OUTPUT1 (tty, buf); xfree (buf); if (start) write_glyphs (start, len); return; } - turn_on_insert (); - cmplus (len); + turn_on_insert (tty); + cmplus (tty, len); /* The bit CODING_MODE_LAST_BLOCK should be set to 1 only at the tail. */ terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK; while (len-- > 0) @@ -1036,7 +960,7 @@ unsigned char conversion_buffer[1024]; int conversion_buffer_size = sizeof conversion_buffer; - OUTPUT1_IF (TS_ins_char); + OUTPUT1_IF (tty, tty->TS_ins_char); if (!start) { conversion_buffer[0] = SPACEGLYPH; @@ -1044,7 +968,7 @@ } else { - highlight_if_desired (); + highlight_if_desired (tty); turn_on_face (f, start->face_id); glyph = start; ++start; @@ -1052,7 +976,7 @@ occupies more than one column. */ while (len && CHAR_GLYPH_PADDING_P (*start)) { - OUTPUT1_IF (TS_ins_char); + OUTPUT1_IF (tty, tty->TS_ins_char); start++, len--; } @@ -1068,22 +992,24 @@ if (produced > 0) { - fwrite (conversion_buffer, 1, produced, stdout); - if (ferror (stdout)) - clearerr (stdout); - if (termscript) - fwrite (conversion_buffer, 1, produced, termscript); + fwrite (conversion_buffer, 1, produced, + TTY_OUTPUT (tty)); + if (ferror (TTY_OUTPUT (tty))) + clearerr (TTY_OUTPUT (tty)); + if (TTY_TERMSCRIPT (tty)) + fwrite (conversion_buffer, 1, produced, + TTY_TERMSCRIPT (tty)); } - OUTPUT1_IF (TS_pad_inserted_char); + OUTPUT1_IF (tty, tty->TS_pad_inserted_char); if (start) { turn_off_face (f, glyph->face_id); - turn_off_highlight (); + turn_off_highlight (tty); } } - cmcheckmagic (); + cmcheckmagic (tty); } void @@ -1092,34 +1018,37 @@ { char *buf; register int i; - - if (delete_glyphs_hook && ! FRAME_TERMCAP_P (updating_frame)) + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + struct tty_display_info *tty = FRAME_TTY (f); + + if (delete_glyphs_hook && ! FRAME_TERMCAP_P (f)) { (*delete_glyphs_hook) (n); return; } - if (delete_in_insert_mode) + + if (tty->delete_in_insert_mode) { - turn_on_insert (); + turn_on_insert (tty); } else { - turn_off_insert (); - OUTPUT_IF (TS_delete_mode); + turn_off_insert (tty); + OUTPUT_IF (tty, tty->TS_delete_mode); } - if (TS_del_multi_chars) + if (tty->TS_del_multi_chars) { - buf = tparam (TS_del_multi_chars, 0, 0, n); - OUTPUT1 (buf); + buf = tparam (tty->TS_del_multi_chars, 0, 0, n); + OUTPUT1 (tty, buf); xfree (buf); } else for (i = 0; i < n; i++) - OUTPUT1 (TS_del_char); - if (!delete_in_insert_mode) - OUTPUT_IF (TS_end_delete_mode); + OUTPUT1 (tty, tty->TS_del_char); + if (!tty->delete_in_insert_mode) + OUTPUT_IF (tty, tty->TS_end_delete_mode); } /* Insert N lines at vpos VPOS. If N is negative, delete -N lines. */ @@ -1128,68 +1057,73 @@ ins_del_lines (vpos, n) int vpos, n; { - char *multi = n > 0 ? TS_ins_multi_lines : TS_del_multi_lines; - char *single = n > 0 ? TS_ins_line : TS_del_line; - char *scroll = n > 0 ? TS_rev_scroll : TS_fwd_scroll; - struct frame *sf; - - register int i = n > 0 ? n : -n; - register char *buf; - - if (ins_del_lines_hook && ! FRAME_TERMCAP_P (updating_frame)) + struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); + if (ins_del_lines_hook && ! FRAME_TERMCAP_P (f)) { (*ins_del_lines_hook) (vpos, n); return; } - - sf = XFRAME (selected_frame); - - /* If the lines below the insertion are being pushed - into the end of the window, this is the same as clearing; - and we know the lines are already clear, since the matching - deletion has already been done. So can ignore this. */ - /* If the lines below the deletion are blank lines coming - out of the end of the window, don't bother, - as there will be a matching inslines later that will flush them. */ - if (scroll_region_ok && vpos + i >= specified_window) - return; - if (!memory_below_frame && vpos + i >= FRAME_LINES (sf)) - return; - - if (multi) - { - raw_cursor_to (vpos, 0); - background_highlight (); - buf = tparam (multi, 0, 0, i); - OUTPUT (buf); - xfree (buf); - } - else if (single) - { - raw_cursor_to (vpos, 0); - background_highlight (); - while (--i >= 0) - OUTPUT (single); - if (TF_teleray) - curX = 0; - } else { - set_scroll_region (vpos, specified_window); - if (n < 0) - raw_cursor_to (specified_window - 1, 0); + struct tty_display_info *tty = FRAME_TTY (f); + char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; + char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; + char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; + + register int i = n > 0 ? n : -n; + register char *buf; + + /* If the lines below the insertion are being pushed + into the end of the window, this is the same as clearing; + and we know the lines are already clear, since the matching + deletion has already been done. So can ignore this. */ + /* If the lines below the deletion are blank lines coming + out of the end of the window, don't bother, + as there will be a matching inslines later that will flush them. */ + if (FRAME_SCROLL_REGION_OK (f) + && vpos + i >= tty->specified_window) + return; + if (!FRAME_MEMORY_BELOW_FRAME (f) + && vpos + i >= FRAME_LINES (f)) + return; + + if (multi) + { + raw_cursor_to (vpos, 0); + background_highlight (tty); + buf = tparam (multi, 0, 0, i); + OUTPUT (tty, buf); + xfree (buf); + } + else if (single) + { + raw_cursor_to (vpos, 0); + background_highlight (tty); + while (--i >= 0) + OUTPUT (tty, single); + if (tty->TF_teleray) + curX (tty) = 0; + } else - raw_cursor_to (vpos, 0); - background_highlight (); - while (--i >= 0) - OUTPUTL (scroll, specified_window - vpos); - set_scroll_region (0, specified_window); - } - - if (!scroll_region_ok && memory_below_frame && n < 0) - { - cursor_to (FRAME_LINES (sf) + n, 0); - clear_to_end (); + { + set_scroll_region (vpos, tty->specified_window); + if (n < 0) + raw_cursor_to (tty->specified_window - 1, 0); + else + raw_cursor_to (vpos, 0); + background_highlight (tty); + while (--i >= 0) + OUTPUTL (tty, scroll, tty->specified_window - vpos); + set_scroll_region (0, tty->specified_window); + } + + if (!FRAME_SCROLL_REGION_OK (f) + && FRAME_MEMORY_BELOW_FRAME (f) + && n < 0) + { + cursor_to (FRAME_LINES (f) + n, 0); + clear_to_end (); + } } } @@ -1247,26 +1181,27 @@ /* ARGSUSED */ static void -calculate_ins_del_char_costs (frame) - FRAME_PTR frame; +calculate_ins_del_char_costs (f) + FRAME_PTR f; { + struct tty_display_info *tty = FRAME_TTY (f); int ins_startup_cost, del_startup_cost; int ins_cost_per_char, del_cost_per_char; register int i; register int *p; - if (TS_ins_multi_chars) + if (tty->TS_ins_multi_chars) { ins_cost_per_char = 0; - ins_startup_cost = string_cost_one_line (TS_ins_multi_chars); + ins_startup_cost = string_cost_one_line (tty->TS_ins_multi_chars); } - else if (TS_ins_char || TS_pad_inserted_char - || (TS_insert_mode && TS_end_insert_mode)) + else if (tty->TS_ins_char || tty->TS_pad_inserted_char + || (tty->TS_insert_mode && tty->TS_end_insert_mode)) { - ins_startup_cost = (30 * (string_cost (TS_insert_mode) - + string_cost (TS_end_insert_mode))) / 100; - ins_cost_per_char = (string_cost_one_line (TS_ins_char) - + string_cost_one_line (TS_pad_inserted_char)); + ins_startup_cost = (30 * (string_cost (tty->TS_insert_mode) + + string_cost (tty->TS_end_insert_mode))) / 100; + ins_cost_per_char = (string_cost_one_line (tty->TS_ins_char) + + string_cost_one_line (tty->TS_pad_inserted_char)); } else { @@ -1274,18 +1209,18 @@ ins_cost_per_char = 0; } - if (TS_del_multi_chars) + if (tty->TS_del_multi_chars) { del_cost_per_char = 0; - del_startup_cost = string_cost_one_line (TS_del_multi_chars); + del_startup_cost = string_cost_one_line (tty->TS_del_multi_chars); } - else if (TS_del_char) + else if (tty->TS_del_char) { - del_startup_cost = (string_cost (TS_delete_mode) - + string_cost (TS_end_delete_mode)); - if (delete_in_insert_mode) + del_startup_cost = (string_cost (tty->TS_delete_mode) + + string_cost (tty->TS_end_delete_mode)); + if (tty->delete_in_insert_mode) del_startup_cost /= 2; - del_cost_per_char = string_cost_one_line (TS_del_char); + del_cost_per_char = string_cost_one_line (tty->TS_del_char); } else { @@ -1294,16 +1229,16 @@ } /* Delete costs are at negative offsets */ - p = &char_ins_del_cost (frame)[0]; - for (i = FRAME_COLS (frame); --i >= 0;) + p = &char_ins_del_cost (f)[0]; + for (i = FRAME_COLS (f); --i >= 0;) *--p = (del_startup_cost += del_cost_per_char); /* Doing nothing is free */ - p = &char_ins_del_cost (frame)[0]; + p = &char_ins_del_cost (f)[0]; *p++ = 0; /* Insert costs are at positive offsets */ - for (i = FRAME_COLS (frame); --i >= 0;) + for (i = FRAME_COLS (f); --i >= 0;) *p++ = (ins_startup_cost += ins_cost_per_char); } @@ -1311,58 +1246,64 @@ calculate_costs (frame) FRAME_PTR frame; { - register char *f = (TS_set_scroll_region - ? TS_set_scroll_region - : TS_set_scroll_region_1); - FRAME_COST_BAUD_RATE (frame) = baud_rate; - scroll_region_cost = string_cost (f); - - /* These variables are only used for terminal stuff. They are allocated - once for the terminal frame of X-windows emacs, but not used afterwards. - - char_ins_del_vector (i.e., char_ins_del_cost) isn't used because - X turns off char_ins_del_ok. */ - - max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); - max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); - - costs_set = 1; - - if (char_ins_del_vector != 0) - char_ins_del_vector - = (int *) xrealloc (char_ins_del_vector, - (sizeof (int) - + 2 * max_frame_cols * sizeof (int))); - else - char_ins_del_vector - = (int *) xmalloc (sizeof (int) - + 2 * max_frame_cols * sizeof (int)); - - bzero (char_ins_del_vector, (sizeof (int) - + 2 * max_frame_cols * sizeof (int))); - - if (f && (!TS_ins_line && !TS_del_line)) - do_line_insertion_deletion_costs (frame, - TS_rev_scroll, TS_ins_multi_lines, - TS_fwd_scroll, TS_del_multi_lines, - f, f, 1); - else - do_line_insertion_deletion_costs (frame, - TS_ins_line, TS_ins_multi_lines, - TS_del_line, TS_del_multi_lines, - 0, 0, 1); - - calculate_ins_del_char_costs (frame); - - /* Don't use TS_repeat if its padding is worse than sending the chars */ - if (TS_repeat && per_line_cost (TS_repeat) * baud_rate < 9000) - RPov = string_cost (TS_repeat); - else - RPov = FRAME_COLS (frame) * 2; - - cmcostinit (); /* set up cursor motion costs */ + if (FRAME_TERMCAP_P (frame)) + { + struct tty_display_info *tty = FRAME_TTY (frame); + register char *f = (tty->TS_set_scroll_region + ? tty->TS_set_scroll_region + : tty->TS_set_scroll_region_1); + + FRAME_SCROLL_REGION_COST (frame) = string_cost (f); + + tty->costs_set = 1; + + /* These variables are only used for terminal stuff. They are + allocated once for the terminal frame of X-windows emacs, but not + used afterwards. + + char_ins_del_vector (i.e., char_ins_del_cost) isn't used because + X turns off char_ins_del_ok. */ + + max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); + max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); + + if (char_ins_del_vector != 0) + char_ins_del_vector + = (int *) xrealloc (char_ins_del_vector, + (sizeof (int) + + 2 * max_frame_cols * sizeof (int))); + else + char_ins_del_vector + = (int *) xmalloc (sizeof (int) + + 2 * max_frame_cols * sizeof (int)); + + bzero (char_ins_del_vector, (sizeof (int) + + 2 * max_frame_cols * sizeof (int))); + + + if (f && (!tty->TS_ins_line && !tty->TS_del_line)) + do_line_insertion_deletion_costs (frame, + tty->TS_rev_scroll, tty->TS_ins_multi_lines, + tty->TS_fwd_scroll, tty->TS_del_multi_lines, + f, f, 1); + else + do_line_insertion_deletion_costs (frame, + tty->TS_ins_line, tty->TS_ins_multi_lines, + tty->TS_del_line, tty->TS_del_multi_lines, + 0, 0, 1); + + calculate_ins_del_char_costs (frame); + + /* Don't use TS_repeat if its padding is worse than sending the chars */ + if (tty->TS_repeat && per_line_cost (tty->TS_repeat) * baud_rate < 9000) + tty->RPov = string_cost (tty->TS_repeat); + else + tty->RPov = FRAME_COLS (frame) * 2; + + cmcostinit (FRAME_TTY (frame)); /* set up cursor motion costs */ + } } struct fkey_table { @@ -1812,10 +1753,10 @@ from them. Some display attributes may not be used together with color; the termcap capability `NC' specifies which ones. */ -#define MAY_USE_WITH_COLORS_P(ATTR) \ - (TN_max_colors > 0 \ - ? (TN_no_color_video & (ATTR)) == 0 \ - : 1) +#define MAY_USE_WITH_COLORS_P(tty, ATTR) \ + (tty->TN_max_colors > 0 \ + ? (tty->TN_no_color_video & (ATTR)) == 0 \ + : 1) /* Turn appearances of face FACE_ID on tty frame F on. */ @@ -1827,12 +1768,13 @@ struct face *face = FACE_FROM_ID (f, face_id); long fg = face->foreground; long bg = face->background; + struct tty_display_info *tty = FRAME_TTY (f); /* Do this first because TS_end_standout_mode may be the same as TS_exit_attribute_mode, which turns all appearances off. */ - if (MAY_USE_WITH_COLORS_P (NC_REVERSE)) + if (MAY_USE_WITH_COLORS_P (tty, NC_REVERSE)) { - if (TN_max_colors > 0) + if (tty->TN_max_colors > 0) { if (fg >= 0 && bg >= 0) { @@ -1846,13 +1788,13 @@ { if (fg == FACE_TTY_DEFAULT_FG_COLOR || bg == FACE_TTY_DEFAULT_BG_COLOR) - toggle_highlight (); + toggle_highlight (tty); } else { if (fg == FACE_TTY_DEFAULT_BG_COLOR || bg == FACE_TTY_DEFAULT_FG_COLOR) - toggle_highlight (); + toggle_highlight (tty); } } else @@ -1863,53 +1805,53 @@ { if (fg == FACE_TTY_DEFAULT_FG_COLOR || bg == FACE_TTY_DEFAULT_BG_COLOR) - toggle_highlight (); + toggle_highlight (tty); } else { if (fg == FACE_TTY_DEFAULT_BG_COLOR || bg == FACE_TTY_DEFAULT_FG_COLOR) - toggle_highlight (); + toggle_highlight (tty); } } } if (face->tty_bold_p) { - if (MAY_USE_WITH_COLORS_P (NC_BOLD)) - OUTPUT1_IF (TS_enter_bold_mode); + if (MAY_USE_WITH_COLORS_P (tty, NC_BOLD)) + OUTPUT1_IF (tty, tty->TS_enter_bold_mode); } else if (face->tty_dim_p) - if (MAY_USE_WITH_COLORS_P (NC_DIM)) - OUTPUT1_IF (TS_enter_dim_mode); + if (MAY_USE_WITH_COLORS_P (tty, NC_DIM)) + OUTPUT1_IF (tty, tty->TS_enter_dim_mode); /* Alternate charset and blinking not yet used. */ if (face->tty_alt_charset_p - && MAY_USE_WITH_COLORS_P (NC_ALT_CHARSET)) - OUTPUT1_IF (TS_enter_alt_charset_mode); + && MAY_USE_WITH_COLORS_P (tty, NC_ALT_CHARSET)) + OUTPUT1_IF (tty, tty->TS_enter_alt_charset_mode); if (face->tty_blinking_p - && MAY_USE_WITH_COLORS_P (NC_BLINK)) - OUTPUT1_IF (TS_enter_blink_mode); - - if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (NC_UNDERLINE)) - OUTPUT1_IF (TS_enter_underline_mode); - - if (TN_max_colors > 0) + && MAY_USE_WITH_COLORS_P (tty, NC_BLINK)) + OUTPUT1_IF (tty, tty->TS_enter_blink_mode); + + if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE)) + OUTPUT1_IF (tty, tty->TS_enter_underline_mode); + + if (tty->TN_max_colors > 0) { char *p; - if (fg >= 0 && TS_set_foreground) + if (fg >= 0 && tty->TS_set_foreground) { - p = tparam (TS_set_foreground, NULL, 0, (int) fg); - OUTPUT (p); + p = tparam (tty->TS_set_foreground, NULL, 0, (int) fg); + OUTPUT (tty, p); xfree (p); } - if (bg >= 0 && TS_set_background) + if (bg >= 0 && tty->TS_set_background) { - p = tparam (TS_set_background, NULL, 0, (int) bg); - OUTPUT (p); + p = tparam (tty->TS_set_background, NULL, 0, (int) bg); + OUTPUT (tty, p); xfree (p); } } @@ -1924,10 +1866,11 @@ int face_id; { struct face *face = FACE_FROM_ID (f, face_id); + struct tty_display_info *tty = FRAME_TTY (f); xassert (face != NULL); - if (TS_exit_attribute_mode) + if (tty->TS_exit_attribute_mode) { /* Capability "me" will turn off appearance modes double-bright, half-bright, reverse-video, standout, underline. It may or @@ -1939,32 +1882,32 @@ || face->tty_blinking_p || face->tty_underline_p) { - OUTPUT1_IF (TS_exit_attribute_mode); - if (strcmp (TS_exit_attribute_mode, TS_end_standout_mode) == 0) - standout_mode = 0; + OUTPUT1_IF (tty, tty->TS_exit_attribute_mode); + if (strcmp (tty->TS_exit_attribute_mode, tty->TS_end_standout_mode) == 0) + tty->standout_mode = 0; } if (face->tty_alt_charset_p) - OUTPUT_IF (TS_exit_alt_charset_mode); + OUTPUT_IF (tty, tty->TS_exit_alt_charset_mode); } else { /* If we don't have "me" we can only have those appearances that have exit sequences defined. */ if (face->tty_alt_charset_p) - OUTPUT_IF (TS_exit_alt_charset_mode); + OUTPUT_IF (tty, tty->TS_exit_alt_charset_mode); if (face->tty_underline_p) - OUTPUT_IF (TS_exit_underline_mode); + OUTPUT_IF (tty, tty->TS_exit_underline_mode); } /* Switch back to default colors. */ - if (TN_max_colors > 0 + if (tty->TN_max_colors > 0 && ((face->foreground != FACE_TTY_DEFAULT_COLOR && face->foreground != FACE_TTY_DEFAULT_FG_COLOR) || (face->background != FACE_TTY_DEFAULT_COLOR && face->background != FACE_TTY_DEFAULT_BG_COLOR))) - OUTPUT1_IF (TS_orig_pair); + OUTPUT1_IF (tty, tty->TS_orig_pair); } @@ -1973,21 +1916,21 @@ colors FG and BG. */ int -tty_capable_p (f, caps, fg, bg) - struct frame *f; +tty_capable_p (tty, caps, fg, bg) + struct tty_display_info *tty; unsigned caps; unsigned long fg, bg; { -#define TTY_CAPABLE_P_TRY(cap, TS, NC_bit) \ - if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(NC_bit))) \ +#define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \ + if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(tty, NC_bit))) \ return 0; - TTY_CAPABLE_P_TRY (TTY_CAP_INVERSE, TS_standout_mode, NC_REVERSE); - TTY_CAPABLE_P_TRY (TTY_CAP_UNDERLINE, TS_enter_underline_mode, NC_UNDERLINE); - TTY_CAPABLE_P_TRY (TTY_CAP_BOLD, TS_enter_bold_mode, NC_BOLD); - TTY_CAPABLE_P_TRY (TTY_CAP_DIM, TS_enter_dim_mode, NC_DIM); - TTY_CAPABLE_P_TRY (TTY_CAP_BLINK, TS_enter_blink_mode, NC_BLINK); - TTY_CAPABLE_P_TRY (TTY_CAP_ALT_CHARSET, TS_enter_alt_charset_mode, NC_ALT_CHARSET); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_INVERSE, tty->TS_standout_mode, NC_REVERSE); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_UNDERLINE, tty->TS_enter_underline_mode, NC_UNDERLINE); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_BOLD, tty->TS_enter_bold_mode, NC_BOLD); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_DIM, tty->TS_enter_dim_mode, NC_DIM); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_BLINK, tty->TS_enter_blink_mode, NC_BLINK); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_ALT_CHARSET, tty->TS_enter_alt_charset_mode, NC_ALT_CHARSET); /* We can do it! */ return 1; @@ -2002,7 +1945,8 @@ (display) Lisp_Object display; { - return TN_max_colors > 0 ? Qt : Qnil; + struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ()); + return tty->TN_max_colors > 0 ? Qt : Qnil; } /* Return the number of supported colors. */ @@ -2012,7 +1956,8 @@ (display) Lisp_Object display; { - return make_number (TN_max_colors); + struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ()); + return make_number (tty->TN_max_colors); } #ifndef WINDOWSNT @@ -2020,8 +1965,7 @@ /* Save or restore the default color-related capabilities of this terminal. */ static void -tty_default_color_capabilities (save) - int save; +tty_default_color_capabilities (struct tty_display_info *tty, int save) { static char *default_orig_pair, *default_set_foreground, *default_set_background; @@ -2031,30 +1975,30 @@ { if (default_orig_pair) xfree (default_orig_pair); - default_orig_pair = TS_orig_pair ? xstrdup (TS_orig_pair) : NULL; + default_orig_pair = tty->TS_orig_pair ? xstrdup (tty->TS_orig_pair) : NULL; if (default_set_foreground) xfree (default_set_foreground); - default_set_foreground = TS_set_foreground ? xstrdup (TS_set_foreground) + default_set_foreground = tty->TS_set_foreground ? xstrdup (tty->TS_set_foreground) : NULL; if (default_set_background) xfree (default_set_background); - default_set_background = TS_set_background ? xstrdup (TS_set_background) + default_set_background = tty->TS_set_background ? xstrdup (tty->TS_set_background) : NULL; - default_max_colors = TN_max_colors; - default_max_pairs = TN_max_pairs; - default_no_color_video = TN_no_color_video; + default_max_colors = tty->TN_max_colors; + default_max_pairs = tty->TN_max_pairs; + default_no_color_video = tty->TN_no_color_video; } else { - TS_orig_pair = default_orig_pair; - TS_set_foreground = default_set_foreground; - TS_set_background = default_set_background; - TN_max_colors = default_max_colors; - TN_max_pairs = default_max_pairs; - TN_no_color_video = default_no_color_video; + tty->TS_orig_pair = default_orig_pair; + tty->TS_set_foreground = default_set_foreground; + tty->TS_set_background = default_set_background; + tty->TN_max_colors = default_max_colors; + tty->TN_max_pairs = default_max_pairs; + tty->TN_no_color_video = default_no_color_video; } } @@ -2063,8 +2007,7 @@ support; zero means set up for the default capabilities, the ones we saw at term_init time; -1 means turn off color support. */ void -tty_setup_colors (mode) - int mode; +tty_setup_colors (struct tty_display_info *tty, int mode) { /* Canonicalize all negative values of MODE. */ if (mode < -1) @@ -2073,27 +2016,27 @@ switch (mode) { case -1: /* no colors at all */ - TN_max_colors = 0; - TN_max_pairs = 0; - TN_no_color_video = 0; - TS_set_foreground = TS_set_background = TS_orig_pair = NULL; + tty->TN_max_colors = 0; + tty->TN_max_pairs = 0; + tty->TN_no_color_video = 0; + tty->TS_set_foreground = tty->TS_set_background = tty->TS_orig_pair = NULL; break; case 0: /* default colors, if any */ default: - tty_default_color_capabilities (0); + tty_default_color_capabilities (tty, 0); break; case 8: /* 8 standard ANSI colors */ - TS_orig_pair = "\033[0m"; + tty->TS_orig_pair = "\033[0m"; #ifdef TERMINFO - TS_set_foreground = "\033[3%p1%dm"; - TS_set_background = "\033[4%p1%dm"; + tty->TS_set_foreground = "\033[3%p1%dm"; + tty->TS_set_background = "\033[4%p1%dm"; #else - TS_set_foreground = "\033[3%dm"; - TS_set_background = "\033[4%dm"; + tty->TS_set_foreground = "\033[3%dm"; + tty->TS_set_background = "\033[4%dm"; #endif - TN_max_colors = 8; - TN_max_pairs = 64; - TN_no_color_video = 0; + tty->TN_max_colors = 8; + tty->TN_max_pairs = 64; + tty->TN_no_color_video = 0; break; } } @@ -2144,7 +2087,7 @@ if (mode != old_mode) { - tty_setup_colors (mode); + tty_setup_colors (FRAME_TTY (f), mode); /* This recomputes all the faces given the new color definitions. */ call0 (intern ("tty-set-up-initial-frame-faces")); @@ -2155,13 +2098,102 @@ #endif /* !WINDOWSNT */ + +struct tty_display_info * +get_named_tty (name) + char *name; +{ + struct tty_display_info *tty = tty_list; + + while (tty) { + if ((tty->name == 0 && name == 0) + || (name && tty->name && !strcmp (tty->name, name))) + return tty; + tty = tty->next; + }; + + return 0; +} + + + +DEFUN ("frame-tty-name", Fframe_tty_name, Sframe_tty_name, 0, 1, 0, + doc: /* Return the name of the TTY device that FRAME is displayed on. */) + (frame) + Lisp_Object frame; +{ + struct frame *f; + + if (NILP (frame)) + { + f = XFRAME (selected_frame); + } + else + { + CHECK_LIVE_FRAME (frame); + f = XFRAME (frame); + } + + if (f->output_method != output_termcap) + wrong_type_argument (Qframe_tty_name, frame); + + if (FRAME_TTY (f)->name) + return build_string (FRAME_TTY (f)->name); + else + return Qnil; +} + +DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0, + doc: /* Return the type of the TTY device that FRAME is displayed on. */) + (frame) + Lisp_Object frame; +{ + struct frame *f; + + if (NILP (frame)) + { + f = XFRAME (selected_frame); + } + else + { + CHECK_LIVE_FRAME (frame); + f = XFRAME (frame); + } + + if (f->output_method != output_termcap) + wrong_type_argument (Qframe_tty_type, frame); + + if (FRAME_TTY (f)->type) + return build_string (FRAME_TTY (f)->type); + else + return Qnil; +} + + /*********************************************************************** Initialization ***********************************************************************/ -void -term_init (terminal_type) - char *terminal_type; +struct tty_display_info * +term_dummy_init (void) +{ + if (initialized || tty_list) + error ("tty already initialized"); + + tty_list = xmalloc (sizeof (struct tty_display_info)); + bzero (tty_list, sizeof (struct tty_display_info)); + tty_list->name = 0; + tty_list->input = stdin; + tty_list->output = stdout; + tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); + tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); + tty_list->kboard = initial_kboard; + return tty_list; +} + + +struct tty_display_info * +term_init (Lisp_Object frame, char *name, char *terminal_type) { char *area; char **address = &area; @@ -2169,69 +2201,166 @@ int buffer_size = 4096; register char *p; int status; - struct frame *sf = XFRAME (selected_frame); + struct frame *f = XFRAME (frame); + struct tty_display_info *tty; + + tty = get_named_tty (name); + if (tty) + { + /* Return the previously initialized terminal, except if it is + the dummy terminal created for the initial frame. */ + if (tty->type) + return tty; + + /* Free up temporary structures. */ + if (tty->Wcm) + xfree (tty->Wcm); + if (tty->display_method) + xfree (tty->display_method); + if (tty->kboard != initial_kboard) + abort (); + tty->kboard = 0; + } + else + { + tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); + bzero (tty, sizeof (struct tty_display_info)); + tty->next = tty_list; + tty_list = tty; + } + + tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); + Wcm_clear (tty); + + /* Each termcap frame has its own display method. */ + tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); + bzero (tty->display_method, sizeof (struct display_method)); + + /* Initialize the common members in the new display method with our + predefined template. */ + *tty->display_method = tty_display_method_template; + f->display_method = tty->display_method; + + /* Make sure the frame is live; if an error happens, it must be + deleted. */ + f->output_method = output_termcap; + if (! f->output_data.tty) + abort (); + f->output_data.tty->display_info = tty; + if (name) + { + int fd; + FILE *file; + fd = emacs_open (name, O_RDWR, 0); + if (fd < 0) + { + delete_tty (tty); + error ("Could not open file: %s", name); + } + file = fdopen (fd, "w+"); + tty->name = xstrdup (name); + tty->input = file; + tty->output = file; + } + else + { + tty->name = 0; + tty->input = stdin; + tty->output = stdout; + } + + tty->type = xstrdup (terminal_type); + + add_keyboard_wait_descriptor (fileno (tty->input)); #ifdef WINDOWSNT initialize_w32_display (); - Wcm_clear (); + Wcm_clear (tty); area = (char *) xmalloc (2044); - FrameRows = FRAME_LINES (sf); - FrameCols = FRAME_COLS (sf); - specified_window = FRAME_LINES (sf); - - delete_in_insert_mode = 1; - - UseTabs = 0; - scroll_region_ok = 0; + FrameRows (tty) = FRAME_LINES (f); + FrameCols (tty) = FRAME_COLS (f); + tty->specified_window = FRAME_LINES (f); + + tty->display_method->delete_in_insert_mode = 1; + + UseTabs (tty) = 0; + FRAME_SCROLL_REGION_OK (f) = 0; /* Seems to insert lines when it's not supposed to, messing up the display. In doing a trace, it didn't seem to be called much, so I don't think we're losing anything by turning it off. */ - - line_ins_del_ok = 0; - char_ins_del_ok = 1; + FRAME_LINE_INS_DEL_OK (f) = 0; + FRAME_CHAR_INS_DEL_OK (f) = 1; baud_rate = 19200; - FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0; - FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none; + FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; + FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ - return; + return tty; #else /* not WINDOWSNT */ - Wcm_clear (); + Wcm_clear (tty); buffer = (char *) xmalloc (buffer_size); status = tgetent (buffer, terminal_type); if (status < 0) { #ifdef TERMINFO - fatal ("Cannot open terminfo database file"); + if (name) + { + xfree (buffer); + delete_tty (tty); + error ("Cannot open terminfo database file"); + } + else + fatal ("Cannot open terminfo database file"); #else - fatal ("Cannot open termcap database file"); + if (name) + { + xfree (buffer); + delete_tty (tty); + error ("Cannot open termcap database file"); + } + else + fatal ("Cannot open termcap database file"); #endif } if (status == 0) { #ifdef TERMINFO - fatal ("Terminal type %s is not defined.\n\ + if (name) + { + xfree (buffer); + delete_tty (tty); + error ("Terminal type %s is not defined", terminal_type); + } + else + fatal ("Terminal type %s is not defined.\n\ If that is not the actual type of terminal you have,\n\ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ `setenv TERM ...') to specify the correct type. It may be necessary\n\ to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", - terminal_type); + terminal_type); #else - fatal ("Terminal type %s is not defined.\n\ + if (name) + { + xfree (buffer); + delete_tty (tty); + error ("Terminal type %s is not defined", terminal_type); + } + else + fatal ("Terminal type %s is not defined.\n\ If that is not the actual type of terminal you have,\n\ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ `setenv TERM ...') to specify the correct type. It may be necessary\n\ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", - terminal_type); + terminal_type); #endif } @@ -2242,219 +2371,230 @@ #endif area = (char *) xmalloc (buffer_size); - TS_ins_line = tgetstr ("al", address); - TS_ins_multi_lines = tgetstr ("AL", address); - TS_bell = tgetstr ("bl", address); - BackTab = tgetstr ("bt", address); - TS_clr_to_bottom = tgetstr ("cd", address); - TS_clr_line = tgetstr ("ce", address); - TS_clr_frame = tgetstr ("cl", address); - ColPosition = NULL; /* tgetstr ("ch", address); */ - AbsPosition = tgetstr ("cm", address); - CR = tgetstr ("cr", address); - TS_set_scroll_region = tgetstr ("cs", address); - TS_set_scroll_region_1 = tgetstr ("cS", address); - RowPosition = tgetstr ("cv", address); - TS_del_char = tgetstr ("dc", address); - TS_del_multi_chars = tgetstr ("DC", address); - TS_del_line = tgetstr ("dl", address); - TS_del_multi_lines = tgetstr ("DL", address); - TS_delete_mode = tgetstr ("dm", address); - TS_end_delete_mode = tgetstr ("ed", address); - TS_end_insert_mode = tgetstr ("ei", address); - Home = tgetstr ("ho", address); - TS_ins_char = tgetstr ("ic", address); - TS_ins_multi_chars = tgetstr ("IC", address); - TS_insert_mode = tgetstr ("im", address); - TS_pad_inserted_char = tgetstr ("ip", address); - TS_end_keypad_mode = tgetstr ("ke", address); - TS_keypad_mode = tgetstr ("ks", address); - LastLine = tgetstr ("ll", address); - Right = tgetstr ("nd", address); - Down = tgetstr ("do", address); - if (!Down) - Down = tgetstr ("nl", address); /* Obsolete name for "do" */ + tty->TS_ins_line = tgetstr ("al", address); + tty->TS_ins_multi_lines = tgetstr ("AL", address); + tty->TS_bell = tgetstr ("bl", address); + BackTab (tty) = tgetstr ("bt", address); + tty->TS_clr_to_bottom = tgetstr ("cd", address); + tty->TS_clr_line = tgetstr ("ce", address); + tty->TS_clr_frame = tgetstr ("cl", address); + ColPosition (tty) = NULL; /* tgetstr ("ch", address); */ + AbsPosition (tty) = tgetstr ("cm", address); + CR (tty) = tgetstr ("cr", address); + tty->TS_set_scroll_region = tgetstr ("cs", address); + tty->TS_set_scroll_region_1 = tgetstr ("cS", address); + RowPosition (tty) = tgetstr ("cv", address); + tty->TS_del_char = tgetstr ("dc", address); + tty->TS_del_multi_chars = tgetstr ("DC", address); + tty->TS_del_line = tgetstr ("dl", address); + tty->TS_del_multi_lines = tgetstr ("DL", address); + tty->TS_delete_mode = tgetstr ("dm", address); + tty->TS_end_delete_mode = tgetstr ("ed", address); + tty->TS_end_insert_mode = tgetstr ("ei", address); + Home (tty) = tgetstr ("ho", address); + tty->TS_ins_char = tgetstr ("ic", address); + tty->TS_ins_multi_chars = tgetstr ("IC", address); + tty->TS_insert_mode = tgetstr ("im", address); + tty->TS_pad_inserted_char = tgetstr ("ip", address); + tty->TS_end_keypad_mode = tgetstr ("ke", address); + tty->TS_keypad_mode = tgetstr ("ks", address); + LastLine (tty) = tgetstr ("ll", address); + Right (tty) = tgetstr ("nd", address); + Down (tty) = tgetstr ("do", address); + if (!Down (tty)) + Down (tty) = tgetstr ("nl", address); /* Obsolete name for "do" */ #ifdef VMS /* VMS puts a carriage return before each linefeed, so it is not safe to use linefeeds. */ - if (Down && Down[0] == '\n' && Down[1] == '\0') - Down = 0; + if (Down (tty) && Down (tty)[0] == '\n' && Down (tty)[1] == '\0') + Down (tty) = 0; #endif /* VMS */ if (tgetflag ("bs")) - Left = "\b"; /* can't possibly be longer! */ + Left (tty) = "\b"; /* can't possibly be longer! */ else /* (Actually, "bs" is obsolete...) */ - Left = tgetstr ("le", address); - if (!Left) - Left = tgetstr ("bc", address); /* Obsolete name for "le" */ - TS_pad_char = tgetstr ("pc", address); - TS_repeat = tgetstr ("rp", address); - TS_end_standout_mode = tgetstr ("se", address); - TS_fwd_scroll = tgetstr ("sf", address); - TS_standout_mode = tgetstr ("so", address); - TS_rev_scroll = tgetstr ("sr", address); - Wcm.cm_tab = tgetstr ("ta", address); - TS_end_termcap_modes = tgetstr ("te", address); - TS_termcap_modes = tgetstr ("ti", address); - Up = tgetstr ("up", address); - TS_visible_bell = tgetstr ("vb", address); - TS_cursor_normal = tgetstr ("ve", address); - TS_cursor_visible = tgetstr ("vs", address); - TS_cursor_invisible = tgetstr ("vi", address); - TS_set_window = tgetstr ("wi", address); - - TS_enter_underline_mode = tgetstr ("us", address); - TS_exit_underline_mode = tgetstr ("ue", address); - TS_enter_bold_mode = tgetstr ("md", address); - TS_enter_dim_mode = tgetstr ("mh", address); - TS_enter_blink_mode = tgetstr ("mb", address); - TS_enter_reverse_mode = tgetstr ("mr", address); - TS_enter_alt_charset_mode = tgetstr ("as", address); - TS_exit_alt_charset_mode = tgetstr ("ae", address); - TS_exit_attribute_mode = tgetstr ("me", address); - - MultiUp = tgetstr ("UP", address); - MultiDown = tgetstr ("DO", address); - MultiLeft = tgetstr ("LE", address); - MultiRight = tgetstr ("RI", address); + Left (tty) = tgetstr ("le", address); + if (!Left (tty)) + Left (tty) = tgetstr ("bc", address); /* Obsolete name for "le" */ + tty->TS_pad_char = tgetstr ("pc", address); + tty->TS_repeat = tgetstr ("rp", address); + tty->TS_end_standout_mode = tgetstr ("se", address); + tty->TS_fwd_scroll = tgetstr ("sf", address); + tty->TS_standout_mode = tgetstr ("so", address); + tty->TS_rev_scroll = tgetstr ("sr", address); + tty->Wcm->cm_tab = tgetstr ("ta", address); + tty->TS_end_termcap_modes = tgetstr ("te", address); + tty->TS_termcap_modes = tgetstr ("ti", address); + Up (tty) = tgetstr ("up", address); + tty->TS_visible_bell = tgetstr ("vb", address); + tty->TS_cursor_normal = tgetstr ("ve", address); + tty->TS_cursor_visible = tgetstr ("vs", address); + tty->TS_cursor_invisible = tgetstr ("vi", address); + tty->TS_set_window = tgetstr ("wi", address); + + tty->TS_enter_underline_mode = tgetstr ("us", address); + tty->TS_exit_underline_mode = tgetstr ("ue", address); + tty->TS_enter_bold_mode = tgetstr ("md", address); + tty->TS_enter_dim_mode = tgetstr ("mh", address); + tty->TS_enter_blink_mode = tgetstr ("mb", address); + tty->TS_enter_reverse_mode = tgetstr ("mr", address); + tty->TS_enter_alt_charset_mode = tgetstr ("as", address); + tty->TS_exit_alt_charset_mode = tgetstr ("ae", address); + tty->TS_exit_attribute_mode = tgetstr ("me", address); + + MultiUp (tty) = tgetstr ("UP", address); + MultiDown (tty) = tgetstr ("DO", address); + MultiLeft (tty) = tgetstr ("LE", address); + MultiRight (tty) = tgetstr ("RI", address); /* SVr4/ANSI color suppert. If "op" isn't available, don't support color because we can't switch back to the default foreground and background. */ - TS_orig_pair = tgetstr ("op", address); - if (TS_orig_pair) + tty->TS_orig_pair = tgetstr ("op", address); + if (tty->TS_orig_pair) { - TS_set_foreground = tgetstr ("AF", address); - TS_set_background = tgetstr ("AB", address); - if (!TS_set_foreground) + tty->TS_set_foreground = tgetstr ("AF", address); + tty->TS_set_background = tgetstr ("AB", address); + if (!tty->TS_set_foreground) { /* SVr4. */ - TS_set_foreground = tgetstr ("Sf", address); - TS_set_background = tgetstr ("Sb", address); + tty->TS_set_foreground = tgetstr ("Sf", address); + tty->TS_set_background = tgetstr ("Sb", address); } - TN_max_colors = tgetnum ("Co"); - TN_max_pairs = tgetnum ("pa"); - - TN_no_color_video = tgetnum ("NC"); - if (TN_no_color_video == -1) - TN_no_color_video = 0; + tty->TN_max_colors = tgetnum ("Co"); + tty->TN_max_pairs = tgetnum ("pa"); + + tty->TN_no_color_video = tgetnum ("NC"); + if (tty->TN_no_color_video == -1) + tty->TN_no_color_video = 0; } - tty_default_color_capabilities (1); - - MagicWrap = tgetflag ("xn"); + tty_default_color_capabilities (tty, 1); + + MagicWrap (tty) = tgetflag ("xn"); /* Since we make MagicWrap terminals look like AutoWrap, we need to have the former flag imply the latter. */ - AutoWrap = MagicWrap || tgetflag ("am"); - memory_below_frame = tgetflag ("db"); - TF_hazeltine = tgetflag ("hz"); - must_write_spaces = tgetflag ("in"); - meta_key = tgetflag ("km") || tgetflag ("MT"); - TF_insmode_motion = tgetflag ("mi"); - TF_standout_motion = tgetflag ("ms"); - TF_underscore = tgetflag ("ul"); - TF_teleray = tgetflag ("xt"); + AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am"); + FRAME_MEMORY_BELOW_FRAME (f) = tgetflag ("db"); + tty->TF_hazeltine = tgetflag ("hz"); + FRAME_MUST_WRITE_SPACES (f) = tgetflag ("in"); + tty->meta_key = tgetflag ("km") || tgetflag ("MT"); + tty->TF_insmode_motion = tgetflag ("mi"); + tty->TF_standout_motion = tgetflag ("ms"); + tty->TF_underscore = tgetflag ("ul"); + tty->TF_teleray = tgetflag ("xt"); term_get_fkeys (address); /* Get frame size from system, or else from termcap. */ { int height, width; - get_frame_size (&width, &height); - FRAME_COLS (sf) = width; - FRAME_LINES (sf) = height; + get_tty_size (fileno (TTY_INPUT (tty)), &width, &height); + FrameCols (tty) = width; + FrameRows (tty) = height; } - if (FRAME_COLS (sf) <= 0) - SET_FRAME_COLS (sf, tgetnum ("co")); - else - /* Keep width and external_width consistent */ - SET_FRAME_COLS (sf, FRAME_COLS (sf)); - if (FRAME_LINES (sf) <= 0) - FRAME_LINES (sf) = tgetnum ("li"); - - if (FRAME_LINES (sf) < 3 || FRAME_COLS (sf) < 3) - fatal ("Screen size %dx%d is too small", - FRAME_LINES (sf), FRAME_COLS (sf)); - - min_padding_speed = tgetnum ("pb"); - TabWidth = tgetnum ("tw"); + if (FrameCols (tty) <= 0) + FrameCols (tty) = tgetnum ("co"); + if (FrameRows (tty) <= 0) + FrameRows (tty) = tgetnum ("li"); + + if (FrameRows (tty) < 3 || FrameCols (tty) < 3) + { + if (initialized) + { + delete_tty (tty); + error ("Screen size %dx%d is too small", + FrameCols (tty), FrameRows (tty)); + } + else + { + fatal ("Screen size %dx%d is too small", + FrameCols (tty), FrameRows (tty)); + } + } + +#if 0 /* This is not used anywhere. */ + tty->display_method->min_padding_speed = tgetnum ("pb"); +#endif + + TabWidth (tty) = tgetnum ("tw"); #ifdef VMS /* These capabilities commonly use ^J. I don't know why, but sending them on VMS does not work; it causes following spaces to be lost, sometimes. For now, the simplest fix is to avoid using these capabilities ever. */ - if (Down && Down[0] == '\n') - Down = 0; + if (Down (tty) && Down (tty)[0] == '\n') + Down (tty) = 0; #endif /* VMS */ - if (!TS_bell) - TS_bell = "\07"; - - if (!TS_fwd_scroll) - TS_fwd_scroll = Down; - - PC = TS_pad_char ? *TS_pad_char : 0; - - if (TabWidth < 0) - TabWidth = 8; + if (!tty->TS_bell) + tty->TS_bell = "\07"; + + if (!tty->TS_fwd_scroll) + tty->TS_fwd_scroll = Down (tty); + + PC = tty->TS_pad_char ? *tty->TS_pad_char : 0; + + if (TabWidth (tty) < 0) + TabWidth (tty) = 8; /* Turned off since /etc/termcap seems to have :ta= for most terminals and newer termcap doc does not seem to say there is a default. - if (!Wcm.cm_tab) - Wcm.cm_tab = "\t"; + if (!tty->Wcm->cm_tab) + tty->Wcm->cm_tab = "\t"; */ /* We don't support standout modes that use `magic cookies', so turn off any that do. */ - if (TS_standout_mode && tgetnum ("sg") >= 0) + if (tty->TS_standout_mode && tgetnum ("sg") >= 0) { - TS_standout_mode = 0; - TS_end_standout_mode = 0; + tty->TS_standout_mode = 0; + tty->TS_end_standout_mode = 0; } - if (TS_enter_underline_mode && tgetnum ("ug") >= 0) + if (tty->TS_enter_underline_mode && tgetnum ("ug") >= 0) { - TS_enter_underline_mode = 0; - TS_exit_underline_mode = 0; + tty->TS_enter_underline_mode = 0; + tty->TS_exit_underline_mode = 0; } /* If there's no standout mode, try to use underlining instead. */ - if (TS_standout_mode == 0) + if (tty->TS_standout_mode == 0) { - TS_standout_mode = TS_enter_underline_mode; - TS_end_standout_mode = TS_exit_underline_mode; + tty->TS_standout_mode = tty->TS_enter_underline_mode; + tty->TS_end_standout_mode = tty->TS_exit_underline_mode; } /* If no `se' string, try using a `me' string instead. If that fails, we can't use standout mode at all. */ - if (TS_end_standout_mode == 0) + if (tty->TS_end_standout_mode == 0) { char *s = tgetstr ("me", address); if (s != 0) - TS_end_standout_mode = s; + tty->TS_end_standout_mode = s; else - TS_standout_mode = 0; + tty->TS_standout_mode = 0; } - if (TF_teleray) + if (tty->TF_teleray) { - Wcm.cm_tab = 0; + tty->Wcm->cm_tab = 0; /* We can't support standout mode, because it uses magic cookies. */ - TS_standout_mode = 0; + tty->TS_standout_mode = 0; /* But that means we cannot rely on ^M to go to column zero! */ - CR = 0; + CR (tty) = 0; /* LF can't be trusted either -- can alter hpos */ /* if move at column 0 thru a line with TS_standout_mode */ - Down = 0; + Down (tty) = 0; } /* Special handling for certain terminal types known to need it */ if (!strcmp (terminal_type, "supdup")) { - memory_below_frame = 1; - Wcm.cm_losewrap = 1; + FRAME_MEMORY_BELOW_FRAME (f) = 1; + tty->Wcm->cm_losewrap = 1; } if (!strncmp (terminal_type, "c10", 3) || !strcmp (terminal_type, "perq")) @@ -2471,102 +2611,150 @@ It would be simpler if the :wi string could go in the termcap entry, but it can't because it is not fully valid. If it were in the termcap entry, it would confuse other programs. */ - if (!TS_set_window) + if (!tty->TS_set_window) { - p = TS_termcap_modes; + p = tty->TS_termcap_modes; while (*p && strcmp (p, "\033v ")) p++; if (*p) - TS_set_window = "\033v%C %C %C %C "; + tty->TS_set_window = "\033v%C %C %C %C "; } /* Termcap entry often fails to have :in: flag */ - must_write_spaces = 1; + FRAME_MUST_WRITE_SPACES (f) = 1; /* :ti string typically fails to have \E^G! in it */ /* This limits scope of insert-char to one line. */ - strcpy (area, TS_termcap_modes); + strcpy (area, tty->TS_termcap_modes); strcat (area, "\033\007!"); - TS_termcap_modes = area; + tty->TS_termcap_modes = area; area += strlen (area) + 1; - p = AbsPosition; + p = AbsPosition (tty); /* Change all %+ parameters to %C, to handle - values above 96 correctly for the C100. */ + values above 96 correctly for the C100. */ while (*p) - { - if (p[0] == '%' && p[1] == '+') - p[1] = 'C'; - p++; - } + { + if (p[0] == '%' && p[1] == '+') + p[1] = 'C'; + p++; + } } - FrameRows = FRAME_LINES (sf); - FrameCols = FRAME_COLS (sf); - specified_window = FRAME_LINES (sf); - - if (Wcm_init () == -1) /* can't do cursor motion */ + tty->specified_window = FrameRows (tty); + + if (Wcm_init (tty) == -1) /* can't do cursor motion */ + if (name) + { + delete_tty (tty); + error ("Terminal type \"%s\" is not powerful enough to run Emacs", + terminal_type); + } + else { #ifdef VMS - fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ + fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ It lacks the ability to position the cursor.\n\ If that is not the actual type of terminal you have, use either the\n\ DCL command `SET TERMINAL/DEVICE= ...' for DEC-compatible terminals,\n\ or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.", - terminal_type); + terminal_type); #else /* not VMS */ # ifdef TERMINFO - fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ + fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ It lacks the ability to position the cursor.\n\ If that is not the actual type of terminal you have,\n\ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ `setenv TERM ...') to specify the correct type. It may be necessary\n\ to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", - terminal_type); + terminal_type); # else /* TERMCAP */ - fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ + fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ It lacks the ability to position the cursor.\n\ If that is not the actual type of terminal you have,\n\ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ `setenv TERM ...') to specify the correct type. It may be necessary\n\ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", - terminal_type); + terminal_type); # endif /* TERMINFO */ #endif /*VMS */ - if (FRAME_LINES (sf) <= 0 - || FRAME_COLS (sf) <= 0) - fatal ("The frame size has not been specified"); - - delete_in_insert_mode - = TS_delete_mode && TS_insert_mode - && !strcmp (TS_delete_mode, TS_insert_mode); - - se_is_so = (TS_standout_mode - && TS_end_standout_mode - && !strcmp (TS_standout_mode, TS_end_standout_mode)); - - UseTabs = tabs_safe_p () && TabWidth == 8; - - scroll_region_ok - = (Wcm.cm_abs - && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1)); - - line_ins_del_ok = (((TS_ins_line || TS_ins_multi_lines) - && (TS_del_line || TS_del_multi_lines)) - || (scroll_region_ok && TS_fwd_scroll && TS_rev_scroll)); - - char_ins_del_ok = ((TS_ins_char || TS_insert_mode - || TS_pad_inserted_char || TS_ins_multi_chars) - && (TS_del_char || TS_del_multi_chars)); - - fast_clear_end_of_line = TS_clr_line != 0; - - init_baud_rate (); - if (read_socket_hook) /* Baudrate is somewhat */ - /* meaningless in this case */ + } + + if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) + { + if (name) + { + delete_tty (tty); + error ("The frame size has not been specified"); + } + else + fatal ("The frame size has not been specified"); + } + + tty->delete_in_insert_mode + = tty->TS_delete_mode && tty->TS_insert_mode + && !strcmp (tty->TS_delete_mode, tty->TS_insert_mode); + + tty->se_is_so = (tty->TS_standout_mode + && tty->TS_end_standout_mode + && !strcmp (tty->TS_standout_mode, tty->TS_end_standout_mode)); + + UseTabs (tty) = tabs_safe_p (fileno (TTY_INPUT (tty))) && TabWidth (tty) == 8; + + FRAME_SCROLL_REGION_OK (f) + = (tty->Wcm->cm_abs + && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1)); + + FRAME_LINE_INS_DEL_OK (f) + = (((tty->TS_ins_line || tty->TS_ins_multi_lines) + && (tty->TS_del_line || tty->TS_del_multi_lines)) + || (FRAME_SCROLL_REGION_OK (f) + && tty->TS_fwd_scroll && tty->TS_rev_scroll)); + + FRAME_CHAR_INS_DEL_OK (f) + = ((tty->TS_ins_char || tty->TS_insert_mode + || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars) + && (tty->TS_del_char || tty->TS_del_multi_chars)); + + FRAME_FAST_CLEAR_END_OF_LINE (f) = tty->TS_clr_line != 0; + + init_baud_rate (fileno (TTY_INPUT (tty))); + if (read_socket_hook) /* Baudrate is somewhat + meaningless in this case */ baud_rate = 9600; - FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0; - FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none; -#endif /* WINDOWSNT */ - - xfree (buffer); + FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; + FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; + +#ifdef AIXHFT + /* The HFT system on AIX doesn't optimize for scrolling, so it's + really ugly at times. */ + FRAME_LINE_INS_DEL_OK (f) = 0; + FRAME_CHAR_INS_DEL_OK (f) = 0; +#endif + +#ifdef MULTI_KBOARD + tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); + init_kboard (tty->kboard); + tty->kboard->next_kboard = all_kboards; + all_kboards = tty->kboard; + /* Don't let the initial kboard remain current longer than necessary. + That would cause problems if a file loaded on startup tries to + prompt in the mini-buffer. */ + if (current_kboard == initial_kboard) + current_kboard = tty->kboard; + tty->kboard->reference_count++; +#endif + + /* Don't do this. I think termcap may still need the buffer. */ + /* xfree (buffer); */ + + /* Set the top frame to the first frame on this display. */ + tty->top_frame = frame; + + /* Init system terminal modes (RAW or CBREAK, etc.). */ + init_sys_modes (tty); + + tty_set_terminal_modes (tty); + + return tty; +#endif /* not WINDOWSNT */ } /* VARARGS 1 */ @@ -2581,6 +2769,131 @@ exit (1); } + + +DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0, + doc: /* Delete all frames on the terminal named TTY, and close the device. */) + (tty) + Lisp_Object tty; +{ + struct tty_display_info *t; + char *name = 0; + + CHECK_STRING (tty); + + if (SBYTES (tty) > 0) + { + name = (char *) alloca (SBYTES (tty) + 1); + strncpy (name, SDATA (tty), SBYTES (tty)); + name[SBYTES (tty)] = 0; + } + + t = get_named_tty (name); + + if (! t) + error ("No such tty device: %s", name); + + delete_tty (t); +} + +static int deleting_tty = 0; + +void +delete_tty (struct tty_display_info *tty) +{ + Lisp_Object tail, frame; + + if (deleting_tty) + /* We get a recursive call when we delete the last frame on this + tty. */ + return; + + deleting_tty = 1; + + if (tty == tty_list) + tty_list = tty->next; + else + { + struct tty_display_info *p; + for (p = tty_list; p && p->next != tty; p = p->next) + ; + + if (! p) + /* This should not happen. */ + abort (); + + p->next = tty->next; + tty->next = 0; + } + + FOR_EACH_FRAME (tail, frame) + { + struct frame *f = XFRAME (frame); + if (FRAME_TERMCAP_P (f) && FRAME_LIVE_P (f) && FRAME_TTY (f) == tty) + { + Fdelete_frame (frame, Qt); + f->output_data.tty = 0; + } + } + + reset_sys_modes (tty); + + if (tty->name) + xfree (tty->name); + if (tty->type) + xfree (tty->type); + + if (tty->input) + { + delete_keyboard_wait_descriptor (fileno (tty->input)); + if (tty->input != stdin) + fclose (tty->input); + } + if (tty->output && tty->output != stdout && tty->output != tty->input) + fclose (tty->output); + if (tty->termscript) + fclose (tty->termscript); + + if (tty->old_tty) + xfree (tty->old_tty); + + if (tty->Wcm) + xfree (tty->Wcm); + + if (tty->display_method) + xfree (tty->display_method); + +#ifdef MULTI_KBOARD + if (tty->kboard && --tty->kboard->reference_count > 0) + abort (); + if (tty->kboard) + delete_kboard (tty->kboard); +#endif + + bzero (tty, sizeof (struct tty_display_info)); + xfree (tty); + deleting_tty = 0; +} + + + + +/* Mark the pointers in the tty_display_info objects. + Called by the Fgarbage_collector. */ +void +mark_ttys () +{ + struct tty_display_info *tty; + Lisp_Object *p; + for (tty = tty_list; tty; tty = tty->next) + { + if (tty->top_frame) + mark_object (tty->top_frame); + } +} + + + void syms_of_term () { @@ -2598,9 +2911,28 @@ The function should accept no arguments. */); Vring_bell_function = Qnil; + Qframe_tty_name = intern ("frame-tty-name"); + staticpro (&Qframe_tty_name); + + Qframe_tty_type = intern ("frame-tty-type"); + staticpro (&Qframe_tty_type); + defsubr (&Stty_display_color_p); defsubr (&Stty_display_color_cells); + defsubr (&Sframe_tty_name); + defsubr (&Sframe_tty_type); + defsubr (&Sdelete_tty); + + Fprovide (intern ("multi-tty"), Qnil); + + /* Initialize the display method template. */ + + /* Termcap-based displays don't support window-based redisplay. */ + tty_display_method_template.rif = 0; + } + + /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 (do not change this comment) */
--- a/src/termchar.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/termchar.h Fri Jan 02 04:37:46 2004 +0000 @@ -1,5 +1,5 @@ /* Flags and parameters describing terminal's characteristics. - Copyright (C) 1985, 1986 Free Software Foundation, Inc. + Copyright (C) 1985, 1986, 2003 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,32 +18,191 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Each termcap frame points to its own struct tty_output object in + the output_data.tty field. The tty_output structure contains the + information that is specific to termcap frames. */ +struct tty_output +{ + /* The Emacs structure for the tty device this frame is on. */ + struct tty_display_info *display_info; -/* extern EMACS_INT baud_rate; */ /* Output speed in baud */ -extern int must_write_spaces; /* Nonzero means spaces in the text - must actually be output; can't just skip - over some columns to leave them blank. */ -extern int min_padding_speed; /* Speed below which no padding necessary */ -extern int fast_clear_end_of_line; /* Nonzero means terminal has - command for this */ + /* There is nothing else here at the moment... */ +}; + +/* Parameters that are shared between frames on the same tty device. */ +struct tty_display_info +{ + struct tty_display_info *next; /* Chain of all tty devices. */ + + char *name; /* The name of the device file or 0 if + stdin/stdout. */ + char *type; /* The type of the tty. */ + + /* Input/output */ + + FILE *input; /* The stream to be used for terminal input. */ + FILE *output; /* The stream to be used for terminal output. */ + + FILE *termscript; /* If nonzero, send all terminal output + characters to this stream also. */ + + struct emacs_tty *old_tty; /* The initial tty mode bits */ + + int term_initted; /* 1 if we have been through init_sys_modes. */ + + + int reference_count; /* Number of frames that are on this display. */ + + /* Info on cursor positioning. */ + struct cm *Wcm; + + /* Redisplay. */ + + /* XXX GC does not know about this; is this a problem? */ + Lisp_Object top_frame; /* The topmost frame on this tty. */ + + /* The previous terminal frame we displayed on this tty. */ + struct frame *previous_terminal_frame; + + /* Strings, numbers and flags taken from the termcap entry. */ + + char *TS_ins_line; /* "al" */ + char *TS_ins_multi_lines; /* "AL" (one parameter, # lines to insert) */ + char *TS_bell; /* "bl" */ + char *TS_clr_to_bottom; /* "cd" */ + char *TS_clr_line; /* "ce", clear to end of line */ + char *TS_clr_frame; /* "cl" */ + char *TS_set_scroll_region; /* "cs" (2 params, first line and last line) */ + char *TS_set_scroll_region_1; /* "cS" (4 params: total lines, + lines above scroll region, lines below it, + total lines again) */ + char *TS_del_char; /* "dc" */ + char *TS_del_multi_chars; /* "DC" (one parameter, # chars to delete) */ + char *TS_del_line; /* "dl" */ + char *TS_del_multi_lines; /* "DL" (one parameter, # lines to delete) */ + char *TS_delete_mode; /* "dm", enter character-delete mode */ + char *TS_end_delete_mode; /* "ed", leave character-delete mode */ + char *TS_end_insert_mode; /* "ei", leave character-insert mode */ + char *TS_ins_char; /* "ic" */ + char *TS_ins_multi_chars; /* "IC" (one parameter, # chars to insert) */ + char *TS_insert_mode; /* "im", enter character-insert mode */ + char *TS_pad_inserted_char; /* "ip". Just padding, no commands. */ + char *TS_end_keypad_mode; /* "ke" */ + char *TS_keypad_mode; /* "ks" */ + char *TS_pad_char; /* "pc", char to use as padding */ + char *TS_repeat; /* "rp" (2 params, # times to repeat + and character to be repeated) */ + char *TS_end_standout_mode; /* "se" */ + char *TS_fwd_scroll; /* "sf" */ + char *TS_standout_mode; /* "so" */ + char *TS_rev_scroll; /* "sr" */ + char *TS_end_termcap_modes; /* "te" */ + char *TS_termcap_modes; /* "ti" */ + char *TS_visible_bell; /* "vb" */ + char *TS_cursor_normal; /* "ve" */ + char *TS_cursor_visible; /* "vs" */ + char *TS_cursor_invisible; /* "vi" */ + char *TS_set_window; /* "wi" (4 params, start and end of window, + each as vpos and hpos) */ -extern int line_ins_del_ok; /* Terminal can insert and delete lines */ -extern int char_ins_del_ok; /* Terminal can insert and delete chars */ -extern int scroll_region_ok; /* Terminal supports setting the scroll - window */ -extern int scroll_region_cost; /* Cost of setting the scroll window, - measured in characters */ -extern int memory_below_frame; /* Terminal remembers lines scrolled - off bottom */ -extern int fast_clear_end_of_line; /* Terminal has a `ce' string */ + char *TS_enter_bold_mode; /* "md" -- turn on bold (extra bright mode). */ + char *TS_enter_dim_mode; /* "mh" -- turn on half-bright mode. */ + char *TS_enter_blink_mode; /* "mb" -- enter blinking mode. */ + char *TS_enter_reverse_mode; /* "mr" -- enter reverse video mode. */ + char *TS_exit_underline_mode; /* "us" -- start underlining. */ + char *TS_enter_underline_mode; /* "ue" -- end underlining. */ + + /* "as"/"ae" -- start/end alternate character set. Not really + supported, yet. */ + char *TS_enter_alt_charset_mode; + char *TS_exit_alt_charset_mode; + + char *TS_exit_attribute_mode; /* "me" -- switch appearances off. */ + + /* Value of the "NC" (no_color_video) capability, or 0 if not present. */ + int TN_no_color_video; + + int TN_max_colors; /* "Co" -- number of colors. */ + + /* "pa" -- max. number of color pairs on screen. Not handled yet. + Could be a problem if not equal to TN_max_colors * TN_max_colors. */ + int TN_max_pairs; + + /* "op" -- SVr4 set default pair to its original value. */ + char *TS_orig_pair; + + /* "AF"/"AB" or "Sf"/"Sb"-- set ANSI or SVr4 foreground/background color. + 1 param, the color index. */ + char *TS_set_foreground; + char *TS_set_background; + + int TF_hazeltine; /* termcap hz flag. */ + int TF_insmode_motion; /* termcap mi flag: can move while in insert mode. */ + int TF_standout_motion; /* termcap mi flag: can move while in standout mode. */ + int TF_underscore; /* termcap ul flag: _ underlines if over-struck on + non-blank position. Must clear before writing _. */ + int TF_teleray; /* termcap xt flag: many weird consequences. + For t1061. */ + + int RPov; /* # chars to start a TS_repeat */ -extern int dont_calculate_costs; /* Nonzero means don't bother computing - various cost tables; we won't use them. */ + int delete_in_insert_mode; /* delete mode == insert mode */ + + int se_is_so; /* 1 if same string both enters and leaves + standout mode */ + + int costs_set; /* Nonzero if costs have been calculated. */ + + int insert_mode; /* Nonzero when in insert mode. */ + int standout_mode; /* Nonzero when in standout mode. */ + + + + /* 1 if should obey 0200 bit in input chars as "Meta", 2 if should + keep 0200 bit in input chars. 0 to ignore the 0200 bit. */ + + int meta_key; + + /* Size of window specified by higher levels. + This is the number of lines, from the top of frame downwards, + which can participate in insert-line/delete-line operations. + + Effectively it excludes the bottom frame_lines - specified_window_size + lines from those operations. */ + + int specified_window; + + /* Flag used in tty_show/hide_cursor. */ -/* Nonzero means no need to redraw the entire frame on resuming - a suspended Emacs. This is useful on terminals with multiple pages, - where one page is used for Emacs and another for all else. */ -extern int no_redraw_on_reenter; + int cursor_hidden; + + /* Nonzero means use ^S/^Q for flow control. */ + int flow_control; + + /* This is a copy of struct frame's display_method value; needed for + freeing up memory when deleting the tty. */ + struct display_method *display_method; + +#ifdef MULTI_KBOARD + /* The terminal's keyboard object. */ + struct kboard *kboard; +#endif +}; + +/* A chain of structures for all tty devices currently in use. */ +extern struct tty_display_info *tty_list; + + +#define FRAME_TTY(f) \ + ((f)->output_method == output_termcap \ + ? (f)->output_data.tty->display_info \ + : (abort(), (struct tty_display_info *) 0)) + +#define CURTTY() FRAME_TTY (SELECTED_FRAME()) + +#define TTY_INPUT(t) ((t)->input) +#define TTY_OUTPUT(t) ((t)->output) +#define TTY_TERMSCRIPT(t) ((t)->termscript) /* arch-tag: bf9f0d49-842b-42fb-9348-ec8759b27193 (do not change this comment) */
--- a/src/termhooks.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/termhooks.h Fri Jan 02 04:37:46 2004 +0000 @@ -25,14 +25,54 @@ struct glyph; struct frame; -/* If nonzero, send all terminal output characters to this stream also. */ -extern FILE *termscript; - /* Only use prototypes when lisp.h has been included. */ #ifndef P_ #define P_(X) () #endif +/* Device-local parameters. */ +struct display_method +{ + /* Terminal characteristics. */ + + int must_write_spaces; /* Nonzero means spaces in the text must + actually be output; can't just skip over + some columns to leave them blank. */ + int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */ + + int line_ins_del_ok; /* Terminal can insert and delete lines */ + int char_ins_del_ok; /* Terminal can insert and delete chars */ + int scroll_region_ok; /* Terminal supports setting the scroll + window */ + int scroll_region_cost; /* Cost of setting the scroll window, + measured in characters. */ + int memory_below_frame; /* Terminal remembers lines scrolled + off bottom */ + +#if 0 /* These are not used anywhere. */ + /* EMACS_INT baud_rate; */ /* Output speed in baud */ + int min_padding_speed; /* Speed below which no padding necessary. */ + int dont_calculate_costs; /* Nonzero means don't bother computing + various cost tables; we won't use them. */ +#endif + + /* Window-based redisplay interface for this frame (0 for termcap + frames). */ + struct redisplay_interface *rif; + + /* XXX Display hooks will go here. */ +}; + +#define FRAME_MUST_WRITE_SPACES(f) ((f)->display_method->must_write_spaces) +#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->display_method->fast_clear_end_of_line) +#define FRAME_LINE_INS_DEL_OK(f) ((f)->display_method->line_ins_del_ok) +#define FRAME_CHAR_INS_DEL_OK(f) ((f)->display_method->char_ins_del_ok) +#define FRAME_SCROLL_REGION_OK(f) ((f)->display_method->scroll_region_ok) +#define FRAME_SCROLL_REGION_COST(f) ((f)->display_method->scroll_region_cost) +#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->display_method->memory_below_frame) + +#define FRAME_RIF(f) ((f)->display_method->rif) + /* Text display hooks. */ extern void (*cursor_to_hook) P_ ((int vpos, int hpos)); @@ -374,7 +414,7 @@ #define EVENT_INIT(event) bzero (&(event), sizeof (struct input_event)) /* Called to read input events. */ -extern int (*read_socket_hook) P_ ((int, struct input_event *, int, int)); +extern int (*read_socket_hook) P_ ((struct input_event *, int, int)); /* Called when a frame's display becomes entirely up to date. */ extern void (*frame_up_to_date_hook) P_ ((struct frame *)); @@ -429,7 +469,7 @@ meta_modifier = CHAR_META /* Under X, the XK_Meta_[LR] keysyms. */ }; -#endif +#endif /* CONSP */ /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d (do not change this comment) */
--- a/src/termopts.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/termopts.h Fri Jan 02 04:37:46 2004 +0000 @@ -40,5 +40,10 @@ /* Nonzero means truncate lines in all windows less wide than the frame */ extern int truncate_partial_width_windows; +/* Nonzero means no need to redraw the entire frame on resuming a suspended + Emacs. This is useful on terminals with multiple pages, where one page is + used for Emacs and another for all else. */ +extern int no_redraw_on_reenter; + /* arch-tag: 35d4d284-dc1a-4fff-97fa-0154a21aebdb (do not change this comment) */
--- a/src/w32inevt.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/w32inevt.c Fri Jan 02 04:37:46 2004 +0000 @@ -642,7 +642,7 @@ } int -w32_console_read_socket (int sd, struct input_event *bufp, int numchars, +w32_console_read_socket (struct input_event *bufp, int numchars, int expected) { BOOL no_events = TRUE;
--- a/src/w32term.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/w32term.c Fri Jan 02 04:37:46 2004 +0000 @@ -4076,8 +4076,7 @@ */ int -w32_read_socket (sd, bufp, numchars, expected) - register int sd; +w32_read_socket (bufp, numchars, expected) /* register */ struct input_event *bufp; /* register */ int numchars; int expected; @@ -6364,12 +6363,13 @@ redeem_scroll_bar_hook = w32_redeem_scroll_bar; judge_scroll_bars_hook = w32_judge_scroll_bars; - scroll_region_ok = 1; /* we'll scroll partial frames */ - char_ins_del_ok = 1; - line_ins_del_ok = 1; /* we'll just blt 'em */ - fast_clear_end_of_line = 1; /* X does this well */ - memory_below_frame = 0; /* we don't remember what scrolls - off the bottom */ + TTY_SCROLL_REGION_OK (CURTTY ()) = 1; /* we'll scroll partial frames */ + TTY_CHAR_INS_DEL_OK (CURTTY ()) = 1; + TTY_LINE_INS_DEL_OK (CURTTY ()) = 1; /* we'll just blt 'em */ + TTY_FAST_CLEAR_END_OF_LINE (CURTTY ()) = 1; /* X does this well */ + TTY_MEMORY_BELOW_FRAME (CURTTY ()) = 0; /* we don't remember what + scrolls off the + bottom */ baud_rate = 19200; w32_system_caret_hwnd = NULL;
--- a/src/w32term.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/w32term.h Fri Jan 02 04:37:46 2004 +0000 @@ -389,8 +389,6 @@ #define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc) #define FRAME_X_WINDOW(f) ((f)->output_data.w32->window_desc) -#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel) -#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel) #define FRAME_FONT(f) ((f)->output_data.w32->font) #define FRAME_FONTSET(f) ((f)->output_data.w32->fontset) #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset)
--- a/src/window.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/window.c Fri Jan 02 04:37:46 2004 +0000 @@ -29,6 +29,7 @@ #include "window.h" #include "commands.h" #include "indent.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "disptab.h" #include "dispextern.h" @@ -6381,7 +6382,7 @@ void init_window_once () { - struct frame *f = make_terminal_frame (); + struct frame *f = make_terminal_frame (0, 0); XSETFRAME (selected_frame, f); Vterminal_frame = selected_frame; minibuf_window = f->minibuffer_window;
--- a/src/xdisp.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/xdisp.c Fri Jan 02 04:37:46 2004 +0000 @@ -173,6 +173,7 @@ #include "keyboard.h" #include "frame.h" #include "window.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "dispextern.h" #include "buffer.h" @@ -742,10 +743,6 @@ #define CLEAR_FACE_CACHE_COUNT 500 static int clear_face_cache_count; -/* Record the previous terminal frame we displayed. */ - -static struct frame *previous_terminal_frame; - /* Non-zero while redisplay_internal is in progress. */ int redisplaying_p; @@ -2011,7 +2008,7 @@ XSETWINDOW (it->window, w); it->w = w; it->f = XFRAME (w->frame); - + /* Extra space between lines (on window systems only). */ if (base_face_id == DEFAULT_FACE_ID && FRAME_WINDOW_P (it->f)) @@ -2024,7 +2021,7 @@ /* If realized faces have been removed, e.g. because of face attribute changes of named faces, recompute them. When running - in batch mode, the face cache of Vterminal_frame is null. If + in batch mode, the face cache of the initial frame is null. If we happen to get called, make a dummy face cache. */ if (noninteractive && FRAME_FACE_CACHE (it->f) == NULL) init_frame_faces (it->f); @@ -7571,11 +7568,11 @@ { Lisp_Object tail, frame; int changed_count = 0; - + FOR_EACH_FRAME (tail, frame) { struct frame *f = XFRAME (frame); - + if (FRAME_VISIBLE_P (f) && FRAME_GARBAGED_P (f)) { if (f->resized_p) @@ -7586,7 +7583,7 @@ f->resized_p = 0; } } - + frame_garbaged = 0; if (changed_count) ++windows_or_buffers_changed; @@ -7622,7 +7619,7 @@ /* When Emacs starts, selected_frame may be a visible terminal frame, even if we run under a window system. If we let this through, a message would be displayed on the terminal. */ - if (EQ (selected_frame, Vterminal_frame) + if (!FRAME_WINDOW_P (XFRAME (selected_frame)) && !NILP (Vwindow_system)) return 0; #endif /* HAVE_WINDOW_SYSTEM */ @@ -7674,7 +7671,7 @@ Can do with a display update of the echo area, unless we displayed some mode lines. */ update_single_window (w, 1); - rif->flush_display (f); + FRAME_RIF (f)->flush_display (f); } else update_frame (f, 1, 1); @@ -8135,8 +8132,8 @@ { BLOCK_INPUT; display_and_set_cursor (w, 1, hpos, vpos, x, y); - if (rif->flush_display_optional) - rif->flush_display_optional (SELECTED_FRAME ()); + if (FRAME_RIF (SELECTED_FRAME ())->flush_display_optional) + FRAME_RIF (SELECTED_FRAME ())->flush_display_optional (SELECTED_FRAME ()); UNBLOCK_INPUT; } } @@ -9029,7 +9026,7 @@ /* Adjust y to the offset in the row to start drawing the bitmap. */ p.y += (row->height - p.h) / 2; - rif->draw_fringe_bitmap (w, row, &p); + FRAME_RIF (f)->draw_fringe_bitmap (w, row, &p); } /* Draw fringe bitmaps for glyph row ROW on window W. Call this @@ -9583,7 +9580,7 @@ { Lisp_Object tail, sym, val; Lisp_Object old = selected_frame; - + selected_frame = frame; for (tail = XFRAME (frame)->param_alist; CONSP (tail); tail = XCDR (tail)) @@ -9699,17 +9696,16 @@ if (face_change_count) ++windows_or_buffers_changed; - if (! FRAME_WINDOW_P (sf) - && previous_terminal_frame != sf) - { - /* Since frames on an ASCII terminal share the same display - area, displaying a different frame means redisplay the whole - thing. */ + if (FRAME_TERMCAP_P (sf) + && FRAME_TTY (sf)->previous_terminal_frame != sf) + { + /* Since frames on a single ASCII terminal share the same + display area, displaying a different frame means redisplay + the whole thing. */ windows_or_buffers_changed++; SET_FRAME_GARBAGED (sf); - XSETFRAME (Vterminal_frame, sf); - } - previous_terminal_frame = sf; + FRAME_TTY (sf)->previous_terminal_frame = sf; + } /* Set the visible flags for all frames. Do this before checking for resized or garbaged frames; they want to know if their frames @@ -9731,6 +9727,7 @@ } } + /* Notice any pending interrupt request to change frame size. */ do_pending_window_change (1); @@ -10088,7 +10085,7 @@ { struct frame *f = XFRAME (frame); - if (FRAME_WINDOW_P (f) || f == sf) + if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) { if (! EQ (frame, selected_frame)) /* Select the frame, for the sake of frame-local @@ -12303,10 +12300,10 @@ if (run.height > 0 && run.current_y != run.desired_y) { update_begin (f); - rif->update_window_begin_hook (w); - rif->clear_window_mouse_face (w); - rif->scroll_run_hook (w, &run); - rif->update_window_end_hook (w, 0, 0); + FRAME_RIF (f)->update_window_begin_hook (w); + FRAME_RIF (f)->clear_window_mouse_face (w); + FRAME_RIF (f)->scroll_run_hook (w, &run); + FRAME_RIF (f)->update_window_end_hook (w, 0, 0); update_end (f); } @@ -12476,10 +12473,10 @@ { struct frame *f = XFRAME (WINDOW_FRAME (w)); update_begin (f); - rif->update_window_begin_hook (w); - rif->clear_window_mouse_face (w); - rif->scroll_run_hook (w, &run); - rif->update_window_end_hook (w, 0, 0); + FRAME_RIF (f)->update_window_begin_hook (w); + FRAME_RIF (f)->clear_window_mouse_face (w); + FRAME_RIF (f)->scroll_run_hook (w, &run); + FRAME_RIF (f)->update_window_end_hook (w, 0, 0); update_end (f); } @@ -12902,7 +12899,7 @@ /* Window must either use window-based redisplay or be full width. */ if (!FRAME_WINDOW_P (f) - && (!line_ins_del_ok + && (!FRAME_LINE_INS_DEL_OK (f) || !WINDOW_FULL_WIDTH_P (w))) GIVE_UP (4); @@ -13310,10 +13307,10 @@ if (FRAME_WINDOW_P (f)) { - rif->update_window_begin_hook (w); - rif->clear_window_mouse_face (w); - rif->scroll_run_hook (w, &run); - rif->update_window_end_hook (w, 0, 0); + FRAME_RIF (f)->update_window_begin_hook (w); + FRAME_RIF (f)->clear_window_mouse_face (w); + FRAME_RIF (f)->scroll_run_hook (w, &run); + FRAME_RIF (f)->update_window_end_hook (w, 0, 0); } else { @@ -13335,7 +13332,7 @@ /* On dumb terminals delete dvpos lines at the end before inserting dvpos empty lines. */ - if (!scroll_region_ok) + if (!FRAME_SCROLL_REGION_OK (f)) ins_del_lines (end - dvpos, -dvpos); /* Insert dvpos empty lines in front of @@ -13356,7 +13353,7 @@ /* On a dumb terminal insert dvpos empty lines at the end. */ - if (!scroll_region_ok) + if (!FRAME_SCROLL_REGION_OK (f)) ins_del_lines (end + dvpos, -dvpos); } @@ -16818,7 +16815,7 @@ = FONT_INFO_FROM_ID (f, face->font_info_id); if (font_info) glyph->font_type - = rif->encode_char (glyph->u.ch, char2b, font_info, two_byte_p); + = FRAME_RIF (f)->encode_char (glyph->u.ch, char2b, font_info, two_byte_p); } } @@ -17048,7 +17045,7 @@ font = face->font; font_info = FONT_INFO_FROM_ID (f, face->font_info_id); if (font /* ++KFS: Should this be font_info ? */ - && (pcm = rif->per_char_metric (font, &char2b, glyph->font_type))) + && (pcm = FRAME_RIF (f)->per_char_metric (font, &char2b, glyph->font_type))) { if (pcm->rbearing > pcm->width) *right = pcm->rbearing - pcm->width; @@ -17216,7 +17213,7 @@ struct font_info *font_info = FONT_INFO_FROM_ID (f, face->font_info_id); if (font_info) - rif->encode_char (c, char2b, font_info, 0); + FRAME_RIF (f)->encode_char (c, char2b, font_info, 0); } } @@ -17283,8 +17280,8 @@ { while (s) { - if (rif->compute_glyph_string_overhangs) - rif->compute_glyph_string_overhangs (s); + if (FRAME_RIF (s->f)->compute_glyph_string_overhangs) + FRAME_RIF (s->f)->compute_glyph_string_overhangs (s); x -= s->width; s->x = x; s = s->prev; @@ -17294,8 +17291,8 @@ { while (s) { - if (rif->compute_glyph_string_overhangs) - rif->compute_glyph_string_overhangs (s); + if (FRAME_RIF (s->f)->compute_glyph_string_overhangs) + FRAME_RIF (s->f)->compute_glyph_string_overhangs (s); s->x = x; x += s->width; s = s->next; @@ -17576,9 +17573,9 @@ struct glyph_string *h, *t; /* Compute overhangs for all glyph strings. */ - if (rif->compute_glyph_string_overhangs) + if (FRAME_RIF (f)->compute_glyph_string_overhangs) for (s = head; s; s = s->next) - rif->compute_glyph_string_overhangs (s); + FRAME_RIF (f)->compute_glyph_string_overhangs (s); /* Prepend glyph strings for glyphs in front of the first glyph string that are overwritten because of the first glyph @@ -17646,7 +17643,7 @@ /* Draw all strings. */ for (s = head; s; s = s->next) - rif->draw_glyph_string (s); + FRAME_RIF (f)->draw_glyph_string (s); if (area == TEXT_AREA && !row->full_width_p @@ -18334,8 +18331,8 @@ it->nglyphs = 1; - pcm = rif->per_char_metric (font, &char2b, - FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display)); + pcm = FRAME_RIF (it->f)->per_char_metric (font, &char2b, + FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display)); it->ascent = FONT_BASE (font) + boff; it->descent = FONT_DESCENT (font) - boff; @@ -18459,8 +18456,8 @@ from the charset width; this is what old redisplay code did. */ - pcm = rif->per_char_metric (font, &char2b, - FONT_TYPE_FOR_MULTIBYTE (font, it->c)); + pcm = FRAME_RIF (it->f)->per_char_metric (font, &char2b, + FONT_TYPE_FOR_MULTIBYTE (font, it->c)); if (font_not_found_p || !pcm) { @@ -18591,8 +18588,8 @@ /* Initialize the bounding box. */ if (font_info - && (pcm = rif->per_char_metric (font, &char2b, - FONT_TYPE_FOR_MULTIBYTE (font, it->c)))) + && (pcm = FRAME_RIF (it->f)->per_char_metric (font, &char2b, + FONT_TYPE_FOR_MULTIBYTE (font, it->c)))) { width = pcm->width; ascent = pcm->ascent; @@ -18650,8 +18647,8 @@ } if (font_info - && (pcm = rif->per_char_metric (font, &char2b, - FONT_TYPE_FOR_MULTIBYTE (font, ch)))) + && (pcm = FRAME_RIF (it->f)->per_char_metric (font, &char2b, + FONT_TYPE_FOR_MULTIBYTE (font, ch)))) { width = pcm->width; ascent = pcm->ascent; @@ -18886,8 +18883,8 @@ frame_x = window_box_left (w, updated_area) + output_cursor.x; frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, output_cursor.y); - rif->shift_glyphs_for_insert (f, frame_x, frame_y, shifted_region_width, - line_height, shift_by_width); + FRAME_RIF (f)->shift_glyphs_for_insert (f, frame_x, frame_y, shifted_region_width, + line_height, shift_by_width); /* Write the glyphs. */ hpos = start - row->glyphs[updated_area]; @@ -18969,8 +18966,8 @@ if (to_x > from_x && to_y > from_y) { BLOCK_INPUT; - rif->clear_frame_area (f, from_x, from_y, - to_x - from_x, to_y - from_y); + FRAME_RIF (f)->clear_frame_area (f, from_x, from_y, + to_x - from_x, to_y - from_y); UNBLOCK_INPUT; } } @@ -19407,8 +19404,8 @@ x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y)); - rif->clear_frame_area (f, x, y, - cursor_glyph->pixel_width, cursor_row->visible_height); + FRAME_RIF (f)->clear_frame_area (f, x, y, + cursor_glyph->pixel_width, cursor_row->visible_height); } /* Erase the cursor by redrawing the character underneath it. */ @@ -19504,9 +19501,9 @@ w->phys_cursor.vpos = vpos; } - rif->draw_window_cursor (w, glyph_row, x, y, - new_cursor_type, new_cursor_width, - on, active_cursor); + FRAME_RIF (f)->draw_window_cursor (w, glyph_row, x, y, + new_cursor_type, new_cursor_width, + on, active_cursor); } @@ -19651,11 +19648,11 @@ /* Change the mouse cursor. */ if (draw == DRAW_NORMAL_TEXT) - rif->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor); + FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor); else if (draw == DRAW_MOUSE_FACE) - rif->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor); - else - rif->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor); + FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor); + else + FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor); } /* EXPORT: @@ -20152,7 +20149,7 @@ #else if (bcmp (&cursor, &No_Cursor, sizeof (Cursor))) #endif - rif->define_frame_cursor (f, cursor); + FRAME_RIF (f)->define_frame_cursor (f, cursor); } /* Take proper action when mouse has moved to the mode or header line @@ -20987,6 +20984,8 @@ x_draw_vertical_border (w) struct window *w; { + struct frame *f = XFRAME (WINDOW_FRAME (w)); + /* We could do better, if we knew what type of scroll-bar the adjacent windows (on either side) have... But we don't :-( However, I think this works ok. ++KFS 2003-04-25 */ @@ -21003,7 +21002,7 @@ window_box_edges (w, -1, &x0, &y0, &x1, &y1); y1 -= 1; - rif->draw_vertical_window_border (w, x1, y0, y1); + FRAME_RIF (f)->draw_vertical_window_border (w, x1, y0, y1); } else if (!WINDOW_LEFTMOST_P (w) && !WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)) @@ -21013,7 +21012,7 @@ window_box_edges (w, -1, &x0, &y0, &x1, &y1); y1 -= 1; - rif->draw_vertical_window_border (w, x0, y0, y1); + FRAME_RIF (f)->draw_vertical_window_border (w, x0, y0, y1); } }
--- a/src/xfaces.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/xfaces.c Fri Jan 02 04:37:46 2004 +0000 @@ -241,6 +241,8 @@ #include "blockinput.h" #include "window.h" #include "intervals.h" +#include "systty.h" /* For emacs_tty in termchar.h */ +#include "termchar.h" #ifdef HAVE_X_WINDOWS @@ -5406,7 +5408,7 @@ /* See if the capabilities we selected above are supported, with the given colors. */ if (test_caps != 0 && - ! tty_capable_p (f, test_caps, fg_tty_color.pixel, bg_tty_color.pixel)) + ! tty_capable_p (FRAME_TTY (SELECTED_FRAME ()), test_caps, fg_tty_color.pixel, bg_tty_color.pixel)) return Qnil; @@ -6638,7 +6640,8 @@ { FRAME_FACE_CACHE (f)->menu_face_changed_p = 0; #ifdef USE_X_TOOLKIT - x_update_menu_appearance (f); + if (FRAME_WINDOW_P (f)) + x_update_menu_appearance (f); #endif }
--- a/src/xfns.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/xfns.c Fri Jan 02 04:37:46 2004 +0000 @@ -48,6 +48,8 @@ #include "systime.h" #include "termhooks.h" #include "atimer.h" +#include "systty.h" +#include "termchar.h" #ifdef HAVE_X_WINDOWS @@ -3243,6 +3245,7 @@ /* Note that X Windows does support scroll bars. */ FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; + f->display_method = &x_display_method; f->output_method = output_x_window; f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); bzero (f->output_data.x, sizeof (struct x_output)); @@ -9978,6 +9981,8 @@ FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; record_unwind_protect (unwind_create_tip_frame, frame); + f->display_method = &x_display_method; + /* By setting the output method, we're essentially saying that the frame is live, as per FRAME_LIVE_P. If we get a signal from this point on, x_destroy_window might screw up reference
--- a/src/xterm.c Thu Jan 01 23:44:00 2004 +0000 +++ b/src/xterm.c Fri Jan 02 04:37:46 2004 +0000 @@ -184,6 +184,10 @@ int x_use_underline_position_properties; +/* Generic display parameters for X displays. */ + +struct display_method x_display_method; + /* This is a chain of structures for all the X displays currently in use. */ @@ -382,7 +386,8 @@ { Lisp_Object rest, frame; FOR_EACH_FRAME (rest, frame) - x_flush (XFRAME (frame)); + if (FRAME_X_P (XFRAME (frame))) + x_flush (XFRAME (frame)); } else if (FRAME_X_P (f)) XFlush (FRAME_X_DISPLAY (f)); @@ -469,7 +474,6 @@ /* Nothing to do. */ } - /* Start update of window W. Set the global variable updated_window to the window being updated and set output_cursor to the cursor position of W. */ @@ -1365,7 +1369,8 @@ for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) if (GC_FRAMEP (XCAR (tail)) && (f = XFRAME (XCAR (tail)), - (f->output_data.nothing != 1 + (FRAME_X_P (f) + && f->output_data.nothing != 1 && FRAME_X_DISPLAY_INFO (f) == dpyinfo)) && f->output_data.x->widget == widget) return f; @@ -3663,7 +3668,8 @@ /* Clear the mouse-moved flag for every frame on this display. */ FOR_EACH_FRAME (tail, frame) - if (FRAME_X_DISPLAY (XFRAME (frame)) == FRAME_X_DISPLAY (*fp)) + if (FRAME_X_P (XFRAME (frame)) + && FRAME_X_DISPLAY (XFRAME (frame)) == FRAME_X_DISPLAY (*fp)) XFRAME (frame)->mouse_moved = 0; last_mouse_scroll_bar = Qnil; @@ -3877,6 +3883,9 @@ if (! GC_FRAMEP (frame)) abort (); + if (! FRAME_X_P (XFRAME (frame))) + continue; + /* Scan this frame's scroll bar list for a scroll bar with the right window ID. */ condemned = FRAME_CONDEMNED_SCROLL_BARS (XFRAME (frame)); @@ -3911,11 +3920,14 @@ XGCTYPE (tail) == Lisp_Cons; tail = XCDR (tail)) { - Lisp_Object frame = XCAR (tail); - Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget; - - if (menu_bar && xlwmenu_window_p (menu_bar, window)) - return menu_bar; + if (FRAME_X_P (XFRAME (XCAR (tail)))) + { + Lisp_Object frame = XCAR (tail); + Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget; + + if (menu_bar && xlwmenu_window_p (menu_bar, window)) + return menu_bar; + } } return NULL; @@ -7057,8 +7069,7 @@ EXPECTED is nonzero if the caller knows input is available. */ static int -XTread_socket (sd, bufp, numchars, expected) - register int sd; +XTread_socket (bufp, numchars, expected) /* register */ struct input_event *bufp; /* register */ int numchars; int expected; @@ -8028,7 +8039,7 @@ FOR_EACH_FRAME (tail, frame) { struct frame *f = XFRAME (frame); - if (FRAME_X_DISPLAY_INFO (f) == dpyinfo) + if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) { FRAME_XIC (f) = NULL; if (FRAME_XIC_FONTSET (f)) @@ -8131,7 +8142,8 @@ { struct frame *f = XFRAME (frame); - if (FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo) + if (FRAME_X_P (f) + && FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo) if (FRAME_XIC (f) == NULL) { create_frame_xic (f); @@ -10802,43 +10814,41 @@ extern frame_parm_handler x_frame_parm_handlers[]; static struct redisplay_interface x_redisplay_interface = -{ - x_frame_parm_handlers, - x_produce_glyphs, - x_write_glyphs, - x_insert_glyphs, - x_clear_end_of_line, - x_scroll_run, - x_after_update_window_line, - x_update_window_begin, - x_update_window_end, - x_cursor_to, - x_flush, + { + x_frame_parm_handlers, + x_produce_glyphs, + x_write_glyphs, + x_insert_glyphs, + x_clear_end_of_line, + x_scroll_run, + x_after_update_window_line, + x_update_window_begin, + x_update_window_end, + x_cursor_to, + x_flush, #ifndef XFlush - x_flush, + x_flush, #else - 0, /* flush_display_optional */ -#endif - x_clear_window_mouse_face, - x_get_glyph_overhangs, - x_fix_overlapping_area, - x_draw_fringe_bitmap, - x_per_char_metric, - x_encode_char, - x_compute_glyph_string_overhangs, - x_draw_glyph_string, - x_define_frame_cursor, - x_clear_frame_area, - x_draw_window_cursor, - x_draw_vertical_window_border, - x_shift_glyphs_for_insert -}; + 0, /* flush_display_optional */ +#endif + x_clear_window_mouse_face, + x_get_glyph_overhangs, + x_fix_overlapping_area, + x_draw_fringe_bitmap, + x_per_char_metric, + x_encode_char, + x_compute_glyph_string_overhangs, + x_draw_glyph_string, + x_define_frame_cursor, + x_clear_frame_area, + x_draw_window_cursor, + x_draw_vertical_window_border, + x_shift_glyphs_for_insert + }; void x_initialize () { - rif = &x_redisplay_interface; - clear_frame_hook = x_clear_frame; ins_del_lines_hook = x_ins_del_lines; delete_glyphs_hook = x_delete_glyphs; @@ -10858,12 +10868,13 @@ redeem_scroll_bar_hook = XTredeem_scroll_bar; judge_scroll_bars_hook = XTjudge_scroll_bars; - scroll_region_ok = 1; /* we'll scroll partial frames */ - char_ins_del_ok = 1; - line_ins_del_ok = 1; /* we'll just blt 'em */ - fast_clear_end_of_line = 1; /* X does this well */ - memory_below_frame = 0; /* we don't remember what scrolls - off the bottom */ + x_display_method.rif = &x_redisplay_interface; + x_display_method.scroll_region_ok = 1; /* We'll scroll partial frames. */ + x_display_method.char_ins_del_ok = 1; + x_display_method.line_ins_del_ok = 1; /* We'll just blt 'em. */ + x_display_method.fast_clear_end_of_line = 1; /* X does this well. */ + x_display_method.memory_below_frame = 0; /* We don't remember what scrolls off the + bottom. */ baud_rate = 19200; x_noop_count = 0;
--- a/src/xterm.h Thu Jan 01 23:44:00 2004 +0000 +++ b/src/xterm.h Fri Jan 02 04:37:46 2004 +0000 @@ -134,6 +134,9 @@ int height, width, depth; }; +/* Generic parameters for X displays. */ +extern struct display_method x_display_method; + /* For each X display, we have a structure that records information about it. */