Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminary exit (performance optimization) for Scrollbars calculation #1574

Merged
merged 3 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Externals/crystaledit/editlib/ccrystaltextview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3310,6 +3310,17 @@ GetMaxLineLength (int nTopLine, int nLines)
return nMaxLineLength;
}

bool CCrystalTextView::
CoverLength(int nTopLine, int nLines, int min_length)
{
const int nLineCount = (std::min)(nTopLine + nLines, GetLineCount());
for (int I = nTopLine; I != nLineCount; I++) {
if (GetLineActualLength(I) >= min_length)
return true;
}
return false;
}

CCrystalTextView *CCrystalTextView::
GetSiblingView (int nRow, int nCol)
{
Expand Down Expand Up @@ -3888,8 +3899,8 @@ AttachToBuffer (CCrystalTextBuffer * pBuf /*= nullptr*/ )
ESB_DISABLE_BOTH : ESB_ENABLE_BOTH);
CScrollBar *pHorzScrollBarCtrl = GetScrollBarCtrl (SB_HORZ);
if (pHorzScrollBarCtrl != nullptr)
pHorzScrollBarCtrl->EnableScrollBar (GetScreenChars () >= GetMaxLineLength (m_nTopLine, GetScreenLines())?
ESB_DISABLE_BOTH : ESB_ENABLE_BOTH);
pHorzScrollBarCtrl->EnableScrollBar(CoverLength(m_nTopLine, GetScreenLines(), GetScreenChars()) ?
ESB_DISABLE_BOTH : ESB_ENABLE_BOTH);

// Update scrollbars
InvalidateVertScrollBar ();
Expand Down
1 change: 1 addition & 0 deletions Externals/crystaledit/editlib/ccrystaltextview.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ protected :
//END SW
int GetCharWidth ();
int GetMaxLineLength (int nTopLine, int nLines);
bool CoverLength(int nTopLine, int nLines, int min_length);
int GetScreenLines ();
int GetScreenChars ();

Expand Down
2 changes: 1 addition & 1 deletion Externals/crystaledit/editlib/ccrystaltextview2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ ScrollLeft ()
void CCrystalTextView::
ScrollRight ()
{
if (m_nOffsetChar < GetMaxLineLength (m_nTopLine, GetScreenLines()) - 1)
if (CoverLength(m_nTopLine, GetScreenLines(), m_nOffsetChar))
{
ScrollToChar (m_nOffsetChar + 1);
UpdateCaret ();
Expand Down