VDBDebuggerApplication.st
changeset 95 f7be8c7905c2
parent 89 b8a2f47655a8
child 97 f59fab5b1d0f
--- a/VDBDebuggerApplication.st	Mon Aug 20 11:00:23 2018 +0100
+++ b/VDBDebuggerApplication.st	Mon Aug 20 22:19:23 2018 +0100
@@ -46,6 +46,47 @@
     "Modified: / 11-06-2017 / 20:08:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!VDBDebuggerApplication class methodsFor:'accessing - defaults'!
+
+defaultUserInit
+    "Return path to user-specific VDB initi file (as Filename).
+     Use this to customize VDB upon startup.
+     If it does not exist, try create one with some defaults."
+    
+    | gdbinit |
+
+    gdbinit := Filename homeDirectory / '.vdbinit.st'.
+    gdbinit exists ifFalse:[
+        [
+            gdbinit 
+                writingFileDo:[:s | 
+                    s
+                        nextPutLine:'"/ VDB init script';
+                        nextPutLine:'"/ Current VDB instance can be accessed in via variable `vdb`';
+                        nextPutLine:'"/';
+                        nextPutLine:'"/ Set prompt';
+                        nextPutLine:'vdb debugger send: ''set prompt (vdb) ''.';
+                        cr;
+                        nextPutLine:'"/ Set default font:';
+                        nextPutLine:'"/ VDBAbstractApplication defaultTextFont: (CodeView defaultFont asSize: 16).';
+                        yourself.
+                ].
+        ] on:Error
+                do:[:ex | 
+            gdbinit exists ifTrue:[
+                gdbinit remove
+            ].
+            ^ nil
+        ].
+    ].
+    ^ gdbinit
+
+    "
+     VDBDebuggerApplication defaultUserInit"
+
+    "Created: / 31-08-2018 / 07:03:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !VDBDebuggerApplication class methodsFor:'interface opening'!
 
 open
@@ -1069,6 +1110,30 @@
 subscribe   
     "Register for debugger events. To be overrided by subclasses"
 
+    | init |
+
+    "/ Read init file
+    init := self class defaultUserInit.  
+    (init notNil and:[ init exists ]) ifTrue:[ 
+        [ 
+            [
+            Workspace workspaceVariableAt: 'vdb' put: self.
+                init fileIn.
+            ] ensure:[
+                Workspace workspaceVariables removeKey: 'vdb'.
+            ].
+        ] on: Error do:[:ex | 
+            Transcript 
+                showCR: ('Error while reading VGB init file (%1)' bindWith: init pathName);
+                showCR: ('Description: %1' bindWith: ex description);
+                showCR: ('Backtrace:');
+                cr.
+            ex suspendedContext fullPrintAllOn: Transcript.
+            Transcript showCR:'------'.
+        ].
+
+    ].
+
     UserPreferences current vdbPrettyPrintingEnabled ifTrue:[ 
         debugger enablePrettyPrinting
     ].
@@ -1085,7 +1150,7 @@
         when: GDBLogOutputEvent     send: #onLogOutputEvent:          to: self.
 
     "Created: / 21-09-2014 / 22:43:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 30-07-2018 / 07:32:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 31-08-2018 / 07:24:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !VDBDebuggerApplication methodsFor:'menu actions'!