eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Workspace':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Workspace


Inheritance:

   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

Description:


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)

copyright

COPYRIGHT (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.

Class protocol:

accessing
o  snippets
the default snippets
(this returns the common global snippet dictionary;
now we also support per-language dicts)

o  snippets: aDictionary
the default snippets
(this sets the common global snippet dictionary;
now we also support per-language dicts)

o  snippetsForLanguage: languageName
return per-language snippets.
languageName must be one of the programmingLanguage instances name
eg. SmalltalkLanguage instance name

o  snippetsForLanguage: languageName put: aDictionary
set per-language snippets.
languageName must be one of the programmingLanguage instances name
eg. SmalltalkLanguage instance name

defaults
o  defaultCompletionSupportClass

o  defaultLabel
my default window label

o  initializeDefaultAbbreviations
default snippets/abbreviations. TODO: save/load snippets

Usage example(s):

after a code change below, update with:
         self initializeDefaultAbbreviations.

o  updateStyleCache
extract values from the styleSheet and cache them in class variables

getting a new Workspace
o  open
launch a new workspace

Usage example(s):

     Workspace open

o  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'

o  openWith: initialText selected: selectedBoolean
launch a new workspace with some initial contents

Usage example(s):

     Workspace openWith:'Transcript showCR:''hello world'''

history
o  clearDoItHistory

o  doItHistory

o  doItHistorySize
the number of remembered doIts

o  rememberDoIt: aString
unparsable

queries
o  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
o  addWorkspaceVariable: varName
create a new (global) workspace variable

o  anyWorkspaceVariableIsDefined

o  rememberResultAsWorkspaceVariable: lastResult
remember some last result as _0,
and shift the previous results (i.e. _0 -> _1 -> .. _9)
remembers it as GLOBAL workspace variable

o  removeAllWorkspaceVariables
delete all workspace variables

o  removeWorkspaceVariable: varName
delete a workspace variable

o  workspaceVariableAt: varName
retrieve a workspace variable's value

Usage example(s):

     Workspace workspaceVariableAt:'foo' put:1234.
     Workspace workspaceVariableAt:'foo'

o  workspaceVariableAt: varName put: aValue
set or define a GLOBAL workspace variable

o  workspaceVariableHolderAt: varName
retrieve a GLOBAL workspace variable (actually, a holder onto it) if present;
otherwise return nil

o  workspaceVariableNames
retrieve the collection of workspace variable names only

o  workspaceVariables
retrieve the collection of global workspace variable holders.
That is a dictionary associating names to values
for ALL workspaces.


Instance protocol:

accessing
o  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)

o  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.

o  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.

o  commentStrings: anArrayOfCommentStrings
define the comment strings

o  doItAction
return the action to be performed when 'doIt' is selected

o  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.

o  editedClass
for the code completion

o  editedMethod
for the code completion

o  editedMethodOrClass
for the code completion

o  editedMethodOrClass: aMethodOrClass
Sets the edited method or class (for code completion)

o  errorBackgroundColor

o  errorForegroundColor

o  nameSpaceForDoits
can be used by the embedding application to control doIt execution
(especially: for tools like expecco, to provide better workspaces

o  nameSpaceForDoits: aNameSpaceOrNil
can be used by the embedding application to control doIt execution
(especially: for tools like expecco, to provide better workspaces

o  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) **

o  poolsConsideredInDoIts: aCollectionOfPools
can be used by the embedding application to control doIt execution
(especially: for tools like expecco, to provide better workspaces

o  programmingLanguage
get the programming language (for comments, indentation etc.)

o  programmingLanguage: aProgrammingLanguageOrNil
set the programming language (for comments, indentation etc.)

o  simulatedContext

o  simulatedContext: aContextOrSimulationOfOrNil

o  simulatedSelf
the 'self' instance used in an evaluation (also used in code completion of self messages)

o  simulatedSelf: anObject
define what self is in an evaluation (also useful in code completion of self messages)

o  warningBackgroundColor

o  warningForegroundColor

compiler interface
o  addWorkspaceVariable: varName
create a new (local) workspace variable

o  compilerClass
? Compiler

o  compilerClass: aCompilerClass

o  currentSourceCode
special interface to compiler - called by parser
to get the updated source code after a corrected error

o  wantChangeLog
sent by the compiler to ask if a changeLog entry should
be written. Return true here.

o  workspaceVariableAt: varName
retrieve a workspace variable's value

o  workspaceVariableAt: varName put: aValue
set or define a LOCAL or GLOBAL workspace variable (dep. on setting of autoDefineVariables)

o  workspaceVariableHolderAt: varName
retrieve a LOCAL workspace variable (actually, a holder onto it) if present;
otherwise return nil

o  workspaceVariables
retrieve the collection of local workspace variable holders.
That is a dictionary associating names to values
for THIS workspace only.

o  workspaceVariables: aDictionary

compiler interface-error handling
o  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

o  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

o  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

o  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) **

o  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)

o  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.

o  highlightingErrorLine: lineNr do: aBlock
evaluate aBlock while some line selection is shown highlighted with error colors.

