From ee3a66f0ebaea12c3fd4000a1acffdcc2b93176f Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 23 Feb 2015 08:20:32 +1100 Subject: Add SCI_GETTARGETTEXT as a simpler alternate to SCI_GETTEXTRANGE. --- doc/ScintillaDoc.html | 7 ++++++- include/Scintilla.h | 1 + include/Scintilla.iface | 3 +++ src/Editor.cxx | 7 ++++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 1697af2ee..0a913506b 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -82,7 +82,7 @@

Scintilla Documentation

-

Last edited 13 February 2015 NH

+

Last edited 22 February 2015 NH

There is an overview of the internal design of Scintilla.
@@ -643,6 +643,8 @@ struct Sci_TextRange { SCI_GETSEARCHFLAGS
SCI_SEARCHINTARGET(int length, const char *text)
+ SCI_GETTARGETTEXT(<unused>, + char *text)
SCI_REPLACETARGET(int length, const char *text)
SCI_REPLACETARGETRE(int length, const char @@ -677,6 +679,9 @@ struct Sci_TextRange { text and the return value is the position of the start of the matching text. If the search fails, the result is -1.

+

SCI_GETTARGETTEXT(<unused>, char *text)
+ Retrieve the value in the target.

+

SCI_REPLACETARGET(int length, const char *text)
If length is -1, text is a zero terminated string, otherwise length sets the number of character to replace the target with. diff --git a/include/Scintilla.h b/include/Scintilla.h index 018a6d8bd..e2e3297a5 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -433,6 +433,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETTARGETEND 2192 #define SCI_GETTARGETEND 2193 #define SCI_SETTARGETRANGE 2686 +#define SCI_GETTARGETTEXT 2687 #define SCI_REPLACETARGET 2194 #define SCI_REPLACETARGETRE 2195 #define SCI_SEARCHINTARGET 2197 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 7373384c8..f5fac5480 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1062,6 +1062,9 @@ get position GetTargetEnd=2193(,) # Sets both the start and end of the target in one call. fun void SetTargetRange=2686(position start, position end) +# Retrieve the text in the target. +get int GetTargetText=2687(, stringresult characters) + # Replace the target text with the argument text. # Text is counted so it can contain NULs. # Returns the length of the replacement text. diff --git a/src/Editor.cxx b/src/Editor.cxx index 5935037d6..6c80b7511 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -5343,7 +5343,7 @@ sptr_t Editor::StringResult(sptr_t lParam, const char *val) { sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len) { // No NUL termination: len is number of valid/displayed bytes - if (lParam) { + if ((lParam) && (len > 0)) { char *ptr = CharPtrFromSPtr(lParam); if (val) memcpy(ptr, val, len); @@ -5576,6 +5576,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } break; + case SCI_GETTARGETTEXT: { + std::string text = RangeText(targetStart, targetEnd); + return BytesResult(lParam, reinterpret_cast(text.c_str()), text.length()); + } + case SCI_REPLACETARGET: PLATFORM_ASSERT(lParam); return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast(wParam)); -- cgit v1.2.3