Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!think!bloom-beacon!mit-hermes!iuvax!isrnix!mr From: mr@isrnix.UUCP (a.k.a regoli@silver.bacs.indiana.edu) Newsgroups: comp.sys.ibm.pc Subject: Repost: EMACS 3.8L Source (Part 8 of 9) Message-ID: <876@isrnix.UUCP> Date: Fri, 31-Jul-87 15:30:59 EDT Article-I.D.: isrnix.876 Posted: Fri Jul 31 15:30:59 1987 Date-Received: Sun, 2-Aug-87 07:58:14 EDT Sender: mr@isrnix.UUCP Organization: indiana university, bloomington Lines: 2642 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # spawn.c # st520.c # tcap.c # termio.c # tipc.c # This archive created: Fri Jul 31 13:54:45 1987 # By: michael regoli (indiana university, bloomington) export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting 'spawn.c'" '(0 character)' if test -f 'spawn.c' then echo shar: "will not over-write existing file 'spawn.c'" else cat << \SHAR_EOF > 'spawn.c' /* Spawn: various DOS access commands for MicroEMACS */ #include #include "estruct.h" #include "edef.h" #if AMIGA #define NEW 1006 #endif #if ST520 & MEGAMAX #include #include #define LOAD_EXEC 0 /* load and execute the program */ char *STcmd, /* the command filename & path */ *STargs, /* command args (if any) */ *STenv, /* environment */ *STwork; /* work area */ #endif #if VMS #define EFN 0 /* Event flag. */ #include /* Random headers. */ #include #include #include extern int oldmode[3]; /* In "termio.c" */ extern int newmode[3]; /* In "termio.c" */ extern short iochan; /* In "termio.c" */ #endif #if V7 | USG | BSD #include extern int vttidy(); #endif #if MSDOS & MSC #include #define system(a) spawnlp(P_WAIT, a, NULL) #endif /* * Create a subjob with a copy of the command intrepreter in it. When the * command interpreter exits, mark the screen as garbage so that you do a full * repaint. Bound to "^X C". The message at the start in VMS puts out a newline. * Under some (unknown) condition, you don't get one free when DCL starts up. */ spawncli(f, n) { #if AMIGA long newcli; #endif #if V7 | USG | BSD register char *cp; char *getenv(); #endif /* don't allow this command if restricted */ if (restflag) return(resterr()); #if AMIGA newcli = Open("CON:0/0/639/199/MicroEmacs Subprocess", NEW); mlwrite("[Starting new CLI]"); sgarbf = TRUE; Execute("", newcli, 0); Close(newcli); return(TRUE); #endif #if VMS movecursor(term.t_nrow, 0); /* In last line. */ mlputs("[Starting DCL]\r\n"); TTflush(); /* Ignore "ttcol". */ sgarbf = TRUE; return (sys(NULL)); /* NULL => DCL. */ #endif #if CPM mlwrite("Not in CP/M-86"); #endif #if ST520 mlwrite("Not in TOS"); #endif #if MSDOS & AZTEC movecursor(term.t_nrow, 0); /* Seek to last line. */ TTflush(); TTkclose(); system("command.com"); TTkopen(); sgarbf = TRUE; return(TRUE); #endif #if MSDOS & LATTICE movecursor(term.t_nrow, 0); /* Seek to last line. */ TTflush(); TTkclose(); sys("\\command.com", ""); /* Run CLI. */ TTkopen(); sgarbf = TRUE; return(TRUE); #endif #if V7 | USG | BSD movecursor(term.t_nrow, 0); /* Seek to last line. */ TTflush(); TTclose(); /* stty to old settings */ if ((cp = getenv("SHELL")) != NULL && *cp != '\0') system(cp); else #if BSD system("exec /bin/csh"); #else system("exec /bin/sh"); #endif sgarbf = TRUE; sleep(2); TTopen(); return(TRUE); #endif } #if BSD bktoshell() /* suspend MicroEMACS and wait to wake up */ { int pid; vttidy(); pid = getpid(); kill(pid,SIGTSTP); } rtfrmshell() { TTopen(); curwp->w_flag = WFHARD; sgarbf = TRUE; } #endif /* * Run a one-liner in a subjob. When the command returns, wait for a single * character to be typed, then mark the screen as garbage so a full repaint is * done. Bound to "C-X !". */ spawn(f, n) { register int s; char line[NLINE]; #if ST520 & MEGAMAX int i,j,k; char *sptr,*tptr; #endif #if AMIGA long newcli; #endif /* don't allow this command if restricted */ if (restflag) return(resterr()); #if AMIGA if ((s=mlreply("!", line, NLINE)) != TRUE) return (s); newcli = Open("CON:0/0/639/199/MicroEmacs Subprocess", NEW); Execute(line,0,newcli); Close(newcli); tgetc(); /* Pause. */ sgarbf = TRUE; return(TRUE); #endif #if ST520 & MEGAMAX if ((s=mlreply("!", line, NLINE)) != TRUE) return(s); movecursor(term.t_nrow - 1, 0); TTclose(); /* * break the line into the command and its args * be cute about it, if there is no '.' in the filename, try * to find .prg, .tos or .ttp in that order * in any case check to see that the file exists before we run * amok */ STenv = NULL; if((tptr = index(&line[0],' ')) == NULL) { /* no args */ STcmd = (char *)malloc(strlen(line) + 1); strcpy(STcmd,line); STargs = NULL; } else { /* seperate out the args from the command */ /* resist the temptation to do ptr arithmetic */ STcmd = (char *)malloc(strlen(line) + 1); for(i = 0,sptr = &line[0]; sptr != tptr; sptr++,i++) STcmd[i] = *sptr; STcmd[i] = '\0'; for(; *tptr == ' ' || *tptr == '\t'; tptr++); if(*tptr == '\0') STargs = NULL; else { STargs = (char *)malloc(strlen(tptr) + 2); /* first byte of STargs is the length of the string */ STargs[0] = strlen(tptr); STargs[1] = NULL; /* fake it for strcat */ strcat(STargs,tptr); } } /* * before we issue the command look for the '.', if it's not there * try adding .prg, .tos and .ttp to see if they exist, if not * issue the command as is */ if((tptr = index(STcmd,'.')) == NULL) { STwork = (char *)malloc(strlen(STcmd) + 4); strcpy(STwork,STcmd); strcat(STwork,".prg"); tptr = index(STwork,'.'); if(Fsfirst(1,STwork) != 0) { /* try .tos */ strcpy(tptr,".tos"); if(Fsfirst(1,STwork) != 0) { /* try .ttp */ strcpy(tptr,".ttp"); if(Fsfirst(1,STwork) != 0) /* never mind */ *STwork = NULL; } } } if(*STwork != NULL) Pexec(LOAD_EXEC,STwork,STargs,STenv); else Pexec(LOAD_EXEC,STcmd,STargs,STenv); TTopen(); mlputs("\r\n\n[End]"); /* Pause. */ TTgetc(); /* Pause. */ sgarbf = TRUE; return (TRUE); #endif #if VMS if ((s=mlreply("!", line, NLINE)) != TRUE) return (s); TTputc('\n'); /* Already have '\r' */ TTflush(); s = sys(line); /* Run the command. */ mlputs("\r\n\n[End]"); /* Pause. */ TTflush(); tgetc(); sgarbf = TRUE; return (s); #endif #if CPM mlwrite("Not in CP/M-86"); return (FALSE); #endif #if MSDOS | (ST520 & LATTICE) if ((s=mlreply("!", line, NLINE)) != TRUE) return(s); movecursor(term.t_nrow - 1, 0); TTkclose(); system(line); TTkopen(); /* if we are interactive, pause here */ if (clexec == FALSE) { mlputs("\r\n\n[End]"); tgetc(); } sgarbf = TRUE; return (TRUE); #endif #if V7 | USG | BSD if ((s=mlreply("!", line, NLINE)) != TRUE) return (s); TTputc('\n'); /* Already have '\r' */ TTflush(); TTclose(); /* stty to old modes */ system(line); TTopen(); mlputs("[End]"); /* Pause. */ TTflush(); while ((s = tgetc()) != '\r' && s != ' ') ; sgarbf = TRUE; return (TRUE); #endif } /* * Pipe a one line command into a window * Bound to ^X @ */ pipecmd(f, n) { register int s; /* return status from CLI */ register WINDOW *wp; /* pointer to new window */ register BUFFER *bp; /* pointer to buffer to zot */ char line[NLINE]; /* command line send to shell */ static char bname[] = "command"; #if AMIGA static char filnam[] = "ram:command"; long newcli; #else static char filnam[] = "command"; #endif #if MSDOS char *tmp; char *getenv(); FILE *fp; FILE *fopen(); #endif /* don't allow this command if restricted */ if (restflag) return(resterr()); #if MSDOS if ((tmp = getenv("TMP")) == NULL) strcpy(filnam, "command"); else strcpy(filnam, tmp); #endif #if VMS mlwrite("Not availible under VMS"); return(FALSE); #endif #if CPM mlwrite("Not availible under CP/M-86"); return(FALSE); #endif /* get the command to pipe in */ if ((s=mlreply("@", line, NLINE)) != TRUE) return(s); /* get rid of the command output buffer if it exists */ if ((bp=bfind(bname, FALSE, 0)) != FALSE) { /* try to make sure we are off screen */ wp = wheadp; while (wp != NULL) { if (wp->w_bufp == bp) { onlywind(FALSE, 1); break; } wp = wp->w_wndp; } if (zotbuf(bp) != TRUE) return(FALSE); } #if AMIGA newcli = Open("CON:0/0/639/199/MicroEmacs Subprocess", NEW); strcat(line, " >"); strcat(line, filnam); Execute(line,0,newcli); s = TRUE; Close(newcli); sgarbf = TRUE; #endif #if MSDOS strcat(line," >>"); strcat(line,filnam); movecursor(term.t_nrow - 1, 0); TTkclose(); system(line); TTkopen(); sgarbf = TRUE; if ((fp = fopen(filnam, "r")) == NULL) { s = FALSE; } else { fclose(fp); s = TRUE; } #endif #if V7 | USG | BSD TTputc('\n'); /* Already have '\r' */ TTflush(); TTclose(); /* stty to old modes */ strcat(line,">"); strcat(line,filnam); system(line); TTopen(); TTflush(); sgarbf = TRUE; s = TRUE; #endif if (s != TRUE) return(s); /* split the current window to make room for the command output */ if (splitwind(FALSE, 1) == FALSE) return(FALSE); /* and read the stuff in */ if (getfile(filnam, FALSE) == FALSE) return(FALSE); /* make this window in VIEW mode, update all mode lines */ curwp->w_bufp->b_mode |= MDVIEW; wp = wheadp; while (wp != NULL) { wp->w_flag |= WFMODE; wp = wp->w_wndp; } /* and get rid of the temporary file */ unlink(filnam); return(TRUE); } /* * filter a buffer through an external DOS program * Bound to ^X # */ filter(f, n) { register int s; /* return status from CLI */ register BUFFER *bp; /* pointer to buffer to zot */ char line[NLINE]; /* command line send to shell */ char tmpnam[NFILEN]; /* place to store real file name */ static char bname1[] = "fltinp"; #if AMIGA static char filnam1[] = "ram:fltinp"; static char filnam2[] = "ram:fltout"; long newcli; #else static char filnam1[] = "fltinp"; static char filnam2[] = "fltout"; #endif /* don't allow this command if restricted */ if (restflag) return(resterr()); if (curbp->b_mode&MDVIEW) /* don't allow this command if */ return(rdonly()); /* we are in read only mode */ #if VMS mlwrite("Not availible under VMS"); return(FALSE); #endif #if CPM mlwrite("Not availible under CP/M-86"); return(FALSE); #endif /* get the filter name and its args */ if ((s=mlreply("#", line, NLINE)) != TRUE) return(s); /* setup the proper file names */ bp = curbp; strcpy(tmpnam, bp->b_fname); /* save the original name */ strcpy(bp->b_fname, bname1); /* set it to our new one */ /* write it out, checking for errors */ if (writeout(filnam1) != TRUE) { mlwrite("[Cannot write filter file]"); strcpy(bp->b_fname, tmpnam); return(FALSE); } #if AMIGA newcli = Open("CON:0/0/639/199/MicroEmacs Subprocess", NEW); strcat(line, " ram:fltout"); Execute(line,0,newcli); s = TRUE; Close(newcli); sgarbf = TRUE; #endif #if MSDOS strcat(line," fltout"); movecursor(term.t_nrow - 1, 0); TTkclose(); system(line); TTkopen(); sgarbf = TRUE; s = TRUE; #endif #if V7 | USG | BSD TTputc('\n'); /* Already have '\r' */ TTflush(); TTclose(); /* stty to old modes */ strcat(line," fltout"); system(line); TTopen(); TTflush(); sgarbf = TRUE; s = TRUE; #endif /* on failure, escape gracefully */ if (s != TRUE || (readin(filnam2,FALSE) == FALSE)) { mlwrite("[Execution failed]"); strcpy(bp->b_fname, tmpnam); unlink(filnam1); unlink(filnam2); return(s); } /* reset file name */ strcpy(bp->b_fname, tmpnam); /* restore name */ bp->b_flag |= BFCHG; /* flag it as changed */ /* and get rid of the temporary file */ unlink(filnam1); unlink(filnam2); return(TRUE); } #if VMS /* * Run a command. The "cmd" is a pointer to a command string, or NULL if you * want to run a copy of DCL in the subjob (this is how the standard routine * LIB$SPAWN works. You have to do wierd stuff with the terminal on the way in * and the way out, because DCL does not want the channel to be in raw mode. */ sys(cmd) register char *cmd; { struct dsc$descriptor cdsc; struct dsc$descriptor *cdscp; long status; long substatus; long iosb[2]; status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, oldmode, sizeof(oldmode), 0, 0, 0, 0); if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) return (FALSE); cdscp = NULL; /* Assume DCL. */ if (cmd != NULL) { /* Build descriptor. */ cdsc.dsc$a_pointer = cmd; cdsc.dsc$w_length = strlen(cmd); cdsc.dsc$b_dtype = DSC$K_DTYPE_T; cdsc.dsc$b_class = DSC$K_CLASS_S; cdscp = &cdsc; } status = LIB$SPAWN(cdscp, 0, 0, 0, 0, 0, &substatus, 0, 0, 0); if (status != SS$_NORMAL) substatus = status; status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, newmode, sizeof(newmode), 0, 0, 0, 0); if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) return (FALSE); if ((substatus&STS$M_SUCCESS) == 0) /* Command failed. */ return (FALSE); return (TRUE); } #endif #if ~AZTEC & MSDOS /* * This routine, once again by Bob McNamara, is a C translation of the "system" * routine in the MWC-86 run time library. It differs from the "system" routine * in that it does not unconditionally append the string ".exe" to the end of * the command name. We needed to do this because we want to be able to spawn * off "command.com". We really do not understand what it does, but if you don't * do it exactly "malloc" starts doing very very strange things. */ sys(cmd, tail) char *cmd; char *tail; { #if MWC_86 register unsigned n; extern char *__end; n = __end + 15; n >>= 4; n = ((n + dsreg() + 16) & 0xFFF0) + 16; return(execall(cmd, tail, n)); #endif #if LATTICE return(forklp(cmd, tail, (char *)NULL)); #endif #if MSC return(spawnlp(P_WAIT, cmd, tail, NULL)); #endif } #endif #if MSDOS & LATTICE /* System: a modified version of lattice's system() function that detects the proper switchar and uses it written by Dana Hogget */ system(cmd) char *cmd; /* Incoming command line to execute */ { char *getenv(); static char *swchar = "/C"; /* Execution switch */ union REGS inregs; /* parameters for dos call */ union REGS outregs; /* Return results from dos call */ char *shell; /* Name of system command processor */ char *p; /* Temporary pointer */ int ferr; /* Error condition if any */ /* get name of system shell */ if ((shell = getenv("COMSPEC")) == NULL) { return (-1); /* No shell located */ } p = cmd; while (isspace(*p)) { /* find out if null command */ p++; } /** If the command line is not empty, bring up the shell **/ /** and execute the command. Otherwise, bring up the **/ /** shell in interactive mode. **/ if (p && *p) { /** detect current switch character and us it **/ inregs.h.ah = 0x37; /* get setting data */ inregs.h.al = 0x00; /* get switch character */ intdos(&inregs, &outregs); *swchar = outregs.h.dl; ferr = forkl(shell, "command", swchar, cmd, (char *)NULL); } else { ferr = forkl(shell, "command", (char *)NULL); } return (ferr ? ferr : wait()); } #endif SHAR_EOF chmod +x 'spawn.c' fi echo shar: "extracting 'st520.c'" '(0 character)' if test -f 'st520.c' then echo shar: "will not over-write existing file 'st520.c'" else cat << \SHAR_EOF > 'st520.c' /* The routines in this file provide support for the Atari 520 or 1040ST using VT52 emulation. The I/O services are provided here as well. It compiles into nothing if not a 520ST style device. */ #define termdef 1 /* don't define "term" external */ #include #include "estruct.h" #include "edef.h" #if MEGAMAX overlay "st520" #endif #if ATARI & ST520 & MEGAMAX #include #include #define LINEA_INIT 0xA000 #define V_CEL_WR -0x28 #define V_CEL_MY -0x2a #define V_CEL_HT -0x2e #define V_FNT_AD -0x16 #define V_OFF_AD -0x0a #define V_DISAB -346 #define NROW 25 /* Screen size. */ #define NCOL 80 /* Edit if you want to. */ #define MARGIN 8 /* size of minimim margin and */ #define SCRSIZ 64 /* scroll size for extended lines */ #define NPAUSE 25 /* # times thru update to pause */ #define BIAS 0x20 /* Origin 0 coordinate bias. */ #define ESC 0x1B /* ESC character. */ #define BEL 0x07 /* ascii bell character */ extern int ttopen(); /* Forward references. */ extern int ttgetc(); extern int ttputc(); extern int ttflush(); extern int ttclose(); extern int st520move(); extern int st520eeol(); extern int st520eeop(); extern int st520beep(); extern int st520open(); extern int st520close(); extern int st520rev(); extern int st520kopen(); extern int st520kclose(); extern int st520chgrez(); #if COLOR extern int st520fcol(); extern int st520bcol(); int cfcolor = -1; /* current fg (character) color */ int cbcolor = -1; /* current bg color */ int oldpal[8]; /* pallette when emacs was invoked */ int newpal[8] = { /* default emacs pallette */ 0x000, 0x700, 0x070, 0x770, 0x007, 0x707, 0x077, 0x777}; #endif int STncolors = 0; /* number of colors */ int STrez; /* physical screen resolution */ /* * Dispatch table. All the * hard fields just point into the * terminal I/O code. */ TERM term = { NROW-1, NCOL, MARGIN, MARGIN, SCRSIZ, NPAUSE, &st520open, &st520close, &st520kopen, &st520kclose, &ttgetc, &ttputc, &ttflush, &st520move, &st520eeol, &st520eeop, &st520beep, &st520rev #if MULTREZ , &st520chgrez #endif #if COLOR , &st520fcol, &st520bcol #endif }; struct KBDvecs { int (*midivec) (); int (*vkbderr) (); int (*vmiderr) (); int (*statvec) (); int (*mousevec) (); int (*clockvec) (); int (*joyvec) (); int (*midisys) (); int (*ikbdsys) (); }; struct Param { char topmode; char buttons; char xparam; char yparam; int xmax,ymax; int xinitial,yinitial; }; struct KBDvecs *kbdvecs; struct Param *paramp; char kbdcmds[25]; st520move(row, col) { ttputc(ESC); ttputc('Y'); ttputc(row+BIAS); ttputc(col+BIAS); } st520eeol() { ttputc(ESC); ttputc('K'); } st520eeop() { #if COLOR st520fcol(gfcolor); st520bcol(gbcolor); #endif ttputc(ESC); ttputc('J'); } st520rev(status) /* set the reverse video state */ int status; /* TRUE = reverse video, FALSE = normal video */ { if(status) { ttputc(ESC); ttputc('p'); } else { ttputc(ESC); ttputc('q'); } } #if COLOR st520fcol(color) int color; { if(color == cfcolor || !STncolors) return; else { ttputc(ESC); ttputc('b'); ttputc(color & 0x0f); cfcolor = color; } } st520bcol(color) int color; { if(color == cbcolor || !STncolors) return; else { ttputc(ESC); ttputc('c'); ttputc(color & 0x0f); cbcolor = color; } } #endif st520beep() { #ifdef BEL ttputc(BEL); ttflush(); #endif } st520open() { int i,j,k; long phys, log; /* screen bases */ /* IMPORTANT: it is ABSOLUTELY necessary that the default resolution be the * largest possible so that display will allocate (malloc) the maximum * size for the VIDEO arrray */ STrez = Getrez(); switch(STrez) { case 0: /* low res 25x40 16 colors */ phys = Physbase(); log = Logbase(); Setscreen(log, phys, 1); STrez = 1; /* fall thru to med res */ case 1: /* med res 25x80 4 colors */ term.t_nrow = 25 - 1; term.t_ncol = 80; grez = 1; #if COLOR STncolors = 4; for(i=0;i<8;i++) { oldpal[i] = Setcolor(i,newpal[i]); } #endif break; case 2: /* high res 25x80 no colors */ term.t_nrow = 40 - 1; term.t_ncol = 80; grez = 2; make_8x10(); /* create a smaller font */ set_40(); /* and go to 40 line mode */ #if COLOR STncolors = 0; #endif break; } revexist = TRUE; eolexist = TRUE; paramp = (struct Param *)malloc(sizeof(struct Param)); kbdvecs = (struct KBDvecs *)Kbdvbase(); paramp -> topmode = 0; paramp -> buttons = 4; paramp -> xparam = 8; paramp -> yparam = 10; paramp -> xmax = 79; paramp -> ymax = 23; paramp -> xinitial = 0; paramp -> yinitial = 0; Initmous(1,paramp,kbdvecs -> mousevec); i = 0; kbdcmds[i++] = 0x0a; /*set mouse keycode mode */ kbdcmds[i++] = 0x08; kbdcmds[i++] = 0x0a; Ikbdws(i-1,&kbdcmds[0]); Cursconf(1,0); Cursconf(3,0); Cconout(27);Cconout('E'); ttopen(); } st520close() { int i,j,k; i = 0; kbdcmds[i++] = 0x80; /*reset mouse keycode mode */ kbdcmds[i++] = 0x01; Ikbdws(i-1,&kbdcmds[0]); if(grez == 2 && STrez == 2) /* b/w monitor in 40 row mode */ restore(); #if COLOR for(i=0;i buttons = 0; Initmous(2,paramp,kbdvecs -> mousevec); i = 0; kbdcmds[i++] = 0x80; /*reset the keyboard*/ kbdcmds[i++] = 0x01; Ikbdws(i-1,&kbdcmds[0]); Cursconf(1,0); ttclose(); } st520kopen() { } st520kclose() { } st520chgrez(nurez) int nurez; { int ierr, i, j ,k; long phys, log; /* screen bases */ char dum[80]; /* for debugging only */ if(grez == nurez) return(TRUE); if(STrez == 2) { /* b/w monitor-only allow hi | med rez */ switch(nurez) { case 2: /* high res */ term.t_nrow = 40 - 1; term.t_ncol = 80; make_8x10(); /* create a smaller font */ set_40(); /* and go to 40 line mode */ grez = 2; sgarbf = TRUE; onlywind(1,1); break; case 1: /* med res */ term.t_nrow = 25 - 1; term.t_ncol = 80; restore(); grez = 1; sgarbf = TRUE; onlywind(1,1); break; default: mlwrite("Invalid resolution"); return(FALSE); break; } } else { /* color monitor-only allow low | medium resolution */ phys = Physbase(); log = Logbase(); switch(nurez) { case 1: term.t_nrow = 25 - 1; term.t_ncol = 80; Setscreen(log, phys, 1); STncolors = 4; grez = 1; sgarbf = TRUE; onlywind(1,1); break; case 0: term.t_nrow = 25 - 1; term.t_ncol = 40; Setscreen(log, phys, 0); STncolors = 8; grez = 0; sgarbf = TRUE; onlywind(1,1); break; default: mlwrite("%Invalid resolution"); return(FALSE); break; } } } STcurblink(onoff) int onoff; { if(onoff) Cursconf(2,0); else Cursconf(3,0); } char parm_save[28]; long fnt_8x10[640]; make_8x10() { int i,j,k; long savea23[2]; for(i=0;i<640;i++) fnt_8x10[i] = 0; asm { movem.l A2-A3,savea23(A6) dc.w LINEA_INIT ;A1 -> array of font headers lea parm_save(A4),A2 ;A2 -> parameters savearea move.l V_OFF_AD(A0),(A2)+ move.l V_FNT_AD(A0),(A2)+ move.w V_CEL_HT(A0),(A2)+ move.w V_CEL_MY(A0),(A2)+ move.w V_CEL_WR(A0),(A2)+ move.l 04(A1),A1 ; A1 -> 8x8 font header move.l 76(A1),A2 ; A2 -> 8x8 font data lea fnt_8x10+0x100(A4),A3 ; A3 -> 2nd line of font buffer move.w #0x200-1,D0 ; D0 <- longword counter for font xfer fnt_loop: move.l (A2)+,(A3)+ dbf D0,fnt_loop movem.l savea23(A6),A2-A3 } } set_40() { long savea23[2]; asm { ; ; use the 8x10 character set: 40 line mode ; movem.l A2-A3,savea23(A6) dc.w LINEA_INIT move.l 04(A1),A1 ; A1 -> 8x8 font header move.l 72(A1),V_OFF_AD(A0) ; v_off_ad <- 8x8 offset table addr lea fnt_8x10(A4),A2 move.l A2,V_FNT_AD(A0) ; v_fnt_ad <- 8x10 font data addr move.w #10,V_CEL_HT(A0) ; v_cel_ht <- 10 8x10 cell height move.w #39,V_CEL_MY(A0) ; v_cel_my <- 39 maximum cell "Y" move.w #800,V_CEL_WR(A0) ; v_cel_wr <- 800 offset to cell Y+1 movem.l savea23,A2-A3 } } set_20() { long savea23[2]; asm { ; ; use the 8x10 character set: 20 line mode ; movem.l A2-A3,savea23(A6) dc.w LINEA_INIT ; A0 -> line A variables move.l 04(A1),A1 ; A1 -> 8x8 font header move.l 72(A1),V_OFF_AD(A0) ; v_off_ad <- 8x8 offset table addr lea fnt_8x10(A4),A2 move.l A2,V_FNT_AD(A0) ; v_fnt_ad <- 8x10 font data addr move.w #10,V_CEL_HT(A0) ; v_cel_ht <- 10 8x10 cell height move.w #19,V_CEL_MY(A0) ; v_cel_my <- 19 maximum cell "Y" move.w #1600,V_CEL_WR(A0) ; v_cel_wr <- 800 offset to cell Y+1 movem.l savea23,A2-A3 } } restore() { long savea23[2]; asm { ; return what was saved in parameter save zone movem.l A2-A3,savea23(A6) dc.w LINEA_INIT ; a0 -> line A variables lea parm_save(A4),A2 ; a2 -> parameter save area move.l (A2)+,V_OFF_AD(A0) move.l (A2)+,V_FNT_AD(A0) move.w (A2)+,V_CEL_HT(A0) move.w (A2)+,V_CEL_MY(A0) move.w (A2)+,V_CEL_WR(A0) movem.l savea23(A6),A2-A3 } } GetCurStat(onoff) int onoff; { long savea23[2]; asm { movem.l A2-A3,savea23(A6) dc.w LINEA_INIT ; a0 -> line A variables move.w V_DISAB(A0),onoff(A6) ; 0 = cursor visible moveq #0,D0 move.w V_DISAB(A0),D0 movem.l savea23(A6),A2-A3 } } #else #if ATARI & ST520 & LATTICE /* These routines provide support for the ATARI 1040ST using the LATTICE compiler using the virtual VT52 Emulator */ #define NROW 40 /* Screen size. */ #define NCOL 80 /* Edit if you want to. */ #define MARGIN 8 /* size of minimim margin and */ #define SCRSIZ 64 /* scroll size for extended lines */ #define NPAUSE 300 /* # times thru update to pause */ #define BIAS 0x20 /* Origin 0 coordinate bias. */ #define ESC 0x1B /* ESC character. */ #define BEL 0x07 /* ASCII bell character */ /**** ST Internals definitions *****/ /* BIOS calls */ #define BCONSTAT 1 /* return input device status */ #define CONIN 2 /* read character from device */ #define BCONOUT 3 /* write character to device */ /* XBIOS calls */ #define INITMOUS 0 /* initialize the mouse */ #define GETREZ 4 /* get current resolution */ #define SETSCREEN 5 /* set screen resolution */ #define SETPALETTE 6 /* set the color pallette */ #define SETCOLOR 7 /* set or read a color */ #define CURSCONF 21 /* set cursor configuration */ #define IKBDWS 25 /* intelligent keyboard send command */ #define KBDVBASE 34 /* get keyboard table base */ /* GEMDOS calls */ #define EXEC 0x4b /* Exec off a process */ #define CON 2 /* CON: Keyboard and screen device */ /* LINE A variables */ #define LINEA_INIT 0xA000 #define V_CEL_WR -0x28 #define V_CEL_MY -0x2a #define V_CEL_HT -0x2e #define V_FNT_AD -0x16 #define V_OFF_AD -0x0a #define V_DISAB -346 /* Palette color definitions */ #define LOWPAL "000700070770007707077777" #define MEDPAL "000700007777" #define HIGHPAL "000111" /* ST Global definitions */ /* keyboard vector table */ struct KVT { long midivec; /* midi input */ long vkbderr; /* keyboard error */ long vmiderr; /* MIDI error */ long statvec; /* IKBD status */ int (*mousevec)(); /* mouse vector */ long clockvec; /* clock vector */ long joyvec; /* joystict vector */ } *ktable; int (*sysmint)(); /* system mouse interupt handler */ /* mouse parameter table */ struct Param { char topmode; char buttons; char xparam; char yparam; int xmax,ymax; int xinitial,yinitial; } mparam; int currez; /* current screen resolution */ char resname[][8] = { /* screen resolution names */ "LOW", "MEDIUM", "HIGH", "DENSE" }; short spalette[16]; /* original color palette settings */ short palette[16]; /* current palette settings */ extern int ttopen(); /* Forward references. */ extern int ttgetc(); extern int ttputc(); extern int ttflush(); extern int ttclose(); extern int stmove(); extern int steeol(); extern int steeop(); extern int stbeep(); extern int stopen(); extern int stclose(); extern int stgetc(); extern int stputc(); extern int strev(); extern int strez(); extern int stkopen(); extern int stkclose(); #if COLOR extern int stfcol(); extern int stbcol(); #endif /* * Dispatch table. All the * hard fields just point into the * terminal I/O code. */ TERM term = { NROW-1, NROW-1, NCOL, NCOL, MARGIN, SCRSIZ, NPAUSE, &stopen, &stclose, &stkopen, &stkclose, &stgetc, &stputc, &ttflush, &stmove, &steeol, &steeop, &stbeep, &strev, &strez #if COLOR , &stfcol, &stbcol #endif }; stmove(row, col) { stputc(ESC); stputc('Y'); stputc(row+BIAS); stputc(col+BIAS); } steeol() { stputc(ESC); stputc('K'); } steeop() { #if COLOR stfcol(gfcolor); stbcol(gbcolor); #endif stputc(ESC); stputc('J'); } strev(status) /* set the reverse video state */ int status; /* TRUE = reverse video, FALSE = normal video */ { if (currez > 1) { stputc(ESC); stputc(status ? 'p' : 'q'); } } #if COLOR mapcol(clr) /* medium rez color translation */ int clr; /* emacs color number to translate */ { static int mctable[] = {0, 1, 2, 3, 2, 1, 2, 3}; if (currez != 1) return(clr); else return(mctable[clr]); } stfcol(color) /* set the forground color */ int color; /* color to set forground to */ { if (currez < 2) { stputc(ESC); stputc('b'); stputc(mapcol(color)); } } stbcol(color) /* set the background color */ int color; /* color to set background to */ { if (currez < 2) { stputc(ESC); stputc('c'); stputc(mapcol(color)); } } #endif stbeep() { stputc(BEL); ttflush(); } domouse() /* mouse interupt handler */ { return((*sysmint)()); } stkopen() /* open the keyboard (and mouse) */ { /* grab the keyboard vector table */ ktable = (struct KVT *)xbios(KBDVBASE); sysmint = ktable->mousevec; /* save mouse vector */ /* initialize the mouse */ mparam.topmode = 0; mparam.buttons = 4; mparam.xparam = 8; mparam.yparam = 10; mparam.xmax = 79; mparam.ymax = 23; mparam.xinitial = 0; mparam.yinitial = 0; xbios(INITMOUS, 4, &mparam, &domouse); } stopen() /* open the screen */ { int i; ttopen(); eolexist = TRUE; /* switch to a steady cursor */ xbios(CURSCONF, 3); /* save the current color palette */ for (i=0; i<16; i++) spalette[i] = xbios(SETCOLOR, i, -1); /* and find the current resolution */ currez = xbios(GETREZ); strcpy(sres, resname[currez]); /* set up the screen size and palette */ switch (currez) { case 0: term.t_mrow = 25 - 1; term.t_nrow = 25 - 1; term.t_ncol = 40 - 1; strcpy(palstr, LOWPAL); break; case 1: term.t_mrow = 25 - 1; term.t_nrow = 25 - 1; strcpy(palstr, MEDPAL); break; case 2: term.t_mrow = 40 - 1; term.t_nrow = 25 - 1; strcpy(palstr, HIGHPAL); } /* and set up the default palette */ spal(palstr); stputc(ESC); /* automatic overflow off */ stputc('w'); stputc(ESC); /* turn cursor on */ stputc('e'); } stkclose() /* close the keyboard (and mouse) */ { static char resetcmd[] = {0x80, 0x01}; /* keyboard reset command */ /* restore the mouse interupt routines */ xbios(INITMOUS, 2, &mparam, (long)sysmint); /* and reset the keyboard controller */ xbios(IKBDWS, 1, &resetcmd[0]); } stclose() { stputc(ESC); /* auto overflow on */ stputc('v'); /* switch to a flashing cursor */ xbios(CURSCONF, 2); /* restore the original palette settings */ xbios(SETPALETTE, spalette); ttclose(); } /* spal(pstr): reset the current palette according to a "palette string" of the form 000111222333444555666777 which contains the octal values for the palette registers */ spal(pstr) char *pstr; /* palette string */ { int pal; /* current palette position */ int clr; /* current color value */ int i; for (pal = 0; pal < 16; pal++) { if (*pstr== 0) break; /* parse off a color */ clr = 0; for (i = 0; i < 3; i++) if (*pstr) clr = clr * 16 + (*pstr++ - '0'); palette[pal] = clr; }; /* and now set it */ xbios(SETPALETTE, palette); } stgetc() /* get a char from the keyboard */ { int rval; /* return value from BIOS call */ static int funkey = 0; /* held fuction key scan code */ /* if there is a pending function key, return it */ if (funkey) { rval = funkey; funkey = 0; } else { /* waiting... flash the cursor */ xbios(CURSCONF, 2); /* get the character */ rval = bios(CONIN, CON); if ((rval & 255) == 0) { funkey = (rval >> 16) & 255; rval = 0; } /* and switch to a steady cursor */ xbios(CURSCONF, 3); } return(rval & 255); } stputc(c) /* output char c to the screen */ char c; /* character to print out */ { bios(BCONOUT, CON, c); } strez(newrez) /* change screen resolution */ char *newrez; /* requested resolution */ { int nrez; /* requested new resolution */ /* first, decode the resolution name */ for (nrez = 0; nrez < 4; nrez++) if (strcmp(newrez, resname[nrez]) == 0) break; if (nrez == 4) { mlwrite("%%No such resolution"); return(FALSE); } /* next, make sure this resolution is legal for this monitor */ if ((currez < 2 && nrez > 1) || (currez > 1 && nrez < 2)) { mlwrite("%%Resolution illegal for this monitor"); return(FALSE); } /* eliminate non-changes */ if (currez == nrez) return(TRUE); /* finally, make the change */ switch (nrez) { case 0: /* low resolution - 16 colors */ newwidth(TRUE, 40); strcpy(palstr, LOWPAL); xbios(SETSCREEN, -1, -1, 0); break; case 1: /* medium resolution - 4 colors */ newwidth(TRUE, 80); strcpy(palstr, MEDPAL); xbios(SETSCREEN, -1, -1, 1); break; case 2: /* High resolution - 2 colors - 25 lines */ newsize(TRUE, 25); strcpy(palstr, HIGHPAL); /* change char set back to normal */ break; case 3: /* Dense resolution - 2 colors - 40 lines */ /* newsize(TRUE, 40); */ strcpy(palstr, HIGHPAL); /*change char set size */ break; } /* and set up the default palette */ spal(palstr); currez = nrez; strcpy(sres, resname[currez]); stputc(ESC); /* automatic overflow off */ stputc('w'); stputc(ESC); /* turn cursor on */ stputc('e'); return(TRUE); } system(cmd) /* call the system to execute a new program */ char *cmd; /* command to execute */ { char *pptr; /* pointer into program name */ char pname[NSTRING]; /* name of program to execute */ char tail[NSTRING]; /* command tail */ /* scan off program name.... */ pptr = pname; while (*cmd && (*cmd != ' ' && *cmd != '\t')) *pptr++ = *cmd++; *pptr = 0; /* create program name length/string */ tail[0] = strlen(cmd); strcpy(&tail[1], cmd); /* go do it! */ return(gemdos( (int)EXEC, (int)0, (char *)pname, (char *)tail, (char *)NULL)); } #if TYPEAH typahead() { int rval; /* return value from BIOS call */ /* get the status of the console */ rval = bios(BCONSTAT, CON); /* end return the results */ if (rval == 0) return(FALSE); else return(TRUE); } #endif #if FLABEL fnclabel(f, n) /* label a function key */ int f,n; /* default flag, numeric argument [unused] */ { /* on machines with no function keys...don't bother */ return(TRUE); } #endif #else sthello() { } #endif #endif SHAR_EOF chmod +x 'st520.c' fi echo shar: "extracting 'tcap.c'" '(0 character)' if test -f 'tcap.c' then echo shar: "will not over-write existing file 'tcap.c'" else cat << \SHAR_EOF > 'tcap.c' /* tcap: Unix V5, V7 and BS4.2 Termcap video driver for MicroEMACS */ #define termdef 1 /* don't define "term" external */ #include #include "estruct.h" #include "edef.h" #if TERMCAP #define MARGIN 8 #define SCRSIZ 64 #define NPAUSE 10 /* # times thru update to pause */ #define BEL 0x07 #define ESC 0x1B extern int ttopen(); extern int ttgetc(); extern int ttputc(); extern int tgetnum(); extern int ttflush(); extern int ttclose(); extern int tcapkopen(); extern int tcapkclose(); extern int tcapmove(); extern int tcapeeol(); extern int tcapeeop(); extern int tcapbeep(); extern int tcaprev(); extern int tcapcres(); extern int tcapopen(); extern int tput(); extern char *tgoto(); #if COLOR extern int tcapfcol(); extern int tcapbcol(); #endif #define TCAPSLEN 315 char tcapbuf[TCAPSLEN]; char *UP, PC, *CM, *CE, *CL, *SO, *SE; TERM term = { NULL, /* these four values are set dynamically at open time */ NULL, NULL, NULL, MARGIN, SCRSIZ, NPAUSE, tcapopen, ttclose, tcapkopen, tcapkclose, ttgetc, ttputc, ttflush, tcapmove, tcapeeol, tcapeeop, tcapbeep, tcaprev, tcapcres #if COLOR , tcapfcol, tcapbcol #endif }; tcapopen() { char *getenv(); char *t, *p, *tgetstr(); char tcbuf[1024]; char *tv_stype; char err_str[72]; if ((tv_stype = getenv("TERM")) == NULL) { puts("Environment variable TERM not defined!"); exit(1); } if ((tgetent(tcbuf, tv_stype)) != 1) { sprintf(err_str, "Unknown terminal type %s!", tv_stype); puts(err_str); exit(1); } if ((term.t_nrow=(short)tgetnum("li")-1) == -1){ puts("termcap entry incomplete (lines)"); exit(1); } term.t_mrow = term.t_nrow; if ((term.t_ncol=(short)tgetnum("co")) == -1){ puts("Termcap entry incomplete (columns)"); exit(1); } term.t_mcol = term.t_ncol; p = tcapbuf; t = tgetstr("pc", &p); if(t) PC = *t; CL = tgetstr("cl", &p); CM = tgetstr("cm", &p); CE = tgetstr("ce", &p); UP = tgetstr("up", &p); SE = tgetstr("se", &p); SO = tgetstr("so", &p); if (SO != NULL) revexist = TRUE; if(CL == NULL || CM == NULL || UP == NULL) { puts("Incomplete termcap entry\n"); exit(1); } if (CE == NULL) /* will we be able to use clear to EOL? */ eolexist = FALSE; if (p >= &tcapbuf[TCAPSLEN]) { puts("Terminal description too big!\n"); exit(1); } ttopen(); } tcapkopen() { strcpy(sres, "NORMAL"); } tcapkclose() { } tcapmove(row, col) register int row, col; { putpad(tgoto(CM, col, row)); } tcapeeol() { putpad(CE); } tcapeeop() { putpad(CL); } tcaprev(state) /* change reverse video status */ int state; /* FALSE = normal video, TRUE = reverse video */ { static int revstate = FALSE; if (state) { if (SO != NULL) putpad(SO); } else if (SE != NULL) putpad(SE); } tcapcres() /* change screen resolution */ { return(TRUE); } spal(dummy) /* change palette string */ { /* Does nothing here */ } #if COLOR tcapfcol() /* no colors here, ignore this */ { } tcapbcol() /* no colors here, ignore this */ { } #endif tcapbeep() { ttputc(BEL); } putpad(str) char *str; { tputs(str, 1, ttputc); } putnpad(str, n) char *str; { tputs(str, n, ttputc); } #if FLABEL fnclabel(f, n) /* label a function key */ int f,n; /* default flag, numeric argument [unused] */ { /* on machines with no function keys...don't bother */ return(TRUE); } #endif #else hello() { } #endif TERMCAP SHAR_EOF chmod +x 'tcap.c' fi echo shar: "extracting 'termio.c'" '(0 character)' if test -f 'termio.c' then echo shar: "will not over-write existing file 'termio.c'" else cat << \SHAR_EOF > 'termio.c' /* * The functions in this file negotiate with the operating system for * characters, and write characters in a barely buffered fashion on the display. * All operating systems. */ #include #include "estruct.h" #include "edef.h" #if MEGAMAX & ST520 overlay "termio" #endif #if AMIGA #define NEW 1006 #define AMG_MAXBUF 1024L static long terminal; static char scrn_tmp[AMG_MAXBUF+1]; static long scrn_tmp_p = 0; #endif #if ST520 & MEGAMAX #include int STscancode = 0; #endif #if VMS #include #include #include #include #include #include #define NIBUF 128 /* Input buffer size */ #define NOBUF 1024 /* MM says bug buffers win! */ #define EFN 0 /* Event flag */ char obuf[NOBUF]; /* Output buffer */ int nobuf; /* # of bytes in above */ char ibuf[NIBUF]; /* Input buffer */ int nibuf; /* # of bytes in above */ int ibufi; /* Read index */ int oldmode[3]; /* Old TTY mode bits */ int newmode[3]; /* New TTY mode bits */ short iochan; /* TTY I/O channel */ #endif #if CPM #include #endif #if MSDOS & (LATTICE | MSC | AZTEC | MWC86) union REGS rg; /* cpu register for use of DOS calls */ int nxtchar = -1; /* character held from type ahead */ #endif #if RAINBOW #include "rainbow.h" #endif #if USG /* System V */ #include #include struct termio otermio; /* original terminal characteristics */ struct termio ntermio; /* charactoristics to use inside */ #endif #if V7 | BSD #undef CTRL #include /* for stty/gtty functions */ #include struct sgttyb ostate; /* saved tty state */ struct sgttyb nstate; /* values for editor mode */ struct tchars otchars; /* Saved terminal special character set */ struct tchars ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* A lot of nothing */ #if BSD #include /* to get at the typeahead */ extern int rtfrmshell(); /* return from suspended shell */ #define TBUFSIZ 128 char tobuf[TBUFSIZ]; /* terminal output buffer */ #endif #endif /* * This function is called once to set up the terminal device streams. * On VMS, it translates TT until it finds the terminal, then assigns * a channel to it and sets it raw. On CPM it is a no-op. */ ttopen() { #if AMIGA terminal = Open("RAW:0/0/640/200/MicroEMACS 3.8i/Amiga", NEW); #endif #if VMS struct dsc$descriptor idsc; struct dsc$descriptor odsc; char oname[40]; int iosb[2]; int status; odsc.dsc$a_pointer = "TT"; odsc.dsc$w_length = strlen(odsc.dsc$a_pointer); odsc.dsc$b_dtype = DSC$K_DTYPE_T; odsc.dsc$b_class = DSC$K_CLASS_S; idsc.dsc$b_dtype = DSC$K_DTYPE_T; idsc.dsc$b_class = DSC$K_CLASS_S; do { idsc.dsc$a_pointer = odsc.dsc$a_pointer; idsc.dsc$w_length = odsc.dsc$w_length; odsc.dsc$a_pointer = &oname[0]; odsc.dsc$w_length = sizeof(oname); status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc); if (status!=SS$_NORMAL && status!=SS$_NOTRAN) exit(status); if (oname[0] == 0x1B) { odsc.dsc$a_pointer += 4; odsc.dsc$w_length -= 4; } } while (status == SS$_NORMAL); status = SYS$ASSIGN(&odsc, &iochan, 0, 0); if (status != SS$_NORMAL) exit(status); status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0, oldmode, sizeof(oldmode), 0, 0, 0, 0); if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) exit(status); newmode[0] = oldmode[0]; newmode[1] = oldmode[1] | TT$M_NOECHO; newmode[1] &= ~(TT$M_TTSYNC|TT$M_HOSTSYNC); newmode[2] = oldmode[2] | TT2$M_PASTHRU; status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, newmode, sizeof(newmode), 0, 0, 0, 0); if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) exit(status); term.t_nrow = (newmode[1]>>24) - 1; term.t_ncol = newmode[0]>>16; #endif #if CPM #endif #if MSDOS & (HP150 == 0) & LATTICE /* kill the ctrl-break interupt */ rg.h.ah = 0x33; /* control-break check dos call */ rg.h.al = 1; /* set the current state */ rg.h.dl = 0; /* set it OFF */ intdos(&rg, &rg); /* go for it! */ #endif #if USG ioctl(0, TCGETA, &otermio); /* save old settings */ ntermio.c_iflag = 0; /* setup new settings */ ntermio.c_oflag = 0; ntermio.c_cflag = otermio.c_cflag; ntermio.c_lflag = 0; ntermio.c_line = otermio.c_line; ntermio.c_cc[VMIN] = 1; ntermio.c_cc[VTIME] = 0; ioctl(0, TCSETA, &ntermio); /* and activate them */ #endif #if V7 | BSD gtty(0, &ostate); /* save old state */ gtty(0, &nstate); /* get base of new state */ nstate.sg_flags |= RAW; nstate.sg_flags &= ~(ECHO|CRMOD); /* no echo for now... */ stty(0, &nstate); /* set mode */ ioctl(0, TIOCGETC, &otchars); /* Save old characters */ ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */ #if BSD /* provide a smaller terminal output buffer so that the type ahead detection works better (more often) */ setbuffer(stdout, &tobuf[0], TBUFSIZ); signal(SIGTSTP,SIG_DFL); /* set signals so that we can */ signal(SIGCONT,rtfrmshell); /* suspend & restart emacs */ #endif #endif /* on all screens we are not sure of the initial position of the cursor */ ttrow = 999; ttcol = 999; } /* * This function gets called just before we go back home to the command * interpreter. On VMS it puts the terminal back in a reasonable state. * Another no-operation on CPM. */ ttclose() { #if AMIGA amg_flush(); Close(terminal); #endif #if VMS int status; int iosb[1]; ttflush(); status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, oldmode, sizeof(oldmode), 0, 0, 0, 0); if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) exit(status); status = SYS$DASSGN(iochan); if (status != SS$_NORMAL) exit(status); #endif #if CPM #endif #if MSDOS & (HP150 == 0) & LATTICE /* restore the ctrl-break interupt */ rg.h.ah = 0x33; /* control-break check dos call */ rg.h.al = 1; /* set the current state */ rg.h.dl = 1; /* set it ON */ intdos(&rg, &rg); /* go for it! */ #endif #if USG ioctl(0, TCSETA, &otermio); /* restore terminal settings */ #endif #if V7 | BSD stty(0, &ostate); ioctl(0, TIOCSETC, &otchars); /* Place old character into K */ #endif } /* * Write a character to the display. On VMS, terminal output is buffered, and * we just put the characters in the big array, after checking for overflow. * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on * MS-DOS (use the very very raw console output routine). */ ttputc(c) #if AMIGA | (ST520 & MEGAMAX) char c; #endif { #if AMIGA scrn_tmp[scrn_tmp_p++] = c; if(scrn_tmp_p>=AMG_MAXBUF) amg_flush(); #endif #if ST520 & MEGAMAX Bconout(2,c); #endif #if VMS if (nobuf >= NOBUF) ttflush(); obuf[nobuf++] = c; #endif #if CPM bios(BCONOUT, c, 0); #endif #if MSDOS & MWC86 putcnb(c); #endif #if MSDOS & (LATTICE | AZTEC) & ~IBMPC bdos(6, c, 0); #endif #if RAINBOW Put_Char(c); /* fast video */ #endif #if V7 | USG | BSD fputc(c, stdout); #endif } #if AMIGA amg_flush() { if(scrn_tmp_p) Write(terminal,scrn_tmp,scrn_tmp_p); scrn_tmp_p = 0; } #endif /* * Flush terminal buffer. Does real work where the terminal output is buffered * up. A no-operation on systems where byte at a time terminal I/O is done. */ ttflush() { #if AMIGA amg_flush(); #endif #if VMS int status; int iosb[2]; status = SS$_NORMAL; if (nobuf != 0) { status = SYS$QIOW(EFN, iochan, IO$_WRITELBLK|IO$M_NOFORMAT, iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0); if (status == SS$_NORMAL) status = iosb[0] & 0xFFFF; nobuf = 0; } return (status); #endif #if CPM #endif #if MSDOS #endif #if V7 | USG | BSD fflush(stdout); #endif } /* * Read a character from the terminal, performing no editing and doing no echo * at all. More complex in VMS that almost anyplace else, which figures. Very * simple on CPM, because the system can do exactly what you want. */ ttgetc() { #if AMIGA char ch; amg_flush(); Read(terminal, &ch, 1L); return(255 & (int)ch); #endif #if ST520 & MEGAMAX long ch; /* * blink the cursor only if nothing is happening, this keeps the * cursor on steadily during movement making it easier to track */ STcurblink(TRUE); /* the cursor blinks while we wait */ ch = Bconin(2); STcurblink(FALSE); /* the cursor is steady while we work */ STscancode = (ch >> 16) & 0xff; return(255 & (int)ch); #endif #if VMS int status; int iosb[2]; int term[2]; while (ibufi >= nibuf) { ibufi = 0; term[0] = 0; term[1] = 0; status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED, iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0); if (status != SS$_NORMAL) exit(status); status = iosb[0] & 0xFFFF; if (status!=SS$_NORMAL && status!=SS$_TIMEOUT) exit(status); nibuf = (iosb[0]>>16) + (iosb[1]>>16); if (nibuf == 0) { status = SYS$QIOW(EFN, iochan, IO$_READLBLK, iosb, 0, 0, ibuf, 1, 0, term, 0, 0); if (status != SS$_NORMAL || (status = (iosb[0]&0xFFFF)) != SS$_NORMAL) exit(status); nibuf = (iosb[0]>>16) + (iosb[1]>>16); } } return (ibuf[ibufi++] & 0xFF); /* Allow multinational */ #endif #if CPM return (biosb(BCONIN, 0, 0)); #endif #if RAINBOW int Ch; while ((Ch = Read_Keyboard()) < 0); if ((Ch & Function_Key) == 0) if (!((Ch & 0xFF) == 015 || (Ch & 0xFF) == 0177)) Ch &= 0xFF; return Ch; #endif #if MSDOS & MWC86 return (getcnb()); #endif #if MSDOS & (LATTICE | MSC | AZTEC) int c; /* character read */ /* if a char already is ready, return it */ if (nxtchar >= 0) { c = nxtchar; nxtchar = -1; return(c); } /* call the dos to get a char */ rg.h.ah = 7; /* dos Direct Console Input call */ intdos(&rg, &rg); c = rg.h.al; /* grab the char */ return(c & 255); #endif #if V7 | USG | BSD return(127 & fgetc(stdin)); #endif } #if TYPEAH & (~ST520 | ~LATTICE) /* typahead: Check to see if any characters are already in the keyboard buffer */ typahead() { #if MSDOS & (LATTICE | AZTEC | MWC86) int c; /* character read */ int flags; /* cpu flags from dos call */ #if MSC if (kbhit() != 0) return(TRUE); else return(FALSE); #endif if (nxtchar >= 0) return(TRUE); rg.h.ah = 6; /* Direct Console I/O call */ rg.h.dl = 255; /* does console input */ #if LATTICE | AZTEC flags = intdos(&rg, &rg); #else intcall(&rg, &rg, 0x21); flags = rg.x.flags; #endif c = rg.h.al; /* grab the character */ /* no character pending */ if ((flags & 64) != 0) return(FALSE); /* save the character and return true */ nxtchar = c; return(TRUE); #endif #if BSD int x; /* holds # of pending chars */ return((ioctl(0,FIONREAD,&x) < 0) ? 0 : x); #endif return(FALSE); } #endif SHAR_EOF chmod +x 'termio.c' fi echo shar: "extracting 'tipc.c'" '(0 character)' if test -f 'tipc.c' then echo shar: "will not over-write existing file 'tipc.c'" else cat << \SHAR_EOF > 'tipc.c' /* * The routines in this file provide support for the TI-PC and other * compatible terminals. It goes directly to the graphics RAM to do * screen output. It compiles into nothing if not a TI-PC driver */ #define termdef 1 /* don't define "term" external */ #include #include "estruct.h" #include "edef.h" #if TIPC #define NROW 25 /* Screen size. */ #define NCOL 80 /* Edit if you want to. */ #define MARGIN 8 /* size of minimim margin and */ #define SCRSIZ 64 /* scroll size for extended lines */ #define NPAUSE 200 /* # times thru update to pause */ #define BEL 0x07 /* BEL character. */ #define ESC 0x1B /* ESC character. */ #define SPACE 32 /* space character */ #define SCADD 0xDE000L /* address of screen RAM */ #define CHAR_ENABLE 0x08 /* TI attribute to show char */ #define TI_REVERSE 0x10 /* TI attribute to reverse char */ #define BLACK 0+CHAR_ENABLE /* TI attribute for Black */ #define BLUE 1+CHAR_ENABLE /* TI attribute for Blue */ #define RED 2+CHAR_ENABLE /* TI attribute for Red */ #define MAGENTA 3+CHAR_ENABLE /* TI attribute for Magenta */ #define GREEN 4+CHAR_ENABLE /* TI attribute for Green */ #define CYAN 5+CHAR_ENABLE /* TI attribute for Cyan */ #define YELLOW 6+CHAR_ENABLE /* TI attribute for Yellow */ #define WHITE 7+CHAR_ENABLE /* TI attribute for White */ extern int ttopen(); /* Forward references. */ extern int ttgetc(); extern int ttputc(); extern int ttflush(); extern int ttclose(); extern int timove(); extern int tieeol(); extern int tieeop(); extern int tibeep(); extern int tiopen(); extern int tirev(); extern int ticres(); extern int ticlose(); extern int tiputc(); #if COLOR extern int tifcol(); extern int tibcol(); int cfcolor = -1; /* current forground color */ int cbcolor = -1; /* current background color */ int ctrans[] = /* ansi to ti color translation table */ {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}; #endif /* * Standard terminal interface dispatch table. Most of the fields point into * "termio" code. */ TERM term = { NROW-1, NROW-1, NCOL, NCOL, MARGIN, SCRSIZ, NPAUSE, tiopen, ticlose, ttgetc, tiputc, ttflush, timove, tieeol, tieeop, tibeep, tirev, ticres #if COLOR , tifcol, tibcol #endif }; extern union REGS rg; #if COLOR setatt( attr ) int attr; { rg.h.ah = 0x16; /* set the forground character attribute */ rg.h.bl = attr; int86( 0x49, &rg, &rg ); } tifcol(color) /* set the current output color */ int color; /* color to set */ { cfcolor = ctrans[color]; setatt ( cfcolor ); } tibcol(color) /* set the current background color */ int color; /* color to set */ { cbcolor = ctrans[color]; } #endif timove(row, col) { rg.h.ah = 2; /* set cursor position function code */ rg.h.dh = col; rg.h.dl = row; int86(0x49, &rg, &rg); } tieeol() /* erase to the end of the line */ { int ccol; /* current column cursor lives */ int crow; /* row */ /* find the current cursor position */ rg.h.ah = 3; /* read cursor position function code */ int86(0x49, &rg, &rg); ccol = rg.h.dh; /* record current column */ crow = rg.h.dl; /* and row */ rg.h.ah = 0x09; /* Write character at cursor position */ rg.h.al = ' '; /* Space */ rg.h.bl = cfcolor; rg.x.cx = NCOL-ccol; /* Number of characters to write */ int86(0x49, &rg, &rg); } tiputc(ch) /* put a character at the current position in the current colors */ int ch; { rg.h.ah = 0x0E; /* write char to screen with current attrs */ rg.h.al = ch; int86(0x49, &rg, &rg); } tieeop() /* Actually a clear screen */ { rg.h.ah = 0x13; /* Clear Text Screen and Home Cursor */ int86(0x49, &rg, &rg); } tirev(state) /* change reverse video state */ int state; /* TRUE = reverse, FALSE = normal */ { setatt( state ? cbcolor : cfcolor ); } ticres() /* change screen resolution */ { return(TRUE); } spal() /* change palette string */ { /* Does nothing here */ } tibeep() { bdos(6, BEL, 0); } tiopen() { strcpy(sres, "NORMAL"); revexist = TRUE; ttopen(); } ticlose() { #if COLOR tifcol(7); tibcol(0); #endif ttclose(); } #else tihello() { } #endif SHAR_EOF chmod +x 'tipc.c' fi exit 0 # End of shell archive