1 /* Canvas for random-access procedural text art.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_TEXT_ART_CANVAS_H
22 #define GCC_TEXT_ART_CANVAS_H
24 #include "text-art/types.h"
30 /* A 2 dimensional grid of text cells (a "canvas"), which
31 can be written to ("painted") via random access, and then
32 written out to a pretty_printer once the picture is complete.
34 Each text cell can be styled independently (colorization,
40 typedef styled_unichar cell_t
;
41 typedef size
<class canvas
> size_t;
42 typedef coord
<class canvas
> coord_t
;
43 typedef range
<class canvas
> range_t
;
44 typedef rect
<class canvas
> rect_t
;
46 canvas (size_t size
, const style_manager
&style_mgr
);
48 size_t get_size () const { return m_cells
.get_size (); }
50 void paint (coord_t coord
, cell_t c
);
51 void paint_text (coord_t coord
, const styled_string
&text
);
53 void fill (rect_t rect
, cell_t c
);
56 void print_to_pp (pretty_printer
*pp
,
57 const char *per_line_prefix
= NULL
) const;
58 void debug (bool styled
) const;
60 const cell_t
&get (coord_t coord
) const
62 return m_cells
.get (coord
);
66 int get_final_x_in_row (int y
) const;
68 array2
<cell_t
, size_t, coord_t
> m_cells
;
69 const style_manager
&m_style_mgr
;
72 } // namespace text_art
74 #endif /* GCC_TEXT_ART_CANVAS_H */