50LineLayout::LineLayout(
int maxLineLength_) :
59 highlightColumn(false),
62 bracePreviousStyles{},
64 widthLine(wrapWidthInfinite),
77 chars = Sci::make_unique<char[]>(maxLineLength_ + 1);
78 styles = Sci::make_unique<unsigned char []>(maxLineLength_ + 1);
81 positions = Sci::make_unique<XYPOSITION []>(maxLineLength_ + 1 + 1);
94 if (validity > validity_)
101 }
else if ((
line >=
lines) || !lineStarts) {
102 return numCharsInLine;
104 return lineStarts[
line];
111 }
else if ((
line >=
lines-1) || !lineStarts) {
112 return scope == Scope::visibleOnly ? numCharsBeforeEOL : numCharsInLine;
114 return lineStarts[
line+1];
124 ((offset == numCharsInLine) && (
line == (
lines-1)));
129 const int newMaxLines =
line + 20;
130 std::unique_ptr<int[]> newLineStarts = Sci::make_unique<int[]>(newMaxLines);
131 for (
int i = 0; i < newMaxLines; i++) {
135 newLineStarts[i] = 0;
144 char bracesMatchStyle,
int xHighlight,
bool ignoreStyle) {
149 styles[braceOffset] = bracesMatchStyle;
156 styles[braceOffset] = bracesMatchStyle;
159 if ((braces[0] >= rangeLine.
start && braces[1] <= rangeLine.
end) ||
160 (braces[1] >= rangeLine.
start && braces[0] <= rangeLine.
end)) {
186 const XYPOSITION posMiddle = positions[middle];
192 }
while (lower < upper);
193 return static_cast<int>(lower);
198 int pos = FindBefore(x, range);
199 while (
pos < range.end) {
201 if (x < (positions[
pos + 1])) {
205 if (x < ((positions[
pos] + positions[
pos + 1]) / 2)) {
211 return static_cast<int>(range.end);
217 if (posInLine > maxLineLength) {
221 for (
int subLine = 0; subLine <
lines; subLine++) {
222 const Range rangeSubLine = SubLineRange(subLine, Scope::visibleOnly);
223 if (posInLine >= rangeSubLine.
start) {
224 pt.
y =
static_cast<XYPOSITION>(subLine*lineHeight);
225 if (posInLine <= rangeSubLine.
end) {
226 pt.
x = positions[posInLine] - positions[rangeSubLine.
start];
227 if (rangeSubLine.
start != 0)
232 pt.
x = positions[numCharsInLine] - positions[rangeSubLine.
start];
233 if (rangeSubLine.
start != 0)
249 allInvalidated(false), styleClock(-1), useCount(0) {
260 cache.resize(length_);
265 size_t lengthForLevel = 0;
269 lengthForLevel = linesOnScreen + 1;
271 lengthForLevel = linesInDoc;
273 if (lengthForLevel >
cache.size()) {
277 if (lengthForLevel <
cache.size()) {
278 for (
size_t i = lengthForLevel; i <
cache.size(); i++) {
282 cache.resize(lengthForLevel);
293 if (!cache.empty() && !allInvalidated) {
294 for (
const std::unique_ptr<LineLayout> &ll : cache) {
296 ll->Invalidate(validity_);
300 allInvalidated =
true;
306 allInvalidated =
false;
307 if ((level_ != -1) && (level != level_)) {
328 }
else if (
cache.size() > 1) {
336 if (!
cache.empty() && (
pos <
static_cast<int>(
cache.size()))) {
339 (
cache[
pos]->maxLineLength < maxChars)) {
344 cache[
pos] = Sci::make_unique<LineLayout>(maxChars);
362 allInvalidated =
false;
373static unsigned int KeyFromString(
const char *charBytes,
size_t len)
noexcept {
376 for (
size_t i=0; i<len && charBytes[i]; i++) {
378 const unsigned char uc = charBytes[i];
385 const short none = 0;
391 MapRepresentation::iterator it =
mapReprs.find(key);
394 const unsigned char ucStart = charBytes[0];
404 const unsigned char ucStart = charBytes[0];
411 const unsigned char ucStart = charBytes[0];
416 return &(it->second);
423 const unsigned char ucStart = charBytes[0];
432 const short none = 0;
437 const int posInLine =
static_cast<int>(val);
439 const std::vector<int>::iterator it = std::lower_bound(
selAndEdge.begin(),
selAndEdge.end(), posInLine);
442 }
else if (*it != posInLine) {
451 lineRange(lineRange_),
452 posLineStart(posLineStart_),
453 nextBreak(static_cast<int>(lineRange_.start)),
458 encodingFamily(pdoc_->CodePageFamily()),
470 if (breakForSelection) {
474 for (
size_t r=0; r<psel->
Count(); r++) {
476 if (!(portion.
start == portion.
end)) {
486 if (pvsDraw->
indicators[deco->Indicator()].OverridesTextFore()) {
490 startPos = deco->EndRun(startPos);
565 styleNumber(0), len(0), clock(0), positions(
nullptr) {
570 styleNumber(other.styleNumber), len(other.styleNumber), clock(other.styleNumber), positions(nullptr) {
573 positions = Sci::make_unique<XYPOSITION[]>(lenData);
579 unsigned int len_,
const XYPOSITION *positions_,
unsigned int clock_) {
584 if (s_ && positions_) {
586 for (
unsigned int i=0; i<
len; i++) {
605 unsigned int len_,
XYPOSITION *positions_)
const noexcept {
606 if ((styleNumber == styleNumber_) && (len == len_) &&
607 (memcmp(&positions[len], s_, len)== 0)) {
608 for (
unsigned int i=0; i<len; i++) {
609 positions_[i] = positions[i];
618 unsigned int ret = s[0] << 7;
619 for (
unsigned int i=0; i<len_; i++) {
631 return clock > other.clock;
669 size_t probe =
pces.size();
670 if ((!
pces.empty()) && (len < 30)) {
677 if (
pces[probe].Retrieve(styleNumber, s, len, positions)) {
681 if (
pces[probe2].Retrieve(styleNumber, s, len, positions)) {
685 if (
pces[probe].NewerThan(
pces[probe2])) {
692 unsigned int startSegment = 0;
694 while (startSegment < len) {
696 surface->
MeasureWidths(fontStyle, s + startSegment, lenSegment, positions + startSegment);
697 for (
unsigned int inSeg = 0; inSeg < lenSegment; inSeg++) {
698 positions[startSegment + inSeg] += xStartSegment;
700 xStartSegment = positions[startSegment + lenSegment - 1];
701 startSegment += lenSegment;
706 if (probe <
pces.size()) {
717 pces[probe].Set(styleNumber, s, len, positions,
clock);
Classes for case folding.
Manages the text of the document.
Character classifications used by Document and RESearch.
Returns the Unicode general category of a character.
Manages visibility of lines for folding and wrapping.
Visual elements added over text.
Text document that handles notifications, DBCS, styling, words and end of line.
Interface between Scintilla and lexers.
Interface for loading into a Scintilla document from a background thread.
Defines the style of indicators which are text decorations such as underlining.
Defines a mapping between keystrokes and commands.
static Sci_Position LineStart(Sci_Position line, Accessor &styler)
Defines the look of a line marker in the margin .
Data structure used to partition an interval.
static unsigned int KeyFromString(const char *charBytes, size_t len) noexcept
Classes for caching layout information.
Defines global type name Position in the Sci internal namespace.
Data structure used to store sparse styles.
Interface to the edit control.
Classes maintaining the selection.
Main data structure for holding arrays that handle insertions and deletions efficiently.
Defines the font and colour style for a class of text.
Functions to handle UTF-8 and UTF-16 strings.
Define UniqueString, a unique_ptr based string type for storage in containers and an allocator for Un...
Store information on how the document is to be viewed.
void Insert(Sci::Position val)
BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw)
bool More() const noexcept
Sci::Position posLineStart
EncodingFamily encodingFamily
unsigned int saeCurrentPos
std::vector< int > selAndEdge
const SpecialRepresentations * preprs
std::unique_ptr< IDecorationList > decorations
int SafeSegment(const char *text, int length, int lengthSegment) const noexcept
int DBCSDrawBytes(const char *text, int len) const noexcept
virtual ~LineLayoutCache()
void Dispose(LineLayout *ll) noexcept
LineLayout * Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_, Sci::Line linesOnScreen, Sci::Line linesInDoc)
std::vector< std::unique_ptr< LineLayout > > cache
void AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc)
void Invalidate(LineLayout::ValidLevel validity_) noexcept
void Allocate(size_t length_)
void Deallocate() noexcept
void SetLevel(int level_) noexcept
int LineLastVisible(int line, Scope scope) const noexcept
int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const noexcept
std::unique_ptr< int[]> lineStarts
int FindBefore(XYPOSITION x, Range range) const noexcept
int LineStart(int line) const noexcept
void Resize(int maxLineLength_)
Range SubLineRange(int subLine, Scope scope) const noexcept
std::unique_ptr< char[]> chars
void SetBracesHighlight(Range rangeLine, const Sci::Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle)
char bracePreviousStyles[2]
std::unique_ptr< XYPOSITION[]> positions
int EndLineStyle() const noexcept
std::unique_ptr< unsigned char[]> styles
Sci::Line lineNumber
Drawing is only performed for maxLineLength characters on each line.
bool InLine(int offset, int line) const noexcept
void SetLineStart(int line, int start)
void Invalidate(ValidLevel validity_) noexcept
Point PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const noexcept
void RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle)
static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len_) noexcept
std::unique_ptr< XYPOSITION[]> positions
void ResetClock() noexcept
PositionCacheEntry() noexcept
bool NewerThan(const PositionCacheEntry &other) const noexcept
void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, const XYPOSITION *positions_, unsigned int clock_)
bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const noexcept
void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber, const char *s, unsigned int len, XYPOSITION *positions, const Document *pdoc)
std::vector< PositionCacheEntry > pces
void SetSize(size_t size_)
The range class represents a range of text in a document.
bool ContainsCharacter(Sci::Position pos) const noexcept
Sci::Position Position() const noexcept
bool IsValid() const noexcept
size_t Count() const noexcept
SelectionRange & Range(size_t r) noexcept
short startByteHasReprs[0x100]
const Representation * RepresentationFromCharacter(const char *charBytes, size_t len) const
bool Contains(const char *charBytes, size_t len) const
void ClearRepresentation(const char *charBytes)
void SetRepresentation(const char *charBytes, const char *value)
MapRepresentation mapReprs
A surface abstracts a place to draw.
virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0
std::vector< Style > styles
std::vector< Indicator > indicators
#define fill(Order, Group, Idx, Charset, Name)
unsigned long int lineNumber
static unsigned int hashValue(const char *const string, langType language)
Styling buffer using one element for each run rather than using a filled buffer.
constexpr int UTF8MaxBytes
int UTF8DrawBytes(const unsigned char *us, int len) noexcept
SelectionSegment Intersect(SelectionSegment check) const noexcept