[net.sources] "grotwin" mods for non-Suns

dpz@topaz.RUTGERS.EDU (David P. Zimmerman) (08/24/86)

Here's a shar file containing the one file I modified to get "grotwin"
running on non-Sun Unix machines, plus an enhanced Makefile and
updated README.  I have successfully run it on Pyramids 90x/98x/98xe
and Celeritys 1200/1230.

------------------------- cut here ------------------------------
# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# README Makefile grotwin.h

echo x - README
cat > "README" << '//E*O*F README//'
This is the README file for the grotwin window manager for normal terminals.

You will have to place the following file definitions contained in grotwin.c
in your locally developed program site /usr/bin equivelent (default of
/usr/mrc shown) :-

manfile[]       = "/usr/mrc/grotwin.man";
helpfile[]      = "/usr/mrc/grotwin.help";
system_more[]   = "more";


You will also need to place the following entry in /etc/termcap (for commands
like tset).

#==================================
#
#	Following entry for grotwin pseudo terminals
#
	gr|grotty|grotwin pseudo tty:\
	:co#78:li#22:cl=^L:cm=\E=%+ %+ :am:bs:nd=^X:ce=^Y:\
	:up=^K:do=^J:kb=^H:so=^E:se=^F:al=^A:dl=^B:
#==================================


Having upshared each file entry via 'sh file', you will need to copy
grotwin.make to Makefile before you can make grotwin.
Having typed 'make' to make grotwin, you will also need to type 'make man'
in order to nroff the manual page.  I'm on holiday from August 12 - 27
inclusive, so any problems will have to sorted out by other people on the net
during this period.

Grotwin has been developed on a Sun 2 running release 2.2.  It should
however, run on any BSD 4.2 or 4.3 system, or indeed any system
which has pseudo terminals and the ability to poll a file descriptor
(select(), ioctl(FIONREAD) or otherwise).

On my system at least, the screen occasionally gets corrupted.  This
is due to the serial line as it doesn't happen at 4800 or on a
sun window.  The fix is simple, simply get grotwin to redraw
the screen as and when it occurs (via ctrl-a l); this is much
more useful than slowing down the serial line speed.

Have fun using it - and remember, it will never be as good as a bit-mapped
windowing system.  It is however, generally more useful than a normal screen
when multiple sessions are required.  I'd be grateful for any feedback/gripes
but remember that as I'm away there will be a delay in my answering them.



Nigel Holder                    UK JANET:       yf21@uk.co.gec-mrc.u
Marconi Research,               ARPA:           yf21%u.gec-mrc.co.uk@ucl-cs
Chelmsford,
Essex. CM2 8HN.

+44 245 73331   ext. 3219 / 3214

=============================================================================

Changes made to grotwin by dpz, 08/23/86

I made relatively few changes to grotwin to get it to run on non-Sun
Unix machines.  I added a struct and a few #defines to the end of
grotwin.h, and I also modified the Makefile so that enabling a -DSUN
will compile grotwin for a Sun, and not enabling it will compile for
"the rest of us".  I guess you could call this modified grotwin
version 2.2a, for want of some way to refer to it.

---
David P. Zimmerman

Arpa: dpz@topaz.rutgers.edu
Uucp: ...{allegra | harvard | seismo | sri-iu | ut-sally}!topaz!dpz
//E*O*F README//

echo x - Makefile
cat > "Makefile" << '//E*O*F Makefile//'
#    Makefile for grotwin window manager on 24 x 80 type terminals

#    Enable next line to install for Sun
#    SUNFLAGS=-DSUN

grotwin: grotwin.o manager.o window.o update.o utmp.o
	cc -O -o grotwin grotwin.o manager.o window.o update.o utmp.o -lcurses -ltermlib

grotwin.o:	grotwin.c grotwin.h
		cc $(SUNFLAGS) -O -c grotwin.c

manager.o:	manager.c grotwin.h
		cc $(SUNFLAGS) -O -c manager.c

window.o:	window.c grotwin.h
		cc $(SUNFLAGS) -O -c window.c

update.o:	update.c grotwin.h
		cc $(SUNFLAGS) -O -c update.c

utmp.o:		utmp.c
		cc $(SUNFLAGS) -O -c utmp.c

man:
		nroff -man grotwin.nroffman > grotwin.man
//E*O*F Makefile//

echo x - grotwin.h
cat > "grotwin.h" << '//E*O*F grotwin.h//'
/***************************************
*
*	Author  :  Nigel Holder
*
*	Date    :  10 July 1986
*
*	   Grotwin - provides a somewhat primitive windowing capability
*	for people unfortunate enough to use the standard 24 x 80 type
*	of terminal when the console is in use.  Definitely written for
*	4.[2,3] at the present time, as Sys V.2 does not cater for pseudo
*	terminals or have the select() facility (amongst other things !)
*	(version 8 should fix this).
*
*	Files used :-
*
*	   grotwin.c	 -	window system initialisation
*				deals with startup files
*
*	   manager.c	 -	window manager
*				deals with input and output
*
*	   window.c	 -	window manipulator
*				deals with aspects concerning windows
*				during normal usage
*
*	   update.c	 -	simulates dumb terminal for use
*				with window manager.
*
*	   grotwin.h	 -	header file for above
*
*	   utmp.c	 -	utmp manipulator
*				updates utmp entries for each window
*
*	   grotwin.make  -	makefile for above
*	   
*	Bugs :-
*
*	   Can't have the situation where no windows are present !
*	   Needs a vt100 like terminal type
*
***************************************/



