Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!orsvax1!pyrnj!caip!lll-crg!mordor!ut-sally!ut-ngp!mic From: mic@ut-ngp.UUCP (Mic Kaczmarczik) Newsgroups: net.micro.amiga Subject: Amiga terminal driver for MicroEmacs (1 of 3) Message-ID: <3275@ut-ngp.UUCP> Date: Wed, 23-Apr-86 11:24:52 EST Article-I.D.: ut-ngp.3275 Posted: Wed Apr 23 11:24:52 1986 Date-Received: Sat, 26-Apr-86 05:12:12 EST Reply-To: mic@ut-ngp.UUCP (Mic Kaczmarczik) Organization: U. Texas Computation Ctr Lines: 282 Keywords: Emacs [.... If I had a hammer, I'd hammer on the line eater bug ....] Greetings, This file, and two more, comprise an Amiga terminal driver for the version of MicroEmacs that was posted to the net last week. I compiled it with Manx Aztec C, but it should not be that hard to move to Lattice, since Aztec seems to have more restrictions (16-bit ints, no structure assignment). There are two versions of the terminal driver: one that uses AmigaDOS for vanilla terminal I/O, and one that uses Intuition for terminal I/O, mouse clicks, and menu selections. The function keys work with both drivers; using the Intuition driver, clicking the mouse in a window moves dot to that position, just as if you'd moved to that window and typed ^F and ^N to get there. Enjoy! Mic Kaczmarczik ...!ihnp4!seismo!ut-sally!ut-ngp!mic cc.kaczmarczik@a20.utexas.edu -----------------------------CUT HERE---------------------------------------- -h- Readme Wed Apr 23 08:52:51 1986 Readme This distribution is in three files, in portable archive format: 1) System routines (subdirectory sys/amiga). Abort.c is there because the Aztec library doesn't provide it. 2) The AmigaDOS terminal interface (subdirectory tty/amigados). It basically opens a RAW: window and reads characters one at a time from the window. 3) The Intuition terminal interface (tty/intuition). This one demonstrates the use of the console device with an Intuition window, and translates non-keyboard events into key sequences that the rest of the driver code can later parse. To get this going, you need the MicroEmacs distribution from mod.sources. Unpack this file and one of the terminal drivers into the main directory, compile and link. Happy hacking, Mic Kaczmarczik UUCP: ...!ihnp4!seismo!ut-sally!ut-ngp!mic ARPA: mic@a20.cc.utexas.edu Mail: 313B W. 35th Austin, TX 75752 -h- abort.c Wed Apr 23 08:52:51 1986 abort.c /* * Name: MicroEmacs * Amiga dummy abort function * Version: 31 * Created: 18-Apr-86 ...!ihnp4!seismo!ut-sally!ut-ngp!mic */ extern int ttclose(); abort() { ttclose(); exit(1000); } -h- fileio.c Wed Apr 23 08:52:51 1986 fileio.c /* * Name: MicroEMACS * Version: 31 * Commodore Amiga file I/O. * Last edit: 15-Apr-86 * By: Mic Kaczmarczik * ...ihnp4!seismo!ut-sally!ut-ngp!mic * * Read and write ASCII files. All * of the low level file I/O knowledge is here. * Pretty much vanilla standard I/O. */ #include "def.h" static FILE *ffp; /* * Open a file for reading. */ ffropen(fn) char *fn; { if ((ffp=fopen(fn, "r")) == NULL) return (FIOFNF); return (FIOSUC); } /* * Open a file for writing. * Return TRUE if all is well, and * FALSE on error (cannot create). */ ffwopen(fn) char *fn; { register int fd; FILE *fdopen(); if ((fd=creat(fn, 0)) < 0 || (ffp=fdopen(fd, "w")) == NULL) { eprintf("Cannot open file for writing"); return (FIOERR); } return (FIOSUC); } /* * Close a file. * Should look at the status. */ ffclose() { fclose(ffp); return (FIOSUC); } /* * Write a line to the already * opened file. The "buf" points to the * buffer, and the "nbuf" is its length, less * the free newline. Return the status. * Check only at the newline. */ ffputline(buf, nbuf) register char buf[]; { register int i; for (i=0; i= nbuf-1) { eprintf("File has long line"); return (FIOERR); } buf[i++] = '\r'; } } if (c==EOF || c=='\n') /* End of line. */ break; if (i >= nbuf-1) { eprintf("File has long line"); return (FIOERR); } buf[i++] = c; } if (c == EOF) { /* End of file. */ if (ferror(ffp) != FALSE) { eprintf("File read error"); return (FIOERR); } if (i == 0) /* Don't get upset if */ return (FIOEOF); /* no newline at EOF. */ } buf[i] = 0; return (FIOSUC); } /* * Make a file name for a backup copy. */ fbackupfile(fname) char *fname; { strcat(fname,"~"); return (TRUE); } /* * The string "fn" is a file name. * Perform any required case adjustments. All sustems * we deal with so far have case insensitive file systems. * We zap everything to lower case. The problem we are trying * to solve is getting 2 buffers holding the same file if * you visit one of them with the "caps lock" key down. * On UNIX file names are dual case, so we leave * everything alone. */ adjustcase(fn) register char *fn; { register int c; while ((c = *fn) != 0) { if (c>='A' && c<='Z') *fn = c + 'a' - 'A'; ++fn; } } -h- sleep.c Wed Apr 23 08:52:51 1986 sleep.c /* * Name: MicroEmacs * AmigaDOS sleep function * Version: 31 * Last Edit: 18-Apr-86 * Created: 18-Apr-86 ...!ihnp4!seismo!ut-sally!ut-ngp!mic */ /* There are really 60 ticks/second, but I don't want to wait that */ /* long when matching parentheses... */ #define TICKS 45 extern long Delay(); sleep(n) int n; { if (n > 0) Delay((long) n * TICKS); } -h- spawn.c Wed Apr 23 08:52:51 1986 spawn.c /* * Name: MicroEMACS * Spawn an AmigaDOS subprocess * Version: 31 * Last edit: 17-Apr-86 * By: ...!ihnp4!seismo!ut-sally!ut-ngp!mic */ #include "def.h" #include #include /* * Create a subjob with a copy * of the command intrepreter in it. Since the command * interpreter doesn't run in the same window, there's no * need for a refresh. Ah, the beauties of windowing system... */ spawncli(f, n, k) { struct FileHandle *newcli, *Open(); eprintf("[Starting new CLI]"); newcli = Open("CON:1/1/639/199/MicroEmacs Subprocess", MODE_NEWFILE); if (newcli == (struct FileHandle *) 0) { eprintf("Can't create new CLI window"); return (FALSE); } Execute("", newcli, 0L); Close(newcli); return (TRUE); }