home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume3
/
mg2a
/
part13
< prev
next >
Wrap
Internet Message Format
|
1989-02-03
|
60KB
Path: xanth!mcnc!ece-csc!ncsuvx!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!necntc!ncoast!allbery
From: BLARSON@ECLA.USC.EDU (Bob Larson)
Newsgroups: comp.sources.misc
Subject: v03i037: mg 2a part 13 of 15
Message-ID: <12401301336.47.BLARSON@ECLA.USC.EDU>
Date: 26 May 88 05:02:50 GMT
Sender: allbery@ncoast.UUCP
Reply-To: BLARSON@ECLA.USC.EDU (Bob Larson)
Lines: 2016
Approved: allbery@ncoast.UUCP
comp.sources.misc: Volume 3, Issue 37
Submitted-By: "Bob Larson" <BLARSON@ECLA.USC.EDU>
Archive-Name: mg2a/Part13
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# sys/amiga/Amiga.Doc
# sys/amiga/Makefile.LATTICE
# sys/amiga/Makefile.MANX
# sys/amiga/amiga_maps.c
# sys/amiga/console.c
# sys/amiga/dirio.c
# sys/amiga/fileio.c
# sys/amiga/malloc.c
# This archive created: Mon May 23 18:09:53 1988
# By: blarson
if test -d sys
then true
else mkdir sys
fi
if test -d sys/amiga
then true
else mkdir sys/amiga
fi
cat << \SHAR_EOF > sys/amiga/Amiga.Doc
Amiga MG 2a Release Notes
-------------------------
This file attempts to document the Amiga-specific features of MG 2a.
Except where otherwise noted. It is assumed that you already know
about the point and the mark, buffers, windows, extended commands, and
the various areas on the screen that all versions of MG maintain. If
you don't, see the MG documentation (what there is of it) for more
information.
Amiga Credits
-------------
The Amiga Intuition terminal driver is the combined effort of Mike
Meyer and Mic Kaczmarczik. Others who helped and/or inspired good
ideas for the MG terminal driver include Steve Walton, Leon Frenkel,
Marcus Brooks, and Tom Rokicki. Steve Walton is also responsible for
the dired mode. Lastly, Bob Larson redesigned the MG keymap system,
making it possible for function keys and mouse clicks to be
``first-class citizens''.
OPTIONS
-------
This section is for people who have their own C compiler. If you
don't have a C compiler, you will hopefully have a version that has
everything compiled into it.
There are a bewildering variety of extra goodies available as
compile-time options when you construct an Amiga MG. If you select none
of them, you save on disk and memory space, but lose out on some
features and versatility.
The Makefile provides documentation on these options and what to do
to make them work, but here is a quick overview:
STARTUP -- You can configure MG so that it will look for a startup
file in either the current directory or the AmigaDOS s: (startup)
directory. An example startup file is included in the distribution,
and also see the STARTUP section below.
MENU -- If this option is used, MG puts an Intuition menu bar with
major editing commands at the top of the screen, just like a "real"
Amiga program. (See the section on the MENU for more info).
BROWSER -- This has got to be seen to be appreciated. The Browser
program turns the menu bar into a way to select files on a disk. First
you select a disk, then a directory on the disk, then a file or
subdirectory on the disk, and so on, all in the menu.
MOUSE -- This option turns on the Amiga hot mouse. You can click
on a character and move point to that spot, and that's just the
beginning. (See the MOUSE section for more.)
FKEYS -- This option turns on support for all the extra Amiga
function keys. This enables the HELP key, which runs the function
"describe-key-briefly". Arrow keys work -- shift-arrow keys apply to
words and paragraphs. (See the KEYBOARD section.)
NO_BACKUP -- This is actually a default option; #defining NO_BACKUP
disables backup files.
When chosen, this #define modifies the action of the save-buffer (C-x
C-s) command. Normally, save-buffer writes out a new copy of the buffer
to disk, thus destroying the contents of the original file. If BACKUP
is enabled, MG will rename the file to filename~ (with a tilde character
at the end), before the new copy is written out. This keeps the
next-to-last copy of your file around on disk, so you can recover from
bad mistakes.
To avoid filling up disk space too quickly, by default MG does *NOT*
make backup files; to do so, enter the command "M-x make-backup-files",
which enables making backup files the next time you enter C-x C-s to
save a file. If you give an argument to the function (by typing "C-u
M-x make-backup-files", for example), backup files are not made.
DO_METAKEY -- When this is enabled, Amiga MG uses the ALT key to
implement the META key found on some terminals. This means that you
can type ALT-f (in one keystroke) to go forward one word, instead of
ESC-f, which requires two.
CHANGE_FONT -- This allows you to set the font used by the Amiga
console device driver when it draws characters in the MG window.
For instance, this lets you use a slightly taller font for editing
when using interlace mode under 1.2. MG cannot handle proportionally
spaced fonts, but will allow you to use them (with rather confusing
results) if you really want to.
MODE_RENDITION, {TEXT,MODE}_{FG,BG} -- These are #defines that
determine the default rendition of the mode line and the foreground
and background colors of the text. See the COLOR section for more
info.
CHANGE_COLOR -- If you want to be able to mess around with the
foreground and background colors of the text window, this option
allows you to do that. You can also specify the way the status line is
rendered (plain, boldface, italics, or reverse video).
USE_ARP -- Amiga MG2a uses a few functions which are part of the
library for ARP, the AmigaDOS Replacement Project. Work-alikes for
these routines are provided for those without a copy of arp.library,
but as a future version of Amiga MG will require ARP and it has so
many other redeeming values, it is recommended you obtain a copy.
DO_ICONIFY -- This turns on the ``amiga-iconify'' function,
described in more detail below.
THE MOUSE
---------
The Amiga Mouse can invoke no less than 24 different functions.
Mouse clicks are essentially treated as keys by the MG, even though you
click the mouse and hold down qualifier keys to get them.
Mouse keys come in three groups of eight, the groups being:
Mouse keys -- when clicked in the text of a window
Mode-Mouse keys -- when clicked on a window's mode line
Echo-Mouse keys -- when clicked in the echo area
Inside each group, which of the eight keys you get is determined by
the combination of Shift, CTRL and ALT keys you are holding down when
the mouse button is pressed. So yes, there really is a
Ctrl-Meta-Shift-Mode-Mouse button. Note that the Meta (M-) prefix
*MUST* be the ALT key. Prefixing a mouse click with ESC will not work.
Mouse keys are generally bound to functions that affect the text in
the selected buffer. If the Intuition mouse pointer is located inside an
MG text window (i.e. an area where text is being edited), then a Mouse
key is sent to the editor when you click the mouse. The buffer
associated wth the window the pointer is in is made current, point is
set as close as possible to the pointer (the character under the
pointer, if possible), then the command bound to that mouse button is
executed.
If the mouse pointer is in the mode line - the line that is in a
different typeface (usually backlit, maybe black instead of white) --
when the mouse button is clicked, a Mode-Mouse key is sent to the
editor. The buffer that the selected status line is associated with is
made the current buffer, the point is set to the value of point for
that window, then whatever command is bound to that button is
executed. Most of the Mode-Mouse keys invoke functions that act on the
entire window or buffer.
Clicking in the echo line - the line at the bottom of the screen
where prompts and message appear - results in an Echo-Mouse key.
Whatever command is bound to that button will be executed. Since the
echo line is not part of a buffer or a window, all the functions bound
to Echo-Mouse keys affect the state of the editor as a whole.
The default bindings for the hot mouse (as distributed) are:
Qualifiers | Area clicked
|
C A Shift | Text window Mode line Echo line
-------------+---------------------------------------------------------
| dot to mouse forward page switch to other buffer
X | recenter backward page kill buffer
X | delete word split window describe key
X X | kill line delete window describe bindings
X | delete char goto bob suspend MG
X X | delete whitespace goto eob quit
X X | kill region enlarge window list buffers
X X X | yank shrink window toggle Intuition window
To help keep straight what the various keys do, notice that the
Status and Echo groups come in pairs; the shifted version of a key is in
some sense the opposite of the unshifted version. There is no opposite
for display-buffers, so that key is bound to "amiga-toggle-border",
which toggles MG' Intuition window between bordered and borderless.
Like any MG key, you are free to rebind the 24 mouse buttons to do
whatever you wish. You may even rebind them in your startup sequence.
NOTE: only functions that start with the prefix "mouse-" are able to
handle clicks in windows and mode lines, because they know how to figure
out where the mouse was clicked. Conversely, any non-mouse function may
be bound to an Echo-Mouse key, because clicking in the echo area does
not send the x,y click information to the function.
If the iconification code is compiled in, then Echo-Mouse is bound
to ``amiga-iconify'' by default.
THE KEYBOARD
------------
There is a shortcut for many of the Meta commands (usually indicated
by the ESC character): hold down the ALT key at the same time you type
what usually comes after the ESC.
Historically, this is why keys that are typed with ESC in front of
them are called META keys; on the terminals at MIT where the Emacs
editor (MG's spiritual parent) was originally written, there was a META
key on the keyboard that did what the ALT key does. However, not many
terminals outside of MIT have the META key at all, so the ESC key was
nominated as a way to tell the system that the next character should be
converted into a META key before it is interpreted.
MG also recognizes Amiga function keys. For quick help on a key,
type the HELP key and then the key you want help on. The following
commands are bound to the Amiga function keys:
Key Function
--------------------------------------------
Help describe-key-briefly
Left backward-char
Shift-Left backward-word
Right forward-char
Shift-Right forward-word
Up previous-line
Shift-Up backward-paragraph
Down next-line
Shift-Down forward-paragraph
F1 find-file
Shift-F1 find-file-other-window
F2 save-buffer
Shift-F2 write-file
F3 scroll-up (page down)
Shift-F3 scroll-down (page up)
F4 enlarge-window
Shift-F4 shrink-window
F5 fill-paragraph
Shift-F5 query-replace
F6 split-window-vertically
Shift-F6 delete-other-windows
F7 transpose-chars
Shift-F7 just-one-space
F8 start-kbd-macro
Shift-F8 end-kbd-macro
F9 call-last-kbd-macro
Shift-F9 describe-bindings
F10 list-buffers
Shift-F10 save-buffers-kill-emacs
FUNCTION KEY NAMES
------------------
On the Amiga, all the function keys are readily visible on the
keyboard, so this table of key names for use in strings is fairly
self-explanitory. If you want to rebind Shift-Down-Arrow to scroll-up
(move down a whole page), for example, insert the line
(global-set-key "\F5" 'scroll-up)
in your s:.mg file.
Amiga key Startup name
-------------------------------------------------------------------------
Up-Arrow \F0
Down-Arrow \F1
Left-Arrow \F2
Right-Arrow \F3
Shift-Up-Arrow \F4
Shift-Down-Arrow \F5
Shift-Left-Arrow \F6
Shift-Right-Arrow \F7
Help \F9
F1 \F12
F2 \F13
F3 \F14
F4 \F15
F5 \F16
F6 \F17
F7 \F18
F8 \F19
F9 \F20
F10 \F21
Shift-F1 \F22
Shift-F2 \F23
Shift-F3 \F24
Shift-F4 \F25
Shift-F5 \F26
Shift-F6 \F27
Shift-F7 \F28
Shift-F8 \F29
Shift-F9 \F30
Shift-F10 \F31
Mouse \F32
Ctrl-Mouse \F33
Shift-Mouse \F34
Shift-Ctrl-Mouse \F35
Meta-Mouse \F36
Meta-Ctrl-Mouse \F37
Meta-Shift-Mouse \F38
Meta-Shift-Ctrl-Mouse \F39
Mode-Mouse \F40
Ctrl-Mode-Mouse \F41
Shift-Mode-Mouse \F42
Shift-Ctrl-Mode-Mouse \F43
Meta-Mode-Mouse \F44
Meta-Ctrl-Mode-Mouse \F45
Meta-Shift-Mode-Mouse \F46
Meta-Shift-Ctrl-Mode-Mouse \F47
Echo-Mouse \F48
Ctrl-Echo-Mouse \F49
Shift-Echo-Mouse \F50
Shift-Ctrl-Echo-Mouse \F51
Meta-Echo-Mouse \F52
Meta-Ctrl-Echo-Mouse \F53
Meta-Shift-Echo-Mouse \F54
Meta-Shift-Ctrl-Echo-Mouse \F55
THE MENU
--------
If the menu option is compiled into the program, you can also use the
Intuition menu, just like any other well-written Amiga program. The menu
names are relatively self-explanitory, as are the names inside each
menu. If you want to learn what the command key is for a menu function,
use the command "apropos" (invoked by Ctrl-Backspace a), followed by a
substring of the menu item you're curious about.
THE BROWSER
-----------
The Browser is the next best (or even better, for some purposes)
thing to a file requester. Simply put, it places the directory tree up
in the menu bar, where you can visit files simply by selecting their
names from the menu bar. Try it, you'll like it. If the MENU option is
also compiled in, the editing menus are all submenus of the first,
"Edit" menu, and the Browser uses the rest of the menu bar.
WINDOW OPTIONS
--------------
As a service to those of us who want a full-size, 80-column editing
window on a 640x200 screen, Amiga MG allows you to make its window
borderless. If you like, you can take over the full Workbench screen (48
rows, 80 columns in interlace mode under 1.2). Borderless windows can be
"visually confusing", to quote the author of Intuition, so it's probably
best to either to 1) take over the whole screen or 2) put the MG window
at the bottom of the screen.
When Amiga MG starts up on a 640x200 screen, its initial window is
borderless, and 640x200 pixels in dimension. To change to a resizeable
window, issue the command "M-x amiga-toggle-border" or select the
"Toggle Window" subitem from the "Window" menu (if it is compiled into
the program). MG will create a new, resizeable, bordered window, which
you can then set to whatever size you wish using the sizing gadget in
the bottom left corner of the window.
To go back to a borderless window, issue the "Toggle Window" command
again. MG will remember the current size of the resizeable window, and
create a borderless window with the same dimensions and position. Since
under Workbench 1.2 you can use a 640x400 window, this lets you take up
the entire screen, 48 rows by 80 columns.
If you use MoreRows, MG will open up a resizeable window if there's
enough room on the screen for an 24 line by 80 column window.
CHANGING THE WINDOW'S FONT
--------------------------
There may be times when you'd like to use another font on the screen,
either to make the text easier to read, or for some special effect, like
editing something on a TV projection system. MG lets you change the
font that is used to draw characters in the window, using the command
"M-x amiga-set-font".
You can use the universal argument to set the desired text font size,
for example saying "C-u 12 M-x set-font", then typing "opal" when it
prompts you for the name of the font. If you give an argument that is
less than 0, MG resets the window's font to the system default (set by
Preferences). If you don't give an argument, MG prompts you for the
desired font size.
Changing the window's font to one that is designed to be
proportionally spaced does not work very well, because MG expects the
all characters on the screen to be the same width, which is of course
not the case with proportional fonts. MG lets you use proportional
fonts, but it asks you to make sure first.
TEXT RENDITION
--------------
If you really want to, you can change the "soft style" the console
device uses to draw characters in the text area and the mode line. The
possible values for these styles are:
0 plain
1 boldface
3 italic
4 underline
7 inverse
About the only useful values are the ones for plain, boldface or
italics. The default value for text is 0 (plain, of course), while the
default for the mode line is 7 (inverse video). These can be changed by
the appropriate #definitions of MODE_RENDITION and TEXT_RENDITION.
The commands to change the rendition values are:
amiga-text-rendition
Set text area rendition
amiga-mode-rendition
Set mode line rendition (this is by far the more useful)
COLOR
-----
You can set the colors the console device uses to draw the text you
are editing. (This does not mean that you can specify *any* color; your
choices are limited to the colors being used by Intuition to maintain
the Workbench screen.) The commands that control this behavior are:
amiga-text-foreground
Sets the color used to draw the characters you see in the
text area (distinct from the mode line area for each window).
Accepts a number from 0 to 7. The value initially used is 1.
You can get a reverse video screen by selecting 0 for this
value and 1 for the background color
amiga-text-background
Sets the color used the draw the background behind characters
in the text area. Accepts the same values as
amiga-text-foreground. The initial value is 0.
amiga-mode-foreground
Sets the foreground color used by the mode line. If you
set this to 0 and the background color to 1, you can get
a reverse video mode line even when you select italics for
the mode line rendition (see RENDITION)
amiga-mode-background
Sets the background color for the mode line. You should
get the idea by now.
ICONIFICATION
-------------
Leo Schwab wrote a set of very general routines for allowing an
Amiga program to shrink its window to an icon. This icon can then be
moved around on the screen, and re-expanded to its full size by a
double click, like the one used to open a drawer. Amiga MG2a
provides this capability through the function ``amiga-iconify'',
which is bound to Echo-Mouse by default if the iconification code is
present. Not only is this a great way to prevent screen clutter, but
it also frees 50K of CHIP RAM while MG's window is iconified (on a 30
line by 80 column mg window).
To iconify the window, click the mouse in MG's echo line or issue
the extended command ``amiga-iconify.'' To expand MG's window back
to its full size, double-click on the MG2a icon in the same way you
would on a disk or drawer icon. The icon can also be dragged
about, and will remember its last position when the window is
iconified again.
FUNCTION LIST
-------------
For completeness, here is a list of all Amiga MG functions that are
specific to the Amiga.
amiga-iconify
Iconifies the Amiga MG window.
amiga-menu
The entry point for using MG's Intuition menu. This function
figures out which menu selection was used, then calls the
appropriate function by name (not hard-coded key value)
amiga-mouse
Set dot to where the mouse is pointing. Two clicks in the same
spot set the mark too.
mouse-*
Functions that first either 1) move point to where the mouse
points to or 2) select the buffer associated with the mode line
the mouse clicked in, then call the function indicated by the
rest of the name. These functions are all "bound" to various
mouse click keys.
amiga-set-font
Set the font used to draw characters inside the MG window.
A positive argument is used for the size of the font, while
a nonpositive argument requests that the font be set to the
system default font. Menu items are not affected by this command.
amiga-mode-rendition
amiga-text-rendition
Set the way your text (or the mode line) is rendered. Choose
from 0 (plain), 1 (bold), 3 (italic), 4 (underline), or
7 (reverse video). 0, 1, and 3 are about the only really useful
ones for text; 7 is the default for the mode line.
amiga-text-foreground
amiga-text-background
amiga-mode-foreground
amiga-mode-background
Set the system color used to draw the characters in the text area
and mode line. Accepts a value between 0 and 7; the default for
the background is 0, the default for the text is 1.
amiga-toggle-border
Switch your window between resizable and borderless. Lets you
take over the whole screen (80 columns! 48 lines in interlace!)
SHAR_EOF
cat << \SHAR_EOF > sys/amiga/Makefile.LATTICE
#
# Makefile for Amiga MG 2x, using Lattice small model.
#
# This Makefile uses the PD Make to be found on fish disk #69, expecting to
# run lc and blink from Lattice version 4. The directory that holds this
# makefile and the system-independent files should be named "mg", unless
# TOP is changed to match.
#
# This Makefile should be executed in the main Emacs directory.
#
# System-dependent conditional compilation possibilities:
#
# V11 -- must be defined for the editor to either run on
# or compile on a version 1.1 AmigaDOS system.
# It mainly wards against bugs in the 1.1 ROM
# Kernel.
#
# NO_STARTUP -- if defined, code for using a startup file
# is not included.
#
# MENU -- if defined, Intuition menu selection is
# enabled. If you #define this, the XOBJ macro
# must contain $(MENUOBJ).
#
# BROWSER -- BROWSER uses the Amiga menu to present a MENU of
# files. Selecting a directory entry (ends with a /)
# makes the contents if that directory the next menu
# (deleting any menus that used to follow it);
# selecting a plain file does a "find-file" on that
# file name. Really has to be seen to be understood.
# XOBJ must contain $(MENUOBJ) for this to link.
#
# MOUSE -- if defined, the Amiga mouse is active.
# If you #define this, XOBJ must contain $(MOUSEOBJ)
#
# FKEYS -- if defined, the editor understands the Amiga
# function keys.
#
# NO_BACKUP -- Disable the creation of backup files. If this
# option is defined, the function make-backup-files
# sets a flag that causes save-buffers (C-x C-s)
# to rename the original file to file~ before
# writing the file. Nice if the space is available.
# By default, backup files are not made. Calling
# make-backup-files with no argument enables this
# feature; calling it with an argument disables it.
#
# DO_METAKEY -- if defined, characters with high bit set (i.e.
# most ALT-ed characters in the usa0 keymap)
# are translated into internal META keys
#
# DO_ICONIFY -- if defined, provide a function to iconify the Emacs
# window into a gadget that can be double-clicked to
# return to the normal display.
#
# CHANGE_COLOR -- if defined, adds commands to manipulate
# the rendition of the mode line and the
# foreground and background color of the
# text window and mode line. The names match
# the regular expression
# set-{text,mode}-{foreground,background}
# CHANGE_FONT -- if defined, adds "set-font", which prompts
# for a font name and size, then tries to reopen
# the Emacs window using the new font.
# USE_ARP -- Use the ARP (AmigaDOS Replacement Library) for
# some functions. This makes the executable
# slightly smaller, but gives no new functionality
# in the current version. It will probably be
# required for some future version.
# USE_ARP has not be tested with the LATTICE version
#
#
# MODE_RENDITION -- the these values indicate the way to render
# TEXT_RENDITION characters in the text area and mode line.
# TEXT_RENDITION is mainly there for completeness.
# Possible values are:
# 0 -- plain text
# 1 -- boldface
# 3 -- italic
# 4 -- underscore
# 7 -- reverse-video (default if not defined)
#
# TEXT_FG -- specifies which system color (0-7) to use
# TEXT_BG when drawing the text and mode line. If they
# MODE_FG aren't between 0 and 7, or if a combination
# MODE_BG comes out badly, it's *YOUR* fault. If
# CHANGE_COLOR is defined, you get to change these
# values on the fly. Naturally, making both
# FG and BG the same results in an unusable display...
#
############################################################################
S = sys/amiga
TOP = mg
LIBS = lib:lc.lib lib:amiga.lib
#
# PREFS contains the defines used to select compile-time options.
# XOBJ is used to denote any extra object files needed for these
# options. MENUOBJ and MOUSEOBJ denote the extra object files
# needed for the menu, mouse and Browser. ARPOBJ is the extra
# object file needed to use arp.library. REGEX is the binaries for the regular
# expression code (requires -dREGEX). REGEX has not been tested under
# Lattice 4.0
MOUSEOBJ = ttymouse.o
MENUOBJ = ttymenu.o menustack.o
ICONIFYOBJ = iconify.o ttyicon.o
#
# the following turn into files with no source in them if you compile with
# the appropriate option turned off. Lattice incorrectly flags this as an error
# instead of a warning. To get around this, you have to add the appropriate
# #?OBJ macro to the XOBJ line for your configuration if you want it.
# Ugly, but it works. There are probably other such things that I've missed.
# The fix is to add a name here, put that on your xobj line, and delete it from
# whichever of OBJ OOBJ or IND that the #?.o files lives in now.
#
MACROOBJ = macro.o
REGEXOBJ = regex.o re_search.o
DIREDOBJ = dired.o
# The big burrito, with the Browser *and* the editing MENU. Tough
# on space, but boy is it neat...
#PREFS = -dSTARTUP -dDO_METAKEY -dDO_ICONIFY -dCHANGE_FONT -dBACKUP -dFKEYS \
# -dMOUSE -dMENU -dBROWSER -dCHANGE_COLOR -dBINDKEY -dBSMAP=0
#XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
# Burrito style, with just the Browser...
#PREFS = -dSTARTUP -dBROWSER -dMOUSE -dCHANGE_COLOR -dFKEYS -dDO_ICONIFY \
# -dDO_METAKEY -dBACKUP
#XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
# Burrito style, with just the menu... # untested for mg2
#PREFS = -dSTARTUP -dMENU -dMOUSE -dCHANGE_COLOR -dFKEYS -dDO_ICONIFY \
# -dDO_METAKEY -dBACKUP -dBSMAP=0
#XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
# Mike's favorite version
PREFS = -dMOUSE -dBROWSER -dMODE_RENDITION=0 -dMODE_FG=2 -dDO_METAKEY \
-dGOSREC -dGOSMACS -dDO_ICONIFY -dNO_STARTUP -dNO_DIRED -dBSMAP=1
XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ)
# Mic's favorite version # untested for mg2
#PREFS = -dSTARTUP -dBROWSER -dMENU -dMOUSE -dCHANGE_FONT -dFKEYS
# -dDO_METAKEY -dDO_ICONIFY -dBACKUP -dPREFIXREGION
#XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ) $(MACROOBJ) $(DIREDOBJ)
# Steve's favorite version # untested for mg2
#PREFS = -dSTARTUP -dMOUSE -dCHANGE_FONT -dFKEYS -dDO_METAKEY \
# -dBACKUP -dPREFIXREGION -dUSE_ARP
#XOBJ = $(MOUSEOBJ) $(MACROOBJ) $(DIREDOBJ)
# Absolutely bare-bones, default editor
#PREFS = -dDO_METAKEY
#XOBJ =
CC = lc
AS = asm
CFLAGS = -i$(S)/ -isys/default/ $(PREFS) -dAMIGA -dLATTICE -b -qram:
# Objects which only depend on the "standard" includes
OBJS = basic.o dir.o file.o line.o match.o paragraph.o \
random.o region.o search.o version.o window.o word.o
# Those with unique requirements
IND = buffer.o display.o echo.o extend.o help.o kbd.o keymap.o \
main.o modes.o
# System dependent objects
OOBJS = cinfo.o spawn.o ttyio.o tty.o ttykbd.o fileio.o sleep.o \
sysinit.o console.o dirio.o offset.o
OBJ = $(OBJS) $(IND) $(OOBJS) $(XOBJ)
OSRCS = cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c fileio.c sleep.c \
sysinit.c console.c dirio.c amiga_maps.c offset.c
SRCS = basic.c dir.c dired.c file.c line.c match.c paragraph.c \
random.c region.c search.c version.c window.c word.c \
buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \
macro.c main.c modes.c regex.c re_search.c
OINCS = $(S)/ttydef.h $(S)/sysdef.h sys/default/chrdef.h
INCS = def.h
#
# The editor
# Building in Ram: saves a LOT of time in pass 2 of the linker.
#
mg: $(OBJ)
blink lib:c.o $(OBJ) lib $(LIBS) to mg map nil: \
SMALLCODE SMALLDATA NODEBUG
# From the Manx version forget it for now.
#
# lint:
# lint +vm -ilint: -e7?? $(CFLAGS) std.lnt mg
#
$(OBJ): $(INCS) $(OINCS)
dir.o search.o: $(INCS) $(OINCS)
regex.o re_search.o: $(INCS) $(OINCS) regex.h
kbd.o: $(INCS) $(OINCS) macro.h kbd.h key.h
macro.o main.o: $(INCS) $(OINCS) macro.h
buffer.o display.o keymap.o help.o modes.o dired.o fileio.o: \
$(INCS) $(OINCS) kbd.h
extend.o: $(INCS) $(OINCS) kbd.h macro.h key.h
help.o: $(INCS) $(OINCS) kbd.h key.h macro.h
echo.o: $(INCS) $(OINCS) key.h macro.h
$(OOBJS): $(INCS) $(OINCS)
clean:
Delete $(OBJ)
fileio.o: $(S)/fileio.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/fileio.c
spawn.o: $(S)/spawn.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/spawn.c
sleep.o: $(S)/sleep.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/sleep.c
sysinit.o: $(S)/sysinit.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/sysinit.c
offset.o: $(S)/offset.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/offset.c
iconify.o: $(S)/iconify/iconify.c $(S)/iconify/iconify.h
$(CC) $(CFLAGS) -o/$(TOP)/ -i$(S)/iconify/ $(S)/iconify/iconify.c
tty.o: $(S)/tty.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/tty.c
ttyicon.o: $(S)/ttyicon.c
$(CC) $(CFLAGS) -o/$(TOP)/ -i$(S)/iconify/ $(S)/ttyicon.c
ttyio.o: $(S)/ttyio.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttyio.c
ttykbd.o: $(S)/ttykbd.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttykbd.c
ttymenu.o: $(S)/ttymenu.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttymenu.c
ttymouse.o: $(S)/ttymouse.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/ttymouse.c
menustack.o: $(S)/menustack.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/menustack.c
console.o: $(S)/console.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/console.c
dirio.o: $(S)/dirio.c
$(CC) $(CFLAGS) -o/$(TOP)/ $(S)/dirio.c
arpbind.o: $(S)/arpbind.asm $(S)/arpbase.i
$(AS) -o arpbind.o -i$(S)/ -isys2:asm/ $(S)/arpbind.asm
alloca.o: $(S)/alloca.asm
$(AS) -o alloca.o $(S)/alloca.asm
keymap.o: keymap.c $(S)/amiga_maps.c
$(CC) $(CFLAGS) -o/$(TOP)/ keymap.c
cinfo.o: sys/default/cinfo.c
$(CC) $(CFLAGS) -o/$(TOP)/ sys/default/cinfo.c
SHAR_EOF
cat << \SHAR_EOF > sys/amiga/Makefile.MANX
#
# Makefile for Amiga MG 2x, using Manx small model.
#
# This Makefile should be executed in the main Emacs directory.
#
# System-dependent conditional compilation possibilities:
#
# V11 -- must be defined for the editor to either run on
# or compile on a version 1.1 AmigaDOS system.
# It mainly wards against bugs in the 1.1 ROM
# Kernel.
#
# NO_STARTUP -- if defined, code for using a startup file
# is not included.
#
# MENU -- if defined, Intuition menu selection is
# enabled. If you #define this, the XOBJ macro
# must contain $(MENUOBJ).
#
# BROWSER -- BROWSER uses the Amiga menu to present a MENU of
# files. Selecting a directory entry (ends with a /)
# makes the contents if that directory the next menu
# (deleting any menus that used to follow it);
# selecting a plain file does a "find-file" on that
# file name. Really has to be seen to be understood.
# XOBJ must contain $(MENUOBJ) for this to link.
#
# MOUSE -- if defined, the Amiga mouse is active.
# If you #define this, XOBJ must contain $(MOUSEOBJ)
#
# FKEYS -- if defined, the editor understands the Amiga
# function keys.
#
# NO_BACKUP -- Disable the creation of backup files. If this
# option is defined, the function make-backup-files
# sets a flag that causes save-buffers (C-x C-s)
# to rename the original file to file~ before
# writing the file. Nice if the space is available.
# By default, backup files are not made. Calling
# make-backup-files with no argument enables this
# feature; calling it with an argument disables it.
#
# DO_METAKEY -- if defined, characters with high bit set (i.e.
# most ALT-ed characters in the usa0 keymap)
# are translated into internal META keys
#
# DO_ICONIFY -- if defined, provide a function to iconify the Emacs
# window into a gadget that can be double-clicked to
# return to the normal display.
#
# CHANGE_COLOR -- if defined, adds commands to manipulate
# the rendition of the mode line and the
# foreground and background color of the
# text window and mode line. The names match
# the regular expression
# set-{text,mode}-{foreground,background}
# CHANGE_FONT -- if defined, adds "set-font", which prompts
# for a font name and size, then tries to reopen
# the Emacs window using the new font.
# USE_ARP -- Use the ARP (AmigaDOS Replacement Library) for
# some functions. This makes the executable
# slightly smaller, but gives no new functionality
# in the current version. It will probably be
# required for some future version. Note that
# LIBS needs to be changed to "-la -lc" if you
# use ARP.
#
#
# MODE_RENDITION -- the these values indicate the way to render
# TEXT_RENDITION characters in the text area and mode line.
# TEXT_RENDITION is mainly there for completeness.
# Possible values are:
# 0 -- plain text
# 1 -- boldface
# 3 -- italic
# 4 -- underscore
# 7 -- reverse-video (default if not defined)
#
# TEXT_FG -- specifies which system color (0-7) to use
# TEXT_BG when drawing the text and mode line. If they
# MODE_FG aren't between 0 and 7, or if a combination
# MODE_BG comes out badly, it's *YOUR* fault. If
# CHANGE_COLOR is defined, you get to change these
# values on the fly. Naturally, making both
# FG and BG the same results in an unusable display...
#
############################################################################
SYS = amiga
S = sys/amiga
LIBS = -lc
#
# PREFS contains the defines used to select compile-time options.
# XOBJ is used to denote any extra object files needed for these
# options. MENUOBJ and MOUSEOBJ denote the extra object files
# needed for the menu, mouse and Browser.
MOUSEOBJ = ttymouse.o
MENUOBJ = ttymenu.o menustack.o
OFFSETOBJ = offset.o
ICONIFYOBJ = iconify.o ttyicon.o
# The big burrito, with the Browser *and* the editing MENU. Tough
# on space, but boy is it neat...
PREFS = -DSTARTUP -DDO_METAKEY -DDO_ICONIFY -DCHANGE_FONT -DCHANGE_COLOR \
-DBACKUP -DFKEYS -DMOUSE -DMENU -DBROWSER
XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(ICONIFYOBJ)
# Burrito style, with just the Browser...
#PREFS = -DSTARTUP -DBROWSER -DMOUSE -DCHANGE_COLOR -DFKEYS -DDO_ICONIFY -DDO_M
#XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(OFFSETOBJ) $(ICONIFYOBJ)
# Burrito style, with just the menu...
#PREFS = -DSTARTUP -DMENU -DMOUSE -DCHANGE_COLOR -DFKEYS -DDO_ICONIFY -DDO_META
#XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(OFFSETOBJ) $(ICONIFYOBJ)
# Mike's favorite version
#PREFS = -DMOUSE -DBROWSER -DMODE_RENDITION=0 -DMODE_FG=2 -DDO_METAKEY \
# -DGOSREC -DV11 -DMEYN
#XOBJ = $(MOUSEOBJ) $(MENUOBJ)
# Mic's favorite version
#PREFS = -DSTARTUP -DMENU -DMOUSE -DCHANGE_FONT -DFKEYS
# -DDO_METAKEY -DDO_ICONIFY -DBACKUP -DPREFIXREGION
#XOBJ = $(MOUSEOBJ) $(MENUOBJ) $(OFFSETOBJ) $(ICONIFYOBJ)
# Steve's favorite version
#PREFS = -DSTARTUP -DMOUSE -DCHANGE_FONT -DFKEYS -DDO_METAKEY \
# -DBACKUP -DPREFIXREGION -DUSE_ARP
#XOBJ = $(MOUSEOBJ)
# Notice the "-la" here to use ARP's library as well as the standard one.
#LIBS = -la -lc
# Absolutely bare-bones, default editor
#PREFS = -DDO_METAKEY
#XOBJ =
CFLAGS = -I$(S) -Isys/default $(PREFS) -DAMIGA -DMANX -DBINDKEY
# Objects which only depend on the "standard" includes
OBJS = basic.o dir.o dired.o file.o line.o match.o paragraph.o \
random.o region.o search.o version.o window.o word.o
# Those with unique requirements
IND = buffer.o display.o echo.o extend.o help.o kbd.o keymap.o \
macro.o main.o modes.o regex.o re_search.o
# System dependent objects
OOBJS = cinfo.o spawn.o ttyio.o tty.o ttykbd.o fileio.o sleep.o \
sysinit.o malloc.o console.o dirio.o
OBJ = $(OBJS) $(IND) $(OOBJS) $(XOBJ)
OSRCS = cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c fileio.c sleep.c \
sysinit.c malloc.c console.c dirio.c
SRCS = basic.c dir.c dired.c file.c line.c match.c paragraph.c \
random.c region.c search.c version.c window.c word.c \
buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \
macro.c main.c modes.c regex.c re_search.c
OINCS = $(S)/ttydef.h $(S)/sysdef.h sys/default/chrdef.h
INCS = def.h
#
# The editor
# Building in Ram: saves a LOT of time in pass 2 of the linker.
#
mg: $(OBJ)
ln -o ram:mg -w $(OBJ) $(LIBS)
copy ram:mg mg
delete ram:mg
lint:
lint +vm -ilint: -e7?? $(CFLAGS) std.lnt mg
$(OBJ): $(INCS) $(OINCS)
dir.o search.o: $(INCS) $(OINCS)
regex.o re_search.o: $(INCS) $(OINCS) regex.h
kbd.o: $(INCS) $(OINCS) macro.h kbd.h key.h
macro.o main.o: $(INCS) $(OINCS) macro.h
buffer.o display.o keymap.o help.o modes.o dired.o fileio.o: \
$(INCS) $(OINCS) kbd.h
extend.o: $(INCS) $(OINCS) kbd.h macro.h key.h
help.o: $(INCS) $(OINCS) kbd.h key.h macro.h
echo.o: $(INCS) $(OINCS) key.h macro.h
$(OOBJS): $(INCS) $(OINCS)
clean:
Delete $(OBJ)
fileio.o: $(S)/fileio.c
cc $(CFLAGS) -o fileio.o $(S)/fileio.c
spawn.o: $(S)/spawn.c
cc $(CFLAGS) -o spawn.o $(S)/spawn.c
sleep.o: $(S)/sleep.c
cc $(CFLAGS) -o sleep.o $(S)/sleep.c
sysinit.o: $(S)/sysinit.c
cc $(CFLAGS) -o sysinit.o $(S)/sysinit.c
malloc.o: $(S)/malloc.c
cc $(CFLAGS) -o malloc.o $(S)/malloc.c
offset.o: $(S)/offset.c
cc $(CFLAGS) -o offset.o $(S)/offset.c
iconify.o: $(S)/iconify/iconify.c $(S)/iconify/iconify.h
cc $(CFLAGS) -I$(S)/iconify -o iconify.o $(S)/iconify/iconify.c
tty.o: $(S)/tty.c
cc $(CFLAGS) -o tty.o $(S)/tty.c
ttyicon.o: $(S)/ttyicon.c
cc $(CFLAGS) -I$(S)/iconify -o ttyicon.o $(S)/ttyicon.c
ttyio.o: $(S)/ttyio.c
cc $(CFLAGS) -o ttyio.o $(S)/ttyio.c
ttykbd.o: $(S)/ttykbd.c
cc $(CFLAGS) -o ttykbd.o $(S)/ttykbd.c
ttymenu.o: $(S)/ttymenu.c
cc $(CFLAGS) -o ttymenu.o $(S)/ttymenu.c
ttymouse.o: $(S)/ttymouse.c
cc $(CFLAGS) -o ttymouse.o $(S)/ttymouse.c
menustack.o: $(S)/menustack.c
cc $(CFLAGS) -o menustack.o $(S)/menustack.c
console.o: $(S)/console.c
cc $(CFLAGS) -o console.o $(S)/console.c
dirio.o: $(S)/dirio.c
cc $(CFLAGS) -o dirio.o $(S)/dirio.c
arpbind.o: $(S)/arpbind.asm $(S)/arpbase.i
as -o arpbind.o -I$(S) -Isys2:asm $(S)/arpbind.asm
alloca.o: $(S)/alloca.asm
as -o alloca.o $(S)/alloca.asm
keymap.o: keymap.c $(S)/amiga_maps.c
cc $(CFLAGS) -Z4000 keymap.c
cinfo.o: sys/default/cinfo.c
cc $(CFLAGS) -o cinfo.o sys/default/cinfo.c
SHAR_EOF
cat << \SHAR_EOF > sys/amiga/amiga_maps.c
/*
* Name: MG 2a
* keymap.c setup for Amiga-specific function keys.
* Created: 14-May-1988 Mic Kaczmarczik (mic@emx.utexas.edu)
* Last edit: 14-May-1988 Mic Kaczmarczik
*
* One big table for coding convenience, because the number of different
* compilation possibilities makes setting up data structures kind of
* tricky. Once again for convenience, the file is #included into keymap.c
* instead of being linked. I tried to minimize the changes to keymap.c,
* while making it possible to have the Amiga function/arrow keys in dired
* mode as well as fundamental mode. In the future, we might want to
* rebind some of the function keys in dired mode, but for right now they
* do the same thing as in fundamental mode.
*/
static PF amiga_keys[] = {
#ifdef FKEYS
backline, /* Up (0x100) */
forwline, /* Down */
backchar, /* Left */
forwchar, /* Right */
gotobop, /* Shift-Up */
gotoeop, /* Shift-Down */
backword, /* Shift-Left */
forwword, /* Shift-Right */
desckey, /* Help (0x108) */
#else
/* 9 unbound keys */
rescan, rescan, rescan, rescan, rescan, rescan, rescan, rescan, rescan,
#endif
#ifdef DO_MENU
amigamenu, /* Menu selction (0x109) */
#else
rescan, /* Menu selection (0x109) */
#endif
refresh, /* Resize window (0x10A) */
rescan, /* used to be Mouse */
#ifdef FKEYS
filevisit, /* F1 (0x10C) */
filesave, /* F2 */
forwpage, /* F3 */
enlargewind, /* F4 */
fillpara, /* F5 */
splitwind, /* F6 */
twiddle, /* F7 */
definemacro, /* F8 */
executemacro, /* F9 */
listbuffers, /* F10 */
poptofile, /* Shift-F1 (0x116) */
filewrite, /* Shift-F2 */
backpage, /* Shift-F3 */
shrinkwind, /* Shift-F4 */
queryrepl, /* Shift-F5 */
onlywind, /* Shift-F6 */
justone, /* Shift-F7 */
finishmacro, /* Shift-F8 */
wallchart, /* Shift-F9 */
quit, /* Shift-F10 (0x11F) */
#else
rescan, rescan, rescan, rescan, rescan, /* 20 unbound keys */
rescan, rescan, rescan, rescan, rescan,
rescan, rescan, rescan, rescan, rescan,
rescan, rescan, rescan, rescan, rescan,
#endif
#ifdef MOUSE
amigamouse, /* Mouse (0x120) */
mforwdel, /* Ctrl-Mouse */
mreposition, /* Shift-Mouse */
mdelwhite, /* Shift-Ctrl-Mouse */
mdelfword, /* Meta-Mouse */
mkillregion, /* Meta-Ctrl-Mouse */
mkillline, /* Meta-Shift-Mouse */
myank, /* Meta-Shift-Ctrl-Mouse */
mforwpage, /* Mode-Mouse (0x128) */
mgotobob, /* Ctrl-Mode-Mouse */
mbackpage, /* Shift-Mode-Mouse */
mgotoeob, /* Shift-Ctrl-Mode-Mouse */
msplitwind, /* Meta-Mode-Mouse */
menlargewind, /* Meta-Ctrl-Mode-Mouse */
mdelwind, /* Meta-Shift-Mode-Mouse */
mshrinkwind, /* Meta-Shift-Ctrl-Mode-Mouse */
#ifdef DO_ICONIFY
tticon, /* Echo-Mouse (0x130) */
#else
usebuffer, /* Echo-Mouse (0x130) */
#endif
spawncli, /* Ctrl-Echo-Mouse */
killbuffer, /* Shift-Echo-Mouse */
quit, /* Shift-Ctrl-Echo-Mouse */
desckey, /* Meta-Echo-Mouse */
listbuffers, /* Meta-Ctrl-Echo-Mouse */
wallchart, /* Meta-Shift-Echo-Mouse */
togglewindow, /* Meta-Shift-Ctrl-Echo-Mouse */
#endif MOUSE
};
/*
* Define extra maps for fundamental mode. Have to provide the number of
* extra map segments because it's used by the KEYMAPE() macro that builds
* keymaps. The keymap setup, while compact, is pretty complex...
*/
#define NFUND_XMAPS 1
#ifdef MOUSE
#define FUND_XMAPS {KUP, KEASCMOUSE, amiga_keys, (KEYMAP*)NULL}
#else
#define FUND_XMAPS {KUP, KSF10, amiga_keys, (KEYMAP*)NULL}
#endif
/*
* Extra map segments for dired mode -- just use fundamental mode segments
*/
#define NDIRED_XMAPS NFUND_XMAPS
#define DIRED_XMAPS FUND_XMAPS
SHAR_EOF
cat << \SHAR_EOF > sys/amiga/console.c
/*
* These functions are taken directly from the
* console.device chapter in the Amiga V1.1
* ROM Kernel Manual.
*/
#include <exec/types.h>
#include <exec/io.h>
#include <devices/console.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
extern LONG OpenDevice();
extern LONG DoIO();
extern LONG SendIO();
/*
* Open a console device, given a read request
* and a write request message.
*/
int OpenConsole(writerequest,readrequest,window)
struct IOStdReq *writerequest;
struct IOStdReq *readrequest;
struct Window *window;
{
LONG error;
writerequest->io_Data = (APTR) window;
writerequest->io_Length = (ULONG) sizeof(*window);
error = OpenDevice("console.device", 0L, writerequest, 0L);
/* clone required parts of the request */
if (readrequest) {
readrequest->io_Device = writerequest->io_Device;
readrequest->io_Unit = writerequest->io_Unit;
}
return((int) error);
}
/*
* Output a single character
* to a specified console
*/
int ConPutChar(request,character)
struct IOStdReq *request;
char character;
{
#ifdef V11
register int x;
#endif
request->io_Command = CMD_WRITE;
request->io_Data = (APTR)&character;
request->io_Length = (ULONG)1;
DoIO(request);
/* caution: read comments in manual! */
return(0);
}
/*
* Output a NULL-terminated string of
* characters to a console
*/
int ConPutStr(request,string)
struct IOStdReq *request;
char *string;
{
#ifdef V11
register int x;
#endif
request->io_Command = CMD_WRITE;
request->io_Data = (APTR)string;
request->io_Length = (LONG)-1;
DoIO(request);
return(0);
}
/*
* Write out a string of predetermined
* length to the console
*/
int ConWrite(request,string,len)
struct IOStdReq *request;
char *string;
int len;
{
#ifdef V11
register int x;
#endif
request->io_Command = CMD_WRITE;
request->io_Data = (APTR)string;
request->io_Length = (LONG)len;
DoIO(request);
return(0);
}
/*
* Queue up a read request
* to a console
*/
int QueueRead(request,whereto)
struct IOStdReq *request;
char *whereto;
{
#ifdef V11
register int x;
#endif
request->io_Command = CMD_READ;
request->io_Data = (APTR)whereto;
request->io_Length = (LONG)1;
SendIO(request);
return(0);
}
SHAR_EOF
cat << \SHAR_EOF > sys/amiga/dirio.c
/*
* Name: MG 2x
* Directory I/O routines, by Stephen Walton
* Version of 5-May-88
*/
#ifndef NO_DIR
#include "sysdef.h"
#include <libraries/dosextens.h>
#include <exec/memory.h>
extern char MyDirName[MAXPATH], *strncat();
char *getwd(path)
char *path;
{
strcpy(path,MyDirName);
return path;
}
chdir(path)
char *path;
{
BPTR Lock(), AttemptLock, CurrentDir();
long PathName(), len;
struct FileInfoBlock *fib;
void *AllocMem();
int retval;
AttemptLock = Lock(path, ACCESS_READ);
if (!AttemptLock)
return -1;
fib = (struct FileInfoBlock *) AllocMem((long)
sizeof(struct FileInfoBlock),
MEMF_CLEAR);
Examine(AttemptLock, fib);
if (fib->fib_DirEntryType < 0) {
retval = -1;
UnLock(AttemptLock);
goto clean;
}
UnLock(CurrentDir(AttemptLock)); /* do the thing */
if (PathName(AttemptLock, MyDirName, MAXPATH/31L) == 0)
MyDirName[0] = '\0';
retval = 0; /* Success! */
clean:
FreeMem((void *) fib, (long) sizeof(struct FileInfoBlock));
return retval;
}
#endif
SHAR_EOF
cat << \SHAR_EOF > sys/amiga/fileio.c
/*
* Name: MG 2a401
* Commodore Amiga file I/O.
* Last edit: 05-May-88 swalton@solar.stanford.edu
* Next-to-Last edit: 16-Dec-87 mic@emx.utexas.edu
* Created: 23-Jul-86 mic@emx.utexas.edu
*
* Read and write ASCII files. All of the low level file I/O
* knowledge is here. Uses AmigaDOS standard I/O and does its
* own dynamic buffering; this seems to save about 2K worth
* of space in the executable image.
*/
#ifdef LATTICE
#include <string.h>
#include <exec/types.h>
#endif
#include <exec/memory.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#ifdef USE_ARP
#include "libraries/arpbase.h"
#else
#define FCHARS 32L
#endif
#undef TRUE
#undef FALSE
#include "def.h"
#define NIOBUF 4096
extern ULONG Rename(), UnLock(), Close(), FreeMem();
extern LONG Write(), Read();
extern UBYTE *AllocMem();
extern struct FileLock *Lock();
extern struct FileHandle *Open();
static struct FileHandle *ffh = 0;
static UBYTE *iobuf;
static int ibufo, niobuf;
static LONG iostat, access_mode;
#ifdef MANX
extern char *strncpy(), *strncat(), *index(), *rindex();
#endif
#ifdef LATTICE
extern char *malloc() ;
#define index strchr
#define rindex strrchr
#endif
#define getch() (ibufo == niobuf) ? FillBuf() : iobuf[ibufo++]
#define putch(c) {if (niobuf == NIOBUF) FlushBuf(); iobuf[niobuf++] = c;}
/*
* Open the Emacs internal file for reading.
*/
ffropen(fn)
char *fn;
{
if ((iobuf = AllocMem((ULONG) NIOBUF, 0L)) == NULL)
return (FIOERR);
if ((ffh = Open(fn, access_mode = MODE_OLDFILE)) == 0L) {
FreeMem(iobuf, (ULONG) NIOBUF);
return (FIOFNF);
}
ibufo = niobuf = 0;
return (FIOSUC);
}
/*
* Open a file for writing. Return TRUE if all
* is well, and FALSE on error (cannot create).
*/
ffwopen(fn)
char *fn;
{
if ((iobuf = AllocMem((ULONG) NIOBUF, 0L)) == NULL)
return (FIOERR);
if ((ffh = Open(fn, access_mode = MODE_NEWFILE)) == 0L) {
ewprintf("Cannot open file for writing");
FreeMem(iobuf, (ULONG) NIOBUF);
return (FIOERR);
}
niobuf = 0;
iostat = NIOBUF; /* pretend we wrote out a full buffer last time */
return (FIOSUC);
}
/*
* Close a file, flushing the output buffer. Should look at
* the status.
*/
ffclose()
{
if (access_mode == MODE_NEWFILE)
FlushBuf();
if (ffh)
(void) Close(ffh);
if (iobuf)
FreeMem(iobuf, (ULONG) NIOBUF);
return (FIOSUC);
}
/*
* Write a buffer to the already opened file. bp points to the
* buffer. Return the status. Check only at the newline and
* end of buffer.
*/
ffputbuf(bp)
BUFFER *bp;
{
register char *cp;
register char *cpend;
register LINE *lp;
register LINE *lpend;
lpend = bp->b_linep;
lp = lforw(lpend);
do {
cp = <ext(lp)[0]; /* begining of line */
cpend = &cp[llength(lp)]; /* end of line */
while(cp != cpend)
putch(*(cp++)); /* putch only evalutes its arg once */
lp = lforw(lp);
if(lp == lpend) break; /* no implied newline on last line */
putch('\n');
} while(iostat > 0L);
if(iostat == -1L) {
ewprintf("Write I/O error");
return FIOERR;
}
return FIOSUC;
}
/*
* Read a line from a file, and store the bytes
* in the supplied buffer. Stop on end of file or end of
* line. When FIOEOF is returned, there is a valid line
* of data without the normally implied \n.
*/
ffgetline(buf, nbuf, nbytes)
register char *buf;
register int nbuf;
register int *nbytes;
{
register int c;
register int i;
i = 0;
while((c = getch())!=EOF && c!='\n') {
buf[i++] = c;
if (i >= nbuf) return FIOLONG;
}
if (c == EOF && (iostat == -1L)) {
ewprintf("File read error");
return FIOERR;
}
*nbytes = i;
return c==EOF ? FIOEOF : FIOSUC;
}
#ifndef NO_BACKUP
/*
* Rename the current file into a backup copy,
* possibly after deleting the original file.
*/
fbackupfile(fname)
char *fname;
{
struct FileLock *twiddle, *lock;
char buffer[NFILEN];
(void) strncpy(buffer,fname,NFILEN - 1);
(void) strcat(buffer,"~");
lock = Lock(fname,(ULONG)EXCLUSIVE_LOCK);/* does file exist? */
if (!lock)
return (FALSE); /* nope, return error */
twiddle = Lock(buffer,(ULONG)EXCLUSIVE_LOCK);
if (twiddle) { /* delete old backup */
UnLock(twiddle); /* let it go */
if (!DeleteFile(buffer)) {
UnLock(lock);
return (FALSE);
}
twiddle = NULL;
}
/* rename file to backup name (after unlocking the file)
*/
UnLock(lock);
return (int) Rename(fname,buffer);
}
#endif NO_BACKUP
#ifndef NO_STARTUP
/*
* Return name of user's startup file. On Amiga, make it
* .mg in the current directory, then s:.mg
*/
static char startname[] = ".mg";
static char altstartname[] = "s:.mg";
char *startupfile()
{
struct FileLock *lock;
if (lock = Lock(startname,(ULONG)SHARED_LOCK)) {
UnLock(lock);
return(startname);
}
if (lock = Lock(altstartname,(ULONG)SHARED_LOCK)) { /* alternate */
UnLock(lock);
return (altstartname);
}
return (NULL);
}
#endif NO_STARTUP
/*
* The string "fn" is a file name. Perform any required name adjustments,
* including conversion to a fully qualified path if NO_DIR isn't defined.
*/
#define MAX_ELEMS 8 /* Maximum number of elements */
extern char MyDirName[];
char *adjustname(fn)
register char *fn;
{
#ifndef NO_DIR
static char fnb[MAX_ELEMS*FCHARS + 1];
struct FileLock *lock;
long PathName();
void TackOn();
char *dup, *p;
if (!index(fn, ':')) { /* no device */
strcpy(fnb, MyDirName);
TackOn(fnb, fn);
if (!index(fn, '/')) /* completely bare name */
return fnb;
} else
strcpy(fnb, fn);
/*
* Else fn has some path components in it. We try to PathName
* the whole thing first, but since the file specified by fn
* may not exist, we PathName the leading part and TackOn the
* trailing part if it doesn't.
*/
if (lock = Lock(fnb, SHARED_LOCK)) {
if (PathName(lock, fnb, (long) MAX_ELEMS) !=0) {
UnLock(lock);
return fnb;
}
ewprintf("adjustname: PathName() failed!");
UnLock(lock);
return fn;
}
if (!(p = rindex(fnb, '/')))
p = index(fnb, ':');
p++;
strcpy((dup = malloc(strlen(p) + 1)), p);
*p = '\0';
if (lock = Lock(fnb, SHARED_LOCK)) {
if (PathName(lock, fnb, (long) MAX_ELEMS) != 0) {
UnLock(lock);
TackOn(fnb, dup);
free(dup);
return fnb;
}
ewprintf("adjustname: PathName() failed!");
UnLock(lock);
}
free(dup);
#endif
return fn; /* if all else fails */
}
/*
* Functions to read/write into the I/O buffer
*/
int FlushBuf()
{
if (niobuf > 0) {
iostat = Write(ffh, iobuf, (ULONG) niobuf);
niobuf = 0;
}
}
/*
* Fill up the input buffer and return the first character in it.
*/
int FillBuf()
{
if ((iostat = Read(ffh, iobuf, (ULONG) NIOBUF)) <= 0L)
return (EOF);
ibufo = 0;
niobuf = (int) iostat;
return (int) (iobuf[ibufo++]);
}
#ifndef NO_DIRED
#include "kbd.h"
copy(frname, toname)
char *frname, *toname;
{
#ifdef MANX
return fexecl("copy", "copy", frname, toname, (char *) 0);
#endif
#ifdef LATTICE
int error ;
if (error = forkl("copy", "copy", frname, toname, (char *) 0, (char *) 0, 2))
return error ;
return (int) wait(2) ;
#endif
}
BUFFER *dired_(dirname)
char *dirname;
{
register BUFFER *bp;
char line[256];
BUFFER *findbuffer();
char *tmpname, *mktemp();
int i;
VOID lfree();
if((dirname = adjustname(dirname)) == NULL) {
ewprintf("Bad directory name");
return NULL;
}
if(!isdirectory(dirname)) {
ewprintf("Not a directory: %s", dirname);
return NULL;
}
if((bp = findbuffer(dirname)) == NULL) {
ewprintf("Could not create buffer");
return NULL;
}
bclear(bp); /* clear out leftover garbage */
(void) strcpy(line, "list >");
(void) strncat(line, tmpname = mktemp("ram:mgXXX.XXX"), sizeof(line));
(void) strncat(line, " \"", sizeof(line));
(void) strncat(line, dirname, sizeof(line));
(void) strncat(line, "\"", sizeof(line));
Execute(line, 0L, 0L);
if (ffropen(tmpname) != FIOSUC) {
ewprintf("Can't open temporary dir file");
return NULL;
}
if (ffgetline(line, sizeof(line), &i) != FIOSUC ||
strncmp(line, "Directory", 9) != 0) {
ffclose();
DeleteFile(tmpname);
ewprintf("No such directory: `%s'", dirname);
return NULL;
}
line[0] = line[1] = ' ';
while (ffgetline(&line[2], sizeof(line)-3, &i) == FIOSUC) {
line[i+2] = '\0';
(VOID) addline(bp, line);
}
ffclose();
DeleteFile(tmpname);
bp->b_dotp = lforw(bp->b_linep); /* go to first line */
(VOID) strncpy(bp->b_fname, dirname, NFILEN);
if((bp->b_modes[0] = name_mode("dired")) == NULL) {
bp->b_modes[0] = &map_table[0];
ewprintf("Could not find mode dired");
return NULL;
}
bp->b_nmodes = 0;
return bp;
}
#ifdef LATTICE
char *
mktemp(pattern)
char *pattern;
{
/* quick hack mktemp for this purpose only */
register char *name, *printo ;
register unsigned short counter = 0 ;
if ((name = malloc(strlen(pattern) + 5)) == NULL)
panic("Manx sucks rocks!") ;
(VOID) strcpy(name, pattern) ;
printo = name + strlen(name) ;
do
(void) sprintf(printo, "%d", counter += 1) ;
while (counter > 0 && access(name, 0) == 0) ;
if (counter == 0) panic("Manx _really_ sucks!") ;
return name ;
}
#endif
#define LIST_LINE_LENGTH 58 /* Size of line from List */
d_makename(lp, fn)
register LINE *lp;
register char *fn;
{
register char *cp;
int n = 2;
if(llength(lp) < LIST_LINE_LENGTH) return ABORT;
if(lgetc(lp, 2) == ':') return ABORT; /* FileNote line */
(VOID) strcpy(fn, curbp->b_fname);
cp = fn + strlen(fn);
if ((cp[-1] != ':') && (cp[-1] != '/')) /* append '/' if needed */
*cp++ = '/';
while (lgetc(lp, n) != ' ') {
*cp++ = lgetc(lp, n);
n++;
}
*cp = '\0';
return strncmp(&lp->l_text[31], "Dir", 3) == 0;
}
static isdirectory(name)
char *name;
{
struct FileLock *lock;
struct FileInfoBlock *fib;
int result;
if ((lock = Lock(name, ACCESS_READ)) == NULL)
return FALSE;
if ((fib = (struct FileInfoBlock *)
AllocMem((long)sizeof(struct FileInfoBlock),MEMF_PUBLIC))==NULL) {
UnLock(lock);
return FALSE;
}
result = (fib->fib_DirEntryType > 0L) ? TRUE : FALSE;
FreeMem(fib,(long)sizeof(struct FileInfoBlock));
UnLock(lock);
return result;
}
#endif
#ifndef USE_ARP
/*
* Here are work-alikes for the few ARP commands now used by the
* Amiga version of mg. These may go away if we require ARP in future.
*/
Strcmp(s1, s2)
register char *s1, *s2;
{
while (tolower(*s1) == tolower(*s2)) {
if (*s1 == '\0')
return 0;
s1++; s2++;
}
return (tolower(*s1) < tolower(*s2) ? -1 : 1);
}
/*
* This PathName function shamelessly stolen from the Matt Dillon Shell.
* It is a slight mod of that program's get_pwd routine, from comm1.c.
*/
long
PathName(flock, pwdstr, nentries)
struct Lock *flock;
long nentries;
char *pwdstr;
{
char *ptr;
char *name;
int err=0;
struct FileLock *lock, *newlock, *ParentDir(), *DupLock();
long Examine();
struct FileInfoBlock *fib;
int i, len, n;
lock = DupLock(flock);
n = nentries * FCHARS + 1;
fib = (struct FileInfoBlock *)AllocMem((long)sizeof(struct FileInfoBlock),
MEMF_PUBLIC);
pwdstr[i = n-1] = '\0';
while (lock) {
newlock = ParentDir(lock);
if (!Examine(lock, fib)) ++err;
name = fib->fib_FileName;
if (*name == '\0') /* HACK TO FIX RAM: DISK BUG */
name = "RAM";
len = strlen(name);
if (newlock) {
if (i == n-1) {
i -= len;
movmem(name, pwdstr + i, len);
} else {
i -= len + 1;
movmem(name, pwdstr + i, len);
pwdstr[i+len] = '/';
}
} else {
i -= len + 1;
movmem(name, pwdstr + i, len);
pwdstr[i+len] = ':';
}
UnLock(lock);
lock = newlock;
}
FreeMem(fib, (long)sizeof(struct FileInfoBlock));
movmem(pwdstr + i, pwdstr, n - i);
if (err) return(0L);
return((long) n - i - 1);
}
void TackOn(path, file)
char *path, *file;
{
if (*file != '\0') {
if (path[strlen(path)-1] != ':')
strcat(path, "/");
strcat(path, file);
}
}
#endif
SHAR_EOF
cat << \SHAR_EOF > sys/amiga/malloc.c
/*
* Hello Mic:
*
* After mailing the first message to you about the free() function I
* decide on a solution similar to the one you sugested in your reply. There
* is one disadvantage with this solution it requires an extra 4 bytes for
* the link information beyond the original 8 bytes already required by each
* block. If we can find a clean way of deallocating stuff within EMACS such
* as killing each buffer and all the other structures we will save 8 bytes
* per allocation (leaving only the 4 bytes for the block size). Anyways
* here is my doubly linked list version of free() which works very fast
* but takes up a bit more memory.
*
* Later,
* Leon
*
*/
/* name: malloc.c
* desc: An improved malloc() and free() function for Aztec c
* date: 04/02/87 LF
* note: This takes over the Aztec _cln() function that is called by
* the startup code once main() returns.
*/
#define NULL 0L
struct mem {
struct mem *next, *prev;
long size;
};
static struct mem *Free;
void *_AllocMem();
static
cleanup()
{
register struct mem *mp, *xp;
for (mp=Free;mp;mp=xp) {
xp = mp->next;
_FreeMem(mp, mp->size+sizeof(struct mem));
}
Free = 0;
}
char *
lmalloc(size)
unsigned long size;
{
register struct mem *ptr;
extern int (*_cln)();
_cln = cleanup;
if ((ptr = _AllocMem(size+sizeof(struct mem), 0L)) == 0)
return(0);
ptr->next = Free;
if (Free != NULL)
{
Free->prev = ptr;
}
ptr->prev = NULL;
ptr->size = size;
Free = ptr;
return((char *)ptr + sizeof(struct mem));
}
char *
malloc(size)
unsigned size;
{
return(lmalloc((unsigned long)size));
}
free(blk)
char *blk;
{
register struct mem *mp, *xp, *xn;
mp = (struct mem*)(blk - sizeof(struct mem));
xp = mp->prev;
xn = mp->next;
if (xn != NULL)
{
xn->prev = xp;
}
if (xp == NULL)
{
Free = xn;
}
else
{
xp->next = xn;
}
_FreeMem(mp, mp->size+sizeof(struct mem));
return(0);
}
SHAR_EOF
# End of shell archive
exit 0
-------