diff options
| -rw-r--r-- | src/Document.cxx | 34 | ||||
| -rw-r--r-- | src/Document.h | 1 | ||||
| -rw-r--r-- | src/Editor.cxx | 19 | 
3 files changed, 44 insertions, 10 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 3ece44c94..e96e7d03a 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -621,21 +621,45 @@ int Document::GetColumn(int pos) {  	int column = 0;  	int line = LineFromPosition(pos);  	if ((line >= 0) && (line < LinesTotal())) { -		for (int i = LineStart(line);i < pos;i++) { +		for (int i = LineStart(line);i < pos;) {  			char ch = cb.CharAt(i); -			if (ch == '\t') +			if (ch == '\t') {  				column = NextTab(column, tabInChars); -			else if (ch == '\r') +				i++; +			} else if (ch == '\r') {  				return column; -			else if (ch == '\n') +			} else if (ch == '\n') {  				return column; -			else +			} else {  				column++; +				i = MovePositionOutsideChar(i + 1, 1); +			}  		}  	}  	return column;  } +int Document::FindColumn(int line, int column) { +	int position = LineStart(line); +	int columnCurrent = 0; +	if ((line >= 0) && (line < LinesTotal())) { +		while (columnCurrent < column) { +			char ch = cb.CharAt(position); +			if (ch == '\t') { +				columnCurrent = NextTab(columnCurrent, tabInChars); +			} else if (ch == '\r') { +				return position; +			} else if (ch == '\n') { +				return position; +			} else { +				columnCurrent++; +				position = MovePositionOutsideChar(position + 1, 1); +			} +		} +	} +	return position; +} +  void Document::Indent(bool forwards, int lineBottom, int lineTop) {  	// Dedent - suck white space off the front of the line to dedent by equivalent of a tab  	for (int line = lineBottom; line >= lineTop; line--) { diff --git a/src/Document.h b/src/Document.h index d0e63fc5b..09814fec8 100644 --- a/src/Document.h +++ b/src/Document.h @@ -141,6 +141,7 @@ public:  	void SetLineIndentation(int line, int indent);  	int GetLineIndentPosition(int line);  	int GetColumn(int position); +	int FindColumn(int line, int column);  	void Indent(bool forwards, int lineBottom, int lineTop);  	void ConvertLineEnds(int eolModeSet);  	void SetReadOnly(bool set) { cb.SetReadOnly(set); } diff --git a/src/Editor.cxx b/src/Editor.cxx index dbf517c50..5f43d5871 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -987,6 +987,10 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {  void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {  	int ydiff = (rcTab.bottom - rcTab.top) / 2;  	int xhead = rcTab.right - 1 - ydiff; +	if (xhead <= rcTab.left) { +		ydiff -= rcTab.left - xhead - 1; +		xhead = rcTab.left - 1; +	}  	if ((rcTab.left + 2) < (rcTab.right - 1))  		surface->MoveTo(rcTab.left + 2, ymid);  	else @@ -1012,6 +1016,15 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou  	ll.lineStarts[0] = 0;  	int numCharsInLine = 0;  	int posLineStart = pdoc->LineStart(line); +	if (vstyle.edgeState == EDGE_BACKGROUND) { +		ll.edgeColumn = pdoc->FindColumn(line, theEdge); +		if (ll.edgeColumn >= posLineStart) { +			ll.edgeColumn -= posLineStart; +		} +	} else { +		ll.edgeColumn = -1; +	} +	  	int posLineEnd = pdoc->LineStart(line + 1);  	Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;  	char styleByte = 0; @@ -1399,7 +1412,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  	}  	if (vsDraw.edgeState == EDGE_LINE) { -		int edgeX = ll.edgeColumn * vsDraw.spaceWidth; +		int edgeX = theEdge * vsDraw.spaceWidth;  		rcSegment.left = edgeX + xStart;  		rcSegment.right = rcSegment.left + 1;  		surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated); @@ -1570,8 +1583,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {  				ll.selEnd = -1;  				ll.containsCaret = false;  			} -			// Need to fix this up so takes account of Unicode and DBCS -			ll.edgeColumn = theEdge;  			int posLineStart = pdoc->LineStart(lineDoc);  			int posLineEnd = pdoc->LineStart(lineDoc + 1); @@ -1814,8 +1825,6 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {  			ll.selStart = -1;  			ll.selEnd = -1;  			ll.containsCaret = false; -			// Need to fix this up so takes account of Unicode and DBCS -			ll.edgeColumn = theEdge;  			PRectangle rcLine;  			rcLine.left = pfr->rc.left + lineNumberWidth; | 
