87
87
self.stream = stream
88
88
self._last_indent = 0
90
def write(self, line, indent, colour):
90
def writeln(self, line, indent, colour):
92
92
indent = self._last_indent + 2
94
94
self._last_indent = indent
95
95
line = ' ' * indent + line
97
self.stream.write(line)
97
self.stream.write(line + '\n')
99
99
colour = self._colours[colour]
100
self.stream.write('\x1b[%sm%s\x1b[0m' % (colour, line))
100
self.stream.write('\x1b[%sm%s\x1b[0m\n' % (colour, line))
102
102
def title(self, name):
103
self.write(name + '\n', 0, 'bright green')
103
self.writeln(name, 0, 'bright green')
105
105
def section(self, name):
106
self.write(name + '\n', 2, 'bright yellow')
106
self.writeln(name, 2, 'bright yellow')
108
108
def subsection(self, name):
109
self.write(name + '\n', 4, 'bright white')
109
self.writeln(name, 4, 'bright white')
111
111
def paragraph(self, text):
118
118
colour = 'yellow'
119
119
for line in text.strip().splitlines(True):
120
self.write(line, None, colour)
121
if not line.endswith('\n'):
122
self.write('\n', None, colour)
120
self.writeln(line.rstrip('\n'), None, colour)