diff options
| author | Neil <nyamatongwe@gmail.com> | 2017-06-12 11:49:56 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2017-06-12 11:49:56 +1000 | 
| commit | 46f9fd7509eaa2809392acf3a264b57a2daf973c (patch) | |
| tree | 1e3ee8a900c4e4c7768abbe21bfa9acc4043b345 /src/Editor.cxx | |
| parent | 09972b3a179d7ea39ef6ce7e0474531797c549fb (diff) | |
| download | scintilla-mirror-46f9fd7509eaa2809392acf3a264b57a2daf973c.tar.gz | |
Removed unused functions and methods from Platform.h.
Replaced Platform::Clamp with Sci::clamp but will later change this to
std::clamp once on full C++17 compilers.
Drop MouseButtonBounce workaround for very early GTK+/Linux.
Diffstat (limited to 'src/Editor.cxx')
| -rw-r--r-- | src/Editor.cxx | 99 | 
1 files changed, 52 insertions, 47 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 1dfb8d9e3..771353654 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -888,10 +888,10 @@ SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveD  		Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);  		if (moveDir > 0) {  			// lineDisplay is already line before fold as lines in fold use display line of line after fold -			lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed()); +			lineDisplay = Sci::clamp(lineDisplay, 0, cs.LinesDisplayed());  			return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay)));  		} else { -			lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed()); +			lineDisplay = Sci::clamp(lineDisplay - 1, 0, cs.LinesDisplayed());  			return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay)));  		}  	} @@ -915,7 +915,7 @@ void Editor::SetLastXChosen() {  }  void Editor::ScrollTo(Sci::Line line, bool moveThumb) { -	const Sci::Line topLineNew = Platform::Clamp(line, 0, MaxScrollPos()); +	const Sci::Line topLineNew = Sci::clamp(line, 0, MaxScrollPos());  	if (topLineNew != topLine) {  		// Try to optimise small scrolls  #ifndef UNDER_CE @@ -1154,7 +1154,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran  				} else {  					// yMarginT must equal to caretYSlop, with a minimum of 1 and  					// a maximum of slightly less than half the heigth of the text area. -					yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen); +					yMarginT = Sci::clamp(caretYSlop, 1, halfScreen);  					if (bEven) {  						yMarginB = yMarginT;  					} else { @@ -1164,7 +1164,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran  				yMoveT = yMarginT;  				if (bEven) {  					if (bJump) { -						yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen); +						yMoveT = Sci::clamp(caretYSlop * 3, 1, halfScreen);  					}  					yMoveB = yMoveT;  				} else { @@ -1179,7 +1179,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran  				}  			} else {	// Not strict  				yMoveT = bJump ? caretYSlop * 3 : caretYSlop; -				yMoveT = Platform::Clamp(yMoveT, 1, halfScreen); +				yMoveT = Sci::clamp(yMoveT, 1, halfScreen);  				if (bEven) {  					yMoveB = yMoveT;  				} else { @@ -1229,7 +1229,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran  				newXY.topLine = std::min(newXY.topLine, lineCaret);  			}  		} -		newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos()); +		newXY.topLine = Sci::clamp(newXY.topLine, 0, MaxScrollPos());  	}  	// Horizontal positioning @@ -1251,7 +1251,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran  				} else {  					// xMargin must equal to caretXSlop, with a minimum of 2 and  					// a maximum of slightly less than half the width of the text area. -					xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen); +					xMarginR = Sci::clamp(caretXSlop, 2, halfScreen);  					if (bEven) {  						xMarginL = xMarginR;  					} else { @@ -1260,7 +1260,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran  				}  				if (bJump && bEven) {  					// Jump is used only in even mode -					xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen); +					xMoveL = xMoveR = Sci::clamp(caretXSlop * 3, 1, halfScreen);  				} else {  					xMoveL = xMoveR = 0;	// Not used, avoid a warning  				} @@ -1283,7 +1283,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran  				}  			} else {	// Not strict  				xMoveR = bJump ? caretXSlop * 3 : caretXSlop; -				xMoveR = Platform::Clamp(xMoveR, 1, halfScreen); +				xMoveR = Sci::clamp(xMoveR, 1, halfScreen);  				if (bEven) {  					xMoveL = xMoveR;  				} else { @@ -1505,7 +1505,7 @@ bool Editor::WrapLines(WrapScope ws) {  		const Sci::Line lineDocTop = cs.DocFromDisplay(topLine);  		const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);  		if (ws == WrapScope::wsVisible) { -			lineToWrap = Platform::Clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal()); +			lineToWrap = Sci::clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());  			// Priority wrap to just after visible area.  			// Since wrapping could reduce display lines, treat each  			// as taking only one display line. @@ -1561,7 +1561,7 @@ bool Editor::WrapLines(WrapScope ws) {  	if (wrapOccurred) {  		SetScrollBars(); -		SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); +		SetTopLine(Sci::clamp(goodTopLine, 0, MaxScrollPos()));  		SetVerticalScrollPos();  	} @@ -1816,7 +1816,7 @@ void Editor::SetScrollBars() {  	// TODO: ensure always showing as many lines as possible  	// May not be, if, for example, window made larger  	if (topLine > MaxScrollPos()) { -		SetTopLine(Platform::Clamp(topLine, 0, MaxScrollPos())); +		SetTopLine(Sci::clamp(topLine, 0, MaxScrollPos()));  		SetVerticalScrollPos();  		Redraw();  	} @@ -2641,7 +2641,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {  		if (mh.linesAdded != 0) {  			// Avoid scrolling of display if change before current display  			if (mh.position < posTopLine && !CanDeferToLastStep(mh)) { -				Sci::Line newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos()); +				Sci::Line newTop = Sci::clamp(topLine + mh.linesAdded, 0, MaxScrollPos());  				if (newTop != topLine) {  					SetTopLine(newTop);  					SetVerticalScrollPos(); @@ -2877,7 +2877,7 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {  	} else {  		Point pt = LocationFromPosition(sel.MainCaret()); -		topLineNew = Platform::Clamp( +		topLineNew = Sci::clamp(  		            topLine + direction * LinesToScroll(), 0, MaxScrollPos());  		newPos = SPositionFromLocation(  			Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())), @@ -3209,6 +3209,14 @@ Sci::Position Editor::StartEndDisplayLine(Sci::Position pos, bool start) {  namespace { +short HighShortFromLong(long x) { +	return static_cast<short>(x >> 16); +} + +short LowShortFromLong(long x) { +	return static_cast<short>(x & 0xffff); +} +  unsigned int WithExtends(unsigned int iMessage) {  	switch (iMessage) {  	case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND; @@ -4470,30 +4478,27 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie  		if (!ctrl || !multipleSelection || (selectionType != selChar && selectionType != selWord))  			SetEmptySelection(newPos.Position());  		bool doubleClick = false; -		// Stop mouse button bounce changing selection type -		if (!Platform::MouseButtonBounce() || curTime != lastClickTime) { -			if (inSelMargin) { -				// Inside margin selection type should be either selSubLine or selWholeLine. -				if (selectionType == selSubLine) { -					// If it is selSubLine, we're inside a *double* click and word wrap is enabled, -					// so we switch to selWholeLine in order to select whole line. -					selectionType = selWholeLine; -				} else if (selectionType != selSubLine && selectionType != selWholeLine) { -					// If it is neither, reset selection type to line selection. -					selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; -				} +		if (inSelMargin) { +			// Inside margin selection type should be either selSubLine or selWholeLine. +			if (selectionType == selSubLine) { +				// If it is selSubLine, we're inside a *double* click and word wrap is enabled, +				// so we switch to selWholeLine in order to select whole line. +				selectionType = selWholeLine; +			} else if (selectionType != selSubLine && selectionType != selWholeLine) { +				// If it is neither, reset selection type to line selection. +				selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; +			} +		} else { +			if (selectionType == selChar) { +				selectionType = selWord; +				doubleClick = true; +			} else if (selectionType == selWord) { +				// Since we ended up here, we're inside a *triple* click, which should always select +				// whole line regardless of word wrap being enabled or not. +				selectionType = selWholeLine;  			} else { -				if (selectionType == selChar) { -					selectionType = selWord; -					doubleClick = true; -				} else if (selectionType == selWord) { -					// Since we ended up here, we're inside a *triple* click, which should always select -					// whole line regardless of word wrap being enabled or not. -					selectionType = selWholeLine; -				} else { -					selectionType = selChar; -					originalAnchorPos = sel.MainCaret(); -				} +				selectionType = selChar; +				originalAnchorPos = sel.MainCaret();  			}  		} @@ -5082,7 +5087,7 @@ Sci::Position Editor::PositionAfterMaxStyling(Sci::Position posMax, bool scrolli  	// When scrolling, allow less time to ensure responsive  	const double secondsAllowed = scrolling ? 0.005 : 0.02; -	const Sci::Line linesToStyle = Platform::Clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine), +	const Sci::Line linesToStyle = Sci::clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),  		10, 0x10000);  	const Sci::Line stylingMaxLine = std::min(  		static_cast<Sci::Line>(pdoc->LineFromPosition(pdoc->GetEndStyled()) + linesToStyle), @@ -5426,18 +5431,18 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {  		const Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);  		if (visiblePolicy & VISIBLE_SLOP) {  			if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) { -				SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos())); +				SetTopLine(Sci::clamp(lineDisplay - visibleSlop, 0, MaxScrollPos()));  				SetVerticalScrollPos();  				Redraw();  			} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||  			        ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { -				SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); +				SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));  				SetVerticalScrollPos();  				Redraw();  			}  		} else {  			if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) { -				SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); +				SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));  				SetVerticalScrollPos();  				Redraw();  			} @@ -6040,7 +6045,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) + 1, 1, true);  	case SCI_POSITIONRELATIVE: -		return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length()); +		return Sci::clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());  	case SCI_LINESCROLL:  		ScrollTo(topLine + static_cast<Sci::Line>(lParam)); @@ -7290,13 +7295,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		return vs.caretWidth;  	case SCI_ASSIGNCMDKEY: -		kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)), -			Platform::HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam)); +		kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)), +			HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));  		break;  	case SCI_CLEARCMDKEY: -		kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)), -			Platform::HighShortFromLong(static_cast<long>(wParam)), SCI_NULL); +		kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)), +			HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);  		break;  	case SCI_CLEARALLCMDKEYS: | 
