13 TextIterator::TextIterator() :
22 mText(_text.asUTF32()),
23 mCurrent(mText.begin()),
35 if (mCurrent == mEnd)
return false;
43 for (UString::utf32string::iterator iter = mCurrent; iter != mEnd; ++iter)
76 for (
size_t pos = 0; pos < 5; pos++)
112 if (mCurrent == mEnd)
return false;
114 UString::utf32string::iterator iter = mCurrent;
128 if (mCurrent == mEnd)
return false;
130 if (mCurrent == mEnd)
return false;
132 const size_t SIZE = 16;
136 swprintf(buff, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
138 swprintf(buff, SIZE, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
141 insert(mCurrent, tmpStr.
asUTF32());
148 if (mCurrent == mEnd)
return false;
150 if (mCurrent == mEnd)
return false;
155 insert(mCurrent, _colour);
171 for (UString::utf32string::const_iterator iter = mCurrent; iter != mEnd; ++iter)
178 if (iter == mEnd)
break;
184 for (
size_t pos = 0; pos < 5; pos++)
209 ret.reserve(text.size());
211 UString::utf32string::const_iterator end = text.end();
212 for (UString::utf32string::const_iterator iter = text.begin(); iter != end; ++iter)
219 if (iter == end)
break;
225 for (
size_t pos = 0; pos < 5; pos++)
239 ret.push_back(*iter);
248 if ( (_iter == mEnd) || ((*_iter) != L
'#') )
return false;
252 if ( (_iter == mEnd) || ((*_iter) == L
'#') )
return false;
255 wchar_t buff[16] = L
"#FFFFFF\0";
256 buff[1] = (wchar_t)(*_iter);
257 for (
size_t pos = 2; pos < 7; pos++)
260 if ( _iter == mEnd )
return false;
261 buff[pos] = (wchar_t)(*_iter);
276 auto character = iter.getCharacter();
288 if (mCurrent == mEnd)
return false;
295 if (mSave == mEnd)
return L
"";
296 size_t start = mSave - mText.begin();
297 return UString(mText.substr(start, mCurrent - mText.begin() - start));
302 if (mSave == mEnd)
return false;
303 mCurrent = erase(mSave, mCurrent);
304 mSave = mEnd = mText.end();
312 normaliseNewLine(text);
317 insert(mCurrent, text.
asUTF32());
329 normaliseNewLine(text);
334 insert(mCurrent, text.
asUTF32());
339 if (_char == L
'#')
return L
"##";
340 wchar_t buff[16] = L
"_\0";
341 buff[0] = (wchar_t)_char;
347 const size_t SIZE = 16;
351 swprintf(buff, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
353 swprintf(buff, SIZE, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
365 if (L
'#' == (*iter)) iter = text.
insert(iter.moveNext(), L
'#');
370 void TextIterator::insert(UString::utf32string::iterator& _start,
const UString::utf32string& _insert)
377 size_t pos = _start - mText.begin();
378 size_t pos_save = (mSave == mEnd) ?
ITEM_NONE : _start - mText.begin();
380 mText.insert(_start, _insert.begin(), _insert.end());
382 _start = mText.begin() + pos;
384 (pos_save ==
ITEM_NONE) ? mSave = mEnd : mSave = mText.begin() + pos_save;
387 UString::utf32string::iterator TextIterator::erase(UString::utf32string::iterator _start, UString::utf32string::iterator _end)
392 size_t start = _start - mText.begin();
395 return mText.erase(_start, _end);
398 void TextIterator::clear()
400 if (mText.empty())
return;
407 mCurrent = mText.begin();
408 mEnd = mSave = mText.end();
414 if ( (mSize !=
ITEM_NONE) && (mSize <= _max) )
return;
415 if (mPosition > _max)
418 mSize = mPosition = 0;
419 mCurrent = mText.begin();
420 mEnd = mSave = mText.end();
425 for (UString::utf32string::iterator iter = mCurrent; iter != mEnd; ++iter)
432 if (iter == mEnd)
break;
438 for (
size_t pos = 0; pos < 5; pos++)
455 mCurrent = erase(iter, mEnd);
456 mSave = mEnd = mText.end();
470 if (size <= _max)
return;
473 size_t diff = size - _max;
476 UString::utf32string::iterator iter_colour = mEnd;
479 UString::utf32string::iterator iter = mText.begin();
480 for (; iter != mEnd; ++iter)
484 UString::utf32string::iterator save = iter;
488 if (iter == mEnd)
break;
494 for (
size_t pos = 0; pos < 5; pos++)
509 if (diff == 0)
break;
515 if (iter_colour != mEnd)
517 colour.append(iter_colour, iter_colour +
size_t(7));
520 mCurrent = erase(mText.begin(), iter);
532 if (mCurrent == mEnd)
return;
534 UString::utf32string::iterator iter = mCurrent;
540 iter = mCurrent = erase(mCurrent, iter);
565 void TextIterator::normaliseNewLine(
UString& _text)
567 for (
size_t index = 0; index < _text.
size(); ++index)
569 Char character = _text[index];
571 ((index + 1) < _text.
size()) &&
574 _text.
erase(index, 1);
static UString getOnlyText(const UString &_text)
void clearNewLine(UString &_text)
static UString getTextNewLine()
static UString getTextCharInfo(Char _char)
void cutMaxLength(size_t _max)
bool setTagColour(const Colour &_colour)
UString getFromStart() const
static UString convertTagColour(const Colour &_colour)
static UString toTagsString(const UString &_text)
void cutMaxLengthFromBeginning(size_t _max)
void setText(const UString &_text, bool _multiLine)
size_t getPosition() const
void insertText(const UString &_insert, bool _multiLine)
bool getTagColour(UString &_colour) const
forward iterator for UString
_fwd_iterator & moveNext()
advances to the next Unicode character, honoring surrogate pairs in the UTF-16 stream
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
iterator insert(iterator i, const code_point &ch)
inserts ch before the code point denoted by i
size_type size() const
Returns the number of code points in the current string.
const utf32string & asUTF32() const
returns the current string in UTF-32 form within a utf32string
std::basic_string< unicode_char > utf32string
string type used for returning UTF-32 formatted data
iterator erase(iterator loc)
removes the code point pointed to by loc, returning an iterator to the next character
iterator end()
returns an iterator just past the end of the string
static const size_type npos
the usual constant representing: not found, no limit, etc
iterator begin()
returns an iterator to the first element of the string
std::vector< TextCommandInfo > VectorChangeInfo