diff options
Diffstat (limited to 'src/Document.cxx')
| -rw-r--r-- | src/Document.cxx | 34 | 
1 files changed, 29 insertions, 5 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--) { | 
