Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several Exploriants Quality Of Lives #124

Merged
merged 12 commits into from
Oct 24, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ SBExampleValueDisplay >> exampleFinished: anExample [
display exampleFinished: anExample.

statusLabel
contents: (hadValue ifTrue: [''] ifFalse: ['- Not reached -']);
contents: (hadValue
ifTrue: ['']
ifFalse: ['- Not reached -']);
visible: hadValue not
]

Expand Down
36 changes: 13 additions & 23 deletions packages/Sandblocks-Babylonian/SBExampleWatch.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"
Observes (watches) an expression locally for added SBExamples. Whenever an example has finished running, it updates its belonging view. Only active watches update their views. Further, with a given modifyExpression, it transforms the watched expression values. Also known as a Probe in the context of Babylonian Smalltalk.
Observes (watches) an expression locally for added SBExamples. Whenever an example has finished running, it updates its belonging view. Further, with a given modifyExpression, it transforms the watched expression values. Also known as a Probe in the context of Babylonian Smalltalk.
"
Class {
#name : #SBExampleWatch,
Expand All @@ -8,7 +8,6 @@ Class {
'identifier',
'watchedExpression',
'modifyExpression',
'isActive',
'exampleToDisplay',
'exampleToValues'
],
Expand Down Expand Up @@ -71,7 +70,7 @@ SBExampleWatch class >> registry [
SBExampleWatch class >> report: aValue for: aSymbol [

"Compatibility to SBWatch"
^ self reportValue: aValue for: aSymbol modifying: (SBStBlockBody identityNamed: 'result').
^ self reportValue: aValue for: aSymbol modifying: (SBStBlockBody identityNamed: 'each').
]

{ #category : #'event handling' }
Expand Down Expand Up @@ -112,24 +111,10 @@ SBExampleWatch >> applyModifyExpressionOnValues [
anExampleDisplayPair value updateDisplay]
]

{ #category : #callbacks }
SBExampleWatch >> artefactSaved: aBlock [

"As we are inactive, we have to manually apply our modifyExpression if it changes.
Otherwise, we would reset by examples starting"
(self isActive not and: [aBlock = self containingArtefact]) ifTrue: [self applyModifyExpressionOnValues]
]

{ #category : #copying }
SBExampleWatch >> asInactiveCopy [

^ (self veryDeepCopy) beInactive.
]

{ #category : #accessing }
SBExampleWatch >> beInactive [

isActive := false
^ SBInactiveExampleWatch newFromWatch: self
]

{ #category : #'colors and color policies' }
Expand Down Expand Up @@ -207,7 +192,7 @@ SBExampleWatch >> exampleToValues: anExampleToCollectionOfObjectsDict [
{ #category : #accessing }
SBExampleWatch >> expression [

^ watchedExpression
^ self submorphs first
]

{ #category : #accessing }
Expand Down Expand Up @@ -245,8 +230,7 @@ SBExampleWatch >> initialize [
exampleToDisplay := Dictionary new.
exampleToValues := Dictionary new.
watchedExpression := SBStMessageSend new.
modifyExpression := SBStBlockBody identityNamed: 'result'.
isActive := true.
modifyExpression := SBStBlockBody identityNamed: 'each'.

self
cellGap: 4;
Expand All @@ -268,7 +252,7 @@ SBExampleWatch >> intoWorld: aWorld [
{ #category : #accessing }
SBExampleWatch >> isActive [

^ isActive
^ true
]

{ #category : #'*Sandblocks-Babylonian' }
Expand Down Expand Up @@ -307,7 +291,7 @@ SBExampleWatch >> layoutCommands [
{ #category : #'*Sandblocks-Babylonian' }
SBExampleWatch >> listensToExamples [

^ self isActive
^ true
]

{ #category : #accessing }
Expand Down Expand Up @@ -373,6 +357,12 @@ SBExampleWatch >> reportValue: anObject for: anExample [
ifPresent: [:values | values add: anObject]
]

{ #category : #accessing }
SBExampleWatch >> setWatchedExpressionUneditable [

watchedExpression selectable: false
]

{ #category : #accessing }
SBExampleWatch >> valuesForExample: anExample [

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExampleWatch.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ SBExampleWatch >> isGlobalWatch [
{ #category : #'*Sandblocks-Babylonian' }
SBExampleWatch >> listensToExamples [

^ self isActive
^ true
]
50 changes: 50 additions & 0 deletions packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"
Does not update its results anymore. Applying modification expressions is still possible.
"
Class {
#name : #SBInactiveExampleWatch,
#superclass : #SBExampleWatch,
#category : #'Sandblocks-Babylonian'
}

{ #category : #'initialize-release' }
SBInactiveExampleWatch class >> newFromWatch: anActiveWatch [

^ (anActiveWatch veryDeepCopy)
primitiveChangeClassTo: self basicNew;
expression: (SBTextBubble new contents: anActiveWatch expression sourceString);
yourself
]

{ #category : #callbacks }
SBInactiveExampleWatch >> artefactSaved: aBlock [

"As we are inactive, we have to manually apply our modifyExpression if it changes.
Otherwise, we would reset by examples starting"
(aBlock = self containingArtefact) ifTrue: [self applyModifyExpressionOnValues]
]

{ #category : #'event handling' }
SBInactiveExampleWatch >> doubleClick: evt [

"Nothing"
]

{ #category : #accessing }
SBInactiveExampleWatch >> expression: aBlock [

super expression: aBlock.
watchedExpression selectable: false
]

{ #category : #accessing }
SBInactiveExampleWatch >> isActive [

^ false
]

{ #category : #'*Sandblocks-Babylonian' }
SBInactiveExampleWatch >> listensToExamples [

^ false
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #SBInactiveExampleWatch }

{ #category : #'*Sandblocks-Babylonian' }
SBInactiveExampleWatch >> listensToExamples [

^ false
]
8 changes: 8 additions & 0 deletions packages/Sandblocks-Babylonian/SBResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Class {
#category : #'Sandblocks-Babylonian'
}

{ #category : #building }
SBResultsView >> addAllWatchesFrom: aCollectionOfMethodBlocks [

self block addAllMorphsBack: (self allWatchesIn: aCollectionOfMethodBlocks)
]

{ #category : #accessing }
SBResultsView >> allActiveExamples [

Expand Down Expand Up @@ -65,6 +71,8 @@ SBResultsView >> buildAllPossibleResults [
activeExamples := self allActiveExamples.
permutations := SBPermutation allPermutationsOf: variants.

permutations ifEmpty: [self addAllWatchesFrom: watchMethodBlocks].

[ permutations do: [:aPermutation |
SBActiveVariantPermutation value: aPermutation.
activeExamples do: #runSynchronouslyIgnoreReturn.
Expand Down
12 changes: 10 additions & 2 deletions packages/Sandblocks-Babylonian/SBVariantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ Class {
{ #category : #building }
SBVariantsView >> buildMethodSectionFor: aSBStMethod [

self block addAllMorphsBack: {aSBStMethod methodHeader copy.
self block addAllMorphsBack: {aSBStMethod methodDefinition.
self containerRow
addAllMorphsBack: (aSBStMethod containedVariants collect: #asProxy).
LineMorph from: 0@0 to: 50@0 color: Color black width: 2}
]

{ #category : #building }
SBVariantsView >> buildNoVariantsText [

self block addMorphBack: (SBOwnTextMorph new contents: 'No variants exist.')
]

{ #category : #initialization }
SBVariantsView >> initialize [

Expand All @@ -28,5 +34,7 @@ SBVariantsView >> visualize [

self clean.

self allMethodBlocksContainingVariants do: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]
self allMethodBlocksContainingVariants
ifNotEmptyDo: [:theMethods | theMethods do: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]]
ifEmpty: [self buildNoVariantsText]
]
4 changes: 2 additions & 2 deletions packages/Sandblocks-Babylonian/SBWatchValueBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SBWatchValueBlock class >> registerShortcuts: aProvider [

]

{ #category : #'as yet unclassified' }
{ #category : #'event handling' }
SBWatchValueBlock >> doubleClick: evt [

super doubleClick: evt.
Expand All @@ -25,7 +25,7 @@ SBWatchValueBlock >> doubleClick: evt [

{ #category : #accessing }
SBWatchValueBlock >> exploreValue [
<action>
<action>

self watchValue watchedValue explore
]
Expand Down
8 changes: 8 additions & 0 deletions packages/Sandblocks-Core/SBLabel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ SBLabel >> symbols [
^ delimiter ifNil: [self colorPolicy symbolsForComment: self]
]

{ #category : #'as yet unclassified' }
SBLabel >> text: aSBOwnTextMorph [

text ifNotNil: [text abandon].
text := aSBOwnTextMorph.
self addMorphBack: text.
]

{ #category : #'as yet unclassified' }
SBLabel >> textBlock: aBlock [

Expand Down
1 change: 1 addition & 0 deletions packages/Sandblocks-Core/SBTabView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ SBTabView >> asTabButton: aNamedBlock [

aNamedBlock = self active ifTrue: [button makeBold].
button when: #contentsChanged send: #updateNameFor:on: to: self withArguments: {aNamedBlock. button}.
button when: #doubleClicked send: #triggerEvent: to: self with: #doubleClicked.

^ button
]
Expand Down
8 changes: 7 additions & 1 deletion packages/Sandblocks-Core/SBTextBubble.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ SBTextBubble >> font: aFont [
text font: aFont
]

{ #category : #'as yet unclassified' }
SBTextBubble >> guessedClass [

^ nil
]

{ #category : #'as yet unclassified' }
SBTextBubble >> initialize [

Expand Down Expand Up @@ -207,7 +213,7 @@ SBTextBubble >> prefix: aString [
{ #category : #'as yet unclassified' }
SBTextBubble >> printOn: aStream [

aStream nextPutAll: 'text bubble'
aStream nextPutAll: (self contents ifNil: ['text bubble'] ifNotNil: [self contents])
]

{ #category : #'as yet unclassified' }
Expand Down
4 changes: 4 additions & 0 deletions packages/Sandblocks-Morphs/SBEditableButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ SBEditableButton >> textMorphFor: aString [
when: #clicked
send: #doButtonAction
to: self;
when: #doubleClicked
send: #triggerEvent:
to: self
with: #doubleClicked;
when: #contentsChanged
send: #triggerEvent:
to: self
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Smalltalk/SBStASTNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SBStASTNode class >> preferredColor [
SBStASTNode class >> registerShortcuts: aProvider [

aProvider
cmdShortcut: $" do: #wrapInToggledCode;
cmdShortcut: $" do: #wrapInOptionalVariant;
cmdShortcut: $Q do: #wrapInVariant;
noInsertShortcut: $[ do: #wrapInBlock;
noInsertShortcut: ${ do: #wrapInDynamicArray;
Expand Down
30 changes: 29 additions & 1 deletion packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,29 @@ SBStGrammarHandler >> wrapInMessageSend: aString [
^ msg
]

{ #category : #actions }
SBStGrammarHandler >> wrapInOptionalVariant [
<multiSelectAction>
<actionValidIf: #isSandblock>

| variant |
self assert: self block isSelected.
variant := SBVariant new.
self block sandblockEditor multiSelectionIsConsecutive ifFalse: [^ self].
self block sandblockEditor doMultiSelection: [:selected |
SBWrapConsecutiveCommand new
selectAfter: #block;
outer: variant;
targets: selected;
wrap: [:outer :inner |
variant
named: inner printString
alternatives:{
SBNamedBlock block: (SBStBlockBody new statements: inner) named:'with'.
SBNamedBlock block: (SBStBlockBody empty) named:'without'} activeIndex: 2];
yourself]
]

{ #category : #actions }
SBStGrammarHandler >> wrapInReturn [
<action>
Expand Down Expand Up @@ -559,7 +582,12 @@ SBStGrammarHandler >> wrapInVariant [
selectAfter: #block;
outer: variant;
targets: selected;
wrap: [:outer :inner | variant named: inner printString alternatives:{SBNamedBlock block: (SBStBlockBody new statements: inner) named:'alt'} activeIndex: 1];
wrap: [:outer :inner | variant
named: inner printString
alternatives: {
SBNamedBlock block: (SBStBlockBody new statements: inner) named: 'original'.
SBNamedBlock block: (SBStBlockBody new statements: inner veryDeepCopy) named: 'alternative'. }
activeIndex: 2];
yourself]
]

Expand Down
10 changes: 8 additions & 2 deletions packages/Sandblocks-Smalltalk/SBStMethod.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,15 @@ SBStMethod >> methodClass [
]

{ #category : #accessing }
SBStMethod >> methodHeader [
SBStMethod >> methodDefinition [

^ self firstSubmorph
^ SBRow new
layoutPolicy: SBAlgebraLayout new;
addMorphBack: (SBOwnTextMorph new contents:
('{1} >> {2}'
format: {
self currentClass name asString.
self currentSelector asString})).
]

{ #category : #'object interface' }
Expand Down
Loading
Loading