diff options
Diffstat (limited to 'win32/ScintillaWin.cxx')
| -rw-r--r-- | win32/ScintillaWin.cxx | 50 | 
1 files changed, 18 insertions, 32 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index c6f34cb18..6c69a8ceb 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -461,6 +461,7 @@ class ScintillaWin :  	bool IsVisible() const noexcept;  	int SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) noexcept;  	bool GetScrollInfo(int nBar, LPSCROLLINFO lpsi) noexcept; +	bool ChangeScrollRange(int nBar, int nMin, int nMax, UINT nPage) noexcept;  	void ChangeScrollPos(int barType, Sci::Position pos);  	sptr_t GetTextLength();  	sptr_t GetText(uptr_t wParam, sptr_t lParam); @@ -2311,59 +2312,44 @@ void ScintillaWin::SetHorizontalScrollPos() {  	ChangeScrollPos(SB_HORZ, xOffset);  } +bool ScintillaWin::ChangeScrollRange(int nBar, int nMin, int nMax, UINT nPage) noexcept { +	SCROLLINFO sci = { sizeof(sci), SIF_PAGE | SIF_RANGE, 0, 0, 0, 0, 0 }; +	GetScrollInfo(nBar, &sci); +	if ((sci.nMin != nMin) || (sci.nMax != nMax) ||	(sci.nPage != nPage)) { +		sci.nMin = nMin; +		sci.nMax = nMax; +		sci.nPage = nPage; +		SetScrollInfo(nBar, &sci, TRUE); +		return true; +	} +	return false; +} +  bool ScintillaWin::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) {  	if (!IsVisible()) {  		return false;  	}  	bool modified = false; -	SCROLLINFO sci = { -		sizeof(sci), 0, 0, 0, 0, 0, 0 -	}; -	sci.fMask = SIF_PAGE | SIF_RANGE; -	GetScrollInfo(SB_VERT, &sci);  	const Sci::Line vertEndPreferred = nMax;  	if (!verticalScrollBarVisible)  		nPage = vertEndPreferred + 1; -	if ((sci.nMin != 0) || -		(sci.nMax != vertEndPreferred) || -		(sci.nPage != static_cast<unsigned int>(nPage)) || -		(sci.nPos != 0)) { -		sci.fMask = SIF_PAGE | SIF_RANGE; -		sci.nMin = 0; -		sci.nMax = static_cast<int>(vertEndPreferred); -		sci.nPage = static_cast<UINT>(nPage); -		sci.nPos = 0; -		sci.nTrackPos = 1; -		SetScrollInfo(SB_VERT, &sci, TRUE); +	if (ChangeScrollRange(SB_VERT, 0, static_cast<int>(vertEndPreferred), static_cast<unsigned int>(nPage))) {  		modified = true;  	}  	const PRectangle rcText = GetTextRectangle();  	int pageWidth = static_cast<int>(rcText.Width()); -	int horizEndPreferred = std::max(scrollWidth, pageWidth-1); -	if (horizEndPreferred < 0) -		horizEndPreferred = 0; +	const int horizEndPreferred = std::max({scrollWidth, pageWidth - 1, 0});  	if (!horizontalScrollBarVisible || Wrapping())  		pageWidth = horizEndPreferred + 1; -	sci.fMask = SIF_PAGE | SIF_RANGE; -	GetScrollInfo(SB_HORZ, &sci); -	if ((sci.nMin != 0) || -		(sci.nMax != horizEndPreferred) || -		(sci.nPage != static_cast<unsigned int>(pageWidth)) || -		(sci.nPos != 0)) { -		sci.fMask = SIF_PAGE | SIF_RANGE; -		sci.nMin = 0; -		sci.nMax = horizEndPreferred; -		sci.nPage = pageWidth; -		sci.nPos = 0; -		sci.nTrackPos = 1; -		SetScrollInfo(SB_HORZ, &sci, TRUE); +	if (ChangeScrollRange(SB_HORZ, 0, horizEndPreferred, pageWidth)) {  		modified = true;  		if (scrollWidth < pageWidth) {  			HorizontalScrollTo(0);  		}  	} +  	return modified;  }  | 
