home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume4 / uemacs / patch1 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  21.5 KB

  1. From: Paul Placeway <talcott!caip!osu-eddie!paul>
  2. Subject: Termcap support for MicroEmacs v. 30 sources
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 79
  7. Submitted by: Paul Placeway <talcott!caip!osu-eddie!paul>
  8.  
  9.  
  10. These are the changes for VERSION 30 MicroEmacs to do Unix termcap support.
  11. They have been tested under 4.2 BSD Unix, and should work under 4.1, and
  12. 4.3.  Changes for any USG version will take more work (i.e. extensive changes
  13. to sys/ultrix/* and tty/termcap/*).
  14.  
  15. Installition instructions for MicroEmacs version 30 termcap support:
  16.  
  17.  1) Go to the directory containing the MicroEmacs version 30 distribution
  18.     (version 30 is the one posted to mod.sources)
  19.  2) unshar the following shar file (trim at the ---cut here-- and run through
  20.     sh).
  21.  3) apply the ./sys/ultrix/ttyio.diff diffs to ttyio.c (by hand or by the patch
  22.     program).
  23.  4) copy Makefile.tc to Makefile
  24.  5) edit the Makefile a bit if you like
  25.  6) make.  You MUST either use the Makefile supplied, or re-edit the ultrix
  26.     Makefile so that the tty is termcap and it does a -ltermcap on the link
  27.     step.
  28.  
  29. If you have any problems, send me mail and I will try to figure things out.
  30.  
  31.              -- Paul Placeway
  32.                 paul@ohio-state
  33.                 ...!cbosgd!osu-eddie!paul
  34.  
  35.  -----------------cut here------------------------------
  36. #! /bin/sh
  37. # This is a shell archive, meaning:
  38. # 1. Remove everything above the #! /bin/sh line.
  39. # 2. Save the resulting text in a file.
  40. # 3. Execute the file with /bin/sh (not csh) to create the files:
  41. #    Makefile.tc
  42. #    sys/ultrix/ttyio.diff
  43. #    tty/termcap/tty.c
  44. #    tty/termcap/ttydef.h
  45. #    tty/termcap/ttykbd.c
  46. # This archive created: Fri Apr 25 07:59:50 1986
  47. export PATH; PATH=/bin:$PATH
  48. echo shar: extracting "'Makefile.tc'" '(1064 characters)'
  49. if test -f 'Makefile.tc'
  50. then
  51.     echo shar: will not over-write existing file "'Makefile.tc'"
  52. else
  53. cat << \SHAR_EOF > 'Makefile.tc'
  54. # Makefile for MicroEMACS.
  55. # Is there a better way to do the rebuilds, other than using
  56. # the links?
  57.  
  58. SYS    = ultrix
  59. TTY    = termcap
  60. LIBS    = -ltermcap
  61. CFLAGS    = -O
  62. DEST    = /u/paul/bin/m
  63.  
  64. OBJ =    basic.o \
  65.     buffer.o \
  66.     cinfo.o \
  67.     display.o \
  68.     echo.o \
  69.     extend.o \
  70.     file.o \
  71.     kbd.o \
  72.     line.o \
  73.     main.o \
  74.     random.o \
  75.     region.o \
  76.     search.o \
  77.     symbol.o \
  78.     version.o \
  79.     window.o \
  80.     word.o \
  81.     fileio.o \
  82.     spawn.o \
  83.     ttyio.o \
  84.     tty.o \
  85.     ttykbd.o
  86.  
  87. xemacs:        $(OBJ)
  88.     cc -o xemacs $(OBJ) $(LIBS)
  89.  
  90. $(OBJ):        def.h sysdef.h ttydef.h
  91.  
  92. sysdef.h:    sys/$(SYS)/sysdef.h    # Update links, if needed.
  93.     rm -f sysdef.h
  94.     ln sys/$(SYS)/sysdef.h .
  95.  
  96. ttydef.h:    tty/$(TTY)/ttydef.h
  97.     rm -f ttydef.h
  98.     ln tty/$(TTY)/ttydef.h .
  99.  
  100. fileio.c:    sys/$(SYS)/fileio.c
  101.     rm -f fileio.c
  102.     ln sys/$(SYS)/fileio.c .
  103.  
  104. spawn.c:    sys/$(SYS)/spawn.c
  105.     rm -f spawn.c
  106.     ln sys/$(SYS)/spawn.c .
  107.  
  108. tty.c:        tty/$(TTY)/tty.c
  109.     rm -f tty.c
  110.     ln tty/$(TTY)/tty.c .
  111.  
  112. ttyio.c:    sys/$(SYS)/ttyio.c
  113.     rm -f ttyio.c
  114.     ln sys/$(SYS)/ttyio.c .
  115.  
  116. ttykbd.c:    tty/$(TTY)/ttykbd.c
  117.     rm -f ttykbd.c
  118.     ln tty/$(TTY)/ttykbd.c .
  119.  
  120. install: xemacs
  121.     cp xemacs $(DEST)
  122. SHAR_EOF
  123. if test 1064 -ne "`wc -c < 'Makefile.tc'`"
  124. then
  125.     echo shar: error transmitting "'Makefile.tc'" '(should have been 1064 characters)'
  126. fi
  127. fi
  128. if test ! -d 'sys'
  129. then
  130.     echo shar: creating directory "'sys'"
  131.     mkdir 'sys'
  132. fi
  133. if test ! -d 'sys/ultrix'
  134. then
  135.     echo shar: creating directory "'sys/ultrix'"
  136.     mkdir 'sys/ultrix'
  137. fi
  138. echo shar: extracting "'sys/ultrix/ttyio.diff'" '(4313 characters)'
  139. if test -f 'sys/ultrix/ttyio.diff'
  140. then
  141.     echo shar: will not over-write existing file "'sys/ultrix/ttyio.diff'"
  142. else
  143. cat << \SHAR_EOF > 'sys/ultrix/ttyio.diff'
  144. *** ttyio.old    Tue Apr 22 17:24:48 1986
  145. --- ttyio.c    Tue Apr 22 18:11:39 1986
  146. ***************
  147. *** 1,10
  148.   /*
  149.    * Name:    MicroEMACS
  150. !  *        Ultrix-32 terminal I/O.
  151. !  * Version:    29
  152. !  * Last edit:    05-Feb-86
  153. !  * By:        rex::conroy
  154. !  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  155.    *
  156.    * The functions in this file
  157.    * negotiate with the operating system for
  158.  
  159. --- 1,10 -----
  160.   /*
  161.    * Name:    MicroEMACS
  162. !  *        Ultrix-32 and Unix terminal I/O.
  163. !  * Version:    29 -- osu 2
  164. !  * Last edit:    22-Apr-86
  165. !  * By:        paul@ohio-state
  166. !  *        cbosgd!osu-eddie!paul
  167.    *
  168.    * The functions in this file
  169.    * negotiate with the operating system for
  170. ***************
  171. *** 38,44
  172.   ttopen()
  173.   {
  174.       register char    *cp;
  175. !     extern char    *getenv();
  176.   
  177.       if (ioctl(0, TIOCGETP, &oldtty) < 0)
  178.           abort();
  179.  
  180. --- 38,48 -----
  181.   ttopen()
  182.   {
  183.       register char    *cp;
  184. !         char *getenv();
  185. !         char *t, *p, *tgetstr();
  186. !         char tcbuf[1024];
  187. !         char *tv_stype;
  188. !         char err_str[72];
  189.   
  190.       if (ioctl(0, TIOCGETP, &oldtty) < 0)
  191.           abort();
  192. ***************
  193. *** 48,53
  194.       newtty.sg_kill   = oldtty.sg_kill;
  195.       newtty.sg_flags  = oldtty.sg_flags;
  196.       newtty.sg_flags &= ~(ECHO|CRMOD);    /* Kill echo, CR=>NL.    */
  197.       newtty.sg_flags |= CBREAK;        /* Half-cooked mode.    */
  198.       if (ioctl(0, TIOCSETP, &newtty) < 0)
  199.           abort();
  200.  
  201. --- 52,58 -----
  202.       newtty.sg_kill   = oldtty.sg_kill;
  203.       newtty.sg_flags  = oldtty.sg_flags;
  204.       newtty.sg_flags &= ~(ECHO|CRMOD);    /* Kill echo, CR=>NL.    */
  205. + #if FLOWCONTROL
  206.       newtty.sg_flags |= CBREAK;        /* Half-cooked mode.    */
  207.   #else
  208.       newtty.sg_flags |= RAW|ANYP;        /* raw mode for 8 bit path.*/
  209. ***************
  210. *** 49,54
  211.       newtty.sg_flags  = oldtty.sg_flags;
  212.       newtty.sg_flags &= ~(ECHO|CRMOD);    /* Kill echo, CR=>NL.    */
  213.       newtty.sg_flags |= CBREAK;        /* Half-cooked mode.    */
  214.       if (ioctl(0, TIOCSETP, &newtty) < 0)
  215.           abort();
  216.       if (ioctl(0, TIOCGETC, &oldtchars) < 0)
  217.  
  218. --- 54,62 -----
  219.       newtty.sg_flags &= ~(ECHO|CRMOD);    /* Kill echo, CR=>NL.    */
  220.   #if FLOWCONTROL
  221.       newtty.sg_flags |= CBREAK;        /* Half-cooked mode.    */
  222. + #else
  223. +     newtty.sg_flags |= RAW|ANYP;        /* raw mode for 8 bit path.*/
  224. + #endif
  225.       if (ioctl(0, TIOCSETP, &newtty) < 0)
  226.           abort();
  227.       if (ioctl(0, TIOCGETC, &oldtchars) < 0)
  228. ***************
  229. *** 55,60
  230.           abort();
  231.       newtchars.t_intrc  = 0xFF;        /* Interrupt.        */
  232.       newtchars.t_quitc  = 0xFF;        /* Quit.        */
  233.       newtchars.t_startc = 0x11;        /* ^Q, for terminal.    */
  234.       newtchars.t_stopc  = 0x13;        /* ^S, for terminal.    */
  235.       newtchars.t_eofc   = 0xFF;
  236.  
  237. --- 63,69 -----
  238.           abort();
  239.       newtchars.t_intrc  = 0xFF;        /* Interrupt.        */
  240.       newtchars.t_quitc  = 0xFF;        /* Quit.        */
  241. + #if FLOWCONTROL
  242.       newtchars.t_startc = 0x11;        /* ^Q, for terminal.    */
  243.       newtchars.t_stopc  = 0x13;        /* ^S, for terminal.    */
  244.   #else
  245. ***************
  246. *** 57,62
  247.       newtchars.t_quitc  = 0xFF;        /* Quit.        */
  248.       newtchars.t_startc = 0x11;        /* ^Q, for terminal.    */
  249.       newtchars.t_stopc  = 0x13;        /* ^S, for terminal.    */
  250.       newtchars.t_eofc   = 0xFF;
  251.       newtchars.t_brkc   = 0xFF;
  252.       if (ioctl(0, TIOCSETC, &newtchars) < 0)
  253.  
  254. --- 66,75 -----
  255.   #if FLOWCONTROL
  256.       newtchars.t_startc = 0x11;        /* ^Q, for terminal.    */
  257.       newtchars.t_stopc  = 0x13;        /* ^S, for terminal.    */
  258. + #else
  259. +     newtchars.t_startc = 0xFF;        /* ^Q, for terminal.    */
  260. +     newtchars.t_stopc  = 0xFF;        /* ^S, for terminal.    */
  261. + #endif
  262.       newtchars.t_eofc   = 0xFF;
  263.       newtchars.t_brkc   = 0xFF;
  264.       if (ioctl(0, TIOCSETC, &newtchars) < 0)
  265. ***************
  266. *** 71,79
  267.       newltchars.t_lnextc = 0xFF;        /* Literal next.    */
  268.       if (ioctl(0, TIOCSLTC, &newltchars) < 0)
  269.           abort();
  270. !     if ((cp=getenv("TERMCAP")) == NULL
  271. !     || (nrow=getvalue(cp, "li")) <= 0
  272. !     || (ncol=getvalue(cp, "co")) <= 0) {
  273.           nrow = 24;
  274.           ncol = 80;
  275.       }
  276.  
  277. --- 84,106 -----
  278.       newltchars.t_lnextc = 0xFF;        /* Literal next.    */
  279.       if (ioctl(0, TIOCSLTC, &newltchars) < 0)
  280.           abort();
  281. ! /* do this the REAL way */
  282. !         if ((tv_stype = getenv("TERM")) == NULL)
  283. !         {
  284. !                 puts("Environment variable TERM not defined!");
  285. !                 exit(1);
  286. !         }
  287. !         if((tgetent(tcbuf, tv_stype)) != 1)
  288. !         {
  289. !                 sprintf(err_str, "Unknown terminal type %s!", tv_stype);
  290. !                 puts(err_str);
  291. !                 exit(1);
  292. !         }
  293. !     if ((nrow=tgetnum ("li")) <= 0
  294. !     || (ncol=tgetnum ("co")) <= 0) {
  295.           nrow = 24;
  296.           ncol = 80;
  297.       }
  298. SHAR_EOF
  299. if test 4313 -ne "`wc -c < 'sys/ultrix/ttyio.diff'`"
  300. then
  301.     echo shar: error transmitting "'sys/ultrix/ttyio.diff'" '(should have been 4313 characters)'
  302. fi
  303. fi
  304. echo shar: done with directory "'sys/ultrix'"
  305. echo shar: done with directory "'sys'"
  306. if test ! -d 'tty'
  307. then
  308.     echo shar: creating directory "'tty'"
  309.     mkdir 'tty'
  310. fi
  311. if test ! -d 'tty/termcap'
  312. then
  313.     echo shar: creating directory "'tty/termcap'"
  314.     mkdir 'tty/termcap'
  315. fi
  316. echo shar: extracting "'tty/termcap/tty.c'" '(6971 characters)'
  317. if test -f 'tty/termcap/tty.c'
  318. then
  319.     echo shar: will not over-write existing file "'tty/termcap/tty.c'"
  320. else
  321. cat << \SHAR_EOF > 'tty/termcap/tty.c'
  322. /*
  323.  * Name:    MicroEMACS
  324.  *        UNIX termcap/terminfo display driver
  325.  * Version:    2
  326.  * Last edit:    16-Apr-86
  327.  * By:        paul@ohio-state
  328.  *        cbosgd!osu-eddie!paul
  329.  *
  330.  * Termcap is a terminal information database and routines to describe 
  331.  * terminals on a UNIX system.  This should be used ALLWAYS on a UNIX system
  332.  * that has it.
  333.  */
  334. #include    "def.h"
  335.  
  336. #define    BEL    0x07            /* BEL character.        */
  337. #define    ESC    0x1B            /* ESC character.        */
  338. #define    LF    0x0A            /* Line feed.            */
  339.  
  340. extern    int    ttrow;
  341. extern    int    ttcol;
  342. extern    int    tttop;
  343. extern    int    ttbot;
  344. extern    int    tthue;
  345.  
  346. int    tceeol;            /* Costs are set later */
  347. int    tcinsl;
  348. int    tcdell;
  349.  
  350. #define TCAPSLEN 315
  351.  
  352. char tcapbuf[TCAPSLEN];
  353. char    PC,
  354.         *CM,
  355.         *CL,
  356.         *CE,
  357.         *UP,
  358.     *IM,            /* insert mode */
  359.     *IC,            /* insert a single space */
  360.     *EI,            /* end insert mode */
  361.     *DC,
  362.     *AL,            /* add line */
  363.     *DL,            /* del line */
  364.     *TI,            /* term init -- start using cursor motion */
  365.     *TE,            /* term end --- end using cursor motion */
  366.     *SO,
  367.     *SE,
  368.         *CD;
  369.  
  370. /*
  371.  * Initialize the terminal when the editor
  372.  * gets started up. This is a no-op on the ANSI
  373.  * display. On the SCALD display, it turns off the
  374.  * half-screen scroll, because this appears to really
  375.  * confuse the scrolling region firmware in the
  376.  * display.
  377.  */
  378. static char tcbuf[1024];
  379.  
  380. ttinit()
  381. {
  382.         char *getenv();
  383.         char *t, *p, *tgetstr();
  384.         char *tv_stype;
  385.         char err_str[72];
  386.  
  387.         if ((tv_stype = getenv("TERM")) == NULL)
  388.         {
  389.                 puts("Environment variable TERM not defined!");
  390.                 exit(1);
  391.         }
  392.  
  393.         if((tgetent(tcbuf, tv_stype)) != 1)
  394.         {
  395.                 sprintf(err_str, "Unknown terminal type %s!", tv_stype);
  396.                 puts(err_str);
  397.                 exit(1);
  398.         }
  399.  
  400.         p = tcapbuf;
  401.         t = tgetstr("pc", &p);
  402.         if(t)
  403.                 PC = *t;
  404.  
  405.         CD = tgetstr("cd", &p);
  406.         CM = tgetstr("cm", &p);
  407.         CE = tgetstr("ce", &p);
  408.         UP = tgetstr("up", &p);
  409.     IM = tgetstr("im", &p);
  410.     IC = tgetstr("ic", &p);
  411.     EI = tgetstr("ei", &p);
  412.     DC = tgetstr("dc", &p);
  413.     AL = tgetstr("al", &p);
  414.     DL = tgetstr("dl", &p);
  415.     TI = tgetstr("ti", &p);
  416.     TE = tgetstr("te", &p);
  417.     SO = tgetstr("so", &p);
  418.     SE = tgetstr("se", &p);
  419.  
  420.         if(CD == NULL || CM == NULL || CE == NULL || UP == NULL)
  421.         {
  422.                 puts("This terminal is not powerful enough to run Micro Emacs\n");
  423.                 exit(1);
  424.         }
  425.     if (!*CE) {
  426.         tceeol = ncol;
  427.     } else {
  428.         tceeol = charcost(CE);
  429.     }
  430.     if (!*AL) {
  431.         tcinsl = nrow * ncol; /* make this cost high enough that it */
  432.                   /* won't ever happen */
  433.     } else {
  434.         tcinsl = charcost(AL);
  435.     }
  436.     if (!*DL) {
  437.         tcdell = nrow * ncol; /* make this cost high enough that it */
  438.                   /* won't ever happen */
  439.     } else {
  440.         tcdell = charcost(DL);
  441.     }
  442.  
  443.         if (p >= &tcapbuf[TCAPSLEN])
  444.         {
  445.                 puts("Terminal description too big!\n");
  446.                 exit(1);
  447.         }
  448.     if (*TI) tputs (TI);    /* init the term */
  449. }
  450.  
  451. /*
  452.  * Clean up the terminal, in anticipation of
  453.  * a return to the command interpreter. This is a no-op
  454.  * on the ANSI display. On the SCALD display, it sets the
  455.  * window back to half screen scrolling. Perhaps it should
  456.  * query the display for the increment, and put it
  457.  * back to what it was.
  458.  */
  459. tttidy()
  460. {
  461.     if (*TE) tputs (TE);    /* set the term back to normal mode */
  462. }
  463.  
  464. /*
  465.  * Move the cursor to the specified
  466.  * origin 0 row and column position. Try to
  467.  * optimize out extra moves; redisplay may
  468.  * have left the cursor in the right
  469.  * location last time!
  470.  */
  471. ttmove(row, col)
  472. {
  473.     if (ttrow!=row || ttcol!=col) {
  474.     putpad(tgoto(CM, col, row));
  475.     ttrow = row;
  476.     ttcol = col;
  477.     }
  478. }
  479.  
  480. /*
  481.  * Erase to end of line.
  482.  */
  483. tteeol()
  484. {
  485.         putpad(CE);
  486. }
  487.  
  488. /*
  489.  * Erase to end of page.
  490.  */
  491. tteeop()
  492. {
  493.         putpad(CD);
  494. }
  495.  
  496. /*
  497.  * Make a noise.
  498.  */
  499. ttbeep()
  500. {
  501.     ttputc(BEL);
  502.     ttflush();
  503. }
  504.  
  505. /*
  506.  * Insert nchunk blank line(s) onto the
  507.  * screen, scrolling the last line on the
  508.  * screen off the bottom. This is done with
  509.  * a cluster of clever insert and delete commands,
  510.  * because there are no scroll regions.
  511.  */
  512. ttinsl(row, bot, nchunk)
  513. {
  514.     register int    i;
  515.     
  516.     if (row == bot) {        /* Case of one line insert is     */
  517.     ttmove(row, 0);        /*    special            */
  518.     tteeol();
  519.     return;
  520.     }
  521.     ttmove(1+bot-nchunk, 0);
  522.     for (i=0; i<nchunk; i++) {    /* For all lines in the chunk    */
  523.     putpad(DL);
  524.     }
  525.     ttmove(row, 0);
  526.     for (i=0; i<nchunk; i++) {    /* For all lines in the chunk    */
  527.     putpad(AL);
  528.     }
  529.     ttrow = row;            /* End up on current line    */
  530.     ttcol = 0;
  531. }
  532.  
  533. /*
  534.  * Delete nchunk line(s) "row", replacing the
  535.  * bottom line on the screen with a blank
  536.  * line. This is done with a crafty sequences
  537.  * of insert and delete line; We assume that the terminal
  538.  * is like the Heath (ie no scrolling region). The presence of the
  539.  * echo area makes a boundry condition
  540.  * go away.
  541.  */
  542. ttdell(row, bot, nchunk)
  543. {
  544.     register int    i;
  545.     
  546.     if (row == bot) {        /* One line special case    */
  547.     ttmove(row, 0);
  548.     tteeol();
  549.     return;
  550.     }
  551.     ttmove(row, 0);
  552.     for (i=0; i<nchunk; i++) {    /* For all lines in chunk    */
  553.     putpad(DL);
  554.     }
  555.     ttmove(1+bot-nchunk,0);
  556.     for (i=0; i<nchunk; i++) {    /* For all lines in chunk    */
  557.     putpad(AL);
  558.     }
  559.     ttrow = bot-nchunk;
  560.     ttcol = 0;
  561. }
  562.  
  563. /*
  564.  * No-op.
  565.  */
  566. ttwindow(top, bot)
  567. {
  568. }
  569.  
  570. /*
  571.  * No-op.
  572.  */
  573. ttnowindow()
  574. {
  575. }
  576.  
  577. /*
  578.  * Set the current writing color to the
  579.  * specified color. Watch for color changes that are
  580.  * not going to do anything (the color is already right)
  581.  * and don't send anything to the display.
  582.  * The rainbow version does this in putline.s on a
  583.  * line by line basis, so don't bother sending
  584.  * out the color shift.
  585.  */
  586. ttcolor(color)
  587. register int    color;
  588. {
  589.     if (color != tthue) {
  590.     if (color == CTEXT) {        /* Normal video.    */
  591.         putpad(SE);
  592.     } else if (color == CMODE) {    /* Reverse video.    */
  593.         putpad(SO);
  594.     }
  595.     tthue = color;            /* Save the color.    */
  596.     }
  597. }
  598.  
  599. /*
  600.  * This routine is called by the
  601.  * "refresh the screen" command to try and resize
  602.  * the display. The new size, which must be deadstopped
  603.  * to not exceed the NROW and NCOL limits, it stored
  604.  * back into "nrow" and "ncol". Display can always deal
  605.  * with a screen NROW by NCOL. Look in "window.c" to
  606.  * see how the caller deals with a change.
  607.  */
  608. ttresize()
  609. {
  610.     register int    c;
  611.     register int    newnrow;
  612.     register int    newncol;
  613.  
  614.     newnrow = tgetnum("li"); /* on a Sun, this returns the NEW size */
  615.     newncol = tgetnum("co"); /* on anything else, returns same old size */
  616.  
  617.     if (newnrow < 1)            /* Check limits.    */
  618.         newnrow = 1;
  619.     else if (newnrow > NROW)
  620.         newnrow = NROW;
  621.     if (newncol < 1)
  622.         newncol = 1;
  623.     else if (newncol > NCOL)
  624.         newncol = NCOL;
  625.     nrow = newnrow;
  626.     ncol = newncol;
  627. }
  628.  
  629. static int cci;
  630.  
  631. static
  632. fakec(c)            /* fake char output for charcost() */
  633. char c;
  634. {
  635.     cci++;
  636. }
  637.  
  638. charcost (s)            /* calculate the cost of doing string s */
  639. char *s;
  640. {
  641.     cci = 0;
  642.  
  643.     tputs(s, nrow, fakec);
  644.     return cci;
  645. }
  646.  
  647. putpad(str)
  648. char    *str;
  649. {
  650.         tputs(str, 1, ttputc);
  651. }
  652.  
  653.  
  654. SHAR_EOF
  655. if test 6971 -ne "`wc -c < 'tty/termcap/tty.c'`"
  656. then
  657.     echo shar: error transmitting "'tty/termcap/tty.c'" '(should have been 6971 characters)'
  658. fi
  659. fi
  660. echo shar: extracting "'tty/termcap/ttydef.h'" '(1285 characters)'
  661. if test -f 'tty/termcap/ttydef.h'
  662. then
  663.     echo shar: will not over-write existing file "'tty/termcap/ttydef.h'"
  664. else
  665. cat << \SHAR_EOF > 'tty/termcap/ttydef.h'
  666. /*
  667.  * Name:    MicroEMACS
  668.  *        Digital ANSI terminal header file
  669.  * Version:    29
  670.  * Last edit:    05-Feb-86
  671.  * By:        rex::conroy
  672.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  673.  */
  674. #define    GOSLING    1            /* Compile in fancy display.    */
  675. #define    MEMMAP    0            /* Not memory mapped video.    */
  676.  
  677. /*
  678.  * Yes Bob, it's wrong for you.
  679.  */
  680. #define    NROW    66            /* Rows.            */
  681. #define    NCOL    132            /* Columns.            */
  682.  
  683. /*
  684.  * Special keys, as on the LK201, which is
  685.  * a superset of the VT100. Originally I tried to keep the
  686.  * numbers in LK201 escape sequence code, but it became too much
  687.  * of a pain because of the keycodes greater than 31. 
  688.  * The codes are all just redefinitions for the standard extra
  689.  * key codes. Using the standard names ensures that the
  690.  * LK201 codes land in the right place.
  691.  */
  692. #define    KUP    K01
  693. #define    KDOWN    K02
  694. #define    KLEFT    K03
  695. #define    KRIGHT    K04
  696. #define    KFIND    K05
  697. #define    KINSERT    K06
  698. #define    KREMOVE    K07
  699. #define    KSELECT    K08
  700. #define    KPREV    K09
  701. #define    KNEXT    K0A
  702. #define    KF4    K0B
  703. #define    KF6    K0C
  704. #define    KF7    K0D
  705. #define    KF8    K0E
  706. #define    KF9    K0F
  707. #define    KF10    K10
  708. #define    KF11    K11
  709. #define    KF12    K12
  710. #define    KF13    K13
  711. #define    KF14    K14
  712. #define    KHELP    K15
  713. #define    KDO    K16
  714. #define    KF17    K17
  715. #define    KF18    K18
  716. #define    KF19    K19
  717. #define    KF20    K1A
  718. #define    KPF1    K1B
  719. #define    KPF2    K1C
  720. #define    KPF3    K1D
  721. #define    KPF4    K1E
  722. SHAR_EOF
  723. if test 1285 -ne "`wc -c < 'tty/termcap/ttydef.h'`"
  724. then
  725.     echo shar: error transmitting "'tty/termcap/ttydef.h'" '(should have been 1285 characters)'
  726. fi
  727. fi
  728. echo shar: extracting "'tty/termcap/ttykbd.c'" '(4209 characters)'
  729. if test -f 'tty/termcap/ttykbd.c'
  730. then
  731.     echo shar: will not over-write existing file "'tty/termcap/ttykbd.c'"
  732. else
  733. cat << \SHAR_EOF > 'tty/termcap/ttykbd.c'
  734. /*
  735.  * Name:    MicroEMACS
  736.  *         Digital ANSI terminal keyboard.
  737.  *        Assumes LK201, which is OK on the VT100.
  738.  * Version:    29
  739.  * Last edit:    05-Feb-86
  740.  * By:        rex::conroy
  741.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  742.  */
  743. #include    "def.h"
  744.  
  745. #define    ESC    0x1B            /* Escape, arrows et al.    */
  746. #define    AGRAVE    0x60            /* LK201 kludge.        */
  747.  
  748. /*
  749.  * The special keys on an LK201 send back
  750.  * escape sequences of the general form <ESC>[nnn~, where
  751.  * nnn is a key code number. This table is indexed by the
  752.  * nnn code to get the key code, which is used in the
  753.  * binding table. The F4 key, and the F6 through F14 keys
  754.  * have key codes. Also F17 through F20. Think of
  755.  * help and do as special.
  756.  */
  757. short    lk201map[] = {
  758.     KRANDOM,    KFIND,        KINSERT,    KREMOVE,
  759.     KSELECT,    KPREV,        KNEXT,        KRANDOM,
  760.     KRANDOM,    KRANDOM,    KRANDOM,    KRANDOM,
  761.     KRANDOM,    KRANDOM,    KF4,        KRANDOM,
  762.     KRANDOM,    KF6,        KF7,        KF8,
  763.     KF9,        KF10,        KRANDOM,    KF11,
  764.     KF12,        KF13,        KF14,        KRANDOM,
  765.     KHELP,        KDO,        KRANDOM,    KF17,
  766.     KF18,        KF19,        KF20
  767. };
  768.  
  769. /*
  770.  * Names for the keys with basic keycode
  771.  * between KFIRST and KLAST (inclusive). This is used by
  772.  * the key name routine in "kbd.c".
  773.  */
  774. char    *keystrings[] = {
  775.     NULL,        "Up",        "Down",        "Left",
  776.     "Right",    "Find",        "Insert",    "Remove",
  777.     "Select",    "Previous",    "Next",        "F4",
  778.     "F6",        "F7",        "F8",        "F9",
  779.     "F10",        "F11",        "F12",        "F13",
  780.     "F14",        "Help",        "Do",        "F17",
  781.     "F18",        "F19",        "F20",        "PF1",
  782.     "PF2",        "PF3",        "PF4",        NULL
  783. };
  784.  
  785. /*
  786.  * Read in a key, doing the low level mapping
  787.  * of ASCII code to 11 bit code. This level deals with
  788.  * mapping the special keys into their spots in the C1
  789.  * control area. The C0 controls go right through, and
  790.  * get remapped by "getkey".
  791.  */
  792. getkbd()
  793. {
  794.     register int    c;
  795.     register int    n;
  796. loop:
  797.     c = ttgetc();
  798.     if (c == ESC) {
  799.         c = ttgetc();
  800.         if (c == '[') {
  801.             c = ttgetc();
  802.             if (c == 'A')
  803.                 return (KUP);
  804.             if (c == 'B')
  805.                 return (KDOWN);
  806.             if (c == 'C')
  807.                 return (KRIGHT);
  808.             if (c == 'D')
  809.                 return (KLEFT);
  810.             if (c>='0' && c<='9') {    /* LK201 functions.    */
  811.                 n = 0;
  812.                 do {
  813.                     n = 10*n + c - '0';
  814.                     c = ttgetc();
  815.                 } while (c>='0' && c<='9');
  816.                 if (c=='~' && n<=34) {
  817.                     c = lk201map[n];
  818.                     if (c != KRANDOM)
  819.                         return (c);
  820.                     goto loop;
  821.                 }
  822.             }
  823.             goto loop;
  824.         }
  825.         if (c == 'O') {    
  826.             c = ttgetc();
  827.             if (c == 'A')
  828.                 return (KUP);
  829.             if (c == 'B')
  830.                 return (KDOWN);
  831.             if (c == 'C')
  832.                 return (KRIGHT);
  833.             if (c == 'D')
  834.                 return (KLEFT);
  835.             if (c == 'P')
  836.                 return (KPF1);
  837.             if (c == 'Q')
  838.                 return (KPF2);
  839.             if (c == 'R')
  840.                 return (KPF3);
  841.             if (c == 'S')
  842.                 return (KPF4);
  843.             goto loop;
  844.         }
  845.         if (ISLOWER(c) != FALSE)    /* Copy the standard    */
  846.             c = TOUPPER(c);        /* META code.        */
  847.         if (c>=0x00 && c<=0x1F)
  848.             c = KCTRL | (c+'@');
  849.         return (KMETA | c);
  850.     }
  851. #if DO_METAKEY
  852.     if (c & 0x80)        /* if meta bit set on input */
  853.         return (KMETA | (c & 0x7f)); /* move bit from 8th to KMETA */
  854. #endif
  855.     return (c);
  856. }
  857.  
  858. /*
  859.  * Terminal specific keymap initialization.
  860.  * Attach the special keys to the appropriate built
  861.  * in functions. Bind all of the assigned graphics in the
  862.  * DEC supplimental character set to "ins-self".
  863.  * As is the case of all the keymap routines, errors
  864.  * are very fatal.
  865.  */
  866. ttykeymapinit()
  867. {
  868.     register SYMBOL    *sp;
  869.     register int    i;
  870.  
  871.     keydup(KFIND,    "search-again");
  872.     keydup(KHELP,    "help");
  873.     keydup(KINSERT, "yank");
  874.     keydup(KREMOVE, "kill-region");
  875.     keydup(KSELECT, "set-mark");
  876.     keydup(KPREV,    "back-page");
  877.     keydup(KNEXT,    "forw-page");
  878.     keydup(KDO,    "execute-macro");
  879.     keydup(KF17,    "back-window");
  880.     keydup(KF18,    "forw-window");
  881.     keydup(KF19,    "enlarge-window");
  882.     keydup(KF20,    "shrink-window");
  883.     keydup(KUP,    "back-line");
  884.     keydup(KDOWN,    "forw-line");
  885.     keydup(KRIGHT,    "forw-char");
  886.     keydup(KLEFT,    "back-char");
  887.  
  888.     /*
  889.      * Bind all GR positions that correspond
  890.      * to assigned characters in the Digital multinational
  891.      * character set to "ins-self". These characters may
  892.      * be used just like any other character.
  893.      */
  894.  
  895.     if ((sp=symlookup("ins-self")) == NULL)
  896.         abort();
  897.     for (i=0xA0; i<0xFF; ++i) {
  898.         if (i!=0xA4 && i!=0xA6 && i!=0xAC && i!=0xAD && i!=0xAE
  899.         &&  i!=0xAF && i!=0xB4 && i!=0xB8 && i!=0xBE && i!=0xF0
  900.         &&  i!=0xFE && i!=0xA0) {
  901.             if (binding[i] != NULL)
  902.                 abort();
  903.             binding[i] = sp;
  904.             ++sp->s_nkey;
  905.         }
  906.     }
  907. }
  908. SHAR_EOF
  909. if test 4209 -ne "`wc -c < 'tty/termcap/ttykbd.c'`"
  910. then
  911.     echo shar: error transmitting "'tty/termcap/ttykbd.c'" '(should have been 4209 characters)'
  912. fi
  913. fi
  914. echo shar: done with directory "'tty/termcap'"
  915. echo shar: done with directory "'tty'"
  916. exit 0
  917. #    End of shell archive
  918.