GCC Middle and Back End API Reference
canvas.h
Go to the documentation of this file.
1/* Canvas for random-access procedural text art.
2 Copyright (C) 2023-2025 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_TEXT_ART_CANVAS_H
22#define GCC_TEXT_ART_CANVAS_H
23
24#include "text-art/types.h"
25
26namespace text_art {
27
28class canvas;
29
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.
33
34 Each text cell can be styled independently (colorization,
35 URLs, etc). */
36
37class canvas
38{
39 public:
45
46 canvas (size_t size, const style_manager &style_mgr);
47
48 size_t get_size () const { return m_cells.get_size (); }
49
50 void paint (coord_t coord, cell_t c);
51 void paint_text (coord_t coord, const styled_string &text);
52
53 void fill (rect_t rect, cell_t c);
54 void debug_fill ();
55
57 const char *per_line_prefix = NULL) const;
58 void debug (bool styled) const;
59
60 const cell_t &get (coord_t coord) const
61 {
62 return m_cells.get (coord);
63 }
64
65 private:
66 int get_final_x_in_row (int y) const;
67
70};
71
72} // namespace text_art
73
74#endif /* GCC_TEXT_ART_CANVAS_H */
Definition pretty-print.h:241
Definition types.h:141
Definition canvas.h:38
void fill(rect_t rect, cell_t c)
Definition canvas.cc:59
styled_unichar cell_t
Definition canvas.h:40
size_t get_size() const
Definition canvas.h:48
const cell_t & get(coord_t coord) const
Definition canvas.h:60
void paint_text(coord_t coord, const styled_string &text)
Definition canvas.cc:46
range< class canvas > range_t
Definition canvas.h:43
void debug_fill()
Definition canvas.cc:67
int get_final_x_in_row(int y) const
Definition canvas.cc:146
rect< class canvas > rect_t
Definition canvas.h:44
size< class canvas > size_t
Definition canvas.h:41
array2< cell_t, size_t, coord_t > m_cells
Definition canvas.h:68
coord< class canvas > coord_t
Definition canvas.h:42
void print_to_pp(pretty_printer *pp, const char *per_line_prefix=NULL) const
Definition canvas.cc:73
canvas(size_t size, const style_manager &style_mgr)
Definition canvas.cc:32
void paint(coord_t coord, cell_t c)
Definition canvas.cc:40
const style_manager & m_style_mgr
Definition canvas.h:69
Definition types.h:342
Definition types.h:424
Definition types.h:360
bool debug
Definition collect-utils.cc:34
Definition diagnostics/context.h:56
Definition types.h:57
Definition types.h:74
Definition types.h:94
Definition types.h:49
#define NULL
Definition system.h:50
const T2 & y
Definition wide-int.h:3870