From 00c771cecda620db28cec9e4c50830f542e3a829 Mon Sep 17 00:00:00 2001
From: nyamatongwe On Windows, the message-passing scheme used to communicate between the container and
@@ -4815,8 +4817,13 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
pass in the direct pointer associated with the target window. SCI_GETCHARACTERPOINTER
+
+
- Move the gap within Scintilla so that the text of the document is stored consecutively
- and ensure there is a NUL character after the text, then return a pointer to the first character.
+ SCI_GETRANGEPOINTER(int position, int rangeLength)
+ SCI_GETGAPPOSITION
+ Grant temporary direct read-only access to the memory used by Scintilla to store
+ the document.SCI_GETCHARACTERPOINTER moves the gap within Scintilla so that the
+ text of the document is stored consecutively
+ and ensure there is a NUL character after the text, then returns a pointer to the first character.
Applications may then pass this to a function that accepts a character pointer such as a regular
expression search or a parser. The pointer should not be written to as that may desynchronize
the internal state of Scintilla.
SCI_GETRANGEPOINTER provides direct access to just the
+ range requested. The gap is not moved unless it is within the requested range so this call
+ can be faster than SCI_GETCHARACTERPOINTER.
+ This can be used by application code that is able to act on blocks of text or ranges of lines.
SCI_GETGAPPOSITION returns the current gap position.
+ This is a hint that applications can use to avoid calling SCI_GETRANGEPOINTER
+ with a range that contains the gap and consequent costs of moving the gap.
A Scintilla window and the document that it displays are separate entities. When you create
diff --git a/include/Scintilla.h b/include/Scintilla.h
index d4da54a9d..e5d545349 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -728,6 +728,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETPOSITIONCACHE 2515
#define SCI_COPYALLOWLINE 2519
#define SCI_GETCHARACTERPOINTER 2520
+#define SCI_GETRANGEPOINTER 2643
+#define SCI_GETGAPPOSITION 2644
#define SCI_SETKEYSUNICODE 2521
#define SCI_GETKEYSUNICODE 2522
#define SCI_INDICSETALPHA 2523
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index ac496dba3..e133be69d 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1924,6 +1924,15 @@ fun void CopyAllowLine=2519(,)
# characters in the document.
get int GetCharacterPointer=2520(,)
+# Return a read-only pointer to a range of characters in the document.
+# May move the gap so that the range is contiguous, but will only move up
+# to rangeLength bytes.
+get int GetRangePointer=2643(int position, int rangeLength)
+
+# Return a position which, to avoid performance costs, should not be within
+# the range of a call to GetRangePointer.
+get position GetGapPosition=2644(,)
+
# Always interpret keyboard input as Unicode
set void SetKeysUnicode=2521(bool keysUnicode,)
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index 19f6670f6..11b8b4acd 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -375,6 +375,14 @@ const char *CellBuffer::BufferPointer() {
return substance.BufferPointer();
}
+const char *CellBuffer::RangePointer(int position, int rangeLength) {
+ return substance.RangePointer(position, rangeLength);
+}
+
+int CellBuffer::GapPosition() const {
+ return substance.GapPosition();
+}
+
// The char* returned is to an allocation owned by the undo history
const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) {
char *data = 0;
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index a82a3973b..388b9027b 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -157,6 +157,8 @@ public:
char StyleAt(int position) const;
void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const;
const char *BufferPointer();
+ const char *RangePointer(int position, int rangeLength);
+ int GapPosition() const;
int Length() const;
void Allocate(int newSize);
diff --git a/src/Document.h b/src/Document.h
index 18bf00a3d..7e03f3d9e 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -298,6 +298,8 @@ public:
void SetSavePoint();
bool IsSavePoint() { return cb.IsSavePoint(); }
const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); }
+ const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); }
+ int GapPosition() const { return cb.GapPosition(); }
int SCI_METHOD GetLineIndentation(int line);
void SetLineIndentation(int line, int indent);
diff --git a/src/Editor.cxx b/src/Editor.cxx
index c3a4eafb4..8aea4db1d 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -8910,6 +8910,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETCHARACTERPOINTER:
return reinterpret_cast