[comp.sources.games] v08i073: unidraw - a text drawing program using curses, Part01/01

billr@saab.CNA.TEK.COM (Bill Randle) (12/07/89)

Submitted-by: mtymp01@ux.acss.umn.edu
Posting-number: Volume 8, Issue 73
Archive-name: unidraw/Part01


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  README COPYRIGHT Makefile command.c fill.c help.c init.c
#   keymap.c main.c redraw.c unidraw.6 unidraw.h
# Wrapped by billr@saab on Wed Dec  6 09:30:30 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(977 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X#ifndef LINT
Xchar COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This
X  program may be distributed if it is impossible for
X  the distributor to get a more up-to-date-version of
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xchar AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
X
XUnidraw is a drawing program. edit makefile, then do 'make install'
Xto make everything happen.
XJust get in to unidraw and do '?'....
Xto get the usage, do 'unidraw -u'...
X
X                      r        a  w   w
X  u   u n  n i  ddd  r r      aa  w   w
X  u   u n  n  i d  d r  r    a a  w   w
X  u   u nn n    d  d r r    a  a  w   w
X  u   u nnnn i  d  d rr     a  a  w   w
X  u   u n nn i  d  d r r    aaaa  w w w
X  u   u n  n i  d  d r  r   a  a  wwww
X   u  u n    i  d  d r  r   a  a  w w
X    uu  n    i  ddd  r  r   a  a
X        n               r      a
X                               a
END_OF_FILE
if test 977 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'COPYRIGHT'\"
else
echo shar: Extracting \"'COPYRIGHT'\" \(388 characters\)
sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
X#ifndef LINT
Xchar COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This
X  program may be distributed if it is impossible for
X  the distributor to get a more up-to-date-version of
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xchar AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
END_OF_FILE
if test 388 -ne `wc -c <'COPYRIGHT'`; then
    echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
