Skip to content

Dynamic code lines show updates in the debugger #1113

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

Open
wants to merge 9 commits into
base: Pharo13
Choose a base branch
from
21 changes: 21 additions & 0 deletions src/NewTools-Core-Tests/StPharoApplicationTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ Class {
#tag : 'Application'
}

{ #category : 'tests' }
StPharoApplicationTest >> testSettingChangesSubscription [

| app presenter window oldSetting |
app := StPharoApplication basicNew.
app subscribeToSettingsAnnouncements.
presenter := StTestSettingChangeReactivePresenter new.
presenter application: app.
window := SpWindowPresenter presenter: presenter.
app registerWindow: window.

self assert: presenter changedSetting isNil.

oldSetting := StPharoSettings codeShowLineNumbers.
StPharoSettings codeShowLineNumbers: oldSetting.

self
assert: presenter changedSetting class
identicalTo: CodeShowLineNumbersChanged
]

{ #category : 'tests' }
StPharoApplicationTest >> testToolRegistration [

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"
I'm a test presenter for testing how the StPresenters react to settings changes announcements from their applications.
"
Class {
#name : 'StTestSettingChangeReactivePresenter',
#superclass : 'StPresenter',
#instVars : [
'changedSetting'
],
#category : 'NewTools-Core-Tests-Application',
#package : 'NewTools-Core-Tests',
#tag : 'Application'
}

{ #category : 'accessing' }
StTestSettingChangeReactivePresenter >> changedSetting [

^ changedSetting
]

{ #category : 'layout' }
StTestSettingChangeReactivePresenter >> defaultLayout [
^SpBoxLayout new
]

{ #category : 'initialization' }
StTestSettingChangeReactivePresenter >> initialize [

super initialize.
self announcer
when: CodeShowLineNumbersChanged
send: #settingChanged:
to: self
]

{ #category : 'as yet unclassified' }
StTestSettingChangeReactivePresenter >> settingChanged: aSettingChangedAnnouncement [

changedSetting := aSettingChangedAnnouncement
]
30 changes: 28 additions & 2 deletions src/NewTools-Core/StPharoApplication.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ StPharoApplication class >> use: application during: aBlock [
^ aBlock ensure: [ Current := oldCurrent ]
]

{ #category : 'settings' }
StPharoApplication >> codeShowLineNumbers [

^ StPharoSettings codeShowLineNumbers
]

{ #category : 'accessing - resources' }
StPharoApplication >> defaultWindowExtent [

Expand All @@ -64,14 +70,18 @@ StPharoApplication >> defaultWindowPresenterClass [
StPharoApplication >> initialize [

super initialize.
self initializeConfiguration
self initializeConfiguration.
self subscribeToSettingsAnnouncements
]

{ #category : 'initialization' }
StPharoApplication >> initializeConfiguration [

self resetConfiguration.
self class codeSupportAnnouncer weak when: UIThemeChanged send: #resetConfiguration to: self
self class codeSupportAnnouncer weak
when: UIThemeChanged
send: #resetConfiguration
to: self
]

{ #category : 'private - factory' }
Expand Down Expand Up @@ -115,13 +125,29 @@ StPharoApplication >> run [
StPharoApplication >> shutDown: quitting [
]

{ #category : 'settings' }
StPharoApplication >> stPharoSettingChanged: aPharoSettingChangeAnnouncement [

(self windows collect: #presenter) do: [ :presenter |
presenter announce: aPharoSettingChangeAnnouncement ]
]

{ #category : 'system startup' }
StPharoApplication >> startUp: resuming [

self resetConfiguration.
self resetBackend.
]

{ #category : 'settings' }
StPharoApplication >> subscribeToSettingsAnnouncements [

self class codeSupportAnnouncer weak
when: CodeShowLineNumbersChanged
send: #stPharoSettingChanged:
to: self
]

{ #category : 'tool management' }
StPharoApplication >> toolNamed: aName [

Expand Down
14 changes: 5 additions & 9 deletions src/NewTools-Core/StPharoSettings.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ Class {
StPharoSettings class >> codeShowLineNumbers [
"Defines if code editors will display line numbers"

^ CodeShowLineNumbers ifNil: [ CodeShowLineNumbers := self defaultCodeShowLineNumbers ]
^ CodeShowLineNumbers ifNil: [
CodeShowLineNumbers := StPharoApplication defaultCodeShowLineNumbers ]
]

{ #category : 'settings' }
StPharoSettings class >> codeShowLineNumbers: aBoolean [
StPharoSettings class >> codeShowLineNumbers: aBoolean [

CodeShowLineNumbers := aBoolean
]

{ #category : 'defaults' }
StPharoSettings class >> defaultCodeShowLineNumbers [

^ true
CodeShowLineNumbers := aBoolean.
self codeSupportAnnouncer announce: CodeShowLineNumbersChanged new
]

{ #category : 'defaults' }
Expand Down
31 changes: 26 additions & 5 deletions src/NewTools-Debugger/StDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,12 @@ StDebugger >> codeLayout [
yourself
]

{ #category : 'subscription' }
StDebugger >> codeShowLineNumbersChanged: aCodeShowLineNumbersChangedAnnouncement [

self code announce: aCodeShowLineNumbersChangedAnnouncement
]

{ #category : 'initialization' }
StDebugger >> connectPresenters [

Expand Down Expand Up @@ -797,10 +803,11 @@ StDebugger >> initialize [
super initialize.
self debuggerActionModel updateContextPredicate.
self forceSessionUpdate.
self subscribeToExtensionToggleAnnouncement.
self subscribeToExtensionToggleAnnouncement.
self subscribeToLayoutChangesAnnouncement.

programmaticallyClosed := false.
self subscribeToSettingsChangesAnnouncements.

programmaticallyClosed := false
]

{ #category : 'initialization' }
Expand All @@ -815,7 +822,7 @@ StDebugger >> initializeCode [

code := self instantiate: StDebuggerCodePresenter.
code debuggerActionModel: self debuggerActionModel.
code whenSubmitDo: [ :text |
code whenSubmitDo: [ :text |
self acceptCodeChanges: text string forContext: self selectedContext ].
code whenResetDo: [ self discardCodeChangesFor: self selectedContext ]
]
Expand Down Expand Up @@ -857,7 +864,6 @@ StDebugger >> initializePresenters [
self initializeInspector.
self initializeExtensionTools.
self setStackAndCodeContainer.

self layout: self defaultLayout
]

Expand Down Expand Up @@ -1200,6 +1206,12 @@ StDebugger >> settings [
^ self class settings
]

{ #category : 'subscription' }
StDebugger >> showLineNumbersAndUpdate [

self code showLineNumbersAndUpdate
]

{ #category : 'stack' }
StDebugger >> stack [
^ self debuggerActionModel stack
Expand Down Expand Up @@ -1374,6 +1386,15 @@ StDebugger >> subscribeToLayoutChangesAnnouncement [
self class codeSupportAnnouncer weak when: StDebuggerLayoutChangedAnnouncement send: #updateLayout to: self
]

{ #category : 'subscription' }
StDebugger >> subscribeToSettingsChangesAnnouncements [

self announcer
when: CodeShowLineNumbersChanged
send: #codeShowLineNumbersChanged:
to: self
]

{ #category : 'toolbar' }
StDebugger >> toolbarAdvancedCommandsGroups [

Expand Down
Loading