Skip to content

Commit

Permalink
core: add utility funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Sep 27, 2023
1 parent 0c63888 commit 008b33b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
8 changes: 7 additions & 1 deletion packages/Sandblocks-Core/Morph.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Morph >> basicCursorPositionsDo: aBlock shallow: aBoolean [
self visibleSubmorphsDo: [:morph |
morph isSandblock ifTrue: [self containingSandblock insertCursorNear: morph before: true do: aBlock].
morph isTextMorph ifTrue: [
morph containingSandblock startInputCommand ifNotNil: [:command |
(morph containingSandblock startInputCommandIn: morph) ifNotNil: [:command |
aBlock value: (SBCursorText new
block: morph containingSandblock;
currentCommand: command)]].
Expand Down Expand Up @@ -344,6 +344,12 @@ Morph >> morphAfterThat: aBlock [
(aBlock value: next) ifTrue: [^ next]] repeat
]

{ #category : #'*Sandblocks-Core-hierarchy' }
Morph >> morphBeforeOrAfter: aBeforeBoolean [

^ aBeforeBoolean ifTrue: [self submorphBefore] ifFalse: [self submorphAfter]
]

{ #category : #'*Sandblocks-Core' }
Morph >> morphBeforeThat: aBlock [

Expand Down
4 changes: 2 additions & 2 deletions packages/Sandblocks-Core/SBBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SBBlock >> actions [
SBBlock >> activeTextMorph [

| candidate |
candidate := self sandblockEditor currentInputCommand ifNotNil: #textMorph.
candidate := (self sandblockEditor ifNil: [^ nil]) currentInputCommand ifNotNil: #textMorph.
candidate ifNil: [^ nil].
(self textMorphs includes: candidate) ifFalse: [^ nil].
^ candidate
Expand Down Expand Up @@ -2073,7 +2073,7 @@ SBBlock >> objectInterfaceNear: aBlock at: aSymbol [
SBBlock >> open [
" tries to find the current SBEditor and open our block in it "

SBExecutionEnvironment value sandblockEditor
(SBExecutionEnvironment value ifNotNil: #sandblockEditor)
ifNotNil: [:editor | editor openMorphInView: self]
ifNil: [self error: 'No editor found in execution context']
]
Expand Down
47 changes: 47 additions & 0 deletions packages/Sandblocks-Core/SBFlashDecorator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Class {
#name : #SBFlashDecorator,
#superclass : #SBBlockDecorator,
#instVars : [
'endTime'
],
#category : #'Sandblocks-Core'
}

{ #category : #'as yet unclassified' }
SBFlashDecorator >> attached: aMorph [

super attached: aMorph.
endTime := Time millisecondClock + self duration
]

{ #category : #'as yet unclassified' }
SBFlashDecorator >> color [

^ (Color r: 1 g: 1 b: 0.0) alpha: (endTime - Time millisecondClock / self duration) asFloat
]

{ #category : #'as yet unclassified' }
SBFlashDecorator >> duration [

^ 400
]

{ #category : #'as yet unclassified' }
SBFlashDecorator >> postDrawOn: aCanvas [

self color alpha.
aCanvas frameRectangle: self morph bounds width: 4 color: self color
]

{ #category : #'as yet unclassified' }
SBFlashDecorator >> step [

Time millisecondClock > endTime ifTrue: [self detach].
self morph changed
]

{ #category : #'as yet unclassified' }
SBFlashDecorator >> stepTime [

^ 0
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Core/SBHoverDecorator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SBHoverDecorator >> position: aPoint [
{ #category : #'as yet unclassified' }
SBHoverDecorator >> postDrawOn: aCanvas [

(self shown and: [SBPreferences showHoverDecorator and: [cursor notNil and: [ActiveHand hasSubmorphs not]]]) ifTrue: [ | c |
(self shown and: [SBPreferences showHoverDecorator and: [cursor notNil and: [ActiveHand hasSubmorphs not and: [morph sandblockEditor ~= morph]]]]) ifTrue: [ | c |
c := (cursor isKindOf: SBCursorText)
ifTrue: [SBCursorSelect new block: cursor block]
ifFalse: [cursor].
Expand Down
6 changes: 6 additions & 0 deletions packages/Sandblocks-Morphs/SBMultilineOwnTextMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Class {
#category : #'Sandblocks-Morphs'
}

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


]

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

Expand Down
6 changes: 6 additions & 0 deletions packages/Sandblocks-Morphs/SBOwnTextMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ SBOwnTextMorph >> bold [
self emphasis: TextEmphasis bold
]

{ #category : #'as yet unclassified' }
SBOwnTextMorph >> characterBeforeCursor [

^ self cursor = 1 ifTrue: [nil] ifFalse: [self contents at: self cursor - 1]
]

{ #category : #'as yet unclassified' }
SBOwnTextMorph >> clear [

Expand Down

0 comments on commit 008b33b

Please sign in to comment.