Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site umcp-cs.UUCP
Path: utzoo!linus!decvax!harpo!seismo!rlgvax!cvl!umcp-cs!chris
From: chris@umcp-cs.UUCP
Newsgroups: net.sources
Subject: Window library changes (now version 1.05)
Message-ID: <1115@umcp-cs.UUCP>
Date: Sun, 24-Jul-83 07:40:59 EDT
Article-I.D.: umcp-cs.1115
Posted: Sun Jul 24 07:40:59 1983
Date-Received: Sun, 24-Jul-83 16:09:19 EDT
Organization: Univ. of Maryland, Computer Science Dept.
Lines: 758
Well, here's a new set of fixes and fixed files for the window
package. There's also a man 3 page at the end. This set of changes
marks version 1.05 of the Maryland Window Library.
- Chris
: Run this shell script with "sh" not "csh"
PATH=:/bin:/usr/bin:/usr/ucb
export PATH
all=FALSE
if [ $1x = -ax ]; then
all=TRUE
fi
cat <<'eof' | tee CHANGE
Changes to make to the documentation:
The SetReal macro was incorrect. The capital Es should be
capital Os, ie w->IXE should read w->IXO.
In the alphabetical list of functions (appendix 2), Wretroline
was missing the third argument "inwin", and Wsetmargins
listed had its arguments listed in the wrong order. The
correct order is Wsetmargins(w,inxorg,inyorg,inxext,inyext).
Other changes to make:
Set the version number in open.c to 1.05 and the release
date to 24-Jul-1983. Apply the diff -c listing for display.c.
Notes:
There is a new, hopefully more coherent, README. There
is a man page.
eof
/bin/chmod 644 CHANGE
/bin/echo -n ' '; /bin/ls -ld CHANGE
/bin/echo 'Extracting read.c'
sed 's/^X//' <<'//go.sysin dd *' >read.c
#include "win.h"
X/* Copyright (c) 1983 University of Maryland Computer Science Department */
X/* Read back from window at cursor, and advance cursor */
X/* If charonly set returns only char (not mode< w_winbuf +
(w -> w_cursor.row + w -> IYO) * w -> OXE +
w -> w_cursor.col + w -> IXO;
int rv;
if (!winonly && (c -> Mode & WBUF))
c = w -> w_bcursor;
rv = charonly ? c -> Char : c -> ch_all;
w -> w_cursor.col++;
w -> w_bcursor++;
if (w -> w_cursor.col >= w -> IXE) {
w -> w_cursor.col = 0;
w -> w_cursor.row++;
if (w -> w_cursor.row >= w -> IYE)
w -> w_cursor.row = 0;
WFixCursor (w);
}
if ((w -> w_status & WCURSOR) == 0)
w -> w_status |= WDUMP;
return rv;
}
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 read.c
/bin/echo -n ' '; /bin/ls -ld read.c
fi
/bin/echo 'Extracting suspend.c'
sed 's/^X//' <<'//go.sysin dd *' >suspend.c
#include "win.h"
#include
X/* Copyright (c) 1983 University of Maryland Computer Science Department */
int (*sigset())();
X/* Suspend window system (called on ^Z) */
X/* NOTE: if SigMagic is not set user must make sure that SIGTSTP does what he
wants */
Wsuspend () {
int (*oldtstp) (), (*oldint) ();
static nest, restart; /* Dont want to recurse */
if (nest)
return restart++, 0;
nest = 1;
top:
if (SigMagic) { /* Then save signal definitions */
sigrelse (SIGTSTP);
sigrelse (SIGINT); /* Make sure they arent held */
/* NOTE: if sigrelse calls Wsuspend "nest" gets us back */
oldtstp = sigset (SIGTSTP, SIG_IGN);
oldint = sigset (SIGINT, SIG_IGN);
}
restart = 0;
Wcleanup (); /* If SigMagic, resets sigs to SIG_DFL */
kill (0, SIGTSTP); /* SCREECHing halt */
if (SigMagic) {
sighold (SIGTSTP);
sighold (SIGINT); /* Hold these for Winit to do its stuff, */
sigset (SIGTSTP, oldtstp);
sigset (SIGINT, oldint);/* putting them back where they were */
}
/* (void) */ Winit (1, 1); /* (void) breaks some compilers */
if (SigMagic) {
sigrelse (SIGTSTP);
sigrelse (SIGINT);
if (restart) /* If TSTP signal occurred during Winit */
goto top; /* Note: the oldxxx=sigset() is OK because we
have already restored the settings */
Wrefresh ();
if (restart) /* If the Wrefresh was suspended */
goto top;
}
return nest = 0;
}
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 suspend.c
/bin/echo -n ' '; /bin/ls -ld suspend.c
fi
/bin/echo 'Extracting win.h'
sed 's/^X//' <<'//go.sysin dd *' >win.h
X/* Copyright (c) 1983 University of Maryland Computer Science Department */
#define NBPB 8 /* Number of bits per byte */
union chr {
struct {
char ch; /* NOTE: this is known to be low byte */
char mode;
} ch_two;
short ch_all;
};
X/* ch_all is set to ' ' or (' '|(WBUF<(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 win.h
/bin/echo -n ' '; /bin/ls -ld win.h
fi
/bin/echo 'Extracting window.h'
sed 's/^X//' <<'//go.sysin dd *' >window.h
X/* Copyright (c) 1983 University of Maryland Computer Science Department */
#include "win.h"
#define Wwrap(w,on) ((w)->w_status &= ~WWRAPOFF, \
(w)->w_status |= (on)?0:WWRAPOFF, 0)
#define Wnewline(w,on) ((w)->w_status &= ~WNEWLINE, \
(w)->w_status |= (on)?WNEWLINE:0, 0)
#define Wsetmode(w,m) ((w)->w_mode &= ~MODEMASK, \
(w)->w_mode |= (m) & MODEMASK, 0)
#define Wsetpopup(w,p) ((w)->w_popup = (p), 0)
#define Wcurup(w,n) (WAcursor (w, \
(w)->w_cursor.row+(w)->w_bstart.row-(n),\
(w)->w_cursor.col+(w)->w_bstart.col))
#define Wcurdown(w,n) (WAcursor (w, \
(w)->w_cursor.row+(w)->w_bstart.row+(n),\
(w)->w_cursor.col+(w)->w_bstart.col))
#define Wcurleft(w,n) (WAcursor (w, \
(w)->w_cursor.row+(w)->w_bstart.row,\
(w)->w_cursor.col+(w)->w_bstart.col-(n)))
#define Wcurright(w,n) (WAcursor (w, \
(w)->w_cursor.row+(w)->w_bstart.row,\
(w)->w_cursor.col+(w)->w_bstart.col+(n)))
#define WWtoBcursor(w) (WAcursor (w, \
(w)->w_textbuf->b_cursor.row-(w)->IYO,\
(w)->w_textbuf->b_cursor.col-(w)->IXO))
X/* NOTE: THESE MACROS MAY BE SYSTEM DEPENDENT */
#define WCHAROF(c) ((c)&0377)
#define WMODEOF(c) ((c)>>NBPB)
X/* Function types for non-integer functions */
Win *Wopen (), *Wlink (), *Wfind (), *Wboxfind ();
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 window.h
/bin/echo -n ' '; /bin/ls -ld window.h
fi
/bin/echo 'Extracting bdelchars.c'
sed 's/^X//' <<'//go.sysin dd *' >bdelchars.c
#include "win.h"
X/* Copyright (c) 1983 University of Maryland Computer Science Department */
X/* Delete n chars from buffer at cursor */
WBdelchars (w, n)
Win *w;
int n;
{
register Buf *b;
register Ch *cp, *ct, *cend;
int blank;
if (n < 0)
return -1;
if (n == 0)
return 0;
b = w -> w_textbuf;
if (n + b -> b_cursor.col > b -> b_ncols)
n = b -> b_ncols - b -> b_cursor.col;
blank = ' ' | (w -> w_mode << NBPB);
ct = b -> b_contents + b -> b_cursor.row * b -> b_ncols;
cend = ct + b -> b_ncols;
ct += b -> b_cursor.col;
cp = ct + n;
while (cp < cend)
ct++ -> ch_all = cp++ -> ch_all;
while (ct < cend)
ct++ -> ch_all = blank;
b -> b_nmodw = -1;
return 0;
}
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 bdelchars.c
/bin/echo -n ' '; /bin/ls -ld bdelchars.c
fi
/bin/echo 'Extracting binschars.c'
sed 's/^X//' <<'//go.sysin dd *' >binschars.c
#include "win.h"
X/* Copyright (c) 1983 University of Maryland Computer Science Department */
X/* Insert n blanks in buffer at cursor */
WBinschars (w, n)
Win *w;
int n;
{
register Buf *b;
register Ch *cp, *ct, *start;
int blank;
if (n < 0)
return -1;
if (n == 0)
return 0;
b = w -> w_textbuf;
if (n + b -> b_cursor.col > b -> b_ncols)
n = b -> b_ncols - b -> b_cursor.col;
blank = ' ' | (w -> w_mode << NBPB);
ct = b -> b_contents + b -> b_cursor.row * b -> b_ncols;
start = ct + b -> b_cursor.col;
ct += b -> b_ncols;
cp = ct - n;
while (cp > start)
(--ct) -> ch_all = (--cp) -> ch_all;
while (ct > start)
(--ct) -> ch_all = blank;
b -> b_nmodw = -1;
return 0;
}
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 binschars.c
/bin/echo -n ' '; /bin/ls -ld binschars.c
fi
/bin/echo 'Extracting README'
sed 's/^X//' <<'//go.sysin dd *' >README
Note: Comments are in [square brackets].
Installation
------------
Look at the Makefile for installation instructions. Everything is
set up for a Vax running Berkeley Unix. If you're running Berkeley
Unix, you should only need to ``make winlib.a'' followed by a ``make
install''.
Not on a Vax?
-------------
If you're not on a Vax, several changes are in order. First, take
out the -DVAX flag in the Makefile. Second, find out whether the
definition of union chr in win.h must be changed. For a 68000,
the two char elements should be reversed. Third, you'll probably
get a name conflict on WBclear and WBclearline, and on setmode and
setmodes in TrmTERM.c. [Wonderful how the eight-character limit
turns into 7 after compiling] For the first, add the following
line to win.h:
#define WBclearline WBclrln
For the second, add the following line to the top of TrmTERM.c:
#define setmodes smodes
Fourth, you may get an error in init.c (something like "Undefined:
_IOLBF"). If so, change the appropriate line to remove the "_IOLBF|"
from it. [So much for "standard" I/O]
Finally, you may not have ranlib. See the Makefile for an alternative.
The above changes were sufficient to make winlib run on a Sun
Microsystems workstation and on a Codata CTW-300. (Both are 68000
based.)
Berkeley 2.8, Anyone?
---------------------
More changes were sent from someone bringing up windows on a PDP11
running Berkeley 2.8+ (2.8 with many 4.1a features):
1. Ranlib didn't work correctly; using the TSORT file worked.
2. globals.c didn't properly define the global variables because
it includes win.h (which marks them external). [This sounds like
a compiler bug] The solution used was to extract the type definitions
from win.h and put them in globals.c, and to define a routine
Windummy(){} in globals.c and call it from init.c (otherwise the
linker ignored globals.o [sounds like a linker bug]). [Another
possibility is to move the definition of NoOperation to globals.c,
although it doesn't really belong there.]
Too big?
--------
Windows is undeniably large. It can be shrunk considerably by
changing two constants defined in display.c, namely MScreenLength
and MScreenWidth. These are the sizes-plus-one of the largest
screen that can be handled. It's currently set up to handle up to
60 lines and up to 135 columns.
Also, you could eliminate some of the Trm*.c terminal drivers.
This requires a bit of modification to display.c as well. Near
the bottom of display.c there is a table of terminal types and
drivers. It should be reasonably obvious how to modify this.
But it's so slow!
-----------------
The TrmTERM.c code for cursor motion is ridiculous. I will probably
eventually rewrite the whole module. For now, if you have a
particular terminal, write a special driver for it. See the second
paragraph under "Too Big?" for more info.
For greater speed, you may want to try rewriting bcopy (bcopy.c)
and/or CopyLine (display.c) in assembly code. I found rewriting
bcopy to copy by words and changing CopyLine to call bcopy to copy
the line text sufficient on the Sun.
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 README
/bin/echo -n ' '; /bin/ls -ld README
fi
/bin/echo 'Extracting diff-c-display'
sed 's/^X//' <<'//go.sysin dd *' >diff-c-display
*** display.c.old Sun Jul 17 19:34:44 1983
--- display.c Mon Jul 18 01:25:55 1983
***************
*** 77,82
#define ScreenWidth (W_tt.t_width)
#define ScreenLength (W_tt.t_length)
#define MScreenWidth 135
#define MScreenLength 60
#define min(a,b) (ab ? a : b)
#define hidden static
--- 80,86 -----
/* These two numbers are actually one greater than the maximum allowed
screen width/length */
#define MScreenWidth 135
! #define MScreenLength 61
#define min(a,b) (ab ? a : b)
#define hidden static
***************
*** 180,187
visible int
ScreenGarbaged, /* set to 1 iff screen content is
! uncertain. */
! InputPending, /* true iff input is known to be pending */
LastRedisplayPaused,/* true iff last redisplay paused */
#ifdef DEBUG
RDdebug, /* line redraw debug switch */
--- 182,188 -----
visible int
ScreenGarbaged, /* set to 1 iff screen content is
! uncertain. */
LastRedisplayPaused,/* true iff last redisplay paused */
#ifdef DEBUG
RDdebug, /* line redraw debug switch */
***************
*** 191,196
virtual screen. */
WDleft; /* number of columns left on the current
line of the virtual screen. */
visible Ch
*WDcursor; /* pointer into a line object, indicates
where to put the next character */
--- 192,199 -----
virtual screen. */
WDleft; /* number of columns left on the current
line of the virtual screen. */
+ visible long
+ InputPending; /* true iff input is known to be pending */
visible Ch
*WDcursor; /* pointer into a line object, indicates
where to put the next character */
***************
*** 220,228
&& (p = DesiredScreen[WDCurrentLine]) -> length
<= (n = ScreenWidth - WDleft))
p -> length = WDleft > 0 ? n : ScreenWidth;
! if (!DesiredScreen[row])
! DesiredScreen[row] = newline ();
! (p = DesiredScreen[row]) -> hash = 0;
p -> touched = 1;
WDcursor = &p -> body[col - 1];
WDCurrentLine = row;
--- 223,231 -----
&& (p = DesiredScreen[WDCurrentLine]) -> length
<= (n = ScreenWidth - WDleft))
p -> length = WDleft > 0 ? n : ScreenWidth;
! if ((p = DesiredScreen[row]) == 0)
! DesiredScreen[row] = p = newline ();
! p -> hash = 0;
p -> touched = 1;
WDcursor = &p -> body[col - 1];
WDCurrentLine = row;
***************
*** 244,250
/* 'hashline' computes a hash value for a line, unless the hash value
is already known. This hash code has a few important properties:
- it is independant of the number of leading and trailing spaces
! - it will never be zero
As a side effect, an estimate of the cost of redrawing the line is
calculated */
--- 247,253 -----
/* 'hashline' computes a hash value for a line, unless the hash value
is already known. This hash code has a few important properties:
- it is independant of the number of leading and trailing spaces
! - it will never be zero (nor 12345)
As a side effect, an estimate of the cost of redrawing the line is
calculated */
***************
*** 989,998
rv = (*W_tt.t_init) (baud_rate);
if (rv)
return rv;
! if (W_tt.t_length > MScreenLength)
! W_tt.t_length = MScreenLength;
! if (W_tt.t_width > MScreenWidth)
! W_tt.t_width = MScreenWidth;
(*W_tt.t_reset) ();
return 0;
}
--- 992,1001 -----
rv = (*W_tt.t_init) (baud_rate);
if (rv)
return rv;
! if (W_tt.t_length >= MScreenLength)
! W_tt.t_length = MScreenLength - 1;
! if (W_tt.t_width >= MScreenWidth)
! W_tt.t_width = MScreenWidth - 1;
(*W_tt.t_reset) ();
return 0;
}
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 diff-c-display
/bin/echo -n ' '; /bin/ls -ld diff-c-display
fi
/bin/echo 'Extracting winlib.3'
sed 's/^X//' <<'//go.sysin dd *' >winlib.3
X.TH WINLIB 3 "U of Maryland"
X.SH NAME
winlib \- high level window display and screen control package
X.SH SYNOPSIS
X.B cc
[ flags ] files
X.B \-lwinlib \-ljobs \-ltermlib
[ libraries ]
X.SH DESCRIPTION
These routines allow for the creation, manipulation, and destruction of
X.BR windows .
In order to use them the user must
X.BR "#include " .
The function
X.I Winit(settings,nomagic)
initializes the window system;
X.I Wrefresh(SkipInputCheck)
updates the screen; and
X.I Wcleanup()
cleans up after the mess. The parameters to
X.I Winit()
are noramally both zero, but
X.I settings
may be a pointer to a
X.B "struct sgttyb"
and nomagic may be non-zero to disable default signal handling. The
argument to
X.I Wrefresh()
is normally zero, but may be nonzero to force a refresh regardless of
pending input. The functions are listed below. In the listing,
X.I w
implies a parameter of type
X.BR "Win\ *" ,
X.I c
implies type
X.BR char ,
X.I s
implies type
X.BR "char\ *" ,
and
X.I m
is an integer parameter made up of zero or more of the constants WBOLD,
WULINE, WINVERSE, and WBLINK (\fImode\fRs).
Other parameters are of type
X.B int
unless otherwise specified.
X.SH SEE ALSO
X.I "The Maryland Window Library,"
Chris Torek,
X.br
signal(2),
stty(2),
jobs(3j),
setenv(3),
tty(4),
termcap(5)
X.SH AUTHOR
Chris Torek
X.SH FUNCTIONS
X.nf
X.ta 3i
X.tc .
Ding() ring terminal's bell
Max(a,b) return the maximum of (a,b)
Min(a,b) return the minimum of (a,b)
WAcursor(w,row,col) move window cursor absolute
WAread(w,charonly) read window at aux cursor
WBclear(w,howto) clear buffer
WBclearline(w,howto) clear buffer line
WBcursor(w,row,col) move buffer cursor
WBdelchars(w,n) delete characters from buffer
WBdelcols(w,n) delete columns from buffer
WBdellines(w,n) delete lines from buffer
WBinschars(w,n) insert characters in buffer
WBinscols(w,n) insert columns in buffer
WBinslines(w,n) insert lines in buffer
WBputc(c,w) put character to buffer
WBputs(s,w) put string to buffer
WBread(w,charonly) read back from buffer
WBscroll(w,rows) scroll buffer
WBtoWcursor(w) move buffer cursor to underneath window cursor
WCHAROF(c) character portion of read-back integer \fIc\fR
WMODEOF(c) mode portion of read-back integer \fIc\fR
WWcursor(w,row,col) move window cursor window relative
WWtoBcursor(w) move window cursor to above buffer cursor
Waputc(c,m,w) put character to winbuf at aux cursor
Waputs(s,m,w) put string to winbuf at aux cursor
Wauxcursor(w,row,col) move aux cursor
Wback(w) move window to the back of the screen
Wborder(w,ulc,top,urc,left,right,llc,bottom,lrc) border window with specified characters
Wbox(xorg,yorg,xext,yext) activate the box
\fBWin *\fRWboxfind() return window pointed to by the box
Wcleanup() clean up terminal settings
Wclear(w,howto) clear window
Wclearline(w,howto) clear window line
Wclose(w) close window
Wcloseall() close all windows
Wcurdown(w,n) move window cursor down
Wcurleft(w,n) move window cursor left
Wcurright(w,n) move window cursor right
Wcurup(w,n) move window cursor up
Wdelchars(w,n) delete characters from window
Wdelcols(w,n) delete columns from window
Wdellines(w,n) delete lines from window
Wexit(code) call Wcleanup(), call exit(code)
Wfiledump(file) dump virtual screen to named \fBchar *\fIfile\fR
\fBWin *\fRWfind(id) return window with id \fIid\fR
Wframe(w) frame window
Wfront(w) move window to the front of the screen
Wgetframe(ulc,top,urc,left,right,llc,bottom,lrc) set the \fBchar *\fR arguments to the frame characters
Whide(w) hide window
Winit(settings,nomagic) initialize windows
Winschars(w,n) insert characters in window
Winscols(w,n) insert columns in window
Winslines(w,n) insert lines in window
Wlabel(w,label,bottom,center) label window with \fBchar *\fIlabel\fR
\fBWin *\fRWlink(ew,id,xorg,yorg,xext,yext,bcols,brows) link to existing window \fIew\fR
Wmove(w,xorg,yorg) reposition window
Wnewline(w,on) set auto-newline mode
Woncursor(w,on) set window cursor visibility
\fBWin *\fRWopen(id,xorg,yorg,xext,yext,bcols,brows) open a window
Wputc(c,w) put character to window
Wputs(s,w) put string to window
Wread(w,charonly,winonly) read back from window
Wrefresh(SkipInputCheck) refresh screen
Wrelscroll(w,rows,cols,cwin) scroll window over buffer
Wretroline(w,m,inwin) retroactively paint a line
Wscreensize(rows,cols) set \fBint *\fIrows, *cols\fR to screen size
Wscroll(w) scroll window w
Wsetbuf(w,bcols,brows) set buffering
Wsetframe(ulc,top,urc,left,right,llc,bottom,lrc) set the frame characters
Wsetmargins(w,inxorg,inyorg,inxext,inyext) set window margins
Wsetmode(w,m) set text-writing mode
Wsetpopup(w,p) set popup
Wsize(w,xext,yext) change window size
Wsuspend() suspend session (^Z)
Wunhide(w) unhide window
Wwrap(w,n) set autowrap mode
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
/bin/chmod 644 winlib.3
/bin/echo -n ' '; /bin/ls -ld winlib.3
fi
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci
UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet: chris@umcp-cs
ARPA: chris.umcp-cs@UDel-Relay