diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Editor.cxx | 43 | ||||
| -rw-r--r-- | src/Editor.h | 17 | ||||
| -rw-r--r-- | src/KeyMap.cxx | 7 | 
3 files changed, 59 insertions, 8 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index d4a0596dd..75139e19f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -3441,6 +3441,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long  	case SCI_DELWORDRIGHT:  	case SCI_DELLINELEFT:  	case SCI_DELLINERIGHT: +	case SCI_LINECOPY:  	case SCI_LINECUT:  	case SCI_LINEDELETE:  	case SCI_LINETRANSPOSE: @@ -3879,6 +3880,13 @@ int Editor::KeyCommand(unsigned int iMessage) {  			pdoc->DeleteChars(currentPos, end - currentPos);  		}  		break; +	case SCI_LINECOPY: { +			int lineStart = pdoc->LineFromPosition(SelectionStart()); +			int lineEnd = pdoc->LineFromPosition(SelectionEnd()); +			CopyRangeToClipboard(pdoc->LineStart(lineStart), +				pdoc->LineStart(lineEnd + 1)); +		} +		break;  	case SCI_LINECUT: {  			int lineStart = pdoc->LineFromPosition(currentPos);  			int lineEnd = pdoc->LineFromPosition(anchor); @@ -3891,6 +3899,7 @@ int Editor::KeyCommand(unsigned int iMessage) {  			int end = pdoc->LineStart(lineEnd + 1);  			SetSelection(start, end);  			Cut(); +			SetLastXChosen();  		}  		break;  	case SCI_LINEDELETE: { @@ -4187,10 +4196,14 @@ char *Editor::CopyRange(int start, int end) {  	return text;  } +void Editor::CopySelectionFromRange(SelectionText *ss, int start, int end) { +	ss->Set(CopyRange(start, end), end - start, false); +} +  void Editor::CopySelectionRange(SelectionText *ss) { -	char *text = 0; -	int size = 0;  	if (selType == selRectangle) { +		char *text = 0; +		int size = 0;  		int lineStart = pdoc->LineFromPosition(SelectionStart());  		int lineEnd = pdoc->LineFromPosition(SelectionEnd());  		int line; @@ -4215,11 +4228,22 @@ void Editor::CopySelectionRange(SelectionText *ss) {  				text[size] = '\0';  			}  		} +		ss->Set(text, size, true);  	} else { -		size = SelectionEnd() - SelectionStart(); -		text = CopyRange(SelectionStart(), SelectionEnd()); +		CopySelectionFromRange(ss, SelectionStart(), SelectionEnd());  	} -	ss->Set(text, size, selType == selRectangle); +} + +void Editor::CopyRangeToClipboard(int start, int end) { +	SelectionText selectedText; +	selectedText.Set(CopyRange(start, end), end - start); +	CopyToClipboard(selectedText); +} + +void Editor::CopyText(int length, const char *text) { +	SelectionText selectedText; +	selectedText.Copy(text, length); +	CopyToClipboard(selectedText);  }  void Editor::SetDragPosition(int newPos) { @@ -5046,6 +5070,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		Copy();  		break; +	case SCI_COPYRANGE: +		CopyRangeToClipboard(wParam, lParam); +		break; + +	case SCI_COPYTEXT: +		CopyText(wParam, CharPtrFromSPtr(lParam)); +		break; +  	case SCI_PASTE:  		Paste();  		SetLastXChosen(); @@ -6187,6 +6219,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  	case SCI_DELWORDRIGHT:  	case SCI_DELLINELEFT:  	case SCI_DELLINERIGHT: +	case SCI_LINECOPY:  	case SCI_LINECUT:  	case SCI_LINEDELETE:  	case SCI_LINETRANSPOSE: diff --git a/src/Editor.h b/src/Editor.h index f2a4c9ca9..bd4669192 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -133,6 +133,19 @@ public:  			len = 0;  		rectangular = rectangular_;  	} +	void Copy(const char *s_, int len_, bool rectangular_=false) { +		delete []s; +		s = new char[len_]; +		if (s) { +			len = len_; +			for (int i = 0; i < len_; i++) { +				s[i] = s_[i]; +			} +		} else { +			len = 0; +		} +		rectangular = rectangular_; +	}  };  /** @@ -416,8 +429,12 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	long SearchInTarget(const char *text, int length);  	void GoToLine(int lineNo); +	virtual void CopyToClipboard(const SelectionText &selectedText) = 0;  	char *CopyRange(int start, int end); +	void CopySelectionFromRange(SelectionText *ss, int start, int end);  	void CopySelectionRange(SelectionText *ss); +	void CopyRangeToClipboard(int start, int end); +	void CopyText(int length, const char *text);  	void SetDragPosition(int newPos);  	virtual void DisplayCursor(Window::Cursor c);  	virtual void StartDrag(); diff --git a/src/KeyMap.cxx b/src/KeyMap.cxx index 837cdd241..f15842af6 100644 --- a/src/KeyMap.cxx +++ b/src/KeyMap.cxx @@ -1,5 +1,5 @@  // Scintilla source code edit control -/** @file KeyMap.cxx  +/** @file KeyMap.cxx   ** Defines a mapping between keystrokes and commands.   **/  // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> @@ -13,7 +13,7 @@  KeyMap::KeyMap() : kmap(0), len(0), alloc(0) {  	for (int i = 0; MapDefault[i].key; i++) { -		AssignCmdKey(MapDefault[i].key,  +		AssignCmdKey(MapDefault[i].key,  			MapDefault[i].modifiers,               		MapDefault[i].msg);  	} @@ -113,7 +113,7 @@ const KeyToCommand KeyMap::MapDefault[] = {      {SCK_BACK,		SCI_SHIFT, 	SCI_DELETEBACK},      {SCK_BACK,		SCI_CTRL, 	SCI_DELWORDLEFT},      {SCK_BACK, 		SCI_ALT,	SCI_UNDO}, -    {SCK_BACK,		SCI_CSHIFT,	SCI_DELLINELEFT},     +    {SCK_BACK,		SCI_CSHIFT,	SCI_DELLINELEFT},      {'Z', 			SCI_CTRL,	SCI_UNDO},      {'Y', 			SCI_CTRL,	SCI_REDO},      {'X', 			SCI_CTRL,	SCI_CUT}, @@ -130,6 +130,7 @@ const KeyToCommand KeyMap::MapDefault[] = {      //'L', 			SCI_CTRL,		SCI_FORMFEED,      {'L', 			SCI_CTRL,	SCI_LINECUT},      {'L', 			SCI_CSHIFT,	SCI_LINEDELETE}, +    {'T', 			SCI_CSHIFT,	SCI_LINECOPY},      {'T', 			SCI_CTRL,	SCI_LINETRANSPOSE},      {'D', 			SCI_CTRL,	SCI_LINEDUPLICATE},      {'U', 			SCI_CTRL,	SCI_LOWERCASE}, | 
