mailr15772 - in /1.3/prompt: base_class.py interpreter.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on April 17, 2012 - 19:30:
Author: bugman
Date: Tue Apr 17 19:30:16 2012
New Revision: 15772

URL: http://svn.gna.org/viewcvs/relax?rev=15772&view=rev
Log:
Better control of the relax prompt colouring via ANSI escape sequences.

The new Exec_info.prompt_colour_on() and Exec_info.prompt_colour_off() 
methods are now used to turn
the colours on and off by aliasing the coloured or non-colours prompts to 
both the class instance
namespace and to the sys module.


Modified:
    1.3/prompt/base_class.py
    1.3/prompt/interpreter.py

Modified: 1.3/prompt/base_class.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/base_class.py?rev=15772&r1=15771&r2=15772&view=diff
==============================================================================
--- 1.3/prompt/base_class.py (original)
+++ 1.3/prompt/base_class.py Tue Apr 17 19:30:16 2012
@@ -222,14 +222,33 @@
         self.intro = True
 
         # The prompts (to change the Python prompt, as well as the function 
print outs).
-        self.ps1 = 'relax> '
-        self.ps2 = 'relax| '
-        self.ps3 = '\n%s' % self.ps1
+        self.ps1_orig = 'relax> '
+        self.ps2_orig = 'relax| '
+        self.ps3_orig = '\n%s' % self.ps1_orig
 
         # Coloured text.
-        self.ps1_colour = "%s%s%s" % (ansi.relax_prompt, self.ps1, ansi.end)
-        self.ps2_colour = "%s%s%s" % (ansi.relax_prompt, self.ps2, ansi.end)
-        self.ps3_colour = "\n%s%s%s" % (ansi.relax_prompt, self.ps1, 
ansi.end)
+        self.ps1_colour = "%s%s%s" % (ansi.relax_prompt, self.ps1_orig, 
ansi.end)
+        self.ps2_colour = "%s%s%s" % (ansi.relax_prompt, self.ps2_orig, 
ansi.end)
+        self.ps3_colour = "\n%s%s%s" % (ansi.relax_prompt, self.ps1_orig, 
ansi.end)
+
+        # Default to no colours.
+        self.prompt_colour_off()
+
+
+    def prompt_colour_off(self):
+        """Turn the prompt colouring ANSI escape sequences off."""
+
+        sys.ps1 = self.ps1 = self.ps1_orig
+        sys.ps2 = self.ps2 = self.ps2_orig
+        sys.ps3 = self.ps3 = self.ps3_orig
+
+
+    def prompt_colour_on(self):
+        """Turn the prompt colouring ANSI escape sequences off."""
+
+        sys.ps1 = self.ps1 = self.ps1_colour
+        sys.ps2 = self.ps2 = self.ps2_colour
+        sys.ps3 = self.ps3 = self.ps3_colour
 
 
 

Modified: 1.3/prompt/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=15772&r1=15771&r2=15772&view=diff
==============================================================================
--- 1.3/prompt/interpreter.py (original)
+++ 1.3/prompt/interpreter.py Tue Apr 17 19:30:16 2012
@@ -133,13 +133,9 @@
 
         # The prompts (change the Python prompt, as well as the function 
print outs).
         if sys.stdout.isatty():
-            sys.ps1 = self._exec_info.ps1_colour
-            sys.ps2 = self._exec_info.ps2_colour
-            sys.ps3 = self._exec_info.ps3_colour
+            self._exec_info.prompt_colour_on()
         else:
-            sys.ps1 = self._exec_info.ps1
-            sys.ps2 = self._exec_info.ps2
-            sys.ps3 = self._exec_info.ps3
+            self._exec_info.prompt_colour_off()
 
         # The function intro flag (store in the execution information 
container).
         self._exec_info.intro = False




Related Messages


Powered by MHonArc, Updated Tue Apr 17 19:40:01 2012