libyui-ncurses
NCWordWrapper.h
1 /*
2  Copyright (C) 2020 SUSE LLC
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as
6  published by the Free Software Foundation; either version 2.1 of the
7  License, or (at your option) version 3.0 of the License. This library
8  is distributed in the hope that it will be useful, but WITHOUT ANY
9  WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11  License for more details. You should have received a copy of the GNU
12  Lesser General Public License along with this library; if not, write
13  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14  Floor, Boston, MA 02110-1301 USA
15 */
16 
17 
18 /*-/
19 
20  File: NCWordWrapper.h
21 
22  Author: Stefan Hundhammer <shundhammer@suse.de>
23 
24 /-*/
25 
26 
27 #ifndef NCWordWrapper_h
28 #define NCWordWrapper_h
29 
30 #include <string>
31 
39 {
40 public:
41 
45  NCWordWrapper();
46 
50  void setText( const std::wstring & origText );
51 
55  void setLineWidth( int width );
56 
60  int lines();
61 
65  const std::wstring & wrappedText();
66 
70  const std::wstring & origText() const { return _origText; }
71 
75  int lineWidth() const { return _lineWidth; }
76 
81  static std::wstring normalizeWhitespace( const std::wstring & orig );
82 
92  void wrap();
93 
97  void clear();
98 
99 
100 protected:
101 
105  void ensureWrapped();
106 
111  std::wstring nextLine( std::wstring & unwrapped );
112 
113  //
114  // Data members
115  //
116 
117  std::wstring _origText;
118  std::wstring _wrappedText;
119  int _lineWidth;
120  int _lines;
121  bool _dirty;
122 };
123 
124 #endif // NCWordWrapper_h
static std::wstring normalizeWhitespace(const std::wstring &orig)
Definition: NCWordWrapper.cc:103
const std::wstring & origText() const
Definition: NCWordWrapper.h:70
void setText(const std::wstring &origText)
Definition: NCWordWrapper.cc:48
void wrap()
Definition: NCWordWrapper.cc:145
void ensureWrapped()
Definition: NCWordWrapper.cc:94
std::wstring nextLine(std::wstring &unwrapped)
Definition: NCWordWrapper.cc:172
const std::wstring & wrappedText()
Definition: NCWordWrapper.cc:86
int lines()
Definition: NCWordWrapper.cc:78
NCWordWrapper()
Definition: NCWordWrapper.cc:39
Definition: NCWordWrapper.h:38
void setLineWidth(int width)
Definition: NCWordWrapper.cc:58
void clear()
Definition: NCWordWrapper.cc:68
int lineWidth() const
Definition: NCWordWrapper.h:75