// Scintilla source code edit control /** @file ViewStyle.cxx ** Store information on how the document is to be viewed. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ScintillaTypes.h" #include "Debugging.h" #include "Geometry.h" #include "Platform.h" #include "Position.h" #include "UniqueString.h" #include "Indicator.h" #include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" using namespace Scintilla; using namespace Scintilla::Internal; MarginStyle::MarginStyle(MarginType style_, int width_, int mask_) noexcept : style(style_), width(width_), mask(mask_), sensitive(false), cursor(CursorShape::ReverseArrow) { } bool MarginStyle::ShowsFolding() const noexcept { return (mask & MaskFolders) != 0; } void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technology, const FontSpecification &fs, const char *localeName) { PLATFORM_ASSERT(fs.fontName); measurements.sizeZoomed = fs.size + zoomLevel * FontSizeMultiplier; if (measurements.sizeZoomed <= FontSizeMultiplier) // May fail if sizeZoomed < 1 measurements.sizeZoomed = FontSizeMultiplier; const float deviceHeight = static_cast(surface.DeviceHeightFont(measurements.sizeZoomed)); const FontParameters fp(fs.fontName, deviceHeight / FontSizeMultiplier, fs.weight, fs.italic, fs.extraFontFlag, technology, fs.characterSet, localeName); font = Font::Allocate(fp); // floor here is historical as platform layers have tweaked their values to match. // ceil would likely be better to ensure (nearly) all of the ink of a character is seen // but that would require platform layer changes. measurements.ascent = std::floor(surface.Ascent(font.get())); measurements.descent = std::floor(surface.Descent(font.get())); measurements.capitalHeight = surface.Ascent(font.get()) - surface.InternalLeading(font.get()); measurements.aveCharWidth = surface.AverageCharWidth(font.get()); measurements.monospaceCharacterWidth = measurements.aveCharWidth; measurements.spaceWidth = surface.WidthText(font.get(), " "); if (fs.checkMonospaced) { // "Ay" is normally strongly kerned and "fi" may be a ligature constexpr std::string_view allASCIIGraphic("Ayfi" // python: ''.join(chr(ch) for ch in range(32, 127)) " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); std::array positions {}; surface.MeasureWidthsUTF8(font.get(), allASCIIGraphic, positions.data()); std::adjacent_difference(positions.begin(), positions.end(), positions.begin()); const XYPOSITION maxWidth = *std::max_element(positions.begin(), positions.end()); const XYPOSITION minWidth = *std::min_element(positions.begin(), positions.end()); const XYPOSITION variance = maxWidth - minWidth; const XYPOSITION scaledVariance = variance / measurements.aveCharWidth; constexpr XYPOSITION monospaceWidthEpsilon = 0.000001; // May need tweaking if monospace fonts vary more measurements.monospaceASCII = scaledVariance < monospaceWidthEpsilon; measurements.monospaceCharacterWidth = minWidth; } else { measurements.monospaceASCII = false; } } ViewStyle::ViewStyle(size_t stylesSize_) : styles(stylesSize_), markers(MarkerMax + 1), indicators(static_cast(IndicatorNumbers::Max) + 1) { nextExtendedStyle = 256; ResetDefaultStyle(); // There are no image markers by default, so no need for calling CalcLargestMarkerHeight() largestMarkerHeight = 0; indicators[0] = Indicator(IndicatorStyle::Squiggle, ColourRGBA(0, 0x7f, 0)); indicators[1] = Indicator(IndicatorStyle::TT, ColourRGBA(0, 0, 0xff)); indicators[2] = Indicator(IndicatorStyle::Plain, ColourRGBA(0xff, 0, 0)); // Reverted to origin constexpr ColourRGBA revertedToOrigin(0x40, 0xA0, 0xBF); // Saved constexpr ColourRGBA saved(0x0, 0xA0, 0x0); // Modified constexpr ColourRGBA modified(0xFF, 0x80, 0x0); // Reverted to change constexpr ColourRGBA revertedToChange(0xA0, 0xC0, 0x0); // Edition indicators constexpr size_t indexHistory = static_cast(IndicatorNumbers::HistoryRevertedToOriginInsertion); indicators[indexHistory+0] = Indicator(IndicatorStyle::CompositionThick, revertedToOrigin, false, 30, 60); indicators[indexHistory+1] = Indicator(IndicatorStyle::Point, revertedToOrigin); indicators[indexHistory+2] = Indicator(IndicatorStyle::CompositionThick, saved, false, 30, 60); indicators[indexHistory+3] = Indicator(IndicatorStyle::Point, saved); indicators[indexHistory+4] = Indicator(IndicatorStyle::CompositionThick, modified, false, 30, 60); indicators[indexHistory+5] = Indicator(IndicatorStyle::PointTop, modified); indicators[indexHistory+6] = Indicator(IndicatorStyle::CompositionThick, revertedToChange, false, 30, 60); indicators[indexHistory+7] = Indicator(IndicatorStyle::Point, revertedToChange); // Edition markers // Reverted to origin constexpr size_t indexHistoryRevertedToOrigin = static_cast(MarkerOutline::HistoryRevertedToOrigin); markers[indexHistoryRevertedToOrigin].back = revertedToOrigin; markers[indexHistoryRevertedToOrigin].fore = revertedToOrigin; markers[indexHistoryRevertedToOrigin].markType = MarkerSymbol::Bar; // Saved constexpr size_t indexHistorySaved = static_cast(MarkerOutline::HistorySaved); markers[indexHistorySaved].back = saved; markers[indexHistorySaved].fore = saved; markers[indexHistorySaved].markType = MarkerSymbol::Bar; // Modified constexpr size_t indexHistoryModified = static_cast(MarkerOutline::HistoryModified); markers[indexHistoryModified].back = Platform::Chrome(); markers[indexHistoryModified].fore = modified; markers[indexHistoryModified].markType = MarkerSymbol::Bar; // Reverted to change constexpr size_t indexHistoryRevertedToModified = static_cast(MarkerOutline::HistoryRevertedToModified); markers[indexHistoryRevertedToModified].back = revertedToChange; markers[indexHistoryRevertedToModified].fore = revertedToChange; markers[indexHistoryRevertedToModified].markType = MarkerSymbol::Bar; technology = Technology::Default; indicatorsDynamic = false; indicatorsSetFore = false; lineHeight = 1; lineOverlap = 0; maxAscent = 1; maxDescent = 1; aveCharWidth = 8; spaceWidth = 8; tabWidth = spaceWidth * 8; // Default is for no selection foregrounds elementColours.erase(Element::SelectionText); elementColours.erase(Element::SelectionAdditionalText); elementColours.erase(Element::SelectionSecondaryText); elementColours.erase(Element::SelectionInactiveText); // Shades of grey for selection backgrounds elementBaseColours[Element::SelectionBack] = ColourRGBA(0xc0, 0xc0, 0xc0, 0xff); elementBaseColours[Element::SelectionAdditionalBack] = ColourRGBA(0xd7, 0xd7, 0xd7, 0xff); elementBaseColours[Element::SelectionSecondaryBack] = ColourRGBA(0xb0, 0xb0, 0xb0, 0xff); elementBaseColours[Element::SelectionInactiveBack] = ColourRGBA(0x80, 0x80, 0x80, 0x3f); elementAllowsTranslucent.insert({ Element::SelectionText, Element::SelectionBack, Element::SelectionAdditionalText, Element::SelectionAdditionalBack, Element::SelectionSecondaryText, Element::SelectionSecondaryBack, Element::SelectionInactiveText, Element::SelectionInactiveBack, }); foldmarginColour.reset(); foldmarginHighlightColour.reset(); controlCharSymbol = 0; /* Draw the control characters */ controlCharWidth = 0; selbar = Platform::Chrome(); selbarlight = Platform::ChromeHighlight(); styles[StyleLineNumber].fore = ColourRGBA(0, 0, 0); styles[StyleLineNumber].back = Platform::Chrome(); elementBaseColours[Element::Caret] = ColourRGBA(0, 0, 0); elementBaseColours[Element::CaretAdditional] = ColourRGBA(0x7f, 0x7f, 0x7f); elementAllowsTranslucent.insert({ Element::Caret, Element::CaretAdditional, }); elementColHTTP/1.1 200 OK Connection: keep-alive Connection: keep-alive Content-Disposition: inline; filename="ViewStyle.cxx" Content-Disposition: inline; filename="ViewStyle.cxx" Content-Length: 27556 Content-Length: 27556 Content-Security-Policy: default-src 'none' Content-Security-Policy: default-src 'none' Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8 Date: Mon, 20 Oct 2025 21:36:16 UTC ETag: "b8fe0c0d6e418ab37b3b74c6fdf0d4161bf37487" ETag: "b8fe0c0d6e418ab37b3b74c6fdf0d4161bf37487" Expires: Thu, 18 Oct 2035 21:36:16 GMT Expires: Thu, 18 Oct 2035 21:36:16 GMT Last-Modified: Mon, 20 Oct 2025 21:36:16 GMT Last-Modified: Mon, 20 Oct 2025 21:36:16 GMT Server: OpenBSD httpd Server: OpenBSD httpd X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff // Scintilla source code edit control /** @file ViewStyle.cxx ** Store information on how the document is to be viewed. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ScintillaTypes.h" #include "Debugging.h" #include "Geometry.h" #include "Platform.h" #include "Position.h" #include "UniqueString.h" #include "Indicator.h" #include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" using namespace Scintilla; using namespace Scintilla::Internal; MarginStyle::MarginStyle(MarginType style_, int width_, int mask_) noexcept : style(style_), width(width_), mask(mask_), sensitive(false), cursor(CursorShape::ReverseArrow) { } bool MarginStyle::ShowsFolding() const noexcept { return (mask & MaskFolders) != 0; } void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technology, const FontSpecification &fs, const char *localeName) { PLATFORM_ASSERT(fs.fontName); measurements.sizeZoomed = fs.size + zoomLevel * FontSizeMultiplier; if (measurements.sizeZoomed <= FontSizeMultiplier) // May fail if sizeZoomed < 1 measurements.sizeZoomed = FontSizeMultiplier; const float deviceHeight = static_cast(surface.DeviceHeightFont(measurements.sizeZoomed)); const FontParameters fp(fs.fontName, deviceHeight / FontSizeMultiplier, fs.weight, fs.italic, fs.extraFontFlag, technology, fs.characterSet, localeName); font = Font::Allocate(fp); // floor here is historical as platform layers have tweaked their values to match. // ceil would likely be better to ensure (nearly) all of the ink of a character is seen // but that would require platform layer changes. measurements.ascent = std::floor(surface.Ascent(font.get())); measurements.descent = std::floor(surface.Descent(font.get())); measurements.capitalHeight = surface.Ascent(font.get()) - surface.InternalLeading(font.get()); measurements.aveCharWidth = surface.AverageCharWidth(font.get()); measurements.monospaceCharacterWidth = measurements.aveCharWidth; measurements.spaceWidth = surface.WidthText(font.get(), " "); if (fs.checkMonospaced) { // "Ay" is normally strongly kerned and "fi" may be a ligature constexpr std::string_view allASCIIGraphic("Ayfi" // python: ''.join(chr(ch) for ch in range(32, 127)) " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); std::array positions {}; surface.MeasureWidthsUTF8(font.get(), allASCIIGraphic, positions.data()); std::adjacent_difference(positions.begin(), positions.end(), positions.begin()); const XYPOSITION maxWidth = *std::max_element(positions.begin(), positions.end()); const XYPOSITION minWidth = *std::min_element(positions.begin(), positions.end()); const XYPOSITION variance = maxWidth - minWidth; const XYPOSITION scaledVariance = variance / measurements.aveCharWidth; constexpr XYPOSITION monospaceWidthEpsilon = 0.000001; // May need tweaking if monospace fonts vary more measurements.monospaceASCII = scaledVariance < monospaceWidthEpsilon; measurements.monospaceCharacterWidth = minWidth; } else { measurements.monospaceASCII = false; } } ViewStyle::ViewStyle(size_t stylesSize_) : styles(stylesSize_), markers(MarkerMax + 1), indicators(static_cast(IndicatorNumbers::Max) + 1) { nextExtendedStyle = 256; ResetDefaultStyle(); // There are no image markers by default, so no need for calling CalcLargestMarkerHeight() largestMarkerHeight = 0; indicators[0] = Indicator(IndicatorStyle::Squiggle, ColourRGBA(0, 0x7f, 0)); indicators[1] = Indicator(IndicatorStyle::TT, ColourRGBA(0, 0, 0xff)); indicators[2] = Indicator(IndicatorStyle::Plain, ColourRGBA(0xff, 0, 0)); // Reverted to origin constexpr ColourRGBA revertedToOrigin(0x40, 0xA0, 0xBF); // Saved constexpr ColourRGBA saved(0x0, 0xA0, 0x0); // Modified constexpr ColourRGBA modified(0xFF, 0x80, 0x0); // Reverted to change constexpr ColourRGBA revertedToChange(0xA0, 0xC0, 0x0); // Edition indicators constexpr size_t indexHistory = static_cast(IndicatorNumbers::HistoryRevertedToOriginInsertion); indicators[indexHistory+0] = Indicator(IndicatorStyle::CompositionThick, revertedToOrigin, false, 30, 60); indicators[indexHistory+1] = Indicator(IndicatorStyle::Point, revertedToOrigin); indicators[indexHistory+2] = Indicator(IndicatorStyle::CompositionThick, saved, false, 30, 60); indicators[indexHistory+3] = Indicator(IndicatorStyle::Point, saved); indicators[indexHistory+4] = Indicator(IndicatorStyle::CompositionThick, modified, false, 30, 60); indicators[indexHistory+5] = Indicator(IndicatorStyle::PointTop, modified); indicators[indexHistory+6] = Indicator(IndicatorStyle::CompositionThick, revertedToChange, false, 30, 60); indicators[indexHistory+7] = Indicator(IndicatorStyle::Point, revertedToChange); // Edition markers // Reverted to origin constexpr size_t indexHistoryRevertedToOrigin = static_cast(MarkerOutline::HistoryRevertedToOrigin); markers[indexHistoryRevertedToOrigin].back = revertedToOrigin; markers[indexHistoryRevertedToOrigin].fore = revertedToOrigin; markers[indexHistoryRevertedToOrigin].markType = MarkerSymbol::Bar; // Saved constexpr size_t indexHistorySaved = static_cast(MarkerOutline::HistorySaved); markers[indexHistorySaved].back = saved; markers[indexHistorySaved].fore = saved; markers[indexHistorySaved].markType = MarkerSymbol::Bar; // Modified constexpr size_t indexHistoryModified = static_cast(MarkerOutline::HistoryModified); markers[indexHistoryModified].back = Platform::Chrome(); markers[indexHistoryModified].fore = modified; markers[indexHistoryModified].markType = MarkerSymbol::Bar; // Reverted to change constexpr size_t indexHistoryRevertedToModified = static_cast(MarkerOutline::HistoryRevertedToModified); markers[indexHistoryRevertedToModified].back = revertedToChange; markers[indexHistoryRevertedToModified].fore = revertedToChange; markers[indexHistoryRevertedToModified].markType = MarkerSymbol::Bar; technology = Technology::Default; indicatorsDynamic = false; indicatorsSetFore = false; lineHeight = 1; lineOverlap = 0; maxAscent = 1; maxDescent = 1; aveCharWidth = 8; spaceWidth = 8; tabWidth = spaceWidth * 8; // Default is for no selection foregrounds elementColours.erase(Element::SelectionText); elementColours.erase(Element::SelectionAdditionalText); elementColours.erase(Element::SelectionSecondaryText); elementColours.erase(Element::SelectionInactiveText); // Shades of grey for selection backgrounds elementBaseColours[Element::SelectionBack] = ColourRGBA(0xc0, 0xc0, 0xc0, 0xff); elementBaseColours[Element::SelectionAdditionalBack] = ColourRGBA(0xd7, 0xd7, 0xd7, 0xff); elementBaseColours[Element::SelectionSecondaryBack] = ColourRGBA(0xb0, 0xb0, 0xb0, 0xff); elementBaseColours[Element::SelectionInactiveBack] = ColourRGBA(0x80, 0x80, 0x80, 0x3f); elementAllowsTranslucent.insert({ Element::SelectionText, Element::SelectionBack, Element::SelectionAdditionalText, Element::SelectionAdditionalBack, Element::SelectionSecondaryText, Element::SelectionSecondaryBack, Element::SelectionInactiveText, Element::SelectionInactiveBack, }); foldmarginColour.reset(); foldmarginHighlightColour.reset(); controlCharSymbol = 0; /* Draw the control characters */ controlCharWidth = 0; selbar = Platform::Chrome(); selbarlight = Platform::ChromeHighlight(); styles[StyleLineNumber].fore = ColourRGBA(0, 0, 0); styles[StyleLineNumber].back = Platform::Chrome(); elementBaseColours[Element::Caret] = ColourRGBA(0, 0, 0); elementBaseColours[Element::CaretAdditional] = ColourRGBA(0x7f, 0x7f, 0x7f); elementAllowsTranslucent.insert({ Element::Caret, Element::CaretAdditional, }); elementColours.erase(Element::CaretLineBack); elementAllowsTranslucent.insert(Element::CaretLineBack); someStylesProtected = false; someStylesForceCase = false; hotspotUnderline = true; elementColours.erase(Element::HotSpotActive); elementAllowsTranslucent.insert(Element::HotSpotActive); leftMarginWidth = 1; rightMarginWidth = 1; ms.resize(MaxMargin + 1); ms[0] = MarginStyle(MarginType::Number); ms[1] = MarginStyle(MarginType::Symbol, 16, ~MaskFolders); ms[2] = MarginStyle(MarginType::Symbol); marginInside = true; CalculateMarginWidthAndMask(); textStart = marginInside ? fixedColumnWidth : leftMarginWidth; zoomLevel = 0; viewWhitespace = WhiteSpace::Invisible; tabDrawMode = TabDrawMode::LongArrow; whitespaceSize = 1; elementColours.erase(Element::WhiteSpace); elementAllowsTranslucent.insert(Element::WhiteSpace); viewIndentationGuides = IndentView::None; viewEOL = false; extraFontFlag = FontQuality::QualityDefault; extraAscent = 0; extraDescent = 0; marginStyleOffset = 0; annotationVisible = AnnotationVisible::Hidden; annotationStyleOffset = 0; eolAnnotationVisible = EOLAnnotationVisible::Hidden; eolAnnotationStyleOffset = 0; braceHighlightIndicatorSet = false; braceHighlightIndicator = 0; braceBadLightIndicatorSet = false; braceBadLightIndicator = 0; edgeState = EdgeVisualStyle::None; theEdge = EdgeProperties(0, ColourRGBA(0xc0, 0xc0, 0xc0)); marginNumberPadding = 3; ctrlCharPadding = 3; // +3 For a blank on front and rounded edge each side lastSegItalicsOffset = 2; localeName = localeNameDefault; } // Copy constructor only called when printing copies the screen ViewStyle so it can be // modified for printing styles. ViewStyle::ViewStyle(const ViewStyle &source) : ViewStyle(source.styles.size()) { styles = source.styles; for (Style &style : styles) { // Can't just copy fontName as its lifetime is relative to its owning ViewStyle style.fontName = fontNames.Save(style.fontName); } nextExtendedStyle = source.nextExtendedStyle; markers = source.markers; CalcLargestMarkerHeight(); indicators = source.indicators; indicatorsDynamic = source.indicatorsDynamic; indicatorsSetFore = source.indicatorsSetFore; selection = source.selection; foldmarginColour = source.foldmarginColour; foldmarginHighlightColour = source.foldmarginHighlightColour; hotspotUnderline = source.hotspotUnderline; controlCharSymbol = source.controlCharSymbol; controlCharWidth = source.controlCharWidth; selbar = source.selbar; selbarlight = source.selbarlight; caret = source.caret; caretLine = source.caretLine; someStylesProtected = false; someStylesForceCase = false; leftMarginWidth = source.leftMarginWidth; rightMarginWidth = source.rightMarginWidth; ms = source.ms; maskInLine = source.maskInLine; maskDrawInText = source.maskDrawInText; maskDrawWrapped = source.maskDrawWrapped; fixedColumnWidth = source.fixedColumnWidth; marginInside = source.marginInside; textStart = source.textStart; zoomLevel = source.zoomLevel; viewWhitespace = source.viewWhitespace; tabDrawMode = source.tabDrawMode; whitespaceSize = source.whitespaceSize; viewIndentationGuides = source.viewIndentationGuides; viewEOL = source.viewEOL; extraFontFlag = source.extraFontFlag; extraAscent = source.extraAscent; extraDescent = source.extraDescent; marginStyleOffset = source.marginStyleOffset; annotationVisible = source.annotationVisible; annotationStyleOffset = source.annotationStyleOffset; eolAnnotationVisible = source.eolAnnotationVisible; eolAnnotationStyleOffset = source.eolAnnotationStyleOffset; braceHighlightIndicatorSet = source.braceHighlightIndicatorSet; braceHighlightIndicator = source.braceHighlightIndicator; braceBadLightIndicatorSet = source.braceBadLightIndicatorSet; braceBadLightIndicator = source.braceBadLightIndicator; edgeState = source.edgeState; theEdge = source.theEdge; theMultiEdge = source.theMultiEdge; marginNumberPadding = source.marginNumberPadding; ctrlCharPadding = source.ctrlCharPadding; lastSegItalicsOffset = source.lastSegItalicsOffset; wrap = source.wrap; localeName = source.localeName; } ViewStyle::~ViewStyle() = default; void ViewStyle::CalculateMarginWidthAndMask() noexcept { fixedColumnWidth = marginInside ? leftMarginWidth : 0; maskInLine = 0xffffffff; int maskDefinedMarkers = 0; for (const MarginStyle &m : ms) { fixedColumnWidth += m.width; if (m.width > 0) maskInLine &= ~m.mask; maskDefinedMarkers |= m.mask; } maskDrawInText = 0; for (int markBit = 0; markBit < 32; markBit++) { const int maskBit = 1U << markBit; switch (markers[markBit].markType) { case MarkerSymbol::Empty: maskInLine &= ~maskBit; break; case MarkerSymbol::Background: case MarkerSymbol::Underline: maskInLine &= ~maskBit; maskDrawInText |= maskDefinedMarkers & maskBit; break; default: // Other marker types do not affect the masks break; } } maskDrawWrapped = 0; for (int markBit = 0; markBit < 32; markBit++) { const int maskBit = 1U << markBit; switch (markers[markBit].markType) { case MarkerSymbol::Bar: maskDrawWrapped |= maskBit; break; default: // Other marker types do not affect the masks break; } } } void ViewStyle::Refresh(Surface &surface, int tabInChars) { fonts.clear(); selbar = Platform::Chrome(); selbarlight = Platform::ChromeHighlight(); // Apply the extra font flag which controls text drawing quality to each style. for (Style &style : styles) { style.extraFontFlag = extraFontFlag; } // Create a FontRealised object for each unique font in the styles. CreateAndAddFont(styles[StyleDefault]); for (const Style &style : styles) { CreateAndAddFont(style); } // Ask platform to allocate each unique font. for (const std::pair> &font : fonts) { font.second->Realise(surface, zoomLevel, technology, font.first, localeName.c_str()); } // Set the platform font handle and measurements for each style. for (Style &style : styles) { const FontRealised *fr = Find(style); style.Copy(fr->font, fr->measurements); } indicatorsDynamic = std::any_of(indicators.cbegin(), indicators.cend(), [](const Indicator &indicator) noexcept { return indicator.IsDynamic(); }); indicatorsSetFore = std::any_of(indicators.cbegin(), indicators.cend(), [](const Indicator &indicator) noexcept { return indicator.OverridesTextFore(); }); maxAscent = 1; maxDescent = 1; FindMaxAscentDescent(); // Ensure reasonable values: lines less than 1 pixel high will not work maxAscent = std::max(1.0, maxAscent + extraAscent); maxDescent = std::max(0.0, maxDescent + extraDescent); lineHeight = static_cast(std::lround(maxAscent + maxDescent)); lineOverlap = lineHeight / 10; if (lineOverlap < 2) lineOverlap = 2; if (lineOverlap > lineHeight) lineOverlap = lineHeight; someStylesProtected = std::any_of(styles.cbegin(), styles.cend(), [](const Style &style) noexcept { return style.IsProtected(); }); someStylesForceCase = std::any_of(styles.cbegin(), styles.cend(), [](const Style &style) noexcept { return style.caseForce != Style::CaseForce::mixed; }); aveCharWidth = styles[StyleDefault].aveCharWidth; spaceWidth = styles[StyleDefault].spaceWidth; tabWidth = spaceWidth * tabInChars; controlCharWidth = 0.0; if (controlCharSymbol >= 32) { const char cc[2] = { static_cast(controlCharSymbol), '\0' }; controlCharWidth = surface.WidthText(styles[StyleControlChar].font.get(), cc); } CalculateMarginWidthAndMask(); textStart = marginInside ? fixedColumnWidth : leftMarginWidth; } void ViewStyle::ReleaseAllExtendedStyles() noexcept { nextExtendedStyle = 256; } int ViewStyle::AllocateExtendedStyles(int numberStyles) { const int startRange = nextExtendedStyle; nextExtendedStyle += numberStyles; EnsureStyle(nextExtendedStyle); return startRange; } void ViewStyle::EnsureStyle(size_t index) { if (index >= styles.size()) { AllocStyles(index+1); } } void ViewStyle::ResetDefaultStyle() { styles[StyleDefault] = Style(fontNames.Save(Platform::DefaultFont())); } void ViewStyle::ClearStyles() { // Reset all styles to be like the default style for (size_t i=0; i= x) && (pt.x < x + ms[i].width)) return static_cast(i); x += ms[i].width; } return -1; } bool ViewStyle::ValidStyle(size_t styleIndex) const noexcept { return styleIndex < styles.size(); } void ViewStyle::CalcLargestMarkerHeight() noexcept { largestMarkerHeight = 0; for (const LineMarker &marker : markers) { switch (marker.markType) { case MarkerSymbol::Pixmap: if (marker.pxpm && marker.pxpm->GetHeight() > largestMarkerHeight) largestMarkerHeight = marker.pxpm->GetHeight(); break; case MarkerSymbol::RgbaImage: if (marker.image && marker.image->GetHeight() > largestMarkerHeight) largestMarkerHeight = marker.image->GetHeight(); break; case MarkerSymbol::Bar: largestMarkerHeight = lineHeight + 2; break; default: // Only images have their own natural heights break; } } } int ViewStyle::GetFrameWidth() const noexcept { return std::clamp(caretLine.frame, 1, lineHeight / 3); } bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const { return caretLine.frame && (caretActive || caretLine.alwaysShow) && ElementColour(Element::CaretLineBack) && (caretLine.layer == Layer::Base) && lineContainsCaret; } // See if something overrides the line background c