fi
# end of 'COPYRIGHT'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(906 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X##ifndef LINT
X#char COPYRIGHT[]="\
X#  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X#  This program is copyright 1989 Nils McCarthy. This
X#  program may be distributed if it is impossible for
X#  the distributor to get a more up-to-date-version of
X#  it. \n\
X#  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X#  ";
X#char AUTHOR[]="Copyright 1989 Nils McCarthy";
X##endif /* LINT */
X# START OF MAKEFILE
XBINDIR=/usr/games
XMANDIR=/usr/man/man6
XOBJS= init.o redraw.o main.o command.o help.o keymap.o fill.o
XSRCS= init.c redraw.c main.c command.c help.c keymap.c fill.c
XCFLAGS=-g
XLIBS= -lcurses -ltermcap #-lcdb
X
Xeverything:
X	more README
X	make install
X
Xoi: over
X	make install
Xover: clean
X	make all
X
Xclean:
X	rm -f $(OBJS) unidraw
X
Xall: unidraw
X
Xunidraw: $(OBJS)
X	cc -o unidraw -g $(OBJS) $(LIBS)
X
X$(OBJS) : unidraw.h
X
Xinstall: unidraw
X	install unidraw $(BINDIR)
X	install -c unidraw.6 $(MANDIR)
X
END_OF_FILE
if test 906 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'command.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'command.c'\"
else
echo shar: Extracting \"'command.c'\" \(3730 characters\)
sed "s/^X//" >'command.c' <<'END_OF_FILE'
X#ifndef LINT
Xstatic char COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
X#include "unidraw.h"
X
Xchar *WinGet(output,mlen,chrset) /* Get a string from a window */
X char *output;
X int mlen;
X char *chrset;
X{
X   char ch;
X   output[0]=NULL;
X   raw();
X   
X   while(strlen(output)<(mlen+1)) { /* so if there is too many chars, it
X				       just dumps them out. */
X      ch=getchar();
X      if(ch==8 || ch==10) /* Backspace */
X	 if(strlen(output)>0) {
X	    output[strlen(output)-1]=NULL;
X	    printw("\b \b");
X	    refresh();
X	 } else {} /* Needed so the following else will take the
X		      right if */
X      else
X	 if(ch==13) { /* enter key */
X	    return(output);
X	 } else
X	    if(chrset==NULL || index(chrset,ch)!=NULL) {
X	       int l; /* Add on a character */
X	       l=strlen(output);
X	       output[l]=ch;
X	       output[l+1]=NULL;
X	       addch(ch);
X	       refresh();
X	    }
X   }
X   return(output);
X   printw("\n");
X   resetty();
X}
X
Xcommand(comm) /* execute a special command */
Xchar *comm;
X{
X   if(!strncmp(comm,"write ",6)) { /* Write to a file */
X      char **writebox;
X      FILE *fptr;
X      char *file;
X      char *linespace;
X      char *line;
X      int i,j;
X
X      writebox=(char **) malloc(PADLINES*sizeof(*writebox));
X      for(i=0;i<PADCOLS;i++)
X	 writebox[i]=malloc(PADCOLS*sizeof(**writebox));
X      linespace=malloc(PADCOLS*sizeof(*linespace));
X      line=linespace+1;
X      linespace[0]=NULL;
X      for(i=0;i<PADLINES;i++)
X	 for(j=0;j<PADLINES;j++)
X	    (writebox[i])[j]=pad(i,j);
X      file=index(comm,' ');
X      file+=1;
X      if(*file==NULL) return;
X      move(3,0);
X      printw("Writing file... ");
X      refresh();
X      fptr=fopen(file,"w");
X      if(fptr==NULL) {
X	 move(3,0);
X	 printw("ERROR: FILE NOT WRITABLE!!! ");
X	 refresh();
X	 return;
X      }
X      line[PADCOLS]=NULL;
X      for(i=0;i<PADLINES;i++) {
X	 for(j=0;j<PADCOLS;j++) /* Take of ending spaces*/
X	    line[j]=pad(i,j);
X	 while(line[strlen(line)-1]==' ' && strlen(line)>0)
X	    line[strlen(line)-1]=NULL;
X	 strcpy(writebox[i],line);
X	 strcat(writebox[i],"\n");
X      }
X      for(i=PADLINES-1;(writebox[i])[0]=='\n' && i>=0;i--)
X	 (writebox[i])[0]=NULL; /* take of ending blank lines */
X      for(i=0;i<PADLINES;i++)
X	 fprintf(fptr,writebox[i]);
X      fclose(fptr);
X   }
X   if(!strncmp(comm,"read ",5)) { /* READ FILE */
X      FILE *fptr;
X      char *file;
X      int i,j;
X      char ch;
X      
X      move(3,0);
X      file=index(comm,' ')+1;
X      if(*file==NULL) return;
X      move(3,0);
X      if((fptr=fopen(file,"r"))==NULL) {
X	 printw("CANNOT OPEN FILE");
X	 refresh();
X	 return;
X      }
X      printw("Reading...");
X      refresh();
X      for(i=0;i<PADLINES;i++)
X	 for(j=0;j<PADCOLS;j++)
X	    pad(i,j)=' ';
X      i=0;j=0;
X      while(j<PADLINES) {
X	 if((ch=fgetc(fptr))==EOF)
X	    return;
X	 if(ch=='\n' || i>PADCOLS) { /* next line */
X	    j++;
X	    i=0;
X	 } else {
X	    pad(j,i)=ch;
X	    i++;
X	 }
X      }
X      redraw();
X   }
X   if(!strcmp(comm,"quit")) /* put the break key in the buffer */
X      ungetc(brk,stdin);
X   if(!strcmp(comm,"suspend")) /* put the suspend key in the buffer */
X      ungetc(suspend,stdin);
X   if(!strcmp(comm,"fill")) /* fill area */
X      fill(padx,pady);
X   if(!strcmp(comm,"clear")) { /* clear area */
X      int i,j;
X      for(i=0;i<PADCOLS;i++)
X	 for(j=0;j<PADLINES;j++)
X	    pad(j,i)=' ';
X   }
X   if(!strcmp(comm,"copy")) /* copyright notice */
X      printw(COPYRIGHT);
X}
END_OF_FILE
if test 3730 -ne `wc -c <'command.c'`; then
    echo shar: \"'command.c'\" unpacked with wrong size!
