diff options
author | Mitchell Foral <unknown> | 2021-06-09 10:51:58 +1000 |
---|---|---|
committer | Mitchell Foral <unknown> | 2021-06-09 10:51:58 +1000 |
commit | 5f998b68113dd116c1e938028dddcbcc7425a144 (patch) | |
tree | ef0e02b0bad89507ef4ee0973913c251736bbfc2 | |
parent | 4fb6cb9c6e694574aab4aa29640f9903df407aed (diff) | |
download | scintilla-mirror-5f998b68113dd116c1e938028dddcbcc7425a144.tar.gz |
Add SCI_PASTERECTANGULAR to insert text like a rectangular paste.
-rw-r--r-- | doc/ScintillaDoc.html | 4 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 3 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 3 | ||||
-rw-r--r-- | include/ScintillaMessages.h | 1 | ||||
-rw-r--r-- | src/Editor.cxx | 9 | ||||
-rw-r--r-- | test/simpleTests.py | 6 |
7 files changed, 27 insertions, 0 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index bae44931d..01ec3e3ad 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -1107,6 +1107,7 @@ struct Sci_TextToFind { <a class="message" href="#SCI_COPYALLOWLINE">SCI_COPYALLOWLINE</a><br /> <a class="message" href="#SCI_SETPASTECONVERTENDINGS">SCI_SETPASTECONVERTENDINGS(bool convert)</a><br /> <a class="message" href="#SCI_GETPASTECONVERTENDINGS">SCI_GETPASTECONVERTENDINGS → bool</a><br /> + <a class="message" href="#SCI_PASTERECTANGULAR">SCI_PASTERECTANGULAR(position length, const char *text)</a><br /> </code> <p><b id="SCI_CUT">SCI_CUT</b><br /> @@ -1147,6 +1148,9 @@ struct Sci_TextToFind { <a class="seealso" href="#SCI_SETEOLMODE">SCI_SETEOLMODE</a>. Defaults to true.</p> + <p><b id="SCI_PASTERECTANGULAR">SCI_PASTERECTANGULAR(position length, const char *text)</b><br/> + Pastes the given text into the existing rectangular or empty selection, overwriting any selected text.</p> + <h2 id="ErrorHandling">Error handling</h2> <code><a class="message" href="#SCI_SETSTATUS">SCI_SETSTATUS(int status)</a><br /> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 30008fc85..39af707b8 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -585,6 +585,9 @@ and support setting a representation for the "\r\n" line end sequence. </li> <li> + Add SCI_PASTERECTANGULAR to insert text like a rectangular paste. + </li> + <li> Fixed bug with SCI_GETLASTCHILD. <a href="https://sourceforge.net/p/scintilla/bugs/2260/">Bug #2260</a>. </li> diff --git a/include/Scintilla.h b/include/Scintilla.h index 123f1ae96..c74332dc3 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -885,6 +885,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_TOGGLECARETSTICKY 2459 #define SCI_SETPASTECONVERTENDINGS 2467 #define SCI_GETPASTECONVERTENDINGS 2468 +#define SCI_PASTERECTANGULAR 2771 #define SCI_SELECTIONDUPLICATE 2469 #define SCI_SETCARETLINEBACKALPHA 2470 #define SCI_GETCARETLINEBACKALPHA 2471 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index dd91bf908..d8e8fc21a 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2439,6 +2439,9 @@ set void SetPasteConvertEndings=2467(bool convert,) # Get convert-on-paste setting get bool GetPasteConvertEndings=2468(,) +# Paste into a rectangular selection. +fun void PasteRectangular=2771(position length, string text) + # Duplicate the selection. If selection empty duplicate the line containing the caret. fun void SelectionDuplicate=2469(,) diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h index 6cf515df9..b5792d809 100644 --- a/include/ScintillaMessages.h +++ b/include/ScintillaMessages.h @@ -581,6 +581,7 @@ enum class Message { ToggleCaretSticky = 2459, SetPasteConvertEndings = 2467, GetPasteConvertEndings = 2468, + PasteRectangular = 2771, SelectionDuplicate = 2469, SetCaretLineBackAlpha = 2470, GetCaretLineBackAlpha = 2471, diff --git a/src/Editor.cxx b/src/Editor.cxx index 6860e153f..3ddd9daae 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -5940,6 +5940,15 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { EnsureCaretVisible(); break; + case Message::PasteRectangular: { + UndoGroup ug(pdoc); + if (!sel.Empty()) { + ClearSelection(); // want to replace rectangular selection contents + } + InsertPasteShape(CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam), PasteShape::rectangular); + break; + } + case Message::Clear: Clear(); SetLastXChosen(); diff --git a/test/simpleTests.py b/test/simpleTests.py index 63a752da4..82ed84810 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -535,6 +535,12 @@ class TestSimple(unittest.TestCase): self.ed.Clear() self.assertEquals(self.ed.Contents(), b"1c") + def testPasteRectangular(self): + self.ed.AddText(5, b"a\nb\nc") + self.ed.SetSel(0,0) + self.ed.PasteRectangular(3, b"1\n2") + self.assertEquals(self.ed.Contents(), b"1a\n2b\nc") + def testCopyAllowLine(self): lineEndType = self.ed.EOLMode self.ed.EOLMode = self.ed.SC_EOL_LF |