diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Editor.cxx | 39 | ||||
| -rw-r--r-- | src/Editor.h | 6 | ||||
| -rw-r--r-- | src/Selection.cxx | 8 | ||||
| -rw-r--r-- | src/Selection.h | 1 | 
4 files changed, 49 insertions, 5 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 2ad5f5863..b690d8011 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4152,8 +4152,9 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {  	}  } -void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len) { +void Editor::InsertPaste(const char *text, int len) {  	if (multiPasteMode == SC_MULTIPASTE_ONCE) { +		SelectionPosition selStart = sel.Start();  		selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace()));  		const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len);  		if (lengthInserted > 0) { @@ -4186,6 +4187,35 @@ void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len)  	}  } +void Editor::InsertPasteShape(const char *text, int len, PasteShape shape) { +	std::string convertedText; +	if (convertPastes) { +		// Convert line endings of the paste into our local line-endings mode +		convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode); +		len = static_cast<int>(convertedText.length()); +		text = convertedText.c_str(); +	} +	if (shape == pasteRectangular) { +		PasteRectangular(sel.Start(), text, len); +	} else { +		if (shape == pasteLine) { +			int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())); +			int lengthInserted = pdoc->InsertString(insertPos, text, len); +			// add the newline if necessary +			if ((len > 0) && (text[len - 1] != '\n' && text[len - 1] != '\r')) { +				const char *endline = StringFromEOLMode(pdoc->eolMode); +				int length = static_cast<int>(strlen(endline)); +				lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline, length); +			} +			if (sel.MainCaret() == insertPos) { +				SetEmptySelection(sel.MainCaret() + lengthInserted); +			} +		} else { +			InsertPaste(text, len); +		} +	} +} +  void Editor::ClearSelection(bool retainMultipleSelections) {  	if (!sel.IsRectangular() && !retainMultipleSelections)  		FilterSelections(); @@ -6150,14 +6180,17 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length  		}  		position = positionAfterDeletion; +		std::string convertedText = Document::TransformLineEnds(value, lengthValue, pdoc->eolMode); +  		if (rectangular) { -			PasteRectangular(position, value, static_cast<int>(lengthValue)); +			PasteRectangular(position, convertedText.c_str(), static_cast<int>(convertedText.length()));  			// Should try to select new rectangle but it may not be a rectangle now so just select the drop position  			SetEmptySelection(position);  		} else {  			position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());  			position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace())); -			const int lengthInserted = pdoc->InsertString(position.Position(), value, static_cast<int>(lengthValue)); +			const int lengthInserted = pdoc->InsertString( +				position.Position(), convertedText.c_str(), static_cast<int>(convertedText.length()));  			if (lengthInserted > 0) {  				SelectionPosition posAfterInsertion = position;  				posAfterInsertion.Add(lengthInserted); diff --git a/src/Editor.h b/src/Editor.h index 119d03379..15a0fcf04 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -473,8 +473,10 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	int InsertSpace(int position, unsigned int spaces);  	void AddChar(char ch);  	virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false); -	void InsertPaste(SelectionPosition selStart, const char *text, int len); -	void ClearSelection(bool retainMultipleSelections=false); +	void InsertPaste(const char *text, int len); +	enum PasteShape { pasteStream=0, pasteRectangular = 1, pasteLine = 2 }; +	void InsertPasteShape(const char *text, int len, PasteShape shape); +	void ClearSelection(bool retainMultipleSelections = false);  	void ClearAll();  	void ClearDocumentStyle();  	void Cut(); diff --git a/src/Selection.cxx b/src/Selection.cxx index ae4d8bfc7..4c2ab0508 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -230,6 +230,14 @@ SelectionRange &Selection::RangeMain() {  	return ranges[mainRange];  } +SelectionPosition Selection::Start() const { +	if (IsRectangular()) { +		return rangeRectangular.Start(); +	} else { +		return ranges[mainRange].Start(); +	} +} +  bool Selection::MoveExtends() const {  	return moveExtends;  } diff --git a/src/Selection.h b/src/Selection.h index e84d3c32c..e7f62f061 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -157,6 +157,7 @@ public:  	void SetMain(size_t r);  	SelectionRange &Range(size_t r);  	SelectionRange &RangeMain(); +	SelectionPosition Start() const;  	bool MoveExtends() const;  	void SetMoveExtends(bool moveExtends_);  	bool Empty() const; | 
