diff options
| -rw-r--r-- | doc/ScintillaDoc.html | 9 | ||||
| -rw-r--r-- | include/Scintilla.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 3 | ||||
| -rw-r--r-- | src/Editor.cxx | 21 | ||||
| -rw-r--r-- | src/Editor.h | 1 | ||||
| -rw-r--r-- | test/simpleTests.py | 14 | 
6 files changed, 42 insertions, 7 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index b23fea4c7..848a4beb0 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -772,6 +772,7 @@ struct Sci_TextToFind {      *text)</a><br />       <a class="message" href="#SCI_REPLACETARGETRE">SCI_REPLACETARGETRE(int length, const char      *text)</a><br /> +     <a class="message" href="#SCI_GETTAG">SCI_GETTAG(int tagNumber, char *tagValue)</a><br />      </code>      <p><b id="SCI_SETTARGETSTART">SCI_SETTARGETSTART(int pos)</b><br /> @@ -818,6 +819,10 @@ struct Sci_TextToFind {             After replacement, the target range refers to the replacement text.             The return value is the length of the replacement string.</p> +    <p><b id="SCI_GETTAG">SCI_GETTAG(int tagNumber, char *tagValue)</b><br /> +     Discover what text was matched by tagged expressions in a regular expression search. +     This is useful if the application wants to interpret the replacement string itself.</p> +      <p>See also: <a class="message" href="#SCI_FINDTEXT"><code>SCI_FINDTEXT</code></a></p>      <h2 id="Overtype">Overtype</h2> @@ -2770,7 +2775,7 @@ struct Sci_TextToFind {       The whole of the text margin on a line may be displayed in a particular style with       <code>SCI_MARGINSETSTYLE</code> or each character may be individually styled with       <code>SCI_MARGINSETSTYLES</code> which uses an array of bytes with each byte setting the style -     of the corresponding text byte simlar to <code>SCI_SETSTYLINGEX</code>. +     of the corresponding text byte similar to <code>SCI_SETSTYLINGEX</code>.       Setting a text margin will cause a       <a class="message" href="#SC_MOD_CHANGEMARGIN"><code>SC_MOD_CHANGEMARGIN</code></a>       notification to be sent. @@ -2822,7 +2827,7 @@ struct Sci_TextToFind {       The whole of the text ANNOTATION on a line may be displayed in a particular style with       <code>SCI_ANNOTATIONSETSTYLE</code> or each character may be individually styled with       <code>SCI_ANNOTATIONSETSTYLES</code> which uses an array of bytes with each byte setting the style -     of the corresponding text byte simlar to <code>SCI_SETSTYLINGEX</code>. The text must be set first as it +     of the corresponding text byte similar to <code>SCI_SETSTYLINGEX</code>. The text must be set first as it       specifies how long the annotation is so how many bytes of styling to read.       Setting an annotation will cause a       <a class="message" href="#SC_MOD_CHANGEANNOTATION"><code>SC_MOD_CHANGEANNOTATION</code></a> diff --git a/include/Scintilla.h b/include/Scintilla.h index 2a79f6649..a4f99c2c7 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -490,6 +490,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SC_MULTIPASTE_EACH 1  #define SCI_SETMULTIPASTE 2614  #define SCI_GETMULTIPASTE 2615 +#define SCI_GETTAG 2616  #define SCI_TARGETFROMSELECTION 2287  #define SCI_LINESJOIN 2288  #define SCI_LINESSPLIT 2289 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 67fcc6060..158d0b515 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1233,6 +1233,9 @@ set void SetMultiPaste=2614(int multiPaste,)  # Retrieve the effect of pasting when there are multiple selections..  get int GetMultiPaste=2615(,) +# Retrieve the value of a tag from a regular expression search. +fun int GetTag=2616(int tagNumber, stringresult tagValue) +  # Make the target range start and end be the same as the selection range start and end.  fun void TargetFromSelection=2287(,) diff --git a/src/Editor.cxx b/src/Editor.cxx index e5623b542..61d10bd6a 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6377,6 +6377,24 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {  	}  } +int Editor::GetTag(char *tagValue, int tagNumber) { +	char name[3] = "\\?"; +	const char *text = 0; +	int length = 0; +	if ((tagNumber >= 1) && (tagNumber <= 9)) { +		name[1] = tagNumber + '0'; +		length = 2; +		text = pdoc->SubstituteByPosition(name, &length); +	} +	if (tagValue) { +		if (text) +			memcpy(tagValue, text, length + 1); +		else +			*tagValue = '\0'; +	} +	return length; +} +  int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {  	UndoGroup ug(pdoc);  	if (length == -1) @@ -6761,6 +6779,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  	case SCI_GETSEARCHFLAGS:  		return searchFlags; +	case SCI_GETTAG: +		return GetTag(CharPtrFromSPtr(lParam), wParam); +  	case SCI_POSITIONBEFORE:  		return pdoc->MovePositionOutsideChar(wParam - 1, -1, true); diff --git a/src/Editor.h b/src/Editor.h index 180db571a..4ffba827c 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -473,6 +473,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	void Expand(int &line, bool doExpand);  	void ToggleContraction(int line);  	void EnsureLineVisible(int lineDoc, bool enforcePolicy); +	int GetTag(char *tagValue, int tagNumber);  	int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);  	bool PositionIsHotspot(int position); diff --git a/test/simpleTests.py b/test/simpleTests.py index 8fac00cd4..db414afea 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -329,6 +329,10 @@ class TestSimple(unittest.TestCase):  		searchString = b"\([1-9]+\)"  		pos = self.ed.SearchInTarget(len(searchString), searchString)  		self.assertEquals(1, pos) +		tagString = b"abcdefghijklmnop" +		lenTag = self.ed.GetTag(1, tagString) +		tagString = tagString[:lenTag] +		self.assertEquals(tagString, b"321")  		rep = b"\\1"  		self.ed.TargetStart = 0  		self.ed.TargetEnd = 0 @@ -409,7 +413,7 @@ class TestContainerUndo(unittest.TestCase):  		self.assertEquals(self.ed.Length, 2)  		self.assertEquals(self.UndoState(), MODI | UNDO)  		self.ed.Undo() -	 +  	def testContainerActCoalesce(self):  		self.ed.InsertText(0, self.data)  		self.ed.AddUndoAction(5, 1) @@ -685,7 +689,7 @@ class TestMarkers(unittest.TestCase):  		self.assertEquals(self.ed.GetLineState(0), 0)  		self.assertEquals(self.ed.GetLineState(1), 100)  		self.assertEquals(self.ed.GetLineState(2), 0) -		 +  	def testSymbolRetrieval(self):  		self.ed.MarkerDefine(1,3)  		self.assertEquals(self.ed.MarkerSymbolDefined(1), 3) @@ -844,7 +848,7 @@ class TestTextMargin(unittest.TestCase):  		self.xite.DoEvents()  		lineHeightIncreased = self.ed.TextHeight(0)  		self.assertEquals(lineHeightIncreased, lineHeight + 2 + 1) -		 +  	def testTextMargin(self):  		self.ed.MarginSetText(0, self.txt)  		result = b"\0" * 10 @@ -1128,7 +1132,7 @@ class TestCaseInsensitiveSearch(unittest.TestCase):  		self.ed.TargetEnd = self.ed.Length-1  		self.ed.SearchFlags = 0  		pos = self.ed.SearchInTarget(len(searchString), searchString) -		self.assertEquals(-1, pos) +		self.assertEquals(0, pos)  	def testASCII(self):  		text = b" x X" @@ -1193,7 +1197,7 @@ class TestLexer(unittest.TestCase):  		self.ed = self.xite.ed  		self.ed.ClearAll()  		self.ed.EmptyUndoBuffer() -		 +  	def testLexerNumber(self):  		self.ed.Lexer = self.ed.SCLEX_CPP  		self.assertEquals(self.ed.GetLexer(), self.ed.SCLEX_CPP)  | 
