VDBInstructionListApplication.st
changeset 92 fa04de209c69
parent 80 7a9cf1d6be50
child 93 bd0a7febf26d
--- a/VDBInstructionListApplication.st	Tue Aug 07 12:17:46 2018 +0100
+++ b/VDBInstructionListApplication.st	Tue Aug 07 15:42:24 2018 +0100
@@ -13,7 +13,7 @@
 VDBAbstractTreeApplication subclass:#VDBInstructionListApplication
 	instanceVariableNames:'instructionListHolder instructionBasicBlocks
 		selectedInstructionHolder selectedInstructionBranchTargetAddress
-		selectedInstructionBasicBlock'
+		selectedInstructionBasicBlock frameHolder'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'VDB-UI-Others'
@@ -53,6 +53,24 @@
 
 !VDBInstructionListApplication methodsFor:'accessing'!
 
+frame
+    ^ self frameHolder value
+
+    "Created: / 06-08-2018 / 13:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+frame: aGDBFrame
+    self frameHolder value: aGDBFrame
+
+    "Created: / 06-08-2018 / 13:22:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+instructionList
+    ^ self instructionListHolder value
+
+    "Created: / 07-08-2018 / 13:27:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 instructionList: aCollection
     self instructionListHolder value: aCollection
 
@@ -61,7 +79,13 @@
 
 !VDBInstructionListApplication methodsFor:'aspects'!
 
-backgroundColorFor: aVDBPresenter 
+backgroundColorFor: aVDBPresenter
+    (frameHolder value notNil and:[aVDBPresenter isInstructionPresenter]) ifTrue:[ 
+        frameHolder value address == aVDBPresenter address ifTrue:[ 
+            ^ Color green.
+        ].
+    ].
+
     selectedInstructionBranchTargetAddress notNil ifTrue:[ 
         aVDBPresenter isInstructionPresenter ifTrue:[ 
             aVDBPresenter instruction address = selectedInstructionBranchTargetAddress ifTrue:[ 
@@ -77,7 +101,7 @@
     ^ nil
 
     "Created: / 26-06-2018 / 11:26:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (format): / 27-06-2018 / 16:08:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 06-08-2018 / 12:29:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 foregroundColorFor: aVDBAbstractPresenter
@@ -88,6 +112,35 @@
     "Created: / 26-06-2018 / 13:07:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+frameHolder
+    "return/create the 'frameHolder' value holder (automatically generated)"
+
+    frameHolder isNil ifTrue:[
+        frameHolder := ValueHolder new.
+        frameHolder addDependent:self.
+    ].
+    ^ frameHolder
+!
+
+frameHolder:something
+    "set the 'frameHolder' value holder (automatically generated)"
+
+    |oldValue newValue|
+
+    frameHolder notNil ifTrue:[
+        oldValue := frameHolder value.
+        frameHolder removeDependent:self.
+    ].
+    frameHolder := something.
+    frameHolder notNil ifTrue:[
+        frameHolder addDependent:self.
+    ].
+    newValue := frameHolder value.
+    oldValue ~~ newValue ifTrue:[
+        self update:#value with:newValue from:frameHolder.
+    ].
+!
+
 instructionListHolder
     "return/create the 'instructionListHolder' value holder (automatically generated)"
 
@@ -161,12 +214,22 @@
          self enqueueDelayedUpdateInternalList.
          ^ self.
     ].
+    sender == frameHolder ifTrue:[ 
+         self updateAfterFrameChanged.
+         ^ self.
+    ].
     sender == selectedInstructionHolder ifTrue:[ 
         self updateAfterSelectedInstructionChanged.
     ].
     super update:aspect with:param from:sender
 
-    "Modified: / 26-06-2018 / 12:46:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 06-08-2018 / 13:23:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateAfterFrameChanged
+    self debugger: self frame debugger
+
+    "Created: / 06-08-2018 / 13:24:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 updateAfterSelectedInstructionChanged
@@ -225,13 +288,16 @@
         ]).
     root expand.
     root children do:[:each | each expand ].
+    self frame notNil ifTrue:[ 
+        self scrollToAddress: self frame address.
+    ].
     internalListView notNil ifTrue:[
         internalListView invalidate.
     ].
     self enqueueDelayedUpdateBasicBlocks.
 
     "Created: / 27-02-2015 / 15:47:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 26-06-2018 / 12:45:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-08-2018 / 13:45:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 delayedUpdateSelection
@@ -247,6 +313,27 @@
     "Modified: / 22-06-2018 / 15:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!VDBInstructionListApplication methodsFor:'event handling'!
+
+onStoppedEvent: aGDBStoppedEvent
+    self frame notNil ifTrue:[ 
+        self enqueueDelayedInvalidateInternalList
+    ].
+
+    "Created: / 06-08-2018 / 14:45:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!VDBInstructionListApplication methodsFor:'initialization & release'!
+
+subscribe   
+    "Register for debugger events. To be overrided by subclasses"
+
+    debugger announcer 
+        when: GDBStoppedEvent send: #onStoppedEvent: to: self.
+
+    "Created: / 06-08-2018 / 14:44:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !VDBInstructionListApplication methodsFor:'private'!
 
 instructionPresentersDo: aBlock
@@ -269,6 +356,21 @@
     "Created: / 22-06-2018 / 15:07:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!VDBInstructionListApplication methodsFor:'scrolling'!
+
+scrollToAddress: address
+    internalListView isNil ifTrue:[ ^ self ].
+    (self frame notNil and:[ self instructionList notEmptyOrNil ]) ifTrue:[ 
+        self instructionPresentersDo:[ :each |
+            each address = address ifTrue:[ 
+                self scrollToListItem: each.
+            ].
+        ]
+    ].
+
+    "Created: / 07-08-2018 / 13:36:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !VDBInstructionListApplication class methodsFor:'documentation'!
 
 version_HG