diff options
Diffstat (limited to 'src/Document.cxx')
| -rw-r--r-- | src/Document.cxx | 34 | 
1 files changed, 33 insertions, 1 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 2036f383c..b75c754ac 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -87,6 +87,7 @@ Document::Document() {  	eolMode = SC_EOL_LF;  #endif  	dbcsCodePage = 0; +	lineEndBitSet = SC_LINE_END_TYPE_DEFAULT;  	stylingBits = 5;  	stylingBitsMask = 0x1F;  	stylingMask = 0; @@ -157,12 +158,29 @@ bool Document::SetDBCSCodePage(int dbcsCodePage_) {  	if (dbcsCodePage != dbcsCodePage_) {  		dbcsCodePage = dbcsCodePage_;  		SetCaseFolder(NULL); +		cb.SetLineEndTypes(lineEndBitSet & LineEndTypesSupported());  		return true;  	} else {  		return false;  	}  } +bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) { +	if (lineEndBitSet != lineEndBitSet_) { +		lineEndBitSet = lineEndBitSet_; +		int lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported(); +		if (lineEndBitSetActive != cb.GetLineEndTypes()) { +			ModifiedAt(0); +			cb.SetLineEndTypes(lineEndBitSetActive); +			return true; +		} else { +			return false; +		} +	} else { +		return false; +	} +} +  void Document::InsertLine(int line) {  	for (int j=0; j<ldSize; j++) {  		if (perLineData[j]) @@ -267,7 +285,21 @@ int SCI_METHOD Document::LineEnd(int line) const {  	if (line == LinesTotal() - 1) {  		return LineStart(line + 1);  	} else { -		int position = LineStart(line + 1) - 1; +		int position = LineStart(line + 1); +		if (SC_CP_UTF8 == dbcsCodePage) { +			unsigned char bytes[] = { +				static_cast<unsigned char>(cb.CharAt(position-3)), +				static_cast<unsigned char>(cb.CharAt(position-2)), +				static_cast<unsigned char>(cb.CharAt(position-1)), +			}; +			if (UTF8IsSeparator(bytes)) { +				return position - UTF8SeparatorLength; +			} +			if (UTF8IsNEL(bytes+1)) { +				return position - UTF8NELLength; +			} +		} +		position--; // Back over CR or LF  		// When line terminator is CR+LF, may need to go back one more  		if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {  			position--; | 
