diff --git a/vstgui/lib/ctexteditor.cpp b/vstgui/lib/ctexteditor.cpp index fab47998e..17e9082e3 100644 --- a/vstgui/lib/ctexteditor.cpp +++ b/vstgui/lib/ctexteditor.cpp @@ -259,6 +259,7 @@ struct TextEditorView : public CView, // TextEditorHighlighting::IEditorExt std::u16string_view readText (size_t startOffset, size_t length) const override; + size_t getTextLength () const override; // commandos bool doShifting (bool right) const; @@ -867,6 +868,9 @@ std::u16string_view TextEditorView::readText (size_t startOffset, size_t length) return {md.model.text.data () + startOffset, length}; } +//------------------------------------------------------------------------ +size_t TextEditorView::getTextLength () const { return md.model.text.length (); } + //------------------------------------------------------------------------ inline Range toLineSelection (const Range& line, size_t selStart, size_t selEnd) { diff --git a/vstgui/lib/ctexteditor.h b/vstgui/lib/ctexteditor.h index 2dfa8303a..09f7413a4 100644 --- a/vstgui/lib/ctexteditor.h +++ b/vstgui/lib/ctexteditor.h @@ -115,7 +115,18 @@ namespace TextEditorColorization { /** extension to ITextEditor, use a dynamic_cast to get it from an ITextEditor */ struct IEditorExt { + /** get access to the internal string buffer of the text editor + * + * @param startOffset offset into the buffer in number of characters + * @param length number of characters + * @return a string view into the buffer + */ virtual std::u16string_view readText (size_t startOffset, size_t length) const = 0; + /** get the length of the text + * + * @return number of characters + */ + virtual size_t getTextLength () const = 0; }; //------------------------------------------------------------------------ @@ -132,8 +143,26 @@ struct IStyleProvider }; using Styles = std::vector