diff options
| -rw-r--r-- | src/ContractionState.cxx | 4 | ||||
| -rw-r--r-- | src/ContractionState.h | 1 | ||||
| -rw-r--r-- | src/Document.h | 8 | ||||
| -rw-r--r-- | src/Editor.cxx | 44 | ||||
| -rw-r--r-- | src/Editor.h | 2 | 
5 files changed, 32 insertions, 27 deletions
| diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx index 0636d90ea..a5ecfe113 100644 --- a/src/ContractionState.cxx +++ b/src/ContractionState.cxx @@ -76,6 +76,10 @@ int ContractionState::DisplayFromDoc(int lineDoc) const {  	}  } +int ContractionState::DisplayLastFromDoc(int lineDoc) const { +	return DisplayFromDoc(lineDoc) + GetHeight(lineDoc) - 1; +} +  int ContractionState::DocFromDisplay(int lineDisplay) const {  	if (OneToOne()) {  		return lineDisplay; diff --git a/src/ContractionState.h b/src/ContractionState.h index 0309fc269..1c9109c69 100644 --- a/src/ContractionState.h +++ b/src/ContractionState.h @@ -39,6 +39,7 @@ public:  	int LinesInDoc() const;  	int LinesDisplayed() const;  	int DisplayFromDoc(int lineDoc) const; +	int DisplayLastFromDoc(int lineDoc) const;  	int DocFromDisplay(int lineDisplay) const;  	void InsertLine(int lineDoc); diff --git a/src/Document.h b/src/Document.h index d73715764..e2414bd36 100644 --- a/src/Document.h +++ b/src/Document.h @@ -43,6 +43,14 @@ public:  		return (start != invalidPosition) && (end != invalidPosition);  	} +	Position First() const { +		return (start <= end) ? start : end; +	} + +	Position Last() const { +		return (start > end) ? start : end; +	} +  	// Is the position within the range?  	bool Contains(Position pos) const {  		if (start < end) { diff --git a/src/Editor.cxx b/src/Editor.cxx index d11de5e72..e9489123e 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -679,8 +679,7 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {  			PRectangle rcSelMargin = GetClientRectangle();  			rcSelMargin.right = rcSelMargin.left + vs.fixedColumnWidth;  			if (line != -1) { -				int position = pdoc->LineStart(line); -				PRectangle rcLine = RectangleFromRange(position, position); +				PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)));  				// Inflate line rectangle if there are image markers with height larger than line height  				if (vs.largestMarkerHeight > vs.lineHeight) { @@ -710,16 +709,9 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {  	}  } -PRectangle Editor::RectangleFromRange(int start, int end) { -	int minPos = start; -	if (minPos > end) -		minPos = end; -	int maxPos = start; -	if (maxPos < end) -		maxPos = end; -	int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(minPos)); -	int lineDocMax = pdoc->LineFromPosition(maxPos); -	int maxLine = cs.DisplayFromDoc(lineDocMax) + cs.GetHeight(lineDocMax) - 1; +PRectangle Editor::RectangleFromRange(Range r) { +	const int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(r.First())); +	const int maxLine = cs.DisplayLastFromDoc(pdoc->LineFromPosition(r.Last()));  	PRectangle rcClient = GetTextRectangle();  	PRectangle rc;  	const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0; @@ -734,7 +726,7 @@ PRectangle Editor::RectangleFromRange(int start, int end) {  }  void Editor::InvalidateRange(int start, int end) { -	RedrawRect(RectangleFromRange(start, end)); +	RedrawRect(RectangleFromRange(Range(start, end)));  }  int Editor::CurrentPosition() const { @@ -1930,18 +1922,18 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {  			}  			// Old code does not know about new markers needed to distinguish all cases -			int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID, +			const int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,  			        SC_MARKNUM_FOLDEROPEN); -			int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND, +			const int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,  			        SC_MARKNUM_FOLDER);  			while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rc.bottom) {  				PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed()); -				int lineDoc = cs.DocFromDisplay(visibleLine); +				const int lineDoc = cs.DocFromDisplay(visibleLine);  				PLATFORM_ASSERT(cs.GetVisible(lineDoc)); -				bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc); -				bool lastSubLine = visibleLine == (cs.DisplayFromDoc(lineDoc + 1) - 1); +				const bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc); +				const bool lastSubLine = visibleLine == cs.DisplayLastFromDoc(lineDoc);  				int marks = pdoc->GetMark(lineDoc);  				if (!firstSubLine) @@ -1951,10 +1943,10 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {  				if (vs.ms[margin].mask & SC_MASK_FOLDERS) {  					// Decide which fold indicator should be displayed -					int level = pdoc->GetLevel(lineDoc); -					int levelNext = pdoc->GetLevel(lineDoc + 1); -					int levelNum = level & SC_FOLDLEVELNUMBERMASK; -					int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK; +					const int level = pdoc->GetLevel(lineDoc); +					const int levelNext = pdoc->GetLevel(lineDoc + 1); +					const int levelNum = level & SC_FOLDLEVELNUMBERMASK; +					const int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;  					if (level & SC_FOLDLEVELHEADERFLAG) {  						if (firstSubLine) {  							if (levelNum < levelNextNum) { @@ -1984,9 +1976,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {  							}  						}  						needWhiteClosure = false; -						int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1)); -						int firstFollowupLineLevel = pdoc->GetLevel(firstFollowupLine); -						int secondFollowupLineLevelNum = pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK; +						const int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1)); +						const int firstFollowupLineLevel = pdoc->GetLevel(firstFollowupLine); +						const int secondFollowupLineLevelNum = pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK;  						if (!cs.GetExpanded(lineDoc)) {  							if ((firstFollowupLineLevel & SC_FOLDLEVELWHITEFLAG) &&  								(levelNum > secondFollowupLineLevelNum)) @@ -6894,7 +6886,7 @@ void Editor::CheckForChangeOutsidePaint(Range r) {  		if (!r.Valid())  			return; -		PRectangle rcRange = RectangleFromRange(r.start, r.end); +		PRectangle rcRange = RectangleFromRange(r);  		PRectangle rcText = GetTextRectangle();  		if (rcRange.top < rcText.top) {  			rcRange.top = rcText.top; diff --git a/src/Editor.h b/src/Editor.h index 532211283..2f095a060 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -361,7 +361,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	virtual void DiscardOverdraw();  	virtual void Redraw();  	void RedrawSelMargin(int line=-1, bool allAfter=false); -	PRectangle RectangleFromRange(int start, int end); +	PRectangle RectangleFromRange(Range r);  	void InvalidateRange(int start, int end);  	bool UserVirtualSpace() const { | 
