diff --git a/docs/primer/001-TITLEPAGE.TEDIT b/docs/primer/001-TITLEPAGE.TEDIT deleted file mode 100644 index f8ca0e89..00000000 Binary files a/docs/primer/001-TITLEPAGE.TEDIT and /dev/null differ diff --git a/docs/primer/002-PREFACE.TEDIT b/docs/primer/002-PREFACE.TEDIT deleted file mode 100644 index 54932787..00000000 Binary files a/docs/primer/002-PREFACE.TEDIT and /dev/null differ diff --git a/docs/primer/003-TOC.TEDIT b/docs/primer/003-TOC.TEDIT deleted file mode 100644 index 64166d16..00000000 Binary files a/docs/primer/003-TOC.TEDIT and /dev/null differ diff --git a/docs/primer/01-GLOSSARY.TEDIT b/docs/primer/01-GLOSSARY.TEDIT deleted file mode 100644 index 37aab11a..00000000 Binary files a/docs/primer/01-GLOSSARY.TEDIT and /dev/null differ diff --git a/docs/primer/02-TYPING-SHORTCUTS.TEDIT b/docs/primer/02-TYPING-SHORTCUTS.TEDIT deleted file mode 100644 index df0dab88..00000000 Binary files a/docs/primer/02-TYPING-SHORTCUTS.TEDIT and /dev/null differ diff --git a/docs/primer/03-USING-MENUS.TEDIT b/docs/primer/03-USING-MENUS.TEDIT deleted file mode 100644 index bad688f8..00000000 Binary files a/docs/primer/03-USING-MENUS.TEDIT and /dev/null differ diff --git a/docs/primer/04-USING-FILES.TEDIT b/docs/primer/04-USING-FILES.TEDIT deleted file mode 100644 index 2ba249bf..00000000 Binary files a/docs/primer/04-USING-FILES.TEDIT and /dev/null differ diff --git a/docs/primer/05-FILEBROWSER.TEDIT b/docs/primer/05-FILEBROWSER.TEDIT deleted file mode 100644 index 2edd9864..00000000 Binary files a/docs/primer/05-FILEBROWSER.TEDIT and /dev/null differ diff --git a/docs/primer/06-WINDOWS.TEDIT b/docs/primer/06-WINDOWS.TEDIT deleted file mode 100644 index 523d9bf1..00000000 Binary files a/docs/primer/06-WINDOWS.TEDIT and /dev/null differ diff --git a/docs/primer/07-EDITING-AND-SAVING.TEDIT b/docs/primer/07-EDITING-AND-SAVING.TEDIT deleted file mode 100644 index e5ed9005..00000000 Binary files a/docs/primer/07-EDITING-AND-SAVING.TEDIT and /dev/null differ diff --git a/docs/primer/08-YOUR-INIT.TEDIT b/docs/primer/08-YOUR-INIT.TEDIT deleted file mode 100644 index 4b67ddc3..00000000 Binary files a/docs/primer/08-YOUR-INIT.TEDIT and /dev/null differ diff --git a/docs/primer/09-FLEXIBILITY.TEDIT b/docs/primer/09-FLEXIBILITY.TEDIT deleted file mode 100644 index 58c54baf..00000000 Binary files a/docs/primer/09-FLEXIBILITY.TEDIT and /dev/null differ diff --git a/docs/primer/10-BREAK-MENU.TEDIT b/docs/primer/10-BREAK-MENU.TEDIT deleted file mode 100644 index 615c2dc7..00000000 Binary files a/docs/primer/10-BREAK-MENU.TEDIT and /dev/null differ diff --git a/docs/primer/11-WHAT-TO-DO.TEDIT b/docs/primer/11-WHAT-TO-DO.TEDIT deleted file mode 100644 index dffdcad6..00000000 Binary files a/docs/primer/11-WHAT-TO-DO.TEDIT and /dev/null differ diff --git a/docs/primer/12-WINDOWS.TEDIT b/docs/primer/12-WINDOWS.TEDIT deleted file mode 100644 index 9c8de454..00000000 Binary files a/docs/primer/12-WINDOWS.TEDIT and /dev/null differ diff --git a/docs/primer/13-WHAT-ARE-MENUS.TEDIT b/docs/primer/13-WHAT-ARE-MENUS.TEDIT deleted file mode 100644 index b3d177bc..00000000 Binary files a/docs/primer/13-WHAT-ARE-MENUS.TEDIT and /dev/null differ diff --git a/docs/primer/14-BITMAPS.TEDIT b/docs/primer/14-BITMAPS.TEDIT deleted file mode 100644 index 54c9ba3c..00000000 Binary files a/docs/primer/14-BITMAPS.TEDIT and /dev/null differ diff --git a/docs/primer/15-DISPLAYSTREAMS.TEDIT b/docs/primer/15-DISPLAYSTREAMS.TEDIT deleted file mode 100644 index 7dcc9a4c..00000000 Binary files a/docs/primer/15-DISPLAYSTREAMS.TEDIT and /dev/null differ diff --git a/docs/primer/16-FONTS.TEDIT b/docs/primer/16-FONTS.TEDIT deleted file mode 100644 index 17b5e8ca..00000000 Binary files a/docs/primer/16-FONTS.TEDIT and /dev/null differ diff --git a/docs/primer/17-INSPECTOR.TEDIT b/docs/primer/17-INSPECTOR.TEDIT deleted file mode 100644 index 3dcbf68a..00000000 Binary files a/docs/primer/17-INSPECTOR.TEDIT and /dev/null differ diff --git a/docs/primer/18-MASTERSCOPE.TEDIT b/docs/primer/18-MASTERSCOPE.TEDIT deleted file mode 100644 index 8feeb509..00000000 Binary files a/docs/primer/18-MASTERSCOPE.TEDIT and /dev/null differ diff --git a/docs/primer/19-SPY.TEDIT b/docs/primer/19-SPY.TEDIT deleted file mode 100644 index 70033bb5..00000000 Binary files a/docs/primer/19-SPY.TEDIT and /dev/null differ diff --git a/docs/primer/20-FREE-MENUS.TEDIT b/docs/primer/20-FREE-MENUS.TEDIT deleted file mode 100644 index 8f98a42d..00000000 --- a/docs/primer/20-FREE-MENUS.TEDIT +++ /dev/null @@ -1,48 +0,0 @@ -1 Medley for the Novice, Release 2.0 1 Medley for the Novice, Release 2.0 20. FREE MENUS 1 20. FREE MENUS 1 "20"20. FREE MENUS 6 Free Menu(FREE% MENU NIL Free% Menu NIL NIL 1) is a library package that is even more flexible than the regular menu package. It allows you to create menus with different types of items in them, and formats them as you require. Free menus are particularly useful when you want a "fill in the form" type interaction with the user. Each menu item is described with a list of properties and values. The following example will give you an idea of the structure of the description list, and some of your options. The most commonly used properties, and each type of menu item will be described in the Parts of a Free Menu Item and Types of Free Menu Items section below. Free Menu Example 1 Free menus can be created(FREE% MENU NIL Free% Menu NIL NIL 1 SUBNAME CREATING SUBTEXT creating) and formatted(FREE% MENU NIL Free% Menu NIL NIL 1 SUBNAME FORMATTING SUBTEXT formatting) automatically! It is done with the function FM.FORMATMENU(FM.FORMATMENU (Function) NIL NIL NIL 1). This function takes one argument, a description of the menu. The description is a list of lists; each internal list describes one row of the free menu. A free menu row can have more than one item in it, so there are really lists of lists of lists! It really isn't hard, though, as you can see from the following example: (SETQ ExampleMenu (FM.FORMATMENU '(((TYPE TITLE LABEL TitlesDoNothing) TYPE 3STATE LABEL Example3State)) ((TYPE EDITSTART LABEL PressToStartEditing ITEMS (EDITEM)) (TYPE EDIT ID EDITEM LABEL "")) (WINDOWPROPS TITLE "Example Does Nothing")))) The first row has two items in it: one is a TITLE, and the second is a 3STATE item. The second row also has two items. The second, the EDIT item, is invisible, because its label is an empty string. The caret will appear for editing, however, if the EDITSTART item is chosen. Windowprops can appear as part of the description of the menu, because a menu is, affer all, just a special window. You can specify not only the title with WINDOWPROPS, but also the position of the free menu, using the "left" and "bottom" properties, and the width of the border in pixels, with the "border" property. Evaluating this expression will return a window. You can see the menu by using the function OPENW(OPENW (Function) NIL NIL NIL 1). The following example illustrates this: Figure 20.1. Example Free Menu The next example shows you what the menu looks like after the EDITSTART item, PressToStartEditing, has been chosen. Figure 20.2. Free menu after EDITSTART Item Chosen The following example shows the menu with the 3STATE item in its T state, with the item highlighted. (In the previous bitmaps, it was in its neutral state.) . Figure 20.3. Free menu with 3STATE Item in its T State Finally, Figure 20.4 shows the 3STATE item in its NIL state, with a diagonal line through the item Figure 20.4 Free menu with the 3STATE item in its NIL State If you would like to specify the layout yourself, you can do that too. See the Lisp Library Packages Manual for more information. Parts of a Free Menu Item 1 There are eight different types of items that you can use in a free menu(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME PROPERTIES SUBTEXT properties). No matter what type, the menu item is easily described by a list of properties, and values. Some of the properties you will use most often are listed below: LABEL (FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME PROPERTIES SUBTEXT properties SUBSUBNAME LABEL SUBSUBTEXT LABEL) Required for every type of menu item. It is the atom, string, or bitmap that appears as a menu selection. TYPE(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME PROPERTIES SUBTEXT properties SUBSUBNAME TYPE SUBSUBTEXT TYPE) One of eight types of menu items. Each of these are described in the section below. MESSAGE(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME PROPERTIES SUBTEXT properties SUBSUBNAME MESSAGE SUBSUBTEXT MESSAGE) The message that appears in the prompt window if a mouse button is held down over the item. ID(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME PROPERTIES SUBTEXT properties SUBSUBNAME ID SUBSUBTEXT ID) An item's unique identifier. An ID is needed for certain types of menu items. ITEMS(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME PROPERTIES SUBTEXT properties SUBSUBNAME ITEMS SUBSUBTEXT ITEMS) Used to list a series of choices for an NCHOOSE item, and to list the ID's of the editable items for an EDITSTART item. SELECTEDFN(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME PROPERTIES SUBTEXT properties SUBSUBNAME SELECTEDFN) The name of the function to be called if the item is chosen. Types of Free Menu(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME TYPES SUBTEXT types) Items 1 Each type of menu item is described in the following list, including an example description list for each one. MOMENTARY(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME TYPES SUBTEXT types SUBSUBNAME MOMENTARY SUBSUBTEXT MOMENTARY) This is the familiar sort of menu item. When it is selected, the function stored with it is called. A description for the function that creates and formats the menu looks like this: (TYPE MOMENTARY LABEL Blink-N-Ring MESSAGE "Blinks the screen and rings bells" SELECTEDFN RINGBELLS) TOGGLE(FREE% MENU NIL Free% Menu NIL NIL 2 SUBNAME TYPES SUBTEXT types SUBSUBNAME TOGGLE SUBSUBTEXT TOGGLE) This menu item has two states, T and NIL. The default state is NIL, but choosing the item toggles its state. The following is an example description list, without code for the SELECTEDFN function, for this type of item: (TYPE TOGGLE LABEL DwimDisable SELECTEDFN ChangeDwimState) 3STATE(FREE% MENU NIL Free% Menu NIL NIL 3 SUBNAME TYPES SUBTEXT types SUBSUBNAME 3STATE SUBSUBTEXT 3STATE) This type of menu item has three states, NEUTRAL, T, and NIL. NEUTRAL is the default state. T is shown by highlighting the item, and NIL is shown with diagonal lines. The following is an example description list, without code for the SELECTEDFN function, for this type of item: (TYPE 3STATE LABEL CorrectProgramAllOrNoSpelling SELECTEDFN ToggleSpellingCorrection) TITLE(FREE% MENU NIL Free% Menu NIL NIL 3 SUBNAME TYPES SUBTEXT types SUBSUBNAME TITLE SUBSUBTEXT TITLE) This menu item appears on the menu as dummy text. It does nothing when chosen. An example of its description: (TYPE TITLE LABEL "Choices:") NWAY(FREE% MENU NIL Free% Menu NIL NIL 3 SUBNAME TYPES SUBTEXT types SUBSUBNAME NWAY SUBSUBTEXT NWAY) A group of items, nnly one of which can be chosen at a time. The items in the NWAY group should all have an ID field, and the ID's should be the same. For example, to set up a menu that would allow the user to choose between Helvetica, Gacha, Modern, and Classic fonts, the descriptions might look like this (once again, without the code for the SELECTEDFN): (TYPE NWAY ID FONTCHOICE LABEL Helvetica SELECTEDFN ChangeFont) (TYPE NWAY ID FONTCHOICE LABEL Gacha SELECTEDFN ChangeFont) (TYPE NWAY ID FONTCHOICE) LABEL Modern SELECTEDFN ChangeFont) (TYPE NWAY ID FONTCHOICE LABEL Classic SELECTEDFN Changefont) NCHOOSE(FREE% MENU NIL Free% Menu NIL NIL 3 SUBNAME TYPES SUBTEXT types SUBSUBNAME NCHOOSE SUBSUBTEXT NCHOOSE) This type of menu item is like NWAY except that the choices are given to the user in a submenu. The list to specify an NCHOOSE menu item that is analogous to the NWAY item above might look like this: (TYPE NCHOOSE LABEL FontChoices ITEMS Helvetica Gacha Modern Classic) SELECTDFN Changefont) EDITSTART (FREE% MENU NIL Free% Menu NIL NIL 3 SUBNAME TYPES SUBTEXT types SUBSUBNAME EDITSTART SUBSUBTEXT EDITSTART) When this type of menu itein is chosen, it activates another type of item, an EDIT item. The EDIT item or items associated with an EDITSTART item have their lD's listed on the EDITSTART's ITEMS property. An example description list is: (TYPE EDITSTART LABEL "Function to add?" ITEMS (Fn)) EDIT(FREE% MENU NIL Free% Menu NIL NIL 3 SUBNAME TYPES SUBTEXT types SUBSUBNAME EDIT SUBSUBTEXT EDIT) This type of menu item can actually be edited by you. It is often associated with an EDITSTART item (see above), but the caret that prompts for input will also appear if the item itself is chosen. An EDIT item follows the same editing conventions as editing in Executive Window: Add characters by typing them at the caret. Move the caret by pointing the mouse at the new position, and clicking the left button. Delete characters from the caret to the mouse by pressing the right button of the mouse. Delete a character behind the caret by pressing the backspace key. Stop editing by typing a carriage return, a Control-X, or by choosing another item from the menu. An example description list for this type of item is: (TYPE EDIT ID Fn LABEL **) (LIST ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "20-" "") STARTINGPAGE# 1) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "20-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (TEXT NIL NIL (54 54 504 690) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "20-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD LEFT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "20-" "")) (54 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGV) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE VERSOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 684) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "20-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "20-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE RECTOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 690) NIL)))))8ll8ll5522HH2HH -2HH2HH2H,HH --T-T25F PAGEHEADING VERSOHEADF PAGEHEADING RECTOHEADE PAGEHEADINGFOOTINGVE PAGEHEADINGFOOTINGR, CLASSIC -CLASSIC -TITAN -CLASSIC HELVETICAMODERN HELVETICACLASSIC - HELVETICA -MODERN - -TIMESROMAN - HRULE.GETFNMODERN - -"  HRULE.GETFNCLASSIC -#   HRULE.GETFNCLASSIC -  HRULE.GETFNCLASSIC - IM.CHAP.GETFN HELVETICA HRULE.GETFNMODERN  %IM.INDEX.GETFNN    HRULE.GETFNCLASSIC GIM.INDEX.GETFNKIM.INDEX.GETFN- (IM.INDEX.GETFND((/"%/ ,:n   IM.INDEX.GETFN+>   . [  . O   HRULE.GETFNCLASSIC HKIM.INDEX.GETFN  - mIM.INDEX.GETFNCLASSIC -k -kIM.INDEX.GETFNCLASSIC - U -qIM.INDEX.GETFNCLASSIC - \ -gIM.INDEX.GETFNCLASSIC - O -mIM.INDEX.GETFNCLASSIC - (9  - -aIM.INDEX.GETFNCLASSIC ->  AIM.INDEX.GETFN  HRULE.GETFNCLASSIC o - kIM.INDEX.GETFN HELVETICA- -eIM.INDEX.GETFN HELVETICA n -"   -eIM.INDEX.GETFN HELVETICA )(b -" %& -cIM.INDEX.GETFN HELVETICA n - -aIM.INDEX.GETFN HELVETICA O -   -gIM.INDEX.GETFN HELVETICA T$"'  - kIM.INDEX.GETFN HELVETICAO " $ + -6 -aIM.INDEX.GETFN HELVETICAW jL - -J - - V -7 - "uz \ No newline at end of file diff --git a/docs/primer/21-GRAPHER.TEDIT b/docs/primer/21-GRAPHER.TEDIT deleted file mode 100644 index 9520bb1b..00000000 Binary files a/docs/primer/21-GRAPHER.TEDIT and /dev/null differ diff --git a/docs/primer/22-RESOURCE-MANAGEMENT.TEDIT b/docs/primer/22-RESOURCE-MANAGEMENT.TEDIT deleted file mode 100644 index 1395787b..00000000 Binary files a/docs/primer/22-RESOURCE-MANAGEMENT.TEDIT and /dev/null differ diff --git a/docs/primer/23-INTERACTIONS.TEDIT b/docs/primer/23-INTERACTIONS.TEDIT deleted file mode 100644 index 01cd5992..00000000 --- a/docs/primer/23-INTERACTIONS.TEDIT +++ /dev/null @@ -1,28 +0,0 @@ -1 Medley for the Novice, Release 2.0 1 Medley for the Novice, Release 2.0 23. SIMPLE INTERACTIONS WITH CURSOR, BITMAP, AND WINDOW 1 23. SIMPLE INTERACTIONS WITH CURSOR, BITMAP, AND WINDOW 1 "23"23. SIMPLE INTERACTIONS WITH THE CURSOR, A BITMAP, AND A WINDOW 6 The purpose of this chapter is to show you how to build a moderately tricky interactive interface(INTERFACE NIL Interface NIL NIL NIL SUBNAME BUILDING SUBTEXT building) with the various Medley display facilities. In particular how to move a large bitmap (larger than 16 x 16 pixels) around inside a window. To do this, you will change the CURSORINFN and CURSOROUTFN properties of the window. If you would also like to then set the bitmap in place in the window, you must reset the BUTTONEVENTFN. This chapter explains how to create the mobile bitmap. GETMOUSESTATE Example Function 1 One function that you will use to "trace the cursor" (have a bitmap follow the cursor around in a window) is GETMOUSESTATE(GETMOUSESTATE (Function) NIL NIL NIL NIL). This function finds the current state of the. mouse, and resets global system variables, such as LASTMOUSEX(LASTMOUSEX (Variable) NIL NIL NIL NIL) and LASTMOUSEY(LASTMOUSEY (Variable) NIL NIL NIL NIL). As an example of how this function works, create a window by typing (SETQ EXAMPLE.WINDOW (CREATEW)) into the Executive Window, and sweeping out a window. Now, type in the function (DEFINEQ (PRINTCOORDS (W) (PROMPTPRINT "(" LASTMOUSEX ", "LASTMOUSEY ")") (BLOCK) (GETMOUSESTATE))) This function calls GETMOUSESTATE and then prints the new values of LASTMOUSEX and LASTMOUSEY in the promptwindow. To use it, type (WINDOWPROP EXAMPLE.WINDOW 'CURSORMOVEDFN 'PRINTCOORDS) The window property CURSORMOVEDFN(CURSORMOVEDFN (Property) NIL NIL NIL NIL), used in this example, will evaluate the function PRINTCOORDS(PRINTCOORDS (Function) NIL NIL NIL NIL) each time the cursor is moved when it is inside the window. The position coordinates of the mouse cursor will appear in the prompt window. (See Figure 23.1.) Figure 23.1. Current Position Coordinates of Mouse Cursor in Prompt Window Advising GETMOUSESTATE 1 For the bitmap to follow the moving mouse cursor, the function GETMOUSESTATE is advised. When you advise a function, you can add new commands to the function without knowing how it is actually implemented. The syntax for advise is (ADVISE fn when where what) fn is the name of the function to be augmented. when and where are optional arguments. when specifies whether the change should be made before, after, or around the body of the function. The values expected are BEFORE, AFTER, or AROUND. what specifies the additional code. In the example, the additional code, what, moves the bitmap to the position of the mouse cursor. The function GETNOUSESTATE will be ADVISEd when the mouse moves into the window. This will cause the bitmap to follow the mouse cursor. ADVISE will be undone when the mouse leaves the window or when a mouse button is pushed. The ADVISEing will be done and undone by changing the CURSORINFN, CURSOROUTFN, and BUTTONEVENTFN for the window. Changing the Cursor 1 One last part of the example, to give the impression that a bitmap is dragged around a window, the original cursor(CURSOR NIL Cursor NIL NIL NIL SUBNAME CHANGING SUBTEXT changing) should disappear. Try typing: (CURSOR (CURSORCREATE (BITMAPCREATE 1 l) 1 1] into the Executive Window. This causes the original cursor to disappear. It reappears when you type (CURSOR T) When the cursor is invisible, and the bitmap moves as the cursor moves, the illusion is given that the bitmap is dragged around the window. Functions for Tracing the Cursor 1 To actually have a bitmap trace (follow) the cursor(CURSOR NIL Cursor NIL NIL NIL SUBNAME TRACING SUBTEXT tracing), the environment must be set up so that when the cursor enters the tracing region the trace is turned on, and when the cursor leaves the tracing region the trace is turned off. The function Establish/Trace/Data will do this. Type it in as it appears (include comments that will help you remember what the function does). (DEFINEQ (Establish/Trace/Data [LAMBDA (wnd tracebitmap cursor/rightoffset cursor/heightoffset GCGAGP) (* * This function is called to establish the data to trace the desired bitmap. "wnd" is the window in which the tracing is to take place, "tracebitmap" is the tracing bitmap, "cursor/rightoffset" and "cursor/heightoffset" are integers which detemine the hotspot of the tracing bitmap. As "cursor/heightoffset and "cursor/rightoffset" increase the cursor hotspot moves up and to the right. If GCGAGP is non-NIL, GCGAG will be disabled.) (PROG NIL (if (OR (NULL wnd) (NULL tracebitmap)) then (PLAYTUNE (LIST (CONS 1000 4000))) (RETURN)) (if GCGAGP then (GCGAG)) (* * Create a blank cursor.) (SETQ *BLANKCURSOR*(BITMAPCREATE 16 16)) (SETQ *BLANKTRACECURSOR*(CURSORCREATE *BLANKCURSOR*)) (* * Set the CURSOR IN and OUT FNS for wnd to the following:) (WINDOWPROP wnd (QUOTE CURSORINFN) (FUNCTION SETUP/TRACE)) (WINDOWPROP wnd (QUOTE CURSOROUTFN) (FUNCTION UNTRACE/CURSOR)) (* * To allow the bitmap to be set down in the window by pressing a mouse button, include this line. Otherwise, it is not needed) (WINDOWPROP wnd (QUOTE BUTTONEVENTFN) (FUNCTION PLACE/BITMAP/IN/WINDOW)) (WINDOWPROP wnd (QUOTE CURSOROUTFN) (* * Set up Global Variables for the tracing operation) (SETQ *TRACEBITMAP* tracebitmap (SETQ *RIGHTTRACE/OFFSET*(OR cursor/rightoffset 0)) (SETQ *HEIGHTTRACE/OFFSET*(OR cxursor heightoffset 0)) (SETQ *OLDBITMAPPOSITION*(BITMAPCREATE (BITMAPWIDTH tracebitmap) (BITMAPHEIGHT tracebitmap))) (SETQ *TRACEWINDOW* wnd])) When the function Establish/Trace/Data is called, the functions SETUP/TRACE(SETUP/TRACE (Function) NIL NIL NIL NIL) and UNTRACE/CURSOR(UNTRACE/CURSOR (Function) NIL NIL NIL NIL) will be installed as the values of the window's WlNDOWPROPS, and will be used to turn the trace on and off. Those functions should be typed in, then: (DEFINEQ (SETUP/TRACE [LAMBDA (wnd) (* * This function is wnd's CURSORINFN. It simply resets the last trace position and the current tracing region. It also readvises GETMOUSESTATE to perform the trace function after each call.) (if *TRACEBITMAP* then (SETQ *LAST-TRACE-XPOS* -2000) (SETQ *LAST-TRACE-YPOS* -2000) (SETQ *WNDREGION* (WINDOWPROP wnd (QUOTE REGION))) (WINDOWPROP wnd (QUOTE TRACING) T) (* * make the cursor disappear) (CURSOR *BLANKTRACECURSOR*) (ADVISE (QUOTE GETMOUSESTATE) (QUOTE AFTER) NIL (QUOTE (TRACE/CURSOR])) (DEFINEQ (UNTRACE/CURSOR [LAMBDA (wnd) (* * This function is wnd's CURSOROUTFN. The function first checks if the cursor is currently being traced; if so, it replaces the tracing bitmap with what is under it and then turns tracing off by unadvising GETMOUSESTATE and setting the TRACING window property of *TRACEWINDOW* to NIL.) (if (WINDOWPROP *TRACEWINDOW*(QUOTE TRACING)) then (BITBLT *OLDBITMAPPOSITION* 0 0 (SCREENBITMAP) (IPLUS (CAR *WNDREGION*)*LAST-TRACE-XPOS*) (IPLUS (CADR *WNDREGION*)*LAST-TRACE-YPOS*)) (WINDOWPROP *TRACEWINDOW*(QUOTE TRACING) NIL)) (* * replace the original cursor shape) (CURSOR T) (* * unadvise GETMOUSESTATE) (UNADVISE (QUOTE GETMOUSESTATE])) The function SETUP/TRACE has a helper function that you must also type in. It is TRACE/CURSOR: (DEFINEQ (TRACE/CURSOR [LAMBDA NIL (* * This function does the actual BITBLTing of the tracing bitmap. This function is called after a GETMOUSESTATE, while tracing.) (PROG ((xpos (IDIFFERENCE (LASTMOUSEX *TRACEWINDOW*) *RIGHTTRACE/OFFSET*)) (ypos (IDIFFERENCE (LASTMOUSEY *TRACEWINDOW*) *HEIGHTTRACE/OFFSET*)) (* * If there is an error in the function, press the right button to unadvise the function. This will keep the machine from locking up.) (if (LASTMOUSESTATE RIGHT) then (UNADVISE (QUOTE GETMOUSESTATE))) (if (AND (NEQ xpos *LAST-TRACE-XPOS*) (NEQ ypos *LAST-TRACE-YPOS*)) then (* * Restore what was under the old position of the trace bitmap) (BITBLT *OLDBITMAPPOSITION* 0 0 (SCREENBITMAP) (IPLUS (CAR *WNDREGION*)*LAST-TRACE-XPOS*) (IPLUS (CADR *WNDREGION*)*LAST-TRACE-YPOS*)) (* * Save what will be under the position of the new trace bitmap) (BITBLT (SCREENBITMAP) (IPLUS (CAR *WNDREGION*) xpos) (IPLUS (CADR *WNDREGION*) ypos)*OLDBITMAPPOSITION* 0 0) (* * BITBLT the trace bitmap onto the new position of the mouse) (BITBLT *TRACEBITMAP* 0 0 (SCREENBITMAP) (IPLUS (CAR *WNDREGION*) xpos) (IPLUS (CADR *WNDREGION*) ypos) NIL NIL (QUOTE INPUT) (QUOTE PAINT)) (* * Save the current position as the last trace position.) (SETQ *LAST-TRACE-XPOS* xpos) (SETQ *LAST-TRACE-YPOS* ypos])) The helper function for UNTRACE/CURSOR, called UNDO/TRACE/DATA, must also be added to the environment: (DEFINEQ (UNDO/TRACE/DATA [LAMBDA NIL (* * The purpose of this function is to turn tracing off and to free up the global variables used to trace the bitmap so that they can be garbage collected.) (* * Check if the cursor is currently being traced. It so, turn it off.) (UNTRACE/CURSOR) (WINDOWPROP *TRACEWINDOW*(QUOTE CURSORINFN) NIL) (WINDOWPROP *TRACEWINDOW*(QUOTE CURSOROUTFN) NIL) (SETQ *TRACEBITMAP* NIL) (SETQ *RIGHTTRACE/OFFSET* NIL) (SETQ *HEIGHTTRACE/OFFSET* NIL) (SETQ *OLDBITMAPPOSITION* NIL) (SETQ *TRACEWINDOW* NIL) (* * Turn GCGAG on) (GCGAG T])) Finally, if you included the WlNDOWPROP to allow the user to place the bitmap in the window by pressing a mouse button, you must also type this function: (DEFINEQ (PLACE/BITMAP/IN/WINDOW [LAMBDA (wnd) (UNADVISE (GETMOUSESTATE)) (BITBLT *TRACEBITMAP* 0 0 (SCREENBITMAP) (IPLUS (CAR *WNDREGION*) xpos) (IPLUS (CADR *WNDREGION*) ypos) NIL NIL (QUOTE INPUT) (QUOTE PAINT] That's all the functions! Running the Functions 1 To run the functions you just typed in, first set a variable to a window by typing something like (SETQ EXAMPLE.WINDOW (CREATEW)) into the Executive Window, and sweeping out a new window. Now, set a variable to a bitmap, by typing, perhaps, (SETQ EXAMPLE.BTM (EDITBM)) Type (Estab1ish/Trace/Data EXAMPLE.WINDOW EXAMPLE.BTM)) When you move the cursor into the window, the cursor will drag the bitmap. (If you want to be able to make menu selections while tracing the cursor(CURSOR NIL Cursor NIL NIL NIL SUBNAME SETTING% THE% HOTSPOT SUBTEXT setting% the% hotspot), make sure that the hotspot of the cursor is set to the extreme right of the bitmap. Otherwise, the menu will be destroyed by the BITBLTs of the trace functions.) To stop tracing, do one of the following: f Move the mouse cursor out of the window f Press the right mouse button f Call the function UNTRACE/CURSOR (LIST ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "23-" "") STARTINGPAGE# 1) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "23-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (TEXT NIL NIL (54 54 504 690) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "23-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD LEFT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "23-" "")) (54 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGV) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE VERSOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 684) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "23-" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "23-" "")) (270 15 288 36) NIL) (HEADING NIL (HEADINGTYPE FOOTINGR) (54 27 558 36) NIL) (HEADING NIL (HEADINGTYPE RECTOHEAD) (54 762 558 36) NIL) (TEXT NIL NIL (54 54 504 684) NIL)))))5$DHHlDHHl>HHl2HTT,`l,H`,HH,ll,ll,ll,HH,HH,HH --T-T2F PAGEHEADING VERSOHEADF PAGEHEADING RECTOHEADE PAGEHEADINGFOOTINGVE PAGEHEADINGFOOTINGR, TITAN -CLASSIC -TITAN -CLASSIC HELVETICAMODERN HELVETICACLASSIC - HELVETICA -MODERN - -TIMESROMAN - HRULE.GETFNMODERN - -"  HRULE.GETFNCLASSIC -# 9  HRULE.GETFNCLASSIC -8  HRULE.GETFNCLASSIC - IM.CHAP.GETFN HELVETICAA HRULE.GETFNMODERN   aGIM.INDEX.GETFN - t 9 HRULE.GETFNCLASSICm *IM.INDEX.GETFNc -'IM.INDEX.GETFN -'IM.INDEX.GETFN  D   P - 5     # - -& 8  *IM.INDEX.GETFN3 (IM.INDEX.GETFNL  HRULE.GETFNCLASSIC?   .x   %E  _W, -   HRULE.GETFNCLASSIC rAIM.INDEX.GETFN . d -  ! HRULE.GETFNCLASSIC 3?IM.INDEX.GETFNo H < = 7 < 2 : . /  -    ,       ) 6  4   # $ $ '  ; /   & / $ :  4 7 E *     (IM.INDEX.GETFN+IM.INDEX.GETFN1 [  ( 9 a %!5"!       +/5.0+  * #   9  QM)'"C1.0E -"C+ - -< "  )      5   ,  -             -s !  )          HRULE.GETFNCLASSIC b  o   3 J  H[IM.INDEX.GETFN *+! *Wz \ No newline at end of file diff --git a/docs/primer/24-GLOBAL-VARIABLES.TEDIT b/docs/primer/24-GLOBAL-VARIABLES.TEDIT deleted file mode 100644 index 6346d140..00000000 Binary files a/docs/primer/24-GLOBAL-VARIABLES.TEDIT and /dev/null differ diff --git a/docs/primer/25-REFERENCES.TEDIT b/docs/primer/25-REFERENCES.TEDIT deleted file mode 100644 index d82bbe04..00000000 Binary files a/docs/primer/25-REFERENCES.TEDIT and /dev/null differ diff --git a/docs/primer/DRAFT.TEDIT b/docs/primer/DRAFT.TEDIT deleted file mode 100644 index f30e8fef..00000000 --- a/docs/primer/DRAFT.TEDIT +++ /dev/null @@ -1,4 +0,0 @@ -Primer from Scan TABLEOFCONTENTS ~)19 ~`~ 1. A Brief Glossary t 1.1 2. The Mouse and the Keyboard / 2.1 2.1. The Mouse 2.1 2.1.1. 2and3ButtonMice 2.1 2.2. _ The _ Keyhoard _ 2.2 2.2.1. _ The _ 1186 _ Keyhoard _ 2.2 2.2.2. _ The _ 1108 _ Keyhoard _ 2.2 3. Turning On Your Lisp Machine / 3.1 3.1. _ Turningonthello8 _ 3.1 3.2. _ Turning on _ the1186 _ 3.2 3.3. _ Loading _ lntertis~D from the _ Hard _ Disk _ 3.3 3.4. _ AfterBooting _ Lisp _ 3.5 3.5. _ Restarting _ Lisp After Logging _ Out _ 3.5 4. If You Have a Fileserver / 4.1 4.1. _ Turning on your 1108 _ 4.1 4.2. _ Turningonyourll86 _ 4.1 4.3. Location of Files 4.2 4.4. The Timeserver 4.2 5. Logging Out And Turning the Machine Off 51 5.1. _ Logging Out _ 5.1 5.2. _ Turning _ The _ MachineOff _ 5.2 6. Typing Shortcuts 6.1 6.1. _ If you _ makea _ Mistake _ 6.3 7. Using Menus 7.1 7.1. _ Making _ a _ Selection from _ a _ Menu _ 7.2 7.2. _ Explanations _ of _ Menu _ Items _ 7.2 7.3. Submenus 7.3 8. How to use Files 8.1 8.1. _ Types of Files _ 8.1 TA8~ OF CONTENtt To'., 1 - - - - . - - - - . - - , - TABLE OF CONTENtr 8.2. _ Directories _ 8.1 8.3. _ Directory Options _ 8.2 8.4. _ Subfile _ Directories _ 8.3 8.5. _ To See What Filri Are _ Loaded _ 8.3 8.6. _ Simple Commands for Manipulating _ Filu _ 8.3 \ 8.7. _ to a _ 8.4 - `.~--y Connecting _ Directory \ s 8.8. _ File Vettion _ Numbers _ 8.4 9. FileBrowser 9.1 9.1. _ Calling the _ FileSrowser _ 9.1 9.2. FileBrowserCommands 9.3 10. ffose Wondertul Windows! 10.1 10.1. _ Windows _ provided _ by lnterlis~D _ 10.1 10.2. _ Creating a _ window _ 10.2 10.3. _ The Right _ Button DefaultWindow _ Menu _ 10.2 10.4. _ An _ explanation of each _ menu _ item _ 10.3 10.5. _ krollable Windows _ 10.3 10.6. Other Window Functions 10.5 10.6.1. PROMPTPRlNT 10.5 10.6.2. _ WHlCHW _ 10.6 11. Editing and Saving 11.1 11.1. _ Defining _ Functions _ 11.1 11.2. Simple Editing in the 1nterlis~D Executive Window 11.2 YA8~ OF cottnritt iA.3. _ Wys to Stop Excution from th Kyboard, called _ 1rhlng LIzp5 _ 14.3 t4.4. _ Programming _ Braks and Dbugging Cod _ 14.4 14.5. Break Monu 14.4 14.6. _ Returning to Top Lovl _ `4.5 15. _ On-Line _ Help _ with _ Interlisp-D: _ HELPSYS and _ DlNFO _ ~ _ 15.1 15.1. _ HelpSys _ 15.1 15.2. Dlnfo 15.1 16. Floppy Disks / 16.1 16.1. _ Buying Floppy Disks _ 16.1 16.2. _ Basic Floppy Disk Information _ 16.1 16.3. _ Care of Floppies _ 16.2 16.4. _ Write Enabling and Write Protecting _ Floppies _ 16.3 16.4.1. _ Write Enabling an _ 1108's _ Floppy _ Disk _ 16.3 16.4.2. _ Write Protecting an _ 1186's Floppy Disk _ 16.3 16.5. _ Inserting _ Floppies _ intothe _ Floppy Drive _ 16.3 16.6. _ Functions for Floppy Disks _ 16.4 16.6.1. _ Formatting Floppies _ 16.4 16.6.2. _ Available Space on a Floppy Disk _ 16.4 16.6.3. _ The Name ofa Floppy Disk _ 16.4 16.6.4. _ FLOPPY.MODE _ 16.5 17. Duplicating Floppy Disks 17.1 17.1. _ Supplies _ 17.1 17.2. _ Preparabon _ 17.1 17.2.1. _ Handling _ Floppy _ Disks _ 17.1 17.2.2. _ Setup _ 17.1 17.3. _ Copying _ Floppy Disks _ 17.2 18. Sysout Files 18.1 18.1. _ Loading SYSOUT Filri _ 18.1 18.1.1. _ Loading a _ SYSOUTfile on the _ 1108 _ 18.1 18.1.2. _ Loading a SYSOuTfileonthe _ 1186 _ 18.2 18.2. _ Making _ Your Own SYSOUT File _ 18.3 19. Using the Epson FX80 Printer ~ 19.1 19.1. _ Initializing the RS232 Port _ 19.1 19.2. _ Power upthe Printer _ 19.1 19.3. _ to Align Top of Page _ 19.1 YA8~ OF CONTENTS TOC.3 TABLE OF CONTEND yl 19.4. _ Fundions To Print Filri and _ Bitmapf _ 19.2 19.4.1. _ RS232.Print _ 19.2 19.4.2. _ FXWSTREAM _ 19.2 19.4.3. _ Printing a Portion of the Screen _ 19.3 20. R5232 File Transfer With a VAX 20.1 20.1. _ Prerequisites _ 20.1 20.2. _ Using Chat to Transfer Filri _ 20.1 21. Ethernet File Transfer 21.1 21.1. _ Prerequisites _ 21.1 21.2. File Transfer 21.1 22. WhatToDolf... 22.1 ;;23. The Text ditor,TEdit 23.1 23.1. _ Using TEdit _ 23.1 23.2. _ Managing the edit Window _ 23.2 23.3. _ Seleding _ Tert _ 23.3 23.4. _ Deleting, Copying, and _ Moving Text with edit _ 23.4 23.4.1. _ Deleting Text From a File _ 23.4 23.4.2. _ Copying _ Text _ 23.4 23.4.3. _ Moving _ Text _ 23.5 23.5. _ rtdit Menus _ 23.6 23.5.1. _ Finding _ and _ Substituting Text with _ edit _ 23.7 23.5.1.1. _ Finding Text _ 23.7 23.5.1.2. _ Substituting Text _ 23.8 23.5.L _ Text Formatting _ 23.10 23.5.2.1. _ Choosing Fonts _ 23.10 23.5.2.2. _ Paragraph _ Formatting _ 23.11 23.5.3. _ Adding _ Bitmaps and Sketches to your TEdit File _ 23.13 23.5.3.t. _ Adding a _ Bitmap to your TEdit file _ 23.13 23.5.3.2. _ Adding a Sketch to your TEdit file _ 23.14 23.5.4. _ Getting and _ Including _ Filri _ 23.14 23.5.4.1. _ Get _ 23.14 23.5.4.2. _ Include _ 23.14 23.5.5. _ Saving and Printing Files _ 23.15 24. _ Records _ May _ BG _ Your _ Favorite _ Data _ Structure! _ 24.1 2&1. _ Interlisp Record ~imitlves _ 24.1 T~.. rAa~0fC0NTENrt TABLE OF OoNTENfl 24.2. _ Exomplo _ 24.3 24.3. _ AFwflps _ 24.4 25. Local Variables - Using LET and PR0G 7 25.1 25.1. _ LET _ 25.1 25.2. _ PfloG _ 25.3 25.3. _ Porillol _ vottus _ S~uential _ Vorioblo _ Binding _ 25.6 25.3.1. _ L~ _ 25.6 25.3.2. _ PROG _ 25.7 26. lterative statements 26.1 26.1. _ General _ Strudurc and _ Use _ 26.1 26.2. _ Local _ Variables _ 26.2 26.3. _ lteration _ On _ Lists _ 26.3 26.4. _ Parallel _ lteration _ 26.4 26.5. _ Conditional _ lteration _ 26.5 26.6. _ More _ lteration _ 26.6 27. Window and Regions 27.1 27.1. _ Windows _ 27.1 27.1.1. _ CREATEW _ 27.1 27.1.2. _ WlNDOWPROP _ 27.2 27.1.3. _ Getting windows to do things _ 27.3 27.1.3.1. _ BUflONEVENTFN _ 27.4 27.1.4. _ Looking at a _ window's properties _ 27.5 27.2. _ Regions _ 27.5 28. What Are Menus? 281 28.1. _ Displaying _ Menus _ 28.1 28.2. _ Getting _ Menus to DO Stuff _ 28.2 28.2.1. The WHENHELDFH and WHENSELE~DFN fields of a menu 28.4 28.3. _ Looking _ at a _ menu's fields _ 28.5 29. Bitmaps 29.1 30. Displaystreams 30.1 30.1. _ Drawing _ on a _ Displaystream _ 30.1 30.1.1. _ DliWUNE _ 30.1 30.1.2. _ DliWTO _ 30.2 30.1.3. _ DliWaRCLE _ 30.3 TABS OF CONTENff TOC.5 l TABS OF CON~Nfl 30.1.3.1. _ FlLLGRCLE _ 30.3 30.2. _ Locating and _ Changing _ Your Position _ in _ a _ Displaystream _ 30.4 30.2.1. _ DSPXP0SlflON _ 30.5 30.2.2. _ DSPYPOSlBON _ 30.5 30.2.3. _ MOVETO _ 30.5 31. Fonts 31.1 31.1. _ WhatmakesupaFONn _ 31.1 31.2. _ Fontdescriptors, and _ FONTCREATE _ 31.2 31.3. _ Display Fonts-Theirfiles, and how to find them _ 31.3 31.4. _ Interpress _ Fonts- Their files, and _ how to find them _ 31.4 31.5. _ Functions for Using Fonts _ 31.4 31.5.1. _ FOHTPROP - _ Looking at Font Properties _ 31.4 31.5.2. _ SffllNGWlDTH _ 31.5 31.5.3. _ DSPFONT- Changing the Font in _ One Window _ 31.6 31.5.4. _ GIo~IlyChanging Fonts _ 31.7 31.5.5. _ Pettonalizing _ Your Font Profile _ 31.7 32. The Inspetror 32.1 32.1. _ Calling the Inspector _ 32.1 32.2. _ Using _ the _ Inspector _ 32.2 32.3. _ Inspector _ Example _ 32.2 33. Masterscope 33.1 33.1. _ The SHOW DATA command and GRAPHER _ 33.2 33.2. Databasefns: Automatic Conrtruction and Upkeep of a Mastettcope Data~se _ 33.3 34. Where Does All the Time Go? SPY 34.1 34.1. _ How to use Spy with the SAY Window _ 34.1 34.2. _ How to use _ SPY from the _ Lisp Top Level _ 34.2 343. _ Interpreting _ SPY's Results _ 34.2 35. SKETCH 35.1 35.1. _ Starting _ Sketch _ 35.1 35.2. _ Selecting _ Sketch elements _ 35.1 35.3. _ Drawing _ with _ Sketch _ 35.2 35.3.1. _ Simpl Shapes: _ Circles, Ellipsri and _ Boxes _ 35.3 35.3.1.1. _ Drawing _ Circlri _ 35.3 35.3.1.1 _ Elllpsri _ 35.3 TA.G TAlLE0fC0NFENrt `/` ----- Next Message ----- Date: 19 Dec 91 14:18 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.141853pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11640>; Thu, 19 Dec 1991 14:19:05 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 14:18:53 -0800 From: John Sybalsky -----RFC822 headers----> TABLE OF CONTENff 42. _ Simple _ Interactions _ with _ the _ Cursor, _ a _ Bitm&p, _ and _ & _ Window _ 42.1 42.1. _ An _ Example Function _ Using _ GETHOUSESTATE _ 42.1 42.2. _ Advising _ GETMOUSESTATE _ 42.2 42.3. _ Changing the Cursor _ 42.2 42.4. _ Functions for _ "Tracing the cursor" _ 42.3 42.5. _ Running the Functions _ 42.6 43. Glossary of Global System Variables 43.1 43.1. _ Directories _ 43.1 43.2. _ Flags _ 43.2 43.3. _ Hirtory _ Lists _ 43.3 43.4. _ Syrtem _ Menus _ 43.3 43.5. _ Windows _ 43.4 43.6. _ Miscellaneous _ 43.4 44. Other References that will be Useful to You 44.1 TA.G TAaU0FC0NTENff PREFACE it wos dawn and the locd told him it was down the road a p;ece, lefl &t the hst fishing bridge in the counvy right at the apple tree stump, and onto the d;rt roadjust before the hill. At m;dnight he knew he was lo$t. -Anonymous Welcome to the Interlisp-D programming environment! The Interlis~D environment truly must be one of the most sophisticated and powerful tools in use by human beings. Overall, it is flexible, well thought out, and full of pleasant surprises: "Wow, here are exactly the set of functions l thought I'd need to write." Unfortunately, along with the power comes mind-numbing complexity. The Intedisp Refertnce Manual describes the functions and some of the tools available in the Interlisp-D environment. To do this takes three large volumes. Other volumes are needed to document the library packages and other newly written tools. Needless to say, it is very difficult to learn such a huge amount of material when there is no way to determine where to rtart! We developed this primer to provide a starting point for new lnterlis~D usert, to enhance your excitement and challenge you with the potential before you. We assume you know a little about LISP, most likely received from taking a survey courte in Artificial Intelligence (Al), and have seen a demonrtration of how lnterlis~D runs on your 1186 or 1108. We further assume that your machine is not on a network system with a file server - though this is addressed, and that you will be working from floppy disks and the hard disk that is part of the machine. If this describes your situation, you are ready to sit down in front of your machine and follow the ste~by-step examples provided in this primer. The primer is broken into many small chapters, and these chapters are organized into five parts. You may want to read Parts 1 through 3 straight through, since they describe the basics of using the machine. Each chapter in Sections 4 and 5, however, can be used to learn a specific skill whenever you are ready to for it Part one, "Introduction", includes Chapters 1 and 2. Part two, "Getting Into/Out of Interlisp", includes Chapters 3 through 5. Part three, "The lnterlis~D language and Programming Environment", includes Chapters 6 through IS. These chapters discuss primary elements in lnterIis~D, and orient you in relation to those elements. Part four, "Important Other Things to Know to Work Successfully", includes Chapters 16 through 31. Part five, "More Language and Environment and Packages", includes Chapters 32 through 44. PREFAcE v ----- Next Message ----- Date: 19 Dec 91 14:20 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.142054pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11636>; Thu, 19 Dec 1991 14:21:05 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 14:20:54 -0800 From: John Sybalsky -----RFC822 headers----> PREFACE Through out we make reference to the lnterlis~D Reference Manual by section and page number. The material in the primer is just an introduction. When you need more depth use the detailed treatment provided in the manual. While only you can plot your ultimate destination, you will flnd this primer indispensable for clearly defining and guiding you to the first landmarks on your way. Acknowledgements The early inspiration and model for this primer came from the Intelligent Tutoring Systems group and the Learning Research and Development Center at the University of Pittsburgh. We gratefully acknowledge their pioneering contribution to more effective artificial intelligence. This primer was developed by Computer Possibilities, a company committed to making Al technology available. Primary development and writing was done by Cynthia Cosic, with technical writing support provided by Sam Zordich. At Xerox Artificial Intelligence Systems, John Vittal managed and directed the project. Substantial assistance was provided by many members of the AlS staff who provided both editorial and systems support. PREFA~ 1 ----- Next Message ----- Date: 19 Dec 91 14:33 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.143340pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11653>; Thu, 19 Dec 1991 14:33:46 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 14:33:40 -0800 From: John Sybalsky -----RFC822 headers----> 1. ABRlEFGLOSSARY The following definitions will acquaint you with general terms used throughout this primer. You will probably want to read through them now, and use this chapter as a reference while you read through the rest of the primer. advising An lnterlis~D facility for specifying function modifications without necessarily knowing how a particular function works or even what it does. Even system functions can be changed with advising. argument An argument is a piece of information given to an lnterlis~D function so that it can execute successfully. When a function is explained in the primer, the arguments that it requires will also be given. Arguments are also called Parametert. atom The smallest rtrvcture in Lisp; like a variable in other programming languages, but can also have a property lirt and a function definition. Background Menu The menu that appears when the mouse is not in any window and the right mouse button is pressed. A typical background menu is shown in Figure I.I. Loops Icon FileB'owser Figuro 1.1. The Menu that appeort when the mouse is not in any window, and the right mouse button is pressed. Your background menu may have some different items in it binding The value of a variable. It could be either a local or a global variable. See unbound. bitmap A rectangular array of ` pixels, ` each of which is on or off representing one point in the bitmap image. BREAK An Interlisp function that causes a function to stop executing, open a Break window, and allow the user to find out what is happening while the function is halted. Break Window A window that opens when an error is encountered while running your program (i.e., when your program has broken). There are tools to help you debug your program from this window. This is explained further in Chapter 14, Page 14.1. browse To examine a data strvcture by use of a display that allows the user to "move" around within the data rtructure. button A BRIEF GL0SSARY 1.1 1 A BRIEF GLOssAny (1) (n.) Akeyonamouse. (2) (v.t.) To depress one of the mouse keys when making a selection. EAR A function that returns the head or firrt element of a list. See CDR. caret The small blinking arrowhead that marks where tert will appear when it is typed in from the keyboard. An example of the caret in the lnterIis~D Executive Window is shown in Figure 1.2. NIL B6+(PLus 3A Figur lJ. Me caret is to the right of the numher 3. When a characters frped atthe keylsoard. it will ap~ar at the caret CDR A function that returns the tail (that is, everything but the first element) ofa list SeeEAR. CLlSP A mechanism for augmenting the standard Lisp syntax. One such augmentation included in Interlisp is the iterative rtatement. SeeSection 13.1. cr Please press your carriage return key. datatype (1) The kind of a datum. In Interlisp, there are many SystemAefine~ datatypes e.g. Floating Point, Integer, Atom, etc. (2) A datatype can also be user~efined. In this case it is like a record made up from system types and other user-defined datatypes. DWlM D~whatl-mean. Many errors made by Interlisp users could be corrected without any information about the purpose of the program or expression in question (e.g. misspellings, certain kinds of parenthesis errort). The DWlM facility is called automatically whenever an error occurt in the evaluation of an Interlisp expression. If DWlM is able to make a correction, the computation continues as though no error had occurred; otherwise, the standard error mechanism is invoked. error Occasionally, while a program is running, an error may occur which will stop the computation. Interlisp provides ertensive facilities for detecting and handling error conditions, to enable the testing, debugging, and revising of impertect programs. evaluate or EVAL Means to flnd the value of a form. For example, if the variable X is bound to 5, we get 5 by evaluating X. Evaluation of a Interlisp function involves evaluating th arguments and then applying thfunction. file packag A set of functions and convntions that facilitato th bookkeping involved with working in i larg systm consisting of many sourc cod files and thir compiled countrparts. Essentially, th fll packag k:ps track of whr things ar and 1, AR1EFGLos~y l A RlF GLoSSARY whet things hevo chonged. N 4150 kaps trck of which files hove been modifiod end n#d to be updetod end recompiled. form Another wey of seying ~xpre5sion. An Jntorlisp-D ex~on tbetcen be evaluated. function A Lisp function is e piece of l;sp code thet executes end returns e veiue. history The progremmers essistent is l,uilt eround e memory structure celled the hirtory Iirt. The hirtory functions (e.g. FIX, UNDO, REDO) ere part of this essirtant. These operations allow you to conveniently r~work previously specifiecl operations. History List As you type on the xreen, you will notice a number followecl by a prompt attow. Each number, and the information on that line, is seeluentially rtored as the History List Using the History List, you can easily reexecute lines typed earlier in a worksession. See Chapter6. icon A pictorial representation, usually of shrunken window. lnterlis~D Executive Window This is your main window, where you will run functions and develop your programs. See Figure 1.3. This is the window that the caret is in when you turn on your machine and load lnterlis~D. NIL 8~#iPRO*PTPRIHT "HELLO" A Fqur tJ. m window inspector An interactive display program for examining and changing the parts of a data structure. Jnterlisp-D has inspectors for lists and other data types. iterative statement (also called i.s.) A statement in Interlisp that repetitively executes abody of code. (E.g.(forxfromltosdo(PRlNTx))isani.s.) iterative variable (also called i.v.) Usually, an iterative statement is controlled by the value that the i.v. takes on. In the iterative statement example above, x is the iterative variable leecause its value is being changed by each cycle through the loop. All iterative variables are local to the iterative rtatement where they are defined. LISP Family of languages invented for "list processing." These languages have in common a set of basic primitives for creating and manipulating symbol rtructures. lnterlis~D is an implementation of the LISP language together with an environment (set of tools) for programming, an a set of packages that ertend the functionality of the system. list A collection of atoms and lists; a list is denoted by surrounding its contents with a pair of parentheses. A BRIEF GLOSSARY lJ 1 A BRIEF GLOSSARY Loading LJSP This is the process of bringing lnterlis~D from floppy disks, hard disks, or some other secondary rtorage into your main, or working, memory. You will need to load (i.e., install, and boot) lnterlis~D if you have not logged off the machine at the end of a session. The process of loading lnterlis~D is explained in Chapter3. Maintenance Panel Codes Should you have a problem with your equipment, these codes will indicate the status of your processor. On the 1108, these are the red LED numbett under the floppy drive door. There is a cover over these numbers. Pull down the cover located immediately under the floppy door button. The code numbers are defined for the 1108 in the 1108 Useri Guide, in the MP Codeschapter. If there is a problem with the 1186, the mouse curtor will change from its normal arrow to the code number that describes the problem. The code numbert are defined for the 1186 in the 1166 User's Guide in the Curtor Codes subsection of the Diagnostics Chapter. Marterscope A program analysis tool. When told to analyze a program, Masterscope creates a data base of information about the program. In particular, Marterscope knows which functions call other functions and which functions use which variables. Masterscope can then answer questions about the program and display the information with a browser. menu A way of graphically presenting the user with a set of options. There are twO kinds of menus: p0~up menus are created when needed and disappear after an item has been selected; permanent menus remain on the screen after use. mouse The Mouse is the box to the right of your keyboard. It controls the movement of the cursor on your screen. As you become familiar with the mouse, you will find it much quicker to use the mouse than the keyboard. See Figure 1.4. (Note: Some mice have three buttons; the button in the center is known as the middle mouse button. If your mouse has only two buttons, you can simulate a middle button by pressing the left and right buttons simultaneously.). Fw- 1.& Mous Mouse Curtor The small arrow on the screen that points to the northwest. See Figure 1.5. F~m I.L Mous c~~~ Mous Curtor Icons I.A A llEF GLos~Y l A IRlEF GLOSSARY I Wait Tho processor is busy. The processor is saving a anpashot or your cureent system session. This is usually don when tbc procffssor hos ~n idle for a while. The "Mouse Confirm Cursor". It appeatt when you have to confirm that the choice you just made was correct. If it was, press the left button. If the choice was not tight, press the right button to abort. F='*x This means "sweep out" the shape of the window. To do this, move the mouse to a position where you want a corner. Press the leff mouse button, and hold it down. Move the mouse diagonally to sketch a rectangle. When the rectangle is the desired size and shape, release the left button. r-'l l l l l - This is the "move window" prompt. Move the mouse so that the large "ghost" rectangle is in the position where you want the window. When you click the left mouse button, the window will appear at this new location. NIL NIL is the lnterlis~D symbol for the empty list h can also be represented by a lefl paren followed by a right paren: (). It is the only expression in lnterIis~D that is both an atom and a list pixel Pixel rtands for PIcture Element. The xreen of your Lisp Machine is made up of a rectangular array of pixels. Each pixel corresponds to one bit When a bit is turned on, i.e. set to 1, the pixel on the screen represented by this bit is black. pretty printing Pretty printing refers to the way lnterIis~D functions are printed with special indentation, to make them easier to read. Functions are pretty printed in the structure eclitor, DEdit (See Section 11.3, Page 11.4). You can pretty print uncompiled functions by calling the function PP with the function you would like to see as an argument, i.e. (PP tunction-name). For an example of this, see Figure 1.6. 96.(PP HEAD) [LANBDA (LST) <6rtG; `~JlinH13;3&) (CAR LsTJ) (HEAD) 97.' Fbm 1.6. An oxam~ u~oftho pro printing `unmon FP A BRIEF GLOSSARY 1.5 I A BRIEF GLOSSARY Programmer's Assistant The programmer's assistant accesses the History List to allow you to FIX, UlOO, and'or REDO your previous expressions typed to the lnterlis~D executive window. (See Chapter 6.) Promptwindow The skinny black window at the top of the xreen. It displays system prompts, or prompts you have developed. (See Figure 1.7.) Fqur 1.7. Prompt window property list A list of the form ( ....) associated with an atom. It accessed by the functions GETPROP and PUTPR0P. record A record is a data-structure that consists of named "flelds". Accessing elements of a record can be separated from the details of how the data structure is actually stored. This eliminates many programming details. A record definition establishes a record template, describing the form of a record. A record instance is an actual record storing data according to a particular record template. (See datatype, second definition.) Right Button Default Window Menu This is the menu that appeaff when the mouse is in a window, and the right mouse button is pressed. It looks like the menu in Figure 1.8. If this menu does not appear when you depress the right button of the mouse and the mouse is in the window, move the mouse so that it is pointing to the title bar of the window, and press the right button. Clone Snap Paint Clear 8ury Redi~play Hardcopy~ Move Shapo Shrink f~a 1.1. tt Right Sutton DqfaultWindow Menu 5-expression Short for "symbolic expression." In Lisp, this refers to any well-formed collection of leff parffns, atoms, and right parens. stack A pushdown lirt Whenever a function is entered, information about that specific function call is pushed onto (i.e. added to the front ofi the stack; this information includes the variable names and their values associated with the function call. When the function is exitted, that data is popped off the stack. storag devices Information is rtored for your Lisp machine on floppy disks, or on the hard disk. They are referred to as (FLOPPY) and (DSK) respectivly. sysout A fll containing G wl'0l Lisp environmnt: namely, lnterlis~O, evrything th user' dfinecl or loaded into the environment, th 1.6 A ~N:EF GL0SsARY I A BRIEF GLOSSARY windows that ppeored on tho Kreen, tb mount of memory used, and 50 on. Evorything ;s rtord in th sysout fil exactly .5 it was whon tho function SYSWT was called). TFACE A function that crates a trace of the execution of another function. Eich time the traced function is called, it prints out the values of the arguments it was called with, and prints out the value it returns upon completion. Unbound Without value; an atom is unbound if a value has never been assigned to it window A rectangular area of the screen that acts as the main display area for some Interlisp process, A BRIEF GLOSSARY 1.7 1 ----- Next Message ----- Date: 19 Dec 91 14:42 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.144256pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11642>; Thu, 19 Dec 1991 14:43:07 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 14:42:56 -0800 From: John Sybalsky -----RFC822 headers----> 6. TYPING SHORTCUTS Once you have logged it, as per Chapters 3 or 4, you are in lnterlis~D. The functions you type into the Interlisp-D executive window will now execute, that is, perform the designated task. Please note that Interlisp-D is case-sensitive; offen it matters whether text is typed in capital- or lower-case letters. The shifflock key is above the left shift key; when it is pressed (on the 1186, the red LED will be on; on the 1108, the key will be depressed), everything typed is in capital letters. You must type all Interlisp-D functions in parentheses. The lnterlis~D interpreter wtll read from the leff parenthesis to the closing right parenthesis to determine both the function you want to execute, and the arguments to that function. Executing this function is called evaluation. When the function is evaluated it returns a value, which is then printed in the lnterlis~D executive window. This entire process is called the read-eval-print loop, and is how most Ll5P interpreters, including the one for lnterlis~D, run. The prompt in Interlis~D is a number followed by a left pointing arrow (see Figure 6.3). This number is the function's position on the History List -- a list that stores your interactions with the lnterlis~D interpreter. Type the function (PLUS 3 4), and notice the number the History List assigns to the function (the number immediately to the leff of the arrow). lnterlis~D reads in the function and its arguments, evaluates the function, then prints the number 7. In addition to this read-eval-print loop, there is also a programmer's assistant. It is the programmer's assistant that prints the number as part of the prompt in the lnterlis~D executive window, and uses these numbers to reference the function calls typed after them. When you issue commands to the programmer's assistant, you will not use parentheses as you do with ordinary function calls. You simply type the command, and some specification that indicates which item on the history list the command refers to. Some programmer's assistant commands are FIX, REDO, and UNDO. They are explained in detail below. Programmer's assistant commands are useful only at the lnterlis~D top level, that is, when you are typing into the lnterlis~D executive window. They will not work in user-defined functions. As an example use of the programmer's assistant, use REDO to redo your function call (PLUS 3 4). Type REDO (Note: programmer's assistant commands can be typed in either upper TYPING 5H0RTCUTS 6 1 TYPING SHORTCUTS or lower case) at the prompt, then specify the previous expression in one of the following ways: (1) When you originally typed in tne function you now want to refer to, there was a History List number to the left of the arrow in the prompt. Type this number affer the programmer's assistant command. This is the method illustrated in the following figure: iPLUe~ 3 4) C'5~REOO `24 7 26-',' , , , . . , . , . . . . . . . , . . . . , , , , . Figure 6.1. Using the programrner's assistant to REDO a function, when you know the its number on the history list (2) A negative number will specily the function call typed in that number of prompts ago. in this example, you would type in-I, the position immediately before the current position. This is shown in the following figure: `2~.(PLUS :3 j) ;;;; `-,7' ii, ~` F.EDS -i 7 :`0~. , , , , , ,: , , :, , ,:, , , , , , ;, : , , , ,; , , Figur 6.2. Typing a negative number affer the programmer's assistant command will cause it use the function found on the History List that many positions before the current one. (3) You can also specify the function for the programmer's assistant with one of the items that was in that function call. The programmer's assistant will se'rch backwards in the History List, and use the first function it finds that includes that item. For example, type REDO PLUS to have the function (PLUS 3 4) reevaluated. (4) If you type a Programmer's Assistant command without specifying a function (i.e., simply typing the command, then a cr) the Programmer's Assistant executes the command using the function entered at the previous prompt. Here are a few more examples of using the programmer's assistant: G.a TYPING SHORrCUff 1 TYPING SH0RTCUTS NIL 54k[PLUS 4 5) 9 55~REDO 9 56#?? 54 +(PLUC~ 4 5) 9 56~(SETQ B `80Y) BOY 5'~B BOY 59" UNDO cETQ SETQ undone. 59'.B UN8OUND nTOM B SBkREDO 56 BOY 6IkB BOY 62# Fqur 6.3. Some Applications of the Programmer's Assistant 6.1 If you make a Mistake Editing in the Interlisp-D Executive Window is explained in Section 11.2, Page 11.2. In this section, only a few of the most useful commands will be repeated. To move the caret to a new place in the command being typed, point the mouse cursor at the appropriate position, and press the leff mouse button. To move the caret back to the end of the command being typed, press CONTROL-X. (Hold the CONTROL key down, and type .X.'.) The way you choose to delete an error may depend on the amount you need to remove. To delete: The character behind the caret simply press the backspace key The word behind the caret press CONTROL-W. (Hold the CONTROL key down, and rype `W'.) Any part of the command, first move the caret to the appropriate place in the command. Hold the right mouse button down and move the mouse cursor over the ten. All of the blackened tert between the caret and mouse cursor is deleted when you release the right mouse button. TYPING SHORTCUTS 63 IF YOU MAKE A MISTAKE The entire command press CONTROL-U. (Hold the CONTROL key down, and type in".) Deletions can be undone. Just press the UNDO key. To add more text to the line, move the caret to the appropriate position, and just type. Whatever you type will appear at the caret. 6.4 TYPING SHORTcUTS ----- Next Message ----- Date: 19 Dec 91 14:48 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.144827pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11544>; Thu, 19 Dec 1991 14:48:38 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 14:48:27 -0800 From: John Sybalsky -----RFC822 headers----> 7. USING MENUS The purpose of this chapter is to show you how to use menus. Many things can be done more easily using menus, and there are many different menus provided in the Interlisp-D environment. Some are "po~up" menus, that are only available until a selection is made, then disappear until they are needed again. An example of one of these is the "background menu", that appears when the mouse is not in any window and the right mouse button is pressed. A background menu is shown in Figure 7.1. Yours may have different items in it. SkGtL'h LUop3 Icon CHAT F.lle0ro~er sav"VM 5nap Figure 7.1. A hackground menu. Another common pop-up menu is the right button default window menu. This menu is explained more in Section 10.4, Page 10.3. Other menus are more permanent, such as the menu that is always available for use with the Interlisp-D Filebrowser. This menu is shown in figure Figure 7.2, and the specifics of its use with the filebrowser is explained in Chapter 9). Dnjelsta Rcname Hor~'UpJ -=`ffl.e Compil'. E~prnnge Recrjm Ut.fl,L' Figure 7.2. The menu that is available when using the Filehrowser USING MENUS 71 I MAKING A SELEcTION FROM A MENU 7.1 Making a Selection from a Menu To make a selection from a menu, point with the inouse to the item you would like to selert If one of the moU5e buttons is already pressed, the menu item 5hould blacken. If it is a permanent menu, you must press the leff mouse button to blacken the item. When you release the button, the item will be chosen. Figure 7.3 shows a menu with the item "Undo" chosen. 1 .lffer Bpfor', GeIer~, Replace `witch ( `3 LIt. Find `=w~ pcpflnt Edt Edfl-Um 0~ik Eva E.xit Figure 73. A menu with the item "Undo" chosen 7.2 Explanations of Men.u Items Many menu items have explanations associated with them. If you are not sure what the consequences of choosing a particular menu item will be, blacken the menu item, and do not release the leff button. If the menu item has an explanation associated with it, the explanation will be printed in the prompt window. Figure 7.4 shows the explanation associated with the item "Snap" from the background menu. ile0row~or Flguv 7.& The explanation associated with the cliosen item, Snip, is displayed in the prom pt window. 7.2 USING NENuS I SUBMENUS 7.3 Submenus Some menus items have submenus associated witl, them. This means that, for these items, you can make even more precise choices if you would like to. A submenu can slso be found in one of two ways. One is to point to the item with the mouse cuttor, and press the middle mouse button. If there is a submenu associated with that item, it will appear. (See Figure 7.5.) l Atter 8e?are DoloCe Replace Yvitch `ut l)nda Find cap Repnnt Edit EditL'om Break Eva OK TOP FigurQ 7.5. The submenu associated with the menu item Exit It appeared when the mouse curtor Pointed to the menu item. and the middle mouse button was pressed. A submenu can be indicated by a gray arrow to the right of the menu item, like the one to the right of the "Hardcopy' choice in Figure 7.1. To see the submenu, blacken the menu item, and move the mouse to follow the arrow. An example of this is shown in Figure 7.6. Choosing an item from a submenu is done in the same way as choosing an item from the menu. Any submenus that might be associated with the items in the submenu are indicated in the same way as the submenus associated with the items in the menu. Dnclelete .~ . Copy Rename Harjcopv .=.ee ~~e~; Loa.d c'.Ee!T.: E,puni~e P',com Ll!e Figure 7.6. The submenu associated with the menu item Edit - It appeared when the menu item was blackened, and the mou>e was moved (0 follow the gray arrow. In summary, here are a few rules of thumb to rerrember about the interactions of the mouse, and system menus: Press the leff mouse button to select an item of a menu Press the middle mouse button to get more options - one of the ways to find a submenu USING MENUS 73 SUBMENU5 Press the right mouse button to see the default right button window menu, and the background menu 7.4 usiNG MENUS ----- Next Message ----- Date: 19 Dec 91 14:56 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.145658pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11659>; Thu, 19 Dec 1991 14:57:09 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 14:56:58 -0800 From: John Sybalsky -----RFC822 headers----> 8. MOW TO USE FILES 8.1 Types of Files A program file, or lisp file, contains a series of expressions that can be read and evaluated by the lnterlis~D interpreter. These expressions can include function or macro definitions, variables and their values, properties of variables, and soon. How to save Interlisp-D expressions on these files is explained in Section 11.6, Page 11.7. Loading a file is explained below, in Section 8.6, Page 8.4. Not all files, however, have lnterlis~D expressions stored on them. For example, TEdit files (see Chapter 23) store tert; sketches are stored on files made with the package Sketch (see Chapter 35), or can be incorporated into TEdit files. These files are not loaded directly into the environment, but are accessed with the package used to create them, such as TEdit or Sketch. When you name a file, there are conventions that you should follow. These conventions allow you to tell the type of a file by the extension to its name. If a file contains: Interlisp-D expressions, it should not have an extension. For example, a file called "MYCODE" should contain lnterlis~D expressions; compiled code, it should have the extension" .DCOM'. For example, a file called `MYCODE.DCOM" should contain compiled code; a Sketch, then its extension should be ".SKETCH. For example, a file called `MOUNTAlNS.SKETCH" should contain a Sketch; text, it should have the extension ".TEDlT'. For example, a file called `REPORT.TEDlT' should contain text that can be edited with the editor TEDlT. 8.2 Directories This section focuses on how you can find files, and how you can easily manipulate files. To see all the files listed on a device, use the function DIR. For example, to see what files are stored on the Y;ard disk, type (DIR (DSK)) HOW TO USE FILES B1 DlRG0R1E5 To see what files are stored on the floppy disk inside of the floppy drive, type (DIR (FLOPPY)) Partial directory listings can be gotten by specifying a file name, rather than just a device name. The wildcard "` can be used to match any number of unknown characters. For example, the command (DIR (DSK)T) will list the names of all files stored on the hard disk that begin with the letter T. An example using the wildcard is shown in Figure 8.1 `DIR `(P\h',(LI'.\PFIL.'.'PRIMER~T';l `LPQh/''.LI."'l FILE.C\,'PRIMER\ Tsi'REF.>.TEP[1)2 T6LlClNT.TEDIT,1 FigurG 8.1. Using the function DIR with a wildcard 8.3 Directory Options Various words can appear as extra arguments to the DIR command. These words give you extra information about the files. (1) SIZE displays the size of each file in the directory. For example, type (DIR (DSK) SIZE) (2) DATE displays the creation date of each file in the directory. An example of this is shown in Figure 8.2 35~(DIR (DsxJ.PRIMER~T* DATE) CREATIDNOATE (DSK)'LI5PFILES~PRIflER? TA'1"REF~TEPlT;2 26-lun-R5 19:A,O:R2 TBLnrnNT.TEDIT;1 26-lun'66 ja:4R~? 3Lq~ . . . . . . : . . . . . . . . . . . .. . . . . . .. . . . . Figure 8.2. An eximpie using th dirctory option DATE (3) DEL deletes all tho files found by the directory command G.a H0W TO USE FILES SUFlLE DlREO0RlES 8.4 Subfile Directories Subfile directories are very helpful for orgonizing files. A set of files that have a single purpose, for example all the external documentation files for a system, can be grouped together into a subfiledirectory. To associate a subfile directory with a filename, simply include the desired subfile directory as part of the name of the file Subfile directories are specified after the device name and before the simple filename. The first sibfile directory should be between less-than and greater-than signs < >, with nested subdirectory names only followed by a greater-than sign > For example: [DSK)SubOlmctory>SrnbSubDirctor-y>.. .>fi1on~ 8.5 To See What Files Are Loaded If you type FILELST, the names of all the files you loaded will display. Type SYSFILES, to see what files are loaded to create the SYSOUT. 8.6 Simple Commands for Manipulating Files The following commands will work with the (FLOPPY) and other devices, but have been shown with (DSK) for simplicity To have the contents of a file displayed in a window: (SEE `[DSK)f11nrn) To copy a file: (coPYFILE `[~)o1dfi1n~ `[DSF)ne,r,,ilonrn) An example of this is shown in Figure 8.3 (sOPvFILE `T~0r,RFc.TEDIT `PF;IMEFREFO.TDITJ t'Dcxl,(.LIsPFILEs.PRIMP.;.PRIMEP.fiEFs.TEDIT;1 Figure 8.3. An example of the use of the function COPYFILE To delete a file: (DEl.FIL `(~)fi1on~) An example of this is shown in Figure 8.4. ,, OELFIL `L'AMPLE.TEPITJ . \l.. I'PfILE;'."PRIMER?>AnPLE.TPIT;1 FigureS.O. The function DELFlLE To rename a file: (RENlEFILE (osK)oldftlnrn `(rSF)ner,r11n~) HOW TO USE FILES 83 1 SIMPLE COMMANDS FOR MANIPULATING FILES "LOAD" a file: Files that contain Interlisp-D expressions can be loaded into the environment. That means that the information on them is read, evaluated, and incorporated into the Interlisp-D environment. To load a file, type: (LUG `[DSff)filenm) When using these functions, always be sure to specify the full filename, including subfile directories if appropriate. 8.7 Connecting to a Directory Offen, each person or project has a subdirectory where their files are stored. If this is your situation, you will want any files you create to be put into this directory automatically. This means you should "connect" to the directory. CONK is the Interlisp-D form that connects you to a directory. For example, COilKin the following figure: - 1 l 11 29#(L'OtJN ``CDv~K1,.LIv"PFILES~\PP,IMER7IM\,!,I t'OS'Y96)cLIy'PFILCv;~PRIh1R.~lM> 30# Fqrnre 8.5. COflffeaing to the subdiredory "PRIMERs srnbsu~i'edory ,.lM" connects you to the subsubdirectory iM, in the subdirectory PRIMER, in the directory LlSPFlLES, on the device D5K. This information, the device and the directory names down to the subdirectory you want to be connected to, is called the "path" to that subdirectory. co:: expects the path to a directory as an argument. Once you are connected to a directory, the command DIR will assume that you want to see the files in that directory, or any of its subdirectories. Other commands that require a filename as an argument (e.g., SEE, above) will assume, if there is no path specified with the filename, that the file is in the connected directory. This will often save you typing. 8.8 File Version Numbers Whe.n stored, each file name is followed by a semicolon and a number. fffILE.TEOIY;1 The number ii the vertion number of the file. This is the system's way of protecting your files from being overwritten. Each time the file is written, a new file is created with a vettion number one 8.1 HOW T0 us: FILES FILE VERSION NUMBERS greater than the lost. This now fle will hove everything from your previous file, plus all of your changes. In most cases, you can exclude the version number when referencing the file. When the vertion is not specified, and there is more that one vertion of the file on that particular directory, the System generally uses your most recent version. An exception is the function DELFILE, which deletes the oldest version (the one with the lowest vertion number) if none is specified. HOW TO USE FILES as ----- Next Message ----- Date: 19 Dec 91 15:03 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.150359pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11664>; Thu, 19 Dec 1991 15:04:10 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 15:03:59 -0800 From: John Sybalsky -----RFC822 headers----> tO.THOSE WONDERFUL WINDOWS! A window is a designated area on the screen. Every rectangular box on the screen is a window. While Interlisp-D supplies many of the windows (such as the lnterlis~D executive window), you may also create your own. Among other things, you will type, draw pictures, and save portions of your screen with windows. 10.1 Windows provided by Interlisp-D Two important windows are available as soon as you enter the lnterlis~D environment. One is the lnterlis~D executive window, the main window where you will run your functions. It is the window that the caret is in when you turn on your machine, and load lnterlis~D. It is shown in Figure 10.1. Figure 10.1. Interlsp-D Executive Window The other window that is open when you enter Interlisp-D is the "Prompt Window". It is the long thin black window at the top of the screen. It displays system prompts, or prompts you have associated with your programs. (See Figure 10.2.) Figure 10.2. Prompt Window Other programs, such as the editors, also use windows. These windows appear when the program starts to run, and close (no longer appear on the screen) when the program is done running. THOSE WONDERFUL WINDOWS' 101 CREATING A WINDOW 10.2 Creating a window To create a new window, type: (CREATEil). The mouse cursor will change, and have a small square attached to it. (See Figure 10.3.) Figure 10.3. The mouse cursor asking you to sweep out a window There may be a prompt in the prompt window to create a window. Press and hold the leff mouse button. Move the mouse around, and notice that it sweeps out a rectangle. When the rectangle is the size that you'd like your window to be, release the leff mouse button. More specific information about the creation of windows, such as giving them titles and specifying their size and position on the xreen when they are created, is given in Section 27.1.2, Page 27.2. 10.3 The Right Button Default Window Menu Position the cursor inside the window you just created, and press and hold the right mouse button. A menu of commands should appear (do not release the right button!), like the one in figure 10.4. To execute one of the commands on this menu, choose the item. Making a choice from a menu is explained in Section 7.1, Page 7.2. clQ1,/ Pant `[oar Bury RoJisplay Hardsopy~ Movc `5hape shrink Figur 1O.& The Right Button Default Window Menu As an example, select "Move" from this menu. The mouse cursor will become a ghost window Oust an outline of a window, the same size as the one you are moving), with a square attached to one corner, like the one shown in Figure 10.5. ~l ~l F~ure 10.1 Th mous cunor !or moving & window Move the mous around. The ghost window will follow. Click the left mous button to plac tho window in a new location. 10.1 TH0Sff w0NKQFUL WlH00~l f THE RIGHT 8Uff0N DEFAULT MN00~ MFNU Choose "Shape", afid notice that you are prompted to sweep out another window. Your original window will have the shape of the window you sketch out. 10.4 An explanation of each menu item The meaning of each right button default window menu item is explained below: Close removes the window from the screen; Snap copies a portion of the screen into a new window; Paint allows drawing in a window; Clear cleart the window by erasing everything within the window boundaries; Bury puts the window beneath all other windows that overlap it; Redisplay redisplays the window contents; Hardcopy sends the contents of the window to a printer or to a flle; Move allows the wi ndow to be moved toanew spot on the screen; Shape repositions and/or reshapes the window; Shrink reduces the window to a small black rectangle callecl an icon. (See Figure 1O6.) Figum lO.L An example icon Expand changes an icon back to iB original window. Position the mouse cursor on the icon, depress the right button, and select Expand. Or, just button the icon with the middle mouse button. These right-button default window menu selections are available in most windows, including the lnterlis~D Executive window. When the right button has other functions in a window (as in an editor window), the right button default window menu should be accessible by pressing the Right button in the black border at the top of the window. 10.5 Scrollable Windows Some windows in Interlisp-D are "scrollable". This means that you can move the contents of the window up and down, or side to side, to see anything that doesn't fit in the window. Point the mouse curtor to the leff or bottom border of a window. If the window is scrollable, a "scroll bar" will appear. THOSE WONDERFlJL WINDOWS' 103 SCROLLABLE WINDOWS The mouse cursor will change to a double headed arrow. (See Figure 10.7.) . 1 , 1 Figuro 10.7. The scrolJ bar of a scrollable window. The mouse cursor changes o a double headed arrow. The xroll bar represents the full contents of the window. The example scroll bar is completely white because the window has nothing in it When a part of the scroll bar is shaded, the amount shaded represents the amount of the window's contents currently shown. If everything is showing, the scroll bar will be fully shaded. (See Figure 10.8.) The position of the shading is also important. It represents the relationshi'p of the section currently diplayed to the the full contents of the window. For example, if the shaded section is at the bottom of the scroll bar, you are looking at the end of the file. 1 . The amount of :>hadin~ in A::;:. the scroll bar represents the amount of the rile ;>hown in the window. Most of the file is visible. Because the shading is at the tap of the scroll bar, you know you are looking at the top of the file. Figur 10.1 Tho amount of shading in the scroll bar represents the amount of the file shown in the window. Most of the file is visible. Because the shading sat the top of the scroll bar. you know you are looking at the top of the file When the scroll bar is visible, you can control the section of the window's contents displayecl: To move the contents higher in the window (scroll the contents up in the window), press the leff button of the mouse, the mouse cursor changes to look like this: Fun 10.1. upward icrollinq cuttor. The contents of the window will scroll up, making the line thit the cursor is beside the topmost lin in the window. 10.4 THo$a ~HOERFUL~~w51 SCROLLASLE MN00~S To move the contonts lower in the window (scroll the contents down" in the window), press the right button of the mouse, ond the mouse cursor changes to look like this: Flgrnro 10.10. Oownwrd scrollinq curtor The contents of the window scroll down, moving the line that is the topmost line in the window to beside the curtor. To show a specific section of the window's contents, remember that the scroll bar represents the full contents of the window. Move the mouse curtor to the relative position of the section you want to see (e.g., to the top of the scroll bar if you want to see the top of the window's contents.). Press the middle button of the mouse. The mouse cursor will look like this: f'9ure 10.11. Proportional scrolling crnrtor. When you release the middle mouse button, the window's contents at that relative position will be displayed. 10.6 Other Window Functions 10.6.1 PROMPTPRlNT Prints an expression to the black prompt window. For example, type (P~PTPRIKT TNIS SILL BE PRIKTED I* THE PAT UIKOoS') The message will appear in the prompt window. (See Figure 10.12.) 1 . 1 Il 43 lpROMPTPRINT `THIS WILL BE PRINTED IN THE PROMPT WINDOW') Flurf 10.12. PROMPTPRlNTing THOSE WONDERFUL WINDOWS' 10.5 OTHER WINDOW FUNCTIONS 10.6.2 WHlCNW Returns as a value the name of the window that the mouse cursor IS in. (VHICHW) can be used as an argument to any function expecting a window, or to reclaim a window that has no name (that is not attached to some particular part of the program.). 10.6 THOil wONOERFUL~N00vn' ----- Next Message ----- Date: 19 Dec 91 15:18 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.151815pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11655>; Thu, 19 Dec 1991 15:18:21 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 15:18:15 -0800 From: John Sybalsky -----RFC822 headers----> tl. DlTUNG AND SAVING This chapter explains how to define functions, how to edit them, and how to save your work. 11.1 Defining Functions DEFINEQ can be used to define new functions. The syntax for it is: (HFIffEQ ( (j> New functions can be created with DEFINEQ by ryping directly into the lnterlis~D executive window. Once defined, a function is a part of the lnterlis~D environment. For example, the function EXANPLE-ADDER is defined in Figure 11.1. - HIL 46=(OEFINEQ (E.~AMPLE-rt"D&ER (~" B cJ (PRINT `THE SUM OF THE THREE NUMBERS Is ") (IPLUS n" B CJJJ (EXn~MPLE-~&DERj 47- F1ure 11.1. Defining the function EXAMPLEADDER Now that the function is defined, it can be called from the lnterlis~D executive window: . - NIL 49'. cEX~-MPLE-ffD&ER 3 4 `J; "THE SUM OF THE THREE NljMBERS 15 12 c~g Fq'rnre IIJ. After EXAMPLADDER is defined, it can he executed The function returns 12, after printing out the message. Functions can also be defined using the editor DEdit described above. To do this, simply type (DF furttiorvnamej EDITING AND SAVING 111 1 DEFINING FUNCTIONS You will be asked whether you would like to edit a Dummy definition. A dummy definition is a standard template for your function definition. Answer by typing Y for Yes, and you will be able to define the function in the editor. (See Figure 11.3. The use of the editor is explained in Section 11.3, Page 11.4.) h.'1,flF PJ~-HOT'E'['Ti Ho FH~., dean ;or oil NflT-E 1:-7, on oU Ui `;h ro ?dlr a `lu 60A "Fl;:l Figurn 11.1 Using DEdit to define a function II _ 2 _ Simple _ Editing _ in _ the _ Interlisp-D _ Executive Window First, type in an example function to edit: 51~(oEFIxEQ (Y~R-FIRST-fuKTIrn (A B) (if (GREATERP A B thn TNE FIR T IS GREATER els THE SECO*O IS 6REATE )))) To run the function, type (YOUR-FIR$T-FUflcTIoa 3 5). 52~(Y~R-FIRST-Fu~TI: 3 5) (TNE SEc~ Is GREATER) Now, let's alter this. Type: 53~FIZ 51 cr Notf that your original function is redisplayed, and ready to edit. (SeeFigure 11.4.) llJ EO1Y1~ AHO SAVING r, SIMPLE EDITING IN TNE INTERLISPD EXECUTIVE WIND0W NIL 53~FI~ 51 +(DEFINEQ [YOUR-FIRST-FUNCTION (A B) ( edited; "~1-Dec-GB 19;"8") (IF (GREaTERPA B) THEN (QUOTE (THE FiRST Is UREATERj) ELSE (QUOTE (THE SECOND IS u'RE~~TER] 1A f~ur11.& Using FIX to editafundion Move the tert cursor to the appropriate place in the function by positioning the mouse cursor and pressing the Jeff mouse button. Delete text by moving the caret to the beginning of the section to be deleted. Hold the right mouse button down and move the mouse cursor over the text. All of the blackened text between the caret and mouse cursor is deleted when you release the right mouse button. If you make a mistake deletions can be undone. On an 1108, press the OPEN key to. UNDO the deletion. On an 1108, press the UNDO key on the keypad to the Jeff of the keyboard. Now changeGREATERtoBIGGER: (1) Position the mouse cursor on the G of GREATER, and click the leff mouse button. The text curtor is now where the mouse cursor 15. (2) Next, press the right mouse button and hold it down. Notice that if you move the mouse cursor around, it will blacken the characters from the text cursor to the mouse cursor. Move the mouse so that the word "GREATER" is blackened. (3) Release the right mouse button and GREATER is deleted. (4) Without moving the cursor, type in BIGGER. (5) There are two ways to end the editing session and run the function. One is to type CONTROL-X. (Hold the CONTROL key down, and type "X".) Another is to move the text cursor to the end of the line and cr In both cases, the function has been edited! Trythe new version of the function bytyping: 58~(Y~-FZRST-F~Tzrn 8 9) (TN sEc~ Is BIKER) and get the new result, or you can type: 5~RE00 52cr (TNE SEc~ Is BIKER) EDITING AND SAVING 11.3 USING THE LIST STRUaURE EDITOR 11.3 Using The List Structure Editor If the function you want to edit is not readily available (i.e. the function is not in the Interlisp-D Executive window, and you can't remember the history list number, or you simply have a lot of editing), use the List Structure Editor, offen called DEdit. This editor is evoked with a call to OF: 81~(DF YWR-FIRST-f~TIa) Your function will be displayed in an edit window, as in Figure 11.5. If there is no edit window on the screen, you will be prompted to create a window. As before, hold the leff mouse button down, move the mouse until it forms a rectangle of an acceptable size and shape, then release the button. Your function definition will automatically appear in this edit window. !L~nb&A IA Bj (* OJtfJ' :1O:cw `~;`~`` .~.tr~r (IF 113'REATEPP A B'i EqV;r~ THEN iOUUTE "THE ::.p'.T f ~Ir,GER),l cl,,t' ELSE 1~UUTE THE .=E.u'N& j:. eluh'ER;J)) 4ep~:c /``tC.h . Un~io Find Rcorint cit. EOlfl/C T7~ Sr:ok E.. y E..t. Figur Il.L An Edit Window Many changes are easily done with the structure editor. Notice that by pressing the left mouse button, different expressions are underlined. Underline BIGGER as in Figure 11.5. Release the left mouse button. To add an expression that doesn't appear in the edit window, (i.e. it can't simply be underlined), just type it in. Doing this will create an edit buffer below the DEdit window. For example, type LARGER and hit cr (Remember to cr! You won't be able to do anything in the editor until you cr - this can fool you at first, so beware.) A new window opens up at the bottom for the new expression. (See Figure 11.6.) LARGER now has the bold line underneath it, while BIGGER has a dotted line. A 11.4 EDITING ~O ~VING USING THE LIST STRUCTURE EDITOR , LAMDOA VA B\ ~ dltd `3' Oc 00 l F;3Q') ArtOr VV (OREATERP A B) Befom ~ VQUOTE -THE FIRST Is 816OER)) cOIOtO (15 (QUOTE VTHE SEL'ONO IS BIW~Ry,\.i Ropl&ce witch ( ) y)out Unoo Find wap FQum Il.L Edit Window with Edit Buffer DEdit keeps track of items you have chosen by Using a stack. The underlines tell you the order of the items on the stack. The solid underline indicates the item on the top of the stack; the dotted underline indicates the second to the top. (liIGGER was pushed on first. When LARGER was pushed on, BIGGER became the second element in the "stack", and LARGER the first.) Many commands operate with two items on the stack. Some of them are listed below: Atter pops the stack, and adds this top item (in this example, LARGER) to the edit window affer the second item on the stack(in this example, BIGGER). The item that was at the top of the stack, LARGER, will now appear in both the original and the new position. Before pops the stack, and adds this top item (in this example, LARGER) to the edit window before the second item on the stack. (See Figure 11.7.) (LAKBDA VA 8' C' oJ'lfG `3,-Ooc~ ~F;l.O ,~rtOr (IF VGREATERp A 8J E~'inre ~ (QUOTE (THE FIRST IS ~`R ,8IUGEP); cOlGte ELI (QUOTE (THE SECOND IS 8I,b'E .j! ,1J F!Gplace itch r tJut Undo Find ,=-.i,1r P.O~rir,t Eda fiUre 11.7. The command Before is chosen; the word LARGER appean Iefore the word BIGGER Replace pops the stack, and substitutes this top item for the second item on the stack. Sat tch changes the position of the first and second items on the stack in the edit window. Find pops the stack, and searches this top expression for an occurance of the second item on the stack. If the item is found, it is underlined with a solid line, that is, pushed on the stack. To find the next occurance, simply choose "Find" again. If the expression is not found, the prompt window will blink, and a EDITING AND SAVING 115 1 USING ~E LIST STRUCTURE EDITOR spc111~ asfa1 If yri ant to &pc ~r coants) There are other editor commands which can be very UsefUl. To learn about them, read to the lntertis~D Reffrence Manual, Volume 2, Section 16, on DEDIT. it .4 _ File _ Functions and _ Variables - _ How to _ See Them _ and _ Save Them With lnterlis~D, all work is done inside the "Lisp Environment". There is no "Operating System" or "Command Level" other than the lnterlis~D Executive Window. All functions and data strUctures are defined and edited using normal Interlisp-D commands. This sertion describes tools in the Interlisp-D environment that will keep track of any changes that you make in the environment that you have not yet saved on files, such as defining new functions, changing the values of variables, or adding new variables. And it then has you save the changes in a file you specify. 11.5 File Variables Certain system-defined global variables are used by the file package to keep track of the environment as it stands. You can get system information by checking the values of these variables. Two important variables follow. FILELST evaluates to a list, all files that yoU have loaded into the lnteris~D environment. filenameC0liS (Each file loaded into the Lisp environment has associated with it a global variable, whose name is formed by appending "COMS" to the end of the filename.) This variable evaluates to a list of all the functions, variables, bitmaps, windows, and soon, that are stored on that particular file. For example, if you type: ~FILEC0*s the system will respond with something like: FKS YouR-FZRST-Fu*CTIil ) VARS)) 11.6 Saving Interlisp-D on Files The functions (FILES?) and (NAKEFILE `filename) are useful when it is time to save function, variables, windows, bitmaps, records and whatever else to files. EDITING AND SAVING 117 I USING THE LIST STRUCTURE EDITOR message that the item was not found will appear. (See Figure 11.8 for an example of an item, the atom THIRD, not appearing in the function, YOUR-FIRST-FUKCTION. 1 L.flFBo~P~~T\P _ B! (,`-.J'l-.J. _ .z' _ P..,n _ 1- THEN `c1.lcTE _ `THE _ FIPT _ ~I.'i'.EP'] ELSE 1tlJlJTE _ HE _ `/E/l)MlD TrtI,,,v Sr.i El ET. Figw 11.& The atom THIRD is not in the fundion being edited Saap changes places, on the stack, of the first and second items on the stack. The edit window does not change, except that the expression that had a solid underline now has a dotted underline, and vice versa. Delete works on only the top item of the stack. Delete removes the solid underlined expression from the edit window. Undo undoes the last editor command. Completing the example begun earlier, here's how to have the word LARGER that you typed into the edit buffer appear in place of the BIGGER that you selected from the DEdit window: select the SWITCH command. Notice that the two items are switched, and the stack is popped. Now select EXIT and to leave the editor, and your function will again be redefined. 11.3.1 Commenting Fundions Tert can be marked as a comment by nesting it in a set of parentheses with a star immediately after the left parenthesis. ( This ii th Von of c~rtt) Inside an editor window, the comment will be printed in a smaller font and may be moved to the far right of the code. Sometimes, however, centered comments are more appropriate. To center a comment, type ,, .... after the left parenthesis. This co.oortt 111 rtot b rnd to th ?r ri9ht of th co5o but 111 b crttrd) It is also possible to insert Iinebreaks within a comment. A dash should be placed in the comment whcrevr A carriag return is needed. Thii feotur allows several commnt1 to b placed insid one S.t of pirntheses. ( This cooo.t 111 h t~~ at. to 1ios. - 11.6 FIrING AND LAYING SAVING INTERLlSP-D ON FILES (FILES?) displays a list of variables that have values and are not already a part of any file, and then the functions that are not already part of any file. Type: (FILES?) the system will respond with something like: tb variables: ~.VARIlLE cURREKT.tuRTLE.. to be du;ed. th functions: RI6HT LEFT FOIAff liCK*Aa cLEAR-uREEil.. to be d~~. srit to s&y bere th abov go? If you type Y, the system will prompt with each item. There are three options: (1) To save the item, type the filename (unquoted) of the file where the item should be placed. (This can be a brand new file or an existing file.) (2) To skip the item, without removing it from consideration the next time (FILES?) is called, type cr This will allow you to postpone the decision about where to save the item. (3) If the item should not be saved at all, type J. NoilhQ re will appear afler the item. Part of an example interaction is shown in the following figure: HIL u31~(FILES,) Che variables: MY-'y'AR. To be di.imped. the functions: MY-SEcuNO-FUtllJTIJN, YJUP-FIPoT'FUNi)TIJN to be dumped. want to say where the .ibove 30 ? `ye' (variables) NY-VAR Nowhere (runctions) NY-SELrnNO-FUN&'TION File name: E;~AMPL~ F~11.9. Part of an interaction using the function FILES? (FILES?) assembles the items by adding them to the appropriate file's COMS variable. (See Section 11.5, Page 11.7.) (FILES?) does NOT write the file to secondary storage (disks or floppies). It only upclates the global variables discussed in SectionIt.S. (NAKEFILE `Tl lenae) actually writes the file to secondary storage. Files should only be writen when the time is set. If the time is not set, you will run into problems, such as not being able to copy your file. To check the time, typ (riTE) If the date is correct, yoU can safely use IRE FILE. If it is riot correct, set the time with the function SETTIKE. To use it, type (SETTIKE date), where dat isa string such as the one shown inFiguretl.10. it.a Eomlflll ANC SAVING I SAVING INTERUSP~ ON FILES NIL 97;k(SETTIME "10-Jul-86 15:08 2<8) "i6-Jul-86 15;08:22 EDT" 98+ Fqurn 11.10. Using the SETTIKE function to set the date and time Once the time is set correctly, use the function MAKEFILE. Type: (liffEFILE `P.FILE.~) and the system will create the file. The function returns the full name of the file created. (i.e. (DSK)MY.FlLE.NAME.; 1). Note: Files written to (DSK) are permanent files. They can be removed only by the user deleting them or by reformatting the disk. Other file manipulation functions can be found in Section 8.6, Page 8.3. EDITING AND SAVING 119 I ----- Next Message ----- Date: 19 Dec 91 15:20 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.152031pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11670>; Thu, 19 Dec 1991 15:20:42 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 15:20:31 -0800 From: John Sybalsky -----RFC822 headers----> t3. FLEXIBILITY AND FORGIVENESS: CLISP AND DWIM CLlSP, (Conversational Lisp), and DWlM, (Do What Mean), are two Interlisp utilities that make life easier. 13.1 CLlSP CLlSP allows the machine to understand and execute commands given in a non-standard way. For example, Figure 13.1 contains an example expressi on (4 + 5). NIL b'4-iJ + 5; 9 85' F9ure 13.1. cLlsP allows the use of infix notation Without CLlSP, you would need to type this using the notation (PLUS 4 5). CLlSP allows you to use expressions such as (4 + 5) for all arithmetic expressions. CLlSP also allows you to use more readable forms inrtead of standard Lisp control structures. Expressions like IF-THEN-ELSE statements can replace COND statements. For example, instead of: (CIO 1J6RE(APLTUESRPBA B (PLUS A 10)) 10 the following can be used: (if (A ~ B) then (A + 10) else (B + 10)) The system translates this CLlSP code into Interlisp-D code. Setting flags will allow you to either save the CLlSP code, or save the translation. One such flag is CLISPIFTRANFLG; if it is set to ffIL, all the IF statements will be replaced with the equivilent CORD statements. This means that when you DEdit the function, the IF will be removed and replaced with the CORD. Typically, flags such as this one are set in your INlT file. These flags are dixussed in the Intertlsp-D Reference Manual in Volume 2, Section 21. FLEXIBILITY AND FORGIVENESS. cLIsP AND DWIM 13 I I OWlM 13.2 DWlM DWlM tries to match unrecognized variable and function names to known ones. This allows Lisp to interpret minor typing errors or misspellings in a function, without causing a break. Line 87 of Figure 13.2 illustrates how the misspelled 0ANNANNA was replaced by 8ANANA before the expression was evaluated. NIL a7(8ETQ 8~N.HA `FRUITj FRUIT 38'8nNN,,~NNA =8,,'H,,NA FRUIT 39' Figure 13.2. Examples of CLlSP and DWlM features Sometimes DWlM may alter an expression you didn't want it to. This may occur if, for example,a hyphenated function name (eg. (NY-FUNCTION)) is misused. If the system doesn't recognize it, it may think you are trying to subtract "FUN~lON" from "MY". DWlM also takes the liberty of updating the function, so it will have to be fixed. However, this is as much a blessing as a curse, since it points out the misused expression! 13.2 F~1lUM AND ~ROVENES$: cub AND OWN I ----- End Forwarded Messages ----- Figure 13.2. Examples of CLlSP and DWlM features Sometimes DWlM may alter an expression you didn't want it to. This may occur if, for example,a hyphenated function name (eg. (NY-FUNCTION)) is misused. If the system doesn't recognize it, it may think you are trying to subtract "FUN~lON" from "MY". DWlM also takes the liberty of updating the function, so it will have to be fixed. However, this is as much a blessing as a curse, since it points out the misused expression! 13.2 F~1lUM AND ~ROVENES$: cub AND OWN I ----- End Forwarded Messages -----  -TIMESROMAN -VH(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8) (POSTSCRIPT (GACHA 8))) -E(z \ No newline at end of file diff --git a/docs/primer/DRAFT2.TEDIT b/docs/primer/DRAFT2.TEDIT deleted file mode 100644 index f8837033..00000000 --- a/docs/primer/DRAFT2.TEDIT +++ /dev/null @@ -1,6 +0,0 @@ -Second Group Date: 19 Dec 91 18:11 PST (Thursday) Posted-Date: 19 Dec 91 18:19 PST From: John Sybalsky:PARC:Xerox Subject: more primer files. To: porter:mv:envos >>CoveringMessage<< ----- Begin Forwarded Messages ----- Date: 19 Dec 91 15:28 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.152817pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11662>; Thu, 19 Dec 1991 15:28:23 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 15:28:17 -0800 From: John Sybalsky -----RFC822 headers----> F- 14. BREAKPACliGE The Break Package is a part of Interlisp that makes debugging your programs much easier. 14.1 Break WindoNT A break is a function either called by the programmer or by the system when an error has occurred. A separate window opens for each break. This window works much like the Interlisp-D Executive Window, except for extra menus unique to a break window. Inside a break window, you can examine variables, look at the call stack at the time of the break, or call the editor. Each successive break opens a new window, where you can execute functions without disturbing the original system stack. These windows disappear when you resolve the break and return to a higher level. 14.2 Break Package Example This example illustrates the basic break package functions. A more complete explanation of the breaking functions, and the break package will follow. The correct definition of FAGTORIAL is: (DEFIKEQ (FMT0RIAL (xj then 1 (iff5 (ITIES x (f~ToRIAL (sue, xj To demonstrate the break package, we have edited in an error: DUffKY in the IF statement is an unbound atom, it lacks a value. (DFIKEQ (F~T0RIAL (xj then ~ (if~[~~ (ITIKES x (FACTORIAL ~suei xj The evaluated function (F~T0RI~ 4) should return 24, but the above function has an error. DUMMY is an unbound atom, an atom without an assigned value, so Lisp will "break". A break window appears (Figure 14.1), that has all the functionality of the typing Interlisp-D expressions into the lnterlis~D executive window (The top level), in addition to the break menu functions. Each consecutive break will move to another level "down". BREAK PACKAGE 141 BREAK PACKAGE EXAMPLE 51+(PP Fllu'T&RIAL) cFACTORlAL [LA'NBOR ! `.j "rOMnNT~ (if (EROP `~ i,,ien Dummy 6Jil (lTIflEc A !FR~TORIAL !.UB1 :~j; !FACTCPIALj 5?(FALTORIAL 4,1 DUMMY (in FAi',TORlALJ in =ERDP P1!t4flY only br'okon! Figuro I..l. Break window Move the mouse cursor into the break window and hold down the middle mouse button. The Break Menu will appear. Choose BT. Another menu, called the stack menu, will appear beside the break window. Choosing stack items from this menu will display another window. This window displays the function's local variable bindings, or values. (See Figure 14.2) This new window, titled FACTORlAL Frame, is an inspector window. (See inspector Chapter 32). Sr fau'TUR[AL EP.PoM5ET fiRE&1 UNBOUND ATOM LflQ DUMMY (in fAcTORIAL) in \(ZEROP x) DUMMY) cob FLiDRI~ (DUMMY broken) cob FkWRl~ L.OB F,c~RI~ L'4M0 Figun 14.3. Back Yraco of trio 5ystem Stack From the break window, you can call the editor for the function FACTORIAL by typing (OF F~15IL) Underline X. Choose EVAL from the zditor menu. The value of X at the time of thff break will appear in the edit buffer below tho editor window. Any list or atom can be evaluated in this way (See Figure 14.3.) 14.1 lRF~PACMA'GF BREAK PACKAGE EXAMPLE UNBOUND ATOM DUMMY (in FACTORIAL ~ (ITIKES x \fASTORIAL ~SUB1 X))))) Replace switch ( ) (DUMMY broken) ()cUt OF FAL'TORIAL) Undo Find Swop Reprint Edit EatCam Break E~a1 E.t Figure 14.3. Editing from the Break Window Replace the unbound atom DUffNY with 1 Exit the editor with the EXIT command on the editor menu. The function is fixed, and you can restart it from the last call on the stack (It does not have to be started again from the Top Level) To begin again from the last call on the stack, choose the last (top) FACTOR1AL call in the BT menu. Select REVERT from the middle button break window, or type it into the window. TThe break window will close, and a new one will appear with the message: FACTORlAL broken. To start execution with this last call to FACTORIAL, choose OK from the middle button break menu. The break window will disappear, and the correct answer, 24, will be returned to the top level. 14.3 _ Ways to _ Stop _ Execution _ from the _ Keyboard, called _ "Breaking _ Lisp" There are ways you can stop execution from the keyboard. They differ in terms of how much of the current operating state is saved: Control-G provides you with a menu of processes to Interrupt. Your process will usually be ` EXEC". Choose it to break your process. A break window will then appear. Control-B causes your function to break, saves the stack, then displays a break window with all the usual break functions. For information on other interrupt characcers, see the Interlisp Reference Manual, volume 111, page 30.1. 8REAKPAcKAG 14.3 I PROGRAMMING BREAKS AND DEBUGGlNG CODE 14.4 Programming Breaks and Debugging Code PrOgramming breaks are put into code to cause a break when that section of code is executed. This is very useful for debugging code. There are 2 basic ways to set prOgramming breaks: (BREAK functionna:e) This function call made at the tOp level will cause a break at the start of the execution of "functionname". This is helpful in checking the values of parameters given to the function. Setting a break in the editor Take the function that you want tO break into the editor. Underline the expression that should break before it is evaluated. Choose BREAK on the editor command menu. Exit the editor. The function will break at this spot when it is executed. Once the function is broken, an effective way tO use the break window for debugging is to put it into the editor window. (See Section 14.2, Page 14.2.) All the local bindings still exist, so you can use the editor's EVAL command to evaluate lists, variables, and expressions individually. Just underline the item in the usual way (move the mouse to the word or parenthesis and press the leff mouse button), then choose EVAL from the command menu. (See Section 14.2 for more detail.) Both kinds of programmed breaks can be undone using the (UNBREAK) function. Type (~KBRDF functionnm) Calling (UNBREAK) without specifying a function name will unbreak all broken functions. 14.5 Break Menu Move the mouse cursor into the break window. Hold the middle button down, and a new menu will pop up, like the one in Figure 14.4. OK BT BY! "a f~ure 14.& Th middle bUtton menu in the Break window Five of the selection& are particularly important when just starting to use lnterlis~D: 8T Sack Trace displays the stack in a menu beside the break window. Back Trace is a very powerful debugging t00l. Each function call is placed on tho stack and removed when the execution of that function is complete. Choosing an item on th stack will open another window displaying that item's local 1(. 8~xpAcl:AGE E~ BREAK MENU voriobles and their bindings. This is on inspector window thit offers all the power of the inspector. (For details, see the section on the Inspector, Chapter 32). ? Sefore you use this menu option, display the stack by choosing 8T from this menu, and choose a function from it. Now, choose 7: It will display the current values of the arguments to the function that has been chosen from the stack. ~ Move back to the previous break window, or if there is no other break window, back to the top level, the InterlispD Executive Window. REVERT Move the point of execution back to a specified function call before the error. The function to revert back to is, by default, the last function call before the break. If, however, a different function call is chosen on the BT menu, revert will go back to the start of this function and open a new break window. The items on the stack above the new starting place will no longer exist. This is used in the tutorial example. (See Section 14.2, Page 14.1.) OK Continue execution from the point of the break. This is useful if you have a simple error, i.e. an unbound variable or a nonnumeric argument to an arithmetic function. Reset the variable in the break window, then select OK. (See Section 14.2.) (Note: In addition to being available on the middle button menu of the break window, all of these functions can be typed directly into the window. Only ST behaves differently when typed. It types the stack into the trace window instead of opening a new window.) 14.6 Returning to Top Level Typing Control-D will immediately take you to the top level from any break window. The functions called before the break will stop, but any side effects of the function that occurred before the break remain. For example, if a function set a global variable before it broke, the variable will still be set afler typing Control-D. BREAK PACKAGE 14.5 1 ----- Next Message ----- Date: 19 Dec 91 15:51 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.155149pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11668>; Thu, 19 Dec 1991 15:51:54 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 15:51:49 -0800 From: John Sybalsky -----RFC822 headers----> 27. WINDOWS AND REGIONS 27.1 Windows Windows have two basic parts: an area Ofi the screen containing a collection of pixels, and a property list. The window properties determine how the window looks, the menus that can be accessed from it, what should happen when the mouse is inside the window and a mouse button is pressed, and soon. 27.1.1 CREATEW 5ome of the window's properties can be specified when a window is created with the function CREATEW. In particular, it is easy to specify the size and position of the window; its title; and the width of its borders. (CREATEW region title borderw'idth) Region is a record, named REGION, with the fields left, botto:. width, and height. A region describes a rectangular area on the screen, the window's dimensions and position. The fields left and botto refer to the position of the bottom leff corner of the region on the screen. Vi dth and height refer to the width and height of the region. The usable space inside the window will be smaller than the width and height, because some of the window's region is consumed by the title bar, and some is taken by the borders. Title is a string that will be placed in the title bar of the window. Bordervvidtfr is the width of the border around the exterior of the window, in number of pixels. For example, typing: (SETQ ~.WIN~ CREATEW (CREAT RE6IS loo 150 300 200) THIS Is ~ r"w ilIN~ ) produces a window with a default borderwidth. Note that you did not need to specify all the window's properties. (See Figure 27.1.) wiNDows AND REGIONS 27 WINDOWS ,.J[1.lGJ'J (flf,,Tfff i'CRE"TEPE,IrnN jvjw 5- `9;, "~~i "TriI;' I> My ij'lN `ff Ibl&U'M' ii (~[N&JwlM2.65554 FigUre 27.1. Creating a Window In fact, if (CREATEW) is called without specifying a region, you will be prompted to sweep out a region for the window. (See Section 10.2, Page 10.2.) 27.1.2 WlNDOWPROP The function to access or add to any property of a window's property list is WIliDOVPROP. (WIN~PR0P window property ) When you use WIKDOWPROP with only two arguments - window and property - it returns the value of the window's property. When you use wIKOOVPROP with all three arguments - window, property and value - it sets the value the window's property to the value you inserted for the third argument. For example, consider the window, NY WINDOW, created using (CREATEW). TITLE and REGION are both properties. Type (ilI*~PW :.uI~ `TITLE) and the value of MY.WlNDOW's TITLE property is returned, "THIS 15 MY OWN WINDOW". To change the title, use the WINDOWPROP function, and give it the window, the property title, and the new title of the window. (wIK~PW ~.uI~ `TITLE P FIRST ilIK~) automatically changes the title and automatically updates the window. Now the window looks like Figure 27.2. 27.1 w1N00WS AND REG~NS WINDOWS 7t'WINDOWfROP NV WINDOW TITLE) IS NV OWN WINDOW" s.(WINDOWPROP NY.WlNDOl4 TITLE `QY FIRST WINDOW") THIS IS M\' OWN WINDOW" 4'. FigUre 27.2. TITLE is a Window Property Altering the region of the window, NY. VINDOV, is also be done with vINDOWPROP, in the same way you changed the title. (Note: changing either of the first two numbers of a region changes the position of the window on the screen. Changing either of the last two numbers changes the dimensions of the window itself.) 27.1.3 Getting windows to do things Four basic window properties will be discussed here. They are CURSORINFN, CURSOROUTFN, CURSORffOVEDFN, and BUTTONEVENTFN. A function can be stored as the value of the CURSORlNFN property of a window. It is called when the mouse cursor is moved into that window. Look at the following example: (1) First, create a window called MY.WlNDOW. Type: (SETQ P.WINDQW (CREATEI (cREATERE6Ia 200 200 200 200) "THIS WIllDOW WILL IREMl)) This creates a window. (2) Now define the function SCREAMER. It will be stored on the property CURSOR1NFN. (Notice that this function has one argument, WlNDOWNAME. All functions called from the property CURSOR1NFN are passed the window it was called from. So the value of MY. WINDOW is bound to WlNDOWNAME. When it is called, SCREAMER simply rings bells. (DEFINQ (ScREMER (WIK~~E) RIilBELLS) PROlPTPRIlT TAT - IT WDRFSI") RIKBELLS))) (3) Now, alter that window's CURSORINFN property, so that the system calls the function SCREAMER at the appropriate time. Type: WlNDow5 AND REGIONS 273 WINDOWS (WIN~PRoP P.wINI;0II `cuR~RIaf (F~IIk:TIK IR~R)) (4) Affer this, when you move the mouse cursor into MY.WlNDOW, the CURSORINFK property's function is called, and it rings beJls tvvice. CURSORINFN is one of the many window properties that come with each window - just as REGION and TITLE did. Other properties include: CURSOROUTFN The function that is the value of this property is executed when the cursor is moved out of a window; CURSORMOVEDFN the function that is the value of this property is executed when the cursor is moved while it is inside the window; BUTTONEVENTFN the function that is the value of this property is executed when either the Ieff or middle mouse buttons are pressed (or released). Figure 27.3 shows MY.WlNDOW's properties. Notice that the CURSORINFK has the function SCREAMER stored in it. The properties were shown in this window using the function INSPECT. INSPECT is covered in Chapter 32. . . ` 1 GREEN NIL HI NOo'rtENTR'[FN O liE. TT'( PRObES PRfllESS NIL `,`181)ROER 4 NEWREL'I)NF4 NIL `NTITLE THIS `ffiINDOW `tILL .QCREAn!" MOlEfN NIL CLOSEFN NIL HORIZOCROLL'.yIND1)',t NIL "ER1L'ROLLNINoO'ff NIL c.u'ROLLFN NIL H)RI=J-'cRlLLREG NIL ":`ERTSCR)LLREU NIL USERDATA NIL E!'!TENT NIL REOH4PEFN NIL REPAINTFN NIL L'URSORttOvEDFN NIL CURSOROUTFN NIL CURSORINFN SCCE'ThER RIGHTBUTTONFN NIL BU1FONEVENTFN TOTOPU REG 12J0 "L)9 J~ `36! SavE (BITMAP~3,1jo52 NE~('t (WIflD1)'-'1j55,1'lj'..8 DSP ~5TRE>M\,~F,jjjj~4 Figur 27.3. Inspeaing MY.wlNDow for MouseRelated Window Properties You can define functions for the values of the properties CURSOROUTFK and CURSORMOVEDfN in much the same way as you did for CURSORINfN. The function that is the value of the property BUTTOHEVENTFN, however, cab be specialized to respond in different ways, depending on which mouse button is pressed. This is explained in the next section. 27.1.3.1 BUtrONVENTFN BUTTONEVENTFK is anothqr property of a window. Tho function that is stored as tfl valu of this property is called when tho mouso is insid tho window, and a mouso button is pressed. As an exampl of how to us iL type: 27A ~N00wS ANO REGIONS witurows (wI~PKP :.ilIK~ `euTTW"EKTtr (F~TI5 ScREAER)) When the mouse cursor is moved into the window, bells will ring because of the CURS0RlNFN, but it will also ring bells when either the Jeff or middle mouse button is pressed. Notice that the right mouse button functions .5 it usually does, with the window manipulation menu. If only the left button should evoke the function SCREAMER, then the function can be written to do just this, using the function MOUSESTATE, and a form that only NOUSESTATE understands, ONLY. For example: (DEFIKEQ (SCRElERZ WIK~) (if ESTATE (aLY LEFT)) tha (RIKBLLS)))) In addition to (ONLY LEFT), MOUSESTATE can also be passed (ONLY MIDDLE), (ONLY RIGHT) or combinations of these (e.g. (OR (ONLY LEFT) (ONLY MIDDLE))). You do not need to use ONLY with MOUSESTATE for every application. ONLY means that that button is pressed and no other. If you do write a function using (ONLY RIGHT), be sure that your function also checks position of the mouse cursor. Even if you want your function to be executed when the mouse cursor is inside the window and the right button is pressed, there is a convention that the function DOVINDOWCOM should be executed when the mouse cursor is in the title bar or the border of the window and the right mouse button is pressed. Please program your windows using this tradition! For more information, please see the Intertisp-D Reference Manual, Volume 3, Chapter 28, Pages 7 and 28. Please refer to the Intertisp Reference Manual, Volume 3, Chapter 28, for more detail and other important functions. 27.1.4 Looking at a window's prOperties INSPECT is a function that displays a list of the properties of a window, and their values. Figure 27.3 shows the INSPECT function run with MYWINDOV. Note the properties introduced in CREATEW: WBORDER is the window's border, REG is the region, and WTITLE is the window's title. 27.2 Regions A region is a record, with the fields LEFT, BOTTOM, WIDTH, AND HEIGHT. LEFT and BOflOM refer to where the bottom leff hand corner of the region is positioned on the screen. WIDTH and HEIGHT refer to the width and height of the region. CREATERE6ION creates an instance of a record of type REGION. Type: (SETO ~.RE6Ia (CREATERESIl 15 loo 200 450)) WINDOWS AND REGIONS 275 REGIONS to create a record of type REGION that denotes a rectangle 200 pixels high, and 450 pixels wide, whose bottom leff corner is at position (15, 100). This record instance can be passed to any function that requires a region as an argument, such as CREATEV, above. a,. WlN00WS ANO REGIONS ----- Next Message ----- Date: 19 Dec 91 15:59 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.155935pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11672>; Thu, 19 Dec 1991 15:59:45 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 15:59:35 -0800 From: John Sybalsky -----RFC822 headers----> 28. WHAT ARE MENUS? While Interlisp-D provides a number of menus of its own (see Section 7.1, Page 7.2), this section addresses the menus you wish to create. You will learn how to create a menu, display a menu, and define functions that make your menu useful. Menu's are instances of records (see Chapter 24). There are 27 fields that determine the composition of every menu. Because Interlisp-O provides default values for most of these descriptive fields, you need to familiarize yourself with only a few that we describe in this section. Two of these fields, the TITLE of your menu, and the ITEMS you wish it to contain, can be typed into the InterlispD Executive window as shown below: NIL 33'(.ETO MY. MEN (cRE"'TE ME/lb TiTLE ,.PLE~~SE CHCio8 ONE OF THE ITEMS" ITEMS (0,LlIT NE,T-l)UE;STION NE;~T-TOPIL SEE-TOPIC;5'JJJ ,rMENU!,#c4, ij':'3jH Figure 28.1. Creating a menu Note that creating a menu does not display it. MY.MENU is set to an instance of a menu record that specifies how the menu will look, but the menu is not displayed. 28.1 Displaying Menus Typing either the MENU or ADDNENU functions will display your menu on the screen. MENU implements pop-up menus, like the Background Menu or the Window Menu. ADDMEHU puts menus into a semi-permanent window on the screen, and lets you select items from it. (MENU MENU POSITION) pops-up a menu at a particular position on the screen. Type: (*EKU MY.ffI KIL) to position the menu at the end of the mouse cursor Note that the POSITION argument is NIL. In order to go on, you must either choose an item, or move outside the menu window and WHAT ARE MENUS' 281 DISPLAYING MENUS press a mouse button. When you do either, the menu will disappear. If you choose an item, then want to choose another, the menu must be redisplayed. (ADONENU menu window position) positions a permanent menu on the screen, or ;n an existing window. Type: (ADlEKU P.*EI) to display the menu as shown in Figure 28.2. This menu will remain active, (will stay on the screen) without stopping all the other processes. Because ADONEliU can display a menu without stopping all other processes, it is very popular in users programs. If window is specified, the menu is displayed in that window. If window is not specified, a window the correct size for the menu is created, and the menu is displayed in that window. If position is not specified, the menu appears at the current position of the mouse cursor. NE..TQUESIlCN 3EEToPIC> . . Figure 28.2. A Simple Menu, displayed with AooNriU. 28.2 Getting Menus to DO Stuff One way to make a menu do things is to specify more about the menu items. Instead of items simply being the strings or atoms that will appear in the menu, items can be lists, each list with three elements. (See Figure 28.3.) The first element of each list is what will appear in the menu; the second expression is what is evaluated, and the results of the evaluation returned, when the item is selected; and the third expression is the expression that should be printed in the Prompt window when a mouse button is held down while the mouse is pointing to that menu item. This third item should be thought of as help text for the user. If the third element of the list is NIL, the system responds with "Will select this item when you release the button". JGJ WHAT AR5 MENUS? GErn~ MENUS TO DO STUFF NIL 17+(SETQ Nv.MENU2 (SRATE MENU TITLE "PLEASE LHOOSE ONE OF TflE ITEMS" I~,EMS `(VQUIT (PRINT "STOPPEO" \ "LHOOSE THIS TO 5O~'',' (NE\T-QUESTIOH (PRINT "HERE IS TME NE.'\'T QLlSTIOH . u'HOOSE THIS TO ~E lSKED THE NE."T QUESTION"', iNE!~T-TOPIL (PRINT HERE IS THE NE'~T TOPIL . "C.HOOSE THIS TO KOv OH TO THE NE'\T SueJELT" `1 (SEE-TOPICS (PRINT "THE FOLLOYIN6 HA'\E NOT e.EEN LARNEO"', *CHOOSE THIS TO SEE THE TOPICS NOT YET LErtRNEO"l `ii ~~MENU,'#5~. `.5~5j 1qL(cl&MENL MY. MEtlU:' ,rNIN&El'~~~4', 175350 14 Firnre 28.3. Creating a menu that will do things, then displaying it with the funttion ADDNEHU Now when an item is selected from KY.KENU2, something will happen. When a mouse button is held down, the expression typed as the third element in the item's specification will be printed in the Prompt window. (See Figure 28.4.) NE7.T.'JUE'=TlE'r~J SEE-TOPIC' Fiqrnre 28.1. Mouse Button Held Down While Mouse Cursor SeIe~ NEXT-QUESTIoN When the mouse button is released (i.e. the item is selected) the expression that was typed as the second element of the item's specification will be run. (See Figure 28.5.) Y-'OUE'Tl"N `EETOPlr"' "HERE IS THE NEXT ilUETION. Figure 28.5. NEXT-QUESTION Selected WHAT ARE MENUS' 283 GEHlNG MENUS TO DO STUFF 28.2.1 _ The WHENHLDFN _ and WNENSELCTEDFN fields of a _ menu Another way to get a menu to do things is to define functions, and make them the values of the menu's WHENHELDFN and WHENSELECTEDFN fields. As the value of the WHENHELDFN field of a menu, the function you defined will be executed when you press and hold a mouse button inside the menu. As the value of the WHENSLCTEDFN field of a menu, the function you defined will be executed when you choose a menu item. This example has the same functionality as the previous example, where each menu item was entered as a list of three items. As an example, type in these two functions so that they can be executed when the menu is created and displayed: (DEFIKEQ LCTED (SELEcfQPiNTEENNUJSENHENHELO (ITEl.SLECTED a:. FROM BUTT:. PRESSED) QUIT (PROMPTPRIKT cHOOSE THIS TO sToP)) NEXT-QUESTION (PROMPTPRIKT CHOOSE THIS TO BE ASKED TNE NEXT QUESTION-)) NEXT-TOPIC PROMPTPRINT CHOOSE THIS TO MOO,E a TO THE NEXT SUBUIECT)) SEE-TOPICS PROMPTPRINT CHDOSE THIS TO SEE THE TOPICS NOT YET LARNED)) ERROR (PROM TPRIKT NO liTCH FOUND))))) (DEFINEQ WENSELECTED (ITEM.SELECTED MENU. FROM 8UTT:.PRESSED) QUIT (PRINT STOPPED)) NEXT-QU RINT "HERE IS THE NEXT QUESTION...)) NEXT-T HERE IS THE NEXT TOPIC. . - PICS PRINT THE FOLLONIK HAVE NOT 8EEN LEARNED. .. ERROR (PRONFTPRINT NO liTCH FOUND))))) Now, to create the menu, type: (SETQ MY.NE:3 (CREATE NE: TITLE PLEASE CHOOSE :E OF THE ITEMS ITEK `(QUIT NEXT-QUESTION NEXT-TOPIC SEE-TOPICS) NHENHELDFN (FUNCTIK MY.NENU3.NHENHELD) fflENSELECTEDFN (FUNCTION NY, .MENU3 .fflENSELECTED))) Type (ADDMENU MY.MENU3) to see your menu work. NOW, due to executing the WHNNELDFN function, holding down any mouse button while pointing to a menu item will display an explanation of the item in the prompt window. The screen will once again look like Figure 28.4 when the mouse button is held when the mouse cursor is pointing to the item NEXT-TOPIC. Now due to executing the WHENSELECTEDFN function, releasing the mouse button to select an item will cause the proper actions for that item to be taken. The screen will once again look like Figure 28.5 when the item NEXT-TOPIC is selected. The crucial thing to note is that the functions you defined for WHENHELDFN and WHENSELECTEDFN are automatically given the following arguments: (t) the item that was slected, ITEM. SELECTED; (2) the menu it was selected from, MENU. FROM; (3) and the mous button that was pressed BUTTON PRESSED. Hot: thes functions, *Y.NENU3.fflENflELO and ffY.KEKUJ.ilHEKSELCTEO, wre quoted using FUKCTIOK instead of QUOTE both for program radability and so that the 21.1 ~YAR1".NUs? GETTlMG MENUS TO 00 STUFF compiler con produce foster code when the program is compiled. It is good style to quote functions in Intertisp by using the function FUNCTION instead of QUOTE. 28.3 Looking at a menus fields INSPECT is a function that displays a list of the fields of a menu, and their values. The Figure 28.6 shows the various fields of NY .NENU3 when the function (INSPECT NY NENU) was called. Notice the values that were assigned by the examples, and all the defaults. \JN"PELT NY liENl./3l l1IHDU'wJ#'1, 54scj NENllPECICNB1:TTi=fl o Imrni';E (!VINDLlrt$#b1.l5lSjl t1)UlT HE~T-LlL'E'TI1=1N ``-Ti'iFl' ET MENUPOffo' ANUEAFF'ETFLL: NIL ffENUEQHT i:FclNTPc:::cf IpTclFt -a TITLE `PLEAL'E CHil.l `HE ,iF THE ITE ffEHlJoFF6ET A LECTEDFN fly flEflJ, h.rtEf:EL.FCTEl `1flE'flELDFH NV flEPlLl3 \rtEHHELJP ENl)NHELoFH l:LFF'RCHPT flENOFEEOe4l,'r.FLG NIL Figure 28.6. The Fields of MY.MENU3 WHAT ARE MENUS' 285 ----- Next Message ----- Date: 19 Dec 91 16:10 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.161052pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11680>; Thu, 19 Dec 1991 16:10:56 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:10:52 -0800 From: John Sybalsky -----RFC822 headers----> 29. lilTMAPS A bitmap is a retangular array of dots. The dots are called pixels (for picture elements). Each dot, or pixel, is represented by a single bit. When a pixel or bit is turned on (i.e. that bit set to 1), a black dot is inserted into a bitmap. If you have a bitmap of a floppy on your screen, (Figure Figure 29.1), then all of the bits in the area that make up the floppy are turned on, and the surrounding bits are turned off. FLOPPY (Ia b~JwP- ~`,5,,Bh (t-:)o Figure 29.1. Bitmap of a Floppy BITNAPCREATE creates a bitmap, even though it can't be seen. (BIfflPCRDTE width height) If the width and height are not supplied, the system will prompt you for them. EDZTBN edits the bitmap. The syntax of the function is: (EDITl bitmapname) Try the following to produce the results in Figure 29.4: l~SoETiQr:~rB!sTHituPbB~I~PcRDTE eo 40)) To draw In the bitmap, move the mouse into the gridded section of the bitmap editor, and press and hold the leff mouse button. Move the mouse around to turn on the bits represented by the spaces in the grid. Notice that each space in the grid represents one pixel on the bitmap To erase Move the mouse into the gridded section of the bitmap editor, and press and hold the center mouse button. Move the mouse around to turn off the bits represented by the spaces in the gridded section of the bitmap editor. To work on a different section Point with the mouse cursor to the picture of the actual bitmap (the upper left corner of the bitmap editor). Press and hold the BlTMAPS 291 BlTMAPS Jeff mouse button. A menu with the singJe item, ttove will appear. (See Figure 29.2.) Choose this item. . . Figure 29.2. Move the mou5e cursor to the Dtcture of the bitmap. Press and hold the Iek mouse button. and the Move menu will appear You will be asked to position a ghost window over the bitmap. This ghost window represents the portion of the bitmap that you are currently editing. Place it over the section of the bitmap that you wish to edit. (See Figure 29.3.) . . . . . . ... . .... I . 29.3. .. J=.. :. II.lI:.:;;. _ . . f1ure Affer you choose move. yoU will be asked to position a ghost window like this one. Position it by clicking the leff mouse button when the ghost window is over the part of the picture of the bitmap you would like to edit. To end the session 8ring the mouse cursor into the upper-right portion of the window (the grey area) and press the center button. Select OK from the menu to save your artwork. 29) .lY~ r'. alTMAps .:: 5''iSETQ ffy IllNAP (I[TNAPcPEATE OR GO)' j:y.IlfM&P ost\ ,A.BlTMAPl6',1.q;lO 58oi,EOIlBM my.IlTNAP\ - - . . -A fr.j: ` = "''~ = . ~. . . . F~ure 29.4. Editing a Bitmap BITBLT is the primitive function for moving bits (or pixels) from one bitmap to another. It extracts bits from the source bitmap, and combines them in appropriate ways with those of the destination bitmap. The syntax of the function is: (BITBLT sourcebitmap sourcelefl sourcebottom destinationbitmap destinationleft destinationbottom width height sourcetype operation texture clippIngregion) Here's how it's done - using MY.BlTMAP as the sourcebitmap and MY.WlNDOW as the destinationbitmap.' (BITBLT rn.BITll4P NIL NIL P.wIN~ NIL NIL KIL NIL `INPUT `REPuCE) Note that the destination bitmap can be, and usually is, a window. Actually, it is the bitmap of a window, but the system handles that detail for you. Because of the IlLs (meaning "use the default"), MY.BlTMAP will be BlTBLT'd into the lower right hand corner of MY.WlNDOW. (See Figure 29.5.) BlTMAPS 293 ~17MAP5 98'(BITBLT KY Strap NIL NIL my ,1(10p,, FL `IL NIL HIL Tipil' P.PLlfi (~=l', Figure 29.5. 9ITBLTng a Bitmap onto a Window Here is what each of the SlTBLT arguments to the function mean: sourcebitmap the bitmap to be moved into the destinationbitmap sourcelett a number, starting at O for the Jeff edge of the sourcebitmap, that tells SITBLT where to start moving pixels from the sourcebitmap. For example, if the leftmost 10 pixeis of sourcebitmap were not to be moved, sourceleft should de 10 The default value is O. sourcebottom a number, starting at O for the bottom edge of the sourcebitmap, that tells BIT6LT where to start moving p1'xels from the sourcebitmap. For example, if the bottom 10 rows of pixels of sourcebitmap were not to be moved, sourcebottom should be 10 The default value is O. destinationbitmap the bitmap that will receive the sourcebitmap. This is offen a window (actually the bitmap of a window, but Interlisp-b takes care of that for you). destinationleff a number, starting at O for the leff edge of the destinationbitmap, that tells BITBLT where to start placing pixels from the sourcebitmap. For example, to place the sourcebitmap 10 pixels in from the Jeff, destinationleft should be 10. The default value is 0. destinationbottom a number, starting at 0 for the bottom edge of the destinationbitmap, that tells BITBLT where to start placing pixels from the sourcebitmap. For example, to place the sourcebitmap 10 pixels up from the bottom, destinationbottom should be 10. The default value is 0. width how many pixels in each row of sourcebitmap should be moved. The samc amount of space is used in destinationbitmap to receive the sourcebitmap. If this argument is NIL, it defaults to the number of pixels from sourceleft to the end of the row of sourcebitmap. height how many rows of pixels of sourcebitmap should be moved. The same amount of space is used in destinationbitmap to receive thq sourtebitmap. If this argument is NIL, it defaults to the number of row; from sourcebottom to tho top of the sourcebitmap. sourcetyp rofors to on of thro ways to cofivrt th sourcebitmap for writing. For now, just us `INPUT. 29. o~ps ` ` ` ` ` ` ` ` ` ` ` ` ` `` ` `" ` ` ` ` ` ` ` ` ` ` ` ` ` OIlMAPS operation refers to how the sourtebitmap gets BlTBLT'd on to the destinationbitmap. `REPLACE will BLT the exact sourcebitmap. Other operations allow you to AND, OR or XOR the bits from the sourcebitmap onto the bits on the destinationbitmap. texture Just use NIL for now. clippingregion just use NIL for now. Por more information on these operations, see the Interlisp-D Reference Manual, Volume 3, Chapter 27, Page 14. Sourcebitmap, sourceleft, sourcebottom, destinationbitmap, destinationleft, destinationbottom, width and height are shown in Figure 29.6. Destination Bitmap Source Bitmap FLOPPY tlcblffkUP' 3/S/Bh height e./,o width Source leh. Source bottom. The "x y coordinates in terms of the source (OOforthewhoiesource). Destination Jeff, Dertination Bottom. The ,,x y" coordinates in terms of the destination bitmap. (00 to put the source bitmap in the Ieft bottom corner of the dertination bitmap). Figure 29.6. BITBLT'ed Bitmap of a Floppy BITMAPS 295 ----- Next Message ----- Date: 19 Dec 91 16:16 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.161653pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11679>; Thu, 19 Dec 1991 16:16:57 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:16:53 -0800 From: John Sybalsky -----RFC822 headers----> 30. DlSPLAYSTREAMS A displaystream is a generaJized "place to display". They determine exactly what is displayed where. One example of a displaystream is a window. Windows are the only displaystreams that will be used in this chapter. If you want to draw on a bitmap that is not a window, other than with BITBLT, or want to use other types of displaystreams, please refer to the Interlisp-D Reference Manual, Volume 3, Chapter 27. This chapter explains functions for drawing on displaystreams: DRAWLINE, DRAWTO, DRAVCIRCLE., and FILLCIRCLE. In addition, functions for locating and changIng your curreAt position in the displaystream are covered: DSPXPOSITIOH, DSPYPOSITION, and NOVETO. 30.t Drawing on a Displaystream Examples will show you how the functions for drawing on a display stream work. First, create a window. Windows are displaystreams, and the one you create will be used for the examples in this chapter. Type: (SETO EwPLE.wIN~ (CREATEI)) 30.1.1 DRAWLlNE DRAWL IRE draws a line in a displaystream. For example, type: (DliVLIKE 10 IS loo 150 S IlERT ExMPLEwIN~) The results should look like this: Figure 30.1. The line drawn onto the displayrtream, ExAMPLEwlNDoW DlSPLAYSTREAMS 30 DRAWING ON A DlSPLAYsTaE:M The syntax of DRAWL1NE is (Dli~IKE xl yl x2 y2 width opera tion stream ) The coordinates of the Jeff bottom corner of the displaystream areOO. xl and yl are the x and y coordinates of the beginning of the line; x2andy2 are the ending coordinates of the line; width isthe width of the line, in pixels operation is the way the line is to be drawn. INVERT causes the line to invert the bits that are already in the displaystream. Drawing a line the second time using INVERT erases the line. For other operations, see the Interlis~D Reference Manual, Volume 111, Page 27.15. stream is the displaystream. In this case, you used a window. 30.1.2 ORA~O DRAWTO draws a line that begins at your current position in the displaystream. For example, type: (Dli~O 120 135 5 `IrvERT E~LE.*IH~) The results should look like this: Figuro 30.2. Another line drawn onto the displaystream, ExAMPLEWlNDow The syntax of ORAWTO is (oliilT0 x y width operation stream i) The line begins at the current position in the displaystream. x is the x coordinate of the end of the line; y is they coordinate of the end of the line; width is the width of the line operation is the way the lino is to be drawn. INVERT causes the line to invert the bits that aro already in tho displaystream. Drawing a line the second time using INVERT erases the line. For other operations, see the lnteHi~O Reference Manual, Volume Ill, Page 27.15. stream is the displaystreom. In this case. you used a window. 30.2 llPLAYSTQCANT DRAW1NG ON A D15PLAr5~E~ 30.1.3 DRAWClRCLE DRAWCIRCLE draws a circle on a displaystream. To use it, type: (0li~I~LE 150 100 so `(~RTICAL 5) KIL E~LE .VI~) Now your window, EXAMPLE.WlNDOW, should look like this: Flur 30.3. The circle drawn onto the displaystream. EXAMPLE WINDOW The syntax of DRAWCIRCLE is (0li~IEL centerx centery radius brush dashing stream) centerx is the x coordinate of the center of the circle centery is they coordinate of the center of the circle radius is the radius of the circle in pixels brush is a list.- The first- item of the list is the shape of the brush. Some of your options include ROUND, SQUARE, and VERTICAL. The second item of that list is the width ofthe brush in pixels. dashing is a list of positive integers. The brush is "on" for the number of units indicated by the first element of the list, "off" for the number of units indicated by the second element of the list. The third element specifies how long it will be on again, and so forth. The sequence is repeated until the circle has been drawn. stream is the displaystream. In this case, you used a window. 30.1.3.1 FlLLClRCLE FILLCIRCLE draws a filled circle on a displaystream. To use it, type: (FILLCIRCLE 200 150 10 6liY~DE ExlPLE.wIli~) EXAMPLE.WlNDOW now looks like this: DlSPLAYSTREAMS 303 l DRAWING ON A DISPLAYSTREAM Figure JO.t A filled circle drawn onto the displaystream, EXAMPLE WINDOW The syntax of FILLCIRCLE i5 (FILLCIRCL centerx centery radius texture stream) centerx is the x coordinate of the center of the circle centery is theycoordinate of the center of the ci rcle radius is the radius of the circle in pixels texture is the shade that will be used to fill in the circle. Interlisp-D provides you with three shades, WHlTESHADE, BLACKSHADE, and GRAYSHADE. You can also create your own shades. For more information on how to do this, see the Interlisp-D Reference Manual, Volumelll, Page 27.7. stream is the displaystream. In this case, you used a window. There are many other functions for drawing on a displaystream. Please refer to the Intertisp-D Reference Manual, Volume 111, Chapter 27. Text can also be placed into displaystreams. To do this, use printing functions such as PRIffl and PRIN2, but supply the name of the displaystream as the "file" to print to. To place the ten in the proper position in the displaystream, see 5ection 30.2, Page 30.4. 30.2 _ Locating _ and _ Changing _ Your _ Position _ in _ a _ Displaystream There are functions provided to locate, and to change your current position in a displayitream. This can help you place text, and other images where you want them in a displaystream. This primer will only discuss three of these. There are others, and they can be found in the lnterlis~D Reference Manual, Volume Ill, Chapter 27. 30.4 0lSPLAY$TREA~ r. LOCATING AND CHANGING YOUR POSITION IN A DISPLAYSTREAM 30.2.1 DSPXPOSlTlON DSPXPOSITION is a functiOn that will either change the current x pOsition in a displaystream, or simply report it. To have the function report the current x position in EXAMPLE.WlNDOW, type: (OSP*PoSlTIoN NIL EXlPLE .ilINDON) DSPXPOSITION expects two arguments. The first is the new x position. If this argument is NIL, the current position is not changed, merely reported. The second argument is the displaystream. 30.2.2 DSPYPOSlTlON DSPYPOSITION is an analogous function, but It changes or reports the current y position in a displaystream. As with DSPXPOSlTlON, If the first argument Is a number, the current y position will be changed to that position. If it is NIL, the current position is simply reported. To have the function report the current y position in EXAMPLE.WlNDOW, type: (DSPYROSITIoN NIL ExlPLE.WIK-~) 30.2.3 MOVETO The function NOVETO always changes your position in the displaystream. It expects three arguments: (~-ET0 xystream) x is the new x position in the display stream y is the new y position in the display stream stream is the display stream. The examples so far have used a window. DISPLAYSTREAMS 30 5 ----- Next Message ----- Date: 19 Dec 91 16:30 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.163054pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11682>; Thu, 19 Dec 1991 16:30:58 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:30:54 -0800 From: John Sybalsky -----RFC822 headers----> 31. FONTS This chapter explains fonts and fontdescriptors, what they are and how to use them, so that you can use functions requiring fontdescriptors You have already been exposed to many fonts in Interlisp-D. For example, when you use the structure editor, DEdit, (See Section 11.3.), you noticed that the comments were printed in a smaller font than the code, and :hat CLlSP words (See Section 13.1, Page 13.1.) were printed in a darker font than the other words in the function. These are only -me of the fonts that are available in Interlisp-D. In addition to the fonts that appear on your screen, Interlisp-D uses fonts for printers that are different than the ones used for the screen. The fonts used to print to the screen are called DlSPLAYFONTS. The fonts used for prining are called INTERPRESSFONTS, or PRESSFONTS, depending on the type of printer. 31.1 What makes up a FONT? Fonts are described by family, weight, slope, width, and size. This section discusses each of these, and describes how they affect the font you see on the screen. Family is one way that fonts can differ. Here are some examples of how "family" affects the look of a font: CLASSIC This family makes the word "Able" look like this: Able MODERN This family makes the word "Able" look like this: Able TERMINAL This family makes the word "Able" look like this: Able Weight also determines the look of a font. Once again, "Able" will be used as an example, this time only with the Classic family. A font's weight can be: BOLD and look like this: Able MEDIUM or REGULAR and look like this: Able The slope of a font is italic or regular. Using the Classic family font again, in a regular weight, the slope affects the font like this: ITALIC looks like this: A file REGULAR looks like this: Able FONT5 311 1 WHAT MAKES UP A FONT? The width of a font is called its "expansion". It can be COMPRESSED, REGULAR, or EXPANDED. Together, the weight, slope, and expansion of a font specifies the font's "face". Specifically, the face of a font is a three element list: (weight slope expansion) To make it easier to type, when a function requires a font face as an argument, it can be abbreviated with a three character atom. The first specifies the weight, the second the slope, and the third character the expansion. For example, some common font faces are abbreviated: MRR This is the usual face, MEDIUM, REGULAR, REGULAR; MlR makes an italic font. It stands for: MEDIUM, ITALIC, REGULAR; BRR makes a bold font. The abbreviation means: BOLD, REGULAR, REGULAR; BIR means that the font should be both bold and italic. BIR stands for BOLD, ITALIC, REGULAR. The above examples are used so oflen, that there are also more mnemonic abbreviations for them. They can also be used to specify a font face for a function that requires a face as an argument. They are: STANDARD This is the usual face: MEDIUM, REGULAR, REGULAR. It was abbreviated above, MRR; ITALIC This was abbreviated above as MR, and specifies an italic font; BOLD of course, makes a bold font. It was abbreviated above, BRR; BOLDlTALIC means that the font should be both bold and italic: BOLD, ITALIC, REGULAR. It was abbreviated above, BlR. A font also has a size. It is a positive integer that specifies the height of the font in printers points. A point is, on an 1108 screen, about 1/72 of an inch. On the screen of an 1186, a point is 1/80 of an inch. The size of the font used in this chapter is 10. For comparison, here is an example of a TERMINAL, MRR, size 12 font: Able. 31.2 Fontdescriptors, and FONTCREATE For InterlispD to use a fort, it must have a fontdescriptor. A fontdescriptor is a data type in InterlispD that that holds all the information needed in order to use a particular font. When you print out a fontdescriptor, it looks like this: [fKTDEIRIPToRji,s~0 Fontdescriptors are created by the function F0NTCREATE. For example, (F~TCREATE `flEL~1lCA 12 `~o) J: 31.2 FOflff FONTDESCRlPTORS, AND F0NTCREAlE creates G fontdescriptor that, when used by other functions, prints in HELVETIEA BOLD size 12. Interlisp-D functions that work with fonts Gxpect a fontdescriptor produced with the FONTCREATE function. The syntax of FONTCREATE is: (F0KTCREATE family size face) Remember from the previous section, face is either a three element list, (weight slope expansion), a three character atom abbreviation, e.g. MRR, or one of the mnemonic abbreviations, e.g. STANDARD. If FONTCREATE is asked to create a fontdescriptor that aJready exists, the existing fontdescriptor is simply returned. 31.3 Display Fonts - Their files, and how to find them Display fonts require files that contain the bitmaps used to print each character on the screen. All of these files have the extension .DlSPLAYFONT. The file name itself describes the font style and size that uses its bitmaps. For example: ~ERK12.DISPUYFRT contains bitmaps for the font family MODERN in size 12 points. Initially, these files are on floppies. The files that are used most offen should be copied onto a directory of your hard disk or fileserver. Usually, this directory is called FONTS. Wherever you put your .DISPLAYFONT files, you should make this one of the values of the variable DISPLAYFONTDIRECTORIES. Its value is a list of directories to search for the bitmap files for display fonts. Usually, it contains the "FONT" directory where you copied the bitmap files, the device (FLOPPY), and the current connected directory The current connected directory is specified by the atom NIL. Here is an example value of DISPLAYFONTDIRECTORIES: . - 11 NIL r~':PI:='pL"'yFnNTDIP,ECTBP,IES i;!Io= ` . =PFIL -FnNT~." (D.~fr):!.LIT'.PFIL fFLnPF"')- NIL!i 9! Figure 31.1. A valuefor the atom DISFLAYFONTDIRECTORIES When looking for a .DiSPl.AYFONl file. `he system will check the F0NT directory on the hard disk. then the top level directory on the hard disk, then the floppy. then the current connected dir8rtory FONTS 313 INTERPRESS FONT5 - THEIR FILES, AND HOW TO FIND THEM 31.4 _ Interpress _ Fonts _ - _ Their files, _ and _ how _ to _ find _ them Interpress i5 the format that is used by Xerox laser printers. These printers normally have a resolution that is much higher than that of the screen: 300 points per inch. In order to format f,Ies appropriately for Output on such a printer, Interlisp must know the actual size for each character that is to be printed. This is done through the use of width files that contain font width information for fonts in Interpress format. Initially, these files (with extension .WD) are on floppies. The files should be copied onto a directory of your hard disk or fileserver. For Interpress fonts, you should make the location of these files one of the `values of the variable INTERPRESSFOliToIRFcTORIES. Its value is a list of directories to search for the font viidths files for Interpress fonts. Here is an example value of INTERPRE5SFONTD1RECT0R1ES: . 11 1'lIL i?IbdTEFPfiET=:FnN7PIP:EcTnRI~,~ .i=~~.~ j:~,~ Figure 31.2. A value for the atom INTERPREssFoNTDIREcToRIEs When looking for a font widths file for an Interpress font, Interlisp-D will cne~ the hard disk. 31.5 Functions for Using Fonts 31.5.1 F0NTPR0P Looking at Font Properties It is possible to see the properties of a fontdescriptor. This s done with the function FONTPROP. For the following examples, the fontdescriptor used will be the one returned by the function (DEFAULTFONT `DISPLAY). In other words, the fontdescriptor examined will be the default display font for the system. There are many properties of a font that might be useful for you. Some of these are: FAffILY To see the family of a font descriptor, type: (FKTPliP (DEFAllLTFoIT `DISPLAY) `f~ILY) SIZE As above, this is a positive integer that determines the height of the font in printer's points. As an example, the SIZE of the current default font is: 31 ~n FUNCTIONS FOR USING FONTS . 11 NIL Gi,(FnNTPROP (DEF~ULTFONT PI~~PLAY) `.,,:`IZE\ is, Figure 31.3. The value of (he font property SIZE of the default font ASCENT The value of this property is a positive integer, the maximum height of any character in the specified font from the baseline (bottom). The top of the tallest character in the font, then, will be at (BASELINE # ASCE[VT - l). For example, the ASCENT of the default font is: 1 11 NIL A 4' ,. I!FnNTPROP if OfF"' ULTFnNT PI~,~PL~","!' `~e-rENT:! q.- A,5~: Figure 31.& The value of the font property ASCENT of the default font DESCENT The DESCENT is an integer that specifies the maximum number of points that a character in the font descends below the baseline (e.g. letters such as "p" and "g" have tails that descend below the baseline.). The bottom of the lowest character in the font will be at (BASELINE - DESCENT). To see the DESCENT of the default font, type: (FOkTPROP (DEfAULTFKT `DISPUY) `DESr:KT) HEIGHT HE IGHT is equal to t'DESCENT-ASCENT). FACE The value of this property is a list of the form, (weight slope expansion). These are the weight, slope, and expansion described above. You can see each one separately, also. Use the property that you are interested in, VEIGHT, SLOPE, or EXPANSION, instead of FACE as the second argument to FONTPROP. For other font properties, see the Interlisp-D Reference Manual, VolumeIll, Pages 27.27 - 27.28. 31.5.2 5TRlNGWlDTH It is offen useful to see how much space is required to print an expression in a particular font. The function STRINGVIDTH does this. For example, type: (STRIKWIDTH "NV thera! (`L'NTcREAT `UCli 10 `STAKDARD)) The number returned IS how many leff to right pixels would be needed if the string were printed in this font. (Note that this F0NTS 31 S FUNCTIONS FOR USING FONTS doesn't ju5t work for pixels on the screen, but for all kinds of streams. For more information about streams, see Chapter 30.) Compare the number returned from the example call with the number returned when you change GACHA to TlMESROMAN. 31.5.3 DSPFONT - Changing the Font in One Window The function DSFF0NT changes the font in a single window. As an example of its use, first create a window to write in. Type: (SETQ ~.FoNT.WINnaN (CttEATE*)) in the Interlisp-D Executive window. Sweep out the window. To print something in the defau!t font, type: (PRINT `HELLO N'f'.FO*T.wIN~) in the Interlisp-D Executive window. Your window, MY. FONT.WlNDOW, will lOOk sOmething like this: HELL Figure 31.5. HELLO, printed with the default font in MY.FONT.WINOOW Now change the font in the window. Type: (DSPF0NT (FONTCREATE `HELVETICA 12 `SOLD) *T.FONT.WINDaN) in the Interlisp-D Executive window. The arguments to FONTCREATE can be chang~-'d to create any desired font. Now retype the PRINT statement, and your window will look somethinglikethis: - . HIL .q.'~;, PSPFnNT (FnNTrRE~TE `HEL";'ET1L~ 1:' BnLPt M't.FnNT.vINPnWj l:FnNTPE~1'RIpTnfl~#?.~,. 1-' 14 "4 3~~iPR[NT `HELLO MY.fnflr.l]INoniff) HELLO Flgur 31.L The font iiiMY FONT WINDow, changed Notice the font has been changedl J. 31.6 FONtt FUNfll0NS FOR USING F0Nff 31.5.4 _ Globally Changing _ Fonts _________________________ There is a library package to globally change the fonts in all the windows. To use it, first load BlG.DCOM. (See Section 8.6, Page 8.4 for how to load a file.) To change fonts in 311 windows using the package BlG.DCOM, type (KE*Fo*T ~ There are four keywords for size of fonts to specify. They are HUGE, BIG, STANDARD, and MEDIUM. For example: (*E*FKT `BIG) sets the fonts in ALL the windows to be a larger size. Note: this package changes the fonts everywhere, including the editor window and system merius It is particularly useful to change the size of the font for demos. 31.5.5 Personalizing Your Font Profile Interlisp-D keeps a list of default font specifications. This list is used to set the font in all windows where the font is not specifically set by the user (Section 31.5.3). The value of the atom FONTPROFILE is this list. (See Figure 31.7.) A FONTPROFILE is a list of font descriptions that certain system functions access when printing output. It contains specifications for big fonts (used when pretty printing a function to type the function name), small fonts (used for printing comments in the editor), and various other fonts. F0NTS 317 I FUNCTIONS FOR USING FONTS - . . . 43-FJtlTPRUF[LE l!' PF"ULTFClFlT i ,.` `,`cH4 LLT; ;`,`~LHk aj t'TEPMINk'L Sij `.`BlLPF'lNT :` (HLlETIl='n' Jo E,PP.;1 `lHL':'TIC" L=' BPP,i `llJPEPtl in' ~FF) `,`LITTLFC'NT 3 ;ttEL'?ErIC" ,3,' iHE - c 1,1p; i.'BIC-FCNT ~ llnof - hlIP"i `HE 1.=' BpP.i `.`HEL''ET .- it' epp:' `.`IrtoPEPrl - (J\EPFONT 6oLOFElNT (C.lMllENTFANT LITTLFi)r'T `.`L"M0P~"FL1flT 61 eFol~! T i.'.='r'3TEMFeNT',i `.`CLI~T'~PFUNT BC'LOF')1'lf i.' CH,,N'3'EF')HT i,'PPETT\'1?.Cit1F(ji~T Bl.lLC'FllltlT i.'FCPlTL DEf"'ULTFEitiT" ,`Fel'JT" 6cLDFclllT; t.'FCt'1T3 LITTLEFciflT; `.f1tlTJ BlCF(.'r'lT',i i.'FElNT~ S `,`HEL',"ETl;,,' 10 81P'. `lHEL'y'ETlc,, `3 61A) CfillDEPN a 81P:; t.'FilNTB 6 `HEL";'ET16~ 10 8RP',i `.`HEL'."ET1C~ L'~ BAA"' llPEPN 3 BAA] Fi)NT7 ? c"'i'.H~ 1:'' :e-"Ln~ 1:!' `.TERMItl,'L 1;''.,,!, 5a, Figure 31.7. The value of the atom FONTPROFlLE The list is in the form of an a5sociation list. The font class names, (e.g. DEFAULTFONT, Or SOLDFONT) are the keywords of the association list. When a number follows the keyword, it is the font number for that font class. The lists following the font class name or number are the font specifications, in a form that the function FONTCREATE can use. The first font specification list affer a keyword is the specification for printing to windows. The list, (GACHA 10), in the figure above is an example of the default specification for the printing to windows. The last two font specification lists are for Press and Interpress file printing, respectively. For more information, see the lnterlis~D Reference Manual, Volume 3, Chapter 27. Now, to change your default font settings, change the value of the variable FONTPROFIL. lnterlis~D has a list of profiles stored as the value of the atom FONTDEFS. Choose the profile to use, then install it as the default FONTPROFILE. Evaluate the atom FONTDEFS and notice that each profile list begins with a keyword. (5ee Figure 31.8.) This keyword corresponds to the size of the fonts included. BIG, SMALL, and STANDARD are some of :he keywords foT profiles on this list - SMALL and STANDARD appear in Figure 31.8. 31.8 F0Htt 1 FUNCTl0NS F0R USING F0NTS [[SMALL cFONTPRQFlLE (DEFALlLTFONT l (TERMINAL 8) tUaCHA 8) `TERmIHAL 8)) (8OLPFL~NT (Mi!OERtt 3 BRR) \HELY'FTIL" 6 BRR) ltl\flEfiH 8 BRfi)) 1 LITTLEFCNT ~` (hllCiERN 8 MIR) lHEL'v'ETIu'"' 8 MIR) iMCiPERN ,q, MIR)) (TIN\FONT a IhllOERN a) to,'F..H" ~) hll!nEr.H 6 iBIrFnNT j (;`,nPF~N 1P BFR) `!HE".'LETIcA lG BRF) hlrPEF;11 16 ~RP) iTE.\TFrNT r `.,6LM"~'.lC 13) `iTIhlE:'Pnn,,"N In) i.LL~.~:IC lot) !`TE\TBnLPFnNT tCL~~CIC 16 Bfifi.,' ~TIME.';RL1MAN 1P BfiR) tP:LAc.~,Ir 16 BRR] [cT~NPARP (FDNTPrnPiLE (PEF"ULTFnNT 1 Figure 31.8. Part of the value of the atom FONTDEFS To install a new profile from this list, follow the following example, but insert any keyword for BIG. To use the profile with the keyword BIG instead of the standard one, evaluate the following expressioh (FOMTSET `BIG)) Now the fonts are permanently replaced. (That is, until another profile is installed.) FONIS 319 1 r. FUNCTIoNS FOR USING F0NTS [[SMALL cFONTPROFlLE (OEFALlLTPONT i (TERMINAL 6) \*U'acHA 6) tTERmIHAL 6)) (SOLPFL~NT (M'1.OERN 6 BRR) tHELY'FTIL"' 6 BRR) Ihll!OER'H qL BRR)) i LITTLEFCNT ~" (MlcERN 6 MIR) lHEL'v'ETIu'"' 6 MIR) iMCiOERN ,q MIR)) (TIN\FONT a IhllOERN a) U,,F.,H" aj hll!nEr.N 6 iBIrFnNT J `;;1nPF~N 1P BFR) `!HE".'LETICA 16 BRF) hlrPEF;i1 16 ~fiP) !` i TE.\TFrNT r 6L"~.'lc 1'~) liTIhlE;:pnMN In) i.LL~.>:Ic In:) !`TE\TBnLPFnNT t CLA~C 1 16 Bfifi jTIME.';ROMAN 1P BfiR) \P:LAc.~.Ir 16 BRR] [<~T~NPARP (FlNTPRnPILE (PEF"ULTFnNT 1 Figure 31.8. Part of the value of the atom FONTDEFS To install a new profile from this list, follow the following example, but insert any keyword for BIG. To use the profile with the keyword BIG instead of the standard one, evaluate the following expressioh (FlTSET `BIG)) Now the fonts are permanently replaced. (That is, until another profile is installed.) FONTS 319 1 ----- Next Message ----- Date: 19 Dec 91 16:35 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.163540pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11681>; Thu, 19 Dec 1991 16:35:49 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:35:40 -0800 From: John Sybalsky -----RFC822 headers----> 12. YOUR INlT FILE Interlisp-D has a number of global variables that control the environment of your 1108 or 1186. Global variables make it easy to customize the environment to fit your needs. One way to do this is to develop an "INlT' file. This is a file that is loaded when you log on to your machine. You can use it to set variables, load files, define functions, and any other things that you want to do to make the Interlisp-D environment suit you. Your lnit fi'e could be callecl INlT, INlT.LlSP, INlT.USER, or whatever the convention is at your site. There is no default name preferred by the system, it just looks for the files listed in the variable USERGREETFILES, (see below). Check to see what the preference is at your site. Put this file in your directory. Your directory name should be the same as your login name. The INlT file is loaded by the function GREET. GREET is normally run when Interlisp-D is started. If this is not the case at your site, or you want to use the machine and Interlisp-D has already been started, you can run the function GREET yourself. If your user name was, for example, TURlNG, then you would type: (GREET `TURIK) This does a number of things, including undoing any previous greeting operation, loading the site init file, and loading your init file. Where GREET looks for your INlT file depends on the value of the variable USERGREETFiLES. The value of this variable is set when the system's SYSOUT file is made, so check its value at your site! For example, its value could be: - . - 11 NIL 3'USERGREETFlLE5 iiiFD5hl,(.LI5PFILES~ USER ;INIT.LISPJ t1rD5h','.LI5PFILE.>.~INIT.LI5PJ t',rFLoPPY',INIT.L15J i,rosh','LI5PFILES\ USER .`INIT.U5ERJ ((O.h L FILE.' .INlT.U.'ER'j i(D. . FIL SER INIT:, i(FLUPP';'j I F~ure12.1. ApcsstblevalueofUSERGREETFILES. In each place you see, "> USER >", the argument passed to GREET is substituted i:ito the path. This is your login name if you are just starting Interlisp-D. For example, the first value in the list would have the system check to see whether there was a file, [DSX]TURlNG>lNlT.LlSP. No error is generated if you do not hcve an INlT file, and none of the files in USERGREETFZLE$ are found. Y0UR NIT FILE 12 1 MAKING AN INlT FILE 12.1 Making an lnit File As described in Section 11.5, Page 11.7, each lnterlis~D program file has a global variable associated with it, whose name is formed by appending "COMS" to the end of the root filename. For any of the standard INlT file names, the variable INlTCOMS is used. To set up an init file, begin by editing this variable. First, type: (SETQ I*ITco*s `((VAnS))) Now, to edit the variable, type: (l z:sicn*s> A DEdit window wiil appear. This DEdit window is the same as the one called with the function OF, and described in Section 11.3, Page 11.4. This chapter will assume that you know how to use the structure editor, DEdit. The CONS variable is a list of lists. The first atom in each internal list specifies for the file package what types of items are in the list, and what it is to do with them. This section will deal with three types of lists: VARS, FILES, and P. Please read about others in the lnterlis~D Reference Manual, Volume ll, Chapter 17. The list that begins with "VAR5' allows you to set the values of variables. For example, one global variable is called DEditLinger. Its default value is T, and means that the Ddit window won't close affer you exit DEdit. If it is set to NIL, then the DEdit window will be closed when you exit DEdit. To set it to NIL in your INlT file, edit the VARS.list so that it looks like this: . . .1 1 1 ((`,4R.$' iOEdirLinger NlLii Her B~,are G~lete Replace `3yvitch ( ) (out Undo Find 5'rtap Rcprint Edit EditCam Break Eva Exit Figur 12J. Setting the variable DEdI tLi nge r in INITCONS. Notice that inside the vars list, there is yet another list. The firtt item in the list is the name of the variable. It is bound to the value of the second item. There are many other variables that you can set by adding them to the VARS list. Some of these variables are described in Chapter 43, and many others can be found in the lnterlis~D Reference Manual. If you want to automatically load files, that can be done in your init file also. For'exampe, if you always want to load tho Library file SPY. DCOM, you can load it by editing tho INlTC0MS variable to list the appropriate file in th list starting with FILES: 12.1 YOUR NIT flu MAKING AN INlT FILE (yARS iflEdlr.Llngr NIL') After ff1LE~ _ ~PY\) Betott Delete Replace Switch ()out Undo Find Swap Reprint Edit EddCom Breok Evol Exit FluFe 12.3. INITCOMS changed to load the file SPY.DCOM Other files can also be added by simply adding their names to this FILES list. Another list that can appear in a COMS list begins with "P". This list contains Interlisp-D expressions that are evaluated when the file is loaded. Do not put DEFINEQ expressions in this list. Define the function in the environment, and then save it on the file in the usual way (see Section 11.6, Page 11.7). One type of expression you might want to see here, however, is a F0NTCREATE function (see Section 31.2, Page 31.2). For example, of you want to use a Helvetica 12 BOLD font, and there is not a fontdescriptor for it normally in your environment, the appropriate call to FOffTCREATE should be in the `P" list. The INlTCOMS would look like this: . ((VARS (DditLingcr NIL)) After (FILES SPY) Betone (~ JFoHTcREaTE (QUOTE Delcte HEL\'ETIl',, Repace ~vyitch 1- ~juoTE _ SOL") _ .1)) (`out Undo Find Swap Reprint Edit EdiKom Break Eva Exit Figure 12.4. ltulTcOfl5editedtoincludeacalltofOffTCflEATE. The form will be evaluated when thelNlT file is loaded. To quit, exit from DEdit in the usual way. When you run the function NAKEFiLES (See Section 11.6, Page 11.7.), be sure that you are connected to the directory (see Section 8.7, Page 8.4) where the INlT file should appear. Now when GREET is run, your init file will be loaded. Y0UR INlT FILE 123 ----- Next Message ----- Date: 19 Dec 91 16:48 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.164812pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11686>; Thu, 19 Dec 1991 16:48:22 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:48:12 -0800 From: John Sybalsky -----RFC822 headers----> r 33. MASTERSCOPE Masterscope is a tool that allows you to quickly examine the structure of complex programs. As your programs enlarge, you may forget what variables are global, what functions call other functions, and so forth. Masterscope keeps track of this for you. Suppose that JVTO is the name of a file that contains many of the functions involved in a complex system and that LlNTRANS is the file containing the remaining functions. The first step is to ask Masterscope to analyze these files. These files must be loaded. All Masterscope queries and commands begin with a period followed by a space, as in AliLYZE FKS a Jvro The ANALYZE process takes a while, so the 5ystem prints a period on the screen for each function it has analyzed. (See Figure 33.1) 82&. ANALYZE FNS ON 3VTO . d.,ne D3~. aNALY?E FNS ON LIH1R'N~ . 1a,lA.l Figure 33.1. The Interlisp-D Executive Window affer anolyzing the files If you are not quite sure what functions were just analyzed, type the file's CONS variable (See Section 11.5, Page 11.7.) into the Interlisp-D Executive Window. The names of the functions stored on the file will be a part of the value of this variable. A variety of commands are now possible, all referring to individual functions within the analyzed files. Substantial variation in exact wording is permitted. Some commands are: SHoN PATHS FRDN ANY T0 ANY EDIT WERE ANY CALLS functionname EDIT WERE ANY USES variablename Wo CALLS WDN Wo CALLS functionname BY WoN IS functionname CALLED WD USES variablename AS FIELD Note that the function is being called to invoke each command. Refer to the /nterlisp-D Reference Manual for commands not listed here. Figure 33.2 shows the lnterlis~D Executive Window affer the commands wno CALLS GobbleDunp and vffo DOES JVLinScan CALL. MASTb'R'j~OPE 331 MASTEH,COPE NIL 7,.,'. 1,,.lillj O~LL;==: ,1)~8 iD.B~imp (,"c.h.~t,:r~i'TJ .J;/,j~J,J .J'.'t'r'Jet'TJ J;,'~~ 1Tij Gi>"ri'.'p~" ,,)bbl,,Ffu:h ,"jbb1~'Srririll I/dump Fiji `...,9j', "Ho clclE.. .J"i'L i `-. r, 1'"'LL (Liri.'ci-ri 1'.'Cfr.3b1A 3 -h1~J `9'A Figure 33.2. Sample Masterscope Output 33.t The SHOW DATA command and GRAPNER When the library package GRAPHER is loaded, (to load this package, type (FILESLOAD GRAPHER).) Masterscope's SHOWPATHS command is modified. The command will be changed to generate a tree structure 5howi ng how the program's functions interact instead of a tabular printout into the lnterlis~D Executive window. For example, typing: ~ PATHS FW Proce:sE. produced the display shown in Figure 33.3. .GtB.,31nT~, T L:.n;.lLl:'.Utn:P,.= ~"``-,Jt",,;r,.pj r~infr.:p it'~;r.!rPr:p r.>~>(Li;'7Uin~p..: ..~..JtL,;.l. Ofl'.JtLl;l. . `,r:L,st lET _ p-: ::J8:~inEnJ ,*.l.T.'r:. .Err.'.r Pfl!I Pr'ni.~n,.; :p~1y ~lnt~nlno Figur 33.3. SHOW PATHS Dsplay Example All the functions in the display are part of this analyzed file or a previously analyzed file. Boxed functions indicate that the function name has been duplicated in another place on the display. Selecting any function name on the display will pretty print the function in a window. (See Figure 33.4.) ij.J MAsTERscopa THE SHOW DATA COMMAND AND GRAPHER -~&lLir1wilhS hfi .~Tlo1nTwTr1no~ ~9i"~ 1n,fl~ _ ~i~or9~~~ ~~&tl1r?inith. "(s . to~~tLisi _ ~~otLirt ~~.~.~r,; ______ Pw:Llrt ~(LTT.' .` .d.~~~~; ~qLT~' f ..`PintError PTl.I Frint~nini .- upv ~inlWr,r. [LAnaPA ~propnaao'i (` cdttod: 16MAA3' L'6''d eCAn~'9SCorProp prcpneae (suR 1012C8L'k]) Figutt 33.4. Browser Printout Example. Selecting it again with the leff mOuse button will produce a dexription of the function's role in the overall system (See Figure 33.4) ~r.;l.1,'?U1n;f'.: t1BfginTW:l.riny~ ________ ,p'~~ 1"~:t,-'.Pr'~ . ~c.3v.Liiniih~t Proc&;:Eli<. _________ .. . Por;~r' ~:l=T7o. nf&r.r ~T=i Prir,t.~nir, PntWr,1fl4 GerryProp i,, - L-Qll:! inetAnC .rorPrtih 1nNl,~ lrireFiJ.,rning Din" `pe~b'c8cJ1nT;.,='tr1n0. i=~rML, 1r'"$T=~',Fr=Ce'EtlD u~' f.-cc TO cocl FlUrf 33.5. Browser Description Example. 33.2 Databasefns: Automatic Construction and Upkeep of a Masterscope Database DataBaseFns is a separate library package that allows you to automatically construct and maintain Masterscope databases of your files The package is contained in the DATABASEFNS.DCOM file. When DATABASEFNS.DCOM is loaded, a Masterscope database will be automatically maintained for every file whose.DATABASE MAST'RS~OPE 333 DATABASEFNS: _ AUTOMATIC CONSTRUCTION AND _ UPKEEP OF A MASTERSCOPE _ DATABASE property has the value YES. If this property's value is not set, you will be asked when you save the file "Do you want a Masterscope Database for this file?". Saying YES enables the DabaBaseFns to construct a Masterscope database of the file you are saving. Each time the function *AKEFILE is used on a file whose DATABASE property has a value YES, Masterscope will analyze your file and update its own database. Each file's masterscop database is kept in a separate file whose name has the form FILE. DATABASE. Whenever you load a file with a YES value for its DATABASE property, you will be asked whether you also want the database file loaded. 33.4 N~TERSCOPE 1 ----- Next Message ----- Date: 19 Dec 91 16:50 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.165058pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11688>; Thu, 19 Dec 1991 16:51:02 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:50:58 -0800 From: John Sybalsky -----RFC822 headers----> r 34.WHERE DOES ALL THE TIME GO? sPY SPY is an Interlisp-D library package that shows you where you spend your time when you run your system. It is easy to learn, and very useful when trying to make programs run faster. 34.1 Now to use Spy with the SPY Window The function SPY. BUTTON brings up a small window which you will be prompted to position. Using the mouse buttons in this window controls the action of the SPY program. When you are not using SPY, the window appears as in Figure 34.1. Figure 34.1. The SPY window when SPY 15 not being rnsed. Ts use SPY, click either the leh or middle mouse button with the mouse cursor in the SPY window. The window will appear as in Figure 34.2, and means that SPY is accumulating data about your program. Figure 34.2. The SPY wir.oow when SPY is being used To turn off SPY affer the program has run, again click a mouse button in the SPY window. The eye closes, and you are asked to position another window. This window contains SPY's results. An ex~nr'ple of result window is shown in Figure 34.3. WHERE D0ES ALL THE TIME G0' SPY 341 1 HOW TO USE SPY WITH THE SPY WINDOW - TIrE. l _ `3~~"H[P _ J~. _ [WIT. _ IN~&F.-1!~ 17 _ `..TIrtP. PplJl'.E,-'-'.. - a ~i~~~~pT~&- . REPE,,TE&L'.EV~rn EJ~rn 1 EF.UFE 7 _ ---RR.. h.JPillU~. _ fPlLE- -. 4 f, IPP,9R.h `F..n 4 Figure 34.3. The window produced afler running $PY This window i5 scrollable in two directions horizontally, and vertically. This is useful, since the whole tree does not fit in the Winoovv. If a part that you want to see is not shown, then you can scroll the window to show the part you want to see. 34.2 How to use SPY from the Lisp Top Level SPY can also be run while a specific function or system is being used. To do this, type the function WITH. SPY: (VITN.sPY form) The expression used for form should be the call to begin running the function or system that SPY is to watch. If you watch the SPY window, the eye will blink! To see your results, run the function SPY. TREE. To do this, type: (SPY.TREE) The results of the last running of SPY will be displayed. If you do this, and 5PY.TREE returns (no SPY saiples have been gathQ red), your function ran too fast for SPY to follow. 34.3 Interpreting SPY's Results Each node in the tree is a box that contains, first, the percentage of time spent running that particular function, and second, the function name. There are two modes that can be used to display this tree. The default mode is cumulative. In this mode, each percentage is the amount of time that function spent on top of the stack, plus the amount of time spent by the functions it calls. The second mode is individual. To chango the mode to individual, point to the title bar of the window, and press the middle `n.ouse button. Choose Individual from the menu that appears. In this mode, the percentage shown is the amount of time th3t the function spent on the top of the stack. 34.2 WHERE 00E5 ALL TN5 ylMff G0? spY 1 lNTERPREn~ SPY'S RESuLtt ----- Next Message ----- Date: 19 Dec 91 16:40 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.164041pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11685>; Thu, 19 Dec 1991 16:40:51 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:40:41 -0800 From: John Sybalsky -----RFC822 headers----> 32. THE INSPECTOR The Inspector is a window-oriented tool designed to examine data structures. Because Interlisp-D is such a powerful programming environment, many types of data structures would be difficult to see in any other way. 32.1 Calling the Inspector Take as an example an object defined through a sequence of pointers (i.e. a bitmap on the property list of a window on the property list of an atom inaprogram.) To inspect an object named NAME, type: (IKSPECT `~) If NAME has many possible interpretations, an option menu will appear. For example, in Interlisp-D, a litatom can refer to both an atom and a function. For example, if NAME was a record, had a function definition, and had properties on its property list, then the menu would appear as in Figure 32.1. PRG'PS FklS FIELD;=~ Figure 32.1. Option Window For Inspection of NAME If NAME were a list, then the option menu shown in Figure 32.2 would appear. The options include: calling the display editor on the list; calling the ~ editor (the "Typing Shortcuts",Chapter 6); seeing the list's elements in a display window. If you choose this option, each element in the list will appear in the right column of the Inspector window. The left column of the Inspector window will be made up of numbers. (See Figure 32.3.) inspecting the list as a record type (this last option would produce a menu of known record types). If you choose a record type, the items in the list will appear in the right column of the Inspector window. The left column of the Inspector window wili be made up of the field names of the record. P~rI~.lErtr Tr:rE'1ir. Inip~rr A~are'iJrd Figure 32.2. Option Window For Inspection of Lirt THE INSPECTOR 321 USING THE INSPECTOR 32.2 Using the Inspector If you choose to display your data structure in an edit window, simply edit the structure and exit in the normal manner when done. If you choose to display the data structure in an inspect window, then follow these instructions: To select an item, point the mouse cursor at it and press the left mouse button. Items in the right column of an Inspector window can themselves be inspected. To do this, choose the item, and press the center mouse button. Items in the right column of an Inspector window can be changed. To do this, choose the corresponding item in the left column, and press the center mouse button. You will be prompted for the new value, and the item will be changed. The sequence of steps is shown in Figure 32.3. . 1 INPEu'T-ME-TOOl 1ie-,PErT-hl-TQi32 a IN.u'FErT-11E-TQO3 The item in the lefl column is selected, and the middle mouse button pressed. Select the SET option from the menu that pops up. The ev..pre:1Un re3J will be E `/~LuQred. cHaflGE&-'.:~"LlJ4 1 ]N.=~Pfi=.T-rrtE-Tc~i 2 1H".~pEcT-ttE-TI:i12 a Il You will then be prompted for the new value. Type it in. 6 1 [flPEQT-ME-TOOi 2 [Y.~PECT-1'1E-TOfl2 a CH~Pl,'ED-'.;~LUE The item in the right column is updated to the value of what you typed in. Figure 32.3. The sequence of steps involved in changing a value in the right column of an Inspector window. 32.3 Inspector Example This example will use ideas discussed in 5ection 37.1. An example, ANlMALGItAPH, is created in that section. You do not need to know the details of how it was created, but the structure will be examined in this chapter. If you type (IKSPECT lI~.6liPN) and then choos th Inspect option from th menu, a display appars as shown in Figure 32.4. ANlMAL.G~PH is being J 33.J TkElNSPECT~ lff5PE~0R EXAMPLE inspected as a list. Note the numbers in the left column of the inspectorwindow. 1 i't'fI.~H ~ NIL NIL --j `BIRD .~ NIL NIL T .i, NIL 4 NIL 5 NIL 6 NIL ? NIL ,q NIL 9. NIL 1A. NIL 11 NIL 1~" NIL Figure 32.4. Inspector Window For ANIMAL GRAPH, inspected as a list. If you choose the "As A Record" option, and choose "GRAPH" from the menu that appears, the inspector window looks like Figure 32.5. Note the fieldnames in the leff column of the inspectorwindow. UP"PH.CH"NCEL"eELFfl NIL CR"PH. INVEP.TL~BELFN NIL CR"PH. IFlvEp.TBCiROERFN NIL CR"PH.FONTcH"NoEFN NIL bRaPH.&ELETELINKFN NIL CRaPH~D&LINkFN NIL URAPH.cLETENC~UEFN HIL bRAPH. .oo&NUGEFN NIL oRoPH.Mo$ENUoEFN NIL DIREcTEDfLG NIL o"IDE~FLo T C.RuPHNi:DE.~ (i.'fl:H & NIL NIL --! `BIPP & NIL GIL Figure 32.5. Inspector Window For ANlMAL.GRAPH, inspected as an instance of a "GRAPH" record. The remaining examples will use ANlMAL.GRAPH inspected as a list. When the first item in the Inspector window is chosen with the leff mouse button, the Inspector window looks like Figure 32.6. 1 ` _ 1 T 3 NIL 4 NIL 5 NIL r~ NIL NIL NIL 9 NIL 1H NIL 11 NIL 1- NIL Figure 32.6. Inspector Window For ANlMAL.GRAPH With First Element Selected When you use the middle mouse button to inspect the seiected list element, the display looks like Figure 32.7. THE INSPECTOR 32 j INSPECTOR EXAMPLE 1 1 T 3 NIL = 4 PIlL 5 NIL 1 iFIfl 1.19:' 44) PIlL NIL HIL --! `BIRD (.192 29) NIL PIlL NIL -- b' NIL 3 (CAT (.is ,J NIL NIL NIL PIlL j. (&UU i"1;39 7) PIlL PJIL NIL NIL ~ ((rh,,"trtffi,,"L GJU c~T) 199 14j fiL J.IlL 9 PIlL 6 ((,,"PIIMAL ; BIRD FI.Jh) .`..~ C9. IlL 19 PIlL 11 NIL 1'.' NIL Figuro 32.7. Inspertor Window For ANlMAL.GRAPH and For the First Element of ANIMALGRAPH How you can see that 5iX items make up the list, and you can further choose to inspect one of these items. Notice that this is also inspected as a list. As usual, it could also have been inspected as a record. Select item 5 - MAMMAL DOG CAT - with the leff mouse button. Press the middle mouse button. Choose "Inspect" to inspect your choice as a list. The Inspector now displays the values of the structure that makes up MAMMAL DOG CAT. (See Figure 32.8.) 1 (h1~~MMkL GJ, lIT) 2 ilvjy' lJ) NIL 4 NIL 5 NIL 6 45 7 is o i',Do': ClIT',i !) (c"'NlMlIL .~ BlRP FI."3Hj iR, (Fi=1NTCLn"',~r'j7R!i?e..764 ii hllIPtMlIL 12 NIL Figure 32.8. Inspector Window for Element S From Figure 32.7 That Begins ((MAMMAL DOG CAT). 32.A THE INSPECTOR ----- Next Message ----- Date: 19 Dec 91 16:54 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.165444pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11690>; Thu, 19 Dec 1991 16:54:53 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:54:44 -0800 From: John Sybalsky -----RFC822 headers----> . . . . . . . r 34.WMERE DOES ALL THE TiME GO? sPY SPY is an InterlispD library package that shows you where you spend your time when you run your system. It is easy to learn, and very useful when trying to make programs run faster. 34.1 How to use Spy with the SPY Window The function SPY. BUTTON brings up a small window which you will be prompted to position. Using the mouse buttons in this window controls the action of the SPY program. When you are not using SPY, the window appears as in Figure 34.1. Figure 34.1. The SPY window when SPY is not being used. Ts use SPY, click either the Iefl or middle mouse button with the mouse cursor in the SPY window. The window will appear as in Figure 34.2, and means that SPY is accumulating data about your program. sPY Figure 34.2. The SPY wirdow when SPY is being used To turn off SPY atter the program has run, again click a mouse button in the SPY window. The eye closes, and you are asked to position another window. This window contains SPY's results. An example of result window is shown in Figure 34.3. WHERE D0ES ALL THE TIME Go' SPY 341 l How TO USE SPY `KlTH THE SPY WINDOW rp.i)rE? ~L,:,,.*~. IrtP.rpji=.E;'';. . U TI~REhpYfi&. J!l!i .EV~fi)f. `:. 1 FEPEA~OL.EU~rn -`1 EJ~J .l ER.GURE 7 _ .BN..F i;f;i.iU~. _ Fpi'cf:11 .. j IPP,fl~.hJri.ii.iN 4 Fiqure 34.3. The window produced affer running SPY Tljis window i5 scrollable in two directions, hOrizontaily, and vertically. This is useful, since the whole tree does not fit in the wiroow. If a part that you want to see is not shown, then you can scroll the window to show the part you want to see. 34.2 How to use SPY from the Lisp Top Level SPY can also be run while a specific function or system is being used. To do this, type the function VITH SPY: (WITH.sPY form) The expression used for form should be the call to begin running the function or system that SPY is to watch. If you watch the SPY window, the eye will blink! To see your results, run the function SPY. TREE. To do this, type: (SPY.TREE) The results of the last running of SPY will be displayed. If you do this, and SPY.TREE returns (no SPY saiples have been gathered), your function ran too fast for SPY to follow. 34.3 Interpreting SPY's Results Each node in the tree is a box that contains, first, the percentage of time spent running that particular function, and second, the function name. There are two modes that can be used to display this tree. The default mode is cumulative. In this mode, each percentage is the amount of time that function spent on top of the stack, plus the amount of time spent by the functions it calls. The second mode is individual. To chango the mode to individual, point to the titlo bar of the window, and press the middle .~ouse button. Choose Individual from the menu that appears. In this mode, the percentage shown is the amount of time that the function spent on the top of the stack. 34.2 WHERE nQE$ ALL THE TIME G0? SPY 1 1NTERPREfl~ SPY'S RESULTS To look fit G iingle branch of the tree, point with the mouse curtor at one of the nodes of the tree, and press the right mouse hutton. From the menu that appeatt, choose the option SubTree. Another SPY window will appear, with just this branch of the tree in it. Another way to focus within the tree is to remove branches from tlie tree. To do this, point to the node at the top of the branch you would like to delete. Press the middle mouse button, and choose Delete from the menu that appears. There are also different amounts of "merging" of functions that can be done in the window. A function can be called by another function more than once. The amount of merging determines where the subfunction, and the functions that it calls, appear in the tree, and how offen. (For a detailed explanation of merging, see the Lisp Library Packages Manual.) WHERE DOES ALL THE TIME GO' sPY 343 1 ----- Next Message ----- Date: 19 Dec 91 16:59 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.165929pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11691>; Thu, 19 Dec 1991 16:59:33 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 16:59:29 -0800 From: John Sybalsky -----RFC822 headers----> tilL.. 36. FREE MENUS Free Menu is a library package that is even more flexible than the regular menu package. It allows you to create menus with different types of items in them, and will format them as you would like. Free menus are pai~icularly useful when you want a "fill in the form" type interaction with the user. Each menu item is described with a list of properties and values. The following example will give you an idea of the structure of the description list, and some of your options. The most commonly used properties, aiid each type of menu item will be described in Section 36.2 and Section 36.3. 36.1 An Example Free Menu Free menus can be created and formatted automatically! It is done with the function FN. FORNATNENU This function takes one argument, a description of the menu. The description is a list of lists; each internal list describes of one row of the free menu. A free menu row can have more than one item in it, so there are really lists of lists of lists! It really isn't hard, though, as you can see from the following example: (SETQ Ex~1e*anu (F*.FORliT*EMu `(( TYPE TITLE LABEL TitlesDonothing) TYPE 3STATE LABEL Ex~1e3State)) ( TYPE EDITSTART LABEL PressToStartEd;ting ITEMS (EDITE*)) (TYPE EDIT ID EDITEN LABEL )) (*IKDDMPRDPS TITLE Ex~1e Dris Nothing)))) The first row has 2 items in it; one is a TITLE, and the second is a 35TATE item. The second row also has 2 items. The second, the EDIT item, is invisible, because its label is an empty string. The caret will appear for editing, however, if the EDlTSTART item is chosen. Windowprops can appear as part of the description of the menu, because a menu is, affer all, just a special window. You can specify not only the title with WINDOWPROPS, but also the position of the free menu, using the "Ieff" and "bottom" properties, and !he width of the border in pixels, with the "border" property. Evaluating this expression will return a window. You can see the menu by using the function OPENW. The following example illustrates this: FREE MENUS 361 1 AN EXAMPLE FREE MENU 6i,'~T~ E;mD.1c1d~nij .;F(,7,fJp,[4,,$~]~fJ.J\J ,, . T' Gf TITLE LBEL T ir1~,flN~rr T .T"rE =-`T."TE L"bEL E:.Jm"1c5tJcs'!'. . `FE =,IT:..THF:T LEL =r~'=Tu'"r~t'tEditing lTEfl= cOlTEN' T"E `IT ID EDITEm L~8EL , "`..ililci=,..''=cipT=.. TITLE ` ;,.,1";c Din' 1'luthlnj.'? .TT9'i i)pf)liff molMertiJ'i f.hi1ltlDu',V'r#' j64 Figure 36.1. An example free menu The next example shows you what the menu looks like affer the EDlTSTART item, PressToStartEditing, has been chosen. T,r f~"=.Oi=i1'1,=irhin3 E':,mp1~,='.=r.,r~ P~'~='"'TJT..,rTEJ1r1r1.j A Figure 36.2. Free menu affer the EDlTSTART item has been chosen The following example shows the menu with the 3STATE item in its T state, with the item highlighted (In the previous bitmaps, it was in its neutral state.) . c l 1 1 .1-=':.OiJ-tljrhini=! ,:`T'='Ot..;rrE'liriiJ, FigUre 36.3. Free menu with the 35TATE .tem in its T state Finally, Figure 36.4 shows the 35TATE item in its NIL state, with a diagonal line through the item T1r le.".OcNorhing E..::r'~ _ 1 _ = _ `.`..,i.~ Rrn. ;``, T,St.arrEdir,iri, . . . . . Figure 36.& Free menu with the 3STATE item in its NIL state If you would like to specify the layout yourself, you can do that too. See the Lisp Library Packages Manual for more information. 36.2 Parts of a Free Menu Item There are 8 different types of items that you can use in a free menu. No matter what type, the menu item is easily described by a list of properties, and values. Somo of the properties you will use most often are: 36.2 FREE MENUS 1 PARTS OF A FREE MENU ITEM LABEL Required for every type of menu item. It is the atom, string, or bitmap that appears as a menu selection. TYPE One of eight types of menu items. Each of these are described below. MESSAGE The message that will appear in the prompt window if a mouse button is held down over the item. ID An item's unique identifier. An ID is needed for certain types of menu items. ITEMS Used to list a series of choices for an NCHOOSE item, and to list the ID's of the editable items for an EDITSTART item. SELECTEDFN The name of the function to be called if the item is chosen 36.3 Types of Free Menu Items Each type of menu item is described in the following list, including an example description list for each one. Momentary This is the familiar sort of menu item. When it is selected, the function stored with it is called. A description for the function that creates and formats the menu looks like this: (TYPE WEKTARY LABEL Blink-K-Rin9 *ES~6E Blinks the screen and rings bells sLEcTEDFK RIKBELLS) TOGGL This menu item has two states, T and NIL. The default state is NIL, but choosing the item toggles its state. The following is an example description list, without code for the SELECTEDFN function, for this type of item: (TYPE T~6LE LABEL hi~isab1e sELEcTEDFN changeIl*State) 3STATE This type of menu item has 3 states, NUIETRAL, T, AND NIL Neutral is the default state. T is shown by highlighting the item, and NIL is shown with diagonal lines. The following is an example description list, without code for the SELECTEDFN function, for this type of item: (TYPE 3STATE LABEL correctprograAllofflospelling sELEcTEDFli ToggleSpellingcorrection) TITLE This menu item appears on the menu as dummy text. It does nothing when chosen. An example of its description: (TYPE TITLE LABEL Choices:") NWAY A group of items, nnly one of which can be chosen at a time. The items in the NWAY group should all have an ID field, and the ID's should be the same. For exan1Fle, to set up a menu that would allow the user to chose betvveei Helvetica, Gacha, Modern, and Classic fonts, the descriptions might look like this (Once again, without the code for the SELECTEDFN): (TYPE lAY ID F~Tc~Ic' LABEL blvetica sELEcTEDFN changeFont) FREE MENUS 36) I TYPES OF FREE MENU ITEMS (TYPE NVAY ID FOQTCKICE LABEL Gacha SELECTEDF (TYPE lAY ID F05TliCriC0ha,~n8efont) LABEL Modern SELECTEDFli Chan2eFont) (TYPE KAY ID fONTCHOIC LABEL Classic SELECTEDFN Changefont) NCHOOSE This type of menu item is like NWAY except that the choices are given to the user in a submenu. The list to specify an NCHOOSE menu item that is analogous to the NWAY item above might look like this: (TYPE MC~SF LABEL FontChoices ITEMS Helvotica Gacha Modern Classic) SELECT DfK Changefont) EDlTSTART When this type of menu itein is chosen, it activates another type of item, an EDIT item. The EDIT item or items associated with an EDlTSTART item have their lD's listed on the EDlT5TART's ITEMS property. An example description list is: (TYPE EDITSTART LABEL Function to add? ITEMS (Fn)) EDIT This type of menu item can actually be edited by you. It is often associated with an EDlT5TART item (see above), but the caret that prompts for input will also appear if the item itself is chosen. An EDIT item follows the same editing conventions as editing in Interlisp-D Executive window: Add Characters by typing them at the caret. Move the caret by pointing the mouse at the new position, and clicking the leff button. Delete Characters from the caret to the mouse by pressing the right button of the mouse. Delete a character behind the caret by pressing the back space key. Stop editing by typing a carriage return, a Control-X, or by choosing another item from the menu. An example description list for this type of item is: (TYPE EDIT ID Fn LABEL ) 36.4 FREENEMus 1 ----- Next Message ----- Date: 19 Dec 91 17:05 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.170545pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11694>; Thu, 19 Dec 1991 17:05:54 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 17:05:45 -0800 From: John Sybalsky -----RFC822 headers----> 37. THEGRAPHER 37.1 Say it with Graphs Grapher is a collection of functions for creating and displaying graphs, networks of nodes and links. Grapher also allows you to associate program behavior with mouse selection of graph nodes. To load this package, type (FILESL~ GliPHER) Figure 37.1 shows a simple graph. i `iLk w.F."PH `N M'L.l;R"PH `NlM'L r;P"Pff' ,(.h,,lINGUY!:w',1513.y1 14' -FIH . NIM"L, BIRO Figure 37.1. A Simple Graph In Figure 37.1 there are six nodes (ANIMAL, MAMMAL, DOG, LAT, FISH, and BIRD) connected by five links. A GRAPH is a record containing several fields. Perhaps the most important field is GRAPHNODS - which is itszlf a list of GRAPHNODE records. Figure 37.2 illustrates these data structures The window on top contains the fields from the simple graph. The window on the bottoms an inspection of the node, DOG. THEGRAPHER 371 SAY lTWlTH GRAPHS i9'1, I ET `NI1'1,,L.CR~PH'.i Ilvl,l = `-#"=9,1j~'j','3 GPPH.cr"ilLEL,,'BELFN `IL 1'R"pH. Ili'!ERTLBELFN 1.lIL H. Ifl.ERTBDPDEPFN tilL H.FGtTi'.HNoEFPl 1lIL , rP'PH,t.lL/ElllDEFbl IL . OIRECTECFLi, (ilL rp..'Pflbll) ~ I.F = , tilL III `.B.IP.D NIL ff IL . NOOEBOPOER `ilL tiODEL,,'BEL loo , , `tODEFONT ~`FOIiT ` . .OtlffO&EO- It'lL - . t,iODE'.~,lOTH `.4, , IiUOEL6EL.'-H~OE lIL , NODELfiELBlTIrt,iP IIL , I,iUDEPUITlClI.l in NODE ID 300 Figure 37.2. Inspefling a Graph and a Node The GRAPHNODE data structure i~ described by its text (NODElD), what goes into it (FROMNODES), what leaves it (TONODES), and other fields that specify its looks. The basic model of graph building is to create a bunch of nodes, then layout the nodes into a graph, and finally display the resultant graph. This can be done in a number of ways. One is to use the function NODECREATE to create the nodes, LAYOUTGRAPH to lay out the nodes, and SHOWGRAPff to display the graph. The primer shows you two simpler ways, but please see the Library Packages Manual for more information about these other functions. The primer's first method is to use SHOWGRAPH to display a graph with no nodes or links, then interactively add them. The second is to use the function LAYOUT5EXPR, which does the appropriate NODECREATES and a LAYOUTGRAPH, with a list. The function SHQWGRAPH displays graphs and allows you to edit them. The syntax of SHOWGffAPH is (~liPH graph window lefibuttonfn middlebuttonfn topjustiffflg alloweditflg copybuttoneventfn) Obviously the graph structure is very complex. Here's the easiest way to create a graph. ~.6liPN III) lS5~liPN P.6liPH 5Y Sraph KIL NIL NIL T) Figur 37.3. My Graph 37.2 THEGRAPHER .J SAY IT WITH GRAPHS You will be prompted to create a small window as in Figure Figure 37.3. This graph has the title My Graph. Hold down the right mouse button in the wiridow. A menu of graph editing operations will appear as in Figure 37.4. D;Ier~ Link &=h~~n9e ib P.I ljbel g,nill~.r l&'bel l~.ro~.r Dir~..ct~.i1 SIdPg ~ BoidP.r `h;~d" `Tr"P Figure 37.4. A Menu of Graph Editing Operations Here's how to use this menu to: Add a Node Start by selecting Add Node. Grapher will prompt you for the name of the node (See Figure 37.5.) and then its position. Figure 37.5. Grapher prompts for the name of the node to add affer Add Node is chosen from the graph editing menu. Position the node by moving the mouse cursor to the desired location and clicking a mouse button. Figure 37.6 ,hows the graph with two nodes added using this menu. ~irr-ri~tle s~~'ondnod~ Figure 37.6. Two nodes added to MY GRAPH using the graph ed it.q.g menu AddaLink Select Add Link from the graph editing menu The Prompt window will prompt you to select the two nodes to be linked. (See Figure 37.7.) Do this, and the link will be added. o . first-node ,.ccond-node Figure 37.7. The Prompt window will prompt you to select the two nodes to link. THEGRAPHER 37.3 SAY IT WITH GRAPHS DeleteALink Select Delete Link from the graph editing menu. ThePrompt window will prompt you to select the two nodes that should no longer be linked. (See Figure 37.8.) Do this, and the iink will be deleted. r _ `rr-n>';1~ ;`~"or,'j-nod; FigUre 37.8. The Prompt window will prompt you to Seje~~ `.1 ryo nodes that shouid no longer be linked. Delete A Node Select Delete Node from the graph editing menu. The Prompt window will prompt you to select the node to be aeleted. (See Figure 37.9.) Do this, and the node will be deletea. firs. r-nod" ,L'0fl'S1-fl0d~ Figure 37.9. The prompt to delete a node Moving a Node Select "Delete Node" from the graph editng menu. Choose a node pointing to the it with the mouse cursor, and pressing and holding the leff mouse button. When you move the mouse cursor, the node will be dragged along. When the node is at the new position, release the mouse button to deposit the node. The commands in this menu are easy to learn. Experiment with them! 37.2 Making a Graph from a List Typically, a graph is used to display one of your program's data structures. Here is how that is done. LATOUTSEXPR takes a list and returns a GRAPH record. The syntax of the function is (UYWTSEXPR sexpr format ~xing font motberd penonald fam;lyd) For example: (u~T10Q AKIliL.TREE `(MIlL (l'~ ~ CAT) BIli FISH)) AaIliL.6liN 37.4 THEGRApHER MAKING A GRAPH FR0M A LIST b~YouTSE*PR AKIliL .TREE HoRIZ0NTALi~) (Eli N AHIliL.GliPN Nj Grpb NIL KIL a T) This is how Figure 37.1 was produced. 37.3 Incorporating Grapher into Your Program The Grapher is designed to be built into other programs. It can call functions when, for example, a mouse button is clicked on a node. The function SHOWGRAPff does this: (~liPH graph window leflbuttonfn middlebuttonfn topjusti~Rg alloweditflg copybuttoneventfn) For example, the third argument to SHOWGRAPH, leftbuttonfn, is a function that is called when the lefl mouse buttoii 15 pressed in the graph window. Try this: (DEFIKQ (~.LEfT.BUTT0N.FUNCTI0N (TNE.6liPHNooE THE.GliPH.wIN~) (INSPECT TNE.6liPNNooE))) (~liPH FlILY.61PN Inspoct&bla fiily (F~TIK N".LEFT.BUTTa.FuNCTIo*) liIL NIL T) In the example above, liT.LEFT.BUTTON. FUNCTION simply calls the inspector. Note that the function should be written assuming it will be passed a graphnode and the window that holds the graph. Try adding a function of your own. 37.4 More of Grapher Some other Library packages make use of the Grapher. (Note: Grapher needs to be loaded with the packages to use these functions.) NASTERSCOPE: The Browser package modifies the Masterscope command, . SHOW PATHS, so that its output is displayed as a graph (using Grapher) instead of simply printed. GRAPHZOOM: allows a graph to be redisplayed larger or smaller automatically. THEGRAPHER 375 ----- Next Message ----- Date: 19 Dec 91 17:11 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.171147pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11697>; Thu, 19 Dec 1991 17:11:55 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 17:11:47 -0800 From: John Sybalsky -----RFC822 headers----> 41. RESOURCE MANAGEMENT 41.1 Naming Variables and Records You will find times when one environment simultaneously hosts a number of different programs. Running a demo of several programs, or reloading the entire Interlisp-D environment from floppies when it contains several different programs, are two examples that could, if you aren't careful, provide a few problems. Here are a few tips on how to prevent problems: If you change the value of a system variable, ffENUHELDVAIT for example, or connect to a directory other than (DsK), write a function to reset the variable or directory to its original value. Run this function when you are finished working. This is especially important if you change any of the system menus. Don't redefine Interlisp-D functions or CLl5P words. Remember, if you reset an atom's value or function definition at the top level (in the Interlisp-D Executive Window), the message (Some.Crucial.Function. Or. Variable redefined), appears. If this is not what you wanted, type UNDO immediately! If, however, you reset the value or function definition of an atom inside your program, a warning message will not be printed. Make the atom names in your programs as unique as possible. To do this without filling your program with unreadable names that noone, including you, can remember, prefix your variable names with the initials of your program. Even then, check to see that they are not already being used with the function BOUNDP. For example, type: (~P B&ckgroundhnu) This atom is bound to the menu that appears when you press the leff mouse button when the mouse cursor is not in any window. BOUKDP returns T. BOUNDP returns NIL if its argument does not currently have a value. Make your function names as unique as possible. Once again, prefixing function names with the initials of your program can be helpful in making them unique, but even so, check to see that they are not already being used. GETD is the Interlisp-D function that returns the function definition of an atom, if it has one. If an atom has no function definition, GETO returns NIL. For example, type: (GEffl `CAR) RESOURCE MANAGEMENT 411 NAMING VARIABLES AND RECORDS A non-NIL value i~ returned. The atom CAR already has a function definition. Use complete record field names in record FETCHes and REPLACEs when your code is not compiled. A Complete record field name is a list Consisting of the record declaration name and the field name. Consider the following example: REC0RD N~ FIRST LAST)) SETQ Nyfflrn create Nl FIRST `John LAST `~ith)) FETCH (~ FIRST) OF Mylrn) Avoid reusing names that are field names of Interlisp-D System records. A few examples of system records follow. Do not reuse these names. RECORD RE6IOl (LEFT RoTTOl WIDTH NEIGHT)) RECORD POSITIK xC00RD RECORD Ili6E~ BITliYCP00RD))) When you select a record name and field names for a new record, check to see whether those names have already been used. Call the function RECLOOK, with your record name as an argument, in the lnterlis~D Executive Window. (See Figure 41.1.) If your record name is already a record, the record definition will be returned; otherwise the function will return NIL. - . 11 4..O:(fi.ECL)OY~ FB;'~ITiON) !`P\ECCPO PO~1TI)N [T\L~'.lp:E)F;,P "So'1P~D! (8Nfl (LlSTP O~TUM\ (NUl18P~P !`,C4l'~ D~TUfi1:)) (i\"('~'Th1\\j (NUMBER (CDR OurOIl] 5ik(P~ECLOUff N~,~P~~) NIL 5~'~E Figuv 41.1. RECLOOK returns tbe record definition If ts argument is already declared as a record, NIL otne~ise. Call the function FIELDLOOK with your new field name in the InterlispD Executive Window. (See Figure 41 2.) If your field name is already a field name in another record, the record definition will be returned; otherwise the function will return NIL. 412 RESOURCE MANAGEMENT 1 NAMING VARIABLES AND RECORDS , 1 ~.4'+(fIELOLOOft Y96COORD) ((RECORD pO'e.ITION (:~`COORO \COORD) [T'Y'PE" (~NP (LIvt~TP O4TUbl! (NUblBERP (CAR D,iTUhl\ I:.NUMBERP ("OR D~TUftt] (S\'~~.TEb1)\) 55~(FIELPLOPh .ip~;\ NIL 58- Figure 41.2. FIELDLOOK returns the record definition if ItS argument Is already the field ofarecord.NILothe~ise 41.2 Some Space and Time Considerations In order for your program to run at maximum speed, you must efficiently use the space available on the system. The following section points out areas that you may not know are wasting valuable space, and tips on how to prevent this waste. Often programs are written so that new data structures are created each time the program is run. This is wasteful. Write your programs so that they only create new variables and other data structures conditionally. If a structure has already been created, use it instead of creating a new one. Some time and space can be saved by changing your RECORD and TYPERECORD declarations to DATATYPE. DATATYPE is used the same way as the functions RECORD and TYPERECORD. (See Chapter 24.) In addition, the same FETCH and REPLACE commands can be used with the data structure DATATYPE creates. The difference is that the data structure DATATYPE creates cannot be treated as a list the way RECORDs and TYPEREC0RDs can. 41.2.1 Global Variables Once defined, global variables remain until Interlisp-D is reloaded. Avoid using global variables if at all possible! One specific problem arises when programs use the function 6ENSYff. In program development, many atoms are created that may no longer be useful. Hints: Use (DELDEF atomname `PKP) to delete property lists, and (DELDEF atomname `vARS) RESOURCE MANAGEMENT 413 ----- Next Message ----- Date: 19 Dec 91 17:15 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.171603pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11560>; Thu, 19 Dec 1991 17:16:06 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 17:16:03 -0800 From: John Sybalsky -----RFC822 headers----> SOME SPACE AND TIME CONSIDERATIONS to have the atom act like it is not defined. These not only remove the definition from memory, but also change the appropriate f 11 eCOffS that the deleted object was associated with so that the file package will not attempt to save the object (function, variable, record definition, and so forth) the next time the file is made. Just doing something like (SETQ (arg at~nm) `~IE) looks like it will have the same effect as the second DELDEF above, but the SETQ doesn't update the file package. If you are generating atom names with GENSYN, try to keep a list of the atom names that are no longer needed. Reuse these atom names, before generating new ones. There is a (fairly large) maximum to the number of atoms you can have, but things slow down considerably when you create lots of atoms. When possible, use a data structure such as a list or an array, instead of many individual atoms. 5uch a structure has only one pointer to it. Once this pointer is removed, the whole Structure will be garbage collected and space reclaimed. 41.2.2 Circular Lists If your program is creating circular lists, a lot of space may be wasted. (Note that many cross linked data structures end up having circularities.) Hints when using circular lists: Write a function to remove pointers that make lists circular when you are through with the circular list. If you are working with circular lists of windows, bind your main window to a unique global variable. Write window creation conditionally so that if the binding of that variable is already a window, use it, and only create a new window if that variable 15 unbound or NIL. Here is an example that illustrates the problem. When several auxilIary windows are built, pointers to these windows are usually kept on the main window's property list. Each auxilIary window also typically keeps a pointer to the main window on its property list If the top level function creates windows rather than reusing existing ones, there will be many lists of useless windows cluttering the work space. Or, if such a main window is closed and will not be used again, you will have to break the links by deleting the relevant properties from both the main window and all of the auxiliary windows first. This is usually done by putting a special CLOSEFli on the main window and all of its auxiliary windows. 41.2.3 When You Run Out Of Space Typically, if you generato a lot of structure! that won't get garbage collected, you will eventually run out of space. The important part ii being aNe to track down those structures and 4I.4 REsouRcE MANAGEMENT I SOME SPACE AND TIME CONSIDERATIONS the code that generates them in order tO become more space efficient. The Lisp Library Package GCHAX.DCOM can be used to track down pointers to data structures. The basic idea is that GCHAX will return the number of references to a particular data structure. A special function exists that allows you to get a little extra space 50 that you can try to save your work when you get toward the edge (usually noted by a message indicating that you should save your work and sysin a fresh Lisp). The GAINSPACE function allows you to delete non-essential data structures. To use it, type: (liIKSPACE) into the Interlisp-D Executive Window. Answer "N" to all questions except the followi ng. Delete edit history Delete history list. Delete values of old variables. Delete your MASTERSCOPE datadase Delete information for undoing your greeting. Save your work and reload Lisp as soon as possible. RESOURCE MANAGEMENT 41 S ----- Next Message ----- Date: 19 Dec 91 17:23 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.172334pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11625>; Thu, 19 Dec 1991 17:23:37 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 17:23:34 -0800 From: John Sybalsky -----RFC822 headers----> 42. SIMPLE INTERACTIONS WITH THE CURSOR, A BITMAP, AND A WINDOW The purpose of this chapter is to show you how to build a moderately tricky interactive interface with the various lnterlis~D display facilities. In particular how to move a large bitmap (larger than 16 x 16 pixels) around inside a window To do this, you will change the CURSORINFN and CURSOROUTFN properties of the window. If you would also like to then set the bitmap in place in the window, you must reset the BUTTOKEVENTFN. This chapter explains how to create the mobile bitmap. 42.1 An Example Function Using GETMOUSESTATE One function that you will use to "trace the cursor" (have a bitmap follow the cursor around in a window) is GETNOUSESTATE. This function finds the current state of the. mouse, and resets global system variables, such as LASTM0USEX andLASTMOUSEY. As an example of how this function works, create a window by typing (SETQ EzMPLE.wIN~ (CREATEI)) into the Interlisp-D Executive window, and sweeping out a window. Now, type in the function (DEFIKEQ (PRIKTC00RDS (V) P~TPRI*T ( ~TuouSEx ., . US~EY )) BLocK) 6E~SESTATE))) This function calls GETNOUSESTATE and then prints the new values of LASTNOUSEX and LASTMOUSET in the promptwindow. To use it, type (WIKraoPRoP EXlPLE .ilI*~ `CURSD~EDFK `PRIaTC00RDS) The window property CURSORffOVEDFN, used in this example, will evaluate the function PRINTCOORDS each time the cursor is moved when it is inside the window. The position coordinates of the mouse cursor will appear in the prompt window. (See Figure 42.1.) SIMPLE INTERACTIONS M'ITH THE cuRsoR. A BlTMAP, AND A WINDOW 42 f I AN EXAMPLE FUNcTION USING GETMOUSE5TATE Figure 42.1. The current position coordinates of the mouse cursor are shown in the prompt window 42.2 Advising GETMOUSESTATE For the bitmap to follow the moving mouse cursor, the function GETKOUSESTATE is advised. When you advise a function, you can add new commands to the function without knowing how it is actually implemented. The syntax for advise is (RISE fn when where what) fn is the name of the function to be augmented. when and where are optional arguments. when specifies whether the change should be made before, affer, or around the body of the function. The values expected are BEFORE, AFTER, or AROUND. what specifies the additional code. In the example, the additional code, what, moves the bitmap to the position of the mouse cursor. The function GETNOUSESTATE will be ADVISEd when the mouse moves into the window. This will cause the bitmap to follow the mouse cursor. ADVISE will be undone when the mouse leaves the window or when a mouse button is pushed. The AOVISEing will be done and undone by changing the CURSORINFK, CURSOROUTFN, and BUTTONEVENTFK forthewindow. 42.3 Changing the Cursor Ofif laot part of tho examplo, to give th impression that a bitmap is dragged around a window, th original cursor should disappear. Try typing: (CURSOR (CURSORCRRrt (6I~PCREAtt 1 l) 1 11 2.2 SINPU NVE~CYI0NS WITH Tn: CURSOR. A StTNAP. ANO A WIHIOOW CHANGING THE CURSOR into the lnterlis~D Executive Window. This causes the original cuttor to disappear. It reappears when you type (CURSOR T) When the cursor is invisible, and the bitmap moves as the cursor moves, the illusion is given that the bitmap is dragged around the window. 42.4 Functions for "Tracing the cursor" To actually have a bitmap trace (follow) the cursor, the environment must be set up so that when the cursor enters the tracing region the trace is turned on, and when the cursor leaves the tracing region the trace is turned off. The function Establish/Trace/Data will do this. Type it in as it appears (note: including the comments will help you remember what the function does later). (DEFIKEQ Establish/Trace/rata [LANR0 (nd tracebiteap cursor/rightoffse~ cursor/heighteffse~ GCGA6P) This functlri is colld to ostablish tha dti to trac the dsirod bitaap nd is the ind~ in hich the tracing is to take place, tracebitap" is the cursor/rightoffset and ~~~50~'~~~g~~0t~~~~~5~i~~1 b~~i~~t~g~~5 hich dete~ine the hotspot of the tracing biteap. As "cursor/heightof'set and cursor/rightoffset increase the cursor hotspot :ves up and to the right. If GCGAGP is non-NIL, GcGAC ill be disabled.) (PRoG NIL (if (0R NULL nd) (NULL tracebitaap)) then (PLAYTUN (LIST (CONS 1000 4000))) (if ~&~&pRET~RN)) then (GC6A6)) Create a blank cursor.) (SSEETTQQ ~8BrnUNNKKCTliURCS0ECRtiR(soBIRllNA(CPCURRsoEARTcEREl,eT~lo)jwxc~~2~j~ Set the CURSOR IN and 0UT FNS for nd to the Jolloeing:) (*INroNPRoP nd UTE CURSORINF (FU TIrn SETUP/Tlic (WINDoNPooP nd~~TE CURSoRoUTFENNJJ (FU TIoN UNTlic/CURSOR)) (O To all",' the bita,ap to be set den in the indw bY pressing a "`ouse button, include this line. 0ther',,'ise, it is not needed) (WINnoNPRop nd (UTE RUTToNEVENTFN) (FUNCTIoN PLACEIBITNAPIINIwINrGN)) Set up Global Variables for the tracing 9eratien) (SETQ TRAcElITNAp tracebiteap) TQ RIGNTTliCE'oFFSET(oR cursor/rightoffse~ 0) 5>sfE~TQ HEIGHTTRACEIoFFSET(0R cursor/hei htoffset )) TQ 0LQBIT~PPosITIoN(BIfflPCREATE llNArnIOTN tracebitap) (SETQ TliCCwfNDoN rndj)) BITNApHEI6hT tracebiteap))) SIMPLE INTERAcT'oNs WITH THE cuRsoR. A BJTMAP. AND A WINDOW 423 1 FUNCTIONS FOR "TRACING THE CURSOR' When the function Establish/Trace/Data is called, the functions SETUP/TRACE and UNTRACE/CURSOR will be installed as the values of the window's WlNDOWPROP$, and will be used to turn the trace on and off. Those functions should be typed in, then: (DEFINEQ SETUP/TRACE [ADA nd) (O This function is and's cuRSORIKFK. It siepiy resoti th last trace position and the current tracing region. It also raadvises fiETNouSESTATE to perforn the trace function after each call.) (if TRAcEBITNAP then SETQ LAST-lPACE-XPO5 -zOo SETQ LAST-TRACE-YPOS -zooo) SETQ vNDREGIa (WINOaNPROP and (ATE REGI0N))) WIN~flROP and (ATE TliCIK) T) :ake the cursor disappear) CURSOR BLANKTRACECURSOR) ANISE QUOTE GEThOUSESTATE) QUOTE AFTER) IL (QUOTE (TPACE/CURSOR])) (Dt~EQ(UaNTRACE/CURSOR Th1s function is nd's CURsOROUTFN. The function first checks if the cursor is currently being traced; if so, it replaces th tracing biiaap aith ahat is under it and then turns tracing off by unadvislng 6ETNOUSESTATE and setting th TliCIK ainda propertj of TRACEWINOoO TO NIL.) (if (VIN~PnOP TRACEWINOON(QUOTE TliCIK)) then (BITBLT 0LOBITNAPPOSITION o o (scREENBIllNAP) IPLUS CAR ffDRE6ION)LAST-lRACE-xPOS) (IPLUS 1CADR :DREGIOffo )usT-TlicE-YPos)) (WINOoePRoP lliCEMINOON(QUOTE TRACIK) NIL)) replace the original cursor shape) (CURSOR T) unadvise 6E~sESTATE) (U~"'ISE (QUOTE 6ETNOUSESTAlE])) The function SETUP/TRACE has a helper function that you must also type in. It is TRACE/CURSOR: (DEFINEQ (TliCE/CURSoR [LANRli NIL This functi: does th actual BITBLTln of th tracing blteap. This functla Is clled after a GE f TATE, abl tracing.) (PRoG ( xpos IDIFFERENCE LAsTNOUsEZ TRACEWINnoN RIGNTTRACE/OFF [ypoo IDIFFERENCE LAsTNOUsEY TRACE*INr~ NEIGnTTRACE/OfFSsEETiJ))) If there Is an rror In th function, ress th riKbt button to unodvls th function. This ill eep th ac in fr: locking up.) (If (LASTNOUSESTATE RIGiiT) (if ~t1h~~~ (NUNAPuISE (QUOTE 6ElS~5ESlATE))) Q xpoa LAST-TRACE-XP0s (KEO ,pea LAsl-TeACE-YPOSj) thn Restoro aht ~s undr the eld pooltla of th trc OilUp) (SITGLY OLliIllnApposITIG o o (IREE5IlliA~) 2A SIMPLE lNTE~CJ\OHS WITH THE CURSOR. A BtTMAP. AflO A WINDOW 1 F, FUNCTIONS FOR "TRACING THE CURSOR" IPLUS CAR il IPLUS CADR :DDRRESEGISIrn2LASTTRAC sv b&t 111 b undr th position of th nee trc biteap) (51 TILT SCREENBITNAP) [IPLUS (CAR aDREGIa) xpos) (IPLUS vNDREGIoa O O) BIfflLT the tracG blt:p onto th n position of th eouse.) (8ITBLT TRACEBITNAP O O ~5CREENBITNAP) (IPLUS (CAR ilDRE ION") (fPLUS (CADS ffORE6ION) ypos NIL NIL YE INPUT) (ONDTE P liT)) Savu the current position as the last trace position.) (SETQ LAST-TRACE-xPDS xpos (SETQ "LAST-TRACE-YPOS ypos The helper function for UHTRACE/CURSOR, called UNDO/TRACE/DATA, must also be added to the environment: (DEFINEQ (UNDo/TRACE/DATA [LISA NIL The purpose of this function is to turn tracing off and to free up the global variables used to trace the bitaap, so that thej can be garbage collected.) Check if the cursor is currently being traced. It so, turn it off.) UiTRACE/CURSoR) WINDoNPRDP TliCE*IN~(uTE CURSDRINFN) NIL) (WINDo*PRDP TRACEwINDDN(uTE CUR~R0UTFN) NIL) SETQ "TRACEBITsAP NIL) SETQ RIGNTTlicE/oFFsET NIL) SETQ HEIGHTTRACE/OFFSET NIL) SETQ OLDBITliPP0SITIDN NIL) SETQ TRACE*I~ NIL) Turn GCGAG on) (6C6A6 TJ)) Finally, if you inCluded the WlNDOWPROP to allow the user to place the bitmap in the window by pressing a mouse button, you must also type this function: (D[E~DEAQ, nd) UNADVISE (SETNDUSESTATE)) fBITBLT TliCEBITNAP O O SCREENBIlNAP) (IPLUS (CA 0N) xpo (IPLUS (CADR iDREGION) ypos) NIL NIL (UTE INPUT) (ATE PAINT] That's all the functions! SIMPLE INTERAcTioNs NITH THE cuRsoR, A BITMAP, AND A WIND0W 42 S p RUNNING THE FuNcTlGh5 42.5 Running the Functions To run the functions you just typed in, first set a variable to a window by typing something like (SETQ EXMPLE.wIN~ (CRATEI)) into the Jnterlisp-D Executive window, and sweeping out a new window. No'rv, set a variable to a bitmap, by typing, perhaps, (SETQ ExlPLE.BTn (DITl)) Type (Estab1isfl'Trsce'Oo~ EXlPLE.WIN~ EXlPLE.BTK)) When you move the cursor into the window, the cursor will drag the bitmap. (Note: If you want to be able to make menu selections while tracing the cursor, make sure that the hotspot of the cursor is set to the extreme right of the bitmap. Otherwise, the menu will be destroyed by the BITSLTs of the trace functions.) To stop tracing, either move the mouse cursor out of the window; press the right mouse button; call the function UNTRACE/CURS0R. u.6 SIMPLE lNTEPACT~NS WITH THE CURSOR. A SITMAP. AND A WlN00W ----- Next Message ----- Date: 19 Dec 91 17:30 PST From: sybalsky:PARC:Xerox To: sybalsky Message-ID: <<91Dec19.173105pst.43009@origami.parc.xerox.com>.?::> <----RFC822 headers----- Received: from origami.parc.xerox.com ([13.1.100.224]) by alpha.xerox.com with SMTP id <11702>; Thu, 19 Dec 1991 17:31:18 PST Received: by origami.parc.xerox.com id <43009>; Thu, 19 Dec 1991 17:31:05 -0800 From: John Sybalsky -----RFC822 headers----> r fi. OTMER RFERENCES THAT WILL 8E USEFUL TO YOU Here are some references to works that will be useful to you in addition to this primer. Some of these you have already been referred to, such as: The InterlispD Reference Manual The Library Packages Manual The User's Guide to SKETCH Thell86orllO8User'sGuide In addition, you can learn more about LISP with the books: Interlisp-D: The languago and its usage by Steven H. Kaisler. This book was published in 1986 by John Wiley and Sons, NY. Essential LISP by John Anderson, Albert Corbett, and Brian Reiser. This book was published in 1986 by Addison Wesley Publishing Company, Reading, MA. It was informed by research on how beginners learn LISP. The Little Lisper by Daniel P. Friedman and Matthias Felleisen. The second edition of this book was published in 1986 by SRA Associates, Chicago. This book is a deceptively simple introduction to recursive programming and the flexible data structures provided by LISP. LISP by Patrick Winston and Berthold Horn. The second edition of this book was published in 1985 by the Addison Wesley Publishing Company, Reading, MA. LISP: A Gentle Introduction to Syabolic Coaputation by David S. Touretzky. This book was published in 1984 by the Harper and Row Publishing Company, NY. Finally, there are three articles about the Interlisp Programming environment: Poaer Tools Tor PrograffaersbyBeauSheil. It appeared in Datamation in February, 1983, Pages 131 - 144. The Interlisp Prograffaing Environaent by Warren Teitelman and Larry Masinter. It appeared in April, 1981, in lEEE Computer, Volume 14:1, Pages 25 - 34. Prograaing In an Interactive Environaent the LISP Experience by Erik Sandewall. It appeared in March, 1978, in the ACM Computing Surveys, Volume 10:1, pages 35 - 71. Each of these articles was reprinted in the book Interactive Prog ral ng Envl ronaents by David R. Barstow, Howard E. 0THER REFERENCES THAT WILL BE USEFuL T0 You 441 I OTHER REFERENCES THAT WILL BE USEFUL TO YOU Shrobe, and Erik Sandewail. This book was published in 1984 by McGraw Hill, NY. The first article can be found on pages 19 - 30, the second on pages 83 - 96, and the third on pages 31 80. J:' ill OTHER REFERE~E5 THAT WILL 55 usEFuL TO You I ----- End Forwarded Messages ----- End of message -TIMESROMAN - -TIMESROMAN -VH(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8) (POSTSCRIPT (GACHA 8))) -Omz \ No newline at end of file