Skip to content

Commit

Permalink
Merge pull request #1258 from pharo-spec/dev-1.0
Browse files Browse the repository at this point in the history
small changes
  • Loading branch information
estebanlm authored Mar 18, 2022
2 parents d6ff725 + 887b91d commit e832d9b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 35 deletions.
29 changes: 21 additions & 8 deletions src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ SpMorphicCodeAdapter >> changeLineNumbers: hasLineNumbers to: aMorph [
{ #category : #'private - shout' }
SpMorphicCodeAdapter >> classOrMetaClass: aClass [

self
setEditingModeFor: self widget textArea
withBehavior: aClass
forScripting: self isForScripting
self suspendObservedPropertiesWhile: [
self
setEditingModeFor: self widget textArea
withBehavior: aClass
forScripting: self isForScripting ]
]

{ #category : #private }
Expand Down Expand Up @@ -203,10 +204,11 @@ SpMorphicCodeAdapter >> setEditingModeFor: textArea [

self hasSyntaxHighlight
ifTrue: [
self
setEditingModeFor: textArea
withBehavior: self behavior
forScripting: self isForScripting ]
self suspendObservedPropertiesWhile: [
self
setEditingModeFor: textArea
withBehavior: self behavior
forScripting: self isForScripting ] ]
ifFalse: [
super setEditingModeFor: textArea ]
]
Expand Down Expand Up @@ -247,6 +249,17 @@ SpMorphicCodeAdapter >> setSyntaxHighlightThemeFor: textArea [
refreshStyling
]

{ #category : #private }
SpMorphicCodeAdapter >> suspendObservedPropertiesWhile: aBlock [
| textHolder textSubscriptions |

textHolder := self presenter observablePropertyNamed: #text.
textSubscriptions := textHolder subscriptions.
textHolder subscriptions: #().
aBlock ensure: [
textHolder subscriptions: textSubscriptions ]
]

{ #category : #private }
SpMorphicCodeAdapter >> textWithStyle [
"This method is to be used for testing.
Expand Down
10 changes: 10 additions & 0 deletions src/Spec2-Code-Tests/SpCodePresenterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ SpCodePresenterTest >> newEnvironment [
^ environment
]

{ #category : #tests }
SpCodePresenterTest >> testChangingEditingModeDoesNotTriggersTextChanged [
| changed |

changed := false.
presenter whenTextChangedDo: [ changed := true ].
presenter beForBehavior: Object.
self deny: changed
]

{ #category : #tests }
SpCodePresenterTest >> testContextKeyBindings [
| contextKeyBindings |
Expand Down
21 changes: 0 additions & 21 deletions src/Spec2-Core/SpListPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,6 @@ SpListPresenter >> iconFor: anItem [
cull: self
]

{ #category : #api }
SpListPresenter >> icons [
"Return the block used to return an icon that will be displayed in the list"
self
deprecated: 'Use #displayIcon'
transformWith: '`@receiver icons' -> '`@receiver displayIcon'.

^ icon
]

{ #category : #api }
SpListPresenter >> icons: aBlock [
"Set a block which takes an item as argument and returns the icon to display in the list.
`aBlock` receives one argument"
self
deprecated: 'Use #displayIcon:'
transformWith: '`@receiver icons: `@arg' -> '`@receiver displayIcon: `@arg'.

icon := aBlock
]

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

Expand Down
5 changes: 5 additions & 0 deletions src/Spec2-Core/SpTPresenterBuilder.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ SpTPresenterBuilder >> newGridLayout [
^ SpGridLayout new
]

{ #category : #'scripting - widgets' }
SpTPresenterBuilder >> newImage [
^ self instantiate: SpImagePresenter
]

{ #category : #'scripting - widgets' }
SpTPresenterBuilder >> newLabel [
^ self instantiate: SpLabelPresenter
Expand Down
2 changes: 1 addition & 1 deletion src/Spec2-Core/SpTextInputFieldPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ SpTextInputFieldPresenter >> whenSubmitDo: aBlock [
`aBlock` receives one argument (the submited text)"

self
bindKeyCombination: Character cr asKeyCombination | $s meta
bindKeyCombination: SpAcceptChangesCommand defaultShortcutKey | Character cr asKeyCombination
toAction: aBlock
]
5 changes: 0 additions & 5 deletions src/Spec2-Morphic/SpTPresenterBuilder.extension.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
Extension { #name : #SpTPresenterBuilder }

{ #category : #'*Spec2-Morphic' }
SpTPresenterBuilder >> newImage [
^ self instantiate: SpImagePresenter
]

{ #category : #'*Spec2-Morphic' }
SpTPresenterBuilder >> newLink [
^ self instantiate: SpLinkPresenter
Expand Down

0 comments on commit e832d9b

Please sign in to comment.