o  highlightingErrorPosition: relPos to: relEndPos do: aBlock
evaluate aBlock while some selection is shown highlighted with error colors.

o  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

o  highlightingWarningPosition: relPos to: relEndPos do: aBlock
evaluate aBlock while some selection is shown highlighted with warning colors.

o  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

o  warning: aString position: relPos to: relEndPos from: aCompiler
compiler notifies us of a warning - same behavior as error

drag & drop
o  canDrop: aDropContext
if allowValueDrop is true, any text- or file-object can be dropped into workspace
(printString); otherwise, only ...

o  doDrop: aDropContext

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  drop: aDropContext
Any object can be dropped into workspace...

editing
o  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).

o  commentSelection
convenient function to comment out a block.
All lines from line1 to line2 get an end-of-line comment
in the first col.

o  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)

o  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
o  keyPress: key x: x y: y
(comment from inherited method)
handle keyboard input

executing
o  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.)

o  executeDoIt: theCode
the core of doIt, printIt, inspectIt, browseIt actions

o  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
o  initStyle
setup viewStyle specifics

o  initialize
(comment from inherited method)
we always use unicode internally

o  initializeDoITAction
set up the block to be evaluated for doIts.
This is done here in a separate method to allow easier
redefinition in subclasses

o  initializeDragAndDrop

menu & menu actions
o  basicInspectIt
user selected 'basicInspectIt' from menu; use doIt to evaluate the code
and start a basicInspector on the result

o  browseClass
user selected 'browseClass' from menu; evaluate the code
and open a browser on the resulting class (if it evaluates to one)

o  browseClassesContainingInName
ask for a piece of text and
open a browser on all classes where that piece is contained in the name

o  browseClassesContainingInName: pieceOfText
open a browser on all classes where that piece is contained in the name

o  browseClassesContainingItInName
open a browser on all classes where the selected text is contained in the name

o  browseImplementorsOf
ask for a name and
open a browser on all implementors of the selector.

o  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

o  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

o  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.

o  browseItsClass
user selected 'browseItsClass' from menu; evaluate the code
and open a browser on the results class

o  browseMethodsContainingInName
ask for a piece of text and
open a browser on all methods where that piece is contained in the selector

o  browseMethodsContainingInName: pieceOfText
open a browser on all methods where that piece is contained in the selector

o  browseMethodsContainingInSource
ask for a piece of text and
open a browser on all methods where that piece is contained in the source

o  browseMethodsContainingInSource: pieceOfText
open a browser on all methods where that piece is contained in the source

o  browseMethodsContainingItInName
open a browser on all methods where the selected text is part of the selector

o  browseMethodsContainingItInSource
open a browser on all methods where the selected text is contained in the source

o  browseMethodsWithString
open a browser on all methods where the selected text is contained in the source

o  browseReferencesTo
ask for a name and
open a browser on all references to the selected global, poolvar or namespace class

o  browseReferencesTo: nameOfVariable
open a browser on all references to the selected global, poolvar or namespace class

o  browseReferencesToIt
open a browser on all references to the selected global, poolvar or namespace class

o  browseSendersOf
ask for a name and
open a browser on all senders of the selector.

o  browseSendersOf: methodName
open a browser on the senders of the selected text

o  browseSendersOfIt
open a browser on the senders of the selected text

o  browseSharedPoolOfIt
open a browser on the shared pool in which the selected variable is

o  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

o  doIt
user selected 'doIt' from menu; show a wait-cursor, evaluate the code
and finally restore cursor; return result of evaluation

o  editMenu
return my popUpMenu; that's the superclasses menu
PLUS st-evaluation items: doIt, printIt and inspectIt.

o  inspectContents
user selected 'inspectContents' from menu; show the contents in an inspector

o  inspectInstances

o  inspectIt
user selected 'inspectIt' from menu; use doIt to evaluate the code
and start an inspector (or basicInspector if Shift pressed) on the result

o  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.

o  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.

o  replaceIt
like printIt, but replace the selection with the result, instead of
pasting it after the selection.

o  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

o  showLineLimitInMenu
false.

o  spyOnIt
user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code
and finally restore the cursor. Show profile data on the Transcript

o  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

o  timeIt
user selected 'timeIt' from menu; show a wait-cursor, evaluate the code
and finally restore cursor; return result of evaluation

o  traceIt
user selected 'traceIt' from menu; evaluate the code with message send tracing,
Finally restore cursor; return result of evaluation

misc
o  expandAbbreviation
after receiving an Alt-shift key-event, look for the string before the
cursor, find an abbrev for it and expand.

o  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

o  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

o  selectedTextOrSyntaxElement

o  syntaxElementForSelectorUnderCursor
we do not support syntax elements, but subclasses may do

o  syntaxElementUnderCursor
we do not support syntax elements, but subclasses may do

queries
o  canDivertOutput
only for text collectors

o  isWorkspace
back-query from the compiler to ask if this is an interactive view
(for error feedback)



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:23:17 GMT