VDBSourceApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 01 Jun 2017 12:23:04 +0100
changeset 40 d766d4c854a2
parent 20 f323725d7b18
child 44 41cc5a7840fe
permissions -rw-r--r--
Cleanup in debugger and inferior console applications to catch up changes in `jv:libgdbs` Recent `jv:libgdbs` spawns GDB on a PTY and opening MI channel on another, debugger console has no need to emulate history, command completion and all that stuff. This is now handled by GDB itself.

"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

VDBAbstractApplication subclass:#VDBSourceApplication
	instanceVariableNames:'frameHolder sourceFileHolder sourceStringHolder sourceView'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Source'
!


!VDBSourceApplication class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:VDBSourceApplication andSelector:#windowSpec
     VDBSourceApplication new openInterface:#windowSpec
     VDBSourceApplication open
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       window: 
      (WindowSpec
         label: 'Source View'
         name: 'Source View'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 300 300)
       )
       component: 
      (SpecCollection
         collection: (
          (NonScrollableArbitraryComponentSpec
             name: 'SourceView'
             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
             model: sourceStringHolder
             component: sourceView
           )
          )
        
       )
     )
! !

!VDBSourceApplication class methodsFor:'plugIn spec'!

aspectSelectors
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this. If it is corrupted,
     the UIPainter may not be able to read the specification."

    "Return a description of exported aspects;
     these can be connected to aspects of an embedding application
     (if this app is embedded in a subCanvas)."

    ^ #(
        #debuggerHolder
        #frameHolder
      ).

! !

!VDBSourceApplication methodsFor:'aspects'!

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.
    ].
!

sourceFileHolder
    "return/create the 'sourceFileHolder' value holder (automatically generated)"

    sourceFileHolder isNil ifTrue:[
        sourceFileHolder := ValueHolder new.
        sourceFileHolder addDependent:self.
    ].
    ^ sourceFileHolder
!

sourceFileHolder:something
    "set the 'sourceFileHolder' value holder (automatically generated)"

    |oldValue newValue|

    sourceFileHolder notNil ifTrue:[
        oldValue := sourceFileHolder value.
        sourceFileHolder removeDependent:self.
    ].
    sourceFileHolder := something.
    sourceFileHolder notNil ifTrue:[
        sourceFileHolder addDependent:self.
    ].
    newValue := sourceFileHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:sourceFileHolder.
    ].
!

sourceStringHolder
    "return/create the 'sourceStringHolder' value holder (automatically generated)"

    sourceStringHolder isNil ifTrue:[
        sourceStringHolder := ValueHolder new.
        sourceStringHolder addDependent:self.
    ].
    ^ sourceStringHolder
!

sourceStringHolder:something
    "set the 'sourceStringHolder' value holder (automatically generated)"

    |oldValue newValue|

    sourceStringHolder notNil ifTrue:[
        oldValue := sourceStringHolder value.
        sourceStringHolder removeDependent:self.
    ].
    sourceStringHolder := something.
    sourceStringHolder notNil ifTrue:[
        sourceStringHolder addDependent:self.
    ].
    newValue := sourceStringHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:sourceStringHolder.
    ].
!

sourceView
    sourceView isNil ifTrue:[ 
        sourceView := Tools::CodeView2 new.
        sourceView readOnly: true.
        sourceView services: #()        
    ].
    ^ sourceView

    "Created: / 21-09-2014 / 01:42:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSourceApplication methodsFor:'change & update'!

update:aspect with:param from:sender
    "Invoked when an object that I depend upon sends a change notification."

    sender == frameHolder ifTrue:[ 
        | frame |

        frame := frameHolder value.
        frame notNil ifTrue:[ 
            | line |

            self sourceFileHolder value: frame fullname.
            line := frame line.
            line notNil ifTrue:[  
                sourceView selectLine: line.
                sourceView makeSelectionVisible.
            ]
        ].
        ^ self.
    ].

    sender == sourceFileHolder ifTrue:[
        | file source |

        source := nil.
        file := sourceFileHolder value.
        file notNil ifTrue:[ 
            file := file asFilename.
            file exists ifTrue:[ 
                source := file contents asString.
            ]
        ].
        self sourceStringHolder value: source.  
        ^ self.
    ].
    super update:aspect with:param from:sender

    "Modified: / 21-09-2014 / 00:15:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSourceApplication class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !