The Trunk: Tools-mt.1056.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Tools-mt.1056.mcz

commits-2
Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1056.mcz

==================== Summary ====================

Name: Tools-mt.1056
Author: mt
Time: 18 May 2021, 1:58:25.950287 pm
UUID: f32e4e04-6f83-d641-ba5a-0de0c535aa73
Ancestors: Tools-mt.1055

Tweak #embedTranscript to only apply when opening a regular workspace via class-side #open. Note that the workspace model is re-used for other purposes such as string edit. See UIManager.

Adds new preference to file-out workspace contents on accept. Thanks to Jaromir for the idea! Preference is enabled by default since there was noe default accept-action in workspaces yet.

=============== Diff against Tools-mt.1055 ===============

Item was changed:
  StringHolder subclass: #Workspace
  instanceVariableNames: 'bindings acceptDroppedMorphs acceptAction mustDeclareVariables shouldStyle environment'
+ classVariableNames: 'DeclareVariablesAutomatically EmbedTranscript FileOutFilePath FileOutOnAccept LookupPools ShouldStyle'
- classVariableNames: 'DeclareVariablesAutomatically EmbedTranscript LookupPools ShouldStyle'
  poolDictionaries: ''
  category: 'Tools-Base'!
 
  !Workspace commentStamp: 'fbs 6/2/2012 20:46' prior: 0!
  A Workspace is a text area plus a lot of support for executable code.  It is a great place to execute top-level commands to compute something useful, and it is a great place to develop bits of a program before those bits get put into class methods.
 
  To open a new workspace, execute:
 
  Workspace open
 
 
  A workspace can have its own variables, called "workspace variables", to hold intermediate results.  For example, if you type into a workspace "x := 5" and do-it, then later you could type in "y := x * 2" and y would become 10.
 
  Additionally, in Morphic, a workspace can gain access to morphs that are on the screen.  If acceptDroppedMorphs is turned on, then whenever a morph is dropped on the workspace, a variable will be created which references that morph.  This functionality is toggled with the window-wide menu of a workspace.
 
 
  The instance variables of this class are:
 
  bindings  -  holds the workspace variables for this workspace
 
  acceptDroppedMorphs - whether dropped morphs should create new variables!

Item was changed:
  ----- Method: Workspace class>>embedTranscript (in category 'preferences') -----
  embedTranscript
  <preference: 'Embed a Transcript in Workspace'
+ categoryList: #('browsing' 'tools')
- category: 'browsing'
  description: 'If true, new workspaces will open with an embedded Transcript.'
  type: #Boolean>
  ^ EmbedTranscript ifNil: [ false ]!

Item was added:
+ ----- Method: Workspace class>>fileOut: (in category 'support') -----
+ fileOut: contents
+ "Write the given contents into the workspace file-out file path."
+
+ | filePath |
+ filePath := self fileOutFilePath.
+ (FileDirectory default on: filePath) containingDirectory assureExistence.
+ FileStream
+ fileNamed: filePath
+ do: [:stream |
+ stream
+ setToEnd;
+ nextPutAll: '"----ACCEPT----';
+ nextPutAll: DateAndTime now asString;
+ nextPutAll: '"';
+ cr; nextPutAll: contents; cr].
+ Transcript showln: 'Workspace contents successfully appended to: ', filePath printString.!

Item was added:
+ ----- Method: Workspace class>>fileOutFilePath (in category 'preferences') -----
+ fileOutFilePath
+ <preference: 'File-out file path for workspace'
+ categoryList: #('browsing' 'tools')
+ description: 'Set the file-out location for #fileOutOnAccept in workspaces.'
+ type: #String>
+ ^ FileOutFilePath ifNil: [ 'workspace.st' ]!

Item was added:
+ ----- Method: Workspace class>>fileOutFilePath: (in category 'preferences') -----
+ fileOutFilePath: aString
+
+ FileOutFilePath := aString.!

Item was added:
+ ----- Method: Workspace class>>fileOutOnAccept (in category 'preferences') -----
+ fileOutOnAccept
+ <preference: 'File-out workspace contents on accept'
+ categoryList: #('browsing' 'tools')
+ description: 'If true, accepting contents in a workspace will append them to a known location in the file system. See #fileOutFilePath.'
+ type: #Boolean>
+ ^ FileOutOnAccept ifNil: [ true ]!

Item was added:
+ ----- Method: Workspace class>>fileOutOnAccept: (in category 'preferences') -----
+ fileOutOnAccept: aBoolean
+
+ FileOutOnAccept := aBoolean.!

Item was added:
+ ----- Method: Workspace class>>open (in category 'instance creation') -----
+ open
+
+ | workspace |
+ workspace := self new.
+ self fileOutOnAccept ifTrue: [
+ workspace acceptAction: [:string | self fileOut: string]].
+ ^ self embedTranscript
+ ifTrue: [workspace buildAndOpenWorkspaceTranscript]
+ ifFalse: [workspace buildAndOpen]!

Item was added:
+ ----- Method: Workspace>>buildAndOpen (in category 'toolbuilder') -----
+ buildAndOpen
+
+ ToolBuilder default open: self.
+ ^ self!

Item was added:
+ ----- Method: Workspace>>buildAndOpenWorkspaceTranscript (in category 'toolbuilder') -----
+ buildAndOpenWorkspaceTranscript
+
+ | windowSpec builder |
+ builder := ToolBuilder default.
+ windowSpec := self buildWindowWith: builder specs: {
+ (0.0 @ 0.0 corner: 1.0 @ 0.6) -> [self buildCodePaneWith: builder].
+ (0.0 @ 0.6 corner: 1.0 @ 1.0) -> [self buildTranscriptWith: builder].
+ }.
+ builder open: windowSpec.
+ ^ self!

Item was removed:
- ----- Method: Workspace>>buildWith: (in category 'toolbuilder') -----
- buildWith: builder
-
- ^ self class embedTranscript
- ifTrue: [self buildWorkspaceTranscriptWith: builder]
- ifFalse: [super buildWith: builder]!

Item was removed:
- ----- Method: Workspace>>buildWorkspaceTranscriptWith: (in category 'toolbuilder') -----
- buildWorkspaceTranscriptWith: builder
-
- | windowSpec |
- windowSpec := self buildWindowWith: builder specs: {
- (0.0 @ 0.0 corner: 1.0 @ 0.6) -> [self buildCodePaneWith: builder].
- (0.0 @ 0.6 corner: 1.0 @ 1.0) -> [self buildTranscriptWith: builder].
- }.
- ^builder build: windowSpec!