Documented constraints.diagonal test more better.
[pseudoku.git] / pseudoku / render / text.py
1 from . import GridRenderer
2 from ..grid import symbols
3
4 class LineGridRenderer(GridRenderer):
5 """Renders a grid into a flat string, as puzzles are often presented in
6 plaintext collections.
7 """
8 pass
9
10
11 class SquareGridRenderer(GridRenderer):
12 """Renders a grid as a square of characters."""
13
14 def after_row(self, row, new_box=False):
15 return '\n'
16
17
18 class AsciiArtGridRenderer(SquareGridRenderer):
19 """Renders a questionably-pretty ASCII art drawing of a grid, with dividers
20 between rows and columns.
21 """
22
23 def inside_grid(self, grid):
24 box_header = '+' + '-' * grid.box_width
25 return box_header * grid.box_height + '+\n'
26
27 def inside_row(self, row):
28 return '|'
29
30 def after_row(self, row):
31 return '|\n'
32
33 def inside_cell(self, cell):
34 if cell.solved:
35 return symbols[cell.value]
36 else:
37 return ' '