This chapter describes the Smalltalk/V environment, including:
Figure 15.1 shows a typical Smalltalk/V screen running with three windows: a Transcript, a Workspace, and a Class Browser.
Figure 15.1
Smalltalk/V Screen
Every window in Smalltalk/V has a title bar and is surrounded by a border or frame. The area inside the border is divided into one or more panes. In our example, the Workspace and the Transcript each have a single pane, and the Class Browser has three panes. The arrow that moves around the window is the cursor, which you control by moving the mouse.
To select a window, position the cursor within the window and click (quickly press and release) the left mouse button.
The window that you have selected is called the active window. The active window is always in front of other windows in a stack and its title bar is in a different color than the title bars of nonactive windows. A window remains active regardless of whether or not the cursor is inside it. To deactivate a window, position the cursor over another open window or collapsed window icon and press either mouse button. The clicked window becomes active and the once active window becomes non-active.
Activating a window with a left-button mouse click simply activates the window while a right-button click simultaneously activates and pops-up a pane menu for the newly activated window. Clicking on a collapsed window icon with either button activates the icon and pops up the window¡s System menu. (Double-clicking the collapsed icon immediately restores the window without requiring you to select the Restore item in the pop-up System menu.)
When you have several open Smalltalk windows on the screen, press the F9 function key. Smalltalk/V deactivates the currently active window and brings another one forward, activating it. Continue pressing F9 to activate another window. This is called window cycling and it is extremely useful when you have many open windows and some are completely covered by others. This is a shortcut to find a window rather than opening the host Task Manager to find and activate a window.
Window cycling only applies to the stack of open windows in the Smalltalk environment. Windows from other applications will remain unaffected as you shuffle through your Smalltalk/V windows.
Menus are the standard means of giving commands to Smalltalk/V windows and their contents. Menus, each with a list of items from which to choose, are located in the menu bar of each window.
The menu bar extends across the top of a window, below the title bar and above the pane or panes of the window. The menu bar displays the title of each of the available menus for the window in which the menu bar is displayed. Standard menus--System, File, Edit--are always in a menu bar, as is a Smalltalk menu. Special menus will appear on the menu bar--e.g., the Classes, Variables and Methods menus in a Class Hierarchy Browser window-depending on the functionality of the active window.
To select a menu, move the cursor to the menu title on the menu bar and press and hold the left mouse button. The menu drops down just below the menu title. If you hold down the mouse button and slide the cursor across the menu bar, you can quickly scan the menus and their items as each menu drops down when the cursor moves over its title. To select an item, slide the cursor down the menu to the item and release the mouse button.
Alternatively, you can select a menu by clicking and releasing the left mouse button. This drops the selected menu down and "freezes" it in the down position. To examine other menus in this manner, you need to point to and click each menu title in turn.
To leave a menu without performing any function, move the cursor outside the menu in any direction and release the mouse button if you are using the click and drag selection method. The pull down portion of the menu disappears. If you are using the click and release selection method, simply point anywhere outside the drop down menu and click again. The menu disappears.
In all windows, keyboard-only operation of menus is permitted. Press the Alt key to activate menu selection and then press an alphabetic key indicated by the underlined characters in the menu titles. The selected menu drops down. For example, pressing Alt + E drops the Edit menu down. In addition, using the left and right arrow keys after pressing Alt will preview each drop down menu in the same way menus can be previewed using the press and drag mouse cursor technique.
To select a menu item, place the cursor over the menu title and click the left mouse button to pull down the menu items. While holding down the mouse button, drag the cursor over the list of items until your desired choice is reversed. As soon as you release the mouse button, the menu disappears and the selected function is executed.
If you use the click and release method of menu selection, point to and click a menu item displayed in the "frozen" pulled down menu. Unlike the press and drag method, the menu items will not video reverse as your cursor moves over each item. When you click on an item, its associated action is performed.
You must leave a menu before you can pull down and select an item from a different menu.
Some menu items are used very often. Keyboard accelerator commands, noted on the far right of items in the pull down menus, are provided so you can select menu items immediately from the keyboard. These keyboard commands may involve pressing the Alt or Ctrl key in combination with another key to select the menu item of interest. For example, an Alt + S will issue the Save command from the File menu. Some menu items do not have a direct-acting accelerator command associated with them.
Windows are usually opened from menus. Windows can also be opened through the evaluation of Smalltalk expressions which result in the definition, creation and activation of windows.
To open a new workspace, select New Workspace from the File menu. An active Workspace window opens. This window can be closed, moved, scrolled, minimized, maximized or resized using typical host environment conventions. The Workspace window is, as its name implies, a "scratchpad" for working on your applications. While open, Workspaces are preserved in the Smalltalk/V environment when the Image is saved at the end of a session. Workspaces also can be individually saved to disk for editing outside of the Smalltalk/V environment using your word processor or other text editor.
Most of your actual Smalltalk programming involves extensions to the Class Hierarchy. So Workspaces come in handy for defining "test states" and example code which call on the extensions you are making to your Smalltalk classes. For example, the tutorial files referenced throughout this manual started as Workspace files which were saved to disk to capture, in a convenient format, the examples which showcase classes and methods in the Smalltalk/V system.
Figure 15.2 shows a typical Workspace window with its title bar and window controls. The title bar displays the window title along with the System menu icon on the left, and the Minimize and Maximize icons on the right. Resizing can be done by clicking and dragging any of the window borders or border corners.
To select a window control icon, place the cursor on the icon and click the left mouse button.
System Menu Icon: When selected, the System menu drops down with menu items which affect the overall state of the window (such as size and position). Double-clicking on the System menu icon directly executes the Close item. If the window is associated with a disk file and its contents have been altered, you will be prompted as to whether or not to save the current changes before closing the window.
Minimize/Maximize Icons: When the Minimize icon (the down-pointing arrow) is clicked, Smalltalk/V collapses the active window which becomes represented by a Smalltalk/V icon along the bottom edge of your display screen. To restore the window from its collapsed state, double-click its Smalltalk/V icon and the window zooms out to its original size and position.
Figure 15.2
A Window and its Parts
To conveniently enlarge an active window, click its Maximize icon (the up-pointing arrow) in the title bar. The window zooms from its current size and position to fill the entire display overlapping all other open windows. Once so enlarged, the Maximize icon becomes a Restore icon (combined up and down arrows). To return the window to its prior size and location, click on the Restore icon of a Maximized window.
Window Borders and Border Corners: You click and drag window borders and corners to resize a window using the mouse. Each window border and corner has a "hot zone" where the mouse cursor turns into a directional indicator for window resizing. When your cursor passes over the top or bottom border of a window, the resize cursor is a double-arrow pointing up and down. The resize cursor for the left and right side borders is a double-arrow pointing left and right. The resize cursor for a corner is a double-arrow pointing diagonally into and out of the window.
To resize the window, press and hold down the left mouse button when one of the border resizing cursors is visible. Depending on the border or corner you selected, a fuzzy gray line will move with movements of the mouse. The gray line or lines indicate the new size the window will snap to when you release the mouse button. If you select a border, only the horizontal or vertical size of the window will be affected. If you select a corner, both horizontal and vertical dimensions of the window will be affected. Regardless of which border or corner you select, the opposite side or corner remains anchored to its current position.
In addition, you can select the Size item in the System menu and resize a window with your cursor arrow keys. Simultaneously pressing a left or right arrow together with an up or down arrow key allows corner resizing.
The System menu, directly accessed by Alt + spacebar, offers functions that apply to the window as a whole.
Restore is active when a window is collapsed as an icon or expanded to full screen. Selecting this item resizes the active window to the position and dimensions it was before it was minimized or maximized.
Move "grabs" the active window so it can be moved around on the screen using the arrow keys or the mouse.
Size lets you resize the active window using the arrow keys rather than clicking and dragging the window¡s borders with the mouse cursor.
Minimize shrinks the active window to an icon which is available for instant retrieval.
Maximize expands the borders of the active window to fill the entire screen for the maximum editing and display area.
ZoomText, accessed by Alt + Z, expands the active text pane to fill the full window borders in a multiple-pane window. If the pane is zoomed, issuing this command a second time collapses the pane to its original proportions, restoring any panes which were hidden while the pane was zoomed to full frame.
Fonts... brings up a dialog box to select the font and font size of the selected text pane or window.
Close, accessed by Alt + F4, closes the active window. (This item is replaced by the Exit Smalltalk/V... item in the Transcript window. See the next paragraph.)
Exit Smalltalk/V..., accessed by Alt + F4 in the System menu of the Transcript window only, is used to quit the Smalltalk/V environment. Selecting this item ends Smalltalk/V's current session. You are prompted as to whether or not you wish to save the current image before the session is terminated.
Switch to..., accessed by Ctrl + Esc, brings up the Task List window for switching between tasks and windows. One of these windows is the Desktop Manager window, which has the system level facilities, such as arranging windows, help and shutdown.
Windows are composed of one or more panes. The most prevalent kinds of panes are text, list, graph and button panes. Animation and group panes are also available. In addition, you can create your own SubPane subclasses to add new and functionally different panes to your Smalltalk system.
Many of the windows in the Smalltalk/V environment have panes that allow you to modify or edit text. These are called text panes. The Transcript is a window with only a single text pane, as is any Workspace. These and all other text panes use the same text editor interface.
Other windows in the Smalltalk/V environment have panes that allow you to select from a list of items. These are called list panes. Windows that have list panes are usually referred to as browsers. The Class Browser is an example of a window with two list panes and a text pane.
The class ControlPane contains all the window control structures. These include Button, EntryField, GraphBox, ListBox, ScrollBar, and StaticPane. These each have numerous subclasses controlling finer adjustments. Using the Class Hierarchy Browser, review these subclasses for their specific controls.
The button controls are useful for obtaining simple interactive responses from the user. The Class or Instance "radio set" buttons in the Class Hierarchy Browser are instances of class RadioButton, whereas the Hop, Skip and Jump buttons of the Debugger are instances of Button.
The group pane is used primarily to gather a number of panes within a window as a kind of "subwindow" within a complex window design. The instance and class buttons which make up the mutually exclusive set of radio buttons in the Class Hierarchy Browser are two instances of RadioButton which have been grouped together in a GroupPane.
The graph and animation panes allow you to display graphics of all kinds. Since these types of panes are not used by any of the standard windows in the Smalltalk/V environment, they are not explained in this chapter. Refer to the graphics and windows tutorials and reference sections for more information.
There are many instances when the content of a window pane is larger than the pane itself. You can think of a pane as a viewport which lets you see only part of a pane's full contents. Scrolling lets you move this viewport around the "virtual space" which contains the full content of the window. In a text window this can mean scrolling up, down, left and right on a page larger than the area shown in the text pane. On a graphics display, this can mean scrolling to bring different parts of a picture into view.
One way to scroll a pane is by using the mouse and the scroll bars. A scroll bar is a rectangle with a scroll arrow at each end and a rectangular scroll box positioned somewhere between the two scroll arrows. The position of the scroll box, called the "slider", along the scroll bar is relative to the position of the displayed text or graphic relative to the entire virtual space of the information presented in the window. For example, when the slider is halfway between the ends of a vertical scroll bar, what you see in the pane is about midway through the content of the entire text you have been given access to by that pane.
Scroll bars are optional. A pane may not need to scroll its contents, so scroll bars may be omitted from such a window or pane specification. A vertical scroll bar appears along the right edge of a window. A horizontal scroll bar appears along the bottom edge of a window. Only active panes or windows show scroll boxes or the gray pattern in scroll bars which indicate that the scroll bars are active and, therefore, functional.
A click in the scroll bar area will page up and down or left and right through the text or graphic content of the window depending on where you click in the scroll bar relative to the scroll box. For instance, clicking above the scroll box in a vertical scroll bar will cause the contents of a text pane to page backward one screen toward the beginning of the text.
Pressing and holding the mouse button on either side of a scroll box will cause the paging function to repeat itself a page at a time until the scroll box reaches that position on the scroll bar. When the scroll box reaches the mouse cursor, scrolling stops. When you click on and drag the scroll box, the contents displayed in the associated pane changes rapidly.
Scroll arrows let you move slowly through pane contents in the direction of the arrow. If you want to see contents just above or just below your current visible location, click once on the vertical up or down arrow respectively. To view contents to the left or right, click once on either horizontal scroll arrow in the appropriate direction. Each click on a scroll arrow moves your visible location one unit in the chosen direction. Units depend on pane contents--one item in a list; one line in text. Pressing and holding down the mouse button while the cursor is on a Scroll arrow causes continuous movement in its direction.
Also, the Page Up and Page Down keys provide a keyboard-based alternative to mouse scrolling. The pane affected is the pane that has the focus, which is normally the last pane in which a selection was made.
Text editing in Smalltalk/V conforms to host system text editing conventions.
To insert text, position the cursor at the exact location where the text is to be inserted and click the left mouse button. This will cause the vertical insertion point to position itself where you clicked. Start typing and the insertion point continually moves to the right as each newly typed character is inserted. If you make an error, press the Backspace key to back up and delete unwanted characters.
To move the insertion point, move the cursor to a new position and click the mouse button. The insertion point jumps to the new cursor position. In addition, the Home key will move the insertion point to the beginning of the line in which the insertion point is currently located, and the End key will move the insertion point to the end of the current line.
Pressing the Enter key moves the insertion point to the beginning of a new line. If the insertion point is positioned in the middle of a line when you press Enter, the line is split into two lines with the text to the right of the insertion point moved to the new line.
If you press the Tab key, a tab character will be inserted at the insertion point to move the point to the next tab stop. In this editor, tab stops occur every four spaces.
If you press the Backspace key, the character to the left of the insertion point is deleted. Although the deleted character doesn't go to the Clipboard, you can undo your deletion by immediately choosing the Undo function from the Edit menu.
If you press the Delete key, the character to the right of the insertion point is deleted. Although the deleted character doesn't go to the Clipboard, you can undo your deletion by immediately choosing the Undo function from the Edit menu.
The four arrow keys, sometimes called cursor keys, provide an additional keyboard-based means of moving the insertion point and scrolling list panes. When the last active pane is a text pane, the up, down, left and right arrow keys move the insertion point a character at a time in their respective directions. When the last active pane is a list pane, the up/down arrow keys move the selection highlight through the list.
To begin the process to select text in the active window, first move the cursor to the point where you want to begin or end your selection, and click the left mouse button. To extend the selection, move the cursor to the other end of the text you want selected and then hold down the Shift key as you click the left mouse button. The text selection will now extend to the current cursor location. Text selection extensions can also be performed by holding down the Shift key while using the four allow keys and the Home or End keys. Selected text will be shown as reverse video.
You can also select text using the draw through method. Position the cursor at one end of the text you want selected--the anchor point. Now press the left mouse button and hold it down as you move the cursor to the other end of the selection--the active point. Notice that as you move the cursor, the selection (the reversed text) follows and includes the current cursor location. Draw through terminates when you release the button.
To select a single character, position the cursor at the character you want to select. Press down the left mouse button and use the draw through method until the single character is reversed.
To select a whole word, position the cursor anywhere on the word to be selected and doubleclick the left mouse button. The word is selected as indicated by its being displayed in reverse video.
To select a line, place the cursor just inside the window border to the left of the line you wish to select and double-click the left mouse button.
To select all text in the currently active window or in the last edited text pane of a multipaned window, choose Select All from the Edit menu.
To replace text, select the text to be replaced, then type the new text. As you type, the selected text is replaced with the new text.
To delete text one character at a time, place the insertion point at the end of the text to be deleted and press the Backspace key or place the insertion point at the beginning of the text and press the Delete key.
To delete large amounts of text, select the text and use Cut or Clear from the Edit menu or press the Backspace or Delete keys. The Cut and Backspace operations will both delete the text and put it the Clipboard. The Clear and Delete operations will delete the text but not place it on the clipboard. If you want to restore the text under any of these operations, you can immediately select Undo from the Edit menu. With the Cut and Backspace operations, you can Paste the deleted text at the insertion point.
The text editor has a buffer, called the Clipboard, that can be used to transfer text from place to place. Text is placed in the Clipboard by either cutting or copying it from a pane. After text has been placed in the Clipboard, it can be pasted anywhere inside the same or another text pane.
To place text in the Clipboard you must first select the text. Then, select either Cut or Copy from the Edit menu. If Cut is selected, the contents of the Clipboard are replaced with the selected text, and the selected text is deleted from the pane. If Copy is selected, the selected text is not deleted from the pane. Instead a copy of the text replaces the contents of the Clipboard. (A Backspace character deletion is equivalent to a one character Cut operation.)
Text in the Clipboard can be pasted into the pane by either inserting it into a new place or replacing some existing text. To insert the contents of the Clipboard, place the insertion point at the desired position and select Paste from the Edit menu. To replace some text with the contents of the Clipboard, first select the text to be replaced and then select Paste from the Edit menu.
The Paste function leaves the contents of the Clipboard unchanged. This means that the same text can be pasted several times in different places. Note that an intervening Backspace operation will replace the Clipboard contents with the currently deleted character, even if the character is a blank space. So get in the habit of using the arrow keys to move the insertion point and the Delete key to perform intervening single character deletion when you know you have text on the Clipboard which you subsequently intend to paste.
Since the same Clipboard is shared by all applications, you can easily transfer text between Smalltalk windows and other applications. First select the text to be transferred. Next, place this text into the Clipboard using either Cut or Copy. Then move the cursor into the new window and either place the insertion point where the text is to be inserted of select some existing text that is to be replaced. Now, use Paste from the Edit menu. The text appears in the non-Smalltalk/V window.
The text editor in Smalltalk/V is always working with a text copy of some underlying object in the system. Among other things, this can be a file, a string, or some Smalltalk code. For example, the Transcript and any Workspace edit strings of characters, and the text pane in the Class Hierarchy Browser edits Smalltalk code. Because a copy is being edited, you must tell the environment when editing is complete. The edited text is then saved back onto the original object. You can also restore the edited text in the pane to its original state, if you wish.
Every pane that allows text editing takes full advantage of the editing functions on the Edit menu and the Save, Save As... and Restore functions on the File menu.
The Save function in the File menu tells Smalltalk/V that editing is complete. The underlying object being edited is updated with the text currently in the pane. For example, if a file is being edited, then the file is rewritten with the text in the pane. You can tell which file is associated with the text pane of a Workspace window by reading its title bar.
The Save As ... choice on the File menu saves a copy of the currently active pane to a device, path and file name you provide through a dialog prompt. Save As... saves editing changes to the new file you have specified, not the original. The new file then becomes the active file. If no changes have been made to the original file and Save As... is chosen, then two identical files will exist, each with its own name. When the Save As... function is not currently available for the information displayed in a window, this item is dimmed in the File menu and cannot be selected.
The Restore function discards all changes made to the active text pane since the last time it was saved, replacing the current copy of the underlying object being edited with a new copy. If you are editing a string, then the underlying string replaces the string text in the pane. If you are editing a file, the text in the original file, as it was last saved, is reread into the pane. If you are editing Smalltalk code, the original source code is copied into the pane.
The image is all the Smalltalk objects, both code and data, that make up the Smalltalk/V environment. The image is read from the V.EXE file and .DLL files when the system starts up. All objects are loaded into memory. These objects include the windows that appear on the screen.
Since Smalltalk/V is an interactive and modifiable environment, the image is constantly being changed as you use and modify Smalltalk/V. These modifications are not written on the disk until you ask them to be written. This can be done at any time by selecting Save Image from the File menu. You can also save the image while exiting as described below. The next time you start up the system, it resumes exactly as it was when the V.EXE file was last written.
The V.EXE file on the disk represents the last saved version; therefore it also becomes the starting point in the event of a system crash or a major mistake. For these reasons, you should maintain a recent backup of the V.EXE file (and its associated sources.sml and change.log files). The Maintaining Smalltalk/V section later in this chapter explains the relationships between the V.EXE and .DLL files in more detail and gives instructions on maintaining them. It also gives advice on how to recover from a system crash or other problem.
To exit Smalltalk/V, select Exit Smalltalk/V... from the System menu of the Transcript window. A dialog pops up asking you whether or not to save the changes you have made to the image in the V.EXE file.
In the Save Image? dialog, selecting Yes causes the state of the system, including the location and contents of all the windows, to be saved. When you start Smalltalk/V the next time, it will begin exactly where you left off.
Selecting No causes all of the changes made since Smalltalk/V was started in the current session to be forgotten (although the change.log will remember them). When started the next time, Smalltalk/V will be restored to the previous saved state, ignoring any changes you have made in the current session.
Selecting Cancel returns you to the Smalltalk/V environment. This has the same effect as leaving a menu without selecting anything.
The Smalltalk language includes expressions which are similar to expressions in other programming languages. In the Smalltalk/V environment, you can enter the text for an expression in any text pane, evaluate it, and display the result. You specify what you want to do in the environment by making selections in pull down menus and by evaluating Smalltalk expressions, which serve as the Smalltalk/V command language.
All text panes in the system support immediate expression evaluation via the Smalltalk menu. To evaluate an expression, you must first select it, then pull down the Smalltalk menu and select either Show It or Do It. If you choose Show It, the expression is evaluated and a character representation of the value of the last expression is inserted in the pane after the evaluated text. If you choose Do It, the expression is evaluated and the expression value is thrown away. Notice that only the selected text is evaluated; the other text in the pane is ignored. Extra blanks at the beginning or the end of the selected text are similarly ignored.
Any legal Smalltalk expression or expression series can be selected in a text pane and evaluated. Temporary variables can be declared as needed.
When you select and evaluate an expression, Smalltalk/V compiles and then evaluates it. If it detects a compilation error, Smalltalk/V inserts an error message in the source code at the point of error. For your convenience, the error message is selected, so a simple Backspace will delete it to restore the pane state prior to evaluation of the expression. To fix the error, simply edit the text in the window and evaluate the expression again.
You do not need to type the expression that you want to evaluate. You can edit some existing text in the pane and then select and evaluate it. This feature makes it possible to build a window or even a file of useful expressions that you can edit as command templates to construct new expressions for evaluation. File sample.sml contains several useful expressions.
You can add to the expressions in this file (or make files of expressions of your own by opening and saving a Workspace). You can include comments with your expressions by merely enclosing the comment in double quotes like this: 'this is a comment'.
Prompters are special kinds of text editing windows which are useful when you need to request additional information from the user before proceeding with a process. Prompters in Smalltalk/V are implemented as dialog boxes. The prompt String is presented as a message in the box. The prompt should be worded so the user knows what response is requested. The user then enters a response into the single text pane of the Prompter. Often a default response appears in the text pane as shown in Figure 15.3.
Figure 15.3
A Prompter
The text editor used by a Prompter is the same as the text editor described under TextEditor above, except for the following differences:
There is a class in Smalltalk/V known as SystemDictionary. There is only one instance of this class, the System Dictionary. The System Dictionary defines methods for system oriented functions such as compressing the change log and determining available memory. It also contains all of the names known globally in the system. This includes the names of the classes, global variables, and pool dictionaries. The System Dictionary is referred to in Smalltalk code with the name Smalltalk/V which is a global variable. All global variable names must begin with a capital letter. An example of a message to the System Dictionary is the following expression:
Smalltalk unusedMemory
This computes the number of bytes of available memory in your system.
The next section describes the System Dictionary and some of the system commands (messages) that are sent to it.
The System Dictionary contains all of the names of the classes, global variables and pool dictionaries in the system. In addition, as you define classes, global variables, and pool dictionaries, their names are added to the System Dictionary.
For the classes present in the dictionary, the key is the class name and the value is the class itself. For the global variables present in the dictionary, the key is the variable name and the value is an object. If the variable has been defined but not initialized, its value is nil. Some of the more important global variables present in the system along with their values and a brief description are:
Variable Description
CharacterConstants A pool dictionary. CharacterConstants associate names with special character values such as: carriage return, line feed, escape, form feed, etc.
Clipboard The ClipboardManager that is used to transfer data between windows or applications usually through copy, cut and paste operations.
CurrentProcess The Process that is currently running.
Cursor A CursorManager used to store the location of the cursor.
CursorConstants A Dictionary which contains all the available cursors.
Disk A Directory. The current directory when the system is launched.
Display The single instance of Screen. Its associated pen can be used to draw directly on the screen without being clipped by windows.
KeyboardSemaphore A Semaphore that is signaled every time there is a keyboard or mouse interrupt.
Notifier The single instance of NotificationManager that dispatches events to windows.
KeyboardLibrary The single instance of KeyboardDLL used to make API calls to the keyboard DynamicLink Library.
FloatLibrary Either a FloatEmulatorDLL or a FloatCoproc-essorDLL used to make API calls to a floating library.
WinEvents An array that provides the mapping from Windows message numbers to Smalltalk selectors.
GDILibrary The single instance of GDIDLL used to make API calls to GDI Dynamic Link Library.
KernelLibrary The single instance of KernelDLL used to make API calls to kernel Dynamic Link Library.
UserLibrary The single instance of UserDLL used to make API calls to user Dynamic Link Library.
Processor The single instance of ProcessScheduler of the system.
TextFont A Font used as the default font for text panes.
ListFont A Font used as the default font for list panes.
Smalltalk The single instance of SystemDictionary.
Sources An Array containing two file streams for accessing the source code of Smalltalk/V The first entry is the sources.sml file. The second entry is the change log file.
SysFont The default Font used for the current graphics resolution.
Terminal A Pen associated with Display. it can be used to sound the bell, write text or draw graphics on the screen.
Transcript A TextWindow which is the Transcript, used primarily for system messages. You can also send his messages to Transcript to show debugging information.
Pool dictionaries are explained in more detail at the end of this chapter.
Many useful functions or methods which operate on the System Dictionary. They include:
Method Description
at: key put: anObject Creates a new global variable, named key, with the value anObject. If the global variable already exists, its value changes to anObject.
compressChanges Compresses the change.log file, removing all but the latest version of the methods.
compressSources Compresses the sources.sml file after updating it with the latest version of the methods in the change.log file.
implementorsOf:aSymbol Returns a Method Browser containing all of the classes that define a method with the name aSymbol. This is equivalent to choosing the Implementors function on the Methods menu of the Class Hierarchy Browser.
keys Returns all of the keys currently defined in the SystemDictionary.
removeKey: key Removes the specified key from the System Dictionary.
sendersOf: aSymbol Returns a Method Browser containing all of the methods, and their corresponding class names, which send a message with name aSymbol. This is equivalent to choosing the Senders function on the Methods menu of the Class Hierarchy Browser.
unusedMemory Returns the number of bytes free in the system.
A Dictionary contained in a global variable can be used as a pool dictionary. You can create a new pool dictionary by evaluating an expression such as:
Smalltalk at: #MyPool put: Dictionary new
You add pool variables by evaluating an expression such as:
MyPool at: 'Age' put: 29
There are several pool dictionaries in the base Smalltalk/V environment. These are briefly outlined below. To examine the contents of a pool dictionary, select the name of the pool and select Inspect It in the Smalltalk menu.
CharacterConstants
CharacterConstants is a pool dictionary associating names to special ASCII character values such as carriage return and escape. The keys of this Dictionary are descriptive strings and the values are the associated ASCII characters as shown below:
Key String ASCII Character
Bell Bell character (ASCII value 7)
Bs Back space character (ASCII value 8)
Cr Carriage return (ASCII value 13)
Del Delete character (ASCII value 127)
Esc Escape character (ASCII value 27)
Ff Form feed character (ASCII value 12)
FunctionPrefix First character of a function key two character sequence (ASCII value 0)
Lf Line feed character (ASCII value 10)
MouseButton Character sent when any mouse button changes state (ASCII value 254)
SetLoc Character sent when the mouse moves (ASCII value 255)
Space Space character (ASCII value 32)
Tab Horizontal tab character (ASCII value 9)
UpperToLower Smalllnteger of value 32, the numeric difference between upper and lower-case ASCII characters
WinConstants
WinConstants is a pool dictionary associating Microsoft Windows constant names to their values.
Pool Dictionaries Description
ColorConstants A pool dictionary associating color names to system color pallette indices.
CursorConstants A pool dictionary associating cursor names to cursorManager instances.
DrawingModeConstants A pool dictionary associating drawing mode names to their values.
FileConstants A pool dictionary associating file attribute names to their values.
VirtualKeyConstants A pool dictionary associating virtual key names to their values.
In this section, the procedures for maintaining the system are discussed. These include:
ä How to keep the files that the system uses from getting too big.
ä Some simple steps that you can take to protect yourself from losing any work in the event of a total failure (crash) of the system.
As you define and modify classes or methods, Smalltalk/V is logging all of these changes to the change log which is maintained in the change.log file. Smalltalk/V maintains pointers from the compiled methods in the environment to the latest version of the source code. If the source code has never been changed, the pointer goes to the VWSRC.DLL file. Otherwise, the pointer goes to the change.log file. As a result, the disk is accessed as you browse the methods in a class. Furthermore, since the V.EXE file contains pointers to the VWSRC.DLL and change.log files, you must maintain these three files as a set.
For these reasons, you must not edit or modify the change log! You can view it with the File menu Open... function and you can reinstall methods and class definitions from it into your system. This capability can be used to facilitate recovery from a system crash and is explained in more detail in the section on Surviving a System Crash in this chapter.
Other important events are automatically logged by Smalltalk/V. Every time the image is saved, a message with the date and time is written to the change.log file. Every Smalltalk expression that you evaluate with either Do It or Show It is also logged. In addition, every time you remove a method from a class, a message is logged.
The format of the change.log is very similar to the one described by Glenn Krasner (Smalltalk-80: Bits of History and Words of Advice, Addison-Wesley, 1983). A brief description of this format using the EBNF notation described in Appendix 1 follows:
<rule> changeLog = {textChunk}.
<rule> textChunk =
sourceCode | classDefinition | expression | imageComment.
<rule> sourceCode= ' ! ' className 'methods ! ' {method ' ! ' } ' ! '.
<rule> classDefinition = ' "define class" ' classDefinitionMessage ' ! '.
<rule> expression = ' "evaluate" ' evaluatedText ' ! '.
<rule> imageComment =
<rule> imageComment = ' " *** saved image on: ' dateAndTime ' *** " !'.
where: className is the name of a class.
method is a valid method as defined in Part 2 of this manual with occurrences of ' ! ' replaced by ' !! '
classDefinitionMessage is a valid class definition message to the class's superclass as defined in Part 2 of this manual.
evaluatedText is the text evaluated by Do It or Show It with all occurrences of ' ! ' replaced by ' !! '.
dateAndtime is the character representation of the date and time the image was saved.
Smalltalk/V is written almost entirely in Smalltalk. The image that is referred to in this manual is the collection of all Smalltalk objects that make up the environment.
When you save an application image, descriptions of application objects are written out on the V.EXE file. When you start the system at a later time, all of the objects described in the V.EXE file are recreated exactly as they were at the time the image was saved. (Actually, some objects in the Smalltalk/V environment are maintained in the host system with pointers to them from Smalltalk/V. When you save an image and exit the system, a complete description of these host-based objects is maintained in the V.EXE file so they may be "reborn" when you run your next Smalltalk/V session.)
As you use the system by writing Smalltalk code or using the environment for other purposes, new objects are created and existing objects have their contents changed. You must save the image to make your changes permanent. You can save the image by either selecting the Save Image function from the File menu or by selecting the Yes button from the Save image? dialog which pops up after selecting Exit Smalltalk/V... from the System menu of the Transcript window. If you do not save the image, the environment will not have any of your changes from the current unsaved session the next time it is started.
If you forget to save the image, you can still recover these changes. Items that were logged in the change log are still present, and you can install them again using the File menu Open... option (see Surviving a System Crash later in this chapter). Not saving the image is useful when you are developing something new and you decide that you have made a major mistake that you would like to discard.
Your Smalltalk/V system actually consists of DLLs plus the following four files:
V.EXE
a very small file that contains a combination of run-time executable (.EXE) code and the image (a collection of data objects). This file grows in size each time the image is saved.
VW.EXE
a very small file that contains the executable code used by the development system
change.log
the constantly updated log of source code changes, image save timestamp messages and expression evaluations
sources.sml
source code representing a major integration or release of your application, often shared by a team of developers
In addition, there are several DLL files containing the unchanging base source and methods and objects of the system. Compressing the change.log file reduces it to only the latest copy of each new or changed method. A new change.log file is written automatically.
You should compress the change.log file when it starts to get large. There must be enough space on the disk for both the new and the old change.log files at the same time, so make sure you compress the change.log file before the disk gets too full.
To compress the change log, evaluate the following expression in any text pane (the Transcript for example):
Smalltalk compressChanges
If there is not enough room on the disk, delete some files and then try again.
As explained in the section Automatic Logging of Changes, all changes you make to the system, are recorded in the change.log file. These changes can be compressed as described in the section above. You can also integrate the source code from changes.log and sources.sml by evaluating the following expression:
Smalltalk compressSources
This will do two things:
Periodically compressing sources will save disk space, and will purge unneeded duplicate source code from your change.log file. Additionally, the source code now contained in the sources.sml file is in a form that is easy to share among a group of developers.
As a result of the interrelationship of V.EXE, sources.sml and change.log, it is critical that you maintain current backups of all three of these files as a set. It is strongly recommended that you do this before compressing sources so you can recover if anything goes wrong.
Smalltalk/V is very resilient. Unfortunately, disasters can and will happen, especially if you are making significant modifications to Smalltalk/V. The automatic logging feature of Smalltalk/V makes it possible to recover from most disasters. Disasters happen not because Smalltalk/V has bugs in it, but because it is a modifiable program development environment. Smalltalk/V will let you change almost anything, even if it cripples the environment.
For example, if you make a mistake changing the method for the Walkback window, or if the hardware fails, you may see the error message: doesNotUnderstand: is missing. This means that Smalltalk/V cannot find the code that displays the appropriate walkback message and has terminated.
This presents no problem since you can recover most, if not all, of your work very quickly. In fact, experimenting with the system is a good way to learn about it, but make sure you take the following precautions:
If the system crashes you should make a copy of your V.EXE, change.log and sources.sml files before proceeding. To recover your work, follow these steps:
When you have finished recovering what you want, use the Save Image item in the File menu and make a backup.
Unused symbols tend to accumulate slowly over time in Smalltalk/V because instances of class Symbol are not automatically collected as garbage. Evaluate the following expression to remove all symbols that are no longer referenced:
Symbol purgeUnusedSymbols
The number of symbols purged and the amount of space reclaimed is usually quite small.
Smalltalk/V supports all the fonts provided by Windows. These fonts can be divided into two major categories: bitmap fonts and outline fonts. Bitmap fonts can be displayed faster than outline ones but they cannot be scaled with consistent quality.
The following global variables govern the fonts used by different parts of the system:
Global Variable Used by
ListFont ListPane
TextFont TextPane
SysFont all others
You can change the first two variables to contain different fonts. When you open new windows, the new fonts will be used. SysFont is used in all other occasions when text is displayed by Smalltalk, For text not displayed by Smalltalk, like menu items, the default Windows system font is used.
You can change the list or text pane font through the Fonts... item in the System menu. Selecting Fonts... brings up a dialog box with list boxes which lets you select the font and size to be used in the newly created list or text panes.
Smalltalk/V represents characters in strings using their ASCII codes. In order to display them on the output medium, these ASCII values must be converted into bitmapped or outlined images. Class TextTool performs the conversion by calling Windows graphics functions while class Font provides information about which font to use to do the conversion.
Following are the useful class messages of Font:
allFonts
Answer an array of all available fonts.
chooseAFont: aTitleString
Open a dialog that lets the user choose a font. Answer an instance of Font.. Argument aTitleString displays as the title of the dialog.
face: aString size: aPoint fixedWidth: bFixedWidth
Answer a font instance whose characteristics most closely match the arguments.
Argument Setting
aString is the face name of the font
aPoint is the maximum width and height of the font
bFixedWidth sets a fixed width font when true
face: aString size: aPoint fixedWidth: bFixedWidth bold: bBold hollow: bHollow italic: bItalic negative: bNegative strikeOut: bStrikeOut underscore: bUnderscore
Answer a font instance whose characteristics most closely match the arguments. This method is similar to the face:size:fixedWidth: method but offers a finer degree of selection.
Argument Setting
aString the face name of the font
aPoint the maximum width and height of the font
bFixedWidth sets a fixed width font when true
bBold sets a bolded font when true
bHollow sets a hollowed font when true
bItalic sets an italic font is when true
bNegative sets a negative font when true
bStrikeOut sets a strike-out font is when true
bUnderscore sets an underscored font when true
Following are the useful instance messages of Font:
deleteFont
Deletes the Windows font handle associated with the instance of Font. Use this method when the instance of Font is no longer needed or when all references to it are about to be removed. Not calling this method for unwanted fonts will leave system resources tied up.
fontHandle
Answer a Windows font handle associated with the instance of Font. Use this method to obtain system font handles needed in Microsoft Windows API calls.
Smalltalk/V uses different cursor shapes to visually indicate system status. For example, the hourglass cursor shape is used to indicate that a computation is in progress. Cursor shapes are also a good way to convey status information about your applications.
The Smalltalk/V cursor is managed by class CursorManager. CursorManager merely provides an interface between Smalltalk/V and the mouse.
Normally when you display something that covers the cursor, you should first hide the cursor; otherwise, cursor writing by the mouse driver may interfere. To simplify this problem, all system primitives that can alter the contents of the screen currently make sure that the cursor is hidden first, and restored after.
For the advanced user, the expression Cursor hide hides the cursor and Cursor display displays it. These two messages work like parentheses: they must be balanced. For example, suppose the cursor is currently being shown; if you hide it twice and then display it once, you must still display it again to Show It. If you are not sure at which level the cursor currently is, and it is not displayed, evaluate the following expression:
Cursor reset
This forces a balance of hide and display and shows the cursor.
To change the cursor shape, simply send the message change to the cursor object you desire. For example:
CursorManager execute change
changes the cursor shape to an hourglass (indicated by 'execute'). If you only want to change the cursor shape temporarily for a block of code, try:
CursorManager origin changeFor: [40000 timesRepeat: [ ] ]
Smalltalk/V includes the following cursor shapes:
Messages to CursorManager Shape
arrow a single-headed arrow pointing northwest
crossHair a crosshairs cursor
execute an hour glass
normal an arrow pointing north west
origin a double headed arrow pointing south west
text an I-beam
To make a cursor shape predefined by the host system available to Smalltalk, do:
CursorConstants at: Cross put: (CursorManager new handle: ( CursorManager getWinCursor: IdcCross)).
And then create a class method in CursorManager:
cross ^Cross
Now you can do
CursorManager cross change
IDcCross is defined in the WinConstants dictionary. Several other cursors are also available, identified by the Idc prefix.