28 TextIterator::TextIterator() :
38 mCurrent(mText.begin()),
50 if (mCurrent == mEnd)
return false;
91 for (
size_t pos = 0; pos < 5; pos++)
127 if (mCurrent == mEnd)
return false;
143 if (mCurrent == mEnd)
return false;
147 if (mCurrent == mEnd)
return false;
149 const size_t SIZE = 16;
153 swprintf(buff, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
155 swprintf(buff, SIZE, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
159 insert(mCurrent, tmpStr);
166 if (mCurrent == mEnd)
return false;
170 if (mCurrent == mEnd)
return false;
173 if ( (_colour.
size() != 7) || (_colour.
find(L
'#', 1) != _colour.
npos) )
return false;
176 insert(mCurrent, _colour);
194 if (iter == mEnd)
break;
200 for (
size_t pos = 0; pos < 5; pos++)
234 if (iter == end)
break;
240 for (
size_t pos = 0; pos < 5; pos++)
263 if ( (_iter == mEnd) || ((*_iter) != L
'#') )
return false;
267 if ( (_iter == mEnd) || ((*_iter) == L
'#') )
return false;
270 wchar_t buff[16] = L
"#FFFFFF\0";
271 buff[1] = (wchar_t)(*_iter);
272 for (
size_t pos = 2; pos < 7; pos++)
275 if ( _iter == mEnd )
return false;
276 buff[pos] = (wchar_t)(*_iter);
302 if (mCurrent == mEnd)
return false;
309 if (mSave == mEnd)
return L
"";
310 size_t start = mSave - mText.
begin();
311 return mText.
substr(start, mCurrent - mText.
begin() - start);
316 if (mSave == mEnd)
return false;
317 mCurrent = erase(mSave, mCurrent);
318 mSave = mEnd = mText.
end();
326 insert(mCurrent, text);
336 insert(mCurrent, text);
341 if (_char == L
'#')
return L
"##";
342 wchar_t buff[16] = L
"_\0";
343 buff[0] = (wchar_t)_char;
349 const size_t SIZE = 16;
353 swprintf(buff, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
355 swprintf(buff, SIZE, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
367 if (L
'#' == (*iter)) iter = text.
insert(++iter, L
'#');
379 size_t pos = _start - mText.
begin();
380 size_t pos_save = (mSave == mEnd) ?
ITEM_NONE : _start - mText.
begin();
384 _start = mText.
begin() + pos;
386 (pos_save ==
ITEM_NONE) ? mSave = mEnd : mSave = mText.
begin() + pos_save;
394 size_t start = _start - mText.
begin();
397 return mText.
erase(_start, _end);
400 void TextIterator::clear()
402 if (mText.
empty())
return;
409 mCurrent = mText.
begin();
410 mEnd = mSave = mText.
end();
416 if ( (mSize !=
ITEM_NONE) && (mSize <= _max) )
return;
417 if (mPosition > _max)
420 mSize = mPosition = 0;
421 mCurrent = mText.
begin();
422 mEnd = mSave = mText.
end();
434 if (iter == mEnd)
break;
440 for (
size_t pos = 0; pos < 5; pos++)
457 mCurrent = erase(iter, mEnd);
458 mSave = mEnd = mText.
end();
472 if (size <= _max)
return;
475 size_t diff = size - _max;
482 for (; iter != mEnd; ++iter)
490 if (iter == mEnd)
break;
496 for (
size_t pos = 0; pos < 5; pos++)
511 if (diff == 0)
break;
517 if (iter_colour != mEnd)
519 colour.
append(iter_colour, iter_colour +
size_t(7));
522 mCurrent = erase(mText.
begin(), iter);
534 if (mCurrent == mEnd)
return;
542 iter = mCurrent = erase(mCurrent, iter);
size_t getPosition() const
static UString getTextCharInfo(Char _char)
void clearNewLine(UString &_text)
const UString & getText() const
UString & append(const UString &str)
appends str on to the end of the current string
void cutMaxLength(size_t _max)
std::vector< TextCommandInfo > VectorChangeInfo
static UString getOnlyText(const UString &_text)
iterator erase(iterator loc)
removes the code point pointed to by loc, returning an iterator to the next character ...
bool getTagColour(UString &_colour) const
size_type find(const UString &str, size_type index=0) const
returns the index of the first occurrence of str within the current string, starting at index; return...
static const size_type npos
the usual constant representing: not found, no limit, etc
const forward iterator for UString
void push_back(unicode_char val)
appends val to the end of the string
void clear()
deletes all of the elements in the string
iterator begin()
returns an iterator to the first element of the string
_fwd_iterator iterator
iterator
void insertText(const UString &_insert, bool _multiLine)
UString substr(size_type index, size_type num=npos) const
returns a substring of the current string, starting at index, and num characters long.
static UString toTagsString(const UString &_text)
void reserve(size_type size)
sets the capacity of the string to at least size code points
forward iterator for UString
void setText(const UString &_text, bool _multiLine)
bool setTagColour(const Colour &_colour)
static UString getTextNewLine()
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
void cutMaxLengthFromBeginning(size_t _max)
iterator insert(iterator i, const code_point &ch)
inserts ch before the code point denoted by i
iterator end()
returns an iterator just past the end of the string
size_type size() const
Returns the number of code points in the current string.
static UString convertTagColour(const Colour &_colour)
bool empty() const
returns true if the string has no elements, false otherwise