From e9280bf01239e81b01899992647766d0c073253b Mon Sep 17 00:00:00 2001
From: Neil
+
@@ -623,15 +624,19 @@
SCI_GETSTYLEDTEXT,
SCI_GETTEXT
SCI_GETSTYLEDTEXT(<unused>, Sci_TextRange *tr) → position
+
+ SCI_GETSTYLEDTEXT(<unused>, Sci_TextRange *tr) → position
+ SCI_GETSTYLEDTEXTFULL(<unused>, Sci_TextRangeFull *tr) → position
This collects styled text into a buffer using two bytes for each cell, with the character at
the lower address of each pair and the style byte at the upper address. Characters between the
positions cpMin and cpMax are copied to lpstrText (see
- struct Sci_TextRange in Scintilla.h). Two 0 bytes are added to the end of
+ struct Sci_TextRange and struct Sci_TextRangeFull in Scintilla.h). Two 0 bytes are added to the end of
the text, so the buffer that lpstrText points at must be at least
2*(cpMax-cpMin)+2 bytes long. No check is made for sensible values of
cpMin or cpMax. Positions outside the document return character codes
and style bytes of 0.
SCI_GETSTYLEDTEXTFULL uses 64-bit positions on all platforms so is safe for documents larger than 2GB.
+ It should always be used in preference to SCI_GETSTYLEDTEXT which will be deprecated in a future release.
See also: SCI_GETSELTEXT,
SCI_GETLINE,
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 5a44b84c5..b145692b5 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -587,6 +587,11 @@
Release 5.3.1
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 03302e293..30760431f 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -63,6 +63,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_SELECTALL 2013
#define SCI_SETSAVEPOINT 2014
#define SCI_GETSTYLEDTEXT 2015
+#define SCI_GETSTYLEDTEXTFULL 2778
#define SCI_CANREDO 2016
#define SCI_MARKERLINEFROMHANDLE 2017
#define SCI_MARKERDELETEHANDLE 2018
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index b03b8c8ca..a527bb9a4 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -154,6 +154,10 @@ fun void SetSavePoint=2014(,)
# Returns the number of bytes in the buffer not including terminating NULs.
fun position GetStyledText=2015(, textrange tr)
+# Retrieve a buffer of cells that can be past 2GB.
+# Returns the number of bytes in the buffer not including terminating NULs.
+fun position GetStyledTextFull=2778(, textrangefull tr)
+
# Are there any redoable actions in the undo history?
fun bool CanRedo=2016(,)
diff --git a/include/ScintillaCall.h b/include/ScintillaCall.h
index 4b8e3c732..9f3b7e40a 100644
--- a/include/ScintillaCall.h
+++ b/include/ScintillaCall.h
@@ -95,6 +95,7 @@ public:
void SelectAll();
void SetSavePoint();
Position GetStyledText(void *tr);
+ Position GetStyledTextFull(void *tr);
bool CanRedo();
Line MarkerLineFromHandle(int markerHandle);
void MarkerDeleteHandle(int markerHandle);
diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h
index 118655689..9d3034f79 100644
--- a/include/ScintillaMessages.h
+++ b/include/ScintillaMessages.h
@@ -34,6 +34,7 @@ enum class Message {
SelectAll = 2013,
SetSavePoint = 2014,
GetStyledText = 2015,
+ GetStyledTextFull = 2778,
CanRedo = 2016,
MarkerLineFromHandle = 2017,
MarkerDeleteHandle = 2018,
diff --git a/scripts/HFacer.py b/scripts/HFacer.py
index cc8467b2c..0d3062f51 100755
--- a/scripts/HFacer.py
+++ b/scripts/HFacer.py
@@ -31,6 +31,8 @@ def printHFile(f):
out.append("#endif")
return out
+showUnused = False
+
def RegenerateAll(root, showMaxID):
f = Face.Face()
f.ReadFromFile(root / "include/Scintilla.iface")
@@ -39,18 +41,19 @@ def RegenerateAll(root, showMaxID):
valueSet = set(int(x) for x in f.values if int(x) < 3000)
maximumID = max(valueSet)
print("Maximum ID is %d" % maximumID)
- #~ valuesUnused = sorted(x for x in range(2001,maximumID) if x not in valueSet)
- #~ print("\nUnused values")
- #~ valueToName = {}
- #~ for name, feature in f.features.items():
- #~ try:
- #~ value = int(feature["Value"])
- #~ valueToName[value] = name
- #~ except ValueError:
- #~ pass
- #~ for v in valuesUnused:
- #~ prev = valueToName.get(v-1, "")
- #~ print(v, prev)
+ if showUnused:
+ valuesUnused = sorted(x for x in range(2001,maximumID) if x not in valueSet)
+ print("\nUnused values")
+ valueToName = {}
+ for name, feature in f.features.items():
+ try:
+ value = int(feature["Value"])
+ valueToName[value] = name
+ except ValueError:
+ pass
+ for v in valuesUnused:
+ prev = valueToName.get(v-1, "")
+ print(v, prev)
if __name__ == "__main__":
RegenerateAll(pathlib.Path(__file__).resolve().parent.parent, True)
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 35148299e..da52d462c 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5783,6 +5783,17 @@ void Editor::AddStyledText(const char *buffer, Sci::Position appendLength) {
SetEmptySelection(sel.MainCaret() + lengthInserted);
}
+Sci::Position Editor::GetStyledText(char *buffer, Sci::Position cpMin, Sci::Position cpMax) const noexcept {
+ Sci::Position iPlace = 0;
+ for (Sci::Position iChar = cpMin; iChar < cpMax; iChar++) {
+ buffer[iPlace++] = pdoc->CharAt(iChar);
+ buffer[iPlace++] = pdoc->StyleAt(iChar);
+ }
+ buffer[iPlace] = '\0';
+ buffer[iPlace + 1] = '\0';
+ return iPlace;
+}
+
bool Editor::ValidMargin(uptr_t wParam) const noexcept {
return wParam < vs.ms.size();
}
@@ -6588,19 +6599,17 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
pdoc->SetSavePoint();
break;
- case Message::GetStyledText: {
- if (lParam == 0)
- return 0;
- TextRange *tr = static_cast