From: Robert Bradshaw Date: Tue, 15 Jan 2008 21:21:14 +0000 (-0800) Subject: Annotation work X-Git-Tag: 0.9.6.14~29^2~78 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=859e52bb5f8e799d729058198a93aefde93a9fc7;p=cython.git Annotation work --- 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 } +