|
Class: Workspace
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ListView
|
+--TextView
|
+--EditTextView
|
+--TextCollector
|
+--Workspace
|
+--CodeView
- Package:
- stx:libwidg
- Category:
- Interface-Smalltalk
- Version:
- rev:
1.456
date: 2024/04/09 12:38:10
- user: stefan
- file: Workspace.st directory: libwidg
- module: stx stc-classLibrary: libwidg
a view for editable text which can evaluate expressions.
I.e. its basically a view for editable text, with added
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu.
The action to be performed on doIt is defined by a block,
which can be defined by the owner of this view.
(thus you can put a workspace into more complex widgets, and
control what should happen on 'doIt').
A useful default action is automatically defined, which simply
evaluates the selection as a smalltalk expression.
(but, a lisp or prolog workspace would define its own action,
to call for another compiler/interpreter ...)
Special workspace- and doIt variables:
workspaces can be configured to automatically define undefined variables
as either workspace- or doIt variables. When encountering undefined variables,
the parser asks for an action, which is responded with #workspace or doIt if a
workspace is the requestor of a doIt. Both are implemented as value holders, and
the parser will generate code sending value/value: instead of normal assignment.
Workspace variables are kept in the Workspace class and will both persist between doIts
and also be visible across workspaces. They are perfect for scripting (and therefore enabled
by default when stx is started with one of the scripting options).
DoIt variables are only valid during a single doIt.
Be aware that when you ask from the outside via workspaceVariableAt:, you'll get a valueHolder.
This is by purbose, as it allows for easy monitoring and tracing of changes.
Caveat:
in this version, Workspace does not yet support doIt in MVC setups.
For now, simulate this by setting the doItAction, to notify the
model manually about the doIt.
[instance variables:]
doItAction <Block> block to evaluate for doIt
errorFgColor <Color> fg-Color to be used when highlighting errors
errorBgColor <Color> bg-Color to be used when highlighting errors
codeStartPosition private temporary
[styleSheet values:]
codeErrorSelectionForegroundColor fg color to highlight errors
(default: selection fg)
codeErrorSelectionBackgroundColor bg color to highlight errors
(default: selection bg)
copyrightCOPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
accessing
-
snippets
-
the default snippets
(this returns the common global snippet dictionary;
now we also support per-language dicts)
-
snippets: aDictionary
-
the default snippets
(this sets the common global snippet dictionary;
now we also support per-language dicts)
-
snippetsForLanguage: languageName
-
return per-language snippets.
languageName must be one of the programmingLanguage instances name
eg. SmalltalkLanguage instance name
-
snippetsForLanguage: languageName put: aDictionary
-
set per-language snippets.
languageName must be one of the programmingLanguage instances name
eg. SmalltalkLanguage instance name
defaults
-
defaultCompletionSupportClass
-
-
defaultLabel
-
my default window label
-
initializeDefaultAbbreviations
-
default snippets/abbreviations. TODO: save/load snippets
Usage example(s):
after a code change below, update with:
self initializeDefaultAbbreviations.
|
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
getting a new Workspace
-
open
-
launch a new workspace
Usage example(s):
-
openForRemote: hostName
-
launch a new workspace to evaluate expression on some remote machine.
Entered expressions are sent over to some partner machine, evaluated there,
and the result is shown here.
This requires the RemoteObjects package to be loaded.
Usage example(s):
Workspace openForRemote:'andi'
|
-
openWith: initialText selected: selectedBoolean
-
launch a new workspace with some initial contents
Usage example(s):
Workspace openWith:'Transcript showCR:''hello world'''
|
history
-
clearDoItHistory
-
-
doItHistory
-
-
doItHistorySize
-
the number of remembered doIts
-
rememberDoIt: aString
-
unparsable
queries
-
isVisualStartable
-
returns whether this application class can be started via #open
(i.e. via a double click on the class in the browser)
workspace variables
-
addWorkspaceVariable: varName
-
create a new (global) workspace variable
-
anyWorkspaceVariableIsDefined
-
-
rememberResultAsWorkspaceVariable: lastResult
-
remember some last result as _0,
and shift the previous results (i.e. _0 -> _1 -> .. _9)
remembers it as GLOBAL workspace variable
-
removeAllWorkspaceVariables
-
delete all workspace variables
-
removeWorkspaceVariable: varName
-
delete a workspace variable
-
workspaceVariableAt: varName
-
retrieve a workspace variable's value
Usage example(s):
Workspace workspaceVariableAt:'foo' put:1234.
Workspace workspaceVariableAt:'foo'
|
-
workspaceVariableAt: varName put: aValue
-
set or define a GLOBAL workspace variable
-
workspaceVariableHolderAt: varName
-
retrieve a GLOBAL workspace variable (actually, a holder onto it) if present;
otherwise return nil
-
workspaceVariableNames
-
retrieve the collection of workspace variable names only
-
workspaceVariables
-
retrieve the collection of global workspace variable holders.
That is a dictionary associating names to values
for ALL workspaces.
accessing
-
allowValueDrop: aBoolean
-
if on (the default), any smalltalk value can be dropped and leads to a workspace variable
holding on to that being defined. Can be turned off, if you don't like this (for standAlone apps)
-
autoDefineVariables
-
undefined variables handling:
are automatically defined as
global workspace variable if autoDefineVariables is #workspace.
local workspace variable if autoDefineVariables is #workspaceLocal.
doit variable if autoDefineVariables is #doit.
are left undefined if autoDefineVariables is nil.
-
autoDefineVariables: nilOrSymbol
-
undefined variables handling:
are automatically defined as
global workspace variable if autoDefineVariables is #workspace.
local workspace variable if autoDefineVariables is #workspaceLocal.
doit variable if autoDefineVariables is #doit.
are left undefined if autoDefineVariables is nil.
-
commentStrings: anArrayOfCommentStrings
-
define the comment strings
-
doItAction
-
return the action to be performed when 'doIt' is selected
-
doItAction: aOneArgBlock
-
define the action to be performed when 'doIt' is selected.
The block will be evaluated, passing the selection as a String argument.
A default doItAction is set for you in the initialize method.
-
editedClass
-
for the code completion
-
editedMethod
-
for the code completion
-
editedMethodOrClass
-
for the code completion
-
editedMethodOrClass: aMethodOrClass
-
Sets the edited method or class (for code completion)
-
errorBackgroundColor
-
-
errorForegroundColor
-
-
nameSpaceForDoits
-
can be used by the embedding application to control doIt execution
(especially: for tools like expecco, to provide better workspaces
-
nameSpaceForDoits: aNameSpaceOrNil
-
can be used by the embedding application to control doIt execution
(especially: for tools like expecco, to provide better workspaces
-
namespaceForDoits: aNameSpaceOrNil
-
can be used by the embedding application to control doIt execution
(especially: for tools like expecco, to provide better workspaces
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
poolsConsideredInDoIts: aCollectionOfPools
-
can be used by the embedding application to control doIt execution
(especially: for tools like expecco, to provide better workspaces
-
programmingLanguage
-
get the programming language (for comments, indentation etc.)
-
programmingLanguage: aProgrammingLanguageOrNil
-
set the programming language (for comments, indentation etc.)
-
simulatedContext
-
-
simulatedContext: aContextOrSimulationOfOrNil
-
-
simulatedSelf
-
the 'self' instance used in an evaluation (also used in code completion of self messages)
-
simulatedSelf: anObject
-
define what self is in an evaluation (also useful in code completion of self messages)
-
warningBackgroundColor
-
-
warningForegroundColor
-
compiler interface
-
addWorkspaceVariable: varName
-
create a new (local) workspace variable
-
compilerClass
-
? Compiler
-
compilerClass: aCompilerClass
-
-
currentSourceCode
-
special interface to compiler - called by parser
to get the updated source code after a corrected error
-
wantChangeLog
-
sent by the compiler to ask if a changeLog entry should
be written. Return true here.
-
workspaceVariableAt: varName
-
retrieve a workspace variable's value
-
workspaceVariableAt: varName put: aValue
-
set or define a LOCAL or GLOBAL workspace variable (dep. on setting of autoDefineVariables)
-
workspaceVariableHolderAt: varName
-
retrieve a LOCAL workspace variable (actually, a holder onto it) if present;
otherwise return nil
-
workspaceVariables
-
retrieve the collection of local workspace variable holders.
That is a dictionary associating names to values
for THIS workspace only.
-
workspaceVariables: aDictionary
-
compiler interface-error handling
-
correctableError: aString position: relPos to: relEndPos from: aCompiler
-
compiler notifies us of a correctable error;
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort;
this method should return true to the compiler if user wants the error
to be corrected; false otherwise
-
correctableSelectorWarning: aString position: relPos to: relEndPos from: aCompiler
-
compiler notifies us of a correctable selector warning;
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort;
this method should return true to the compiler if user wants the error
to be corrected; false otherwise
-
correctableWarning: aString position: relPos to: relEndPos from: aCompiler
-
compiler notifies us of a correctable warning;
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort;
this method should return true to the compiler if user wants the error
to be corrected; false otherwise
-
error: aString position: relPos to: relEndPos asWarning: asWarning
-
obsolete - no longer invoked
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
error: aString position: relPos to: relEndPos from: aCompiler
-
compiler notifies us of an error; hilight the error (relPos to relEndPos)
and show a Box asking for continue/abort.
Return true for correction, false of not (or not possible)
-
error: aString position: relPos to: relEndPos from: aCompiler asWarning: asWarning
-
compiler notifies us of an error; hilight the error (relPos to relEndPos)
and show a Box asking for continue/abort.
-
highlightingErrorLine: lineNr do: aBlock
-
evaluate aBlock while some line selection is shown highlighted with error colors.
-
highlightingErrorPosition: relPos to: relEndPos do: aBlock
-
evaluate aBlock while some selection is shown highlighted with error colors.
-
highlightingErrorPosition: relPos to: relEndPos withForeground: hilightFg andBackground: hilightBg do: aBlock
-
evaluate aBlock while some selection is shown highlighted with colors passed as args.
relPos and relEndPos are the position of the error within the selected doIt-code
(i.e. as seen by the parser, which is only given the selection).
For highlighting, we must relocate this back to the absolute position within the text
-
highlightingWarningPosition: relPos to: relEndPos do: aBlock
-
evaluate aBlock while some selection is shown highlighted with warning colors.
-
unusedVariableWarning: aString position: relPos to: relEndPos from: aCompiler
-
compiler notifies us of a (or some) unused variables;
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort;
this method should return true to the compiler if user wants the error
to be corrected; false otherwise
-
warning: aString position: relPos to: relEndPos from: aCompiler
-
compiler notifies us of a warning - same behavior as error
drag & drop
-
canDrop: aDropContext
-
if allowValueDrop is true, any text- or file-object can be dropped into workspace
(printString); otherwise, only ...
-
doDrop: aDropContext
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
drop: aDropContext
-
Any object can be dropped into workspace...
editing
-
commentFrom: line1 to: line2
-
convenient function to comment out a block.
All lines from line1 to line2 get an end-of-line comment
in the first col
(if no eol comment is available, a bracketing comment is used).
-
commentSelection
-
convenient function to comment out a block.
All lines from line1 to line2 get an end-of-line comment
in the first col.
-
uncommentFrom: line1 to: line2
-
convenient function to comment out a block.
All lines from line1 to line2 get an end-of-line comment
in the first col.
(if no eol comment is available, a bracketing comment is removed)
-
uncommentSelection
-
convenient function to comment out a block.
All lines from line1 to line2 get an end-of-line comment
in the first col.
event handling
-
keyPress: key x: x y: y
-
(comment from inherited method)
handle keyboard input
executing
-
do: code withValueDo: aBlock
-
helper for doIt, printIt and inspectIt.
Evaluate the selection and, if all went well, evaluate the argument,
aBlock with the value.
Most work is in preparing for proper cleanup in case of abort
or other exception while the evaluation is performed.
(restore cursor, selectionColors etc.)
-
executeDoIt: theCode
-
the core of doIt, printIt, inspectIt, browseIt actions
-
withValueOfSelectionDo: aBlock
-
helper for doIt, printIt, inspectIt, etc.
Evaluate the selection and, if all went well, evaluate the argument,
aBlock with the value.
initialization & release
-
initStyle
-
setup viewStyle specifics
-
initialize
-
(comment from inherited method)
we always use unicode internally
-
initializeDoITAction
-
set up the block to be evaluated for doIts.
This is done here in a separate method to allow easier
redefinition in subclasses
-
initializeDragAndDrop
-
menu & menu actions
-
basicInspectIt
-
user selected 'basicInspectIt' from menu; use doIt to evaluate the code
and start a basicInspector on the result
-
browseClass
-
user selected 'browseClass' from menu; evaluate the code
and open a browser on the resulting class (if it evaluates to one)
-
browseClassesContainingInName
-
ask for a piece of text and
open a browser on all classes where that piece is contained in the name
-
browseClassesContainingInName: pieceOfText
-
open a browser on all classes where that piece is contained in the name
-
browseClassesContainingItInName
-
open a browser on all classes where the selected text is contained in the name
-
browseImplementorsOf
-
ask for a name and
open a browser on all implementors of the selector.
-
browseImplementorsOf: methodNameArg
-
open a browser on the implementors of the selected text,
or - if I support syntax elements, on the syntax element at the cursor position
-
browseImplementorsOfIt
-
open a browser on the implementors of the selected text,
or - if I support syntax elements, on the syntax element at the cursor position
-
browseIt
-
evaluate the code and open a browser on the resulting class (if it evaluates to one),
or the class of the resulting object (if it does not evaluate to a class).
Added feature:
if selection is of the form class >> selector,
immediately switch to that selector.
and:
if selection is of the form class >> selector [lineNr],
also navigate to that line.
and:
if selection is of the form class >> selector @lineNr,
also navigate to that line.
-
browseItsClass
-
user selected 'browseItsClass' from menu; evaluate the code
and open a browser on the results class
-
browseMethodsContainingInName
-
ask for a piece of text and
open a browser on all methods where that piece is contained in the selector
-
browseMethodsContainingInName: pieceOfText
-
open a browser on all methods where that piece is contained in the selector
-
browseMethodsContainingInSource
-
ask for a piece of text and
open a browser on all methods where that piece is contained in the source
-
browseMethodsContainingInSource: pieceOfText
-
open a browser on all methods where that piece is contained in the source
-
browseMethodsContainingItInName
-
open a browser on all methods where the selected text is part of the selector
-
browseMethodsContainingItInSource
-
open a browser on all methods where the selected text is contained in the source
-
browseMethodsWithString
-
open a browser on all methods where the selected text is contained in the source
-
browseReferencesTo
-
ask for a name and
open a browser on all references to the selected global, poolvar or namespace class
-
browseReferencesTo: nameOfVariable
-
open a browser on all references to the selected global, poolvar or namespace class
-
browseReferencesToIt
-
open a browser on all references to the selected global, poolvar or namespace class
-
browseSendersOf
-
ask for a name and
open a browser on all senders of the selector.
-
browseSendersOf: methodName
-
open a browser on the senders of the selected text
-
browseSendersOfIt
-
open a browser on the senders of the selected text
-
browseSharedPoolOfIt
-
open a browser on the shared pool in which the selected variable is
-
debugIt
-
user selected 'debugIt' from menu; evaluate the code with an immediate halt before,
to allow for single stepping into the code.
Finally restore cursor; return result of evaluation
-
doIt
-
user selected 'doIt' from menu; show a wait-cursor, evaluate the code
and finally restore cursor; return result of evaluation
-
editMenu
-
return my popUpMenu; that's the superclasses menu
PLUS st-evaluation items: doIt, printIt and inspectIt.
-
inspectContents
-
user selected 'inspectContents' from menu; show the contents in an inspector
-
inspectInstances
-
-
inspectIt
-
user selected 'inspectIt' from menu; use doIt to evaluate the code
and start an inspector (or basicInspector if Shift pressed) on the result
-
printIt
-
user selected 'printIt' from menu;
use doIt to evaluate the code
and insert the result of evaluation into my text.
If the text is readOnly, do nothing.
-
profileIt
-
user selected 'profileIt' from menu; show a wait-cursor, profile the code
and finally restore the cursor. Open a visual profiler on the sample data.
-
replaceIt
-
like printIt, but replace the selection with the result, instead of
pasting it after the selection.
-
seeDetail
-
user selected 'seeDetails' from menu while the cursor was at a text-element with
an actionBlock. Evaluate it.
Used by the inspector to provide detail about errors
-
showLineLimitInMenu
-
false.
-
spyOnIt
-
user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code
and finally restore the cursor. Show profile data on the Transcript
-
spyOnItUsing: aProfiler
-
common code for spyOnIt / profileIt.
Show a wait-cursor, evaluate the code with profier on it,
and finally restore the cursor. Show profile data as per profiler
-
timeIt
-
user selected 'timeIt' from menu; show a wait-cursor, evaluate the code
and finally restore cursor; return result of evaluation
-
traceIt
-
user selected 'traceIt' from menu; evaluate the code with message send tracing,
Finally restore cursor; return result of evaluation
misc
-
expandAbbreviation
-
after receiving an Alt-shift key-event, look for the string before the
cursor, find an abbrev for it and expand.
-
findAbbreviationKeyBeforeCursor
-
after receiving an Alt-shift key-event, look for the string before the
cursor, find an abbrev for it, return the key and the abbreviation for it.
If none is found, return nil
-
selectAbbreviationKeyBeforeCursor
-
after receiving an Alt-shift key-event, look for the string before the
cursor, find an abbrev for it, select it and return the abbreviation for it.
If none is found, do not select and return nil
-
selectedTextOrSyntaxElement
-
-
syntaxElementForSelectorUnderCursor
-
we do not support syntax elements, but subclasses may do
-
syntaxElementUnderCursor
-
we do not support syntax elements, but subclasses may do
queries
-
canDivertOutput
-
only for text collectors
-
isWorkspace
-
back-query from the compiler to ask if this is an interactive view
(for error feedback)
|