fi
# end of 'command.c'
fi
if test -f 'fill.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fill.c'\"
else
echo shar: Extracting \"'fill.c'\" \(773 characters\)
sed "s/^X//" >'fill.c' <<'END_OF_FILE'
X#ifndef LINT
Xstatic char COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
X#include "unidraw.h"
X
Xfill(x,y)
X{
X   int xl=x,xr=x,i;
X   while(pad(y,xl)==' ' && xr>=0)
X      xl--;
X   while(pad(y,xr)==' ' && xr<=PADCOLS)
X      xr++;
X   xl++;
X   xr--;
X   for(i=xl;i<=xr;i++)
X      pad(y,i)=pench;
X   for(i=xl;i<=xr;i++) {
X      if(y>0 && pad(y-1,i)==' ')
X	 fill(i,y-1);
X      if(y<PADLINES && pad(y+1,i)==' ')
X	 fill(i,y+1);
X   }
X   refresh();
X}
END_OF_FILE
if test 773 -ne `wc -c <'fill.c'`; then
    echo shar: \"'fill.c'\" unpacked with wrong size!
fi
# end of 'fill.c'
fi
if test -f 'help.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'help.c'\"
else
echo shar: Extracting \"'help.c'\" \(1824 characters\)
sed "s/^X//" >'help.c' <<'END_OF_FILE'
X#ifndef LINT
Xstatic char COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
X#include "unidraw.h"
Xhelp()
X{
X   clear();
X   move(0,0);
X   printw("          /\n");
X   printw("         /   /\n");
X   printw("         \\  /\n");
X   printw("          \\/NIDRAW\n");
X   printw("   copyright 1989 Nils McCarthy\n");
X   printw("\n");
X   printw("   WELCOME TO UNIDRAW! here is a summary of the commands:\n");
X   printw("  1-4,6-9 : movement\n");
X   printw("  ?       : help\n");
X   printw("  ^L      : redraw the screen\n");
X   printw("  p       : pen on/off\n");
X   printw("  \\char   : set penchar to char\n");
X   printw("  ^C      : quit\n");
X   printw("\n\npress any key to continue\n");
X   refresh();
X   getchar();
X   clear();
X   move(0,0);
X   printw("  >       : special commands:\n");
X   printw("          read    : read a file in to page\n");
X   printw("          write   : write picture to page\n");
X   printw("          fill    : fill region with current char\n");
X   printw("          clear   : clear pad\n");
X   printw("          quit    : quit\n");
X   printw("          suspend : suspend the program to do something else\n");
X   printw("          copy    : display copyright notice\n");
X   printw("   also, if you want to redifine the keys, you do:\n");
X   printw("    setenv UNIDRAW name=key,name=key,...\n");
X   printw("   or if you just want vi keys, use:\n");
X   printw("    unidraw -v [file]\n\n\n");
X   printw("press any key to continue\n");
X   refresh();
X   getchar();
X   clear();
X}
END_OF_FILE
if test 1824 -ne `wc -c <'help.c'`; then
    echo shar: \"'help.c'\" unpacked with wrong size!
fi
# end of 'help.c'
fi
if test -f 'init.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'init.c'\"
else
echo shar: Extracting \"'init.c'\" \(936 characters\)
sed "s/^X//" >'init.c' <<'END_OF_FILE'
X#ifndef LINT
Xstatic char COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
Xvoid endwin();
X#include "unidraw.h"
X
Xbrkfunct()
X{
X   clear();
X   move(0,0);
X   printw("goodbye. see you in unidraw again sometime...\n");
X   refresh();
X   echo();
X   nl();
X   resetty();
X   endwin();
X   exit(0);
X}
X  
Xinit()
X{
X   int i,j;
X   
X   initscr();
X   savetty();
X   cbreak();
X   noecho();
X   signal(SIGINT,brkfunct);
X   nl();
X   
X   keymaps();
X   
X   pen=0;
X   pench='#';
X   padx=0;
X   pady=0;
X   padposx=0;
X   padposy=0;
X   for(i=0;i<PADLINES;i++)
X      for(j=0;j<PADCOLS;j++)
X	 pad(i,j)=' ';
X   clear();
X   redraw();
X}
END_OF_FILE
if test 936 -ne `wc -c <'init.c'`; then
    echo shar: \"'init.c'\" unpacked with wrong size!
