Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
Makefile | H A D | 17-Nov-2016 | 1.1 KiB | 26 | 19 | |
README | H A D | 26-Nov-2011 | 9.4 KiB | 196 | 169 | |
alias.h | H A D | 26-Nov-2011 | 2.3 KiB | 55 | 13 | |
char.c | H A D | 26-Nov-2011 | 5.7 KiB | 146 | 101 | |
char.h | H A D | 26-Nov-2011 | 2.5 KiB | 60 | 10 | |
cmd.c | H A D | 30-Jan-2018 | 6.1 KiB | 303 | 252 | |
cmd1.c | H A D | 26-Nov-2011 | 4.2 KiB | 168 | 128 | |
cmd2.c | H A D | 16-Mar-2012 | 5.3 KiB | 153 | 109 | |
cmd3.c | H A D | 26-Nov-2011 | 2.1 KiB | 60 | 22 | |
cmd4.c | H A D | 26-Nov-2011 | 2.1 KiB | 53 | 15 | |
cmd5.c | H A D | 26-Nov-2011 | 3.3 KiB | 126 | 75 | |
cmd6.c | H A D | 16-Mar-2012 | 2.9 KiB | 108 | 63 | |
cmd7.c | H A D | 16-Mar-2012 | 6 KiB | 282 | 223 | |
compress.c | H A D | 16-Mar-2012 | 19.8 KiB | 902 | 786 | |
context.c | H A D | 16-Mar-2012 | 3.2 KiB | 132 | 85 | |
context.h | H A D | 26-Nov-2011 | 3.2 KiB | 86 | 42 | |
defs.h | H A D | 26-Nov-2011 | 4.4 KiB | 128 | 82 | |
error.c | H A D | 16-Mar-2012 | 2.8 KiB | 101 | 58 | |
lcmd.c | H A D | 26-Nov-2011 | 4.2 KiB | 123 | 81 | |
lcmd.h | H A D | 26-Nov-2011 | 3.4 KiB | 84 | 42 | |
lcmd1.c | H A D | 16-Mar-2012 | 9.3 KiB | 432 | 352 | |
lcmd2.c | H A D | 16-Mar-2012 | 9.8 KiB | 385 | 318 | |
local.h | H A D | 26-Nov-2011 | 2 KiB | 50 | 8 | |
main.c | H A D | 21-Feb-2023 | 4.6 KiB | 187 | 140 | |
mloop.c | H A D | 26-Nov-2011 | 2.7 KiB | 85 | 46 | |
parser.h | H A D | 26-Nov-2011 | 2.6 KiB | 63 | 24 | |
parser1.c | H A D | 30-Jan-2018 | 4.4 KiB | 225 | 168 | |
parser2.c | H A D | 16-Mar-2012 | 5.7 KiB | 230 | 182 | |
parser3.c | H A D | 30-Jan-2018 | 4 KiB | 188 | 114 | |
parser4.c | H A D | 16-Mar-2012 | 6 KiB | 293 | 241 | |
parser5.c | H A D | 16-Mar-2012 | 4.4 KiB | 196 | 147 | |
scanner.c | H A D | 30-Jan-2018 | 11.5 KiB | 591 | 541 | |
startup.c | H A D | 16-Mar-2012 | 3.1 KiB | 93 | 48 | |
string.c | H A D | 21-Feb-2023 | 3.4 KiB | 146 | 93 | |
token.h | H A D | 26-Nov-2011 | 2.6 KiB | 82 | 43 | |
tt.h | H A D | 26-Nov-2011 | 5.6 KiB | 179 | 94 | |
ttf100.c | H A D | 26-Nov-2011 | 2.3 KiB | 66 | 23 | |
ttgeneric.c | H A D | 16-Mar-2012 | 12.2 KiB | 591 | 510 | |
tth19.c | H A D | 26-Nov-2011 | 6.1 KiB | 300 | 224 | |
tth29.c | H A D | 26-Nov-2011 | 2.9 KiB | 93 | 37 | |
ttinit.c | H A D | 16-Mar-2012 | 3.3 KiB | 116 | 67 | |
ttoutput.c | H A D | 26-Nov-2011 | 3.3 KiB | 143 | 95 | |
tttermcap.c | H A D | 16-Mar-2012 | 3 KiB | 114 | 66 | |
tttvi925.c | H A D | 26-Nov-2011 | 2.2 KiB | 61 | 18 | |
ttwyse60.c | H A D | 16-Mar-2012 | 2.5 KiB | 73 | 26 | |
ttwyse75.c | H A D | 16-Mar-2012 | 2.5 KiB | 73 | 26 | |
ttzapple.c | H A D | 30-Jan-2018 | 9.1 KiB | 522 | 429 | |
ttzentec.c | H A D | 11-Apr-2017 | 2.3 KiB | 63 | 18 | |
value.h | H A D | 26-Nov-2011 | 2 KiB | 53 | 14 | |
var.c | H A D | 16-Mar-2012 | 3.6 KiB | 142 | 94 | |
var.h | H A D | 26-Nov-2011 | 2.6 KiB | 64 | 23 | |
win.c | H A D | 16-Mar-2012 | 8.1 KiB | 361 | 248 | |
window.1 | H A D | 21-Feb-2023 | 24.4 KiB | 1,065 | 1,064 | |
window_string.h | H A D | 21-Feb-2023 | 2.4 KiB | 73 | 27 | |
windowrc | H A D | 24-Jan-2016 | 2.9 KiB | 85 | 79 | |
ww.h | H A D | 06-Jan-2018 | 13.1 KiB | 392 | 292 | |
wwadd.c | H A D | 26-Nov-2011 | 2.7 KiB | 83 | 40 | |
wwalloc.c | H A D | 16-Mar-2012 | 2.3 KiB | 68 | 28 | |
wwbox.c | H A D | 26-Nov-2011 | 2.3 KiB | 60 | 22 | |
wwchild.c | H A D | 26-Nov-2011 | 2.4 KiB | 67 | 28 | |
wwclose.c | H A D | 26-Nov-2011 | 2.2 KiB | 57 | 20 | |
wwclreol.c | H A D | 26-Nov-2011 | 2.7 KiB | 90 | 34 | |
wwclreos.c | H A D | 26-Nov-2011 | 2 KiB | 51 | 12 | |
wwcursor.c | H A D | 26-Nov-2011 | 2.9 KiB | 89 | 49 | |
wwdelchar.c | H A D | 26-Nov-2011 | 3.2 KiB | 120 | 63 | |
wwdelete.c | H A D | 26-Nov-2011 | 3.6 KiB | 135 | 86 | |
wwdelline.c | H A D | 26-Nov-2011 | 2.6 KiB | 83 | 33 | |
wwdump.c | H A D | 26-Nov-2011 | 3.1 KiB | 115 | 68 | |
wwend.c | H A D | 26-Nov-2011 | 2.1 KiB | 63 | 25 | |
wwenviron.c | H A D | 30-Jan-2018 | 3.3 KiB | 105 | 58 | |
wwerror.c | H A D | 26-Nov-2011 | 2.3 KiB | 64 | 27 | |
wwflush.c | H A D | 26-Nov-2011 | 3.1 KiB | 114 | 69 | |
wwframe.c | H A D | 26-Nov-2011 | 5.3 KiB | 239 | 184 | |
wwgets.c | H A D | 26-Nov-2011 | 3 KiB | 104 | 63 | |
wwinit.c | H A D | 16-Mar-2012 | 9.1 KiB | 409 | 329 | |
wwinschar.c | H A D | 26-Nov-2011 | 3.3 KiB | 126 | 69 | |
wwinsline.c | H A D | 26-Nov-2011 | 2.5 KiB | 83 | 33 | |
wwiomux.c | H A D | 16-Mar-2012 | 6.2 KiB | 236 | 172 | |
wwlabel.c | H A D | 26-Nov-2011 | 2.8 KiB | 90 | 44 | |
wwmisc.c | H A D | 26-Nov-2011 | 2.3 KiB | 64 | 22 | |
wwmove.c | H A D | 26-Nov-2011 | 2.9 KiB | 94 | 47 | |
wwopen.c | H A D | 16-Mar-2012 | 5.1 KiB | 194 | 144 | |
wwprintf.c | H A D | 26-Nov-2011 | 2.1 KiB | 55 | 15 | |
wwpty.c | H A D | 26-Nov-2011 | 2.2 KiB | 60 | 22 | |
wwputc.c | H A D | 26-Nov-2011 | 1.9 KiB | 43 | 6 | |
wwputs.c | H A D | 26-Nov-2011 | 1.9 KiB | 47 | 9 | |
wwredraw.c | H A D | 26-Nov-2011 | 2 KiB | 54 | 16 | |
wwredrawwin.c | H A D | 26-Nov-2011 | 2.4 KiB | 68 | 30 | |
wwrint.c | H A D | 26-Nov-2011 | 2.6 KiB | 76 | 24 | |
wwscroll.c | H A D | 26-Nov-2011 | 5.6 KiB | 230 | 154 | |
wwsize.c | H A D | 21-Feb-2023 | 5 KiB | 186 | 116 | |
wwspawn.c | H A D | 26-Nov-2011 | 2.6 KiB | 87 | 41 | |
wwsuspend.c | H A D | 26-Nov-2011 | 2.1 KiB | 53 | 15 | |
wwterminfo.c | H A D | 21-Feb-2023 | 3.3 KiB | 115 | 55 | |
wwtty.c | H A D | 26-Nov-2011 | 4.4 KiB | 175 | 116 | |
wwunframe.c | H A D | 16-Mar-2012 | 2.5 KiB | 72 | 32 | |
wwupdate.c | H A D | 26-Nov-2011 | 6.5 KiB | 269 | 198 | |
wwwrite.c | H A D | 21-Feb-2023 | 7.2 KiB | 296 | 244 | |
xx.c | H A D | 16-Mar-2012 | 5.2 KiB | 265 | 199 | |
xx.h | H A D | 26-Nov-2011 | 2.6 KiB | 78 | 36 | |
xxflush.c | H A D | 16-Mar-2012 | 5.7 KiB | 192 | 131 |
README
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Edward Wang at The University of California, Berkeley. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)README 8.1 (Berkeley) 6/6/93 33 */ 34 35Compilation notes: 36 37 Compiler options: 38 39 BYTE_ORDER (used only in ww.h) 40 It should already be defined in machine/endian.h. 41 The code knows about BIG_ENDIAN, LITTLE_ENDIAN, and PDP_ENDIAN. 42 It only cares about byte order in words, so PDP_ENDIAN 43 is the same as LITTLE_ENDIAN. 44 OLD_TTY 45 If you don't have Posix termios, then define this. 46 VMIN_BUG 47 Even if you have Posix termios, define this if the MIN and TIME 48 feature in noncanonical mode doesn't work correctly. 49 50 Ok, there's another one, STR_DEBUG. It turns on consistency checks 51 in the string allocator. It's been left on since performace doesn't 52 seem to suffer. There's an abort() somewhere when an inconsistency 53 is found. It hasn't happened in years. 54 55 The file local.h contains locally tunable constants. 56 57 The makefile used to be updated with mkmf; it has been changed 58at various times to use cpp -M and, currently, mkdep. The only library 59it needs is termcap. 60 61 Window, as is, only runs on 4.3 (or later) machines. 62 63 On 4.2 machines, at least these modifications must be done: 64 65 delete uses of window size ioctls: TIOCGWINSZ, TIOCSWINSZ, 66 struct winsize 67 add to ww.h 68 typedef int fd_set; 69 #define FD_ZERO(s) (*(s) = 0) 70 #define FD_SET(b, s) (*(s) |= 1 << (b)) 71 #define FD_ISSET(b, s) (*(s) & 1 << (b)) 72 add to ww.h 73 #define sigmask(s) (1 << (s) - 1) 74 75 76A few notes about the internals: 77 78 The window package. Windows are opened by calling wwopen(). 79Wwwrite() is the primitive for writing to windows. Wwputc(), wwputs(), 80and wwprintf() are also supported. Some of the outputs to windows are 81delayed. Wwupdate() updates the terminal to match the internal screen 82buffer. Wwspawn() spawns a child process on the other end of a window, 83with its environment tailored to the window. Visible windows are 84doubly linked in the order of their overlap. Wwadd() inserts a window 85into the list at a given place. Wwdelete() deletes it. Windows not in 86the list are not visible, though wwwrite() still works. Window was 87written before the days of X and Sunview, so some of the terminology 88is not standard. 89 90 Most functions return -1 on error. Wwopen() returns the null 91pointer. An error number is saved in wwerrno. Wwerror() returns an 92error string based on wwerrno suitable for printing. 93 94 The terminal drivers perform all output to the physical terminal, 95including special functions like character and line insertion and 96deletion. The window package keeps a list of known terminals. At 97initialization time, the terminal type is matched against the list to 98find the right terminal driver to use. The last driver, the generic 99driver, matches all terminals and uses the termcap database. The 100interface between the window package the terminal driver is the `tt' 101structure. It contains pointers to functions to perform special 102functions and terminal output, as well as flags about the 103characteristics of the terminal. Most of these ideas are borrowed 104from the Maryland window package, which in turn is based on Goslin's 105Emacs. 106 107 The IO system is semi-synchronous. Terminal input is signal 108driven, and everything else is done synchronously with a single 109poll(). It is roughly event-driven, though not in a clean way. 110 111 Normally, in both conversation mode and command mode, window 112sleeps in a poll() in wwiomux() waiting for data from the 113pseudo-terminals. At the same time, terminal input causes SIGIO which 114is caught by wwrint(). The poll() returns when at least one of the 115pseudo-terminals becomes ready for reading. 116 117 Wwrint() is the interrupt handler for tty input. It reads input 118into a linear buffer accessed through four pointers: 119 120 +-------+--------------+----------------+ 121 | empty | data | empty | 122 +-------+--------------+----------------+ 123 ^ ^ ^ ^ 124 | | | | 125 wwib wwibp wwibq wwibe 126 127Wwrint() appends characters at the end and increments wwibq (*wwibq++ 128= c), and characters are taken off the buffer at wwibp using the 129wwgetc() and wwpeekc() macros. As is the convention in C, wwibq 130and wwibe point to one position beyond the end. In addition, 131wwrint() will do a longjmp(wwjmpbuf) if wwsetjmp is true. This is 132used by wwiomux() to interrupt the poll() which would otherwise 133resume after the interrupt. (Actually, I hear this is not true, 134but the longjmp feature is used to avoid a race condition as well. 135Anyway, it means I didn't have to depend on a feature in a 136daily-changing kernel, but that's another story.) The macro 137wwinterrupt() returns true if the input buffer is non-empty. 138Wwupdate(), wwwrite(), and wwiomux() check this condition and will 139return at the first convenient opportunity when it becomes true. 140In the case of wwwrite(), the flag ww_nointr in the window structure 141overrides this. This feature allows the user to interrupt lengthy 142outputs safely. The structure of the input buffer is designed to 143avoid race conditions without blocking interrupts. 144 145 Actually, wwsetjmp and wwinterrupt() are part of a software 146interrupt scheme used by the two interrupt catchers wwrint() and 147wwchild(). Asserting the interrupt lets the synchronous parts of 148the program know that there's an interesting asynchronous condition 149(i.e., got a keyboard character, or a child process died) that they 150might want to process before anything else. The synchronous routines 151can check for this condition with wwinterrupt() or by arranging 152that a longjmp() be done. 153 154 Wwiomux() copies pseudo-terminal output into their corresponding 155windows. Without anything to do, it blocks in a poll(), waiting for 156read ready on pseudo-terminals. Reads are done into per-window buffers 157in the window structures. When there is at least one buffer non-empty, 158wwiomux() finds the top most of these windows and writes it using 159wwwrite(). Then the process is repeated. A non-blocking poll() is 160done after a wwwrite() to pick up any output that may have come in 161during the write, which may take a long time. Specifically, we use 162this to stop output or flush buffer when a pseudo-terminal tells us to 163(we use pty packet mode). The poll() blocks only when all of the 164windows' buffers are empty. A wwupdate() is done prior to this, which 165is the only time the screen is guaranteed to be completely up to date. 166Wwiomux() loops until wwinterrupt() becomes true. 167 168 The top level routine for all this is mloop(). In conversation 169mode, it simply calls wwiomux(), which only returns when input is 170available. The input buffer is then written to the pseudo-terminal of 171the current window. If the escape character is found in the input, 172command mode is entered. Otherwise, the process is repeated. In 173command mode, control is transferred to docmd() which returns only when 174conversation mode is reentered. Docmd() and other command processing 175routines typically wait for input in a loop: 176 177 while (wwpeekc() < 0) 178 wwiomux(); 179 180When the loop terminates, wwgetc() is used to read the input buffer. 181 182 Output to the physical terminal is handled by the lowest level 183routines of the window package, in the files ttoutput.c and tt.h. The 184standard IO package is not used, to get better control over buffering 185and to use non-blocking reads in wwrint(). The buffer size is set to 186approximately one second of output time, based on the baudrate. 187 188 The result of all this complexity is faster response time, 189especially in output stopping and flushing. Wwwrite() checks 190wwinterrupt() after every line. It also calls wwupdate() for each line 191it writes. The output buffer is limited to one second of output time. 192Thus, there is usually only a delay of one to two lines plus one second 193after a ^C or ^S. Also, commands that produce lengthy output can be 194aborted without actually showing all of it on the terminal. (Try the 195'?' command followed by escape immediately.) 196