From 859e52bb5f8e799d729058198a93aefde93a9fc7 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 15 Jan 2008 13:21:14 -0800 Subject: [PATCH] Annotation work --- Cython/Compiler/Annotate.py | 33 ++++++++++++++++++++------------- Cython/Compiler/Code.py | 2 ++ Cython/Compiler/ModuleNode.py | 4 ++++ Cython/Compiler/Nodes.py | 2 -- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Cython/Compiler/Annotate.py b/Cython/Compiler/Annotate.py index 278ca8e6..e1f05e49 100644 --- a/Cython/Compiler/Annotate.py +++ b/Cython/Compiler/Annotate.py @@ -7,6 +7,10 @@ from StringIO import StringIO from Code import CCodeWriter +# need one-characters subsitutions (for now) so offsets aren't off +special_chars = [('<', '\xF0', '<'), + ('>', '\xF1', '>'), + ('&', '\xF2', '&')] class AnnotationCCodeWriter(CCodeWriter): @@ -29,14 +33,13 @@ class AnnotationCCodeWriter(CCodeWriter): # if pos is not None: # CCodeWriter.mark_pos(self, pos) # return - print "marking", pos if self.last_pos: try: code = self.code[self.last_pos[1]] except KeyError: code = "" self.code[self.last_pos[1]] = code + self.buffer.getvalue() - self.buffer = StringIO() + self.buffer = StringIO() self.last_pos = pos def annotate(self, pos, item): @@ -47,12 +50,10 @@ class AnnotationCCodeWriter(CCodeWriter): f = open(filename) lines = f.readlines() for k in range(len(lines)): - # there has to be a better way to do this - lines[k] = lines[k].replace(' ','\t ') - lines[k] = lines[k].replace(' ','\t\t') - # TODO: this is incorrect - lines[k] = lines[k].replace('<', '~') - lines[k] = lines[k].replace('>', '~') + line = lines[k] + for c, cc, html in special_chars: + line = line.replace(c, cc) + lines[k] = line f.close() all = [] for pos, item in self.annotations: @@ -86,6 +87,7 @@ body { font-family: courier; font-size: 12; } .py_api { color: red; } .pyx_api { color: #FF3000; } .py_macro_api { color: #FF8000; } +.error_goto { color: #FF8000; } .tag { } @@ -97,6 +99,8 @@ body { font-family: courier; font-size: 12; } .py_call { color: #FF0000; font-weight: bold; } .c_call { color: #0000FF; } +.line { margin: 0em } +