#include <stdio.h>
#include <sys/param.h>
#include <curses.h>



/*******************
*      The following defines are very ascii dependent (which is good since its
*   anti-IBM EBSDIC)
*******************/


/*******************
*   maximum number of windows (maximum of 10 imposed), depends on
*   stdin, stdout, stderr, utmp update and two per window
*   (NOFILE is 30 on a Sun 2 running op sys version 2.2, normally 20
*   though on unix systems)
*******************/

#define		SYSTEM_WINDOWS		( (NOFILE - 4) / 2 )

#define		MAX_WINDOWS		( 10 )		/*  windows 0 to 9  */

#if		( MAX_WINDOWS > SYSTEM_WINDOWS )
#undef		MAX_WINDOWS
#define		MAX_WINDOWS		( SYSTEM_WINDOWS )
#endif		MAX_WINDOWS

#define		MAX_WINDOWS_PLUS	( MAX_WINDOWS + 1 )

#define		REALLY_CONFUSED		( 2 )
#define		READGRAIN		( 2 )
#define		CTRL_MASK		( 0x1F )
#define		WIN_SWITCH_NUMBER	( (unsigned char) 0x80 )

/*  user window control commands  */
#define		SELECT			( 'a' & CTRL_MASK )
#define		WIN_SWITCH		( 'w' & CTRL_MASK )
#define		NEW_WINDOW		( 'n' & CTRL_MASK )
#define		FORCED_EXIT		( 'f' & CTRL_MASK )
#define		REMOVE_WIN		( 'r' & CTRL_MASK )
#define		CLEAR			( 'z' & CTRL_MASK )
#define		MOVE			( 'm' & CTRL_MASK )
#define		EXPAND			( 'x' & CTRL_MASK )
#define		VERTICAL_EXPAND		( 'v' & CTRL_MASK )
#define		HORIZONTAL_EXPAND	( 'c' & CTRL_MASK )
#define		EXPOSE_WINDOW		( 'e' & CTRL_MASK )
#define		HIDE_WINDOW		( 'h' & CTRL_MASK )
#define		SCREEN_REDRAW		( 'l' & CTRL_MASK )
#define		XON			( 'q' & CTRL_MASK )
#define		XOFF			( 's' & CTRL_MASK )
#define		PAGE_MODE		( 'p' & CTRL_MASK )
#define		OVERWRITE_MODE		( 'o' & CTRL_MASK )
#define		TIME_TOGGLE		( 't' & CTRL_MASK )
#define		INFORM			( 'i' & CTRL_MASK )
#define		HELP			( '?' )

#define		BUFLEN			( 256 )
#define		TIME_RES		( 30 )
#define		HIDE			( 0 )
#define		DISPLAY			( 2 )
#define		REMOVE			( 1 )
#define		MAXARGS			( 20 )
#define		WORLD_MIN_COLUMNS	( 20 )
#define		WORLD_MIN_ROWS		( 6 )
#define		MIN_COLUMNS		( 3 )
#define		MIN_ROWS		( 4 )		/*  3 doesn't work  */
#define		OVERLAY			( 4 )
#define		BOX			( 1 )
#define		NOT_BOX			( 0 )
#define		BAD_INPUT		( 0 )
#define		MISTAKE			( 1 )
#define		NORMAL			( 2 )

#define		BACKGROUND		'.'

#define         WIN_STANDOUT            ( (char) 0x80 ) 
#define         WIN_STANDEND            ( (char) 0x00 ) 



struct windowdetails   {
		int	active;
		int	masterfd;
		int	slavefd;
		int	slavepid;
		int	slavemaskfd;
		int	output_blocked;
		int	output_paged;
		int	line_count;
		int	paged_page_full;
		int	overwrite;
		int	cursor_addressing;
		int	cursor_addr_passes;
		int	cursor_addr_row;
		int	lines;
		int	columns;
		int	x_current;
		int	y_current;
		int	x_start;
		int	y_start;
		int	x_end;
		int	y_end;
		int	readgrain;
		int	page_buf_length;
		char	**screenptr;
		char	*page_ptr;
		char	page_buf[BUFSIZ + 3];
		char	pseudo_ttyname[20];
		char	*progy;
		char	standout_mode;
};

/* dpz additions to grotwin.h for non-sun machines 08/23/86 */

#ifndef SUN

struct ttysize {
	int	ts_lines;	/* number of lines on terminal */
	int	ts_cols;	/* number of columns on terminal */
};

#define	TIOCSSIZE	_IOW(t,103,struct ttysize)/* set tty size */
#define	SIGWINCH 28	/* window changed */
#undef  NOFILE          /* not on a sun, so make it 20 */
#define NOFILE 20

#endif
//E*O*F grotwin.h//

exit 0