python: set custom prompt only for from VDB UI
authorJan Vrany <jan.vrany@labware.com>
Mon, 17 May 2021 12:41:11 +0100
changeset 216 f8e5782301b6
parent 215 a4a5863bc49b
child 217 e2669ea6a1d0
python: set custom prompt only for from VDB UI
extensions.st
python/vdb/__init__.py
--- a/extensions.st	Mon May 17 12:07:28 2021 +0100
+++ b/extensions.st	Mon May 17 12:41:11 2021 +0100
@@ -25,7 +25,8 @@
     self assert: pythonDir isDirectory.
 
     self pythonSysPathAppend: pythonDir.
-    self pythonImport: 'vdb'
+    self pythonImport: 'vdb'.
+    self send: 'python vdb.set_prompt()'.
 
     "Created: / 08-07-2019 / 11:44:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
--- a/python/vdb/__init__.py	Mon May 17 12:07:28 2021 +0100
+++ b/python/vdb/__init__.py	Mon May 17 12:41:11 2021 +0100
@@ -451,8 +451,10 @@
 
     varobj.set_visualizer(visualizer)
 
-
-# Set prompt for both, GDBCLI and Python CLI
-gdb.prompt_hook = lambda x: "vdb > "
-sys.ps1 = "vdb pi > "
-sys.ps2 = "       > "
+def set_prompt(prompt = 'vdb'):
+    """
+    Set prompt for both, GDBCLI and Python CLI
+    """
+    gdb.prompt_hook = lambda x: "%s > " % prompt
+    sys.ps1 = "%s pi > " % prompt
+    sys.ps2 = "%s    > " % (' ' * len(prompt))