diff options
| -rw-r--r-- | src/Document.cxx | 42 | ||||
| -rw-r--r-- | src/Document.h | 1 | 
2 files changed, 28 insertions, 15 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 6659f4f0c..16b434083 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -722,7 +722,7 @@ void Document::ConvertLineEnds(int eolModeSet) {  	for (int pos = 0; pos < Length(); pos++) {  		if (cb.CharAt(pos) == '\r') { -			if (cb.CharAt(pos + 1) == '\n') {  +			if (cb.CharAt(pos + 1) == '\n') {  				// CRLF  				if (eolModeSet == SC_EOL_CR) {  					DeleteChars(pos + 1, 1); // Delete the LF @@ -731,7 +731,7 @@ void Document::ConvertLineEnds(int eolModeSet) {  				} else {  					pos++;  				} -			} else {  +			} else {  				// CR  				if (eolModeSet == SC_EOL_CRLF) {  					InsertString(pos + 1, "\n", 1); // Insert LF @@ -756,33 +756,45 @@ void Document::ConvertLineEnds(int eolModeSet) {  	EndUndoAction();  } -int Document::ParaDown(int pos) { -	int line = LineFromPosition(pos); -	while (line < LinesTotal() && LineStart(line) != LineEnd(line)) { // skip non-empty lines -		line++; -	} -	while (line < LinesTotal() && LineStart(line) == LineEnd(line)) { // skip empty lines -		line++; +bool Document::IsWhiteLine(int line) { +	int currentChar = LineStart(line); +	int endLine = LineEnd(line); +	while (currentChar < endLine) { +		if (cb.CharAt(currentChar) != ' ' && cb.CharAt(currentChar) != '\t') { +			return false; +		} +		++currentChar;  	} -	if (line < LinesTotal()) -		return LineStart(line); -	else // end of a document -		return LineEnd(line-1); +	return true;  }  int Document::ParaUp(int pos) {  	int line = LineFromPosition(pos);  	line--; -	while (line >= 0 && LineStart(line) == LineEnd(line)) { // skip empty lines +	while (line >= 0 && IsWhiteLine(line)) { // skip empty lines  		line--;  	} -	while (line >= 0 && LineStart(line) != LineEnd(line)) { // skip non-empty lines +	while (line >= 0 && !IsWhiteLine(line)) { // skip non-empty lines  		line--;  	}  	line++;  	return LineStart(line);  } +int Document::ParaDown(int pos) { +	int line = LineFromPosition(pos); +	while (line < LinesTotal() && !IsWhiteLine(line)) { // skip non-empty lines +		line++; +	} +	while (line < LinesTotal() && IsWhiteLine(line)) { // skip empty lines +		line++; +	} +	if (line < LinesTotal()) +		return LineStart(line); +	else // end of a document +		return LineEnd(line-1); +} +  Document::charClassification Document::WordCharClass(unsigned char ch) {  	if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80))  		return ccWord; diff --git a/src/Document.h b/src/Document.h index f2fcc7c69..1b59b1dab 100644 --- a/src/Document.h +++ b/src/Document.h @@ -229,6 +229,7 @@ public:  	int WordPartLeft(int pos);  	int WordPartRight(int pos);  	int ExtendStyleRange(int pos, int delta, bool singleLine = false); +	bool IsWhiteLine(int line);  	int ParaUp(int pos);  	int ParaDown(int pos);  	int IndentSize() { return actualIndentInChars; } | 
