13 TextIterator::TextIterator() :
23 mCurrent(mText.begin()),
35 if (mCurrent == mEnd)
return false;
76 for (
size_t pos = 0; pos < 5; pos++)
112 if (mCurrent == mEnd)
return false;
128 if (mCurrent == mEnd)
return false;
132 if (mCurrent == mEnd)
return false;
134 const size_t SIZE = 16;
138 swprintf(buff, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
140 swprintf(buff, SIZE, L
"#%.2X%.2X%.2X\0", (
int)(_colour.
red * 255), (
int)(_colour.
green * 255), (
int)(_colour.
blue * 255));
144 insert(mCurrent, tmpStr);
151 if (mCurrent == mEnd)
return false;
155 if (mCurrent == mEnd)
return false;
158 if ( (_colour.
size() != 7) || (_colour.
find(L
'#', 1) != _colour.
npos) )
return false;
161 insert(mCurrent, _colour);
179 if (iter == mEnd)
break;
185 for (
size_t pos = 0; pos < 5; pos++)
219 if (iter == end)
break;
225 for (
size_t pos = 0; pos < 5; pos++)
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);
287 if (mCurrent == mEnd)
return false;
294 if (mSave == mEnd)
return L
"";
295 size_t start = mSave - mText.
begin();
296 return mText.
substr(start, mCurrent - mText.
begin() - start);
301 if (mSave == mEnd)
return false;
302 mCurrent = erase(mSave, mCurrent);
303 mSave = mEnd = mText.
end();
312 normaliseNewLine(text);
317 insert(mCurrent, text);
329 normaliseNewLine(text);
334 insert(mCurrent, text);
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, L
'#');
377 size_t pos = _start - mText.
begin();
378 size_t pos_save = (mSave == mEnd) ?
ITEM_NONE : _start - mText.
begin();
382 _start = mText.
begin() + pos;
384 (pos_save ==
ITEM_NONE) ? mSave = mEnd : mSave = mText.
begin() + pos_save;
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();
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;
480 for (; iter != mEnd; ++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;
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);