From 215215c5fc8f76e0857602b89a5ed1d7c41c080c Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 26 May 2012 15:25:57 +1000 Subject: Add DeleteRange method. --- doc/ScintillaDoc.html | 4 ++++ include/Scintilla.h | 1 + include/Scintilla.iface | 3 +++ src/Editor.cxx | 4 ++++ test/simpleTests.py | 7 +++++++ 5 files changed, 19 insertions(+) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index c610b9c70..1651c0862 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -387,6 +387,7 @@ SCI_APPENDTEXT(int length, const char *s)
SCI_INSERTTEXT(int pos, const char *text)
SCI_CLEARALL
+ SCI_DELETERANGE(int pos, int deleteLength)
SCI_CLEARDOCUMENTSTYLE
SCI_GETCHARAT(int position)
SCI_GETSTYLEAT(int position)
@@ -519,6 +520,9 @@

SCI_CLEARALL
Unless the document is read-only, this deletes all the text.

+

SCI_DELETERANGE(int pos, int deleteLength)
+ Deletes a range of text in the document.

+

SCI_CLEARDOCUMENTSTYLE
When wanting to completely restyle the document, for example after choosing a lexer, the SCI_CLEARDOCUMENTSTYLE can be used to clear all styling information and reset the diff --git a/include/Scintilla.h b/include/Scintilla.h index e5d545349..8251726dc 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -51,6 +51,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_ADDSTYLEDTEXT 2002 #define SCI_INSERTTEXT 2003 #define SCI_CLEARALL 2004 +#define SCI_DELETERANGE 2645 #define SCI_CLEARDOCUMENTSTYLE 2005 #define SCI_GETLENGTH 2006 #define SCI_GETCHARAT 2007 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index e133be69d..7abbb68c1 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -101,6 +101,9 @@ fun void InsertText=2003(position pos, string text) # Delete all text in the document. fun void ClearAll=2004(,) +# Delete a range of text in the document. +fun void DeleteRange=2645(position pos, int deleteLength) + # Set all style bytes to 0, remove all folding information. fun void ClearDocumentStyle=2005(,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 8aea4db1d..d72ff302c 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7480,6 +7480,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { ClearAll(); return 0; + case SCI_DELETERANGE: + pdoc->DeleteChars(wParam, lParam); + return 0; + case SCI_CLEARDOCUMENTSTYLE: ClearDocumentStyle(); return 0; diff --git a/test/simpleTests.py b/test/simpleTests.py index 5ad5cf987..8e101b84e 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -26,6 +26,13 @@ class TestSimple(unittest.TestCase): self.ed.ClearAll() self.assertEquals(self.ed.Length, 0) + def testDeleteRange(self): + self.ed.AddText(5, b"abcde") + self.assertEquals(self.ed.Length, 5) + self.ed.DeleteRange(1, 2) + self.assertEquals(self.ed.Length, 3) + self.assertEquals(self.ed.Contents(), b"ade") + def testAddStyledText(self): self.assertEquals(self.ed.EndStyled, 0) self.ed.AddStyledText(2, b"x\002") -- cgit v1.2.3