aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2008-04-27 07:49:54 +0000
committernyamatongwe <devnull@localhost>2008-04-27 07:49:54 +0000
commit05afdfab73062917988db56f56c09695bef7b0cf (patch)
treef417bd12ca0629aea1894848303450fd0d539757
parent3be48e12ea69c4443d7296ad6e00bb77bf9d6f04 (diff)
downloadscintilla-mirror-05afdfab73062917988db56f56c09695bef7b0cf.tar.gz
Implemented GetCharacterPointer feature.
-rw-r--r--doc/ScintillaDoc.html20
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface4
-rw-r--r--src/CellBuffer.cxx4
-rw-r--r--src/CellBuffer.h1
-rw-r--r--src/Document.h1
-rw-r--r--src/Editor.cxx3
-rw-r--r--src/SplitVector.h6
8 files changed, 40 insertions, 0 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index f3aeec90b..8610dbe91 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -3978,6 +3978,7 @@ struct RangeToFormat {
<h2 id="DirectAccess">Direct access</h2>
<code><a class="message" href="#SCI_GETDIRECTFUNCTION">SCI_GETDIRECTFUNCTION</a><br />
<a class="message" href="#SCI_GETDIRECTPOINTER">SCI_GETDIRECTPOINTER</a><br />
+ <a class="message" href="#SCI_GETCHARACTERPOINTER">SCI_GETCHARACTERPOINTER</a><br />
</code>
<p>On Windows, the message-passing scheme used to communicate between the container and
@@ -4022,6 +4023,25 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
this once for each Scintilla window you create. When you call the direct function, you must
pass in the direct pointer associated with the target window.</p>
+ <p><b id="SCI_GETCHARACTERPOINTER">SCI_GETCHARACTERPOINTER</b><br />
+ This moves the gap within Scintilla so that the text of the document is stored consecutively
+ and ensures 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 <em>not</em> be written to as that may desynchoronize
+ the internal state of Scintilla. </p>
+ <p>Since any action in Scintilla may change its internal state
+ this pointer becomes invalid after any call or by allowing user interface activity. The application
+ should reacquire the pointer after making any call or performing any user-interface calls such
+ as modifying a progress indicator.</p>
+ <p>This call takes similar time to inserting a character at the end of the document and this may
+ include moving the document contents. Specifically, all the characters after the document gap
+ are moved to before the gap. This compacted state should persist over calls and user interface
+ actions that do not change the document contents so reacquiring the pointer afterwards is very
+ quick. If this call is used to implement a global replace operation, then each replacement will
+ move the gap so if <code>SCI_GETCHARACTERPOINTER</code> is called after
+ each replacement then the operation will become O(n^2) rather than O(n). Instead, all
+ matches should be found and remembered, then all the replacements performed.</p>
+
<h2 id="MultipleViews">Multiple views</h2>
<p>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 ac32f40d8..90e7669ed 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -668,6 +668,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_SETPOSITIONCACHE 2514
#define SCI_GETPOSITIONCACHE 2515
#define SCI_COPYALLOWLINE 2519
+#define SCI_GETCHARACTERPOINTER 2520
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 946da891e..8641c6d91 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1800,6 +1800,10 @@ get int GetPositionCache=2515(,)
# Copy the selection, if selection empty copy the line with the caret
fun void CopyAllowLine=2519(,)
+# Compact the document buffer and return a read-only pointer to the
+# characters in the document.
+get int GetCharacterPointer=2520(,)
+
# Start notifying the container of all key presses and commands.
fun void StartRecord=3001(,)
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index 85bf43552..0e9ae6950 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -587,6 +587,10 @@ char CellBuffer::StyleAt(int position) {
return style.ValueAt(position);
}
+const char *CellBuffer::BufferPointer() {
+ return substance.BufferPointer();
+}
+
// 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 4f654a8fd..4b83f48e0 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -171,6 +171,7 @@ public:
char CharAt(int position) const;
void GetCharRange(char *buffer, int position, int lengthRetrieve);
char StyleAt(int position);
+ const char *BufferPointer();
int Length() const;
void Allocate(int newSize);
diff --git a/src/Document.h b/src/Document.h
index a36c4aafe..04bbd5c74 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -159,6 +159,7 @@ public:
void EndUndoAction() { cb.EndUndoAction(); }
void SetSavePoint();
bool IsSavePoint() { return cb.IsSavePoint(); }
+ const char *BufferPointer() { return cb.BufferPointer(); }
int GetLineIndentation(int line);
void SetLineIndentation(int line, int indent);
diff --git a/src/Editor.cxx b/src/Editor.cxx
index af60624ff..3b6e7a2c3 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -7579,6 +7579,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETPASTECONVERTENDINGS:
return convertPastes ? 1 : 0;
+ case SCI_GETCHARACTERPOINTER:
+ return reinterpret_cast<sptr_t>(pdoc->BufferPointer());
+
default:
return DefWndProc(iMessage, wParam, lParam);
}
diff --git a/src/SplitVector.h b/src/SplitVector.h
index 9d62aef72..76f9a8f36 100644
--- a/src/SplitVector.h
+++ b/src/SplitVector.h
@@ -238,6 +238,12 @@ public:
DeleteRange(0, lengthBody);
}
+ T* BufferPointer() {
+ RoomFor(1);
+ GapTo(lengthBody);
+ body[lengthBody] = 0;
+ return body;
+ }
};
#endif