VDBSimpleDebuggerConsoleApplication.st
changeset 139 c619cc458fb1
parent 138 8b44ccd9ae58
child 143 df7f89efd39d
equal deleted inserted replaced
138:8b44ccd9ae58 139:c619cc458fb1
     8 "
     8 "
     9 "{ Package: 'jv:vdb' }"
     9 "{ Package: 'jv:vdb' }"
    10 
    10 
    11 "{ NameSpace: Smalltalk }"
    11 "{ NameSpace: Smalltalk }"
    12 
    12 
    13 VDBAbstractApplication subclass:#VDBSimpleDebuggerConsoleApplication
    13 VDBAbstractConsoleApplication subclass:#VDBSimpleDebuggerConsoleApplication
    14 	instanceVariableNames:'consoleView consoleInput consoleOutput consoleOutputLock
    14 	instanceVariableNames:'consoleInput consoleOutput consoleOutputLock consoleProcess
    15 		consoleProcess consolePrompt consolePromptPrinted
    15 		consolePrompt consolePromptPrinted outstandingCommand
    16 		outstandingCommand outstandingCommandToken
    16 		outstandingCommandToken outstandingCommandBlocker
    17 		outstandingCommandBlocker ignoreNextLogStreamEvent running'
    17 		ignoreNextLogStreamEvent running'
    18 	classVariableNames:''
    18 	classVariableNames:''
    19 	poolDictionaries:'GDBCommandStatus'
    19 	poolDictionaries:'GDBCommandStatus'
    20 	category:'VDB-UI-Console'
    20 	category:'VDB-UI-Console'
    21 !
    21 !
    22 
    22 
    44 
    44 
    45     "Created: / 08-01-2018 / 18:59:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    45     "Created: / 08-01-2018 / 18:59:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    46     "Modified: / 03-10-2018 / 15:39:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    46     "Modified: / 03-10-2018 / 15:39:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    47 ! !
    47 ! !
    48 
    48 
    49 !VDBSimpleDebuggerConsoleApplication class methodsFor:'interface specs'!
    49 !VDBSimpleDebuggerConsoleApplication class methodsFor:'startup-web applications'!
    50 
    50 
    51 windowSpec
    51 initialPageSpec
    52     "This resource specification was automatically generated
    52     "this is only required for web-applications"
    53      by the UIPainter of ST/X."
    53 
    54 
    54     ^ self shouldImplement
    55     "Do not manually edit this!! If it is corrupted,
    55 !
    56      the UIPainter may not be able to read the specification."
    56 
    57 
    57 pageSpecs
    58     "
    58     "this is only required for web-applications"
    59      UIPainter new openOnClass:VDBSimpleDebuggerConsoleApplication andSelector:#windowSpec
    59 
    60      VDBSimpleDebuggerConsoleApplication new openInterface:#windowSpec
    60     ^ self shouldImplement
    61      VDBSimpleDebuggerConsoleApplication open
    61 ! !
    62     "
    62 
    63 
    63 !VDBSimpleDebuggerConsoleApplication methodsFor:'accessing'!
    64     <resource: #canvas>
    64 
    65 
    65 consoleInput
    66     ^ 
    66     ^ consoleInput
    67     #(FullSpec
    67 
    68        name: windowSpec
    68     "Created: / 21-01-2019 / 14:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    69        uuid: '28fb22b0-fe61-11e8-90a6-606720e43e2c'
    69 !
    70        window: 
    70 
    71       (WindowSpec
    71 consoleOutput
    72          label: 'Debugger Console'
    72     ^ consoleOutput
    73          name: 'Debugger Console'
    73 
    74          uuid: '28fb22b1-fe61-11e8-90a6-606720e43e2c'
    74     "Created: / 21-01-2019 / 14:18:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    75          min: (Point 10 10)
       
    76          bounds: (Rectangle 0 0 782 332)
       
    77        )
       
    78        component: 
       
    79       (SpecCollection
       
    80          collection: (
       
    81           (ArbitraryComponentSpec
       
    82              name: 'Console'
       
    83              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
       
    84              uuid: '28fb22b2-fe61-11e8-90a6-606720e43e2c'
       
    85              hasHorizontalScrollBar: true
       
    86              hasVerticalScrollBar: true
       
    87              miniScrollerHorizontal: true
       
    88              autoHideScrollBars: true
       
    89              hasBorder: false
       
    90              component: consoleView
       
    91            )
       
    92           )
       
    93         
       
    94        )
       
    95      )
       
    96 ! !
       
    97 
       
    98 !VDBSimpleDebuggerConsoleApplication class methodsFor:'plugIn spec'!
       
    99 
       
   100 aspectSelectors
       
   101     "This resource specification was automatically generated
       
   102      by the UIPainter of ST/X."
       
   103 
       
   104     "Do not manually edit this. If it is corrupted,
       
   105      the UIPainter may not be able to read the specification."
       
   106 
       
   107     "Return a description of exported aspects;
       
   108      these can be connected to aspects of an embedding application
       
   109      (if this app is embedded in a subCanvas)."
       
   110 
       
   111     ^ #(
       
   112         #debuggerHolder
       
   113       ).
       
   114 
       
   115 ! !
    75 ! !
   116 
    76 
   117 !VDBSimpleDebuggerConsoleApplication methodsFor:'actions'!
    77 !VDBSimpleDebuggerConsoleApplication methodsFor:'actions'!
   118 
    78 
   119 doComplete: line
    79 doComplete: line
   143     "Modified: / 16-01-2019 / 14:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   103     "Modified: / 16-01-2019 / 14:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   144 ! !
   104 ! !
   145 
   105 
   146 !VDBSimpleDebuggerConsoleApplication methodsFor:'aspects'!
   106 !VDBSimpleDebuggerConsoleApplication methodsFor:'aspects'!
   147 
   107 
   148 consoleView
   108 consoleViewClass
   149     consoleView isNil ifTrue:[
   109     ^ VDBSimpleDebuggerConsoleView
   150         consoleView := VDBSimpleDebuggerConsoleView new.
   110 
   151         consoleView
   111     "Modified: / 21-01-2019 / 14:22:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   152             font:self textFont;
       
   153             foregroundColor:Color white backgroundColor:Color black;
       
   154             cursorForegroundColor:Color white backgroundColor:Color white.
       
   155         consoleView localEcho:true.
       
   156         consoleView inputTranslateCRToNL:true.
       
   157         consoleView lineEditMode:true.
       
   158         consoleView inStream:consoleInput.
       
   159         consoleView outStream:consoleOutput.
       
   160         consoleView startReaderProcessWhenVisible.
       
   161         self initializeCompletion
       
   162     ].
       
   163     ^ consoleView
       
   164 
       
   165     "Created: / 09-06-2014 / 10:11:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   166     "Modified: / 04-04-2018 / 22:40:59 / jv"
       
   167     "Modified: / 16-01-2019 / 14:43:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   168 ! !
   112 ! !
   169 
   113 
   170 !VDBSimpleDebuggerConsoleApplication methodsFor:'event handling'!
   114 !VDBSimpleDebuggerConsoleApplication methodsFor:'event handling'!
   171 
   115 
   172 onCmdParamChanged: event
   116 onCmdParamChanged: event
   291     super initialize.
   235     super initialize.
   292 
   236 
   293     consoleInput := GDBInternalPipeStream new.
   237     consoleInput := GDBInternalPipeStream new.
   294     consoleOutput := GDBInternalPipeStream new.
   238     consoleOutput := GDBInternalPipeStream new.
   295     consoleOutputLock := RecursionLock new.
   239     consoleOutputLock := RecursionLock new.
   296     consolePrompt := '(vdb) '.
   240     consolePrompt := '(gdb) '.
   297     consolePromptPrinted := false.
   241     consolePromptPrinted := false.
   298     running := false.
   242     running := false.
   299     outstandingCommandBlocker := Semaphore new.
   243     outstandingCommandBlocker := Semaphore new.
   300     ignoreNextLogStreamEvent := false.
   244     ignoreNextLogStreamEvent := false.
   301 
   245 
   302     "Created: / 10-06-2014 / 01:23:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   246     "Created: / 10-06-2014 / 01:23:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   303     "Modified: / 07-04-2018 / 23:13:27 / jv"
   247     "Modified: / 07-04-2018 / 23:13:27 / jv"
   304     "Modified: / 19-01-2019 / 23:55:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   248     "Modified: / 21-01-2019 / 15:37:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   305 !
   249 !
   306 
   250 
   307 initializeCompletion
   251 initializeConsoleView: aTerminalView
   308     consoleView isNil ifTrue:[ ^ self ].
   252     super initializeConsoleView: aTerminalView.
   309     (debugger notNil and:[debugger hasCommand:'-complete']) ifTrue:[ 
   253     aTerminalView localEcho:true.
   310         consoleView completionBlock: [ :prefix | self doComplete: prefix ]
   254     aTerminalView inputTranslateCRToNL:true.
       
   255     aTerminalView lineEditMode:true.
       
   256 
       
   257     "Created: / 21-01-2019 / 14:13:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   258     "Modified: / 21-01-2019 / 15:33:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   259 !
       
   260 
       
   261 initializeConsoleView: aTerminalView forDebugger: aGDBDebugger
       
   262     super initializeConsoleView: aTerminalView forDebugger: aGDBDebugger.
       
   263     (aGDBDebugger notNil and:[aGDBDebugger hasCommand:'-complete']) ifTrue:[ 
       
   264         consoleView completionBlock: [ :prefix | self doComplete: prefix ].
       
   265         consolePrompt := debugger getParameter: 'prompt'.
   311     ] ifFalse:[ 
   266     ] ifFalse:[ 
   312         consoleView completionBlock: nil
   267         consoleView completionBlock: nil.
   313     ].
   268         consolePrompt := '(gdb) '
   314 
   269     ].
   315     "Created: / 16-01-2019 / 14:42:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   270 
       
   271     "Created: / 21-01-2019 / 15:33:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   272     "Modified: / 21-01-2019 / 17:49:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   316 !
   273 !
   317 
   274 
   318 release
   275 release
   319     super release.
   276     super release.
   320     consoleProcess terminate.
   277     consoleProcess terminate.
   323 !
   280 !
   324 
   281 
   325 subscribe   
   282 subscribe   
   326     "Register for debugger events. To be overrided by subclasses"
   283     "Register for debugger events. To be overrided by subclasses"
   327 
   284 
       
   285     super subscribe.
   328     debugger announcer 
   286     debugger announcer 
   329         when: GDBCommandEvent           send: #onCommandEvent:          to: self;
   287         when: GDBCommandEvent           send: #onCommandEvent:          to: self;
   330         when: GDBCommandResultEvent     send: #onCommandResultEvent:    to: self;
   288         when: GDBCommandResultEvent     send: #onCommandResultEvent:    to: self;
   331 
   289 
   332         when: GDBRunningEvent           send: #onRunningEvent:          to: self;
   290         when: GDBRunningEvent           send: #onRunningEvent:          to: self;
   338 
   296 
   339         when: GDBEventSetProcessingFinished send: #onEventSetProcessingFinished: to: self;
   297         when: GDBEventSetProcessingFinished send: #onEventSetProcessingFinished: to: self;
   340 
   298 
   341         when: GDBCmdParamChangedEvent send: #onCmdParamChanged: to: self.
   299         when: GDBCmdParamChangedEvent send: #onCmdParamChanged: to: self.
   342 
   300 
   343     consolePrompt := debugger getParameter: 'prompt'.
       
   344 
       
   345     running := debugger inferiors anySatisfy:[ :tg | tg isRunning ].
   301     running := debugger inferiors anySatisfy:[ :tg | tg isRunning ].
   346 
   302 
   347     self initializeCompletion.
       
   348 
       
   349     "Created: / 06-06-2014 / 21:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   303     "Created: / 06-06-2014 / 21:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   350     "Modified: / 19-01-2019 / 23:51:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   304     "Modified: / 21-01-2019 / 15:37:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   351 ! !
   305 ! !
   352 
   306 
   353 !VDBSimpleDebuggerConsoleApplication methodsFor:'private - console process'!
   307 !VDBSimpleDebuggerConsoleApplication methodsFor:'private - console process'!
   354 
   308 
   355 consoleProcess1Command
   309 consoleProcess1Command