Commits

Antonio Cuni  committed 0d148b5

colorize the stack entry

  • Participants
  • Parent commits 6b0b90a

Comments (0)

Files changed (1)

     disable_pytest_capturing = True
 
     line_number_color = Color.turquoise
+    filename_color = Color.yellow
     current_line_color = 44 # blue
 
     def setup(self, pdb):
         self._lexer = PythonLexer()
         return True
 
+
+    stack_entry_regexp = re.compile(r'(.*?)\(([0-9]+?)\)(.*)', re.DOTALL)
+    #
+    def format_stack_entry(self, frame_lineno, lprefix=': '):
+        entry = pdb.Pdb.format_stack_entry(self, frame_lineno, lprefix)
+        if self.config.highlight:
+            match = self.stack_entry_regexp.match(entry)
+            if match:
+                filename, lineno, other = match.groups()
+                filename = Color.set(self.config.filename_color, filename)
+                lineno = Color.set(self.config.line_number_color, lineno)
+                entry = '%s(%s)%s' % (filename, lineno, other)
+        return entry
+
     def format_source(self, src):
         if not self._init_pygments():
             return src