fi
# end of 'init.c'
fi
if test -f 'keymap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'keymap.c'\"
else
echo shar: Extracting \"'keymap.c'\" \(2286 characters\)
sed "s/^X//" >'keymap.c' <<'END_OF_FILE'
X#ifndef LINT
Xstatic char COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
X#include "unidraw.h"
Xmapkey(name,key)
X char *name;
X char key;
X{
X   if(!strcmp(name,"up"))
X      up=key;
X   else if(!strcmp(name,"down"))
X      down=key;
X   else if(!strcmp(name,"right"))
X      right=key;
X   else if(!strcmp(name,"left"))
X      up_left=key;
X   else if(!strcmp(name,"up_left"))
X      up_right=key;
X   else if(!strcmp(name,"up_right"))
X      down_left=key;
X   else if(!strcmp(name,"down_left"))
X      down_right=key;
X   else if(!strcmp(name,"down_right"))
X      down_right=key;
X   else if(!strcmp(name,"pentoggle"))
X      pentoggle=key;
X   else if(!strcmp(name,"penkey"))
X      penkey=key;
X   else if(!strcmp(name,"special"))
X      special=key;
X   else if(!strcmp(name,"brk"))
X      brk=key;
X   else if(!strcmp(name,"suspend"))
X      suspend=key;
X   else {
X      fprintf(stderr,"setenv misformat: %s=%c\n",name,key);
X      sleep(5);
X   }
X}
X
X
Xkeymaps()
X{
X   char *beginname,*endname;
X   char name[80];
X   if(vi) {
X      up='k';
X      down='j';
X      right='l';
X      left='h';
X      up_right='u';
X      up_left='y';
X      down_right='n';
X      down_left='b';
X   } else {
X      up='8';
X      down='2';
X      right='6';
X      left='4';
X      up_right='9';
X      up_left='7';
X      down_right='3';
X      down_left='1';
X   }
X   suspend=25;
X   pentoggle='p';
X   penkey='\\';
X   brk=3;
X   redr='';
X   special='>';
X   if(getenv("UNIDRAW")==NULL)
X      return;
X   beginname=(char *) getenv("UNIDRAW");
X   endname=beginname; /* so if it isn't setenv'd to anything... */
X   while(*beginname!=NULL) {
X      name[0]=NULL;
X      for(endname=beginname;*endname!='=';endname++) {
X	 name[strlen(name)+1]=NULL;
X	 name[strlen(name)]= (*endname);
X      }
X      if(*(endname+2)!=',' && *(endname+2)!=NULL) {
X	 fprintf(stderr,"environment misusage.\n");
X	 exit(-1);
X      }
X      mapkey(name,*(endname+1));
X      beginname=endname+3;
X      if(*(endname+2)=NULL)
X	 beginname--;
X   }
X}
X
END_OF_FILE
if test 2286 -ne `wc -c <'keymap.c'`; then
    echo shar: \"'keymap.c'\" unpacked with wrong size!
