Skip to content

Commit

Permalink
remove code duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Oct 21, 2024
1 parent eac1ed2 commit 1c6ea88
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions vstgui/lib/ctexteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,26 +1717,21 @@ void TextEditorView::layout (StbTexteditRow* row, size_t start_i) const
return;
if (md.stbInternalIterator == md.model.lines.end ())
md.stbInternalIterator = md.model.lines.begin ();
row->baseline_y_delta = static_cast<float> (md.lineHeight);
row->ymin = static_cast<float> (-md.fontDescent);
row->ymax = static_cast<float> (md.lineHeight);
row->x0 = static_cast<float> (md.style->leftMargin);
row->x1 = static_cast<float> (getWidth ());
if (start_i == md.stbInternalIterator->range.start)
{
row->num_chars = static_cast<int> (md.stbInternalIterator->range.length);
row->baseline_y_delta = static_cast<float> (md.lineHeight);
row->ymin = static_cast<float> (-md.fontDescent);
row->ymax = static_cast<float> (md.lineHeight);
row->x0 = static_cast<float> (md.style->leftMargin);
row->x1 = static_cast<float> (getWidth ());
++md.stbInternalIterator;
return;
}
md.stbInternalIterator = md.model.lines.begin ();
auto line = findLine (md.model.lines.begin (), md.model.lines.end (), start_i);
vstgui_assert (line != md.model.lines.end ());
row->num_chars = static_cast<int> (line->range.length);
row->baseline_y_delta = static_cast<float> (md.lineHeight);
row->ymin = static_cast<float> (-md.fontDescent);
row->ymax = static_cast<float> (md.lineHeight);
row->x0 = static_cast<float> (md.style->leftMargin);
row->x1 = static_cast<float> (getWidth ());
}

//------------------------------------------------------------------------
Expand Down

0 comments on commit 1c6ea88

Please sign in to comment.