Skip to content

Commit

Permalink
core: add some nil checks, expose functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Oct 9, 2023
1 parent 707fc4d commit b01dabf
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
15 changes: 9 additions & 6 deletions packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Class {
}

{ #category : #accessing }
SBExampleValueDisplay >> exampleFinished: anExample [
SBExampleValueDisplay >> exampleFinished: anExample [

display exampleFinished: anExample.

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

{ #category : #accessing }
Expand Down Expand Up @@ -69,11 +69,13 @@ SBExampleValueDisplay >> layoutCommands [

^ SBAlgebraCommand container
morph: self;
data: (self submorphs collect: #layoutCommands separatedBy: [SBAlgebraCommand gap])
data: ((self submorphs select: [:s | s visible])
collect: #layoutCommands
separatedBy: [SBAlgebraCommand gap])
]

{ #category : #naming }
SBExampleValueDisplay >> name: aString [
SBExampleValueDisplay >> name: aString [

label contents: aString
]
Expand All @@ -83,5 +85,6 @@ SBExampleValueDisplay >> reportValue: anObject name: aString [

display reportValue: anObject.
label contents: aString.
label visible: aString notEmpty.
hadValue := true
]
6 changes: 6 additions & 0 deletions packages/Sandblocks-Core/SBBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,12 @@ SBBlock >> dynamicNumberOfChildren [
^ self fixedNumberOfChildren not
]

{ #category : #'colors and color policies' }
SBBlock >> emphasis [

^ self colorPolicy defaultEmphasis
]

{ #category : #actions }
SBBlock >> endInput [
<inputAction>
Expand Down
6 changes: 4 additions & 2 deletions packages/Sandblocks-Core/SBEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,9 @@ SBEditor >> performForSelection: anActionSymbol [
self selection notNil ifTrue: [(self selection performAction: anActionSymbol) ifTrue: [^ true]].

globalShortcutListeners do: [:listener |
(listener lookupGlobalAction: anActionSymbol) ifNotNil: [listener perform: anActionSymbol. ^ true]].
(listener lookupGlobalAction: anActionSymbol) ifNotNil: [
listener perform: anActionSymbol.
^ true]].

^ false
]
Expand Down Expand Up @@ -1679,7 +1681,7 @@ SBEditor >> summarizeActionsDuring: aBlock [
{ #category : #'as yet unclassified' }
SBEditor >> textFocus [

^ self selection activeTextMorph
^ self selection ifNotNil: #activeTextMorph
]

{ #category : #actions }
Expand Down
11 changes: 10 additions & 1 deletion packages/Sandblocks-Core/SBErrorDecorator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ SBErrorDecorator >> fixActions: aCollection [
fixActions := aCollection
]

{ #category : #'as yet unclassified' }
SBErrorDecorator >> message [

^ message
]

{ #category : #'as yet unclassified' }
SBErrorDecorator >> message: aString [

Expand Down Expand Up @@ -58,6 +64,9 @@ SBErrorDecorator >> subtle: aBoolean [
{ #category : #'as yet unclassified' }
SBErrorDecorator >> tryFixIfFail: aBlock [

| index |
(fixActions isNil or: [fixActions isEmpty]) ifTrue: [^ aBlock value].
self morph proposeCodeActions: fixActions for: self morph

index := UIManager default chooseFrom: (fixActions collect: #label).
index > 0 ifTrue: [(fixActions at: index) do] ifFalse: [^ aBlock value]
]
10 changes: 10 additions & 0 deletions packages/Sandblocks-Morphs/SBMultilineOwnTextMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ SBMultilineOwnTextMorph >> selectionBounds [
^ {self selectionBound min: self cursor. self selectionBound max: self cursor}
]

{ #category : #'as yet unclassified' }
SBMultilineOwnTextMorph >> setBoundsDirect: aRectangle [

| delta |
delta := aRectangle origin - bounds origin.
paragraph ifNotNil: [:p | p moveBy: delta].

super setBoundsDirect: aRectangle
]

{ #category : #'as yet unclassified' }
SBMultilineOwnTextMorph >> showPlaceholder [

Expand Down

0 comments on commit b01dabf

Please sign in to comment.