diff options
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 18eafa271..49fa40910 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1739,7 +1739,7 @@ int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const { return markerCheck; } -bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { +bool ValidStyledText(const ViewStyle &vs, size_t styleOffset, const StyledText &st) { if (st.multipleStyles) { for (size_t iStyle=0; iStyle<st.length; iStyle++) { if (!vs.ValidStyle(styleOffset + st.styles[iStyle])) @@ -1752,7 +1752,7 @@ bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { return true; } -static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, +static int WidthStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, const char *text, const unsigned char *styles, size_t len) { int width = 0; size_t start = 0; @@ -1761,14 +1761,15 @@ static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, size_t endSegment = start; while ((endSegment+1 < len) && (static_cast<size_t>(styles[endSegment+1]) == style)) endSegment++; - width += static_cast<int>(surface->WidthText(vs.styles[style + styleOffset].font, text + start, + FontAlias fontText = vs.styles[style + styleOffset].font; + width += static_cast<int>(surface->WidthText(fontText, text + start, static_cast<int>(endSegment - start + 1))); start = endSegment + 1; } return width; } -static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, const StyledText &st) { +static int WidestLineWidth(Surface *surface, const ViewStyle &vs, int styleOffset, const StyledText &st) { int widthMax = 0; size_t start = 0; while (start < st.length) { @@ -1777,7 +1778,8 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); } else { - widthSubLine = static_cast<int>(surface->WidthText(vs.styles[styleOffset + st.style].font, + FontAlias fontText = vs.styles[styleOffset + st.style].font; + widthSubLine = static_cast<int>(surface->WidthText(fontText, st.text + start, static_cast<int>(lenLine))); } if (widthSubLine > widthMax) @@ -1787,7 +1789,7 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con return widthMax; } -void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, +void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { @@ -1799,12 +1801,13 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle while (end < length-1 && st.styles[start+end+1] == style) end++; style += styleOffset; - int width = static_cast<int>(surface->WidthText(vs.styles[style].font, + FontAlias fontText = vs.styles[style].font; + int width = static_cast<int>(surface->WidthText(fontText, st.text + start + i, static_cast<int>(end - i + 1))); PRectangle rcSegment = rcText; rcSegment.left = static_cast<XYPOSITION>(x); rcSegment.right = static_cast<XYPOSITION>(x + width + 1); - surface->DrawTextNoClip(rcSegment, vs.styles[style].font, + surface->DrawTextNoClip(rcSegment, fontText, static_cast<XYPOSITION>(ascent), st.text + start + i, static_cast<int>(end - i + 1), vs.styles[style].fore, @@ -1814,7 +1817,8 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle } } else { size_t style = st.style + styleOffset; - surface->DrawTextNoClip(rcText, vs.styles[style].font, + FontAlias fontText = vs.styles[style].font; + surface->DrawTextNoClip(rcText, fontText, rcText.top + vs.maxAscent, st.text + start, static_cast<int>(length), vs.styles[style].fore, @@ -2162,8 +2166,7 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { * Copy the given @a line and its styles from the document into local arrays. * Also determine the x position at which each character starts. */ -void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) { -//void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width, Document *pdoc, PositionCache &posCache, SpecialRepresentations &reprs) { +void Editor::LayoutLine(int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; @@ -2387,13 +2390,13 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } } -ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) const { +ColourDesired Editor::SelectionBackground(const ViewStyle &vsDraw, bool main) const { return main ? (primarySelection ? vsDraw.selColours.back : vsDraw.selBackground2) : vsDraw.selAdditionalBackground; } -ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, +ColourDesired Editor::TextBackground(const ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const { if (inSelection == 1) { if (vsDraw.selColours.back.isSet && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { @@ -2475,12 +2478,12 @@ static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourDesired } } -void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, +void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle rcSegment, const char *s, ColourDesired textBack, ColourDesired textFore, bool twoPhaseDraw) { if (!twoPhaseDraw) { surface->FillRectangle(rcSegment, textBack); } - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; int normalCharHeight = static_cast<int>(surface->Ascent(ctrlCharsFont) - surface->InternalLeading(ctrlCharsFont)); PRectangle rcCChar = rcSegment; @@ -2499,7 +2502,7 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, textBack, textFore); } -void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, +void Editor::DrawEOL(Surface *surface, const ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, bool overrideBackground, ColourDesired background, bool drawWrapMarkEnd, ColourDesired wrapColour) { @@ -2650,7 +2653,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin } } -void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw, +void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; PRectangle rcIndic( @@ -2661,7 +2664,7 @@ void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surf vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine); } -void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +void Editor::DrawIndicators(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) { // Draw decorators const int posLineStart = pdoc->LineStart(line); @@ -2710,7 +2713,7 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x } } -void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +void Editor::DrawAnnotation(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { int indent = static_cast<int>(pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); PRectangle rcSegment = rcLine; @@ -2767,7 +2770,7 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x } } -void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, +void Editor::DrawLine(Surface *surface, const ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { if (subLine >= ll->lines) { @@ -2780,7 +2783,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // Using one font for all control characters so it can be controlled independently to ensure // the box goes around the characters tightly. Seems to be no way to work out what height // is taken by an individual character - internal leading gives varying results. - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; // See if something overrides the line background color: Either if caret is on the line // and background color is set for that, or if a marker is defined that forces its background @@ -3007,7 +3010,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (rcSegment.Intersects(rcLine)) { int styleMain = ll->styles[i]; ColourDesired textFore = vsDraw.styles[styleMain].fore; - Font &textFont = vsDraw.styles[styleMain].font; + FontAlias textFont = vsDraw.styles[styleMain].font; //hotspot foreground if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) { if (vsDraw.hotspotColours.fore.isSet) @@ -3253,7 +3256,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } -void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, +void Editor::DrawBlockCaret(Surface *surface, const ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) { int lineStart = ll->LineStart(subLine); @@ -3312,7 +3315,8 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, // This character is where the caret block is, we override the colours // (inversed) for drawing the caret here. int styleMain = ll->styles[offsetFirstChar]; - surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font, + FontAlias fontText = vsDraw.styles[styleMain].font; + surface->DrawTextClipped(rcCaret, fontText, rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, numCharsToDraw, vsDraw.styles[styleMain].back, caretColour); @@ -3386,7 +3390,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { } } -void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xStart, +void Editor::DrawCarets(Surface *surface, const ViewStyle &vsDraw, int lineDoc, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { // When drag is active it is the only caret drawn bool drawDrag = posDrag.IsValid(); |