]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
improved prompt format
authorGuido van Rossum <guido@python.org>
Thu, 10 Nov 1994 22:27:35 +0000 (22:27 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 10 Nov 1994 22:27:35 +0000 (22:27 +0000)
Lib/bdb.py
Lib/pdb.py

index 9b50767176014c2feab8e4b5fa829f1dc1e2cb61..7642ed0cd97874f1a118bf67025365f0fb131d5a 100644 (file)
@@ -242,7 +242,7 @@ class Bdb: # Basic Debugger
        
        # 
        
-       def format_stack_entry(self, frame_lineno):
+       def format_stack_entry(self, frame_lineno, lprefix=': '):
                import linecache, repr, string
                frame, lineno = frame_lineno
                filename = frame.f_code.co_filename
@@ -260,7 +260,7 @@ class Bdb: # Basic Debugger
                        s = s + '->'
                        s = s + repr.repr(rv)
                line = linecache.getline(filename, lineno)
-               if line: s = s + ': ' + string.strip(line)
+               if line: s = s + lprefix + string.strip(line)
                return s
        
        # The following two methods can be called by clients to use
index a77dd29f89842fb80b2e17a2121acbab3ebdb3d4..30b1477536d7a904eb0ffd69a7d1eb3f1ecd6361 100755 (executable)
@@ -10,6 +10,13 @@ import bdb
 import repr
 
 
+# Interaction prompt line will separate file and call info from code
+# text using value of line_prefix string.  A newline and arrow may
+# be to your liking.  You can set it once pdb is imported using the
+# command "pdb.line_prefix = '\n% '".
+# line_prefix = ': '   # Use this to get the old situation back
+line_prefix = '\n-> '  # Probably a better default
+
 class Pdb(bdb.Bdb, cmd.Cmd):
        
        def __init__(self):
@@ -55,7 +62,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
        
        def interaction(self, frame, traceback):
                self.setup(frame, traceback)
-               self.print_stack_entry(self.stack[self.curindex])
+               self.print_stack_entry(self.stack[self.curindex],
+                                      line_prefix)
                self.cmdloop()
                self.forget()
 
@@ -280,13 +288,13 @@ class Pdb(bdb.Bdb, cmd.Cmd):
                except KeyboardInterrupt:
                        pass
        
-       def print_stack_entry(self, frame_lineno):
+       def print_stack_entry(self, frame_lineno, prompt_prefix=''):
                frame, lineno = frame_lineno
                if frame is self.curframe:
                        print '>',
                else:
                        print ' ',
-               print self.format_stack_entry(frame_lineno)
+               print self.format_stack_entry(frame_lineno, prompt_prefix)
 
 
        # Help methods (derived from pdb.doc)