diff options
| author | nyamatongwe <unknown> | 2002-01-16 07:26:01 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2002-01-16 07:26:01 +0000 | 
| commit | 93660c1b10407f26bd3bf58b2dc0102c9d936c4c (patch) | |
| tree | 315e5052bc040c2926145968ffa558dd00482231 /src/Editor.cxx | |
| parent | dafcd28f79ae282b973b9e7cf7b350e7902ca943 (diff) | |
| download | scintilla-mirror-93660c1b10407f26bd3bf58b2dc0102c9d936c4c.tar.gz | |
WrapLines performs scroll bar and top line maintenance.
WrapLines called before ensuring a lin eis visible so doc<->visible mapping
correct.
When modification changes number of lines, NeedWrapping starts one line
before.
Horizontal scrolling disallowed even more when in wrap mode.
Diffstat (limited to 'src/Editor.cxx')
| -rw-r--r-- | src/Editor.cxx | 31 | 
1 files changed, 19 insertions, 12 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 8c4a5cb9b..bdc322645 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -627,7 +627,7 @@ void Editor::HorizontalScrollTo(int xPos) {  	//Platform::DebugPrintf("HorizontalScroll %d\n", xPos);  	if (xPos < 0)  		xPos = 0; -	if (xOffset != xPos) { +	if ((wrapState == eWrapNone) && (xOffset != xPos)) {  		xOffset = xPos;  		SetHorizontalScrollPos();  		RedrawRect(GetClientRectangle()); @@ -750,12 +750,14 @@ void Editor::InvalidateCaret() {  void Editor::NeedWrapping(int docLineStartWrapping) {  	docLineLastWrapped = docLineStartWrapping - 1; +	if (docLineLastWrapped < -1) +		docLineLastWrapped = -1;  }  // Check if wrapping needed and perform any needed wrapping.  // Return true if wrapping occurred. -bool Editor::WrapLines(int *goodTopLine) { -	*goodTopLine = topLine; +bool Editor::WrapLines() { +	int goodTopLine = topLine;  	bool wrapOccurred = false;  	if (docLineLastWrapped < pdoc->LinesTotal()) {  		if (wrapState == eWrapNone) { @@ -787,13 +789,18 @@ bool Editor::WrapLines(int *goodTopLine) {  						wrapOccurred = true;  				}  			} -			*goodTopLine = cs.DisplayFromDoc(lineDocTop); +			goodTopLine = cs.DisplayFromDoc(lineDocTop);  			if (subLineTop < cs.GetHeight(lineDocTop)) -				*goodTopLine += subLineTop; +				goodTopLine += subLineTop;  			else -				*goodTopLine += cs.GetHeight(lineDocTop); +				goodTopLine += cs.GetHeight(lineDocTop);  		}  	} +	if (wrapOccurred) { +		SetScrollBars(); +		SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); +		SetVerticalScrollPos(); +	}  	return wrapOccurred;  } @@ -1433,11 +1440,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {  	//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d)   %d\n",  	//	rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); -	int goodTopLine = topLine; -	if (WrapLines(&goodTopLine)) { -		SetScrollBars(); -		SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); -		SetVerticalScrollPos(); +	if (WrapLines()) {  		// The wrapping process has changed the height of some lines so abandon this  		// paint for a complete repaint.  		paintState = paintAbandoned; @@ -2263,7 +2266,7 @@ void Editor::CheckModificationForWrap(DocModification mh) {  					LineLayout ll;  					LayoutLine(lineDoc, surface, vs, ll, wrapWidth);  					if (cs.GetHeight(lineDoc) != ll.lines) { -						NeedWrapping(lineDoc); +						NeedWrapping(lineDoc-1);  						Redraw();  					}  				} else { @@ -3708,6 +3711,10 @@ void Editor::ToggleContraction(int line) {  // Recurse up from this line to find any folds that prevent this line from being visible  // and unfold them all.  void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { + +	// In case in need of wrapping to ensure DisplayFromDoc works. +	WrapLines(); +  	if (!cs.GetVisible(lineDoc)) {  		int lineParent = pdoc->GetFoldParent(lineDoc);  		if (lineParent >= 0) { | 
