home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume8 / micrognu / part07 < prev    next >
Text File  |  1987-01-26  |  56KB  |  1,924 lines

  1. Subject:  v08i014:  A Micro-Emacs variant that resembles GNU Emacs
  2. Newsgroups: mod.sources
  3. Approved: mirror!rs
  4.  
  5. Submitted by: Bob Larson <seismo!usc-oberon!blarson>
  6. Mod.sources: Volume 8, Issue 14
  7. Archive-name: micrognu/Part07
  8.  
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create the files:
  15. #    tty/amiga/ttykbd.c
  16. #    tty/amiga/ttymouse.c
  17. #    sys/amiga/Makefile.LATTICE
  18. #    sys/amiga/Makefile.MANX
  19. #    sys/amiga/amiga.doc
  20. #    sys/amiga/fileio.c
  21. #    sys/amiga/sleep.c
  22. #    sys/amiga/spawn.c
  23. #    sys/amiga/sysdef.h
  24. #    sys/amiga/varargs.h
  25. # This archive created: Sat Nov 15 15:34:45 1986
  26. export PATH; PATH=/bin:$PATH
  27. if test -f 'tty/amiga/ttykbd.c'
  28. then
  29.     echo shar: will not over-write existing file "'tty/amiga/ttykbd.c'"
  30. else
  31. cat << \SHAR_EOF > 'tty/amiga/ttykbd.c'
  32. /*
  33.  * Name:    MicroEMACS
  34.  *         Amiga virtual terminal keyboard, default console keymap.
  35.  * Version:    Gnu v30
  36.  * Last edit:    25-Oct-86
  37.  * Created:    19-Apr-86 ...!ihnp4!seismo!ut-sally!ut-ngp!mic
  38.  *        This goes with the Intuition terminal driver,
  39.  *        and implements Mike Meyer's hot mouse.
  40.  */
  41. #include    <exec/types.h>
  42. #include    <intuition/intuition.h>
  43. #undef    TRUE
  44. #undef    FALSE
  45. #include    "def.h"
  46.  
  47. #define    ESC    0x1B            /* Escape, arrows et al.    */
  48. #define    CSI    0x9B            /* Amiga CSI            */
  49.  
  50. #ifdef    MOUSE
  51. /* Stuff for the hot mouse.  Since right now the mouse
  52.  * keys get bound into a wierd place, a lot of the
  53.  * jiggery-pokery up here is to make it possible
  54.  * to shift their location in the keymap without too
  55.  * much fuss.  Sorry for the horrid macro names...
  56.  */
  57.  
  58. /* key code w/o mini qualifiers */
  59. #define    WMOUSE    ((KEY)(KCTRL | KMETA | 'a'))
  60. #define SMOUSE    ((KEY)(KCTRL | KMETA | 'i'))
  61. #define    EMOUSE    ((KEY)(KCTRL | KMETA | 'q'))
  62.  
  63. /* mini qualifiers */
  64. #define    SHFT    1
  65. #define ALT    2
  66. #define CTRL    4
  67.  
  68. /* macros to create qualified key codes */
  69.  
  70. #define    S(k)    (k + SHFT)
  71. #define    A(k)    (k + ALT)
  72. #define    C(k)    (k + CTRL)
  73. #define    AS(k)    (k + SHFT + ALT)
  74. #define    CS(k)    (k + CTRL + SHFT)
  75. #define    CA(k)    (k + CTRL + ALT)
  76. #define    CAS(k)    (k + SHFT + ALT + CTRL)
  77. #endif /* ifdef MOUSE */
  78.  
  79. #ifdef    XKEYS
  80. /*
  81.  * The function keys on the Amiga send back
  82.  * escape sequences of the form <ESC>[code~, where code
  83.  * is a one or two-character code for the key.  To make
  84.  * it easier to decode, we place the internal key values
  85.  * for these codes in this table.
  86.  */
  87.  
  88. short    consolemap[] = {
  89.     KF1,        KF2,        KF3,        KF4,
  90.     KF5,        KF6,        KF7,        KF8,
  91.     KF9,        KF10,        KSF1,        KSF2,
  92.     KSF3,        KSF4,        KSF5,        KSF6,
  93.     KSF7,        KSF8,        KSF9,        KSF10
  94. };
  95. #define    NFUNCKEYS ((sizeof consolemap)/(sizeof consolemap[0]))
  96. #endif
  97.  
  98. /*
  99.  * Names for the keys with basic keycode
  100.  * between KFIRST and KLAST (inclusive). This is used by
  101.  * the key name routine in "kbd.c".  KFIRST is KRANDOM,
  102.  * which we don't bind anything useful to.  "The Menu" is
  103.  * special; we implement menus as another function key,
  104.  * but there isn't really any "MENU" key on the keyboard.
  105.  * There is no shifted value for the help key.  Mouse clicks
  106.  * have been moved to a hitherto unused part of the keymap.
  107.  */
  108. #ifdef    DO_MENU
  109. #define MENUNAME "The Menu"
  110. #else
  111. #define MENUNAME NULL
  112. #endif
  113.  
  114. char    *keystrings[] = {
  115. #ifdef    XKEYS
  116.     NULL,        "F1",        "F2",        "F3",
  117.     "F4",        "F5",        "F6",        "F7",
  118.     "F8",        "F9",        "F10",        "Shift-F1",
  119.     "Shift-F2",    "Shift-F3",    "Shift-F4",    "Shift-F5",
  120.     "Shift-F6",    "Shift-F7",    "Shift-F8",    "Shift-F9",
  121.     "Shift-F10",    "Up",        "Shift-Up",    "Down",
  122.     "Shift-Down",    "Left",        "Shift-Left",    "Right",
  123.     "Shift-Right",    "Help",        MENUNAME,    NULL
  124. #else
  125.     NULL,        NULL,        NULL,        NULL,
  126.     NULL,        NULL,        NULL,        NULL,
  127.     NULL,        NULL,        NULL,        NULL,
  128.     NULL,        NULL,        NULL,        NULL,
  129.     NULL,        NULL,        NULL,        NULL,
  130.     NULL,        NULL,        NULL,        NULL,
  131.     NULL,        NULL,        NULL,        NULL,
  132.     NULL,        NULL,        MENUNAME,    NULL
  133. #endif
  134. };
  135.  
  136. /*
  137.  * Read in a key, doing the low level mapping
  138.  * of ASCII code to 11 bit code. This level deals with
  139.  * mapping the special keys into their spots in the C1
  140.  * control area. The C0 controls go right through, and
  141.  * get remapped by "getkey".  Returning function keys
  142.  * with KMETA set distinguishes these keys from codes
  143.  * generated by ALT-ing a control key (which I want
  144.  * to have mapped in the usual way).
  145.  */
  146.  
  147. getkbd()
  148. {
  149.     register int    c;
  150. #ifdef    XKEYS
  151.     register int    n;
  152. #endif
  153. loop:
  154.     c = ttgetc();
  155.     if (c == CSI) {
  156.         c = ttgetc();
  157. #ifdef    MOUSE
  158.         if (c == 'P') {            /* mouse sequence    */
  159.             ttgetc();        /* discard '~'        */
  160.             return (KCTRL | getmouse());    /* create key code    */
  161.         }
  162. #endif
  163.  
  164. #ifdef    DO_MENU
  165.         if (c == 'M') {            /* (fake) menu key    */
  166.             ttgetc();        /* discard '~'        */
  167.             return (KCTRL | KMENU);
  168.         }
  169. #endif
  170.  
  171. #ifdef    XKEYS
  172.         if (c == '?') {            /* HELP key        */
  173.             ttgetc();        /* discard '~'        */
  174.             return (KCTRL | KHELP);
  175.         }
  176.         /* Arrow keys */
  177.         if (c == 'A')
  178.             return (KCTRL | KUP);
  179.         if (c == 'B')
  180.             return (KCTRL | KDOWN);
  181.         if (c == 'C')
  182.             return (KCTRL | KRIGHT);
  183.         if (c == 'D')
  184.             return (KCTRL | KLEFT);
  185.         if (c == 'T')
  186.             return (KCTRL | KSUP);
  187.         if (c == 'S')
  188.             return (KCTRL | KSDOWN);
  189.         /* Shifted left, right arrow */
  190.         if (c == ' ') {
  191.             c = ttgetc();
  192.             if (c == 'A' || c == '@')
  193.                 return (KCTRL | ((c == 'A') ?
  194.                     (KSLEFT) : (KSRIGHT)));
  195.             goto loop;        /* try again, sucker */
  196.         }
  197.  
  198.         /* Function keys    */
  199.         if (c >= '0' && c <= '9') {
  200.             n = 0;
  201.             do {
  202.                 n = 10*n + c - '0';
  203.                 c = ttgetc();
  204.             } while (c>='0' && c<='9');
  205.             if (c == '~' && n < NFUNCKEYS) {
  206.                 c = consolemap[n];
  207.                 if (c != KRANDOM)
  208.                     return (KCTRL | c);
  209.                 goto loop;
  210.             }
  211.             else 
  212.                 goto loop;    /* Try again */
  213.         }
  214. #endif
  215.         goto loop;        /* Try again */
  216.     }
  217.     return (c);
  218. }
  219.  
  220. #ifdef    MOUSE
  221. /*
  222.  * A hack for the hot mouse -- peek ahead at the
  223.  * next mouse event and construct an internal key
  224.  * code.  Might as well use those extra binding slots...
  225.  */
  226.  
  227. getmouse()
  228. {
  229.     USHORT        row, col, qual;
  230.     int ttmouse();
  231.     register int    code = 0;
  232.     register struct WINDOW *wp;
  233.  
  234.     ttmouse(FALSE, &row, &col, &qual);    /* look at mouse */
  235.  
  236.     /* was the click in a window ???    */
  237.     for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
  238.         if ((row >= wp->w_toprow) &&
  239.             (row <= (wp->w_toprow + wp->w_ntrows)))
  240.             break ;
  241.  
  242.     /* figure out what area the click was in            */
  243.     if (wp == NULL)            /* not found; assume echo line    */
  244.         code = EMOUSE;
  245.     else if (row == (wp->w_toprow + wp->w_ntrows))    /* status line    */
  246.         code = SMOUSE;
  247.     else
  248.         code = WMOUSE;    /* click in a window        */
  249.  
  250.     /* figure out 'mini' qualifiers -- ADD them, because 'a' isn't    */
  251.     /* divisible by 2...  This took me 2 hours to realize...           */
  252.     if (qual & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
  253.         code += SHFT;
  254.     if (qual & (IEQUALIFIER_LALT | IEQUALIFIER_RALT))
  255.         code += ALT;
  256.     if (qual & IEQUALIFIER_CONTROL)
  257.         code += CTRL;
  258.  
  259.     return (code);
  260. }
  261. #endif
  262.  
  263. /*
  264.  * Terminal specific keymap initialization.
  265.  *
  266.  * Bind all of the assigned graphics in the
  267.  * Amiga alternate character set to self-insert.
  268.  *
  269.  * #ifdef XKEYS, attach the special keys to the appropriate
  270.  * built-in functions.
  271.  *
  272.  * #ifdef DO_MENU, bind the fake KMENU code to amigamenu()
  273.  * to do menu selection as transparently as possible.
  274.  *
  275.  * #ifdef MOUSE, bind the hot mouse keys to the
  276.  * functions. In the case of window and mode line
  277.  * selections, call special functions
  278.  * special functions that select the appropriate
  279.  * object (i.e. character, window) before performing
  280.  * the task.
  281.  *
  282.  * As is the case of all the keymap routines, errors
  283.  * result in panic.
  284.  */
  285.  
  286. extern    int    togglewindow();        /* Defined by "ttyio.c"        */
  287.  
  288. #ifdef    DO_MENU
  289. extern    int    amigamenu();        /* Defined by "ttymenu.c"     */
  290. #endif
  291.  
  292. #ifdef    CHANGE_FONT
  293. extern    int    setfont();        /* Defined by "ttyio.c"        */
  294. #endif
  295.  
  296. #ifdef    MOUSE
  297. extern    int    amigamouse();        /* Defined by "ttymouse.c"    */
  298. extern    int    mreposition();        /* Functions which select the    */ 
  299. extern    int    mdelfword();        /* window the click was in,    */
  300. extern    int    mkillline();        /* then call another one    */
  301. extern    int    mforwdel();        /* Defined in "ttymouse.c"    */
  302. extern    int    mdelwhite();
  303. extern    int    mkillregion();
  304. extern    int    myank();
  305. extern    int    mforwpage();
  306. extern    int    mbackpage();
  307. extern    int    msplitwind();
  308. extern    int    mdelwind();
  309. extern    int    mgotobob();
  310. extern    int    mgotoeob();
  311. extern    int    menlargewind();
  312. extern    int    mshrinkwind();
  313. #endif
  314.  
  315. #ifdef    CHANGE_COLOR
  316.     /* functions to mess with the mode line rendition, window colors*/
  317. extern    int    ttmode();        /* Defined by "tty.c"        */
  318. extern    int    tttext();        /*  ""                */
  319. extern    int    textforeground();    /*  ""                */
  320. extern    int    textbackground();    /*  ""                */
  321. extern    int    modeforeground();    /*  ""                */
  322. extern    int    modebackground();    /*  ""                */
  323. #endif
  324.  
  325. ttykeymapinit()
  326. {
  327.     register SYMBOL    *sp;
  328.     register int    i;
  329.  
  330.     /* Intuition window manipulation     */
  331.  
  332. #ifndef    MEYN
  333.     keydup((KEY)KMETA|KCTRL|'L',    "redraw-display");
  334. #endif
  335.      keyadd((KEY)-1,    togglewindow,    "toggle-window-hack");
  336.  
  337.     /*
  338.      * Bind all positions that correspond
  339.      * to characters in the Amiga alternate
  340.      * character set to "ins-self". These characters may
  341.      * be used just like any other character.  Of course,
  342.      * if DO_METAKEY is defined in kbd.c, the alternate character
  343.      * set will get mapped to META-ed keys...
  344.      */
  345.  
  346.     if ((sp=symlookup("self-insert-command")) == NULL)
  347.         panic("ttykeymapinit: can't find self-insert-command");
  348.     for (i=0xA0; i<0xFF; ++i) {
  349.         if (binding[i] != NULL)
  350.             panic("ttykeymapinit: key already bound");
  351.         binding[i] = sp;
  352.     }
  353.  
  354. #ifdef    DO_MENU
  355.     /* "Menu" key, if compiled in    */
  356.     keyadd((KEY)KMENU,    amigamenu,    "amiga-menu");
  357. #endif
  358.  
  359. #ifdef    CHANGE_FONT
  360.     keyadd((KEY)-1,    setfont,    "set-font");
  361. #endif
  362.  
  363. #ifdef    CHANGE_COLOR
  364.     /* Functions to allow you to change colors    */
  365.     keyadd((KEY)-1, ttmode,        "set-mode-rendition");
  366.     keyadd((KEY)-1,    tttext,        "set-text-rendition");
  367.     keyadd((KEY)-1,    textforeground,    "set-text-foreground");
  368.     keyadd((KEY)-1,    textbackground,    "set-text-background");
  369.     keyadd((KEY)-1, modeforeground, "set-mode-foreground");
  370.     keyadd((KEY)-1,    modebackground,    "set-mode-background");
  371. #endif
  372.  
  373. #ifdef    XKEYS
  374.     /* Arrow keys    */
  375.     keydup((KEY)KUP,    "previous-line");
  376.     keydup((KEY)KDOWN,    "next-line");
  377.  
  378.     keydup((KEY)KSUP,    "backward-paragraph");
  379.     keydup((KEY)KSDOWN,    "forward-paragraph");    
  380.  
  381.     keydup((KEY)KRIGHT,    "forward-char");
  382.     keydup((KEY)KLEFT,    "backward-char");
  383.  
  384.     keydup((KEY)KSRIGHT,    "forward-word");
  385.     keydup((KEY)KSLEFT,    "backward-word");
  386.  
  387.     /* Function keys     */
  388.     keydup((KEY)KHELP,    "describe-key-briefly");
  389.  
  390.     keydup((KEY)KF1,    "find-file");
  391.     keydup((KEY)KSF1,    "find-file-other-window");
  392.  
  393.     keydup((KEY)KF2,    "save-buffer");
  394.     keydup((KEY)KSF2,    "write-file");
  395.  
  396.     keydup((KEY)KF3,    "scroll-up");
  397.     keydup((KEY)KSF3,    "scroll-down");
  398.  
  399.     keydup((KEY)KF4,    "next-window");
  400.     keydup((KEY)KSF4,    "previous-window");
  401.  
  402.     keydup((KEY)KF5,    "enlarge-window");
  403.     keydup((KEY)KSF5,    "shrink-window");
  404.  
  405.     keydup((KEY)KF6,    "fill-paragraph");
  406.     keydup((KEY)KSF6,    "query-replace");
  407.  
  408.     keydup((KEY)KF7,    "split-window-vertically");
  409.     keydup((KEY)KSF7,    "delete-other-windows");
  410.  
  411.     keydup((KEY)KF8,    "global-set-key");
  412.     keydup((KEY)KSF8,    "global-unset-key");
  413.  
  414.     keydup((KEY)KF9,    "start-kbd-macro");
  415.     keydup((KEY)KSF9,    "end-kbd-macro");
  416.  
  417.     keydup((KEY)KF10,    "call-last-kbd-macro");
  418.     keydup((KEY)KSF10,    "save-buffers-kill-emacs");
  419. #endif
  420.  
  421. #ifdef    MOUSE
  422.     /* Mouse clicks in a window do editing functions on the    */
  423.     /* window.                        */
  424.  
  425.     keyadd(WMOUSE,        amigamouse,    "amiga-mouse");
  426.     keyadd(S(WMOUSE),    mreposition,    "mouse-recenter");
  427.     keyadd(A(WMOUSE),    mdelfword,    "mouse-kill-word");
  428.     keyadd(AS(WMOUSE),    mkillline,    "mouse-kill-line");
  429.     keyadd(C(WMOUSE),    mforwdel,    "mouse-delete-char");
  430.     keyadd(CS(WMOUSE),    mdelwhite,    "mouse-just-one-space");
  431.     keyadd(CA(WMOUSE),    mkillregion,    "mouse-kill-region");
  432.     keyadd(CAS(WMOUSE),    myank,        "mouse-yank");
  433.  
  434.     /* Mouse clicks in the status line select that window and    */
  435.     /* then perform a command on that window or buffer.        */
  436.     /* Use keyadd() because they haven't been bound before        */
  437.  
  438.     keyadd(SMOUSE,       mforwpage,    "mouse-scroll-up");
  439.     keyadd(S(SMOUSE),  mbackpage,    "mouse-scroll-down");
  440.     keyadd(A(SMOUSE),  msplitwind,    "mouse-split-window-vertically");
  441.     keyadd(AS(SMOUSE), mdelwind,    "mouse-delete-window");
  442.     keyadd(C(SMOUSE),  mgotobob,    "mouse-beginning-of-buffer");
  443.     keyadd(CS(SMOUSE), mgotoeob,    "mouse-end-of-buffer");
  444.     keyadd(CA(SMOUSE), menlargewind,"mouse-enlarge-window");
  445.     keyadd(CAS(SMOUSE),mshrinkwind,    "mouse-shrink-window");
  446.  
  447.     /* mouse clicks in echo line do global things        */
  448.  
  449. #ifdef    MEYN
  450.     keydup(EMOUSE,        "save-buffer");
  451. #else
  452.     keydup(EMOUSE,        "switch-to-buffer");
  453. #endif
  454.     keydup(S(EMOUSE),    "kill-buffer");
  455.     keydup(A(EMOUSE),    "describe-key-briefly");
  456.     keydup(AS(EMOUSE),    "describe-bindings");
  457.     keydup(C(EMOUSE),    "suspend-emacs");
  458.     keydup(CS(EMOUSE),    "save-buffers-kill-emacs");
  459.     keydup(CA(EMOUSE),    "list-buffers");
  460.     keydup(CAS(EMOUSE),    "toggle-window-hack");
  461. #endif
  462. }
  463. SHAR_EOF
  464. fi # end of overwriting check
  465. if test -f 'tty/amiga/ttymouse.c'
  466. then
  467.     echo shar: will not over-write existing file "'tty/amiga/ttymouse.c'"
  468. else
  469. cat << \SHAR_EOF > 'tty/amiga/ttymouse.c'
  470. /*
  471.  * Name:    MicroEmacs
  472.  *        Commodore Amiga mouse handling (no longer simple!)
  473.  * Version:    Gnu v30
  474.  * Last edit:    02-Aug-86  ...!ihnp4!seismo!ut-sally!ut-ngp!mic
  475.  */
  476.  
  477. #include <exec/types.h>
  478. #include <intuition/intuition.h>
  479. #undef    TRUE
  480. #undef    FALSE
  481. #include "def.h"
  482.  
  483. extern    int    ttmouse();        /* Defined by "ttyio.c"        */
  484. extern    int    forwline();        /* Defined by "line.c"        */
  485. extern    int    forwchar();        /* Defined by "basic.c"        */
  486. extern    int    setmark();        /* Defined by "random.c"    */
  487.  
  488. /* stuff for go-to-window-and-do-it functions */
  489. extern    int    reposition();
  490. extern    int    delfword();
  491. extern    int    killline();
  492. extern    int    forwdel();
  493. extern    int    delwhite();
  494. extern    int    killregion();
  495. extern    int    yank();
  496. extern    int    forwpage();
  497. extern    int    backpage();
  498. extern    int    splitwind();
  499. extern    int    delwind();
  500. extern    int    gotobob();
  501. extern    int    gotoeob();
  502. extern    int    enlargewind();
  503. extern    int    shrinkwind();
  504.  
  505. /*
  506.  * Handle the mouse click that's been passed
  507.  * by ttgetc() and position dot where the
  508.  * user pointed at.  If this is the same position
  509.  * where the user pointed the last time, set the mark,
  510.  * whether or not this is a true double-click.
  511.  * This isn't a true double-click, but it does
  512.  * most of what we want.
  513.  */
  514.  
  515. static USHORT    oldrow = HUGE, oldcol = HUGE;    /* last mouse click    */
  516. static USHORT    newrow, newcol;            /* next mouse click    */
  517.  
  518. amigamouse(f, n, k)
  519. {
  520.     if (!dottomouse())            /* sets newrow, newcol    */
  521.         return (FALSE);
  522.     if ((newrow == oldrow) && (newcol == oldcol))
  523.         setmark(FALSE, 0, KRANDOM);    /* double-click        */
  524.     oldrow = newrow;                /* save state        */
  525.     oldcol = newcol;
  526.     return (TRUE);
  527. }
  528.  
  529. /*
  530.  * Recenter on selected line
  531.  */
  532. mreposition(f, n, k)
  533. {
  534.     if (!dottomouse())
  535.         return (FALSE);
  536.     return (reposition(f, n, k));
  537. }
  538.  
  539. /*
  540.  * Delete word after selected char
  541.  */
  542. mdelfword(f, n, k)
  543. {
  544.     if (!dottomouse())
  545.         return (FALSE);
  546.     return (delfword(f, n, k));
  547. }
  548.  
  549. /*
  550.  * Move to selection, kill line
  551.  */
  552. mkillline(f, n, k)
  553. {
  554.     if (!dottomouse())
  555.         return (FALSE);
  556.     return (killline(f, n, k));
  557. }
  558.  
  559. /*
  560.  * Move to selection, kill line
  561.  */
  562. mforwdel(f, n, k)
  563. {
  564.     if (!dottomouse())
  565.         return (FALSE);
  566.     return (forwdel(f, n, k));
  567. }
  568.  
  569. /*
  570.  * Move to selection, kill line
  571.  */
  572. mdelwhite(f, n, k)
  573. {
  574.     if (!dottomouse())
  575.         return (FALSE);
  576.     return (delwhite(f, n, k));
  577. }
  578.  
  579. /*
  580.  * Move to selection, kill region.
  581.  * This makes it easy to mark a
  582.  * region with a double-click, then
  583.  * hold down some shift keys to
  584.  * delete the region.
  585.  */
  586. mkillregion(f, n, k)
  587. {
  588.     if (!dottomouse())
  589.         return (FALSE);
  590.     return (killregion(f, n, k));
  591. }
  592.  
  593. /*
  594.  * Move to selection, yank kill buffer
  595.  */
  596. myank(f, n, k)
  597. {
  598.     if (!dottomouse())
  599.         return (FALSE);
  600.     return (yank(f, n, k));
  601. }
  602.  
  603. /*
  604.  * Select window pointed to by mouse, then scroll down
  605.  */
  606.  
  607. mforwpage(f, n, k)
  608. {
  609.     if (!dottomouse())
  610.         return (FALSE);
  611.     return (forwpage(f, n, k));
  612. }
  613.  
  614. /*
  615.  * Select buffer, scroll page down
  616.  */
  617. mbackpage(f, n, k)
  618. {
  619.     if (!dottomouse())
  620.         return (FALSE);
  621.     return (backpage(f, n, k));
  622. }
  623.  
  624. /*
  625.  * Select the window, split it.
  626.  */
  627. msplitwind(f, n, k)
  628. {
  629.     if (!dottomouse())
  630.         return (FALSE);
  631.     return (splitwind(f, n, k));
  632. }
  633.  
  634. /*
  635.  * Select the buffer, delete it.
  636.  */
  637. mdelwind(f, n, k)
  638. {
  639.     if (!dottomouse())
  640.         return (FALSE);
  641.     return (delwind(f, n, k));
  642. }
  643.  
  644. /*
  645.  * Select window, goto beginning of buffer
  646.  */
  647. mgotobob(f, n, k)
  648. {
  649.     if (!dottomouse())
  650.         return (FALSE);
  651.     return (gotobob(f, n, k));
  652. }
  653.  
  654. /*
  655.  * Select window, go to end of buffer
  656.  */
  657. mgotoeob(f, n, k)
  658. {
  659.     if (!dottomouse())
  660.         return (FALSE);
  661.     return (gotoeob(f, n, k));
  662. }
  663.  
  664. /*
  665.  * Select window, enlarge it.
  666.  */
  667. menlargewind(f, n, k)
  668. {
  669.     if (!dottomouse())
  670.         return (FALSE);
  671.     return (enlargewind(f, n, k));
  672. }
  673.     
  674. /*
  675.  * Select window, shrink it.
  676.  */
  677. mshrinkwind(f, n, k)
  678. {
  679.     if (!dottomouse())
  680.         return (FALSE);
  681.     return (shrinkwind(f, n, k));
  682. }
  683.  
  684. /*
  685.  * Utility routine to move dot to where
  686.  * the user clicked.  If in mode line,
  687.  * chooses that buffer as the one
  688.  * to work on.
  689.  */
  690.  
  691. static dottomouse()
  692. {
  693.     register WINDOW *wp;
  694.     register int    dot;
  695.     register int    c;
  696.     register int    col;
  697.     int        qualifier;
  698.  
  699.     /* figure out new screen position of dot, throw away mouse evt */
  700.     if (!ttmouse(TRUE, &newrow, &newcol, &qualifier))
  701.         return (FALSE);            /* out of synch!    */
  702.  
  703.     /* find out which window was clicked in                */
  704.     for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
  705.         if ((newrow >= wp->w_toprow) && 
  706.             (newrow <= (wp->w_toprow + wp->w_ntrows)))
  707.             break;
  708.  
  709.     if (wp == NULL)                /* echo line        */
  710.         return (ABORT);
  711.     else if (newrow == wp->w_toprow + wp->w_ntrows) {/* mode line */
  712.         curwp = wp;            /* just change buffer     */
  713.         curbp = wp->w_bufp;
  714.     } else {
  715.         /* move to selected window, move dot to top left    */
  716.         curwp = wp;
  717.         curbp = wp->w_bufp;
  718.         curwp->w_dotp = wp->w_linep;
  719.         curwp->w_doto = 0;
  720.  
  721.         /* go forward the correct # of lines         */
  722.         forwline(FALSE, newrow - curwp->w_toprow, KRANDOM);
  723.     
  724.         /* go forward the correct # of characters    */
  725.         /* need to count them out because of tabs    */
  726.         col = dot = 0;
  727.         while ((col < newcol) && (dot < llength(curwp->w_dotp))) {
  728.             c = lgetc(curwp->w_dotp, dot++);
  729.             if (c == '\t')
  730.                 col |= 0x07;
  731.             else if (ISCTRL(c) != FALSE)
  732.                 ++col;
  733.             ++col;
  734.         }
  735. #ifdef        MEYN
  736.         if (col > newcol) dot--;    /* back up to tab/ctrl char */
  737. #endif
  738.         forwchar(FALSE, dot, KRANDOM);
  739.     }
  740.     return (TRUE);
  741. }
  742. SHAR_EOF
  743. fi # end of overwriting check
  744. if test -f 'sys/amiga/Makefile.LATTICE'
  745. then
  746.     echo shar: will not over-write existing file "'sys/amiga/Makefile.LATTICE'"
  747. else
  748. cat << \SHAR_EOF > 'sys/amiga/Makefile.LATTICE'
  749. #
  750. # Makefile for Amiga MicroGNUmacs, using lattice and PD make.
  751. #
  752. #    This Makefile should be executed in the main Emacs directory.
  753. #
  754. # Conditional compilation possibilities:
  755. #
  756. #    V11        -- must be defined for the editor to either run on
  757. #               or compile on a version 1.1 amigados system
  758. #
  759. #    STARTUP        -- if defined, code for using a startup file
  760. #               is included.  This is handy for folks who
  761. #               won't be able to hack the editor to their
  762. #               taste.
  763. #
  764. #    MENU        -- if defined, Intuition menu selection is
  765. #               enabled.  This uses a good bit of space,
  766. #               both on disk and in memory.  If you #define
  767. #               this, the XOBJ macro must contain $(MENUOBJ).
  768. #
  769. #    BROWSER        -- BROWSER uses the Amiga menu to
  770. #               present a MENU of files. Selecting a directory
  771. #               entry (ends with a /) makes the contents if that
  772. #               directory the next menu (deleting any menus that
  773. #               used to follow it); selecting a plain file does a
  774. #               "find-file" on that file name. Really has to be
  775. #               seen to be understood. XOBJ must contain
  776. #               $(MENUOBJ) for this to work.
  777. #
  778. #    MOUSE        -- if defined, the Amiga mouse is active.
  779. #               If you #define this, XOBJ must contain $(MOUSEOBJ)
  780. #
  781. #    XKEYS        -- if defined, the editor understands the Amiga
  782. #               function keys.
  783. #
  784. #    DO_METAKEY    -- if defined, characters with high bit set (i.e.
  785. #               most ALT-ed characters in the usa0 keymap)
  786. #               are translated into internal META keys
  787. #
  788. #    CHANGE_COLOR    -- if defined, adds commands to manipulate
  789. #               the rendition of the mode line and the
  790. #               foreground and background color of the
  791. #               text window and mode line.  The names match
  792. #               the regular expression
  793. #               set-{text,mode}-{foreground,background}
  794. #
  795. #    MODE_RENDITION    -- the these values indicate the way to render
  796. #    TEXT_RENDITION       characters in the text area and mode line.
  797. #               TEXT_RENDITION is mainly there for completeness.
  798. #               Possible values are:
  799. #                0 -- plain text
  800. #                1 -- boldface
  801. #                3 -- italic
  802. #                4 -- underscore
  803. #                7 -- reverse-video (default if not defined)
  804. #
  805. #    TEXT_FG        -- specifies which system color (0-7) to use
  806. #    TEXT_BG           when drawing the text and mode line.  If they
  807. #    MODE_FG           aren't between 0 and 7, or if a combination
  808. #    MODE_BG           comes out badly, it's *YOUR* fault.  If
  809. #               CHANGE_COLOR is defined, you get to change these
  810. #               values on the fly.  Naturally, making both
  811. #               FG and BG the same results in an unusable display...
  812. #
  813. #    TOGGLE_ZOOMS    -- the function toggle-menu-hack switches between
  814. #               a bordered, sizeable window and a borderless
  815. #               window.  By default, the borderless window
  816. #               retains the size of the sizeable window.
  817. #               If TOGGLE_ZOOMS is #defined, however, the
  818. #               borderless window always takes up the whole
  819. #               screen.
  820. #
  821. ############################################################################
  822. CC =        cc
  823. #DEBUGFLAG =    -g
  824. TTYDIR =    tty/amiga
  825. SYSDIR =    sys/amiga
  826. MENUOBJ =    ttymenu.o menustack.o
  827. MOUSEOBJ =    ttymouse.o
  828.  
  829. INCS = def.h $(TTYDIR)/ttydef.h $(SYSDIR)/sysdef.h
  830.  
  831. # The whole enchilada (~60K with Manx small model)
  832. PREFS = -DSTARTUP -DBROWSER -DMENU -DMOUSE -DCHANGE_COLOR -DXKEYS -DDO_METAKEY 
  833. XOBJ  = $(MENUOBJ) $(MOUSEOBJ)
  834.  
  835. # Burrito style, with just the Browser...
  836. #PREFS = -DSTARTUP  -DBROWSER -DMOUSE -DCHANGE_COLOR -DXKEYS -DDO_METAKEY
  837. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ)
  838.  
  839. # Burrito style, with just the menu...
  840. #PREFS = -DSTARTUP  -DMENU -DMOUSE -DCHANGE_COLOR -DXKEYS -DDO_METAKEY
  841. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ)
  842.  
  843. # Mike's favorite version
  844. #PREFS = -DMOUSE -DBROWSER -DMODE_RENDITION=0 -DMODE_FG=2 -DTOGGLE_ZOOMS -DDO_METAKEY -DGOSREC -DMEYN
  845. #XOBJ = $(MOUSEOBJ) $(MENUOBJ)
  846.  
  847. # Absolutely bare-bones editor (~49K with Manx small model)
  848. #PREFS = -DDO_METAKEY
  849. #XOBJ  =
  850.  
  851. CFLAGS =    -O -I$(TTYDIR) -I$(SYSDIR) $(DEBUGFLAG) $(PREFS)
  852.  
  853. EXEFILE =    mg
  854. COM1    = basic.o buffer.o cinfo.o display.o echo.o extend.o file.o kbd.o
  855. COM2    = line.o main.o match.o random.o region.o search.o symbol.o version.o
  856. COM3    = window.o paragraph.o prefix.o word.o
  857. TTYOBJ    = console.o tty.o ttyio.o ttykbd.o
  858. SYSOBJ    = fileio.o sleep.o spawn.o
  859. OBJ    = comlib1.o comlib2.o comlib3.o ttylib.o syslib.o $(XOBJ)
  860.  
  861. $(EXEFILE) :    $(OBJ)
  862.         $(CC) -o $(EXEFILE) $(OBJ)
  863.  
  864. comlib1.o :    $(COM1)
  865.         join $(COM1) as comlib1.o
  866.  
  867. comlib2.o :    $(COM2)
  868.         join $(COM2) as comlib2.o
  869.  
  870. comlib3.o :    $(COM3)
  871.         join $(COM3) as comlib3.o
  872.  
  873. ttylib.o :    $(TTYOBJ)
  874.         join $(TTYOBJ) as ttylib.o
  875.  
  876. syslib.o :    $(SYSOBJ)
  877.         join $(SYSOBJ) as syslib.o
  878.  
  879. basic.o :    basic.c $(INCS)
  880.         $(CC) -c $(CFLAGS) basic.c
  881.  
  882. buffer.o :    buffer.c $(INCS)
  883.         $(CC) -c $(CFLAGS) buffer.c
  884.  
  885. cinfo.o :    cinfo.c $(INCS)
  886.         $(CC) -c $(CFLAGS) cinfo.c
  887.  
  888. display.o :    display.c $(INCS)
  889.         $(CC) -c $(CFLAGS) display.c
  890.  
  891. echo.o :    echo.c $(INCS)
  892.         $(CC) -c $(CFLAGS) echo.c
  893.  
  894. extend.o :    extend.c $(INCS)
  895.         $(CC) -c $(CFLAGS) extend.c
  896.  
  897. file.o :    file.c $(INCS)
  898.         $(CC) -c $(CFLAGS) file.c
  899.  
  900. kbd.o :        kbd.c $(INCS)
  901.         $(CC) -c $(CFLAGS) kbd.c
  902.  
  903. line.o :    line.c $(INCS)
  904.         $(CC) -c $(CFLAGS) line.c
  905.  
  906. match.o :    match.c $(INCS)
  907.         $(CC) -c $(CFLAGS) match.c
  908.  
  909. prefix.o :    prefix.c $(INCS)
  910.         $(CC) -c $(CFLAGS) prefix.c
  911.  
  912. paragraph.o :    paragraph.c $(INCS)
  913.         $(CC) -c $(CFLAGS) paragraph.c
  914.  
  915. main.o :    main.c $(INCS)
  916.         $(CC) -c $(CFLAGS) main.c
  917.  
  918. random.o :    random.c $(INCS)
  919.         $(CC) -c $(CFLAGS) random.c
  920.  
  921. region.o :    region.c $(INCS)
  922.         $(CC) -c $(CFLAGS) region.c
  923.  
  924. search.o :    search.c $(INCS)
  925.         $(CC) -c $(CFLAGS) search.c
  926.  
  927. symbol.o :    symbol.c $(INCS)
  928.         $(CC) -c $(CFLAGS) symbol.c
  929.  
  930. version.o :    version.c $(INCS)
  931.         $(CC) -c $(CFLAGS) version.c
  932.  
  933. window.o :    window.c $(INCS)
  934.         $(CC) -c $(CFLAGS) window.c
  935.  
  936. word.o :    word.c $(INCS)
  937.         $(CC) -c $(CFLAGS) word.c
  938.  
  939. console.o :    $(TTYDIR)/console.c $(INCS)
  940.         $(CC) -c $(CFLAGS) $(TTYDIR)/console.c
  941.  
  942. menustack.o :    $(TTYDIR)/menustack.c $(INCS)
  943.         $(CC) -c $(CFLAGS) $(TTYDIR)/menustack.c
  944.  
  945. tty.o :        $(TTYDIR)/tty.c $(INCS)
  946.         $(CC) -c $(CFLAGS) $(TTYDIR)/tty.c
  947.  
  948. ttyio.o :    $(TTYDIR)/ttyio.c $(INCS)
  949.         $(CC) -c $(CFLAGS) $(TTYDIR)/ttyio.c
  950.  
  951. ttykbd.o :    $(TTYDIR)/ttykbd.c $(INCS)
  952.         $(CC) -c $(CFLAGS) $(TTYDIR)/ttykbd.c
  953.  
  954.  
  955. ttymouse.o :    $(TTYDIR)/ttymouse.c $(INCS)
  956.         $(CC) -c $(CFLAGS) $(TTYDIR)/ttymouse.c
  957.  
  958. ttymenu.o :    $(TTYDIR)/ttymenu.c $(INCS)
  959.         $(CC) -c $(CFLAGS) $(TTYDIR)/ttymenu.c
  960. abort.o :    $(SYSDIR)/abort.c $(INCS)
  961.         $(CC) -c $(CFLAGS) $(SYSDIR)/abort.c
  962.  
  963. fileio.o :    $(SYSDIR)/fileio.c $(INCS)
  964.         $(CC) -c $(CFLAGS) $(SYSDIR)/fileio.c
  965.  
  966. sleep.o :    $(SYSDIR)/sleep.c $(INCS)
  967.         $(CC) -c $(CFLAGS) $(SYSDIR)/sleep.c
  968.  
  969. spawn.o :    $(SYSDIR)/spawn.c $(INCS)
  970.         $(CC) -c $(CFLAGS) $(SYSDIR)/spawn.c
  971. SHAR_EOF
  972. fi # end of overwriting check
  973. if test -f 'sys/amiga/Makefile.MANX'
  974. then
  975.     echo shar: will not over-write existing file "'sys/amiga/Makefile.MANX'"
  976. else
  977. cat << \SHAR_EOF > 'sys/amiga/Makefile.MANX'
  978. #
  979. # Makefile for Amiga MicroGNUmacs, using Manx small model.
  980. #
  981. #    This Makefile should be executed in the main Emacs directory.
  982. #
  983. # System-dependent conditional compilation possibilities:
  984. #
  985. #    V11        -- must be defined for the editor to either run on
  986. #               or compile on a version 1.1 AmigaDOS system.
  987. #               It mainly wards against bugs in the 1.1 ROM
  988. #               Kernel.
  989. #
  990. #    STARTUP        -- if defined, code for using a startup file
  991. #               is included.  This is handy for folks who
  992. #               won't be able to hack the editor to their
  993. #               taste.
  994. #
  995. #    MENU        -- if defined, Intuition menu selection is
  996. #               enabled.  If you #define this, the XOBJ macro
  997. #               must contain $(MENUOBJ).
  998. #
  999. #    BROWSER        -- BROWSER uses the Amiga menu to present a MENU of
  1000. #               files. Selecting a directory entry (ends with a /)
  1001. #               makes the contents if that directory the next menu
  1002. #               (deleting any menus that used to follow it);
  1003. #               selecting a plain file does a "find-file" on that
  1004. #               file name. Really has to be seen to be understood.
  1005. #               XOBJ must contain $(MENUOBJ) for this to link.
  1006. #
  1007. #    MOUSE        -- if defined, the Amiga mouse is active.
  1008. #               If you #define this, XOBJ must contain $(MOUSEOBJ)
  1009. #
  1010. #    TOGGLE_ZOOMS    -- the function toggle-menu-hack switches between
  1011. #               a bordered, sizeable window and a borderless
  1012. #               window.  By default, the borderless window
  1013. #               retains the size of the sizeable window.
  1014. #               If TOGGLE_ZOOMS is #defined, however, the
  1015. #               borderless window always takes up the whole
  1016. #               screen.
  1017. #
  1018. #    XKEYS        -- if defined, the editor understands the Amiga
  1019. #               function keys.
  1020. #
  1021. #    DO_METAKEY    -- if defined, characters with high bit set (i.e.
  1022. #               most ALT-ed characters in the usa0 keymap)
  1023. #               are translated into internal META keys
  1024. #
  1025. #    CHANGE_COLOR    -- if defined, adds commands to manipulate
  1026. #               the rendition of the mode line and the
  1027. #               foreground and background color of the
  1028. #               text window and mode line.  The names match
  1029. #               the regular expression
  1030. #               set-{text,mode}-{foreground,background}
  1031. #    CHANGE_FONT    -- if defined, adds "set-font", which prompts
  1032. #               for a font name and size, then tries to reopen
  1033. #               the Emacs window using the new font.
  1034. #
  1035. #
  1036. #    MODE_RENDITION    -- the these values indicate the way to render
  1037. #    TEXT_RENDITION       characters in the text area and mode line.
  1038. #               TEXT_RENDITION is mainly there for completeness.
  1039. #               Possible values are:
  1040. #                0 -- plain text
  1041. #                1 -- boldface
  1042. #                3 -- italic
  1043. #                4 -- underscore
  1044. #                7 -- reverse-video (default if not defined)
  1045. #
  1046. #    TEXT_FG        -- specifies which system color (0-7) to use
  1047. #    TEXT_BG           when drawing the text and mode line.  If they
  1048. #    MODE_FG           aren't between 0 and 7, or if a combination
  1049. #    MODE_BG           comes out badly, it's *YOUR* fault.  If
  1050. #               CHANGE_COLOR is defined, you get to change these
  1051. #               values on the fly.  Naturally, making both
  1052. #               FG and BG the same results in an unusable display...
  1053. #
  1054. ############################################################################
  1055. SYS    = amiga
  1056. S    = sys/amiga
  1057. TTY    = amiga
  1058. T    = tty/amiga
  1059. LIBS    = -lc
  1060.  
  1061. #
  1062. # PREFS contains the defines used to select compile-time options.
  1063. # XOBJ is used to denote any extra object files needed for these
  1064. # options.  MENUOBJ MOUSEOBJ denote the extra object files needed
  1065. # for the menu, mouse and Browser.
  1066.  
  1067. MOUSEOBJ = ttymouse.o
  1068. MENUOBJ  = ttymenu.o menustack.o
  1069.  
  1070. # The big burrito, with the Browser *and* the editing MENU.  Tough
  1071. # on space, but boy is it neat...
  1072. PREFS = -DSTARTUP  -DBROWSER -DMENU -DMOUSE -DCHANGE_FONT \
  1073.     -DCHANGE_COLOR -DXKEYS -DDO_METAKEY
  1074. XOBJ  = $(MOUSEOBJ) $(MENUOBJ)
  1075.  
  1076. # Burrito style, with just the Browser...
  1077. #PREFS = -DSTARTUP  -DBROWSER -DMOUSE -DCHANGE_COLOR -DXKEYS -DDO_METAKEY
  1078. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ)
  1079.  
  1080. # Burrito style, with just the menu...
  1081. #PREFS = -DSTARTUP  -DMENU -DMOUSE -DCHANGE_COLOR -DXKEYS -DDO_METAKEY
  1082. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ)
  1083.  
  1084. # Mike's favorite version
  1085. #PREFS = -DMOUSE -DBROWSER -DMODE_RENDITION=0 -DMODE_FG=2 -DDO_METAKEY -DGOSREC -DV11 -DMEYN
  1086. #XOBJ = $(MOUSEOBJ) $(MENUOBJ)
  1087.  
  1088. # Mic's favorite version
  1089. #PREFS = -DSTARTUP -DBROWSER -DMENU -DMOUSE -DXKEYS -DDO_METAKEY
  1090. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ)
  1091.  
  1092. # Absolutely bare-bones, default editor (~49K with Manx small model)
  1093. #PREFS = -DDO_METAKEY
  1094. #XOBJ  =
  1095.     
  1096. CFLAGS    = -I$(T) -I$(S) $(PREFS) -DMANX
  1097.  
  1098. OBJ   =    basic.o buffer.o cinfo.o display.o echo.o extend.o file.o kbd.o \
  1099.     line.o main.o match.o random.o region.o search.o symbol.o version.o \
  1100.     window.o paragraph.o prefix.o word.o \
  1101.     fileio.o spawn.o sleep.o\
  1102.     ttyio.o tty.o ttykbd.o console.o $(XOBJ)
  1103. #
  1104. # OSRCS = system-dependent modules, SRCS = denotes system-independent ones
  1105. #
  1106. OSRCS = $(S)/fileio.c $(S)/spawn.c $(S)/sleep.c \
  1107.     $(T)/ttyio.c $(T)/tty.c $(T)/ttykbd.c $(T)/console.c \
  1108.     $(T)/ttymenu.c $(T)/menustack.c $(T)/ttymouse.c
  1109.  
  1110. SRCS  =    basic.c buffer.c cinfo.c display.c echo.c extend.c file.c kbd.c \
  1111.     line.c main.c match.c random.c region.c search.c symbol.c version.c \
  1112.     window.c word.c paragraph.c prefix.c
  1113. #
  1114. # Include files
  1115. #
  1116. OINCS =    $(T)/ttydef.h $(S)/sysdef.h
  1117. INCS  =    def.h
  1118.  
  1119. #
  1120. # The editor
  1121. #
  1122. mg:        $(OBJ)
  1123.         copy df0:lib/c.lib ram:
  1124.         set CLIB=ram:
  1125.         ln -o mg $(OBJ) $(LIBS)
  1126.         delete ram:c.lib
  1127.  
  1128. $(OBJ):        $(INCS) $(OINCS)
  1129.  
  1130. fileio.o:    $(S)/fileio.c
  1131.         cc $(CFLAGS) -o fileio.o $(S)/fileio.c
  1132.  
  1133. spawn.o:    $(S)/spawn.c
  1134.         cc $(CFLAGS) -o spawn.o $(S)/spawn.c
  1135.  
  1136. sleep.o:    $(S)/sleep.c
  1137.         cc $(CFLAGS) -o sleep.o $(S)/sleep.c
  1138.  
  1139. tty.o:        $(T)/tty.c
  1140.         cc $(CFLAGS) -o tty.o $(T)/tty.c
  1141.  
  1142. ttyio.o:    $(T)/ttyio.c
  1143.         cc $(CFLAGS) -o ttyio.o $(T)/ttyio.c
  1144.  
  1145. ttykbd.o:    $(T)/ttykbd.c
  1146.         cc $(CFLAGS) -o ttykbd.o $(T)/ttykbd.c
  1147.  
  1148. ttymenu.o:    $(T)/ttymenu.c
  1149.         cc $(CFLAGS) -o ttymenu.o $(T)/ttymenu.c
  1150.  
  1151. ttymouse.o:    $(T)/ttymouse.c
  1152.         cc $(CFLAGS) -o ttymouse.o $(T)/ttymouse.c
  1153.  
  1154. menustack.o:    $(T)/menustack.c
  1155.         cc $(CFLAGS) -o menustack.o $(T)/menustack.c
  1156.  
  1157. console.o:    $(T)/console.c
  1158.         cc $(CFLAGS) -o console.o $(T)/console.c
  1159. SHAR_EOF
  1160. fi # end of overwriting check
  1161. if test -f 'sys/amiga/amiga.doc'
  1162. then
  1163.     echo shar: will not over-write existing file "'sys/amiga/amiga.doc'"
  1164. else
  1165. cat << \SHAR_EOF > 'sys/amiga/amiga.doc'
  1166.  
  1167.                         Amiga MicroGNUmacs Notes
  1168.                         ------------------------
  1169.  
  1170.    This file purports to document the Amiga-specific features of
  1171. MicroGNUmacs. Except where otherwise noted, "MicroEmacs", "Emacs", "MG",
  1172. "MicroGNU", and "MicroGNUmacs" all refer to the Amiga version of the
  1173. GNU-compatible MicroEmacs text editor. MicroEmacs was created by Dave
  1174. Conroy. This version has been GNUified by Mike Meyer, and the
  1175. Intuition terminal driver enhanced and (hopefully) improved by Mic
  1176. Kaczmarczik.
  1177.  
  1178.    It is assumed that you already know about the point and the mark,
  1179. buffers, windows, extended commands, and the various areas on the
  1180. screen that all versions of MicroEmacs maintain. If you don't, see the
  1181. MicroEmacs documentation (what there is of it) for more information.
  1182.  
  1183.                               OPTIONS
  1184.                               -------
  1185.  
  1186.    (This section is for people who have their own C compiler. If you
  1187. don't have a C compiler, you will hopefully have a version that has
  1188. *everything* compiled into it...)
  1189.  
  1190.    There are a bewildering variety of extra goodies available as
  1191. compile-time options when you construct an Amiga MicroEmacs. If you
  1192. select none of them, you save on disk space, but lose out on some
  1193. features and versatility.
  1194.  
  1195.    The Makefile provides documentation on these options and what to do
  1196. to make them work, but here is a quick overview:
  1197.  
  1198.    STARTUP -- You can configure MicroEmacs so that it will look for a
  1199. startup file in either the current directory or the AmigaDOS s:
  1200. (startup) directory. An example startup file is included in the
  1201. distribution, and also see the STARTUP section below.
  1202.  
  1203.    MENU -- If this option is used, MicroEmacs puts an Intuition menu
  1204. bar with major editing commands at the top of the screen, just like a
  1205. "real" Amiga program. (See the section on the MENU for more info).
  1206.  
  1207.    BROWSER -- This has got to be seen to be appreciated. The Browser
  1208. program turns the menu bar into a way to select files on a disk. First
  1209. you select a disk, then a directory on the disk, then a file or
  1210. subdirectory on the disk, and so on, all in the menu.
  1211.  
  1212.    MOUSE -- This option turns on the Amiga Hot Mouse (and it's all due
  1213. to Mike Meyer!). You can click on a character and move point to that
  1214. spot, and that's just the beginning. (See the MOUSE section for more.)
  1215.  
  1216.    XKEYS -- This option turns on support for all the extra Amiga
  1217. function keys. This enables the HELP key, which runs the function
  1218. "describe-key-briefly". Arrow keys work -- shift-arrow keys apply to
  1219. words and paragraphs. (See the KEYBOARD section.)
  1220.  
  1221.    DO_METAKEY -- Characters with the high bit set (i.e. codes > 0x80)
  1222. are transformed into 'META' characters. If you're using 1.2, you will
  1223. need to issue the command setmap usa0 to get the same console keymap
  1224. as the one used by 1.1. If you don't have the usa0 keymap, this option
  1225. may or may not be too helpful. If you *do* have DO_METAKEY set, you
  1226. can still use the CTRL-Q command to insert ALT-ed characters.
  1227.  
  1228.    CHANGE_FONT -- This allows you to set the font used by the Amiga
  1229. console device driver when it draws characters in the Emacs window.
  1230. For instance, this lets you use a slightly taller font for editing
  1231. when using interlace mode under 1.2.  MG cannot handle proportionally
  1232. spaced fonts, but will allow you to use them (with rather confusing
  1233. results) if you really want to.
  1234.  
  1235.    MODE_RENDITION, {TEXT,MODE}_{FG,BG} -- These are #defines that
  1236. determine the default rendition of the mode line and the foreground
  1237. and background colors of the text. See the COLOR section for more
  1238. info.
  1239.  
  1240.    CHANGE_COLOR -- If you want to be able to mess around with the
  1241. foreground and background colors of the text window, this option
  1242. allows you to do that. You can also specify the way the status line is
  1243. rendered (plain, boldface, italics, or reverse video).
  1244.  
  1245.                               THE MOUSE
  1246.                               ---------
  1247.  
  1248. (This section originated from Mike Meyer, the inventor of the Hot
  1249. Mouse. It has been edited to be consistent with the current state of
  1250. the Hot Mouse.)
  1251.  
  1252.    The Amiga Mouse in hot mode can invoke no less than 24 different
  1253. functions!!!  They are treated as keys by the rest of MicroEmacs, even
  1254. though you click the mouse and hold down qualifier keys to get them.
  1255.  
  1256.    Mouse keys come in three groups of eight, the groups being Mouse
  1257. keys, Mode-Mouse keys, and Echo-Mouse keys. Inside each group, which
  1258. of the eight keys you get is determined by the combination of Shift,
  1259. CTRL and ALT keys you are holding down when the mouse button is
  1260. pressed. So yes, there really is a C-M-Shift-Mode-Mouse button*.
  1261. Note that the Meta (M-) prefix *MUST* be the ALT key. Prefixing it
  1262. with ESC will *not* work.  Sorry, life's a beach.
  1263.  
  1264. [* Technical note *]
  1265.  
  1266.    Sadly, in order to keep the basic MicroEmacs editor code the same
  1267. for all systems (it runs on everything from DEC-20's to CP/M
  1268. machines), the Mouse keys do not have names like C-M-Shift-Mode-Mouse.
  1269. They end up having names like ESC C-a when you use the
  1270. describe-key-briefly command. This may be changed in a later version.
  1271.  
  1272. [* Practical note *]
  1273.    Because of the above restriction (I'm working on it, I'm working on
  1274. it!) you sometimes get burned when you absent-mindedly click the mouse
  1275. during a dialogue (e.g. I-search or switch-buffer). I have not found a
  1276. good way to avoid this problem and preserve the main editor, so I'm
  1277. leaving this unresolved until the next round of improvements.
  1278.  
  1279.    Mouse keys are generally bound to functions that affect the text in
  1280. the selected buffer. If the Intuition mouse pointer is located inside
  1281. an Emacs text window (i.e. an area where text is being edited), then a
  1282. Mouse key is sent to the editor when you click the mouse. The buffer
  1283. associated wth the window the pointer is in is made current, the point
  1284. is set as close as possible to the pointer (the character under the
  1285. pointer, if possible), then the command bound to that mouse button is
  1286. executed.
  1287.  
  1288.    If the mouse pointer is in the mode line - the line that is in a
  1289. different typeface (usually backlit, maybe black instead of white) --
  1290. when the mouse button is clicked, a Mode-Mouse key is sent to the
  1291. editor. The buffer that the selected status line is associated with is
  1292. made the current buffer, the point is set to the value of point for
  1293. that window, then whatever command is bound to that button is
  1294. executed. Most of the Mode-Mouse keys invoke functions that act on the
  1295. entire window or buffer.
  1296.  
  1297.    Clicking the mouse button when the mouse pointer is in the echo
  1298. line - the line at the bottom of the screen where prompts and message
  1299. appear - results in an Echo-Mouse key. Whatever command is bound to
  1300. that button will be executed.  Since the echo line is not part of
  1301. a buffer or a window, all the functions bound to Echo-Mouse keys
  1302. affect the state of the editor as a whole.
  1303.    
  1304.    The default bindings for the hot mouse (as distributed) are:
  1305.  
  1306.  Qualifiers  |            Area clicked
  1307.              |
  1308. C  A  Shift  |    Text window        Mode line    Echo line
  1309. -------------+---------------------------------------------------------
  1310.          |    dot to mouse        forward page    switch to other buffer 
  1311.       X         |    recenter        backward page    kill buffer
  1312.    X         |    delete word        split window    describe key
  1313.    X  X         |    kill line        delete window    describe bindings
  1314. X         |    delete char        goto bob    suspend emacs
  1315. X     X         |    delete whitespace    goto eob    quit
  1316. X  X         |    kill region        enlarge window    list buffers
  1317. X  X  X         |    yank            shrink window    toggle Intuition window
  1318.  
  1319.    To help keep straight what the various keys do, notice that the
  1320. Status and Echo groups come in pairs; the shifted version of a key is
  1321. in some sense the opposite of the unshifted version. There is no
  1322. opposite for display buffers, so that key is bound to
  1323. toggle-window-hack, which toggles Emacs' Intuition window between
  1324. bordered and borderless.
  1325.  
  1326.    Like any Emacs key, you are perfectly free to rebind the 24 mouse
  1327. buttons to do whatever you wish, although currently you can't rebind
  1328. them in a startup file.
  1329.  
  1330.                THE KEYBOARD
  1331.                ------------
  1332.  
  1333.    There is a shortcut for many of the Meta commands (usually
  1334. indicated by the ESC character): hold down the ALT key at the same
  1335. time you type what usually comes after the ESC.
  1336.  
  1337.    (Historically, this is why keys that are typed with ESC in front of
  1338. them are called META keys; on the terminals at MIT where Emacs was
  1339. originally written, there was a META key on the keyboard that did what
  1340. the ALT key does. However, not many terminals outside of MIT have the
  1341. META key at all, so the ESC key was nominated as a way to tell the
  1342. system that the next character should be converted into a META key
  1343. before it is interpreted.)
  1344.  
  1345.    If you are running under the 1.2 Workbench, you may need to issue
  1346. the command "setmap usa0" to make things work right (the default
  1347. console keymap changed between 1.1 and 1.2).
  1348.  
  1349.    MicroEmacs also recognizes all the standard Amiga function keys.
  1350. For quick help on a key, type the HELP key and then the key you want
  1351. help on. The following commands are bound to the Amiga function keys:
  1352.  
  1353.     Key            Function
  1354.     ----------------------------------
  1355.     Help            describe-key-briefly
  1356.  
  1357.     Left            backward-char
  1358.     Shift-Left        backward-word
  1359.     Right            forward-char
  1360.     Shift-Right        forward-word
  1361.  
  1362.     Up            previous-line
  1363.     Shift-Up        backward-paragraph
  1364.  
  1365.     Down            next-line
  1366.     Shift-Down        forward-paragraph
  1367.  
  1368.     F1            find-file
  1369.     Shift-F1        find-file-other-window
  1370.     F2            save-buffer
  1371.     Shift-F2        write-file
  1372.     F3            scroll-up (page down)
  1373.     Shift-F3        scroll-down (page up)
  1374.     F4            next-window
  1375.     Shift-F4        previous-window
  1376.     F5            enlarge-window
  1377.     Shift-F5        shrink-window
  1378.     F6            fill-paragraph
  1379.     Shift-F6        query-replace
  1380.     F7            split-window-vertically
  1381.     Shift-F7        delete-other-windows
  1382.     F8            global-set-key
  1383.     Shift-F8        global-unset-key
  1384.     F9            start-kbd-macro
  1385.     Shift-F9        end-kbd-macro
  1386.     F10            call-last-kbd-macro
  1387.     Shift-F10        save-buffers-kill-emacs
  1388.  
  1389.                  THE MENU
  1390.                  --------
  1391.    If the menu option is compiled into the program, you can also use
  1392. the Intuition menu, just like a "real" Amiga program. The menu names
  1393. are relatively self-explanitory, as are the names inside each menu. If
  1394. you want to learn what the command key is for a menu function, type
  1395. "<ESC>-x describe-bindings<RET>" and page through till you find a
  1396. function with a similar name. A future release of the Amiga driver
  1397. will probably allow you to directly find out what command keys are
  1398. bound to a particular function, but you'll just have to bear with us
  1399. for a while.
  1400.  
  1401.                 THE BROWSER
  1402.                 -----------
  1403.  
  1404.    The Browser is the next best (or even better, for some purposes)
  1405. thing to a file requester. In essence, it puts the directory tree up
  1406. in the menu bar, where you can visit files simply by selecting their
  1407. names from the menu bar. Try it, you'll like it.  If the MENU option
  1408. is also compiled in, the editing menus are all submenus of the first,
  1409. "Edit" menu, and the Browser uses the rest of the menu bar.
  1410.  
  1411.                WINDOW OPTIONS 
  1412.                --------------
  1413.  
  1414.    As a service to those of us who want a full-size, 80-column editing
  1415. window, Amiga MicroEmacs allows you to make its window borderless. If
  1416. you like, you can take over the full Workbench screen (48 rows, 80
  1417. columns in interlace mode under 1.2). Borderless windows can be
  1418. "visually confusing", to say the least, so it's probably best to
  1419. either to 1) take over the whole screen or 2) put the Emacs window at
  1420. the bottom of the screen.
  1421.  
  1422.    When Amiga MicroEmacs starts up, its initial window is borderless,
  1423. and 640x200 pixels in dimension. To change to a resizeable window,
  1424. issue the command "M-x toggle-window-hack" or select the "Toggle
  1425. Window" item from the menu (if it is compiled into the program).
  1426. MicroEmacs will create a new, resizeable, bordered window, which you
  1427. can then set to whatever size you wish using the sizing gadget in the
  1428. bottom left corner of the window.
  1429.  
  1430.    To go back to a borderless window, issue the "Toggle Window"
  1431. command again. MicroEmacs will remember the current size of the
  1432. resizeable window, and create a borderless window with the same
  1433. dimensions and position. Since under Workbench 1.2 you can use a
  1434. 640x400 window, this lets you take up the *entire screen* -- 48 rows
  1435. by 80 columns!
  1436.  
  1437.  
  1438.                CHANGING THE WINDOW'S FONT
  1439.                --------------------------
  1440.  
  1441.    There may be times when you'd like to use another font on the screen,
  1442. either to make the text easier to read, or for some special effect, like
  1443. editing something on a TV projection system.  MG lets you change the
  1444. font that is used to draw characters in the window, using the command
  1445. M-x set-font.
  1446.  
  1447.    You can use the universal argument to set the desired text font size,
  1448. for example saying C-u 12 M-x set-font, then typing "opal" when it
  1449. prompts you for the name of the font.  If you give an argument that is
  1450. <= 0, MG resets the window's font to the system default (set by
  1451. Preferences).  If you don't give an argument, MG prompts you for the
  1452. desired font size.
  1453.  
  1454.    Changing the window's font to one that is designed to be
  1455. proportionally spaced does not work very well, because Emacs expects the
  1456. all characters on the screen to be the same width, which is of course
  1457. not the case with proportional fonts.  MG lets you use proportional
  1458. fonts, but it asks you to make sure first. 
  1459.  
  1460.  
  1461.                 TEXT RENDITION
  1462.                 --------------
  1463.  
  1464.    If you really want to, you can change the "soft style" the console
  1465. device uses to draw characters in the text area and the mode line.
  1466. The possible values for these styles are:
  1467.  
  1468.     0    plain
  1469.     1    boldface
  1470.     3    italic
  1471.     4    underline
  1472.     7    inverse
  1473.  
  1474.    About the only useful values are the ones for plain, boldface or
  1475. italics. The default value for text is 0 (plain, of course), while the
  1476. default for the mode line is 7 (inverse video). These can be changed
  1477. by the appropriate #definitions of MODE_RENDITION and TEXT_RENDITION.
  1478.  
  1479.    The commands to change the rendition values are:
  1480.  
  1481.     set-text-rendition
  1482.         Set text area rendition
  1483.     set-mode-rendition
  1484.         Set mode line rendition (this is by far the more useful)
  1485.  
  1486.                 COLOR
  1487.                 -----
  1488.  
  1489.    You can set the colors the console device uses to draw the text you
  1490. are editing. (This does not mean that you can specify *any* color;
  1491. your choices are limited to the colors being used by Intuition to
  1492. maintain the Workbench screen.) The commands that control this
  1493. behavior are:
  1494.  
  1495.     set-text-foreground
  1496.         Sets the color used to draw the characters you
  1497.         see in the text area (distinct from the mode
  1498.         line area for each window).  Accepts a number from
  1499.         0 to 7.  The value initially used is 1.  You can
  1500.         get a reverse video screen by selecting 0 for this
  1501.         value and 1 for the background color
  1502.  
  1503.     set-text-background
  1504.         Sets the color used the draw the background behind
  1505.         characters in the text area.  Accepts the same values
  1506.         as set-text-foreground-color.  The initial value
  1507.         is 0.
  1508.  
  1509.     set-mode-foreground
  1510.         Sets the foreground color used by the mode line.  If you
  1511.         set this to 0 and the background color to 1, you can get
  1512.         a reverse video mode line even when you select italics for
  1513.         the mode line rendition (see RENDITION)
  1514.  
  1515.     set-mode-background
  1516.         Sets the background color for the mode line.  You should
  1517.         get the idea by now.
  1518.         
  1519.  
  1520.                THE STARTUP FILE
  1521.                ----------------
  1522.  
  1523.    If the STARTUP option has been compiled into your editor, you can
  1524. use a file of startup commands that rebind (most of the) keys and
  1525. otherwise set up the editor as you see fit.
  1526.  
  1527.    The startup file must have the name ".mg", and can either be
  1528. located in the current directory, or the "s:" system startup
  1529. directory. If the file is there, MicroEmacs opens the file and
  1530. attempts to interpret the commands therein.
  1531.  
  1532.    The basic idea is that you are issuing M-X commands; the first line
  1533. in the example startup file below would be interpreted as "M-x
  1534. bsmap-mode". Spaces are necessary to separate the parts of the
  1535. command, but the quotation marks are there mainly for effect. If you
  1536. happen to use GNU Emacs on a larger system, the startup file routines
  1537. can also read your ".emacs" file, as long as the functions you call in
  1538. the ".emacs" file are available in MicroGNUEmacs.
  1539.  
  1540. The escape conventions for startup files are:
  1541.  
  1542.     \^    next character is a control character
  1543.     \e    next character is an escape (meta) character
  1544.     \n    newline
  1545.     \t    tab
  1546.     \r    carriage return
  1547.     \\    backslash character
  1548.  
  1549.     A '\' followed by anything else means "quote this character
  1550.     as-is".
  1551.  
  1552.    Here, then, is the example startup file:
  1553.  
  1554. ---------------------------------CUT HERE---------------------------------
  1555. bsmap-mode
  1556. auto-fill-mode
  1557. global-set-key "\^l" redraw-display
  1558. global-set-key "\e\^h" forward-kill-word
  1559. global-set-key "\^h" delete-char
  1560. global-set-key "\^x\^v" find-file
  1561. global-set-key "\eg" goto-line
  1562. set-mode-rendition 3
  1563. set-mode-foreground 0
  1564. set-mode-background 1
  1565. ---------------------------------CUT HERE-------------------------------------
  1566.  
  1567.                 FUNCTION LIST
  1568.                 -------------
  1569.  
  1570.    For completeness, here is a list of all Amiga MicroEmacs functions
  1571. that are specific to the Amiga. See the file "functions" for the others.
  1572.  
  1573. amiga-menu
  1574.     The entry point for using Emacs's Intuition menu.  This function
  1575.     figures out which menu selection was used, then calls the
  1576.     appropriate function by name (not hard-coded key value)
  1577. amiga-mouse
  1578.     Set dot to where the mouse is pointing.  Two clicks in the same
  1579.     spot set the mark too.
  1580. mouse-*
  1581.     Functions that first either 1) move point to where the mouse
  1582.     points to or 2) select the buffer associated with the mode line
  1583.     the mouse clicked in, then call the function indicated by the
  1584.     rest of the name.  These functions are all "bound" to mouse
  1585.     clicks, because the input machinery converts them into internal
  1586.     Emacs "keys".
  1587. set-font
  1588.     Set the font used to draw characters inside the Emacs window.
  1589.     A positive argument is used for the size of the font, while
  1590.     a nonpositive argument requests that the font be set to the
  1591.     system default font.  Menu items are not affected by this command.
  1592. set-mode-rendition
  1593. set-text-rendition
  1594.     Set the way your text (or the mode line) is rendered.  Choose
  1595.     from 0 (plain), 1 (bold), 3 (italic), 4 (underline), or
  1596.     7 (reverse video). 0, 1, and 3 are about the only really useful
  1597.     ones for text; 7 is the default for the mode line.
  1598. set-text-foreground
  1599. set-text-background
  1600. set-mode-foreground
  1601. set-mode-background
  1602.     Set the system color used to draw the characters in the text area
  1603.     and mode line.  Accepts a value between 0 and 7; the default for
  1604.     the background is 0, the default for the text is 1.
  1605. toggle-window-hack
  1606.     Switch your window between resizable and borderless. Lets you
  1607.     take over the whole screen (80 columns! 48 lines in interlace!)
  1608. SHAR_EOF
  1609. fi # end of overwriting check
  1610. if test -f 'sys/amiga/fileio.c'
  1611. then
  1612.     echo shar: will not over-write existing file "'sys/amiga/fileio.c'"
  1613. else
  1614. cat << \SHAR_EOF > 'sys/amiga/fileio.c'
  1615. /*
  1616.  * Name:    MicroEMACS
  1617.  * Version:    Gnu v30
  1618.  *        Commodore Amiga file I/O.
  1619.  * Last edit:    30-Sep-86 ...ihnp4!seismo!ut-sally!ut-ngp!mic
  1620.  * Created:    23-Jul-86 ...ihnp4!seismo!ut-sally!ut-ngp!mic
  1621.  *        (from sys/bsd/fileio.c)
  1622.  *
  1623.  * Read and write ASCII files. All
  1624.  * of the low level file I/O knowledge is here.
  1625.  * Pretty much vanilla standard I/O.
  1626.  */
  1627. #include    "def.h"
  1628. /* With Uttice, make sure you use -Idf0:include/lattice/ to    */
  1629. /* put the Lattice files in the right spot.            */
  1630. #include    <fcntl.h>
  1631.  
  1632. static    FILE    *ffp;
  1633.  
  1634. /*
  1635.  * Open a file for reading.
  1636.  */
  1637. ffropen(fn)
  1638. char    *fn;
  1639. {
  1640.     if ((ffp=fopen(fn, "r")) == NULL)
  1641.         return (FIOFNF);
  1642.     return (FIOSUC);
  1643. }
  1644.  
  1645. /*
  1646.  * Open a file for writing.
  1647.  * Return TRUE if all is well, and
  1648.  * FALSE on error (cannot create).
  1649.  */
  1650. ffwopen(fn)
  1651. char    *fn;
  1652. {
  1653.     if ((ffp=fopen(fn, "w")) == NULL) {
  1654.         ewprintf("Cannot open file for writing");
  1655.         return (FIOERR);
  1656.     }
  1657.     return (FIOSUC);
  1658. }
  1659.  
  1660. /*
  1661.  * Close a file.
  1662.  * Should look at the status.
  1663.  */
  1664. ffclose()
  1665. {
  1666.     fclose(ffp);
  1667.     return (FIOSUC);
  1668. }
  1669.  
  1670. /*
  1671.  * Write a line to the already
  1672.  * opened file. The "buf" points to the
  1673.  * buffer, and the "nbuf" is its length, less
  1674.  * the free newline. Return the status.
  1675.  * Check only at the newline.
  1676.  */
  1677. ffputline(buf, nbuf)
  1678. register char    buf[];
  1679. {
  1680.     register int    i;
  1681.  
  1682.     for (i=0; i<nbuf; ++i)
  1683.         putc(buf[i]&0xFF, ffp);
  1684.     putc('\n', ffp);
  1685.     if (ferror(ffp) != FALSE) {
  1686.         ewprintf("Write I/O error");
  1687.         return (FIOERR);
  1688.     }
  1689.     return (FIOSUC);
  1690. }
  1691.  
  1692. /*
  1693.  * Read a line from a file, and store the bytes
  1694.  * in the supplied buffer. Stop on end of file or end of
  1695.  * line. Don't get upset by files that don't have an end of
  1696.  * line on the last line; this seem to be common on CP/M-86 and
  1697.  * MS-DOS (the suspected culprit is VAX/VMS kermit, but this
  1698.  * has not been confirmed. If this is sufficiently researched
  1699.  * it may be possible to pull this kludge). Delete any CR
  1700.  * followed by an LF.
  1701.  */
  1702. ffgetline(buf, nbuf)
  1703. register char    buf[];
  1704. {
  1705.     register int    c;
  1706.     register int    i;
  1707.  
  1708.     i = 0;
  1709.     for (;;) {
  1710.         c = getc(ffp);
  1711.         if (c == '\r') {        /* Delete any non-stray    */
  1712.             c = getc(ffp);        /* carriage returns.    */
  1713.             if (c != '\n') {
  1714.                 if (i >= nbuf-1) {
  1715.                     ewprintf("File has long line");
  1716.                     return (FIOERR);
  1717.                 }
  1718.                 buf[i++] = '\r';
  1719.             }
  1720.         }
  1721.         if (c==EOF || c=='\n')        /* End of line.        */
  1722.             break;
  1723.         if (i >= nbuf-1) {
  1724.             ewprintf("File has long line");
  1725.             return (FIOERR);
  1726.         }
  1727.         buf[i++] = c;
  1728.     }
  1729.     if (c == EOF) {                /* End of file.        */
  1730.         if (ferror(ffp) != FALSE) {
  1731.             ewprintf("File read error");
  1732.             return (FIOERR);
  1733.         }
  1734.         if (i == 0)            /* Don't get upset if    */
  1735.             return (FIOEOF);    /* no newline at EOF.    */
  1736.     }
  1737.     buf[i] = 0;
  1738.     return (FIOSUC);
  1739. }
  1740.  
  1741. #ifdef    BACKUP
  1742. /*
  1743.  * Make a file name for a backup copy.
  1744.  */
  1745. fbackupfile(fname)
  1746. char    *fname;
  1747. {
  1748.     strcat(fname,"~");
  1749.     return (TRUE);
  1750. }
  1751. #endif    BACKUP
  1752.  
  1753. #ifdef    STARTUP
  1754. /*
  1755.  * Return name of user's startup file.  On Amiga, make it
  1756.  * s:.mg
  1757.  */
  1758.  
  1759. static char startname[] = ".mg";
  1760. static char altstartname[] = "s:.mg";
  1761.  
  1762. char *startupfile()
  1763. {
  1764.     FILE *f, *fopen();
  1765.     if (f = fopen(startname,"r")) {        /* first try    */
  1766.         fclose(f);
  1767.         return(startname);
  1768.     }
  1769.     if (f = fopen(altstartname,"r")) {    /* second try    */
  1770.         fclose(f);
  1771.         return (altstartname);
  1772.     }
  1773.     return (NULL);
  1774. }
  1775. #endif    STARTUP
  1776.  
  1777. /*
  1778.  * The string "fn" is a file name.
  1779.  * Perform any required case adjustments.
  1780.  * On the Amiga file names are dual case,
  1781.  * so we leave everything alone.
  1782.  */
  1783. adjustcase(fn)
  1784. register char    *fn;
  1785. {
  1786.     return (TRUE);
  1787. }
  1788. SHAR_EOF
  1789. fi # end of overwriting check
  1790. if test -f 'sys/amiga/sleep.c'
  1791. then
  1792.     echo shar: will not over-write existing file "'sys/amiga/sleep.c'"
  1793. else
  1794. cat << \SHAR_EOF > 'sys/amiga/sleep.c'
  1795. /*
  1796.  * Name:    MicroEmacs
  1797.  *        AmigaDOS sleep function
  1798.  * Version:    31
  1799.  * Last Edit:    18-Apr-86
  1800.  * Created:    18-Apr-86 ...!ihnp4!seismo!ut-sally!ut-ngp!mic
  1801.  */
  1802.  
  1803. /* There are really 60 ticks/second, but I don't want to wait that     */
  1804. /* long when matching parentheses... */
  1805. #define    TICKS    45
  1806. extern    long Delay();
  1807.  
  1808. sleep(n)
  1809. int n;
  1810. {
  1811.     if (n > 0)
  1812.         Delay((long) n * TICKS);
  1813. }
  1814. SHAR_EOF
  1815. fi # end of overwriting check
  1816. if test -f 'sys/amiga/spawn.c'
  1817. then
  1818.     echo shar: will not over-write existing file "'sys/amiga/spawn.c'"
  1819. else
  1820. cat << \SHAR_EOF > 'sys/amiga/spawn.c'
  1821. /*
  1822.  * Name:    MicroEMACS
  1823.  *        Spawn an AmigaDOS subprocess
  1824.  * Version:    Gnu30
  1825.  * Last edit:    17-Aug-1986
  1826.  * By:        ...!ihnp4!seismo!ut-sally!ut-ngp!mic
  1827.  */
  1828.  
  1829. #include <libraries/dos.h>
  1830. #include <libraries/dosextens.h>
  1831. #undef TRUE
  1832. #undef FALSE
  1833. #include "def.h"        /* AFTER system files to avoid redef's */
  1834.  
  1835. /*
  1836.  * Create a subjob with a copy of the command intrepreter in it.
  1837.  * This is really a way to get a new copy of the CLI, because
  1838.  * we don't wait around for the new process to quit.  Note the use
  1839.  * of a file handle to nil: to avoid the "endcli" message going out
  1840.  * to Emacs's standard output.
  1841.  */
  1842.  
  1843. spawncli(f, n, k)
  1844. {
  1845.     struct FileHandle *nil, *Open();
  1846.     
  1847.     ewprintf("[Starting new CLI]");
  1848.     nil = Open("NIL:", MODE_NEWFILE);
  1849.     if (nil == (struct FileHandle *) 0) { /* highly unlikely */
  1850.         ewprintf("Can't create nil file handle");
  1851.         return (FALSE);
  1852.     }
  1853.     Execute("NEWCLI \"CON:0/0/640/200/MicroEmacs Subprocess\"",nil,nil);
  1854.     Close(nil);
  1855.     return (TRUE);
  1856. }
  1857.  
  1858.  
  1859. SHAR_EOF
  1860. fi # end of overwriting check
  1861. if test -f 'sys/amiga/sysdef.h'
  1862. then
  1863.     echo shar: will not over-write existing file "'sys/amiga/sysdef.h'"
  1864. else
  1865. cat << \SHAR_EOF > 'sys/amiga/sysdef.h'
  1866. /*
  1867.  * Name:    MicroEMACS
  1868.  *        Commodore Amiga system header file.
  1869.  * Version:    Gnu v30
  1870.  */
  1871.  
  1872. #ifdef MANX
  1873. #define    PCC    0            /* "[]" works.            */
  1874. #else
  1875. #define    PCC    1            /* "[]" does not work.        */
  1876. #endif
  1877.  
  1878. #define    VARARGS
  1879. #define    KBLOCK    4096            /* Kill grow.            */
  1880. #define    GOOD    0            /* Good exit status.        */
  1881.  
  1882. /*
  1883.  * Macros used by the buffer name making code.
  1884.  * Start at the end of the file name, scan to the left
  1885.  * until BDC1 (or BDC2, if defined) is reached. The buffer
  1886.  * name starts just to the right of that location, and
  1887.  * stops at end of string (or at the next BDC3 character,
  1888.  * if defined). BDC2 and BDC3 are mainly for VMS.
  1889.  */
  1890. #define    BDC1    ':'            /* Buffer names.        */
  1891. #define    BDC2    '/'
  1892.  
  1893. /*
  1894.  * Typedefs for internal key type and how big a region can be.
  1895.  */
  1896.  
  1897. typedef    short    KEY;    /* 16-bit ints        */
  1898. typedef    long    RSIZE;    /* size of a region    */
  1899.  
  1900. #define    bcopy(src,dest,len) movmem(src,dest,len)
  1901. SHAR_EOF
  1902. fi # end of overwriting check
  1903. if test -f 'sys/amiga/varargs.h'
  1904. then
  1905.     echo shar: will not over-write existing file "'sys/amiga/varargs.h'"
  1906. else
  1907. cat << \SHAR_EOF > 'sys/amiga/varargs.h'
  1908. /*
  1909.  * Varargs, for use on AmigaDOS with the Lattice C compiler,
  1910.  *    or (maybe?) the Manx compiler with 32-bit ints.
  1911.  *    Blatantly lifted from 4.2BSD.
  1912.  */
  1913.  
  1914. typedef char        *va_list;
  1915. #define va_dcl        int va_alist;
  1916. #define va_start(pv)    pv = (char *) &va_alist
  1917. #define va_end(pv)    /* Naught to do... */
  1918. #define va_arg(pv, t)    ((t *) (pv += sizeof(t)))[-1]
  1919. SHAR_EOF
  1920. fi # end of overwriting check
  1921. #    End of shell archive
  1922. exit 0
  1923.  
  1924.