35 using namespace Drawing;
46 template<
typename _tBi>
51 while(b != --s && *s != c)
60 template<
typename _tBi>
62 FindLineFeed(
const TextRegion& r, _tBi s, _tBi e)
68 while(s != e && *s !=
'\n')
72 w += r.Font.GetAdvance(*s);
85 template<
typename _tBi>
87 FindPreviousLineFeed(TextRegion& r, _tBi s, _tBi b)
93 auto t(FindPreviousChar(s, b,
'\n'));
100 t = FindLineFeed(r, t, e);
110 template<
typename _tIn,
class _tArea,
class _tContainer>
112 AdjustForNewline(_tArea& area, _tIn& i, _tContainer& c)
114 i = FindLineFeed(area,
next_if_eq(i,
'\n'), c.GetEnd());
121 template<
typename _tIn,
class _tArea,
class _tContainer>
123 AdjustPrevious(_tArea& area, _tIn& i, _tContainer& c)
125 i = FindPreviousLineFeed(area, i, c.GetBegin());
142 size_t dst_offset, ptrdiff_t offset,
size_t n)
144 YAssert(n != 0,
"Invalid number of lines found.");
145 YAssert(n <=
size_t(std::abs(offset)),
"Invalid offset found.");
151 yunseq(src_offset *=
w, dst_offset *=
w, n *=
w);
170 "No enough space of areas found.");
174 auto* p_src(&area_dn);
175 auto* p_dst(&area_up);
186 CopyScrollArea(*p_src, src_off, *p_dst, dst_off, offset, n);
187 p_src->ClearLine(clr_off, n);
192 CheckOverRead(TextRegion& r)
207 : p_text(),
fc(fc_), i_top(), i_btm(), overread_line_n(0), scroll_offset(0),
241 DualScreenReader::SetFont(
const Font& fnt)
256 AdjustForNewline(area_up, i_top, *p_text);
262 AdjustPrevious(area_up, i_top, *p_text);
285 return bool(p_text) && scroll_offset != 0
311 if(
YB_UNLIKELY(!p_text || p_text->GetTextSize() == 0))
315 if(AdjustScrollOffset() != 0)
335 MoveScrollArea(area_up, area_dn, hx,
h);
337 AdjustForPrevNewline();
340 if(overread_line_n > 0)
343 AdjustPrevious(area_up, i_btm, *p_text);
347 MoveUpForLastLine(-hx,
h);
350 i_btm = PutLastLine();
351 AdjustForFirstNewline();
361 AdjustForPrevNewline();
363 while(ln-- && !IsTextBottom())
365 AdjustForNewline(area_dn, i_btm, *p_text);
366 AdjustForFirstNewline();
388 YAssert(
bool(p_text),
"Null text buffer found.");
390 const auto s(p_text->GetTextSize());
399 i_top = p_text->GetBegin();
402 i_top = p_text->GetIterator(pos);
404 AdjustForPrevNewline();
416 p_text = make_unique<Text::TextFileBuffer>(file);
417 yunseq(i_top = p_text->GetBegin(), i_btm = p_text->GetEnd());
432 MoveScrollArea(area_up, area_dn, off, h);
436 YAssert(n != 0,
"No Enough height.");
441 Text::TextFileBuffer::Iterator
465 YAssert(scroll_offset < ln_h_ex,
"Invalid scroll offset found."),
466 YAssert(
bool(p_text),
"Null text buffer found.");
468 if(
YB_UNLIKELY(i_btm == p_text->GetEnd() || scroll_offset + h > ln_h_ex))
470 MoveUpForLastLine(-h, h);
473 if(
YB_LIKELY((scroll_offset += h) < ln_h_ex))
475 area_dn.
Pen.
Y += ln_h_ex - scroll_offset;
480 i_btm = PutLastLine();
481 AdjustForFirstNewline();
504 yunseq(i_top = Text::TextFileBuffer::Iterator(),
505 i_btm = Text::TextFileBuffer::Iterator(),
512 if(
YB_UNLIKELY(!p_text || p_text->GetTextSize() == 0))
522 overread_line_n = CheckOverRead(area_up) + area_dn.
GetTextLineNEx();
526 i_btm =
PutString(area_dn, i_new, p_text->GetEnd());
527 overread_line_n = CheckOverRead(area_dn);
530 if(
YB_LIKELY(!IsTextBottom() && *i_btm ==
'\n'))