• Aucun résultat trouvé

System Workspace Tools

Dans le document TEKTRONIX SMALLTALK (Page 79-82)

The System Workspace provides templates for many expressions you may find useful to evaluate.

The following four subsections describe some of the most useful expressions available from the System Workspace.

• The expressions under the heading

Inquiry

inquire about messages, methods, and literals in the system.

• The expressions under the heading

Globals

provide a list of global variables in the Small talk system.

• The expressions under the heading

Display

allow you to manipulate certain aspects of the display.

• The expressions under the heading

Measurements

allow you to ascertain the size or number of certain objects.

In addition, the expressions under the heading

Fonts and Text Styles

provide useful templates for dealing with the appearance of characters in your windows. Consult Section 9 of this manual for further information on this subject.

Finally, the expressions under the heading

Change Management

provide useful templates for manipulating your image and changes files. Consult Section 6 of this manual for further information on this subject.

Inquiry

The following expressions allow you to inquire about the relationships among the objects in the system. Many of these expressions require symbols, denoted by the # sign, as arguments.

Smalltalk browseAlllmplementorsOf: #messageSelector

Replace the word messageSelector with the' message selector you wish to inquire about.

(Leave the # sign.) When you execute the statement, a browser appears containing all objects that implement the specified message selector. This expression is comparable to executing the menu item implementors in the message selector pane of the System Browser.

Smalltalk browseAIICalisOn: #messageSelector

Replace the word messageSelector with the message selector you wish to inquire about.

(Leave the # sign.) When you execute the statement, a browser appears containing all methods that send the specified message selector. This expression is comparable to executing the menu item senders in the message selector pane of the System Browser.

Collection browseAIiCalisOn: #timesRepeat

The message selector timesRepeat is provided as an example. You may replace it with any other message selector you wish to inquire about. When you execute the statement, a browser appears containing all methods in the class Collection that send the specified message selector.

Smalltalk browseAIiCalisOn: #at: and: #atput:

This expression allows you to access information about two message selectors simultaneously.

Smalltalk browseAIiCalisOn: (Smalltalk associationAt: #Transcript)

When you execute this statement, a browser appears containing all methods that reference the global variable Transcript.

Smalltalk browseAIiCalisOn: (TextConstants associationAt: #Centered)

When you execute this statement, a browser appears containing all methods that reference the literal Centered found in the pool dictionary TextConstants.

Smalltalk browseAIiCalisOn: (Object c1assPool associationAt: #DependentsFields) When you execute this statement, a browser appears containing all methods that reference the literal DependentsFields, one of Object's class variables. This expression is comparable to executing the menu item class var refs in the class pane of the System Browser.

Smalltalk browseAIiSelect: [:meth

I

meth numLiterals > 40]

This expression opens a browser on all methods using more than forty literals. Any set of expressions may be substituted within the block. The browser opens on all methods such that, when the block is evaluated with a method as its argument, the result is true.

FileStream instanceCount

This expression answers the number of instances of the class FileStream that exists in the system at the time of evaluation.

FormView alilnstances inspect

This expression creates an inspector on the collection of all the instances of the class Form View that exist at the time of evaluation.

Globals

The System Workspace lists all global variables in the standard image. You can add new global variables to the system by executing the expression:

Smalltalk at: #GlobalName put: anObject

where GlobalName is the name of the new object you have created. GlobalName becomes a key in the Small talk dictionary. (Keys in dictionaries are symbols.)

You can remove global variables form the system by executing the expression:

Smalltalk removeKey: #GlobalName

where GlobalName is the name of the global variable you wish to remove.

A number of global variables are necessary to run the Smalltalk programming environment.

Below, each of these global variables is explained in greater detail.

Disk

This is the Smalltalk home directory. Any files you reference without fully qualified pathnames are treated as relative to Disk. This directory should be different for each image; otherwise, you will have one changes file for two images, which can cause problems. The specific directory each image uses for Disk is set above in the System Workspace, under the heading Create File System. Typing a * in the top pane of a File List matches all the files in your Disk directory.

Refer to Sections 6 and 11 of this manual for more information about the file system.

Display

This is the virtual display (by default 1376 by 1024 pixels). You can make a rectangle flash on the display by sending Display the following message:

Display flash: (1 00@100 corner: 300@300)

Programming in Smalltalk

Other useful messages that can be sent to Display are available from the System Browser, under the category Graphics - Display Objects, class DisplayScreen, instance protocol display functions.

Further messages to send to Display are in the System Workspace under the heading

Display

and described in a later subsection.

FontManager

This is the instance of StrikeFontManager used by the system. It contains instances of StrikeFonts.

A trikeFont contains bitmaps of characters to display on the screen, and information for displaying them. A trikeFontManager is a dictionary containing Strike Fonts.

The FontManager allows you to share fonts among text styles, saving memory. Some fonts may not be loaded into your image yet. If you inspect the FontManager, you see instances of VirtualStrikeFonts indicating unloaded fonts. As soon as you reference them from a TextStyle, however, they are automatically loaded.

Refer to Section 7 of this manual for more information about this.

ImageName

This is the word you enter to invoke your image. It is the string you type in the fill-in-the-blank window when you save your image. The default ImageName is image.

as

This stands for

operating system.

It is a global variable used to avoid references to specific operating systems, for the purpose of enhancing code portability. Messages sent to operating system commands are sent to

as,

which is set to the specific operating system used by your computer.

Processor

This is the scheduler for Smalltalk processes, such as activating a window or determining keyboard events. The Processor schedules higher priority processes preemptively. If you create two or more processes of equal priority, the Processor does not switch between them automatically. One of the processes must specifically relinquish control by sending the message:

Processor yield ScheduledControllers

This is the window manager. It contains a list of all controllers in use by the project. It determines the order in which windows are stacked. The right button menu items under and restore display are implemented by ScheduledControllers.

Sensor

This is the instance of class InputSensor which keeps track of where the mouse cursor is. Some useful expressions to send to Sensor are found below.

Sensor cursorPoint returns the coordinates of the mouse cursor.

Sensor waitButton returns the coordinates of the point where the mouse cursor was when the left mouse button was pressed.

Sensor yellowButtonPressed returns true or false depending on the state of the middle button.

SourceFiles

This keeps track of the source and changes files for your image. It is an array. The first element

points to the source file. The second element points to the changes file.

Style Manager

This stores all available TextStyles. A TextStyle contains an array of fonts used by that style.

It usually consists of two sizes of fonts, each in roman, boldface, and italic. You can access the Style Manager using the right button menu item style.

For more information about this, see Section 7 of this manual.

SystemOrganization

This determines the relationship between the class category and the class panes in the System Browser. If you inspect SystemOrganization, you see a categoryArray, which lists the categories in the leftmost pane of the System Browser. The elementArray lists the classes, in class category order. Stops tells the categoryArray how many classes, incrementally, are in each category.

Transcript

This points to the System Transcript of the current project. For a useful expression template, see the heading Example use of

a

transcript, below the list of global variables in the System Workspace.

In addition to the global variables, Smalltalk has

pool dictionaries,

also called

variable pools.

These are dictionaries containing variables available to a set of classes. A pool dictionary allows methods of those classes quicker and easier reference to all objects in that dictionary. Some important pool dictionaries are described below.

• Smalltalk is a pool dictionary available to the entire system. It stores all classes, global variables, and pool dictionaries. The compiler looks objects up in the Smalltalk dictionary.

• Undeclared is a pool dictionary containing any undeclared object. For example, if you file in a new method containing a name the system does not understand, the system places it in the Undeclared dictionary.

Display

The following expressions allow you to manipulate the display.

DisplayScreen displayExtent: 1376@1 024

Make the virtual display 1376 by 1024 pixels. This is the default size. If you are using a machine with a smaller screen, you must pan to see the full display.

DisplayScreen displayExtent: 800@800

Make the virtual display 800 by 800 pixels. Using this expression template, you can make the display any size you wish.

NOTE

If you make the display too small to pop up a menu, you will be

Dans le document TEKTRONIX SMALLTALK (Page 79-82)

Documents relatifs