fi
# end of 'keymap.c'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(3161 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X#ifndef LINT
Xstatic char COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
X#include "unidraw.h"
Xmain(argc,argv)
X int argc;
X char *argv[];
X{
X   char ch;
X   BOOL redra;
X   char *readfile=NULL;
X   
X   vi=FALSE;
X   init();
X   if(argv[0][0]!='-') { /* so if people want to use unidraw as a shell,
X			    they can...*/
X      if(argc>3 || (argc==3 && strcmp(argv[1],"-v"))) {
X	 fprintf(stderr,"Usage: unidraw [-v] [file]\n");
X	 exit(-5547);
X      }
X      if(argc>1) {
X	 if(argc==3) {
X	    vi=TRUE;
X	    readfile=argv[2];
X	 } else if(argv[1][0]=='-') {
X	    vi=TRUE;
X	    printf("BIBIBI");
X	 } else {
X	    readfile=argv[1];
X	 }
X	 if(readfile) {
X	    int c;
X	    char *ttt;
X	    ttt=malloc(sizeof(char)*(strlen(readfile)+8));
X	    strcpy(ttt,"read ");
X	    strcat(ttt,readfile);
X	    command(ttt);
X	 }
X      }
X   }
X   keymaps();
X   move(WINTOP+padx-padposx,WINLEFT+pady-padposy);
X   refresh();
X   
X   
X   while((ch=getchar()) != EOF) {
X      if(ch==up) {
X	 pady--;
X	 posref();
X      } else
X      if(ch==down) {
X	 pady++;
X	 posref();
X      } else
X      if(ch==right) {
X	 padx++;
X	 posref();
X      } else
X      if(ch==left) {
X	 padx--;
X	 posref();
X      } else
X      if(ch==up_left) {
X	 padx--;
X	 pady--;
X	 posref();
X      } else
X      if(ch==up_right) {
X	 padx++;
X	 pady--;
X	 posref();
X      } else
X      if(ch==down_left) {
X	 padx--;
X	 pady++;
X	 posref();
X      } else
X      if(ch==down_right) {
X	 padx++;
X	 pady++;
X	 posref();
X      } else
X      if(ch==pentoggle) {
X	 pen=!pen;
X	 move(1,5);
X	 printw("%s",pen?"yes":"no ");
X      } else
X      if(ch==redr) {
X	 clear();
X	 redraw();
X      } else
X      if(ch==penkey) {
X	 pench=getchar();
X	 move(1,30);
X	 printw("%c",ch);
X      } else
X      if(ch==special) {
X	 char comm[80];
X	 move(3,0);
X	 printw(">"); /* command prompt */
X	 clrtoeol(); /* Clear to end of line */
X	 refresh();
X	 WinGet(comm,80,"abcdefghijklmnopqrstuvwxyz ");
X	 command(comm);
X      } else
X      if(ch==brk) {
X	 clear();
X	 refresh();
X	 endwin();
X	 exit(0);
X      } else
X      if(ch==suspend) {
X	 kill(getpid(),18);
X      } else
X      if(ch=='?') {
X	 help();
X	 redraw();
X      } else {
X	 pench=ch;
X	 move(1,30);
X	 printw("%c",ch);
X      }
X      move(WINTOP+pady-padposy,WINLEFT+padx-padposx);
X      redra=!0;
X      if(padx<0) padx++;
X      if(padx>PADCOLS) padx--;
X      if(pady<0) pady++;
X      if(pady>PADLINES) pady--;
X      if(padx<padposx+3 && padposx>0) padposx-=1;
X      if(pady<padposy+3 && padposy>0) padposy-=1;
X      if(padx>padposx+WINCOLS-3 && padposx<PADCOLS-WINCOLS) padposx+=1;
X      if(pady>padposy+WINLINES-3 && padposy<PADLINES-WINLINES) padposy+=1;
X      redraw();
X      if(pen) {
X	 posref();
X	 printw("%c",pench);
X	 pad(pady,padx)=pench;
X      }
X      posref();
X      refresh();
X   }
X}
X
Xposref()
X{
X   move(1,12);
X   printw("%3d y: %3d",padx,pady);
X   move(WINTOP+pady-padposy,WINLEFT+padx-padposx);
X}
END_OF_FILE
if test 3161 -ne `wc -c <'main.c'`; then
    echo shar: \"'main.c'\" unpacked with wrong size!
