StdFormatter

Contains utilities useful to all formatters.

Methods

__init__(self)

   def __init__(self):

_commit(self, data)

   def _commit(self, data):

Must be implemented by subclass. Writes the raw data to the final consumer.

_curIsEmpty(self)

   def _curIsEmpty(self):

Returns true if the current line is empty (consists entirely of whitespace).

_flush(self, pos)

   def _flush(self, pos):

Flushes up to and including position pos in the buffer.

_makeLine(self, line)

   def  _makeLine(self, line):

Derived classes may overload this to implement their own indentation.

_reduce(self)

   def _reduce(self):

Called when the receiver's buffer exceeds the maximum line length. Flushes the receiver up to the point of the last whitespace region under the maximum line length.

If the buffer has no whitspace zone below the maximum line space, flushes up to the first white space.

_tooLong(self, line)

   def _tooLong(self, line):

Returns true if the given line is too long to fit on the rendering destination.

By default, this compares the length of the line to maxLineWidth. derived classes should override this to implement layout rules that take into account things like font size.

_write(self, str)

   def _write(self, str):

Used by the formatting functions to write information to the buffered output stream. The output will be buffered unless it contains a newline, in which case the buffer will be committed up to the last newline.

_writeSpace(self)

   def _writeSpace(self):

Used to indicate that white space is needed between the previous written object and the next one. This function will add the appropriate amount of whitespace (possibly none) depending on the state of the buffer.

If the buffer exceeds the maximum line width (maxLineWidth), part of it will be committed using _reduce().

close(self)

   def close(self):

Closes the formatting of the block, committing the contents of the buffer.