diff options
-rw-r--r-- | doc/ScintillaDoc.html | 32 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 8 | ||||
-rw-r--r-- | include/Scintilla.h | 3 | ||||
-rw-r--r-- | include/Scintilla.iface | 9 | ||||
-rw-r--r-- | src/Editor.cxx | 43 | ||||
-rw-r--r-- | src/Editor.h | 17 | ||||
-rw-r--r-- | src/KeyMap.cxx | 7 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 26 |
8 files changed, 118 insertions, 27 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 66944ec97..daf9d6c11 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -747,6 +747,16 @@ struct TextToFind { <h2 id="CutCopyAndPaste">Cut, copy and paste</h2> + <code><a class="message" href="#SCI_CUT">SCI_CUT</a><br /> + <a class="message" href="#SCI_COPY">SCI_COPY</a><br /> + <a class="message" href="#SCI_PASTE">SCI_PASTE</a><br /> + <a class="message" href="#SCI_CLEAR">SCI_CLEAR</a><br /> + <a class="message" href="#SCI_CANPASTE">SCI_CANPASTE</a><br /> + <a class="message" href="#SCI_COPYRANGE">SCI_COPYRANGE(int start, int end)</a><br /> + <a class="message" href="#SCI_COPYTEXT">SCI_COPYTEXT(int length, + const char *text)</a><br /> + </code> + <p><b id="SCI_CUT">SCI_CUT</b><br /> <b id="SCI_COPY">SCI_COPY</b><br /> <b id="SCI_PASTE">SCI_PASTE</b><br /> @@ -762,6 +772,12 @@ struct TextToFind { <p>GTK+ does not really support <code>SCI_CANPASTE</code> and always returns <code>TRUE</code> unless the document is read-only.</p> + <b id="SCI_COPYRANGE">SCI_COPYRANGE(int start, int end)</b><br /> + <b id="SCI_COPYTEXT">SCI_COPYTEXT(int length, const char *text)</b><br /> + <p><code>SCI_COPYRANGE</code> copies a range of text from the document to + the system clipboard and <code>SCI_COPYTEXT</code> copies a supplied piece of + text to the system clipboard.</p> + <h2 id="ErrorHandling">Error handling</h2> <p><b id="SCI_SETSTATUS">SCI_SETSTATUS(int status)</b><br /> @@ -3166,40 +3182,44 @@ struct TextToFind { <tr> <td><code>SCI_LINECUT</code></td> + <td><code>SCI_LINECOPY</code></td> + <td><code>SCI_LINEDELETE</code></td> <td><code>SCI_LINETRANSPOSE</code></td> - - <td><code>SCI_LINEDUPLICATE</code></td> </tr> <tr> + <td><code>SCI_LINEDUPLICATE</code></td> + <td><code>SCI_LOWERCASE</code></td> <td><code>SCI_UPPERCASE</code></td> <td><code>SCI_WORDPARTLEFT</code></td> - - <td><code>SCI_WORDPARTLEFTEXTEND</code></td> </tr> <tr> + <td><code>SCI_WORDPARTLEFTEXTEND</code></td> + <td><code>SCI_WORDPARTRIGHT</code></td> <td><code>SCI_WORDPARTRIGHTEXTEND</code></td> <td><code>SCI_HOMEDISPLAY</code></td> - - <td><code>SCI_HOMEDISPLAYEXTEND</code></td> </tr> <tr> + <td><code>SCI_HOMEDISPLAYEXTEND</code></td> + <td><code>SCI_LINEENDDISPLAY</code></td> <td><code>SCI_LINEENDDISPLAYEXTEND</code></td> <td><code>SCI_VCHOMEWRAP</code></td> + </tr> + <tr> <td><code>SCI_VCHOMEWRAPEXTEND</code></td> </tr> </tbody> diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index e8f1626b3..11506abb0 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -137,6 +137,7 @@ private: void NotifyKey(int key, int modifiers); void NotifyURIDropped(const char *list); virtual int KeyDefault(int key, int modifiers); + virtual void CopyToClipboard(const SelectionText &selectedText); virtual void Copy(); virtual void Paste(); virtual void CreateCallTipWindow(PRectangle rc); @@ -910,6 +911,13 @@ int ScintillaGTK::KeyDefault(int key, int modifiers) { //Platform::DebugPrintf("SK-key: %d %x %x\n",key, modifiers); } +void ScintillaGTK::CopyToClipboard(const SelectionText &selectedText) { + copyText.Copy(selectedText.s, selectedText.len); + gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)), + clipboard_atom, + GDK_CURRENT_TIME); +} + void ScintillaGTK::Copy() { if (currentPos != anchor) { CopySelectionRange(©Text); diff --git a/include/Scintilla.h b/include/Scintilla.h index 470425e76..250f79314 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -464,6 +464,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_LINEENDWRAPEXTEND 2452 #define SCI_VCHOMEWRAP 2453 #define SCI_VCHOMEWRAPEXTEND 2454 +#define SCI_LINECOPY 2455 #define SCI_MOVECARETINSIDEVIEW 2401 #define SCI_LINELENGTH 2350 #define SCI_BRACEHIGHLIGHT 2351 @@ -537,6 +538,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_PARAUPEXTEND 2416 #define SCI_POSITIONBEFORE 2417 #define SCI_POSITIONAFTER 2418 +#define SCI_COPYRANGE 2419 +#define SCI_COPYTEXT 2420 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 94c181379..2c2c092e7 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1231,6 +1231,9 @@ fun void LineEndWrapExtend=2452(,) fun void VCHomeWrap=2453(,) fun void VCHomeWrapExtend=2454(,) +# Copy the line containing the caret. +fun void LineCopy=2455(,) + # Move the caret inside current view if it's not there already. fun void MoveCaretInsideView=2401(,) @@ -1449,6 +1452,12 @@ fun position PositionBefore=2417(position pos,) # page into account. Maximum value returned is the last position in the document. fun position PositionAfter=2418(position pos,) +# Copy a range of text to the clipboard. Positions are clipped into the document. +fun void CopyRange=2419(position start, position end) + +# Copy argument text to the clipboard. +fun void CopyText=2420(int length, string text) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) 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}, diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index d44769237..b26f7a1e6 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -220,7 +220,7 @@ class ScintillaWin : void AddCharBytes(char b0, char b1=0); void GetIntelliMouseParameters(); - void CopySelTextToClipboard(); + virtual void CopyToClipboard(const SelectionText &selectedText); void ScrollMessage(WPARAM wParam); void HorizontalScrollMessage(WPARAM wParam); void RealizeWindowPalette(bool inBackGround); @@ -1036,13 +1036,9 @@ void ScintillaWin::NotifyDoubleClick(Point pt, bool shift) { void ScintillaWin::Copy() { //Platform::DebugPrintf("Copy\n"); if (currentPos != anchor) { - ::OpenClipboard(MainHWND()); - ::EmptyClipboard(); - CopySelTextToClipboard(); - if (selType == selRectangle) { - ::SetClipboardData(cfColumnSelect, 0); - } - ::CloseClipboard(); + SelectionText selectedText; + CopySelectionRange(&selectedText); + CopyToClipboard(selectedText); } } @@ -1534,11 +1530,9 @@ void ScintillaWin::GetIntelliMouseParameters() { ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &linesPerScroll, 0); } -void ScintillaWin::CopySelTextToClipboard() { - SelectionText selectedText; - CopySelectionRange(&selectedText); - if (selectedText.len == 0) - return; +void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) { + ::OpenClipboard(MainHWND()); + ::EmptyClipboard(); HGLOBAL hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, selectedText.len + 1); @@ -1562,6 +1556,12 @@ void ScintillaWin::CopySelTextToClipboard() { } ::SetClipboardData(CF_UNICODETEXT, uhand); } + + if (selectedText.rectangular) { + ::SetClipboardData(cfColumnSelect, 0); + } + + ::CloseClipboard(); } void ScintillaWin::ScrollMessage(WPARAM wParam) { |