home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume8
/
unidraw
/
part01
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-12-19
|
3KB
|
159 lines
#ifndef LINT
static char COPYRIGHT[]="\
COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
This program is copyright 1989 Nils McCarthy. This \
program may be distributed if it is impossible for \
the distributor to get a more up-to-date-version of \
it. \n\
COPYRIGHT --- COPYRIGHT --- COPYRIGHT --- COPYRIGHT \n\
";
static char AUTHOR[]="Copyright 1989 Nils McCarthy";
#endif /* LINT */
#include "unidraw.h"
main(argc,argv)
int argc;
char *argv[];
{
char ch;
BOOL redra;
char *readfile=NULL;
vi=FALSE;
init();
if(argv[0][0]!='-') { /* so if people want to use unidraw as a shell,
they can...*/
if(argc>3 || (argc==3 && strcmp(argv[1],"-v"))) {
fprintf(stderr,"Usage: unidraw [-v] [file]\n");
exit(-5547);
}
if(argc>1) {
if(argc==3) {
vi=TRUE;
readfile=argv[2];
} else if(argv[1][0]=='-') {
vi=TRUE;
printf("BIBIBI");
} else {
readfile=argv[1];
}
if(readfile) {
int c;
char *ttt;
ttt=malloc(sizeof(char)*(strlen(readfile)+8));
strcpy(ttt,"read ");
strcat(ttt,readfile);
command(ttt);
}
}
}
keymaps();
move(WINTOP+padx-padposx,WINLEFT+pady-padposy);
refresh();
while((ch=getchar()) != EOF) {
if(ch==up) {
pady--;
posref();
} else
if(ch==down) {
pady++;
posref();
} else
if(ch==right) {
padx++;
posref();
} else
if(ch==left) {
padx--;
posref();
} else
if(ch==up_left) {
padx--;
pady--;
posref();
} else
if(ch==up_right) {
padx++;
pady--;
posref();
} else
if(ch==down_left) {
padx--;
pady++;
posref();
} else
if(ch==down_right) {
padx++;
pady++;
posref();
} else
if(ch==pentoggle) {
pen=!pen;
move(1,5);
printw("%s",pen?"yes":"no ");
} else
if(ch==redr) {
clear();
redraw();
} else
if(ch==penkey) {
pench=getchar();
move(1,30);
printw("%c",ch);
} else
if(ch==special) {
char comm[80];
move(3,0);
printw(">"); /* command prompt */
clrtoeol(); /* Clear to end of line */
refresh();
WinGet(comm,80,"abcdefghijklmnopqrstuvwxyz ");
command(comm);
} else
if(ch==brk) {
clear();
refresh();
endwin();
exit(0);
} else
if(ch==suspend) {
kill(getpid(),18);
} else
if(ch=='?') {
help();
redraw();
} else {
pench=ch;
move(1,30);
printw("%c",ch);
}
move(WINTOP+pady-padposy,WINLEFT+padx-padposx);
redra=!0;
if(padx<0) padx++;
if(padx>PADCOLS) padx--;
if(pady<0) pady++;
if(pady>PADLINES) pady--;
if(padx<padposx+3 && padposx>0) padposx-=1;
if(pady<padposy+3 && padposy>0) padposy-=1;
if(padx>padposx+WINCOLS-3 && padposx<PADCOLS-WINCOLS) padposx+=1;
if(pady>padposy+WINLINES-3 && padposy<PADLINES-WINLINES) padposy+=1;
redraw();
if(pen) {
posref();
printw("%c",pench);
pad(pady,padx)=pench;
}
posref();
refresh();
}
}
posref()
{
move(1,12);
printw("%3d y: %3d",padx,pady);
move(WINTOP+pady-padposy,WINLEFT+padx-padposx);
}