fi
# end of 'main.c'
fi
if test -f 'redraw.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'redraw.c'\"
else
echo shar: Extracting \"'redraw.c'\" \(1462 characters\)
sed "s/^X//" >'redraw.c' <<'END_OF_FILE'
X#ifndef LINT
Xstatic char COPYRIGHT[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHOR[]="Copyright 1989 Nils McCarthy";
X#endif /* LINT */
X
X#include "unidraw.h"
X
Xredraw()
X{
X   
X   int i,j;
X   
X   
X   
X   move(0,0);
X   printw("Copyright 1989 Nils McCarthy +-+");
X   move(1,0);
X   printw("Pen: %3s x: %3d y: %3d char: |%c|", /* status line */
X	  pen?"yes":"no",
X	  padx, /* x position */
X	  pady, /* y position */
X	  pench); /* pen character */
X   move(2,0);
X   printw("                             +-+");
X   
X   /* draw a box around the pad */
X   
X   for(i=WINTOP;i<=WINTOP+WINLINES;i++) {
X      move(i,WINLEFT-1);
X      printw("|");
X      move(i,WINLEFT+WINCOLS+1);
X      printw("|");
X   }
X   for(i=WINLEFT;i<=WINLEFT+WINCOLS;i++) {
X      move(WINTOP-1,i);
X      printw("-");
X      move(WINTOP+WINLINES+1,i);
X      printw("-");
X   }
X   move(WINTOP-1,WINLEFT-1);
X   printw("+");
X   move(WINTOP-1,WINLEFT+WINCOLS+1);
X   printw("+");
X   move(WINTOP+WINLINES+1,WINLEFT-1);
X   printw("+");
X   move(WINTOP+WINLINES+1,WINLEFT+WINCOLS+1);
X   printw("+");
X   
X   for(i=0;i<=WINLINES;i++)
X   for(j=0;j<=WINCOLS;j++) {
X      move(i+WINTOP,j+WINLEFT);
X      printw("%c",pad(padposy+i,padposx+j));
X   }
X}
X
END_OF_FILE
if test 1462 -ne `wc -c <'redraw.c'`; then
    echo shar: \"'redraw.c'\" unpacked with wrong size!
fi
# end of 'redraw.c'
fi
if test -f 'unidraw.6' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'unidraw.6'\"
else
echo shar: Extracting \"'unidraw.6'\" \(450 characters\)
sed "s/^X//" >'unidraw.6' <<'END_OF_FILE'
X.TH UNIDRAW 6
X.SH NAME
Xunidraw \- great drawing program by Nils McCarthy
X.SH USAGE
Xunidraw [\-v] [filename]
X.SH DESCRIPTION
Xget in to unidraw and do "?"...
X.SH COPYRIGHT
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT
X
X  This program is copyright 1989 Nils McCarthy. This
X
X  program may be distributed if it is impossible for
X
X  the distributor to get a more up-to-date-version of
X
X  it.
X
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT
X
END_OF_FILE
if test 450 -ne `wc -c <'unidraw.6'`; then
    echo shar: \"'unidraw.6'\" unpacked with wrong size!
fi
# end of 'unidraw.6'
fi
if test -f 'unidraw.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'unidraw.h'\"
else
echo shar: Extracting \"'unidraw.h'\" \(1148 characters\)
sed "s/^X//" >'unidraw.h' <<'END_OF_FILE'
Xstatic char COPYRIGHTh[]="\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  This program is copyright 1989 Nils McCarthy. This \
X  program may be distributed if it is impossible for \
X  the distributor to get a more up-to-date-version of \
X  it. \n\
X  COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
X  ";
Xstatic char AUTHORh[]="Copyright 1989 Nils McCarthy";
X
X#define pad(i,j) (thepad[i][j])
Xchar *malloc();
X#include <sys/file.h>
X#include <signal.h>
X#include <curses.h>
X#include <stdio.h>
X#include <strings.h>
X#ifndef cbreak()
X#define cbreak() crmode()
X#endif /* cbreak */
X#define BOOL char /* Boolean */
X#define WINLINES 14
X#define WINCOLS 70
X#define WINTOP 5
X#define WINLEFT 5
X#define PADLINES 102
X#define PADCOLS 102
X#define SECWINCOORDS WINLINES,WINCOLS,WINTOP,WINLEFT
X
XWINDOW *secwin;
Xint padx,pady,padposx,padposy;
X
XBOOL pen,vi;
X
Xchar pench;
Xchar thepad[PADLINES+5][PADCOLS+5];
Xchar up;
Xchar down;
Xchar left;
Xchar right;
Xchar pentoggle;
Xchar up_right;
Xchar down_right;
Xchar up_left;
Xchar down_left;
Xchar penkey;
Xchar redr;
Xchar special;
X#define brk brk_key_because_there_is_already_an_brk_variable
Xchar brk;
Xchar suspend;
END_OF_FILE
if test 1148 -ne `wc -c <'unidraw.h'`; then
    echo shar: \"'unidraw.h'\" unpacked with wrong size!
fi
# end of 'unidraw.h'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0