[comp.sys.amiga] Add a System Key to the Amiga

rokicki@polya.Stanford.EDU (Tomas G. Rokicki) (07/19/88)

Mackie 1.1 (beta release for 1.2) is now available.  This revision has
significantly greater functionality than the original Mackie, and I am
releasing it in hopes of getting comments and improvements.

To get the program, anonymous ftp it from labrea.stanford.edu (in ~pub)
or send me mail; I'll send it to you by Email or physical mail (at least
to the first 20 people who ask).  You'll get both source and executable;
comments on the source is greatly appreciated.

Those of you who have used Lisp machines or TI Explorers will recognize
how this works.  I've added a `System' key to the Amiga, by taking over
the help key.  If I want to edit a file, I simply hit `Help' then `E'.
If an editor already has a window open, it will be popped to front;
otherwise, an editor will be spawned.  Similarly, `Help' `V' will give
me a VT100 window, whether one exists or not.  If I want a new editor,
regardless of ones that current exist, `Help' CTRL-E will give me one.

Let's plunge right in, by examining my current startup file.

*
*   Typical .mackierc file; set the default pop
*   command:
*
command "newwsh con:10/10/640/200/MackieCLI"
;
;   and the timeout:
;
timeout 200
#
#   Now define some system keys
#
space cli "" "newwsh"
t cli "tex*" "newwsh con:20/20/640/100/texwsh cmd tex"
p intuition "preview*" "preview"
e intuition "mg*" "mg"
v intuition "vt100*" "run vt100"
d intuition "dfc*" "dfc"

w intuition ""

So, all the POPCLI stuff is still in there.  I'll address the system keys
one by one.

The line that starts with `space' means that whenever `Help' `Space' is
pressed, the next CLI window that matches the empty string is brought
to the front.  The only CLI windows with a null command are the ones
not executing a command, so this gives me a CLI ready for a command.

The line that starts with `t' means that `Help' `t' will look for a CLI
executing a command starting with the three characters `tex', and pop it
to front.  If one doesn't exist, one is started.  Note that all string
comparisons here are case insensitive, and that `*' means match all the
rest of the characters.

The syntax for the startup file is each line is an empty line, a comment,
a parameter line, or a system key definition.  Comment lines start with
semicolons, hashes, or splats.  Parameter lines start with `command',
`timeout', `blank', or `lines'.  Timeout must be folled by a number,
and command must be followed by a string.  Separators are tabs, spaces,
equal signs, commas, or hyphens.

System key definitions start with the key being defined.  Allowable
keys are A-Z or 0-9 (as themselves), F1 through F10 for the function
keys, or Space for the space key.  The keyword `Shift' can precede the
key.  After the key, an optional `CLI' or `Intuition' keyword can be
placed.  These will be described later.

After the optional keyword, one or two strings should be found.  The
first string is the command to match; the second string (if given) is
the command to execute if no matches are found.  This command should
return relatively quickly; if the program doesn't detach, then you want
to precede the command with a `run' or `newcli' so it does.

Strings are bracketed by double quotes; a backslash-double quote means
a literal double quote.

Any key that doesn't have a definition in the startup file gets a default
definition; for the letter keys A-Z, the default definition is

X "X*"

for example, which means match any window starting with `X', be it a CLI
or an Intuition window.  The number keys match only the CLI with that
particular number.  The space key by default matches any window (so it just
cycles all of the windows), and the function keys match nothing.

Windows are not matched by their title; the title is often blank or used
for error messages and the like.  Instead, windows are matched by the
name of the task associated with the window for Intuition windows, or the
command being executed by the CLI in the case of CLI windows.  Thus, the
program doesn't work very well with programs that use strange task names.
For instance, Manx db uses the name `Aztec_db', so you'd have to match
that, rather than the intuitive `db'.

There are three classes of programs.  There are those programs that run
from the workbench or detach themselves from a CLI; these programs have
only an Intuition window associated with them.  An example of this class
is Manx `db'.  There are those programs that interact only through the CLI
windows; an example of these is `tex'.  And finally, there are programs
that run from a CLI but do their interaction through an Intuition window;
an example of this is `vt100'.

Only the third class offers any ambiguity; the question is whether to
active the CLI window or the Intuition window.  But the type of window is
usually specified for the other kinds anyway, to help limit the search.

If you give a search string such as `!xyzzy!' that isn't likely to be
matched, then the command string is always executed, so you can bind
arbitrary commands to a system key.

Oh, yes; one important thing.  Hitting `help' twice passes a help key
on through the input stream, so you haven't lost your help key.

The code will only compile with Manx.

Usage is simply:

   run mackie [-q] [-l] [-b] [-f filename] [command] [time]

Note that it doesn't automatically detach itself, so the `RUN' is
necessary.  The first time you run it, it loads itself into RAM.
Subsequent invocations need not be `run', as they notice the running
portion of the program and simply send new parameters to it.

The options mean:

   -q             Quit.  Remove the resident portion from memory.
   -l             Lines.  Draw lines instead of a blank screen.  (Default)
   -b             Blank.  Draw a blank screen instead of fancy lines.
   -f filename    Startup file (default is s:.mackierc).

A time is an argument that starts with a digit; this time is in seconds.
After that much inactivity, the screen blanking starts.

A command is an argument that starts with neither digits nor a hyphen.
This is the command executed whenever left-amiga ESC is pressed.

Thus, the command

   run mackie "newcli con:10/10/640/200/MackieCLI"

starts mackie up, and sets the command to be executed to a NewCLI with a
specified size.  Later, if you want to see the screen blanking feature
quickly, just type

   mackie 1

and in a second, the screen will go blank.  If the lines are driving you
wild, you might type

   mackie -b

to turn them off.  Finally, you need every byte of memory, so you want to
remove mackie.  Simply type

   mackie -q

That's all there is to it.

Enjoy this program!  Send bug reports to Tomas Rokicki, Box 2081,
Stanford, CA  94309.

Based on:

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* |_o_o|\\ Copyright (c) 1986 The Software Distillery.  All Rights Reserved */
/* |. o.| || This program may not be distributed without the permission of   */
/* | .  | || the authors.                                                    */
/* | o  | ||    Dave Baker     Ed Burnette  Jay Denebeim John Mainwaring     */
/* |  . |//     Gordon Keener  Jack Rouse   John Toebes  Doug Walker         */
/* ======                    BBS:(919)-471-6436                              */ 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

POPCLI III by John Toebes ) 1987 The Software Distillery.  All Rights Reserved
 235 Trillingham Ln, Cary, NC 27511
 
Contributions to continue development of this and other fine products for the
Amiga should be sent to the Software Distillery at the above address.

Other Products produced by the Software Distillery are:
   BLINK    - the Turbo-charged Alink replacement
   HACK     - The Amiga port of the famous UNIX game
   LARN     - Another famous UNIX game
   MEMWATCH - Protects your machine from random trashes
   MAKE     - A software development tool one shouldn't be without
   KERMIT   - The World renown file transfer protocol brought to the Amiga
   ICONEXEC, SETALTERNATE, SETWINDOW - Icon manipulation tools
   TSIZE    - A short utility for determining directory sizes.
All of these are available on our BBS.

Permission is hereby granted to distribute this program provided both this
documentation accompanies the executable and that no charge is made for its
distribution.

POPCLI (pronounced POP-SEE-EL-EYE) is designed to solve two problems at once.
First it provides a simple way of starting another CLI at any time without
having to load workbench or exit whatever program you may be using.  Second
it has a builtin screen saver mode that automatically turns off the Amiga
display when there has been no input for a given period of time.