1*18742Sedward@(#)README 3.6 04/24/85 215556Sedward 3*18742Sedward/* 4*18742Sedward * Copyright (c) 1983 Regents of the University of California, 5*18742Sedward * All rights reserved. Redistribution permitted subject to 6*18742Sedward * the terms of the Berkeley Software License Agreement. 7*18742Sedward */ 8*18742Sedward 916284SedwardCompilation notes: 1015556Sedward 1116398Sedward There is only one compiler option: 1216284Sedward 1316535Sedward mc68000 use 68000 byte ordering 1416535Sedward It should already be defined in the preprocessor. 1515556Sedward 1616398Sedward The file local.h contains locally tunable constants. 1715556Sedward 1816284Sedward The makefile should be updated with mkmf. The only library it needs 1916284Sedwardis termcap (and jobs for 4.1). 2015556Sedward 2116398Sedward Window only runs on 4.2 machines. 2215556Sedward 2315556Sedward 2416284SedwardA few notes about the internals: 2516284Sedward 2616284Sedward The window package. Windows are opened by calling wwopen(). 2716284SedwardWwwrite() is the primitive for writing to windows. Wwputc(), wwputs(), 2816284Sedwardand wwprintf() are also supported. Some of the outputs to windows are 2916284Sedwarddelayed. Wwupdate() updates the terminal to match the internal screen 3016284Sedwardbuffer. Wwspawn() spawns a child process on the other end of a window, 3116284Sedwardwith it's environment tailored to the window. Visible windows are 3216284Sedwarddoubly linked in the order of their overlap. Wwadd() inserts a window 3316535Sedwardinto the list at a given place. Wwdelete() deletes it. Windows not in 3416535Sedwardthe list are not visible, though wwwrite() still works. 3516284Sedward 3616284Sedward Most functions return -1 on error. Wwopen() returns the null 3716535Sedwardpointer. An error number is saved in wwerrno. Wwerror() returns an 3816535Sedwarderror string based on wwerrno suitable for printing. 3916284Sedward 4016284Sedward The terminal drivers perform all output to the physical terminal, 4116284Sedwardincluding special functions like character and line insertion and 4216284Sedwarddeletion. The window package keeps a list of known terminals. At 4316284Sedwardinitialization time, the terminal type is matched against the list to 4416284Sedwardfind the right terminal driver to use. The last driver, the generic 4516284Sedwarddriver, matches all terminals and uses the termcap database. The 4616284Sedwardinterface between the window package the terminal driver is the `tt' 4716284Sedwardstructure. It contains pointers to functions to perform special 4816284Sedwardfunctions and terminal output, as well as flags about the 4916284Sedwardcharacteristics of the terminal. 5016284Sedward 5116535Sedward The IO system is semi-synchronous. Terminal input is signal 5216535Sedwarddriven, and everything else is done synchronously with a single 5316535Sedwardselect(). 5416284Sedward 5516535Sedward Normally, in both conversation mode and command mode, window 5616535Sedwardsleeps in a select() in wwiomux() waiting for data from the 5716535Sedwardpseudo-terminals. At the same time, terminal input causes SIGIO which 5816535Sedwardis caught by wwrint(). The select() returns when at least one of the 5916535Sedwardpseudo-terminals becomes ready for reading. 6016284Sedward 6116535Sedward Wwrint() is the interrupt handler for tty input. It reads input 6216535Sedwardinto a linear buffer accessed through four pointers: 6316284Sedward 6416284Sedward +-------+--------------+----------------+ 6516284Sedward | empty | data | empty | 6616284Sedward +-------+--------------+----------------+ 6716284Sedward ^ ^ ^ ^ 6816284Sedward | | | | 6916284Sedward wwib wwibp wwibq wwibe 7016284Sedward 7116535SedwardWwrint() appends characters at the end and increments wwibq (*wwibq++ = 7216535Sedwardc), and characters are taken from the buffer at wwibp using the 7316535Sedwardwwgetc() and wwpeekc() macros. As is the convention in C, wwibq and 7416535Sedwardwwibe point to one position beyond the end. In addition, wwrint() will 7516535Sedwarddo a longjmp(wwjmpbuf) if wwsetjmp is true. This is used by wwiomux() 7616535Sedwardto interrupt the select() which would otherwise resume after the 7716284Sedwardinterrupt. The macro wwinterrupt() returns true if the input buffer is 7816284Sedwardnon-empty. Wwupdate(), wwwrite(), and wwiomux() check this condition 7916284Sedwardand will return at the first convenient opportunity when it becomes 8016284Sedwardtrue. In the case of wwwrite(), the flag ww_nointr in the window 8116284Sedwardstructure overrides this. This feature allows the user to interrupt 8216535Sedwardlengthy outputs safely. The structure of the input buffer is designed 8316535Sedwardto avoid race conditions without blocking interrupts. 8416284Sedward 8516284Sedward Wwiomux() copies pseudo-terminal outputs into their corresponding 8616284Sedwardwindows. Without anything to do, it blocks in a select(), waiting for 8716284Sedwardread ready on pseudo-terminals. Reads are done into per-window buffers 8816284Sedwardin the window structures. When there is at least one buffer non-empty, 8916284Sedwardwwiomux() finds the top most of these windows and writes it using 9016535Sedwardwwwrite(). Then the process is repeated. A non-blocking select() is 9116535Sedwarddone after a wwwrite() to pick up any output that may have come in 9216535Sedwardduring the write, which may take a long time. Specifically, we use 9316535Sedwardthis to stop output or flush buffer when a pseudo-terminal tells us to 9416535Sedward(we use pty packet mode). The select() blocks only when all of the 9516535Sedwardwindows' buffers are empty. A wwupdate() is done prior to this, which 9616535Sedwardis the only time the screen is guaranteed to be completely up to date. 9716535SedwardWwiomux() loops until wwinterrupt() becomes true. 9816284Sedward 9916535Sedward The top level routine for all this is mloop(). In conversation 10016535Sedwardmode, it simply calls wwiomux(), which only returns when input is 10116535Sedwardavailable. The input buffer is then written to the pseudo-terminal of 10216535Sedwardthe current window. If the escape character is found in the input, 10316535Sedwardcommand mode is entered. Otherwise, the process is repeated. In 10416535Sedwardcommand mode, control is transferred to docmd() which returns only when 10516535Sedwardconversation mode is reentered. Docmd() and other command processing 10616535Sedwardroutines typically wait for input in a loop: 10716284Sedward 10816535Sedward while (wwpeekc() < 0) 10916284Sedward wwiomux(); 11016284Sedward 11116535SedwardWhen the loop terminates, wwgetc() is used to read the input buffer. 11216284Sedward 11316284Sedward Output to the physical terminal is handled by the lowest level 11416284Sedwardroutines of the window package, in the files ttoutput.c and tt.h. The 11516535Sedwardstandard IO package is not used, to get better control over buffering 11616535Sedwardand to use non-blocking reads in wwrint(). The buffer size is set to 11716284Sedwardapproximately one second of output time, based on the baudrate. 11816284Sedward 11916284Sedward The result of all this complexity is faster response time, 12016284Sedwardespecially in output stopping and flushing. Wwwrite() checks 12116284Sedwardwwinterrupt() after every line. It also calls wwupdate() for each line 12216284Sedwardit writes. The output buffer is limited to one second of output time. 12316284SedwardThus, there is usually only a delay of one to two lines plus one second 12416284Sedwardafter a ^C or ^S. Also, commands that produce lengthy output can be 12516284Sedwardaborted without actually showing all of it on the terminal. (Try the 12616535Sedward'?' command followed by escape immediately.) 127