aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx85
1 files changed, 74 insertions, 11 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 6ec2dea3e..f99914ebd 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1834,18 +1834,30 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
// This is mostly copied from the Paint method but with some things omitted
// such as the margin markers, line numbers, selection and caret
// Should be merged back into a combined Draw method.
-Sci::Position Editor::FormatRange(bool draw, const RangeToFormat *pfr) {
- if (!pfr)
- return 0;
-
- AutoSurface surface(pfr->hdc, this, Technology::Default);
- if (!surface)
- return 0;
- AutoSurface surfaceMeasure(pfr->hdcTarget, this, Technology::Default);
- if (!surfaceMeasure) {
+Sci::Position Editor::FormatRange(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) {
+ if (!lParam)
return 0;
+ const bool draw = wParam != 0;
+ void *ptr = PtrFromSPtr(lParam);
+ if (iMessage == Message::FormatRange) {
+ RangeToFormat *pfr = static_cast<RangeToFormat *>(ptr);
+ CharacterRangeFull chrg{ pfr->chrg.cpMin,pfr->chrg.cpMax };
+ AutoSurface surface(pfr->hdc, this, Technology::Default);
+ AutoSurface surfaceMeasure(pfr->hdcTarget, this, Technology::Default);
+ if (!surface || !surfaceMeasure) {
+ return 0;
+ }
+ return view.FormatRange(draw, chrg, pfr->rc, surface, surfaceMeasure, *this, vs);
+ } else {
+ // FormatRangeFull
+ RangeToFormatFull *pfr = static_cast<RangeToFormatFull *>(ptr);
+ AutoSurface surface(pfr->hdc, this, Technology::Default);
+ AutoSurface surfaceMeasure(pfr->hdcTarget, this, Technology::Default);
+ if (!surface || !surfaceMeasure) {
+ return 0;
+ }
+ return view.FormatRange(draw, pfr->chrg, pfr->rc, surface, surfaceMeasure, *this, vs);
}
- return view.FormatRange(draw, pfr, surface, surfaceMeasure, *this, vs);
}
long Editor::TextWidth(uptr_t style, const char *text) {
@@ -4121,6 +4133,37 @@ Sci::Position Editor::FindText(
}
/**
+ * Search of a text in the document, in the given range.
+ * @return The position of the found text, -1 if not found.
+ */
+Sci::Position Editor::FindTextFull(
+ uptr_t wParam, ///< Search modes : @c FindOption::MatchCase, @c FindOption::WholeWord,
+ ///< @c FindOption::WordStart, @c FindOption::RegExp or @c FindOption::Posix.
+ sptr_t lParam) { ///< @c Sci_TextToFindFull structure: The text to search for in the given range.
+
+ TextToFindFull *ft = static_cast<TextToFindFull *>(PtrFromSPtr(lParam));
+ Sci::Position lengthFound = strlen(ft->lpstrText);
+ if (!pdoc->HasCaseFolder())
+ pdoc->SetCaseFolder(CaseFolderForEncoding());
+ try {
+ const Sci::Position pos = pdoc->FindText(
+ static_cast<Sci::Position>(ft->chrg.cpMin),
+ static_cast<Sci::Position>(ft->chrg.cpMax),
+ ft->lpstrText,
+ static_cast<FindOption>(wParam),
+ &lengthFound);
+ if (pos != -1) {
+ ft->chrgText.cpMin = static_cast<Sci_PositionCR>(pos);
+ ft->chrgText.cpMax = static_cast<Sci_PositionCR>(pos + lengthFound);
+ }
+ return pos;
+ } catch (RegexError &) {
+ errorStatus = Status::RegEx;
+ return -1;
+ }
+}
+
+/**
* Relocatable search support : Searches relative to current selection
* point and sets the selection to the found text range with
* each search.
@@ -6244,6 +6287,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::FindText:
return FindText(wParam, lParam);
+ case Message::FindTextFull:
+ return FindTextFull(wParam, lParam);
+
case Message::GetTextRange: {
if (lParam == 0)
return 0;
@@ -6259,13 +6305,30 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
return len; // Not including NUL
}
+ case Message::GetTextRangeFull: {
+ if (lParam == 0)
+ return 0;
+ TextRangeFull *tr = static_cast<TextRangeFull *>(PtrFromSPtr(lParam));
+ Sci::Position cpMax = tr->chrg.cpMax;
+ if (cpMax == -1)
+ cpMax = pdoc->Length();
+ PLATFORM_ASSERT(cpMax <= pdoc->Length());
+ const Sci::Position len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions
+ PLATFORM_ASSERT(len >= 0);
+ pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len);
+ // Spec says copied text is terminated with a NUL
+ tr->lpstrText[len] = '\0';
+ return len; // Not including NUL
+ }
+
case Message::HideSelection:
view.hideSelection = wParam != 0;
Redraw();
break;
case Message::FormatRange:
- return FormatRange(wParam != 0, static_cast<RangeToFormat *>(PtrFromSPtr(lParam)));
+ case Message::FormatRangeFull:
+ return FormatRange(iMessage, wParam, lParam);
case Message::GetMarginLeft:
return vs.leftMarginWidth;