home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume3 / mg2a / part13 < prev    next >
Internet Message Format  |  1989-02-03  |  60KB

  1. Path: xanth!mcnc!ece-csc!ncsuvx!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!necntc!ncoast!allbery
  2. From: BLARSON@ECLA.USC.EDU (Bob Larson)
  3. Newsgroups: comp.sources.misc
  4. Subject: v03i037: mg 2a part 13 of 15
  5. Message-ID: <12401301336.47.BLARSON@ECLA.USC.EDU>
  6. Date: 26 May 88 05:02:50 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: BLARSON@ECLA.USC.EDU (Bob Larson)
  9. Lines: 2016
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. comp.sources.misc: Volume 3, Issue 37
  13. Submitted-By: "Bob Larson" <BLARSON@ECLA.USC.EDU>
  14. Archive-Name: mg2a/Part13
  15.  
  16. #    This is a shell archive.
  17. #    Remove everything above and including the cut line.
  18. #    Then run the rest of the file through sh.
  19. #----cut here-----cut here-----cut here-----cut here----#
  20. #!/bin/sh
  21. # shar:    Shell Archiver
  22. #    Run the following text with /bin/sh to create:
  23. #    sys/amiga/Amiga.Doc
  24. #    sys/amiga/Makefile.LATTICE
  25. #    sys/amiga/Makefile.MANX
  26. #    sys/amiga/amiga_maps.c
  27. #    sys/amiga/console.c
  28. #    sys/amiga/dirio.c
  29. #    sys/amiga/fileio.c
  30. #    sys/amiga/malloc.c
  31. # This archive created: Mon May 23 18:09:53 1988
  32. # By:    blarson
  33. if test -d sys
  34. then true
  35. else mkdir sys
  36. fi
  37. if test -d sys/amiga
  38. then true
  39. else mkdir sys/amiga
  40. fi
  41. cat << \SHAR_EOF > sys/amiga/Amiga.Doc
  42.  
  43.             Amiga MG 2a Release Notes
  44.             -------------------------
  45.  
  46.    This file attempts to document the Amiga-specific features of MG 2a.
  47. Except where otherwise noted.  It is assumed that you already know
  48. about the point and the mark, buffers, windows, extended commands, and
  49. the various areas on the screen that all versions of MG maintain.  If
  50. you don't, see the MG documentation (what there is of it) for more
  51. information. 
  52.  
  53.                   Amiga Credits
  54.                   -------------
  55.  
  56.   The Amiga Intuition terminal driver is the combined effort of Mike
  57. Meyer and Mic Kaczmarczik.  Others who helped and/or inspired good
  58. ideas for the MG terminal driver include Steve Walton, Leon Frenkel,
  59. Marcus Brooks, and Tom Rokicki.  Steve Walton is also responsible for
  60. the dired mode. Lastly, Bob Larson redesigned the MG keymap system,
  61. making it possible for function keys and mouse clicks to be
  62. ``first-class citizens''.
  63.  
  64.                               OPTIONS
  65.                               -------
  66.  
  67.    This section is for people who have their own C compiler. If you
  68. don't have a C compiler, you will hopefully have a version that has
  69. everything compiled into it. 
  70.  
  71.    There are a bewildering variety of extra goodies available as
  72. compile-time options when you construct an Amiga MG. If you select none
  73. of them, you save on disk and memory space, but lose out on some
  74. features and versatility. 
  75.  
  76.    The Makefile provides documentation on these options and what to do
  77. to make them work, but here is a quick overview:
  78.  
  79.    STARTUP -- You can configure MG so that it will look for a startup
  80. file in either the current directory or the AmigaDOS s: (startup)
  81. directory.  An example startup file is included in the distribution,
  82. and also see the STARTUP section below.
  83.  
  84.    MENU -- If this option is used, MG puts an Intuition menu bar with
  85. major editing commands at the top of the screen, just like a "real"
  86. Amiga program. (See the section on the MENU for more info).
  87.  
  88.    BROWSER -- This has got to be seen to be appreciated. The Browser
  89. program turns the menu bar into a way to select files on a disk. First
  90. you select a disk, then a directory on the disk, then a file or
  91. subdirectory on the disk, and so on, all in the menu. 
  92.  
  93.    MOUSE -- This option turns on the Amiga hot mouse.  You can click
  94. on a character and move point to that spot, and that's just the
  95. beginning. (See the MOUSE section for more.)
  96.  
  97.    FKEYS -- This option turns on support for all the extra Amiga
  98. function keys. This enables the HELP key, which runs the function
  99. "describe-key-briefly". Arrow keys work -- shift-arrow keys apply to
  100. words and paragraphs. (See the KEYBOARD section.)
  101.  
  102.    NO_BACKUP -- This is actually a default option; #defining NO_BACKUP
  103. disables backup files.
  104.  
  105.    When chosen, this #define modifies the action of the save-buffer (C-x
  106. C-s) command.  Normally, save-buffer writes out a new copy of the buffer
  107. to disk, thus destroying the contents of the original file.  If BACKUP
  108. is enabled, MG will rename the file to filename~ (with a tilde character
  109. at the end), before the new copy is written out.  This keeps the
  110. next-to-last copy of your file around on disk, so you can recover from
  111. bad mistakes. 
  112.  
  113.    To avoid filling up disk space too quickly, by default MG does *NOT*
  114. make backup files; to do so, enter the command "M-x make-backup-files",
  115. which enables making backup files the next time you enter C-x C-s to
  116. save a file.  If you give an argument to the function (by typing "C-u
  117. M-x make-backup-files", for example), backup files are not made. 
  118.  
  119.    DO_METAKEY -- When this is enabled, Amiga MG uses the ALT key to
  120. implement the META key found on some terminals.  This means that you
  121. can type ALT-f (in one keystroke) to go forward one word, instead of
  122. ESC-f, which requires two.
  123.  
  124.    CHANGE_FONT -- This allows you to set the font used by the Amiga
  125. console device driver when it draws characters in the MG window.
  126. For instance, this lets you use a slightly taller font for editing
  127. when using interlace mode under 1.2.  MG cannot handle proportionally
  128. spaced fonts, but will allow you to use them (with rather confusing
  129. results) if you really want to.
  130.  
  131.    MODE_RENDITION, {TEXT,MODE}_{FG,BG} -- These are #defines that
  132. determine the default rendition of the mode line and the foreground
  133. and background colors of the text. See the COLOR section for more
  134. info.
  135.  
  136.    CHANGE_COLOR -- If you want to be able to mess around with the
  137. foreground and background colors of the text window, this option
  138. allows you to do that. You can also specify the way the status line is
  139. rendered (plain, boldface, italics, or reverse video).
  140.  
  141.    USE_ARP -- Amiga MG2a uses a few functions which are part of the
  142. library for ARP, the AmigaDOS Replacement Project. Work-alikes for
  143. these routines are provided for those without a copy of arp.library,
  144. but as a future version of Amiga MG will require ARP and it has so
  145. many other redeeming values, it is recommended you obtain a copy.
  146.  
  147.    DO_ICONIFY -- This turns on the ``amiga-iconify'' function,
  148. described in more detail below.
  149.  
  150.                               THE MOUSE
  151.                               ---------
  152.  
  153.    The Amiga Mouse can invoke no less than 24 different functions.
  154. Mouse clicks are essentially treated as keys by the MG, even though you
  155. click the mouse and hold down qualifier keys to get them. 
  156.  
  157.    Mouse keys come in three groups of eight, the groups being:
  158.     Mouse keys        -- when clicked in the text of a window
  159.     Mode-Mouse keys        -- when clicked on a window's mode line
  160.     Echo-Mouse keys        -- when clicked in the echo area
  161.  
  162.    Inside each group, which of the eight keys you get is determined by
  163. the combination of Shift, CTRL and ALT keys you are holding down when
  164. the mouse button is pressed. So yes, there really is a
  165. Ctrl-Meta-Shift-Mode-Mouse button.  Note that the Meta (M-) prefix
  166. *MUST* be the ALT key. Prefixing a mouse click with ESC will not work. 
  167.  
  168.    Mouse keys are generally bound to functions that affect the text in
  169. the selected buffer. If the Intuition mouse pointer is located inside an
  170. MG text window (i.e. an area where text is being edited), then a Mouse
  171. key is sent to the editor when you click the mouse. The buffer
  172. associated wth the window the pointer is in is made current, point is
  173. set as close as possible to the pointer (the character under the
  174. pointer, if possible), then the command bound to that mouse button is
  175. executed. 
  176.  
  177.    If the mouse pointer is in the mode line - the line that is in a
  178. different typeface (usually backlit, maybe black instead of white) --
  179. when the mouse button is clicked, a Mode-Mouse key is sent to the
  180. editor. The buffer that the selected status line is associated with is
  181. made the current buffer, the point is set to the value of point for
  182. that window, then whatever command is bound to that button is
  183. executed. Most of the Mode-Mouse keys invoke functions that act on the
  184. entire window or buffer.
  185.  
  186.    Clicking in the echo line - the line at the bottom of the screen
  187. where prompts and message appear - results in an Echo-Mouse key.
  188. Whatever command is bound to that button will be executed.  Since the
  189. echo line is not part of a buffer or a window, all the functions bound
  190. to Echo-Mouse keys affect the state of the editor as a whole.
  191.    
  192.    The default bindings for the hot mouse (as distributed) are:
  193.  
  194.  Qualifiers  |            Area clicked
  195.              |
  196. C  A  Shift  |    Text window        Mode line    Echo line
  197. -------------+---------------------------------------------------------
  198.          |    dot to mouse        forward page    switch to other buffer 
  199.       X         |    recenter        backward page    kill buffer
  200.    X         |    delete word        split window    describe key
  201.    X  X         |    kill line        delete window    describe bindings
  202. X         |    delete char        goto bob    suspend MG
  203. X     X         |    delete whitespace    goto eob    quit
  204. X  X         |    kill region        enlarge window    list buffers
  205. X  X  X         |    yank            shrink window    toggle Intuition window
  206.  
  207.    To help keep straight what the various keys do, notice that the
  208. Status and Echo groups come in pairs; the shifted version of a key is in
  209. some sense the opposite of the unshifted version. There is no opposite
  210. for display-buffers, so that key is bound to "amiga-toggle-border",
  211. which toggles MG' Intuition window between bordered and borderless. 
  212.  
  213.    Like any MG key, you are free to rebind the 24 mouse buttons to do
  214. whatever you wish.  You may even rebind them in your startup sequence.
  215. NOTE: only functions that start with the prefix "mouse-" are able to
  216. handle clicks in windows and mode lines, because they know how to figure
  217. out where the mouse was clicked. Conversely, any non-mouse function may
  218. be bound to an Echo-Mouse key, because clicking in the echo area does
  219. not send the x,y click information to the function.
  220.  
  221.    If the iconification code is compiled in, then Echo-Mouse is bound
  222. to ``amiga-iconify'' by default.
  223.  
  224.                THE KEYBOARD
  225.                ------------
  226.  
  227.    There is a shortcut for many of the Meta commands (usually indicated
  228. by the ESC character): hold down the ALT key at the same time you type
  229. what usually comes after the ESC. 
  230.  
  231.    Historically, this is why keys that are typed with ESC in front of
  232. them are called META keys; on the terminals at MIT where the Emacs
  233. editor (MG's spiritual parent) was originally written, there was a META
  234. key on the keyboard that did what the ALT key does. However, not many
  235. terminals outside of MIT have the META key at all, so the ESC key was
  236. nominated as a way to tell the system that the next character should be
  237. converted into a META key before it is interpreted. 
  238.  
  239.    MG also recognizes Amiga function keys.  For quick help on a key,
  240. type the HELP key and then the key you want help on. The following
  241. commands are bound to the Amiga function keys:
  242.  
  243.     Key            Function
  244.     --------------------------------------------
  245.     Help            describe-key-briefly
  246.  
  247.     Left            backward-char
  248.     Shift-Left        backward-word
  249.     Right            forward-char
  250.     Shift-Right        forward-word
  251.  
  252.     Up            previous-line
  253.     Shift-Up        backward-paragraph
  254.  
  255.     Down            next-line
  256.     Shift-Down        forward-paragraph
  257.  
  258.     F1            find-file
  259.     Shift-F1        find-file-other-window
  260.     F2            save-buffer
  261.     Shift-F2        write-file
  262.     F3            scroll-up (page down)
  263.     Shift-F3        scroll-down (page up)
  264.     F4            enlarge-window
  265.     Shift-F4        shrink-window
  266.     F5            fill-paragraph
  267.     Shift-F5        query-replace
  268.     F6            split-window-vertically
  269.     Shift-F6        delete-other-windows
  270.     F7            transpose-chars
  271.     Shift-F7        just-one-space
  272.     F8            start-kbd-macro
  273.     Shift-F8        end-kbd-macro
  274.     F9            call-last-kbd-macro
  275.     Shift-F9        describe-bindings
  276.     F10            list-buffers
  277.     Shift-F10        save-buffers-kill-emacs
  278.  
  279.               FUNCTION KEY NAMES
  280.               ------------------
  281.  
  282. On the Amiga, all the function keys are readily visible on the
  283. keyboard, so this table of key names for use in strings is fairly
  284. self-explanitory.  If you want to rebind Shift-Down-Arrow to scroll-up
  285. (move down a whole page), for example, insert the line
  286.  
  287.     (global-set-key "\F5" 'scroll-up)
  288.  
  289. in your s:.mg file.
  290.     Amiga key            Startup name
  291. -------------------------------------------------------------------------
  292.     Up-Arrow            \F0
  293.     Down-Arrow            \F1
  294.     Left-Arrow            \F2
  295.     Right-Arrow            \F3
  296.  
  297.     Shift-Up-Arrow            \F4
  298.     Shift-Down-Arrow        \F5
  299.     Shift-Left-Arrow        \F6
  300.     Shift-Right-Arrow        \F7
  301.  
  302.     Help                \F9
  303.  
  304.     F1                \F12
  305.     F2                \F13
  306.     F3                \F14
  307.     F4                \F15
  308.     F5                \F16
  309.     F6                \F17
  310.     F7                \F18
  311.     F8                \F19
  312.     F9                \F20
  313.     F10                \F21
  314.  
  315.     Shift-F1            \F22
  316.     Shift-F2            \F23
  317.     Shift-F3            \F24
  318.     Shift-F4            \F25
  319.     Shift-F5            \F26
  320.     Shift-F6            \F27
  321.     Shift-F7            \F28
  322.     Shift-F8            \F29
  323.     Shift-F9            \F30
  324.     Shift-F10            \F31
  325.  
  326.     Mouse                \F32
  327.     Ctrl-Mouse            \F33
  328.     Shift-Mouse            \F34
  329.     Shift-Ctrl-Mouse        \F35
  330.     Meta-Mouse            \F36
  331.     Meta-Ctrl-Mouse            \F37
  332.     Meta-Shift-Mouse        \F38
  333.     Meta-Shift-Ctrl-Mouse        \F39
  334.  
  335.     Mode-Mouse            \F40
  336.     Ctrl-Mode-Mouse            \F41
  337.     Shift-Mode-Mouse        \F42
  338.     Shift-Ctrl-Mode-Mouse        \F43
  339.     Meta-Mode-Mouse            \F44
  340.     Meta-Ctrl-Mode-Mouse        \F45
  341.     Meta-Shift-Mode-Mouse        \F46
  342.     Meta-Shift-Ctrl-Mode-Mouse    \F47
  343.  
  344.     Echo-Mouse            \F48
  345.     Ctrl-Echo-Mouse            \F49
  346.     Shift-Echo-Mouse        \F50
  347.     Shift-Ctrl-Echo-Mouse        \F51
  348.     Meta-Echo-Mouse            \F52
  349.     Meta-Ctrl-Echo-Mouse        \F53
  350.     Meta-Shift-Echo-Mouse        \F54
  351.     Meta-Shift-Ctrl-Echo-Mouse    \F55
  352.  
  353.  
  354.                  THE MENU
  355.                  --------
  356.    If the menu option is compiled into the program, you can also use the
  357. Intuition menu, just like any other well-written Amiga program. The menu
  358. names are relatively self-explanitory, as are the names inside each
  359. menu. If you want to learn what the command key is for a menu function,
  360. use the command "apropos" (invoked by Ctrl-Backspace a), followed by a
  361. substring of the menu item you're curious about. 
  362.  
  363.                 THE BROWSER
  364.                 -----------
  365.  
  366.    The Browser is the next best (or even better, for some purposes)
  367. thing to a file requester. Simply put, it places the directory tree up
  368. in the menu bar, where you can visit files simply by selecting their
  369. names from the menu bar. Try it, you'll like it.  If the MENU option is
  370. also compiled in, the editing menus are all submenus of the first,
  371. "Edit" menu, and the Browser uses the rest of the menu bar.
  372.  
  373.                WINDOW OPTIONS 
  374.                --------------
  375.  
  376.    As a service to those of us who want a full-size, 80-column editing
  377. window on a 640x200 screen, Amiga MG allows you to make its window
  378. borderless. If you like, you can take over the full Workbench screen (48
  379. rows, 80 columns in interlace mode under 1.2). Borderless windows can be
  380. "visually confusing", to quote the author of Intuition, so it's probably
  381. best to either to 1) take over the whole screen or 2) put the MG window
  382. at the bottom of the screen. 
  383.  
  384.    When Amiga MG starts up on a 640x200 screen, its initial window is
  385. borderless, and 640x200 pixels in dimension. To change to a resizeable
  386. window, issue the command "M-x amiga-toggle-border" or select the
  387. "Toggle Window" subitem from the "Window" menu (if it is compiled into
  388. the program).  MG will create a new, resizeable, bordered window, which
  389. you can then set to whatever size you wish using the sizing gadget in
  390. the bottom left corner of the window. 
  391.  
  392.    To go back to a borderless window, issue the "Toggle Window" command
  393. again. MG will remember the current size of the resizeable window, and
  394. create a borderless window with the same dimensions and position. Since
  395. under Workbench 1.2 you can use a 640x400 window, this lets you take up
  396. the entire screen, 48 rows by 80 columns. 
  397.  
  398. If you use MoreRows, MG will open up a resizeable window if there's
  399. enough room on the screen for an 24 line by 80 column window.
  400.  
  401.  
  402.                CHANGING THE WINDOW'S FONT
  403.                --------------------------
  404.  
  405.    There may be times when you'd like to use another font on the screen,
  406. either to make the text easier to read, or for some special effect, like
  407. editing something on a TV projection system.  MG lets you change the
  408. font that is used to draw characters in the window, using the command
  409. "M-x amiga-set-font".
  410.  
  411.    You can use the universal argument to set the desired text font size,
  412. for example saying "C-u 12 M-x set-font", then typing "opal" when it
  413. prompts you for the name of the font.  If you give an argument that is
  414. less than 0, MG resets the window's font to the system default (set by
  415. Preferences).  If you don't give an argument, MG prompts you for the
  416. desired font size.
  417.  
  418.    Changing the window's font to one that is designed to be
  419. proportionally spaced does not work very well, because MG expects the
  420. all characters on the screen to be the same width, which is of course
  421. not the case with proportional fonts.  MG lets you use proportional
  422. fonts, but it asks you to make sure first.
  423.  
  424.  
  425.                 TEXT RENDITION
  426.                 --------------
  427.  
  428.    If you really want to, you can change the "soft style" the console
  429. device uses to draw characters in the text area and the mode line.  The
  430. possible values for these styles are:
  431.  
  432.     0    plain
  433.     1    boldface
  434.     3    italic
  435.     4    underline
  436.     7    inverse
  437.  
  438.    About the only useful values are the ones for plain, boldface or
  439. italics. The default value for text is 0 (plain, of course), while the
  440. default for the mode line is 7 (inverse video). These can be changed by
  441. the appropriate #definitions of MODE_RENDITION and TEXT_RENDITION. 
  442.  
  443.    The commands to change the rendition values are:
  444.  
  445.     amiga-text-rendition
  446.         Set text area rendition
  447.     amiga-mode-rendition
  448.         Set mode line rendition (this is by far the more useful)
  449.  
  450.                 COLOR
  451.                 -----
  452.  
  453.    You can set the colors the console device uses to draw the text you
  454. are editing. (This does not mean that you can specify *any* color; your
  455. choices are limited to the colors being used by Intuition to maintain
  456. the Workbench screen.) The commands that control this behavior are:
  457.  
  458.     amiga-text-foreground
  459.         Sets the color used to draw the characters you see in the
  460.         text area (distinct from the mode line area for each window).
  461.         Accepts a number from 0 to 7.  The value initially used is 1.
  462.         You can get a reverse video screen by selecting 0 for this
  463.         value and 1 for the background color
  464.  
  465.     amiga-text-background
  466.         Sets the color used the draw the background behind characters
  467.         in the text area.  Accepts the same values as
  468.         amiga-text-foreground.  The initial value is 0.
  469.  
  470.     amiga-mode-foreground
  471.         Sets the foreground color used by the mode line.  If you
  472.         set this to 0 and the background color to 1, you can get
  473.         a reverse video mode line even when you select italics for
  474.         the mode line rendition (see RENDITION)
  475.  
  476.     amiga-mode-background
  477.         Sets the background color for the mode line.  You should
  478.         get the idea by now.
  479.  
  480.                 ICONIFICATION
  481.                 -------------
  482.  
  483.    Leo Schwab wrote a set of very general routines for allowing an
  484. Amiga program to shrink its window to an icon.  This icon can then be
  485. moved around on the screen, and re-expanded to its full size by a
  486. double click, like the one used to open a drawer.  Amiga MG2a
  487. provides this capability through the function ``amiga-iconify'',
  488. which is bound to Echo-Mouse by default if the iconification code is
  489. present.  Not only is this a great way to prevent screen clutter, but
  490. it also frees 50K of CHIP RAM while MG's window is iconified (on a 30
  491. line by 80 column mg window).
  492.  
  493.    To iconify the window, click the mouse in MG's echo line or issue
  494. the extended command ``amiga-iconify.''  To expand MG's window back
  495. to its full size, double-click on the MG2a icon in the same way you
  496. would on a disk or drawer icon.  The icon can also be dragged
  497. about, and will remember its last position when the window is
  498. iconified again.
  499.         
  500.  
  501.                 FUNCTION LIST
  502.                 -------------
  503.  
  504.    For completeness, here is a list of all Amiga MG functions that are
  505. specific to the Amiga. 
  506.  
  507. amiga-iconify
  508.     Iconifies the Amiga MG window.
  509. amiga-menu
  510.     The entry point for using MG's Intuition menu.  This function
  511.     figures out which menu selection was used, then calls the
  512.     appropriate function by name (not hard-coded key value)
  513. amiga-mouse
  514.     Set dot to where the mouse is pointing.  Two clicks in the same
  515.     spot set the mark too.
  516. mouse-*
  517.     Functions that first either 1) move point to where the mouse
  518.     points to or 2) select the buffer associated with the mode line
  519.     the mouse clicked in, then call the function indicated by the
  520.     rest of the name.  These functions are all "bound" to various
  521.     mouse click keys.
  522. amiga-set-font
  523.     Set the font used to draw characters inside the MG window.
  524.     A positive argument is used for the size of the font, while
  525.     a nonpositive argument requests that the font be set to the
  526.     system default font.  Menu items are not affected by this command.
  527. amiga-mode-rendition
  528. amiga-text-rendition
  529.     Set the way your text (or the mode line) is rendered.  Choose
  530.     from 0 (plain), 1 (bold), 3 (italic), 4 (underline), or
  531.     7 (reverse video). 0, 1, and 3 are about the only really useful
  532.     ones for text; 7 is the default for the mode line.
  533. amiga-text-foreground
  534. amiga-text-background
  535. amiga-mode-foreground
  536. amiga-mode-background
  537.     Set the system color used to draw the characters in the text area
  538.     and mode line.  Accepts a value between 0 and 7; the default for
  539.     the background is 0, the default for the text is 1.
  540. amiga-toggle-border
  541.     Switch your window between resizable and borderless. Lets you
  542.     take over the whole screen (80 columns! 48 lines in interlace!)
  543. SHAR_EOF
  544. cat << \SHAR_EOF > sys/amiga/Makefile.LATTICE
  545. #
  546. # Makefile for Amiga MG 2x, using Lattice small model.
  547. #
  548. # This Makefile uses the PD Make to be found on fish disk #69, expecting to
  549. # run lc and blink from Lattice version 4. The directory that holds this
  550. # makefile and the system-independent files should be named "mg", unless
  551. # TOP is changed to match.
  552. #
  553. #    This Makefile should be executed in the main Emacs directory.
  554. #
  555. # System-dependent conditional compilation possibilities:
  556. #
  557. #    V11        -- must be defined for the editor to either run on
  558. #               or compile on a version 1.1 AmigaDOS system.
  559. #               It mainly wards against bugs in the 1.1 ROM
  560. #               Kernel.
  561. #
  562. #    NO_STARTUP    -- if defined, code for using a startup file
  563. #               is not included.
  564. #
  565. #    MENU        -- if defined, Intuition menu selection is
  566. #               enabled.  If you #define this, the XOBJ macro
  567. #               must contain $(MENUOBJ).
  568. #
  569. #    BROWSER        -- BROWSER uses the Amiga menu to present a MENU of
  570. #               files. Selecting a directory entry (ends with a /)
  571. #               makes the contents if that directory the next menu
  572. #               (deleting any menus that used to follow it);
  573. #               selecting a plain file does a "find-file" on that
  574. #               file name. Really has to be seen to be understood.
  575. #               XOBJ must contain $(MENUOBJ) for this to link.
  576. #
  577. #    MOUSE        -- if defined, the Amiga mouse is active.
  578. #               If you #define this, XOBJ must contain $(MOUSEOBJ)
  579. #
  580. #    FKEYS        -- if defined, the editor understands the Amiga
  581. #               function keys.
  582. #
  583. #    NO_BACKUP    -- Disable the creation of backup files. If this
  584. #               option is defined, the function make-backup-files
  585. #               sets a flag that causes save-buffers (C-x C-s)
  586. #               to rename the original file to file~ before
  587. #               writing the file.  Nice if the space is available.
  588. #               By default, backup files are not made.  Calling
  589. #               make-backup-files with no argument enables this
  590. #               feature; calling it with an argument disables it.
  591. #
  592. #    DO_METAKEY    -- if defined, characters with high bit set (i.e.
  593. #               most ALT-ed characters in the usa0 keymap)
  594. #               are translated into internal META keys
  595. #
  596. #    DO_ICONIFY    -- if defined, provide a function to iconify the Emacs
  597. #               window into a gadget that can be double-clicked to
  598. #               return to the normal display.
  599. #
  600. #    CHANGE_COLOR    -- if defined, adds commands to manipulate
  601. #               the rendition of the mode line and the
  602. #               foreground and background color of the
  603. #               text window and mode line.  The names match
  604. #               the regular expression
  605. #               set-{text,mode}-{foreground,background}
  606. #    CHANGE_FONT    -- if defined, adds "set-font", which prompts
  607. #               for a font name and size, then tries to reopen
  608. #               the Emacs window using the new font.
  609. #    USE_ARP        -- Use the ARP (AmigaDOS Replacement Library) for
  610. #               some functions.  This makes the executable
  611. #               slightly smaller, but gives no new functionality
  612. #               in the current version.  It will probably be
  613. #               required for some future version.
  614. #        USE_ARP has not be tested with the LATTICE version
  615. #
  616. #
  617. #    MODE_RENDITION    -- the these values indicate the way to render
  618. #    TEXT_RENDITION       characters in the text area and mode line.
  619. #               TEXT_RENDITION is mainly there for completeness.
  620. #               Possible values are:
  621. #                0 -- plain text
  622. #                1 -- boldface
  623. #                3 -- italic
  624. #                4 -- underscore
  625. #                7 -- reverse-video (default if not defined)
  626. #
  627. #    TEXT_FG        -- specifies which system color (0-7) to use
  628. #    TEXT_BG           when drawing the text and mode line.  If they
  629. #    MODE_FG           aren't between 0 and 7, or if a combination
  630. #    MODE_BG           comes out badly, it's *YOUR* fault.  If
  631. #               CHANGE_COLOR is defined, you get to change these
  632. #               values on the fly.  Naturally, making both
  633. #               FG and BG the same results in an unusable display...
  634. #
  635. ############################################################################
  636. S    = sys/amiga
  637. TOP    = mg
  638. LIBS    = lib:lc.lib lib:amiga.lib
  639.  
  640. #
  641. # PREFS contains the defines used to select compile-time options.
  642. # XOBJ is used to denote any extra object files needed for these
  643. # options.  MENUOBJ and MOUSEOBJ denote the extra object files
  644. # needed for the menu, mouse and Browser. ARPOBJ is the extra
  645. # object file needed to use arp.library. REGEX is the binaries for the regular
  646. # expression code (requires -dREGEX). REGEX has not been tested under
  647. # Lattice 4.0
  648.  
  649. MOUSEOBJ = ttymouse.o
  650. MENUOBJ  = ttymenu.o menustack.o
  651. ICONIFYOBJ = iconify.o ttyicon.o
  652.  
  653. #
  654. # the following turn into files with no source in them if you compile with
  655. # the appropriate option turned off. Lattice incorrectly flags this as an error
  656. # instead of a warning. To get around this, you have to add the appropriate
  657. # #?OBJ macro to the XOBJ line for your configuration if you want it.
  658. # Ugly, but it works. There are probably other such things that I've missed.
  659. # The fix is to add a name here, put that on your xobj line, and delete it from
  660. # whichever of OBJ OOBJ or IND that the #?.o files lives in now.
  661. #
  662.  
  663. MACROOBJ = macro.o
  664. REGEXOBJ = regex.o re_search.o
  665. DIREDOBJ = dired.o
  666.  
  667. # The big burrito, with the Browser *and* the editing MENU.  Tough
  668. # on space, but boy is it neat...
  669. #PREFS = -dSTARTUP -dDO_METAKEY -dDO_ICONIFY -dCHANGE_FONT -dBACKUP -dFKEYS \
  670. #    -dMOUSE -dMENU -dBROWSER -dCHANGE_COLOR -dBINDKEY -dBSMAP=0
  671. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
  672.  
  673. # Burrito style, with just the Browser...
  674. #PREFS = -dSTARTUP  -dBROWSER -dMOUSE -dCHANGE_COLOR -dFKEYS -dDO_ICONIFY \
  675. #    -dDO_METAKEY -dBACKUP
  676. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
  677.  
  678. # Burrito style, with just the menu... # untested for mg2
  679. #PREFS = -dSTARTUP  -dMENU -dMOUSE -dCHANGE_COLOR -dFKEYS -dDO_ICONIFY \
  680. #    -dDO_METAKEY -dBACKUP -dBSMAP=0
  681. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
  682.  
  683.  
  684. # Mike's favorite version
  685. PREFS = -dMOUSE -dBROWSER -dMODE_RENDITION=0 -dMODE_FG=2 -dDO_METAKEY \
  686.     -dGOSREC -dGOSMACS -dDO_ICONIFY -dNO_STARTUP -dNO_DIRED -dBSMAP=1
  687. XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ)
  688.  
  689. # Mic's favorite version # untested for mg2
  690. #PREFS = -dSTARTUP -dBROWSER -dMENU -dMOUSE -dCHANGE_FONT -dFKEYS
  691. #    -dDO_METAKEY -dDO_ICONIFY -dBACKUP -dPREFIXREGION
  692. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
  693.  
  694. # Steve's favorite version # untested for mg2
  695. #PREFS  = -dSTARTUP -dMOUSE -dCHANGE_FONT -dFKEYS -dDO_METAKEY \
  696. #     -dBACKUP -dPREFIXREGION -dUSE_ARP
  697. #XOBJ   = $(MOUSEOBJ) $(MACROOBJ) $(DIREDOBJ)
  698.  
  699. # Absolutely bare-bones, default editor
  700. #PREFS = -dDO_METAKEY
  701. #XOBJ  =
  702.  
  703. CC    = lc
  704. AS    = asm
  705. CFLAGS    = -i$(S)/ -isys/default/ $(PREFS) -dAMIGA -dLATTICE -b -qram:
  706.  
  707. # Objects which only depend on the "standard" includes
  708. OBJS    = basic.o dir.o file.o line.o match.o paragraph.o \
  709.       random.o region.o search.o version.o window.o word.o
  710.  
  711. # Those with unique requirements
  712. IND    = buffer.o display.o echo.o extend.o help.o kbd.o keymap.o \
  713.       main.o modes.o
  714.  
  715. # System dependent objects
  716. OOBJS = cinfo.o spawn.o ttyio.o tty.o ttykbd.o fileio.o sleep.o \
  717.     sysinit.o console.o dirio.o offset.o
  718.  
  719. OBJ = $(OBJS) $(IND) $(OOBJS) $(XOBJ)
  720.  
  721. OSRCS    = cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c fileio.c sleep.c \
  722.       sysinit.c console.c dirio.c amiga_maps.c offset.c
  723. SRCS    = basic.c dir.c dired.c file.c line.c match.c paragraph.c \
  724.       random.c region.c search.c version.c window.c word.c \
  725.       buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \
  726.       macro.c main.c modes.c regex.c re_search.c
  727.  
  728. OINCS =    $(S)/ttydef.h $(S)/sysdef.h sys/default/chrdef.h
  729. INCS =    def.h
  730.  
  731.  
  732. #
  733. # The editor
  734. # Building in Ram: saves a LOT of time in pass 2 of the linker.
  735. #
  736. mg:        $(OBJ)
  737.         blink lib:c.o $(OBJ) lib $(LIBS) to mg map nil: \
  738.         SMALLCODE SMALLDATA NODEBUG
  739.  
  740. # From the Manx version forget it for now.
  741. #
  742. # lint:
  743. #     lint +vm -ilint: -e7?? $(CFLAGS) std.lnt mg
  744. #
  745.  
  746. $(OBJ):        $(INCS) $(OINCS)
  747.  
  748. dir.o search.o:    $(INCS) $(OINCS)
  749.  
  750. regex.o re_search.o:    $(INCS) $(OINCS) regex.h
  751.  
  752. kbd.o:    $(INCS) $(OINCS) macro.h kbd.h key.h
  753.  
  754. macro.o main.o:    $(INCS) $(OINCS) macro.h
  755.  
  756. buffer.o display.o keymap.o help.o modes.o dired.o fileio.o: \
  757.     $(INCS) $(OINCS) kbd.h
  758.  
  759. extend.o:    $(INCS) $(OINCS) kbd.h macro.h key.h
  760.  
  761. help.o:    $(INCS) $(OINCS) kbd.h key.h macro.h
  762.  
  763. echo.o:    $(INCS) $(OINCS) key.h macro.h
  764.  
  765. $(OOBJS):    $(INCS) $(OINCS)
  766.  
  767. clean:
  768.     Delete $(OBJ)
  769.  
  770.  
  771. fileio.o:    $(S)/fileio.c
  772.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/fileio.c
  773.  
  774. spawn.o:    $(S)/spawn.c
  775.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/spawn.c
  776.  
  777. sleep.o:    $(S)/sleep.c
  778.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/sleep.c
  779.  
  780. sysinit.o:    $(S)/sysinit.c
  781.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/sysinit.c
  782.  
  783. offset.o:    $(S)/offset.c
  784.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/offset.c
  785.  
  786. iconify.o:    $(S)/iconify/iconify.c $(S)/iconify/iconify.h
  787.         $(CC) $(CFLAGS) -o/$(TOP)/ -i$(S)/iconify/ $(S)/iconify/iconify.c
  788.  
  789. tty.o:        $(S)/tty.c
  790.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/tty.c
  791.  
  792. ttyicon.o:    $(S)/ttyicon.c
  793.         $(CC) $(CFLAGS) -o/$(TOP)/ -i$(S)/iconify/ $(S)/ttyicon.c
  794.  
  795. ttyio.o:    $(S)/ttyio.c
  796.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttyio.c
  797.  
  798. ttykbd.o:    $(S)/ttykbd.c
  799.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttykbd.c
  800.  
  801. ttymenu.o:    $(S)/ttymenu.c
  802.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttymenu.c
  803.  
  804. ttymouse.o:    $(S)/ttymouse.c
  805.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttymouse.c
  806.  
  807. menustack.o:    $(S)/menustack.c
  808.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/menustack.c
  809.  
  810. console.o:    $(S)/console.c
  811.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/console.c
  812.  
  813. dirio.o:    $(S)/dirio.c
  814.         $(CC) $(CFLAGS) -o/$(TOP)/ $(S)/dirio.c
  815.  
  816. arpbind.o:    $(S)/arpbind.asm $(S)/arpbase.i
  817.         $(AS) -o arpbind.o -i$(S)/ -isys2:asm/ $(S)/arpbind.asm
  818.  
  819. alloca.o:    $(S)/alloca.asm
  820.         $(AS) -o alloca.o $(S)/alloca.asm
  821.  
  822. keymap.o:    keymap.c $(S)/amiga_maps.c
  823.         $(CC) $(CFLAGS) -o/$(TOP)/ keymap.c
  824.  
  825. cinfo.o:    sys/default/cinfo.c
  826.         $(CC) $(CFLAGS) -o/$(TOP)/ sys/default/cinfo.c
  827. SHAR_EOF
  828. cat << \SHAR_EOF > sys/amiga/Makefile.MANX
  829. #
  830. # Makefile for Amiga MG 2x, using Manx small model.
  831. #
  832. # This Makefile should be executed in the main Emacs directory.
  833. #
  834. # System-dependent conditional compilation possibilities:
  835. #
  836. # V11  -- must be defined for the editor to either run on
  837. #      or compile on a version 1.1 AmigaDOS system.
  838. #      It mainly wards against bugs in the 1.1 ROM
  839. #      Kernel.
  840. #
  841. # NO_STARTUP -- if defined, code for using a startup file
  842. #      is not included.
  843. #
  844. # MENU  -- if defined, Intuition menu selection is
  845. #      enabled.  If you #define this, the XOBJ macro
  846. #      must contain $(MENUOBJ).
  847. #
  848. # BROWSER  -- BROWSER uses the Amiga menu to present a MENU of
  849. #      files. Selecting a directory entry (ends with a /)
  850. #      makes the contents if that directory the next menu
  851. #      (deleting any menus that used to follow it);
  852. #      selecting a plain file does a "find-file" on that
  853. #      file name. Really has to be seen to be understood.
  854. #      XOBJ must contain $(MENUOBJ) for this to link.
  855. #
  856. # MOUSE  -- if defined, the Amiga mouse is active.
  857. #      If you #define this, XOBJ must contain $(MOUSEOBJ)
  858. #
  859. # FKEYS  -- if defined, the editor understands the Amiga
  860. #      function keys.
  861. #
  862. # NO_BACKUP -- Disable the creation of backup files. If this
  863. #      option is defined, the function make-backup-files
  864. #      sets a flag that causes save-buffers (C-x C-s)
  865. #      to rename the original file to file~ before
  866. #      writing the file.  Nice if the space is available.
  867. #      By default, backup files are not made.  Calling
  868. #      make-backup-files with no argument enables this
  869. #      feature; calling it with an argument disables it.
  870. #
  871. # DO_METAKEY -- if defined, characters with high bit set (i.e.
  872. #      most ALT-ed characters in the usa0 keymap)
  873. #      are translated into internal META keys
  874. #
  875. # DO_ICONIFY -- if defined, provide a function to iconify the Emacs
  876. #      window into a gadget that can be double-clicked to
  877. #      return to the normal display.
  878. #
  879. # CHANGE_COLOR -- if defined, adds commands to manipulate
  880. #      the rendition of the mode line and the
  881. #      foreground and background color of the
  882. #      text window and mode line.  The names match
  883. #      the regular expression
  884. #      set-{text,mode}-{foreground,background}
  885. # CHANGE_FONT -- if defined, adds "set-font", which prompts
  886. #      for a font name and size, then tries to reopen
  887. #      the Emacs window using the new font.
  888. # USE_ARP  -- Use the ARP (AmigaDOS Replacement Library) for
  889. #      some functions.  This makes the executable
  890. #      slightly smaller, but gives no new functionality
  891. #      in the current version.  It will probably be
  892. #      required for some future version.  Note that
  893. #      LIBS needs to be changed to "-la -lc" if you
  894. #      use ARP.
  895. #
  896. #
  897. # MODE_RENDITION -- the these values indicate the way to render
  898. # TEXT_RENDITION    characters in the text area and mode line.
  899. #      TEXT_RENDITION is mainly there for completeness.
  900. #      Possible values are:
  901. #    0 -- plain text
  902. #    1 -- boldface
  903. #    3 -- italic
  904. #    4 -- underscore
  905. #    7 -- reverse-video (default if not defined)
  906. #
  907. # TEXT_FG  -- specifies which system color (0-7) to use
  908. # TEXT_BG     when drawing the text and mode line.  If they
  909. # MODE_FG     aren't between 0 and 7, or if a combination
  910. # MODE_BG     comes out badly, it's *YOUR* fault.  If
  911. #      CHANGE_COLOR is defined, you get to change these
  912. #      values on the fly.  Naturally, making both
  913. #      FG and BG the same results in an unusable display...
  914. #
  915. ############################################################################
  916. SYS = amiga
  917. S = sys/amiga
  918. LIBS = -lc
  919.  
  920. #
  921. # PREFS contains the defines used to select compile-time options.
  922. # XOBJ is used to denote any extra object files needed for these
  923. # options.  MENUOBJ and MOUSEOBJ denote the extra object files
  924. # needed for the menu, mouse and Browser.
  925.  
  926. MOUSEOBJ = ttymouse.o
  927. MENUOBJ  = ttymenu.o menustack.o
  928. OFFSETOBJ = offset.o
  929. ICONIFYOBJ = iconify.o ttyicon.o
  930.  
  931. # The big burrito, with the Browser *and* the editing MENU.  Tough
  932. # on space, but boy is it neat...
  933. PREFS = -DSTARTUP -DDO_METAKEY -DDO_ICONIFY -DCHANGE_FONT -DCHANGE_COLOR \
  934.  -DBACKUP -DFKEYS -DMOUSE -DMENU -DBROWSER
  935. XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ)
  936.  
  937. # Burrito style, with just the Browser...
  938. #PREFS = -DSTARTUP  -DBROWSER -DMOUSE -DCHANGE_COLOR -DFKEYS -DDO_ICONIFY -DDO_M
  939. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(OFFSETOBJ) $(ICONIFYOBJ)
  940.  
  941. # Burrito style, with just the menu...
  942. #PREFS = -DSTARTUP  -DMENU -DMOUSE -DCHANGE_COLOR -DFKEYS -DDO_ICONIFY -DDO_META
  943. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(OFFSETOBJ) $(ICONIFYOBJ)
  944.  
  945.  
  946. # Mike's favorite version
  947. #PREFS = -DMOUSE -DBROWSER -DMODE_RENDITION=0 -DMODE_FG=2 -DDO_METAKEY \
  948. # -DGOSREC -DV11 -DMEYN
  949. #XOBJ = $(MOUSEOBJ) $(MENUOBJ)
  950.  
  951. # Mic's favorite version
  952. #PREFS = -DSTARTUP -DMENU -DMOUSE -DCHANGE_FONT -DFKEYS
  953. # -DDO_METAKEY -DDO_ICONIFY -DBACKUP -DPREFIXREGION
  954. #XOBJ  = $(MOUSEOBJ) $(MENUOBJ) $(OFFSETOBJ) $(ICONIFYOBJ)
  955.  
  956. # Steve's favorite version
  957. #PREFS  = -DSTARTUP -DMOUSE -DCHANGE_FONT -DFKEYS -DDO_METAKEY \
  958. #  -DBACKUP -DPREFIXREGION -DUSE_ARP
  959. #XOBJ   = $(MOUSEOBJ)
  960. # Notice the "-la" here to use ARP's library as well as the standard one.
  961. #LIBS = -la -lc
  962.  
  963. # Absolutely bare-bones, default editor
  964. #PREFS = -DDO_METAKEY
  965. #XOBJ  =
  966.  
  967. CFLAGS = -I$(S) -Isys/default $(PREFS) -DAMIGA -DMANX -DBINDKEY
  968.  
  969. # Objects which only depend on the "standard" includes
  970. OBJS = basic.o dir.o dired.o file.o line.o match.o paragraph.o \
  971.    random.o region.o search.o version.o window.o word.o
  972.  
  973. # Those with unique requirements
  974. IND = buffer.o display.o echo.o extend.o help.o kbd.o keymap.o \
  975.    macro.o main.o modes.o regex.o re_search.o
  976.  
  977. # System dependent objects
  978. OOBJS = cinfo.o spawn.o ttyio.o tty.o ttykbd.o fileio.o sleep.o \
  979.  sysinit.o malloc.o console.o dirio.o
  980.  
  981. OBJ = $(OBJS) $(IND) $(OOBJS) $(XOBJ)
  982.  
  983. OSRCS = cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c fileio.c sleep.c \
  984.    sysinit.c malloc.c console.c dirio.c
  985. SRCS = basic.c dir.c dired.c file.c line.c match.c paragraph.c \
  986.    random.c region.c search.c version.c window.c word.c \
  987.    buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \
  988.    macro.c main.c modes.c regex.c re_search.c
  989.  
  990. OINCS = $(S)/ttydef.h $(S)/sysdef.h sys/default/chrdef.h
  991. INCS = def.h
  992.  
  993.  
  994. #
  995. # The editor
  996. # Building in Ram: saves a LOT of time in pass 2 of the linker.
  997. #
  998. mg:        $(OBJ)
  999.         ln -o ram:mg -w $(OBJ) $(LIBS)
  1000.         copy ram:mg mg
  1001.         delete ram:mg
  1002.  
  1003. lint:
  1004.     lint +vm -ilint: -e7?? $(CFLAGS) std.lnt mg
  1005.  
  1006. $(OBJ):        $(INCS) $(OINCS)
  1007.  
  1008. dir.o search.o:    $(INCS) $(OINCS)
  1009.  
  1010. regex.o re_search.o:    $(INCS) $(OINCS) regex.h
  1011.  
  1012. kbd.o:    $(INCS) $(OINCS) macro.h kbd.h key.h
  1013.  
  1014. macro.o main.o:    $(INCS) $(OINCS) macro.h
  1015.  
  1016. buffer.o display.o keymap.o help.o modes.o dired.o fileio.o: \
  1017.     $(INCS) $(OINCS) kbd.h
  1018.  
  1019. extend.o:    $(INCS) $(OINCS) kbd.h macro.h key.h
  1020.  
  1021. help.o:    $(INCS) $(OINCS) kbd.h key.h macro.h
  1022.  
  1023. echo.o:    $(INCS) $(OINCS) key.h macro.h
  1024.  
  1025. $(OOBJS):    $(INCS) $(OINCS)
  1026.  
  1027. clean:
  1028.     Delete $(OBJ)
  1029.  
  1030.  
  1031. fileio.o:    $(S)/fileio.c
  1032.         cc $(CFLAGS) -o fileio.o $(S)/fileio.c
  1033.  
  1034. spawn.o:    $(S)/spawn.c
  1035.         cc $(CFLAGS) -o spawn.o $(S)/spawn.c
  1036.  
  1037. sleep.o:    $(S)/sleep.c
  1038.         cc $(CFLAGS) -o sleep.o $(S)/sleep.c
  1039.  
  1040. sysinit.o:    $(S)/sysinit.c
  1041.         cc $(CFLAGS) -o sysinit.o $(S)/sysinit.c
  1042.  
  1043. malloc.o:    $(S)/malloc.c
  1044.         cc $(CFLAGS) -o malloc.o $(S)/malloc.c
  1045.  
  1046. offset.o:    $(S)/offset.c
  1047.         cc $(CFLAGS) -o offset.o $(S)/offset.c
  1048.  
  1049. iconify.o:    $(S)/iconify/iconify.c $(S)/iconify/iconify.h
  1050.         cc $(CFLAGS) -I$(S)/iconify -o iconify.o $(S)/iconify/iconify.c
  1051.  
  1052. tty.o:        $(S)/tty.c
  1053.         cc $(CFLAGS) -o tty.o $(S)/tty.c
  1054.  
  1055. ttyicon.o:    $(S)/ttyicon.c
  1056.         cc $(CFLAGS) -I$(S)/iconify -o ttyicon.o $(S)/ttyicon.c
  1057.  
  1058. ttyio.o:    $(S)/ttyio.c
  1059.         cc $(CFLAGS) -o ttyio.o $(S)/ttyio.c
  1060.  
  1061. ttykbd.o:    $(S)/ttykbd.c
  1062.         cc $(CFLAGS) -o ttykbd.o $(S)/ttykbd.c
  1063.  
  1064. ttymenu.o:    $(S)/ttymenu.c
  1065.         cc $(CFLAGS) -o ttymenu.o $(S)/ttymenu.c
  1066.  
  1067. ttymouse.o:    $(S)/ttymouse.c
  1068.         cc $(CFLAGS) -o ttymouse.o $(S)/ttymouse.c
  1069.  
  1070. menustack.o:    $(S)/menustack.c
  1071.         cc $(CFLAGS) -o menustack.o $(S)/menustack.c
  1072.  
  1073. console.o:    $(S)/console.c
  1074.         cc $(CFLAGS) -o console.o $(S)/console.c
  1075.  
  1076. dirio.o:    $(S)/dirio.c
  1077.         cc $(CFLAGS) -o dirio.o $(S)/dirio.c
  1078.  
  1079. arpbind.o:    $(S)/arpbind.asm $(S)/arpbase.i
  1080.         as -o arpbind.o -I$(S) -Isys2:asm $(S)/arpbind.asm
  1081.  
  1082. alloca.o:    $(S)/alloca.asm
  1083.         as -o alloca.o $(S)/alloca.asm
  1084.  
  1085. keymap.o:    keymap.c $(S)/amiga_maps.c
  1086.         cc $(CFLAGS) -Z4000 keymap.c
  1087.  
  1088. cinfo.o:    sys/default/cinfo.c
  1089.         cc $(CFLAGS) -o cinfo.o sys/default/cinfo.c
  1090. SHAR_EOF
  1091. cat << \SHAR_EOF > sys/amiga/amiga_maps.c
  1092. /*
  1093.  * Name:    MG 2a
  1094.  *        keymap.c setup for Amiga-specific function keys.
  1095.  * Created:    14-May-1988 Mic Kaczmarczik (mic@emx.utexas.edu)
  1096.  * Last edit:    14-May-1988 Mic Kaczmarczik
  1097.  *
  1098.  * One big table for coding convenience, because the number of different
  1099.  * compilation possibilities makes setting up data structures kind of
  1100.  * tricky.  Once again for convenience, the file is #included into keymap.c
  1101.  * instead of being linked.  I tried to minimize the changes to keymap.c,
  1102.  * while making it possible to have the Amiga function/arrow keys in dired
  1103.  * mode as well as fundamental mode.  In the future, we might want to
  1104.  * rebind some of the function keys in dired mode, but for right now they
  1105.  * do the same thing as in fundamental mode.
  1106.  */
  1107.  
  1108. static    PF    amiga_keys[] = {
  1109. #ifdef    FKEYS
  1110.     backline,    /* Up            (0x100)    */
  1111.     forwline,    /* Down                */
  1112.     backchar,    /* Left                */
  1113.     forwchar,    /* Right            */
  1114.     gotobop,    /* Shift-Up            */
  1115.     gotoeop,    /* Shift-Down            */
  1116.     backword,    /* Shift-Left            */
  1117.     forwword,    /* Shift-Right            */
  1118.     desckey,    /* Help            (0x108)    */
  1119. #else
  1120.     /* 9 unbound keys */
  1121.     rescan, rescan, rescan, rescan, rescan, rescan, rescan, rescan, rescan, 
  1122. #endif
  1123.  
  1124. #ifdef    DO_MENU
  1125.     amigamenu,    /* Menu selction    (0x109)    */
  1126. #else
  1127.     rescan,        /* Menu selection    (0x109)    */
  1128. #endif
  1129.     refresh,    /* Resize window    (0x10A)    */
  1130.     rescan,        /* used to be Mouse        */
  1131.  
  1132. #ifdef    FKEYS
  1133.     filevisit,    /* F1            (0x10C)    */
  1134.     filesave,    /* F2                */
  1135.     forwpage,    /* F3                */
  1136.     enlargewind,    /* F4                */
  1137.     fillpara,    /* F5                */
  1138.     splitwind,    /* F6                */
  1139.     twiddle,    /* F7                */
  1140.     definemacro,    /* F8                */
  1141.     executemacro,    /* F9                */
  1142.     listbuffers,    /* F10                */
  1143.     poptofile,    /* Shift-F1        (0x116)    */
  1144.     filewrite,    /* Shift-F2            */
  1145.     backpage,    /* Shift-F3            */
  1146.     shrinkwind,    /* Shift-F4            */
  1147.     queryrepl,    /* Shift-F5            */
  1148.     onlywind,    /* Shift-F6            */
  1149.     justone,    /* Shift-F7            */
  1150.     finishmacro,    /* Shift-F8            */
  1151.     wallchart,    /* Shift-F9            */
  1152.     quit,        /* Shift-F10        (0x11F)    */
  1153. #else
  1154.     rescan, rescan, rescan, rescan, rescan,    /* 20 unbound keys */
  1155.     rescan, rescan, rescan, rescan, rescan,
  1156.     rescan, rescan, rescan, rescan, rescan,
  1157.     rescan, rescan, rescan, rescan, rescan,
  1158. #endif
  1159.  
  1160. #ifdef    MOUSE
  1161.     amigamouse,    /* Mouse        (0x120)    */
  1162.     mforwdel,    /* Ctrl-Mouse            */
  1163.     mreposition,    /* Shift-Mouse            */
  1164.     mdelwhite,    /* Shift-Ctrl-Mouse        */
  1165.     mdelfword,    /* Meta-Mouse            */
  1166.     mkillregion,    /* Meta-Ctrl-Mouse        */
  1167.     mkillline,    /* Meta-Shift-Mouse        */
  1168.     myank,        /* Meta-Shift-Ctrl-Mouse    */
  1169.     mforwpage,    /* Mode-Mouse        (0x128)    */
  1170.     mgotobob,    /* Ctrl-Mode-Mouse        */
  1171.     mbackpage,    /* Shift-Mode-Mouse        */
  1172.     mgotoeob,    /* Shift-Ctrl-Mode-Mouse    */
  1173.     msplitwind,    /* Meta-Mode-Mouse        */
  1174.     menlargewind,    /* Meta-Ctrl-Mode-Mouse        */
  1175.     mdelwind,    /* Meta-Shift-Mode-Mouse    */
  1176.     mshrinkwind,    /* Meta-Shift-Ctrl-Mode-Mouse    */
  1177. #ifdef    DO_ICONIFY
  1178.     tticon,        /* Echo-Mouse        (0x130)    */
  1179. #else
  1180.     usebuffer,    /* Echo-Mouse        (0x130)    */
  1181. #endif
  1182.     spawncli,    /* Ctrl-Echo-Mouse        */
  1183.     killbuffer,    /* Shift-Echo-Mouse        */
  1184.     quit,        /* Shift-Ctrl-Echo-Mouse    */
  1185.     desckey,    /* Meta-Echo-Mouse        */
  1186.     listbuffers,    /* Meta-Ctrl-Echo-Mouse        */
  1187.     wallchart,    /* Meta-Shift-Echo-Mouse    */
  1188.     togglewindow,    /* Meta-Shift-Ctrl-Echo-Mouse    */
  1189. #endif    MOUSE
  1190. };
  1191.  
  1192.  
  1193. /*
  1194.  * Define extra maps for fundamental mode.  Have to provide the number of
  1195.  * extra map segments because it's used by the KEYMAPE() macro that builds
  1196.  * keymaps.  The keymap setup, while compact, is pretty complex...
  1197.  */
  1198.  
  1199. #define    NFUND_XMAPS    1
  1200.  
  1201. #ifdef    MOUSE
  1202. #define    FUND_XMAPS    {KUP,    KEASCMOUSE,    amiga_keys,    (KEYMAP*)NULL}
  1203. #else
  1204. #define    FUND_XMAPS    {KUP,    KSF10,        amiga_keys,    (KEYMAP*)NULL}
  1205. #endif
  1206.  
  1207. /*
  1208.  * Extra map segments for dired mode -- just use fundamental mode segments
  1209.  */
  1210. #define    NDIRED_XMAPS    NFUND_XMAPS
  1211. #define    DIRED_XMAPS    FUND_XMAPS
  1212.  
  1213. SHAR_EOF
  1214. cat << \SHAR_EOF > sys/amiga/console.c
  1215. /*
  1216.  * These functions are taken directly from the
  1217.  * console.device chapter in the Amiga V1.1
  1218.  * ROM Kernel Manual.
  1219.  */
  1220. #include <exec/types.h>
  1221. #include <exec/io.h>
  1222. #include <devices/console.h>
  1223. #include <libraries/dos.h>
  1224. #include <intuition/intuition.h>
  1225.  
  1226. extern    LONG    OpenDevice();
  1227. extern    LONG    DoIO();
  1228. extern    LONG    SendIO();
  1229.  
  1230. /*
  1231.  * Open a console device, given a read request
  1232.  * and a write request message.
  1233.  */
  1234.  
  1235. int OpenConsole(writerequest,readrequest,window)
  1236. struct IOStdReq *writerequest;
  1237. struct IOStdReq *readrequest;
  1238. struct Window *window;
  1239. {
  1240.     LONG error; 
  1241.     writerequest->io_Data = (APTR) window;
  1242.     writerequest->io_Length = (ULONG) sizeof(*window);
  1243.     error = OpenDevice("console.device", 0L, writerequest, 0L);
  1244.  
  1245.     /* clone required parts of the request */
  1246.     if (readrequest) {
  1247.         readrequest->io_Device = writerequest->io_Device;
  1248.         readrequest->io_Unit   = writerequest->io_Unit;
  1249.     }
  1250.     return((int) error);
  1251. }
  1252.  
  1253. /*
  1254.  * Output a single character    
  1255.  * to a specified console
  1256.  */ 
  1257.  
  1258. int ConPutChar(request,character)
  1259. struct IOStdReq *request;
  1260. char character;
  1261. {
  1262. #ifdef    V11
  1263.     register int x;
  1264. #endif
  1265.     request->io_Command = CMD_WRITE;
  1266.     request->io_Data = (APTR)&character;
  1267.     request->io_Length = (ULONG)1;
  1268.     DoIO(request);
  1269.     /* caution: read comments in manual! */
  1270.     return(0);
  1271. }
  1272.  
  1273. /*
  1274.  * Output a NULL-terminated string of
  1275.  * characters to a console
  1276.  */ 
  1277.  
  1278. int ConPutStr(request,string)
  1279. struct IOStdReq *request;
  1280. char *string;
  1281. {
  1282. #ifdef    V11
  1283.     register int x;
  1284. #endif
  1285.     request->io_Command = CMD_WRITE;
  1286.     request->io_Data = (APTR)string;
  1287.     request->io_Length = (LONG)-1;
  1288.     DoIO(request);
  1289.     return(0);
  1290. }
  1291.  
  1292. /*
  1293.  * Write out a string of predetermined
  1294.  * length to the console
  1295.  */
  1296.  
  1297. int ConWrite(request,string,len)
  1298. struct IOStdReq *request;
  1299. char *string;
  1300. int len;
  1301. {
  1302. #ifdef    V11
  1303.     register int x;
  1304. #endif
  1305.     request->io_Command = CMD_WRITE;
  1306.     request->io_Data = (APTR)string;
  1307.     request->io_Length = (LONG)len;
  1308.     DoIO(request);
  1309.     return(0);
  1310. }
  1311.  
  1312. /*
  1313.  * Queue up a read request 
  1314.  * to a console
  1315.  */
  1316.  
  1317. int QueueRead(request,whereto)
  1318. struct IOStdReq *request;
  1319. char *whereto;
  1320. {
  1321. #ifdef    V11
  1322.     register int x;
  1323. #endif
  1324.     request->io_Command = CMD_READ;
  1325.     request->io_Data = (APTR)whereto;
  1326.     request->io_Length = (LONG)1;
  1327.     SendIO(request);
  1328.     return(0);
  1329. }
  1330.  
  1331. SHAR_EOF
  1332. cat << \SHAR_EOF > sys/amiga/dirio.c
  1333. /*
  1334.  * Name:    MG 2x
  1335.  *        Directory I/O routines, by Stephen Walton
  1336.  *        Version of 5-May-88
  1337.  */
  1338.  
  1339. #ifndef NO_DIR
  1340.  
  1341. #include "sysdef.h"
  1342. #include <libraries/dosextens.h>
  1343. #include <exec/memory.h>
  1344.  
  1345. extern    char        MyDirName[MAXPATH], *strncat();
  1346.  
  1347. char *getwd(path)
  1348. char *path;
  1349. {
  1350.     strcpy(path,MyDirName);
  1351.     return path;
  1352. }
  1353.  
  1354. chdir(path)
  1355. char *path;
  1356. {
  1357.     BPTR Lock(), AttemptLock, CurrentDir();
  1358.     long PathName(), len;
  1359.     struct FileInfoBlock *fib;
  1360.     void *AllocMem();
  1361.     int retval;
  1362.  
  1363.     AttemptLock = Lock(path, ACCESS_READ);
  1364.     if (!AttemptLock)
  1365.         return -1;
  1366.     fib = (struct FileInfoBlock *) AllocMem((long)
  1367.                             sizeof(struct FileInfoBlock),
  1368.                         MEMF_CLEAR);
  1369.     Examine(AttemptLock, fib);
  1370.     if (fib->fib_DirEntryType < 0) {
  1371.         retval = -1;
  1372.         UnLock(AttemptLock);
  1373.         goto clean;
  1374.     }
  1375.     UnLock(CurrentDir(AttemptLock));    /* do the thing        */
  1376.     if (PathName(AttemptLock, MyDirName, MAXPATH/31L) == 0)
  1377.         MyDirName[0] = '\0';
  1378.     retval = 0;                /* Success!        */
  1379.     clean:
  1380.     FreeMem((void *) fib, (long) sizeof(struct FileInfoBlock));
  1381.     return retval;
  1382. }
  1383. #endif
  1384. SHAR_EOF
  1385. cat << \SHAR_EOF > sys/amiga/fileio.c
  1386. /*
  1387.  * Name:    MG 2a401
  1388.  *        Commodore Amiga file I/O.
  1389.  * Last edit:    05-May-88 swalton@solar.stanford.edu
  1390.  * Next-to-Last edit:    16-Dec-87 mic@emx.utexas.edu
  1391.  * Created:    23-Jul-86 mic@emx.utexas.edu
  1392.  *
  1393.  * Read and write ASCII files. All of the low level file I/O
  1394.  * knowledge is here.  Uses AmigaDOS standard I/O and does its
  1395.  * own dynamic buffering; this seems to save about 2K worth
  1396.  * of space in the executable image.
  1397.  */
  1398.  
  1399. #ifdef        LATTICE
  1400. #include    <string.h>
  1401. #include    <exec/types.h>
  1402. #endif
  1403. #include    <exec/memory.h>
  1404. #include    <libraries/dos.h>
  1405. #include    <libraries/dosextens.h>
  1406. #ifdef        USE_ARP
  1407. #include    "libraries/arpbase.h"
  1408. #else
  1409. #define FCHARS    32L
  1410. #endif
  1411.  
  1412. #undef    TRUE
  1413. #undef    FALSE
  1414. #include    "def.h"
  1415.  
  1416. #define    NIOBUF            4096
  1417.  
  1418. extern ULONG            Rename(), UnLock(), Close(), FreeMem();
  1419. extern LONG            Write(), Read();
  1420. extern UBYTE            *AllocMem();
  1421. extern struct FileLock        *Lock();
  1422. extern struct FileHandle    *Open();
  1423.  
  1424. static struct FileHandle    *ffh = 0;
  1425. static UBYTE            *iobuf;
  1426. static int            ibufo, niobuf;
  1427. static LONG            iostat, access_mode;
  1428. #ifdef    MANX
  1429. extern char            *strncpy(), *strncat(), *index(), *rindex();
  1430. #endif
  1431. #ifdef    LATTICE
  1432. extern char            *malloc() ;
  1433. #define    index    strchr
  1434. #define rindex    strrchr
  1435. #endif
  1436.  
  1437. #define    getch()        (ibufo == niobuf) ? FillBuf() : iobuf[ibufo++]
  1438. #define putch(c)    {if (niobuf == NIOBUF) FlushBuf(); iobuf[niobuf++] = c;}
  1439.  
  1440. /*
  1441.  * Open the Emacs internal file for reading.
  1442.  */
  1443. ffropen(fn)
  1444. char    *fn;
  1445. {
  1446.     if ((iobuf = AllocMem((ULONG) NIOBUF, 0L)) == NULL)
  1447.         return (FIOERR);
  1448.  
  1449.     if ((ffh = Open(fn, access_mode = MODE_OLDFILE)) == 0L) {
  1450.         FreeMem(iobuf, (ULONG) NIOBUF);
  1451.         return (FIOFNF);
  1452.     }
  1453.     ibufo = niobuf = 0;
  1454.     return (FIOSUC);
  1455. }
  1456.  
  1457. /*
  1458.  * Open a file for writing.  Return TRUE if all
  1459.  * is well, and FALSE on error (cannot create).
  1460.  */
  1461.  
  1462. ffwopen(fn)
  1463. char    *fn;
  1464. {
  1465.     if ((iobuf = AllocMem((ULONG) NIOBUF, 0L)) == NULL)
  1466.         return (FIOERR);
  1467.     if ((ffh = Open(fn, access_mode = MODE_NEWFILE)) == 0L) {
  1468.         ewprintf("Cannot open file for writing");
  1469.         FreeMem(iobuf, (ULONG) NIOBUF);
  1470.         return (FIOERR);
  1471.     }
  1472.     niobuf = 0;
  1473.     iostat = NIOBUF;    /* pretend we wrote out a full buffer last time */
  1474.     return (FIOSUC);
  1475. }
  1476.  
  1477. /*
  1478.  * Close a file, flushing the output buffer.  Should look at
  1479.  * the status.
  1480.  */
  1481. ffclose()
  1482. {
  1483.     if (access_mode == MODE_NEWFILE)
  1484.         FlushBuf();
  1485.     if (ffh)
  1486.         (void) Close(ffh);
  1487.     if (iobuf)
  1488.         FreeMem(iobuf, (ULONG) NIOBUF);
  1489.     return (FIOSUC);
  1490. }
  1491.  
  1492. /*
  1493.  * Write a buffer to the already opened file. bp points to the
  1494.  * buffer. Return the status. Check only at the newline and
  1495.  * end of buffer.
  1496.  */
  1497. ffputbuf(bp)
  1498. BUFFER *bp;
  1499. {
  1500.     register char *cp;
  1501.     register char *cpend;
  1502.     register LINE *lp;
  1503.     register LINE *lpend;
  1504.  
  1505.     lpend = bp->b_linep;
  1506.     lp = lforw(lpend);
  1507.     do {
  1508.     cp = <ext(lp)[0];        /* begining of line    */
  1509.     cpend = &cp[llength(lp)];    /* end of line        */
  1510.     while(cp != cpend)
  1511.         putch(*(cp++));        /* putch only evalutes its arg once */
  1512.     lp = lforw(lp);
  1513.     if(lp == lpend) break;        /* no implied newline on last line */
  1514.     putch('\n');
  1515.     } while(iostat > 0L);
  1516.  
  1517.     if(iostat == -1L) {
  1518.     ewprintf("Write I/O error");
  1519.     return FIOERR;
  1520.     }
  1521.     return FIOSUC;
  1522. }
  1523.  
  1524. /*
  1525.  * Read a line from a file, and store the bytes
  1526.  * in the supplied buffer. Stop on end of file or end of
  1527.  * line.  When FIOEOF is returned, there is a valid line
  1528.  * of data without the normally implied \n.
  1529.  */
  1530. ffgetline(buf, nbuf, nbytes)
  1531. register char    *buf;
  1532. register int    nbuf;
  1533. register int    *nbytes;
  1534. {
  1535.     register int    c;
  1536.     register int    i;
  1537.  
  1538.     i = 0;
  1539.     while((c = getch())!=EOF && c!='\n') {
  1540.         buf[i++] = c;
  1541.         if (i >= nbuf) return FIOLONG;
  1542.     }
  1543.     if (c == EOF  && (iostat == -1L)) {
  1544.         ewprintf("File read error");
  1545.         return FIOERR;
  1546.     }
  1547.     *nbytes = i;
  1548.     return c==EOF ? FIOEOF : FIOSUC;
  1549. }
  1550.  
  1551. #ifndef    NO_BACKUP
  1552. /*
  1553.  * Rename the current file into a backup copy,
  1554.  * possibly after deleting the original file.
  1555.  */
  1556. fbackupfile(fname)
  1557. char    *fname;
  1558. {
  1559.     struct FileLock *twiddle, *lock;
  1560.     char buffer[NFILEN];
  1561.  
  1562.     (void) strncpy(buffer,fname,NFILEN - 1);
  1563.     (void) strcat(buffer,"~");
  1564.  
  1565.     lock = Lock(fname,(ULONG)EXCLUSIVE_LOCK);/* does file exist?    */
  1566.     if (!lock)
  1567.         return (FALSE);            /* nope, return error    */
  1568.  
  1569.     twiddle = Lock(buffer,(ULONG)EXCLUSIVE_LOCK);
  1570.     if (twiddle) {                /* delete old backup    */
  1571.         UnLock(twiddle);        /* let it go        */
  1572.         if (!DeleteFile(buffer)) {
  1573.             UnLock(lock);
  1574.             return (FALSE);
  1575.         }
  1576.         twiddle = NULL;
  1577.     }
  1578.     /* rename file to backup name (after unlocking the file)
  1579.      */
  1580.     UnLock(lock);
  1581.     return (int) Rename(fname,buffer);
  1582. }
  1583. #endif    NO_BACKUP
  1584.  
  1585. #ifndef    NO_STARTUP
  1586. /*
  1587.  * Return name of user's startup file.  On Amiga, make it
  1588.  * .mg in the current directory, then s:.mg
  1589.  */
  1590.  
  1591. static char startname[] = ".mg";
  1592. static char altstartname[] = "s:.mg";
  1593.  
  1594. char *startupfile()
  1595. {
  1596.     struct FileLock *lock;
  1597.  
  1598.     if (lock = Lock(startname,(ULONG)SHARED_LOCK)) {
  1599.         UnLock(lock);
  1600.         return(startname);
  1601.     }
  1602.     if (lock = Lock(altstartname,(ULONG)SHARED_LOCK)) { /* alternate */
  1603.         UnLock(lock);
  1604.         return (altstartname);
  1605.     }
  1606.     return (NULL);
  1607. }
  1608. #endif    NO_STARTUP
  1609.  
  1610. /*
  1611.  * The string "fn" is a file name. Perform any required name adjustments,
  1612.  * including conversion to a fully qualified path if NO_DIR isn't defined.
  1613.  */
  1614.  
  1615. #define MAX_ELEMS      8        /* Maximum number of elements    */
  1616. extern char MyDirName[];
  1617.  
  1618. char *adjustname(fn)
  1619. register char    *fn;
  1620. {
  1621. #ifndef NO_DIR
  1622.     static char fnb[MAX_ELEMS*FCHARS + 1];
  1623.     struct FileLock *lock;
  1624.     long PathName();
  1625.     void TackOn();
  1626.     char *dup, *p;
  1627.  
  1628.     if (!index(fn, ':')) {            /* no device        */
  1629.         strcpy(fnb, MyDirName);
  1630.         TackOn(fnb, fn);
  1631.         if (!index(fn, '/'))        /* completely bare name */
  1632.             return fnb;
  1633.     } else
  1634.         strcpy(fnb, fn);
  1635.     /*
  1636.      * Else fn has some path components in it.  We try to PathName
  1637.      * the whole thing first, but since the file specified by fn
  1638.      * may not exist, we PathName the leading part and TackOn the
  1639.      * trailing part if it doesn't.
  1640.      */
  1641.     if (lock = Lock(fnb, SHARED_LOCK)) {
  1642.         if (PathName(lock, fnb, (long) MAX_ELEMS) !=0) {
  1643.             UnLock(lock);
  1644.             return fnb;
  1645.         }
  1646.         ewprintf("adjustname: PathName() failed!");
  1647.         UnLock(lock);
  1648.         return fn;
  1649.     }
  1650.     if (!(p = rindex(fnb, '/')))
  1651.         p = index(fnb, ':');
  1652.     p++;
  1653.     strcpy((dup = malloc(strlen(p) + 1)), p);
  1654.     *p = '\0';
  1655.     if (lock = Lock(fnb, SHARED_LOCK)) {
  1656.         if (PathName(lock, fnb, (long) MAX_ELEMS) != 0) {
  1657.             UnLock(lock);
  1658.             TackOn(fnb, dup);
  1659.             free(dup);
  1660.             return fnb;
  1661.         }
  1662.         ewprintf("adjustname: PathName() failed!");
  1663.         UnLock(lock);
  1664.     }
  1665.     free(dup);
  1666. #endif
  1667.     return fn;                /* if all else fails    */
  1668. }
  1669.  
  1670. /*
  1671.  * Functions to read/write into the I/O buffer
  1672.  */
  1673.  
  1674. int FlushBuf()
  1675. {
  1676.     if (niobuf > 0) {
  1677.         iostat = Write(ffh, iobuf, (ULONG) niobuf);
  1678.         niobuf = 0;
  1679.     }
  1680. }
  1681.  
  1682. /*
  1683.  * Fill up the input buffer and return the first character in it.
  1684.  */
  1685. int FillBuf()
  1686. {
  1687.     if ((iostat = Read(ffh, iobuf, (ULONG) NIOBUF)) <= 0L)
  1688.         return (EOF);
  1689.     ibufo = 0;
  1690.     niobuf = (int) iostat;
  1691.     return (int) (iobuf[ibufo++]);
  1692. }
  1693.  
  1694. #ifndef NO_DIRED
  1695.  
  1696. #include "kbd.h"
  1697.  
  1698. copy(frname, toname)
  1699. char *frname, *toname;
  1700. {
  1701. #ifdef    MANX
  1702.     return fexecl("copy", "copy", frname, toname, (char *) 0);
  1703. #endif
  1704. #ifdef    LATTICE
  1705.     int    error ;
  1706.     if (error = forkl("copy", "copy", frname, toname, (char *) 0, (char *) 0, 2))
  1707.         return error ;
  1708.     return (int) wait(2) ;
  1709. #endif
  1710. }
  1711.  
  1712. BUFFER *dired_(dirname)
  1713. char *dirname;
  1714. {
  1715.     register BUFFER *bp;
  1716.     char line[256];
  1717.     BUFFER *findbuffer();
  1718.     char *tmpname, *mktemp();
  1719.     int i;
  1720.     VOID lfree();
  1721.  
  1722.     if((dirname = adjustname(dirname)) == NULL) {
  1723.     ewprintf("Bad directory name");
  1724.     return NULL;
  1725.     }
  1726.     if(!isdirectory(dirname)) {
  1727.     ewprintf("Not a directory: %s", dirname);
  1728.     return NULL;
  1729.     }
  1730.     if((bp = findbuffer(dirname)) == NULL) {
  1731.     ewprintf("Could not create buffer");
  1732.     return NULL;
  1733.     }
  1734.     bclear(bp);                /* clear out leftover garbage    */
  1735.     (void) strcpy(line, "list >");
  1736.     (void) strncat(line, tmpname = mktemp("ram:mgXXX.XXX"), sizeof(line));
  1737.     (void) strncat(line, " \"", sizeof(line));
  1738.     (void) strncat(line, dirname, sizeof(line));
  1739.     (void) strncat(line, "\"", sizeof(line));
  1740.     Execute(line, 0L, 0L);
  1741.     if (ffropen(tmpname) != FIOSUC) {
  1742.      ewprintf("Can't open temporary dir file");
  1743.      return NULL;
  1744.     }
  1745.     if (ffgetline(line, sizeof(line), &i) != FIOSUC ||
  1746.     strncmp(line, "Directory", 9) != 0) {
  1747.     ffclose();
  1748.     DeleteFile(tmpname);
  1749.     ewprintf("No such directory: `%s'", dirname);
  1750.         return NULL;
  1751.     }
  1752.     line[0] = line[1] = ' ';
  1753.     while (ffgetline(&line[2], sizeof(line)-3, &i) == FIOSUC) {
  1754.     line[i+2] = '\0';
  1755.     (VOID) addline(bp, line);
  1756.     }
  1757.     ffclose();
  1758.     DeleteFile(tmpname);
  1759.     bp->b_dotp = lforw(bp->b_linep);        /* go to first line */
  1760.     (VOID) strncpy(bp->b_fname, dirname, NFILEN);
  1761.     if((bp->b_modes[0] = name_mode("dired")) == NULL) {
  1762.     bp->b_modes[0] = &map_table[0];
  1763.     ewprintf("Could not find mode dired");
  1764.     return NULL;
  1765.     }
  1766.     bp->b_nmodes = 0;
  1767.     return bp;
  1768. }
  1769.  
  1770. #ifdef    LATTICE
  1771. char *
  1772. mktemp(pattern)
  1773. char *pattern;
  1774. {
  1775. /* quick hack mktemp for this purpose only */
  1776.     register char        *name, *printo ;
  1777.     register unsigned short    counter = 0 ;
  1778.  
  1779.     if ((name = malloc(strlen(pattern) + 5)) == NULL)
  1780.         panic("Manx sucks rocks!") ;
  1781.     (VOID) strcpy(name, pattern) ;
  1782.     printo = name + strlen(name) ;
  1783.     do
  1784.         (void) sprintf(printo, "%d", counter += 1) ;
  1785.         while (counter > 0 && access(name, 0) == 0) ;
  1786.     if (counter == 0) panic("Manx _really_ sucks!") ;
  1787.     return name ;
  1788. }
  1789. #endif
  1790.  
  1791. #define LIST_LINE_LENGTH 58            /* Size of line from List */
  1792.  
  1793. d_makename(lp, fn)
  1794. register LINE *lp;
  1795. register char *fn;
  1796. {
  1797.     register char *cp;
  1798.     int n = 2;
  1799.  
  1800.     if(llength(lp) < LIST_LINE_LENGTH) return ABORT;
  1801.     if(lgetc(lp, 2) == ':') return ABORT;    /* FileNote line    */
  1802.     (VOID) strcpy(fn, curbp->b_fname);
  1803.     cp = fn + strlen(fn);
  1804.     if ((cp[-1] != ':') && (cp[-1] != '/'))    /* append '/' if needed    */
  1805.     *cp++ = '/';
  1806.     while (lgetc(lp, n) != ' ') {
  1807.     *cp++ = lgetc(lp, n);
  1808.     n++;
  1809.     }
  1810.     *cp = '\0';
  1811.     return strncmp(&lp->l_text[31], "Dir", 3) == 0;
  1812. }
  1813.  
  1814. static isdirectory(name)
  1815. char *name;
  1816. {
  1817.     struct FileLock *lock;
  1818.     struct FileInfoBlock *fib;
  1819.     int result;
  1820.  
  1821.     if ((lock = Lock(name, ACCESS_READ)) == NULL)
  1822.     return FALSE;
  1823.     if ((fib = (struct FileInfoBlock *)
  1824.        AllocMem((long)sizeof(struct FileInfoBlock),MEMF_PUBLIC))==NULL) {
  1825.     UnLock(lock);
  1826.     return FALSE;
  1827.     }
  1828.     result = (fib->fib_DirEntryType > 0L) ? TRUE : FALSE;
  1829.     FreeMem(fib,(long)sizeof(struct FileInfoBlock));
  1830.     UnLock(lock);
  1831.     return result;
  1832. }
  1833.  
  1834. #endif
  1835.  
  1836. #ifndef USE_ARP
  1837.  
  1838. /*
  1839.  * Here are work-alikes for the few ARP commands now used by the
  1840.  * Amiga version of mg.  These may go away if we require ARP in future.
  1841.  */
  1842.  
  1843. Strcmp(s1, s2)
  1844. register char *s1, *s2;
  1845. {
  1846.     while (tolower(*s1) == tolower(*s2)) {
  1847.         if (*s1 == '\0')
  1848.             return 0;
  1849.         s1++; s2++;
  1850.     }
  1851.     return (tolower(*s1) < tolower(*s2) ? -1 : 1);
  1852. }
  1853.  
  1854. /*
  1855.  * This PathName function shamelessly stolen from the Matt Dillon Shell.
  1856.  * It is a slight mod of that program's get_pwd routine, from comm1.c.
  1857.  */
  1858. long
  1859. PathName(flock, pwdstr, nentries)
  1860. struct Lock *flock;
  1861. long nentries;
  1862. char *pwdstr;
  1863. {
  1864.  
  1865.    char *ptr;
  1866.    char *name;
  1867.    int err=0;
  1868.  
  1869.    struct FileLock *lock, *newlock, *ParentDir(), *DupLock();
  1870.    long Examine();
  1871.    struct FileInfoBlock *fib;
  1872.    int i, len, n;
  1873.  
  1874.    lock = DupLock(flock);
  1875.    n = nentries * FCHARS + 1;
  1876.          
  1877.    fib = (struct FileInfoBlock *)AllocMem((long)sizeof(struct FileInfoBlock),
  1878.                          MEMF_PUBLIC);
  1879.    pwdstr[i = n-1] = '\0';
  1880.  
  1881.    while (lock) {
  1882.       newlock = ParentDir(lock);
  1883.       if (!Examine(lock, fib)) ++err;
  1884.       name = fib->fib_FileName;
  1885.       if (*name == '\0')        /* HACK TO FIX RAM: DISK BUG */
  1886.      name = "RAM";
  1887.       len = strlen(name);
  1888.       if (newlock) {
  1889.      if (i == n-1) {
  1890.         i -= len;
  1891.         movmem(name, pwdstr + i, len);
  1892.      } else {
  1893.         i -= len + 1;
  1894.         movmem(name, pwdstr + i, len);
  1895.         pwdstr[i+len] = '/';
  1896.      }
  1897.       } else {
  1898.      i -= len + 1;
  1899.      movmem(name, pwdstr + i, len);
  1900.      pwdstr[i+len] = ':';
  1901.       }
  1902.       UnLock(lock);
  1903.       lock = newlock;
  1904.    }
  1905.    FreeMem(fib, (long)sizeof(struct FileInfoBlock));
  1906.    movmem(pwdstr + i, pwdstr, n - i);
  1907.    if (err) return(0L);
  1908.    return((long) n - i - 1);
  1909. }
  1910.  
  1911. void TackOn(path, file)
  1912. char *path, *file;
  1913. {
  1914.     if (*file != '\0') {
  1915.         if (path[strlen(path)-1] != ':')
  1916.             strcat(path, "/");
  1917.         strcat(path, file);
  1918.     }
  1919. }
  1920. #endif
  1921. SHAR_EOF
  1922. cat << \SHAR_EOF > sys/amiga/malloc.c
  1923. /*
  1924.  * Hello Mic:
  1925.  *
  1926.  *   After mailing the first message to you about the free() function I
  1927.  * decide on a solution similar to the one you sugested in your reply. There
  1928.  * is one disadvantage with this solution it requires an extra 4 bytes for
  1929.  * the link information beyond the original 8 bytes already required by each
  1930.  * block.  If we can find a clean way of deallocating stuff within EMACS such
  1931.  * as killing each buffer and all the other structures we will save 8 bytes
  1932.  * per allocation (leaving only the 4 bytes for the block size). Anyways
  1933.  * here is my doubly linked list version of free() which works very fast
  1934.  * but takes up a bit more memory.
  1935.  *
  1936.  *      Later,
  1937.  *         Leon
  1938.  *
  1939.  */
  1940.  
  1941. /* name: malloc.c
  1942.  * desc: An improved malloc() and free() function for Aztec c
  1943.  * date: 04/02/87 LF
  1944.  * note: This takes over the Aztec _cln() function that is called by
  1945.  *     the startup code once main() returns.
  1946.  */
  1947.  
  1948. #define NULL 0L
  1949.  
  1950. struct mem {
  1951.     struct mem *next, *prev;
  1952.     long size;
  1953. };
  1954.  
  1955. static struct mem *Free;
  1956.  
  1957. void *_AllocMem();
  1958.  
  1959. static
  1960. cleanup()
  1961. {
  1962.     register struct mem *mp, *xp;
  1963.  
  1964.     for (mp=Free;mp;mp=xp) {
  1965.         xp = mp->next;
  1966.         _FreeMem(mp, mp->size+sizeof(struct mem));
  1967.     }
  1968.     Free = 0;
  1969. }
  1970.  
  1971. char *
  1972. lmalloc(size)
  1973. unsigned long size;
  1974. {
  1975.     register struct mem *ptr;
  1976.     extern int (*_cln)();
  1977.  
  1978.     _cln = cleanup;
  1979.     if ((ptr = _AllocMem(size+sizeof(struct mem), 0L)) == 0)
  1980.         return(0);
  1981.     ptr->next = Free;
  1982.         if (Free != NULL)
  1983.         {
  1984.           Free->prev = ptr;
  1985.         }
  1986.         ptr->prev = NULL;
  1987.     ptr->size = size;
  1988.     Free = ptr;
  1989.     return((char *)ptr + sizeof(struct mem));
  1990. }
  1991.  
  1992. char *
  1993. malloc(size)
  1994. unsigned size;
  1995. {
  1996.     return(lmalloc((unsigned long)size));
  1997. }
  1998.  
  1999. free(blk)
  2000. char *blk;
  2001. {
  2002.     register struct mem *mp, *xp, *xn;
  2003.  
  2004.         mp = (struct mem*)(blk - sizeof(struct mem));
  2005.         xp = mp->prev;
  2006.         xn = mp->next;
  2007.  
  2008.         if (xn != NULL)
  2009.         {
  2010.           xn->prev = xp;
  2011.         }
  2012.  
  2013.         if (xp == NULL)
  2014.         {
  2015.           Free = xn;
  2016.         }
  2017.         else
  2018.         {
  2019.           xp->next = xn;
  2020.         }
  2021.  
  2022.     _FreeMem(mp, mp->size+sizeof(struct mem));
  2023.     return(0);
  2024. }
  2025. SHAR_EOF
  2026. #    End of shell archive
  2027. exit 0
  2028. -------
  2029.