If you are new to Smalltalk/X, or even new to Smalltalk, please take a few minutes, to read this document.
"smalltalk"
(or "stx"
)
at the Unix (or Windows) prompt.
If you downloaded the developer's package,
and did not install ST/X in a standard place,
you will have to change the directory first:
On most Unix systems, the current directory is not in the PATH,
and you have to type "
% cd projects/smalltalk
% ./stx
<some info messages>
reading 'private.rc'...
starting Launcher...
./smalltalk
" or "./stx
".
For historic reasons,
the IDE is found in the "projects/smalltalk
" subdirectory.
One reason was that there are multiple pre-compiled Smalltalk applications found under this
folder.
Beside the actual IDE, there is a stand alone webserver (which serves the eXept web site),
a tinytalk, which is a smalltalk without UI classes, and other helloWorld-like demo programs.
You can ignore all those others and only care for "projects/smalltalk
".
The "smalltalk"
command found there is actually a little shell script,
which sets up the LD_LIBRARY path (so the class libraries, which are the libxxx.so files, are found)
and calls the real executable "stx"
.
If your path and ld-library path settings are correct, you can call "stx"
directly (if not, try "export LD_LIBRARY_PATH=."
before).
On most systems today, the LD_LIBRARY_PATH already includes the current directory,
and "stx" command works out of the box.
Of course, you can also double-click on the icon in the K-, Gnome or Windows desktop or file manager.
Windows-users will find two executables: "stx.exe"
and "stx.com"
.
The difference is described below.
Mac OSX users will almost certainly get a message like "stx not found".
This is because the current directory "." is not included in the shell's PATH variable.
Please try "./stx
" then.
"smalltalk.rc"
,
which consists of regular Smalltalk expressions in
fileOut-format
(i.e. Smalltalk
expressions separated by an exclamation mark '!').
"/opt/smalltalk/lib"
or
"/usr/local/lib/smalltalk/"
under Unix
and "\Programs\smalltalk\lib"
under MSDos).
After setting up various defaults (keyboard maps, function keys, view style etc.),
this script finally starts up a
Launcher
and a
Workspace
window.
The Launcher provides menus and buttons for the
most common actions and also a
Transcript
view, which plays the role of a Smalltalk console
where relevant system information is shown (for example: info and warning messages).
Other tools which can be opened via the Launcher's menu and toolbar
are described in more detail later.
When you are new to the system, you probably do not want (need) to modify those startup script files - the setup done there should be perfect for most users.
However, you can of course modify the startup scripts according to your personal preferences and/or add your own startup tools there.More info on these script files and startup actions is found in the documents ``Installation'' and especially in ``Configuration & Customization''.
stx.com
" and "stx.exe
".
The first ("stx.com
") is a console application, which shows a command-window into which trace and debug
info is written. It is also used to communicate with the user in case of a hard internal
error, if the graphical debugger is no longer working, or if ST/X has been built without
graphical debugging support.
The second ("stx.exe
") is a non-console application. If it ever encounters problems, there
is no way to communicate with the user, and it will finish (just like all other windows
applications do).
However, it does write its diagnostic output to a log file
(defaults to "smalltalk.log
", unless suppressed by a
command line argument).
An attempt to close the launcher window (via the windows close-button) leads to a confirmation dialog. This gives you a chance to either stop Smalltalk (and close all of its windows) or to only close the Launcher (and leave other windows open).
You can also type "CTRL-C" at the command propt, where "stx" was started (if it was actually started via the command line). Then, you will get into a mini debugger, which is described below.
It is recommended, that you save a snapshot image in regular intervals (whenever some work has been done). However, it is non-fatal if you do not, because ST/X logs all your programming work in a so called "changes file", which can be replayed (loaded). So even if you do not have a snapshot, it is quite easy to get to the state before, without loosing any of your work.
You may of course have multiple snapshot images around,
either to separate projects, or to be able to quickly return to
various previous states of your work.
Use different and meaningful names for the snapshots.
Please notice, that ST/X does not need an image!
It can (and usually is) started without a snapshot image. All classes and objects (i.e. views,tools etc.) are created and initialized during a normal (non-snapshot) start by sending the "initialize" message to every loaded class, followed by the UI startup, which is actually controlled by a script file.
"st.img"
(in the current directory
or your workspace directory under "~/.smalltalk")
and, if present, loads the state found in this file.
If not, a normal "clean start" is performed.
If you saved your snapshot under another name, start Smalltalk/X with an image (-i) argument
as in:
If you want to start Smalltalk/X from scratch,
ignoring any existing snapshot image,
use the ignore (-I) flag, as in:
stx -i <nameOfImage.img>
Hint/trick:
stx -I
On Unix systems, you can also change the permissions of the snapshot file
to be executable (i.e. "chmod +x st.img
") and
make certain that a Smalltalk/X executable is found along the path
by the name "stx"
.
Then, the snapshot file can be restarted simply by entering its name
to the shell prompt.
You can also rename the snapshot image to whatever name you prefer
(such as "myImage"
), and make it executable.
This allows startup of an (application-) snapshot image simply by
its name.
On modern graphical operating systems, you can also drag the icon, which represents a snapshot file, on your desktop over the Smalltalk/x icon, or double-click on a snapshot image icon.
All of the "VM-Arguments" must occur before any command line
arguments for the Smalltalk application (the "Non-VM-Arguments").
The runtime system's command line parser stops after the last
recognized VM-argument or when it encounters a "--
" argument (two dashes)
and passes the rest to the Smalltalk system (or a Smalltalk application),
where it is available as "Smalltalk » commandLineArguments
".
(also use "--
" to pass an argument which conflicts with a VM-option's name to your program)
When ST/X itself is started (i.e. the IDE),
the startup method which gets the initial control and
which does command line argument parsing
is "Smalltalk » start
".
When a standalone application is compiled and linked
(eg. using the ProjectBuilder),
the application's startup-class as specified in the project definition is responsible for this
(see the "StandaloneStartup
" class for an example).
-i
<snapshotFileName>
-I
--help
--noLog
--logFile
<fileName>
--noBanner
--infoPrint
--noInfoPrint
--infoPrint
".
-Tinit
stx --help
" to get a full list.
--quick
(-Q)
--quick
" option still suppresses the license confirmation banner.
--packagePath
<dir> (-PP)
--load
<file_or_package> (-l)
--noAutoload
--autoload
--verbose (-V)
--debug
--silent
--logFile
<fileName>
--logLevel
<level>
--logColor
<true/false>
--ignoreHalt
--ignoreAssert
--noShellArgs
For scripting, it is recommended to install ST/X at a standard place
("/usr/local/bin
", "/opt/smalltalk
" under Linux/Unix/OSX,
or "c:\Programs\SmalltalkX
" under Windows),
and to make sure that the ST/X executable's folder is in the path.
Then scripts can be executed on the shell level with "stx
" or
the script's name (as described below).
The scripting options imply a "--silent" option behavior; this means that no diagnostic output is generated (unless you reenable it via an option and of course except output which is generated explicitly by the script).
The individual scripting options are:
--file
"<fileName>" ( -f for short)
--eval
"<st-expression>" ( -E for short)
--print
"<st-expression>" ( -P for short)
--filter
"<st-expression>" ( -F for short)
--filter
"<expr1>" "<expr2>" "<expr3>" ( -F for short)
--run
"<packageName>"
--run
"<className>"
stx -I --run foo:dir/package
" will load the package "foo:dir/package",
then call the "main" method of foo_dir_package .
stx -I -l MyClass.st --run MyClass
" can be used to
load and run a class's "main" method as a script.
stx -I -l my/package/app --run MyAppplication
" would load
first a package (probably as a binary compiled class library) and then start the main method
in the MyApplication class (which ought to be in that package, of course).
--scripting
<portNr> [ --allowHost
<host> ]
-i
" argument is given,
no image file is automatically loaded
(i.e. a "-I
" argument is not required);
_$0
" - the command's name
_$n
" - the number of arguments on the command line
_$1
" .. "_$<n>
" - the command's arguments (up to <n> arguments)
_$$
- all of the command's arguments (as a collection)
Unless they open up a UI and a Transcript window, the global "Transcript" is bound to "Stderr", so the normal "Transcript show:" and "foo transcribe" constructs will send the output there, and pipes to stdout still work without being polluted by debug messages.
One possible pitfall is the encoding of output: by default, ST/X will expect input and output to be UTF8 encoded,
which may or may not be the case in a Windows command window.
We may add an automatic mechanism for that in later versions, but for now its best to
explicitly state the encoding, by adding two lines such as:
possibly wrapped into an if (i.e. Stdout := EncodedStream stream:Stdout encoder:(CharacterEncoder encoderFor:#'cp850').
Stderr := EncodedStream stream:Stderr encoder:(CharacterEncoder encoderFor:#'cp850').
OperatingSystem isMSWindowsLike ifTrue:[...]
.
Sorry for the inconvenience, but we were not aware of this problem before (and you won't, unless you use scripts
outside the US ;-)
A possibly better solution is to leave the script as is, and instead add a batch file, which changes the encoding of the terminal in the command executes (although, that may lead to trouble with other commands running there - sigh)
stx -E "Delay waitForSeconds:1"
- same as "sleep 1"
stx -P "Smalltalk versionString"
- prints the ST/X version string"
stx -P "Float pi"
- print pi
stx -P "LargeFloat pi printfPrintString:'%.50f'"
- print pi with higher precision
stx -P "4567 * 8975"
- compute and print result
stx -P "a:=4567. a*a*8975"
- compute and print result (the variable "a" is automatically defined)
stx -P "100 factorial"
- compute and print result
stx -F "line asLowercase"
- converts its input to lowercase output (up to an EOF)
stx -F "count := 1" "count := count+1" "count printCR"
- counts the number of lines of its input (up to an EOF). I.e. this is the same as the "wc -l" command under Unix.
stx -E "Workspace open"
- opens a Workspace window
stx -E "WorkspaceApplication open"
- opens a full blown Workspace application
stx -E "Smalltalk loadPackage:'myPack'. MyApp open"
- loads a user package (typically from a binary compiled class library) and runs it
stx --load "myPack" --run "MyApp"
- does the same as above, but is less cryptic
File "hello.stx
":Execute with:
#!/usr/bin/env stx --script 'hello, word' printCR.or even better with:
> stx --script hello.stx
> chmod +x hello.stx > ./hello.stx
File "script1.stx
":Execute with:
#!/usr/bin/env stx --script 1 to:10 do:[:i | 'the factorial of %d is %d\n' printf:{ i . i factorial } ].or even better with:
> stx --script script1.stx
> chmod +x script1.stx > ./script1.stx
File "script2.stx
":Execute with:
#!/usr/bin/env stx --script Workspace open.
> chmod +x script1.stx > ./script2.stx
File "script4.stx
":Execute with:
#!/usr/bin/env stx --script 1 to: (_$1 asInteger) do:[:i | 'the factorial of %d is %d\n' printf:{ i . i factorial } ].
> chmod +x script4.stx > ./script4.stx 25
Stdin request:prompt.
Stdin confirm:prompt.
--debug
" option (before any -P/-E option).
To get a walkback, add a "--debugPrint
" or "--verbose
" option.
The following examples demonstrate the error behavior (in this case, a division by zero error):
stx -P "1 / 0"
prints an error message
stx --debugPrint -P "1 / 0"
prints an error message plus walkback
stx --verbose -P "1 / 0"
the same
stx --debug -P "1 / 0"
opens a mini debugger
stx --silent -P "1 / 0"
just returns an error-exit code
--repl
" (or "-R
" for short) command line argument starts a read-eval-print-loop,
in which expressions can be evaluated in an interactive line-by-line mode.
Long evaluations or endless loops can be stopped by presing CTRL-C, which gets you into
a MiniDebugger, and the evaluation can be aborted with the 'a(bort)' command.
The repl will auto-declare undefined variables as workspace variables,
and their values will be retained between evaluations
(like in a Workspace, with the "auto-define-as-Workspace-variables" option enabled).
The previous expression's value is available as "_0
".
The input can be either in traditional chunk file format or in a special repl-format, where chunks are separated by either an empty line, or a line ending in a "." character (if you want to enter more text, add a space character after the period).
By default, the repl is in non-chunk mode.
While reading, lines beginning in a "#"-character are treated as directives:
#help
(or "?"
)
#use
<packageName>
#show [all | variables | processes | memory | packages | modules | flags]
#set / #clear
<flagName>
timing
" and "profiling
".
Type "#help
" to get a list of flags.
#apropos <keywordPattern>
show class names and selectors which match the keyworPattern (GLOB search)
#list <className> [ <selector> ]
show the class definition and comment or the source code of a method
#read
<fileName>
read another script file in chunk format,
or in repl-format (if a line beginning with "#" is encountered in the file).
#edit [
<className> [
<selector> ] ]
open an external editor on a class or individual method.
Without an argument, the last edited item is edited again.
The editor can be specified in either the shell environment
variables "STX_EDITOR
" or "EDITOR
",
or via the "#set editor path-to-command
" directive.
#ide
enter the ST/X IDE (opens a Launcher).
Control is returned to the REPL when the launcher is closed.
#break
<className> <selector>
set a breakpoint.
#delete
<className> <selector>
remove a breakpoint.
#exit
(or EOF)
exit the read-eval-print loop.
#set debugconfirm false
").
You can also completely disable the debugger ("#set nodebug
");
if disabled, the cause of the error is printed,
and the REPL continues reading the next command/expression.
By default, the REPL shows a hello message, and both command prompts and answer prompts.
Give a "--silent
" (or "-q
") option to disable the hello message and answer prompts
(ST/X will behave similar to GNU Smalltalk then).
The answer prompt can also be changed by "#clear answerprompt
".
Type "#show flags
" to see more options.
Example Session (user input in bold):
--noShellArgs
" option is not present, the value of this
shell variable is prepended to the list of arguments.
--autoload
" option.
The following chapter describes the old behavior.
When started without a snapshot image, Smalltalk/x first does a recursive scan of all directories below the stx-top directory for autoloadable packages. This is done for your convenience, so that many tools, demos and other support classes are already present as autoload-stubs in the class hierarchy. Autoloaded classes are simple proxy objects which perform an on-demand lazy loading of missing code for you.
This recursive scan can be somewhat slow if many directories are present or the filesystem
is slow (on a network drive). It is therefore often useful to start the system without
autoloaded classes, and load missing packages either via
the launcher's file menu, pr programatically with
or by opening a fileBrowser on a directory and applying the "Install Autoloaded Classes" menu function
on it. Also, the system workspace includes a page with useful package-loading expressions.
Smalltalk loadPackage: <packageID>
To start ST/X without autoloaded classes, use the "
Motivation for no longer making this a default behavior:
You should be aware that the debugger is one of your best friends in the Smalltalk IDE.
In contrast to other programming languages, getting into the debugger is far from
being fatal in Smalltalk. In fact, many Smalltalk programmers place breakpoints into
as yet unimplemented branches of their source, and develop the program almost exclusively
inside the debugger, by adding the missing code, as the halts are reached.
This ensures, that all of the code has been reached at least once and has already
been tested at least once when the coding is complete.
The most useful button actions are:
The terminate function is disabled,
if the affected process is the scheduler or the event dispatcher process
(since if those were terminated, proper operation of the system
would no longer be possible).
There are many other button and menu functions in the debugger.
Read
``Using the debugger''
for more information.
Hint:
You can also type the interrupt key "Break/Pause" in any view,
to force the corresponding view-process to be interrupted and to enter the debugger.
Thus, to interrupt an ongoing doIt, simply press "Break/Pause" into the
workspace window. If your keyboard does not provide such a key, try "CTRL-." which
is provided as an alternative (and is also compatible to other Smalltalk system's interrupt key).
Finally, pressing "CTRL-c"
in the terminal (xterm- or console) window where Smalltalk was started,
forces a hard-interrupt, which interrupts any running process -
even the scheduler, event dispatcher, other system process.
This will usually bring you into a so called "Minidebugger" (see below),
a very simple command line debugger.
If ST/X does not even respond to "CTRL-c"
in the terminal window, try quickly pressing it twice or more times.
The Minidebugger is especially useful to leave endless loops in
undebugged user primitive code or if you made a mistake in changing some system code.
On some Unix systems, this interrupt key is labeled "INTR"
or "DEL".
Notice, that you can have multiple debuggers open at the same time,
operating on different processes.
However, only one so called "modal debugger" may operate on
the scheduler or event dispatcher process. Pressing the interrupt key
in the terminal window will usually bring you into a modal debugger.
or evaluate one of the following in a workspace:
The "CTRL-Break" key handling is a functionality of
the Smalltalk event handler - it does not work in the terminal window.
(Notice: in previous releases, this function used to be on the "Ctrl-y" key-combination.
This has been changed to conform to standard conventions. "Ctrl-y" now means "redo")
The system considers errors occuring in the graphical debugger itself as serious.
For example, if you have changed the Scrollbar class which
is also used in the debugView, or if any other error occurs while
the debugView is initializing itself.
You may also get into the MiniDebugger,
if you press "CTRL-C" in the
terminal window.
If all of the above fail, you should exit Smalltalk, restart from a previously saved image and
reapply any changes using the ChangesBrowser.
The MiniDebugger also offers two commands for emergency
saving: "S" to save a crash-image,
and "C" to save your session changes into a separate
changes file.
The crash image can be browsed later with the snapshot image browser,
or you can try to restart it (although that will likely fail).
In rare cases (other Smalltalk processes are running, and the scheduler
suspended the debuggers process),
the MiniDebugger may seem to not react to your input.
The menu's entries depend on the type of view and often on the
context or type of object/text being displayed.
Typically, it offers operations on the contents or the current selection.
Some views offer an extra control-middleButtonMenu,
which is activated if the "CTRL" key is
pressed simultaneously with the mouse button.
Of course, moving the text-cursor in a textView or moving the selection in a list-view
via the cursor keys also leads to a scroll operation if required.
Pressing the left mouse button again makes the system forget the
old selection and start a new one, except when you
press the "SHIFT" key while pressing the button.
There are two ways to extend the selection with "SHIFT":
It is also possible to move the mouse pointer out of
the view, while the mouse button is kept pressed.
The view will then start to automatically scroll.
The farther away you move the pointer from the views border,
the faster will it scroll.
This is the easiest way of selecting text:
just let it scroll by and stop when the end-position arrives.
If you keep the button pressed and start to move
after a double click, it continues to select whole words;
moving after a triple click continues to select whole lines.
This rule also applies when extending previous word or line
selection with a SHIFT click.
If you double click one of a parenthesis, bracket
or brace, the text up to and including the
matching one is selected.
Notice, ST/X differentiates between two types of selections:
There are also two convenient keyboard shortcuts
(*)
for selecting:
Especially when new to the system, this may be a bit confusing.
Most editors allow you to type in changes in a modeless fashion
anywhere on the editors window area
(i.e. there are no invisible and hidden tabulators or end-of-line characters
embedded). Like on a piece of paper, you can position the text-cursor whereever
you like, and start typing text.
The editor will insert blanks or empty lines automatically, as required.
This behavior can be turned off by checking the "ST80 Cursor Behavior"-flag in the
("Settings" - "Tools" - "Editor")
settings dialog.
The opposite of "accept" is "cancel". This will undo you changes
and revert back to the last saved ("accepted") version.
As an option, the class browser adds two buttons to its code-editor window.
These allow for very quick "accept" or "cancel".
Also, they give a very prominent feedback on the modification state of the text.
If you press the "Shift" key in addition
(i.e. "CTRL-SHIFT-V"), a list of previously
copied text fragments is shown, from which you can choose the
text that should be pasted ("copy history").
Cursor positioning:
Function-keys
(these are configured during startup, by the "keyboard.rc" script-file):
Notice that most programmers prefer "as you type" completion hints,
which shows possible completions automatically.
Enable this via the Launcher's
"System" - "Settings" - "Tools" - "Editor" settings dialog.
No change in the text will have any permanent effect,
unless you accept the new text.
Thus, to revert back to the original code in a system browser,
simply reselect the method again.
Please read
``Keyboard commands''
in ``Configuration & Customization''
on how to add/change function keys settings.
Especially, if your window manager (motif) catches some of these keys
for its own window operations, you may have to change (some of) these
settings. (i.e. use "CTRL" instead of "CMD").
In addition to using (and defining keys for) those builtin functions,
it is also possible to define your own text or action macros.
Read ``Keyboard macros''
in ``Configuration & Customization'' for more info on this.
As opposed to many other (Smalltalk-) IDEs,
we prefer a fixed-width font for code,
as it makes tabular data much easier to look at
and leads to a more consistent indentation.
Therefore, the default is set to a fixed width "Courier" font.
If you don't like this, please change it via the Launcher's settings dialog
("Settings" - "ViewStyle" - "Font").
To change an individual editor's font (i.e. one which is already open),
open its font selection dialog via the "Other" - "Other" - "Font" - popup menu item.
In addition, "SHIFT-CTRL-+" and
"SHIFT-CTRL--" will change the font sizes of ALL text views.
If you don't like this behavior,
define an additional pair of tabbing keys, to function as (alternative)
"FocusNext" and "FocusPrevious" keys.
A dialog can be quickly closed (cancelled) with the "Escape" key.
Notice, that an explicit focus-assignment (eg. via tabbing) is never changed by simple mouse movements.
The middle button menu's doIt function does
this; it parses the selected text (i.e. checks it for being a correct
piece of Smalltalk code) and silently evaluates
the corresponding Smalltalk expressions.
To try it, open a workspace and type (or copy-paste from this example):
Unless the expression does some printing itself (as in the first two examples),
the result of the evaluation is not shown anywhere.
Finally, inspectIt opens an inspector window
on the result, where you can have a look at the resulting
object in more detail.
Also notice that all keyboard shortcuts are defined in the startup
scripts (usually in "
To see the contents of a file, double-click on its name
in the fileBrowser's top list. Also directories are changed in this way.
More info on the fileBrowser is found in
``Using the FileBrowser''.
Non-graphical classes should work (almost) unchanged even if they originated from
these systems - if you find interesting code on an ftp-archive,
you may also try to fileIn this.
Although ST/X was written to be protocol compatible to other Smalltalk
implementations (i.e. ANSI-Smalltalk), most classes were implemented differently and internals are
completely different.
Loaded code depending on such internals may not work as expected.
In practice, most non-graphical classes work unchanged;
however, if a loaded class depend
on a particular superclass implementation (accessing instance variables),
or superclass hierarchy (accessing superclasses by name),
this may not be true. In this case, you should open a Changes Browser
on the source file, and apply individual changes one-by-one, to see where
problems arise.
Packages from Squeak/Pharo can also be imported in their native Monticello package format;
for this, use a "Monticello Browser".
Start by examining existing simple demo programs (such as
the ClockView, TicTacToe, PenDemo etc.
More info on the System Browser is found in
``Using the SystemBrowser''.
For a rough overview of what is there, read
``Basic Classes Overview''
and start excursions to the classes encountered there.
Getting more used to the language, try creating a little graphical
application or a web service.
Read and understand the coding examples found in the directories
(**) command key
Notice that some window managers catch some
command-key combinations themselfes - NOT passing those key events to
ST/X
(this is especially true for motif's mwm and fvwm,
and for MacOSX, where some CTRL-key combinations might be used for desktop operations) .
If this is the case with (some of) your keys,
you may either disable the window manager's key functions (in the wm's resource file)
or change the settings
(in your
Most of the window manager's key functions are hardly ever used if you have a mouse
hooked to your system - so it may be preferrable to disable those,
instead of
redefining ST/X's key mapping.
--quick
" command line option.
Because autoloading is only possible
in the IDE (where the classes source code is accessible), but not for standalone applications,
a common error situation is to access or depend upon classes which were originally autoloaded,
but not binary-compiled into a classLibrary-dll. So during development in the IDE, these classes
were present and everything worked fine.
On the other hand, it lead to a runtime exception in the deployed application.
Therefore, it was recommended to always use the "--quick
" option during development,
so the programmer got informed about any missing class.
We thought, that it is better to avoid such mistakes right away.
Autoload Command Line Option (--autoload)
This option forces the old behavior, where the whole directory tree is scanned for autoloadable classes.
This used to be done automatically, but turned out to become both unreasonably slow and
dangerous.
Please compile any of your classes into packages and load packages.
This is both much faster,
and also less error prone (read the argument above).
If you need the old (scanning) behavior, use the "--autoload
" command line argument.
The Debugger
Leaving the Debugger
Whenever some error occurs in Smalltalk, or a breakpoint is encountered,
a debugger window pops up (or a MiniDebugger, if scripting),
which shows where the error occurred
and how the system got there (this is called a backtrace or walkback).
Since you may sooner or later get into the debugger,
it is useful to give a brief description of how to get back to your normal work.
The debugger's actions are controlled by a set of buttons, a main menu,
and a popup menu in the walkback view
(for the less frequently used functions).
A close of the debugger-window via the button in the window-title area,
or the window manager has the same effect as "Abort".
execution continues at some save place in the interrupted process.
The definition of what a "save place" is,
depends on the process: for UI processes (such as workspaces, launchers
etc. ) it's usually the place where input events are read.
(To Smalltalkers: technically, an AbortOperationRequest
exception is raised,
for which a handler exists in the window's main event loop.)
(To C-talkers: this is kind of a longjmp back to the
window's main eventloop.)
the debugger will be closed, execution continues where it
was interrupted.
This will often trigger other errors and
bring the debugger back again, if the error occurs in a loop,
or if the followup processing gets confused by the first error.
(for example, if the error was an unimplemented message
send, the continue-function will continue
as if the method was a no-operation and returned nil,
which is often not what the caller expected.)
Notice that not all exceptions are proceedable. For a non-proceedable exception,
the "Continue"-button is disabled and you have to "Abort" instead.
this will terminate the process (thread) in which the error occured.
Usually, there is one process associated to each toplevel window
on the screen. Pressing terminate shuts down this process
and closes all of its views.
Therefore, if an error occurs while evaluating a
doIt in a workspace,
the terminate function will abort
the processing, terminate the process and close the
workspace as a side effect.
single-step to the next line ("Next") or message send ("Step") in the
selected method.
In contrast to the "Send"-button, these step over any code in called methods (unless another error or halt is encountered).
The debugger will regain control after the step, and show the
current line, the position of the next message send which is about to be executed.
"Next" and "Step" always operate on the currently selected context in the top list.
By selecting the "about to be executed method" in the walkback,
you can continue stepping in this called method.
By selecting a context further up in the calling hierarchy (i.e. further down in the list),
a caller can be stepped.
restarts the selected method from the beginning. This is especially useful after a code change
in that method, or in one of the methods called by it.
When you are new to the system, you probably should not care about
all of those options;
simply press Abort or the close-button in the windows title area
to get out of the faulty computation.
Entering the Debugger
The debugger can be entered either due to an
unhandled error
(such as division by zero, or array bounds check etc.)
or by an explicit request
such as sending a halt
-message to an object or
a code breakpoint.
(The key used to be "Ctrl-c" in previous Unix versions,
but has been changed to have a unified keyboard mapping across systems.
"Ctrl-c" is now copy on all systems.)
If "CTRL-c" does not work in your xterm,
read the Unix manual page on the `stty'
command for details.
or
self halt:'stopped for debug'
|someVariable|
someVariable := 0.
Transcript showCR:(5 / someVariable)
Aborting without Entering the Debugger
If you simply want to abort some ongoing operation in some view
(for example, a long evaluation in a workspace, or a file-load operation
in a Filebrowser), you can also type "CTRL-Break".
This also interrupts the process in whatever it is doing, but
aborts the operation without entering a debugger. I.e. this is equivalent to interrupting the
program, followed by the debugger's "abort".
(for experts: an AbortOperationRequest exception is raised, instead of UserInterrupt)
Leaving the Low-Level Emergency (Mini-)Debugger
Whenever a serious error occurs within the graphical debugger itself,
or when an error occurs during startup (before the GUI has been initialized),
or if an error is encountered in a deployed non-GUI standalone application,
or in scripting mode,
you may find yourself in a line-by-line debugger called the MiniDebugger.
This MiniDebugger allows for some limited debugging without using the graphical user interface.
The "Q"-command (quick terminate process) terminates the current
process without any cleanup actions being performed - this may leave dead windows on your
screens which have to be manually destroyed (use the Launcher's tools-destroy view menu function).
Be aware, that this may also leave files open and semaphores locked.
So this should be used wth great care.
If this happens, press the interrupt key again (as described above) and try again.
The interrupt should reenter the MiniDebugger in an exclusive
input mode and stop any scheduling of other processes.
Editing
PopUp Menus
Most views offer functions via a PopUpMenu.
This menu is activated by pressing the right mouse button in the view.
(Historically, it was located on the middle mouse button, and is therefore
sometimes referred to as middleButtonMenu;
However, this naming is historic. You can customize your mouse buttons,
if you don't like this. Left-handers typically prefer things to be vice
versa).
Read ``Configuration & Customization''
on how this is done.
These control menus provide additional functions - which are
either seldom needed
or perform ST/X's developers hidden private goody operations ;-).
However, they may be useful for others too - try the control menu
in the browser's code view or its class list (select a class first).
Scrolling Text
Scrolling using Scrollbars
The scrollbars shown beside the actual text work
as usual, however, they provide the following special
behavior:
(see more on text positioning in the section on keyboard commands).
Pressing "SHIFT" speeds up the autoscroll a bit
Scrolling using the Mouse-Wheel
If your mouse has a mouseWheel, the scroll amount can be adjusted via the control-
and shift keys as follows:
Scrolling using Cursor-Keys
Text-windows can also be scrolled
by pressing the "CTRL" key together with a cursor key.
Mini Scrollers
Some views which are considered to be less likely to be scrolled often,
show a mini scroller. These are thin scrollers, without buttons.
They are typically shown in selection lists
and require less valuable screen space. Otherwise, they behave like regular scrollbars.
Selecting Text
Text is selected by multiclicks or by moving the left-mouse button while keeping it pressed:
The current selection will be highlighted.
In this case, the current selection will be expanded.
You can expand a selection at any time, even if you
leave and reenter the view containing the selection.
It is therefore possible, to scroll the view (using
the scrollbar) or perform any other function (page-up
or page-down), required to make the desired end-position
visible. A selection can be expanded in both directions,
any number of times.
*) note: in previous ST/X versions,
the SHIFT-click behaved like the SHIFT-CTRL click behaves now.
This was inconvenient, when eg.
selecting a literal array or similar parenthized text
in the code piece of code and then need to extend that to include
the hash-charcter before the left parenthesis.
(this might sound strange, but is quite common when editing
Smalltalk code).
changes either end of the selection; i.e. if
you click before the previous left end of the selection, the left end
will be moved to the click position,
if you click after the right end, the right end will be moved.
retains the previous initial click position
and changes the selection's other end position.
The behavior is as if you released the mouse button
at this new position when you did the initial selection using a mouse move.
These behave different, when a key is pressed or text is pasted:
a user selection is replaced by the characters entered at the keyboard, or
by pasting text from the clipboard.
In contrast, already pasted text is not again replaced; instead, new text
as entered or pasted is inserted behind the selection.
(allowing for multiple paste operations to be performed).
In some viewStyles, pasted selections are shown in a slightly different color,
than regular selections.
Notice:
to select the whole text (same as quadruple-click)
to select from the beginning of the line up to
the current cursor position. (Thus to evaluate
something in a workspace, you have to press two keys only:
"ESC" followed by "CMD-d".)
In Smalltalk, selecting has always been a
separate action than copying. To copy something into a buffer,
you first have to select the text then do a copy
action.
In contrast to that, X-Window's xterm and toolkit views use
a different style where select and copy are combined;
whenever text is selected, this is automatically placed into
the copy buffer.
(My personal feeling is that X's behavior is a result of a poor
design, which was later made a ``feature'' - especially with the newest
xterms, where you have to press "SHIFT" in addition,
making things even more confusing ;-)
Editing Text
All views which show text allow you to perform the usual
functions via their middleButtonMenu or keyboard shortcuts
(also called "keyboard accelerators").
Because all text views are based on a common EditTextView class,
the behavior of all of them is similar.
Special Characters
Special characters, such as math, greek, arrows and other characters which are
not found on the keyboard,
can be entered via a special-character window, which is opened via the popup menu
("Other" -> "Special Characters").
This window behaves like a keyboard: click on a character to get it inserted into the text.
Notice, that most fonts do not contain glyphs for all characters.
Such characters will be displayed as a fallback (default) character, which is typically
a rectangular empty box. However, even if not drawn correctly, the text will contain
the corresponding character, and will be displayed correctly, if a proper font is chosen.
Accepting
Text is usually not stored (or installed), until "accepted".
What exactly "accept" means depends on the context: in a file-browser,
it means that the changed contents is written back to the file. In
a class-browser, it means that the changed code is compiled and installed.
Keyboard Accelerators / Function Keys
Notice that the function key mapping may be different on some systems.
If in doubt, open the "Settings"-"Keyboard-Mappings" dialog in the launcher.
This shows a list of the actual mapping. Also, it is controlled by two files which are
consulted during startup ("keyboard.rc" and "keyboardMacros.rc"), which can be changed and reconsulted, of course.
Some keyboards (for example on Sun workstations) provide
function keys labeled "copy", "cut",
"paste" and so on.
These keys should also behave as expected (this depends on your startup file).
the selected text is copied into the copy-paste-buffer.
This also places the selection into the display's clipboard,
to allow pasting it into a non Smalltalk (xterm) view.
the selected text is deleted.
The text is also copied into the copy-paste-buffer
and to the display's clipBoard.
the contents of the copy-paste-buffer is inserted at the
current cursor position. If there is currently a selection,
the selected text will be replaced.
This also pastes selections from other (xterm) windows.
joins the cursor-line with the next line at the current cursor column.
(i.e. the rest of the line after the cursor is deleted).
opens a panel to start a string search. The entered search string
and case-ignore-mode are remembered for followup "Search forward"
and "Search backward" operations (see below).
The dialog also offers an option to replace matching strings by another string.
search forward in the text, and position the cursor to (and select)
the next occurrence of the search-string.
The search-string is either the current
selection or - if there is no selection - the last search string
entered into the search-string box.
Thus, to search for the next occurrence of some word under the cursor,
select it and type "CMD-f".
search backward in the text, like above, but search backward.
selects the word under the cursor, or the whitespace between
words, depending on the character under the cursor.
A word is defined as any sequence of alphanumeric characters
delimited by separators. If there is currently a selection,
the next word or whitespace is selected.
opens a box to ask for a line-number and positions the cursor to that line.
undoes the effect of the last text-modification(s).
Every editor keeps a (possibly unlimited) undo list.
This list remembers all changes made to the text and allows for undo/redo of edit modifications.
The redo function is found in the textview's popup-menu (under the "others"-submenu).
The undo list is cleared whenever the text is "accepted" (see below)
(i.e. a files text is written back or a methods code is saved).
undoes the the last undo.
these change the font size of the view (which has the focus).
With "SHIFT", the font size of all views is changed.
(read more in "Changing the Font" below).
Other functions which affect the cursor position:
position the cursor to the begin of the current line.
If the line is indented (i.e. spaces at the beginning),
and the cursor was positioned after the first non-space character,
the cursor will be moved to right before the first non-blank character.
Otherwise, the cursor is positioned to column 1.
position the cursor to the end of the current line
position the cursor to the beginning of the next word.
Numbers (i.e. digit sequences) are treated like words.
Other characters (punktuation) are treated like single-character words.
similar to the above. However, the cursor
is first moved to the end of the current word.
Then, the next press moves it to the beginning of the next word.
Useful especially in a keyboard macro, to position the cursor to the end of a word.
position the cursor on the matching parenthesis.
The definition of what matching parenthesis are
depends on the editor's (programming-) language setting.
Usually, this will be Smalltalk-mode, where "()", "[]" and "{}"
are defined as pairs.
However, the editor of a filebrowser uses the mime-type of the
edited document to define those pairs.
So, for example when editing HTML or XML, "<>" are also defined as matching pairs.
however, if there is a line-selection (i.e. a full line or a number of full lines),
SHIFT-Tab will undent by 4 (remove 4 leading spaces).
Unshifted, the Tab-key will indent the selected lines by 4 spaces.
when first pressed, move the cursor to the first visible line.
If pressed again, move it to the very beginning of the text.
when first pressed, move the cursor to the last visible line.
If pressed again, move it to the very end of the text.
The following keyboard command is available in views
which show code (i.e. browsers) and the File- and ChangeBrowser:
Which object is to be renamed depends upon the view in which you pressed the key.
In a fileBrowser, the currently selected file(s) is/are renamed.
In a systemBrowser, the class, method or selected variable is renamed.
comment the selected (Smalltalk-) code.
If the selection is a "full-lines-selection", an End-of-line comment is used.
If the selection is a single word, or spawning multiple lines but not covering full first and last lines,
a regular comment is used.
If nothing is selected, the current cursors line is commented.
uncomment the selected (Smalltalk-) code.
The same heuristic behavior is as in the above "Comment" function is used.
convert the selected text to lowercase / uppercase / uppercase-first.
Press this key multiple times to cycle through the above conversions.
search forward and repeat the last cut- or replace-operation.
For example, to replace all occurrences of "foo" by "bar" in the text,
select the first "foo" and type "bar" to replace it.
Then repeat pressing F8 until no more replacements are possible.
if present, remove 4 leading spaces in the cursor line,
or the selected line range.
The same operation is performed by the SHIFT-Tab-key (if there is a line-selection)
add 4 more leading spaces in the cursor line,
or the selected line range.
The same operation is performed by the Tab-key (if there is a line-selection)
if present, remove one leading spaces in the cursor line, or
the selected line range.
add one more leading spaces in the cursor line, or
the selected line range.
The following keyboard commands are available in views
which show Smalltalk code (i.e. browsers and debuggers):
the whole text (not just the selection) will
be installed and changes be made permanent.
The definition of what exactly "installing"
means is context dependent:
tries to explain the selected text, which must be a single
word. This figures out, who implements a message or where a peritcular
variable is defined.
inserts a snippet using the word before the text-cursor as the name of of the abbreviation.
For example, typing "itf" followed by "CMD-SPACE" will insert a template
for the "ifTrue:ifFalse:" message send. The set of abbreviations can be edited via the Workspaces
pulldown menu.
complete the word to the left of the cursor.
This completion is syntax aware - if the word to the left of the cursor is a partial variable
name, the best variable (as visible in the scope) is searched. If it's a message selector, the best
matching message name is searched.
If more than one completion is possible, a popup menu offers a choice among the most likely completions.
Finally, see the keyPress:x:y:
methods
in the TextView
class and its subclasses.
You can easily modify these to add more functions.
Changing the Font
The default font used by text editors is specified in a preference settings entry.
This setting affects the initial font of new text editors.
Any individual editor's font can be later changed via its popup menu,
and the font size alternatively via keyboard shortcuts or the mouse wheel.
The font size can be quickly changed by turning the mouse-wheel while keeping
the "CTRL"-Key pressed,
or with the "CTRL-+" (ctrl-plus) and "CTRL--" (ctrl-minus) keys.
Moving the Keyboard Focus (Tabbing)
Within a complex view or a dialog,
the keyboard focus can be stepped through the fields by pressing
"Tab" or "SHIFT-Tab".
This works for all components, except text views which allow "Tab"
as regular text input (i.e. all code views).
Using the keyboard map, these can be set to "Alt-CursorLeft"
and "Alt-CursorRight", for example.
(the default mapping defines both "Alt" and "Ctrl"
combinations of the cursor keys.)
Focus Mode ("focus-follows-mouse" vs. "focus-on-click")
Depending on your personal preference,
the keyboard focus can be configured to either
follow the mouse pointer automatically ("focus-follows-mouse" mode)
or to change when a widget is clicked upon ("focus-on-click" mode).
To change this, change the Launcher's "Settings"-"Viewstyle"-"Focus Follows Mouse" checkBox setting.
Smalltalk
Evaluating Smalltalk Expressions
Most views which show code and especially workspaces allow you to
select some text and immediately evaluate this as a
Smalltalk expression
(remember the old Basic-interpreters ? :-).
This is very useful to try out things quickly,
without actually creating a program for it.
Your first experiments should probably be done in a workspace.
or:
Transcript showCR:'hello'
or:
Transcript showCR:(100 factorial)
In the workspace, select the text and evaluate it using doIt
(if nothing is selected, the whole text of the current cursor line is evaluated).
WorkspaceApplication open
To see the result of such an evaluation, use the middle button menu's
printIt function.
Just like doIt, this evaluates the expression;
however, after the evaluation, it inserts a printed representation
of the result at the current text-cursor position.
See the difference between doIt and printIt
when executing:
(the factorial operation computes the product 1*2*3*4*...*100)
100 factorial
Try to inspect the result of:
or
Array new:10
Each has a convenient keyboard shortcut:
Point x:10 y:25
In addition, it is often convenient to open a browser on an expression's class
(especially, if the expression consists of the global variable which names that class)
For this, use the browseIt shortcut function:
the selected text is evaluated as a Smalltalk expression
(if nothing is selected, the whole text in the cursors line is evaluated).
the selected text is evaluated as a Smalltalk expression,
and a printed representation of the result is inserted as the
new selection (use cut to remove it).
the selected text is evaluated as a Smalltalk expression
and an Inspector is opened on the result.
In case you run into an endless loop, or the evaluation
takes too long, the evaluation may be interrupted or aborted with:
evaluates the selected text, and opens a browser on the result (if it evaluated to a class)
or on its class.
Notice: in previous versions, interrupt used to be mapped to "CTRL-c"
and abort to "CTRL-y". This has been changed for standard conformance.
"CTRL-c" is now always copy and "CTRL-y" is redo.
stops the evaluation and enters a debugger.
In the debugger, you may proceed with the evaluation by pressing 'Continue'.
Depending on the system, the break key is either
the "Interrupt/Pause"-key or "CTRL-c".
For the convenience of Squeak and VisualWorks users,
"CMD-." (alt-period) is also mapped to this function.
stops and aborts the evaluation (without debugger).
display.rc
").
Read ``Configuration & Customization''
and have a look at the startup files.
Variables and Scope in a doIt Evaluation
Doits are evaluated in a variable scope,
which depends on the situation and tool in which it is performed.
Especially the visibility of local variables and the meaning of
the "self" pseudo variable varies:
Loading Existing Code / Using the FileBrowser
Files containing Smalltalk code
(in fileOut-format),
binary bytecode ('.cls'-files) or compiled machineCode ('.so' or '.dll' files)
can be loaded into the system either by evaluating:
in a workspace (with doIt),
or - more convenient - by using the FileBrowser.
Smalltalk fileIn:filename
To load a file in the FileBrowser, select the file
and execute its "fileIn" function from
tje middle button menu
in the browser's upper (file-list) panel.
As a concrete exercise, fileIn the contents of
"stx/clients/Clock/Clock.st
.
Watch the Transcript for what is going on.
Importing Code from Other Smalltalk Dialects
Smalltalk/X understands ParcPlace's
Smalltalk-80 / VisualWorks,
Digitalks Smalltalk/V and Squeak source formats
(limited support for IBM's VisualAge is also available).
Programming
To write your own code (classes) or to modify existsing code,
open a System Browser which is the central tool for programmers.
All classes also include a documentation method category,
where you will find two methods called "documentation" and
"examples".
The examples can be selected in the browser and evaluated via the
doIt menu function.
An introduction to Smalltalk and programming is found in the
``Smalltalk Beginners Tutorial''.
Learning Smalltalk
If you are new to Smalltalk,
start by learning how to use the non graphical basic classes.
A very quick introduction to the language and classes is found in the
``Tutorial''.
Many classes contain example methods in their documentation category.
Try these, and understand what is going on there. Also, many methods (especially in
the collection classes) contain a comment with some sample expressions at the end.
These are meant to show short typical uses of those methods.
"doc/coding"
and "clients/Demos"
.
Notes:
(*) keyboard shortCuts
The keyboard shortcuts as described here are not hard-coded;
instead, the bindings of keys to functions is done in your startup scripts.
This document describes the default bindings as set in the "keyboard.rc
" script.
See ``Keyboard Settings''
on how to change these.
The command key is labeled different on some keyboards;
try "ALT", "CMD", "META"
or similar.
"private.rc"
) to use
different control- or command key combinations instead.
Copyright © Claus Gittinger Development & Consulting
Copyright © eXept Software AG
Doc $Revision: 1.29 $ $Date: 1999/07/07 14:09:52 $