--- a/VDBInstructionsAndSourcePresenter.st Mon Jul 30 17:26:19 2018 +0100
+++ b/VDBInstructionsAndSourcePresenter.st Tue Aug 07 12:17:46 2018 +0100
@@ -45,12 +45,47 @@
"Created: / 26-06-2018 / 12:37:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+lineDigitsToDisplay
+ "Return a number of line digits to display."
+
+ "/ Currently hardcoded but maybe it will be dynamic
+ "/ in future...
+ ^ 5
+
+ "Created: / 09-08-2018 / 11:10:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
subject
"Return an instance of GDB object that this presenter displays."
^ instructionsAndSource
"Created: / 22-06-2018 / 15:10:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+tooltip
+ | source line tooltip |
+
+ source := instructionsAndSource source.
+ source isNil ifTrue:[ ^ instructionsAndSource file, ': ', instructionsAndSource line printString ].
+ line := instructionsAndSource line asInteger.
+ tooltip := TextStream on: ''.
+ tooltip emphasis: #bold;
+ nextPutAll: instructionsAndSource file;
+ emphasis: nil.
+ tooltip cr; cr.
+ ((line - 5) max: 1) to: ((line + 10) min: source size) do:[:i |
+ i == line ifTrue:[ tooltip emphasis: #bold ].
+ i == line ifTrue:[ tooltip nextPut: $> ] ifFalse:[ tooltip space. ].
+ tooltip space.
+ i printOn: tooltip base: 10 size: self lineDigitsToDisplay fill: Character space.
+ tooltip space.
+ tooltip nextPutLine: (source at: i).
+ i == line ifTrue:[ tooltip emphasis: nil ].
+ ].
+ ^ tooltip contents.
+
+ "Created: / 09-08-2018 / 10:45:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBInstructionsAndSourcePresenter methodsFor:'initialization'!
@@ -70,9 +105,15 @@
!
label
- ^ instructionsAndSource file, ': ', instructionsAndSource line printString
+ | source line |
+ source := instructionsAndSource source.
+ line := instructionsAndSource line.
+ ^ (source notNil and:[ line notNil and: [ instructionsAndSource line asInteger between: 1 and: source size]])
+ ifTrue:[ (line printStringRadix: 10 size: self lineDigitsToDisplay fill: Character space) , Character space , (source at: line asInteger) ]
+ ifFalse:[ instructionsAndSource file, ': ', instructionsAndSource line printString ].
"Created: / 22-06-2018 / 12:22:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-08-2018 / 11:10:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBInstructionsAndSourcePresenter methodsFor:'testing'!
@@ -81,3 +122,10 @@
^ true
! !
+!VDBInstructionsAndSourcePresenter class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+