diff options
| -rw-r--r-- | src/Editor.cxx | 26 | ||||
| -rw-r--r-- | src/Editor.h | 4 | 
2 files changed, 15 insertions, 15 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index b73576dd8..64e643b67 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -50,7 +50,7 @@ LineLayout::LineLayout(int maxLineLength_) :  	styles(0),  	indicators(0),  	positions(0), -	widthLine(0), +	widthLine(wrapWidthInfinite),  	lines(1) {  		Resize(maxLineLength_);  } @@ -357,7 +357,7 @@ Editor::Editor() {  	foldFlags = 0;  	wrapState = eWrapNone; -	wrapWidth = wrapWidthInfinite; +	wrapWidth = LineLayout::wrapWidthInfinite;  	docLineLastWrapped = -1;  	llc.SetLevel(LineLayoutCache::llcDocument); @@ -493,7 +493,7 @@ Point Editor::LocationFromPosition(int pos) {  			pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)];  		}  		for (int subLine=0; subLine<ll->lines; subLine++) { -			if ((posInLine > ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine+1))) { +			if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine+1))) {  				pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)];  			}  			if (posInLine >= ll->LineStart(subLine)) { @@ -1030,8 +1030,8 @@ bool Editor::WrapLines() {  	bool wrapOccurred = false;  	if (docLineLastWrapped < pdoc->LinesTotal()) {  		if (wrapState == eWrapNone) { -			if (wrapWidth != wrapWidthInfinite) { -				wrapWidth = wrapWidthInfinite; +			if (wrapWidth != LineLayout::wrapWidthInfinite) { +				wrapWidth = LineLayout::wrapWidthInfinite;  				for (int lineDoc=0; lineDoc<pdoc->LinesTotal(); lineDoc++) {  					cs.SetHeight(lineDoc, 1);  				} @@ -1315,7 +1315,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou  		return;  	int posLineStart = pdoc->LineStart(line);  	if (ll->validity == LineLayout::llInvalid) { -		ll->widthLine = width; +		ll->widthLine = LineLayout::wrapWidthInfinite;  		ll->lines = 1;  		int numCharsInLine = 0;  		if (vstyle.edgeState == EDGE_BACKGROUND) { @@ -1413,15 +1413,15 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou  		ll->numCharsInLine = numCharsInLine;  		ll->validity = LineLayout::llPositions;  	} -	if (ll->validity == LineLayout::llPositions) { -		if (width == wrapWidthInfinite) { +	// Hard to cope when too narrow, so just assume there is space +	if (width < 20) { +		width = 20; +	} +	if ((ll->validity == LineLayout::llPositions) || (ll->widthLine != width)) { +		ll->widthLine = width; +		if (width == LineLayout::wrapWidthInfinite) {  			ll->lines = 1; -			ll->widthLine = ll->positions[ll->numCharsInLine];  		} else { -			if (width < 20)	{ // Hard to cope when too narrow, so just assume there is space -				width = 20; -				ll->widthLine = width; -			}  			ll->lines = 0;  			// Calculate line start positions based upon width.  			// For now this is simplistic - wraps on byte rather than character and diff --git a/src/Editor.h b/src/Editor.h index 8f47819b5..35aea3fc3 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -42,6 +42,7 @@ private:  	int lineNumber;  	bool inCache;  public: +	enum { wrapWidthInfinite = 0x7ffffff };  	int maxLineLength;  	int numCharsInLine;  	enum validLevel { llInvalid, llPositions, llLines } validity; @@ -271,7 +272,6 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	// Wrapping support  	enum { eWrapNone, eWrapWord } wrapState; -	enum { wrapWidthInfinite = 0x7ffffff };  	int wrapWidth;  	int docLineLastWrapped; @@ -337,7 +337,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	void PaintSelMargin(Surface *surface, PRectangle &rc);  	LineLayout *RetrieveLineLayout(int lineNumber);  	void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,  -		int width=wrapWidthInfinite); +		int width=LineLayout::wrapWidthInfinite);  	void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,  		PRectangle rcLine, LineLayout *ll, int subLine=0);  	void Paint(Surface *surfaceWindow, PRectangle rcArea); | 
