Tools
Contents

The Workspace


The workspace is a simple text editor. It looks like a sheet of paper. Workspaces are often used like paper sheets from a notepad.

A workspace with text and a menu

You can type a Smalltalk expression into a workspace and immediately evaluate it. This feature is very helpful for programming: It gives you a possibility to try an expression very quickly.

The items of the menu:

To change the appearance of a selected piece of text, you use the Alt key (or on MacOS, the Command key) together with an additional key.

control
key
effect
1
select a very small font size
2
select a small font size
3
select a medium font size
4
select a large font size
5
select a very large font size
6
brings up a menu that offers text color and some other options
7
toggles the text attribute bold
8
toggles the text attribute italics
9
toggles the text attribute narrow
-
(minus)
toggles the text attribute underline
0
removes text attributes bold, italics, underline, stroke, narrow

Implementation Notes

The Workspace is implemented in class Workspace, a subclass of StringHolder that adds functionality that is mostly irrelevant for MVC. The edit menu is defined in ParagraphEditor. The definition of the menu can be found in class method initializeTextEditorMenus of that class. That menu is a prebuilt one that is used by all editors that do not provide menus of their own. The instance protocol of ParagraphEditor implements most of the methods that are associated with that menu. Some of these methods are reimplemented in subclasses of ParagraphEditor.

To open a workspace programmatically, you can write:

Workspace open

To open a workspace with a dedicated window title, you write:

Workspace openLabel: 'My Workspace'

To put a string into a workspace before you open it, you write:

 | string |
 string := 'Are you happy with Squeak?'.
 Workspace new
    contents: string;
    openLabel: 'Display a String:'.

It is of course also possible to put stylished text into a workspace. See the page TextStream for a worked example.


Tools
Contents