aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-10-19 13:36:08 +1100
committerNeil <nyamatongwe@gmail.com>2022-10-19 13:36:08 +1100
commite9280bf01239e81b01899992647766d0c073253b (patch)
tree924d5f1a128552bf8c0b92f8c579544f34edc0ed /src/Editor.cxx
parent19a781319ccc6c9de302182e141383ba73403030 (diff)
downloadscintilla-mirror-e9280bf01239e81b01899992647766d0c073253b.tar.gz
Feature [feature-requests:#1455] Implement GetStyledTextFull as a 64-bit safe
version of GetStyledText.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx33
1 files changed, 21 insertions, 12 deletions
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<TextRange *>(PtrFromSPtr(lParam));
- Sci::Position iPlace = 0;
- for (Sci::Position iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) {
- tr->lpstrText[iPlace++] = pdoc->CharAt(iChar);
- tr->lpstrText[iPlace++] = pdoc->StyleAt(iChar);
- }
- tr->lpstrText[iPlace] = '\0';
- tr->lpstrText[iPlace + 1] = '\0';
- return iPlace;
+ case Message::GetStyledText:
+ if (TextRange *tr = static_cast<TextRange *>(PtrFromSPtr(lParam))) {
+ return GetStyledText(tr->lpstrText, tr->chrg.cpMin, tr->chrg.cpMax);
}
+ return 0;
+
+ case Message::GetStyledTextFull:
+ if (TextRangeFull *tr = static_cast<TextRangeFull *>(PtrFromSPtr(lParam))) {
+ return GetStyledText(tr->lpstrText, tr->chrg.cpMin, tr->chrg.cpMax);
+ }
+ return 0;
case Message::CanRedo:
return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0;