Name Date Size #Lines LOC

..13-Oct-2023-

MakefileH A D08-May-20221.1 KiB2619

READMEH A D08-May-20229.4 KiB196169

alias.hH A D08-May-20222.3 KiB5513

char.cH A D08-May-20225.7 KiB146101

char.hH A D08-May-20222.5 KiB6010

cmd.cH A D08-May-20226.1 KiB303252

cmd1.cH A D08-May-20224.2 KiB168128

cmd2.cH A D08-May-20225.3 KiB153109

cmd3.cH A D08-May-20222.1 KiB6022

cmd4.cH A D08-May-20222.1 KiB5315

cmd5.cH A D08-May-20223.3 KiB12675

cmd6.cH A D08-May-20222.9 KiB10863

cmd7.cH A D08-May-20226 KiB282223

compress.cH A D08-May-202219.8 KiB902786

context.cH A D08-May-20223.2 KiB13285

context.hH A D08-May-20223.2 KiB8642

defs.hH A D08-May-20224.4 KiB12882

error.cH A D08-May-20222.8 KiB10158

lcmd.cH A D08-May-20224.2 KiB12381

lcmd.hH A D08-May-20223.4 KiB8442

lcmd1.cH A D08-May-20229.3 KiB432352

lcmd2.cH A D08-May-20229.8 KiB385318

local.hH A D08-May-20222 KiB508

main.cH A D21-Feb-20234.6 KiB187140

mloop.cH A D08-May-20222.7 KiB8546

parser.hH A D08-May-20222.6 KiB6324

parser1.cH A D08-May-20224.4 KiB225168

parser2.cH A D08-May-20225.7 KiB230182

parser3.cH A D08-May-20224 KiB188114

parser4.cH A D08-May-20226 KiB293241

parser5.cH A D08-May-20224.4 KiB196147

scanner.cH A D08-May-202211.5 KiB591541

startup.cH A D08-May-20223.1 KiB9348

string.cH A D21-Feb-20233.4 KiB14693

token.hH A D08-May-20222.6 KiB8243

tt.hH A D08-May-20225.6 KiB17994

ttf100.cH A D08-May-20222.3 KiB6623

ttgeneric.cH A D08-May-202212.2 KiB591510

tth19.cH A D08-May-20226.1 KiB300224

tth29.cH A D08-May-20222.9 KiB9337

ttinit.cH A D08-May-20223.3 KiB11667

ttoutput.cH A D08-May-20223.3 KiB14395

tttermcap.cH A D08-May-20223 KiB11466

tttvi925.cH A D08-May-20222.2 KiB6118

ttwyse60.cH A D08-May-20222.5 KiB7326

ttwyse75.cH A D08-May-20222.5 KiB7326

ttzapple.cH A D08-May-20229.1 KiB522429

ttzentec.cH A D08-May-20222.3 KiB6318

value.hH A D08-May-20222 KiB5314

var.cH A D08-May-20223.6 KiB14294

var.hH A D08-May-20222.6 KiB6423

win.cH A D08-May-20228.1 KiB361248

window.1H A D21-Feb-202324.4 KiB1,0651,064

window_string.hH A D21-Feb-20232.4 KiB7327

windowrcH A D08-May-20222.9 KiB8579

ww.hH A D08-May-202213.1 KiB392292

wwadd.cH A D08-May-20222.7 KiB8340

wwalloc.cH A D08-May-20222.3 KiB6828

wwbox.cH A D08-May-20222.3 KiB6022

wwchild.cH A D08-May-20222.4 KiB6728

wwclose.cH A D08-May-20222.2 KiB5720

wwclreol.cH A D08-May-20222.7 KiB9034

wwclreos.cH A D08-May-20222 KiB5112

wwcursor.cH A D08-May-20222.9 KiB8949

wwdelchar.cH A D08-May-20223.2 KiB12063

wwdelete.cH A D08-May-20223.6 KiB13586

wwdelline.cH A D08-May-20222.6 KiB8333

wwdump.cH A D08-May-20223.1 KiB11568

wwend.cH A D08-May-20222.1 KiB6325

wwenviron.cH A D08-May-20223.3 KiB10558

wwerror.cH A D08-May-20222.3 KiB6427

wwflush.cH A D08-May-20223.1 KiB11469

wwframe.cH A D08-May-20225.3 KiB239184

wwgets.cH A D08-May-20223 KiB10463

wwinit.cH A D08-May-20229.1 KiB409329

wwinschar.cH A D08-May-20223.3 KiB12669

wwinsline.cH A D08-May-20222.5 KiB8333

wwiomux.cH A D08-May-20226.2 KiB236172

wwlabel.cH A D08-May-20222.8 KiB9044

wwmisc.cH A D08-May-20222.3 KiB6422

wwmove.cH A D08-May-20222.9 KiB9447

wwopen.cH A D08-May-20225.1 KiB194144

wwprintf.cH A D08-May-20222.1 KiB5515

wwpty.cH A D08-May-20222.2 KiB6022

wwputc.cH A D08-May-20221.9 KiB436

wwputs.cH A D08-May-20221.9 KiB479

wwredraw.cH A D08-May-20222 KiB5416

wwredrawwin.cH A D08-May-20222.4 KiB6830

wwrint.cH A D08-May-20222.6 KiB7624

wwscroll.cH A D08-May-20225.6 KiB230154

wwsize.cH A D21-Feb-20235 KiB186116

wwspawn.cH A D08-May-20222.6 KiB8741

wwsuspend.cH A D08-May-20222.1 KiB5315

wwterminfo.cH A D21-Feb-20233.3 KiB11555

wwtty.cH A D08-May-20224.4 KiB175116

wwunframe.cH A D08-May-20222.5 KiB7232

wwupdate.cH A D08-May-20226.5 KiB269198

wwwrite.cH A D21-Feb-20237.2 KiB296244

xx.cH A D08-May-20225.2 KiB265199

xx.hH A D08-May-20222.6 KiB7836

xxflush.cH A D08-May-20225.7 KiB192131

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