MeddleDoc.tioga
Carl Waldspurger, September 1, 1986 1:48:08 am PDT
MEDDLE: A Mathematics Editing and Display Environment
CEDAR 6.1 — FOR INTERNAL XEROX USE ONLY
MEDDLE
A Mathematics Editing and Display Environment
Carl Waldspurger
© Copyright 1986 Xerox Corporation. All rights reserved.
Abstract: MEDDLE is an interactive syntax-directed WYSIWYG mathematics editor and display system which can be used for mathematics formatting in documents (via Tioga character artwork) and as an integrated part of a computer algebra system (currently Dennis Arnon's CaminoReal).
Created by: Carl Waldspurger
Maintained by: Dennis Arnon <Arnon.pa>
Keywords: MEDDLE, Math Editor, WYSIWYG, Computer Algebra
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. Introduction
Starting up
To start up MEDDLE, simply issue "Run Meddle" to the CommandTool.
This registers two commands, "MeddleOpen" and "MeddleArtwork":
"MeddleOpen foo" opens a new MEDDLE viewer named foo.
"MeddleArtwork on" enables MEDDLE formatting of Tioga character artwork with
property $MeddleExpr. Similarly, "MeddleArtwork off" disables this feature.
See documentation for CaminoReal for a discussion of MEDDLE's role in a computer
algebra system.
Terminology
The following terminology will be used in this document:
PlaceHolder:
A placeholder is an empty expression which needs to be filled in.
It is similar in appearance and function to placeholders () in Tioga, with
the exception that MEDDLE placeholders are never optional.
Replace:
"Replace old with new" means to delete old and insert new in its place.
Wrap:
"Wrap template foo around bar" means to use bar to fill in a placeholder in
template foo. After the wrap, bar is a subexpression of foo.
2. Selecting expressions
What can you select?
You can select any MEDDLE expression or subexpression.
You cannot select individuals symbols in an expression.
Example:
If you are editing a template for a summation, you can select any of the summation's
subexpressions (lowerlimit, upperlimit, summand) or the entire summation expression.
You cannot, however, select the sigma symbol by itself in the summation (clicking on the
sigma will actually select the entire summation expression).
Since MEDDLE expressions can be thought of as trees (with operators at nodes and atoms at leaves),
MEDDLE provides ways to move through the expression tree with a minimum of fuss.
Operations are available which allow you to: extend a selection to include its parent
expression (moving up the tree), narrow a selection to a child expression (moving down
the tree), and change a selection to select a sibling expression (same level in tree).
Thus, both MEDDLE and Tioga have hierarchical tree-like structures and commands for
selecting subtrees and leaves.
There are three (well, really four) selection types, again similar in appearance and
function to Tioga selections:
Primary selection:
Selected expression is highlighted by rendering it white on black, which is
inverted from the normal black on white (just like Tioga).
Copy selection:
Selected expression is highlighted in dark gray.
Move selection:
Selected expression is highlighted in light gray.
Active keyboard selection (KB Selection):
This selection type cannot be applied by the user. The selected expression
highlighted using horizontal gray lines. This selection type is automatically
invoked when there is an active keyboard entry for an atom (e.g. a number or
variable). Its purpose is mostly as an indicator. However, when template
wrapping is invoked from the keyboard, an active keyboard selection is used
like a primary selection. (yes, I know this isn't so great and should be made more uniform,
but I have a plane to catch - It wouldn't be too hard to fix).
How can you select?
You can select MEDDLE expressions using either the mouse or keyboard (mostly the mouse).
To select an expression with the mouse, simply point at the expression you wish to
select and click the appropriate button. The selected expression will be the smallest
expression (greatest depth in tree) which contains the point specified by the mouse. If you
think of each expression as being enclosed by a bounding box, this is the expression
enclosed by the smallest box which contains the point specified by the mouse.
The following mappings are currently used (if you're a TIP table hacker, you can improve on them):
Single Clicks:
Red => Primary Select
Shift Red => Copy Select
Ctrl Red => Move Select
Blue => Primary Sibling Select
Shift Blue => Primary Child Select
Double Clicks:
Red => Extend Primary Selection to Parent
Shift Red => Extend Copy Selection to Parent
Ctrl Red => Extend Move Selection to Parent
Other:
DEL => Delete Primary Selection
Ctrl-P => Primary Select Parent of current Primary or KB selection
3. Entering Expressions
Using Menus:
ReplaceWithMatrix:
Replaces the primary selection with a matrix expression.
The dimensions for the matrix are chosen from pop-up menus.
(note: MEDDLE can support arbitrarily big matrices, but the current user interface restricts
the maximum dimension to be 10 x 10.)
The matrix is initialized by setting all elements = 0.
This is useful when entering sparse matrices, and isn't really a hindarance when
you aren't.
ReplaceWithVector:
Replaces the primary selection with a vector expression.
The type (row or column) and dimension for the vector are chosen from pop-up menus.
(note: MEDDLE can support arbitrarily big vectors, but the current user interface restricts
the maximum dimension to be 10.)
The vector is initialized by setting all elements = 0.
Vectors are really just special cases of matrices, but for some applications (e.g. CaminoReal)
it is desireable to maintain a distinction between vectors and matrices.
ReplaceWithExpr:
Replaces the primary selection with a template for a compound expression.
The template (operation) is chosen from a pop-up menu.
ReplaceWithAtom:
Replaces the primary selection with an atomic expression.
The type of atom is chosen from a pop-up menu. Depending on the type of atom
selected, the atom value is either obtained from additional pop-up menus or from
a Tioga viewer selection. For example, "ReplaceWithAtom Integer" tries to get an
integer from an active text selection, and "ReplceWithAtom GreekVariable" provides
a pop-up menu of choices for the variable.
WrapWithExpr:
Wraps a template around the primary selection. In other words, the primary selection
is used to fill in a placeholder in the template. This placeholder is usually the first
(e.g. "a" in "a + b") or most important (e.g. integrand in integration) argument to the
template. (Yes, of course the "hot" argument should be highlighted in the pop-up menu, but unfortunately
the pop-up menus package can't switch fonts between chars or even selections. Other alternatives
looked bad.) The template (operation) is chosen from a pop-up menu.
Using the keyboard:
MEDDLE allows keyboard input for the most common atoms and compound types.
Integer, Real, and Variable atoms can be typed directly into a selected expression.
As mentioned in the section on selections, the active keyboard selection will be selected
and highlighted using horizontal gray lines. This selection is terminated as soon as
a primary selection is made or any editing function is invoked (you can always select
outside of an expression to get rid of the selection).
Typing operator characters into a selected expression performs a template wrap around
the currently active keyboard or primary selection. Currently supported keys include
+, -, *, &, |, ~, #, =, >, <, /, etc. This allows what I call "pseudo-infix" input
instead of the prefix type input required when using menus. For example, to enter
"a + b", simply select a placeholder, then type "a", "+", "b". What is really going on
is that the operation "+" is wrapped around the expression "a", and the placeholder for
the augend is auto-selected. Typing the "b" fills in the augend placeholder. The
ctrl-P "select parent" operation is very useful for keyboard input to avoid switching
beteen the keyboard and the mouse. For example, to (correctly) enter "x^2 + 1 = 0",
use the keystrokes "x", "^", "2", ctrl—P, "+", "1", ctrl-P, "=", "0".
(Note: This method is far from ideal. The user should be able to type "soft" parentheses
which would elminate the need for most ctrl-P's. This also opens up the can of worms
called "operator precedences" and "automatic parentheses generation" which should be
considered for any future systems such as MEDDLE).
4. MEDDLE Operations (Menu Buttons)
Scale:
Scales the contents of the viewer.
red => scale by factor of 1.5 (zoom)
yellow => remove all scaling and return to default size (normal)
blue => scale by factor of 1/1.5 (shrink)
Home:
Moves the expression to its default location at the lower left-hand corner of the
viewer. This is useful if you used the bi-scrollers and "lost" the expression somewhere
on the infinite plane.
Undo:
Undoes the last operation which changed the contents of the viewer.
Undo in MEDDLE, unlike Tioga, undoes the last change to an individual viewer, not
to the global collection of active viewers. There are pros and cons to this approach.
Undo also clobbers (i.e. unselects) any active selections in the viewer.
ToRope:
This operation opens a new text viewer whose contents is the linear (i.e. ROPE form)
MEDDLE expression for the current primary selection. This operation is used to
create a text representation of a MEDDLE expression which can be saved to a file or
used as a property value for a Tioga MeddleExpr Artwork Character.
FromRope:
This operation copies a previously generated linear MEDDLE expression into a MEDDLE
viewer. To do this, first make a primary selection in the MEDDLE viewer. Next select
the linear form in the text viewer which contains it. Then click on FromRope.
The primary selection is replaced by the expression represented by the linear form.
Gee, this paragraph doesn't parse too cleanly. It really isn't tricky - this operation
behaves how you would expect it to (things always seem intuitive to the implementor!).
ToASRope:
This operation is similar to the ToRope operation, except that the linear form generated
is in a format which is readable by Dennis Arnon's AlgebraStructures and CaminoReal
computer algebra systems.
ReplaceWithMatrix, ReplaceWithVector, ReplaceWithExpr, ReplaceWithAtom, WrapWithExpr:
See Section Three, "Entering Expressions".
Debug:
Bugging (no pun intended) Debug raises a resumable Break SIGNAL.
The state of the viewer and the currently displayed expression can be
examined in the symbolic debugger.