6.14.9.13.2. Code Formating

@F{start_code_line} is called to begin a line of code. Any count is placed at the beginning of the line.

Ending a line of code is accomlished by @F end_code_line. It simply adds a new line to the output stream.

@F write_code_fragment is called repeatedly for each token in the code stream. The parameter @F markup is the token type. Currently only comments and keywords are displayed differently. This code assumes that the font used to display program text has an @I Oblique form. This is true of Courier.

Start python section to interscript/weavers/lout.py[18 /34 ] Next Prev First Last
   252: #line 533 "lout_weaver.ipk"
   253:     def start_code_line(self,count=None):
   254:         if count:
   255:             self._write('%6d: ' % count)
   256:         else:
   257:             self._write('       ')
   258:         return
   259: 
   260:     def end_code_line(self):
   261:         self._writeline()
   262:         return
   263: 
   264:     markups = {'COMMENT' : '{Oblique} @Font {',
   265:                'KEYWORD' : '{Bold} @Font {',
   266:                }
   267:     def write_code_fragment(self,frag,markup=None):
   268:         haveMarkup = 0
   269:         if markup and lout_weaver.markups.has_key(markup):
   270:             self._write(lout_weaver.markups[markup])
   271:             haveMarkup = 1
   272: 
   273:         if frag:
   274:             self._write(self.cvt_code(frag))
   275: 
   276:         if haveMarkup:
   277:             self._write('}')
   278:         return
   279: 
End python section to interscript/weavers/lout.py[18]