comparison fontaine/console.py @ 8:02d2e4d8b0c1

Make renderers responsible for formatting the title page.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 04 Jan 2017 02:55:20 -0800
parents e3d52edde00b
children
comparison
equal deleted inserted replaced
7:e3d52edde00b 8:02d2e4d8b0c1
18 def __init__(self, width=80): 18 def __init__(self, width=80):
19 super().__init__(ConsoleTextRenderer()) 19 super().__init__(ConsoleTextRenderer())
20 self.width = width 20 self.width = width
21 colorama.init() 21 colorama.init()
22 22
23 def write_title_heading(self, text, out): 23 def write_title_page(self, values, out):
24 known = ['title', 'credit', 'author', 'source']
25 center_values = [values.get(i) for i in known
26 if i is not None]
27
24 print("", file=out) 28 print("", file=out)
25 for line in text.split('\n'): 29 for val in center_values:
26 print(line.center(self.width), file=out) 30 for l in val.split('\n'):
31 print(l.center(self.width), file=out)
32 print("", file=out)
27 print("", file=out) 33 print("", file=out)
28 print("", file=out) 34 print("", file=out)
29 35
30 def write_title_footer(self, text, out): 36 ddate = values.get('date') or values.get('draft date')
31 _w(out, colorama.Style.DIM, text) 37 contact = values.get('contact')
38 bottom_lines = [i for i in [ddate, contact]
39 if i is not None]
40
41 _w(out, colorama.Style.DIM, '\n\n'.join(bottom_lines))
32 print("", file=out) 42 print("", file=out)
33 _w(out, colorama.Style.DIM, 80 * '=') 43 _w(out, colorama.Style.DIM, 80 * '=')
34 44
35 def write_scene_heading(self, text, out): 45 def write_scene_heading(self, text, out):
36 print("", file=out) 46 print("", file=out)