]> git.lyx.org Git - lyx.git/blob - src/mathed/TextPainter.C
Avoid processing empty lines when reading the symbols file
[lyx.git] / src / mathed / TextPainter.C
1 /**
2  * \file TextPainter.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "TextPainter.h"
14 #include "support/std_ostream.h"
15
16
17 namespace lyx {
18
19
20 TextPainter::TextPainter(int xmax, int ymax)
21         : xmax_(xmax), ymax_(ymax), data_(xmax_ * (ymax_ + 1), ' ')
22 {}
23
24
25 char_type & TextPainter::at(int x, int y)
26 {
27         return data_[y * xmax_ + x];
28 }
29
30
31 char_type TextPainter::at(int x, int y) const
32 {
33         return data_[y * xmax_ + x];
34 }
35
36
37 void TextPainter::draw(int x, int y, char_type const * str)
38 {
39         //cerr << "drawing string '" << str << "' at " << x << ',' << y << endl;
40         for (int i = 0; *str && x + i < xmax_; ++i, ++str)
41                 at(x + i, y) = *str;
42         //show();
43 }
44
45
46 void TextPainter::horizontalLine(int x, int y, int n, char_type c)
47 {
48         for (int i = 0; i < n && i + x < xmax_; ++i)
49                 at(x + i, y) = c;
50 }
51
52
53 void TextPainter::verticalLine(int x, int y, int n, char_type c)
54 {
55         for (int i = 0; i < n && i + y < ymax_; ++i)
56                 at(x, y + i) = c;
57 }
58
59
60 void TextPainter::draw(int x, int y, char_type c)
61 {
62         //cerr << "drawing char '" << c << "' at " << x << ',' << y << endl;
63         at(x, y) = c;
64         //show();
65 }
66
67
68 void TextPainter::show(odocstream & os, int offset) const
69 {
70         os << '\n';
71         for (int j = 0; j <= ymax_; ++j) {
72                 for (int i = 0; i < offset; ++i)
73                         os << ' ';
74                 for (int i = 0; i < xmax_; ++i)
75                         os << at(i, j);
76                 os << '\n';
77         }
78 }
79
80
81 } // namespace lyx