diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/EditView.cxx | 23 | ||||
| -rw-r--r-- | src/Editor.cxx | 7 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 20 | ||||
| -rw-r--r-- | src/ViewStyle.h | 3 | 
4 files changed, 31 insertions, 22 deletions
| diff --git a/src/EditView.cxx b/src/EditView.cxx index bef27fd3e..4a10f6584 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -1727,7 +1727,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi  				if (ll->chars[i] == '\t') {  					// Tab display  					if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) -						textBack = *vsDraw.whitespaceColours.back; +						textBack = *vsDraw.whitespaceBack;  				} else {  					// Blob display  					inIndentation = false; @@ -1745,7 +1745,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi  									rcSegment.top,  									ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart),  									rcSegment.bottom); -								surface->FillRectangleAligned(rcSpace, Fill(*vsDraw.whitespaceColours.back)); +								surface->FillRectangleAligned(rcSpace, Fill(*vsDraw.whitespaceBack));  							}  						} else {  							inIndentation = false; @@ -1972,7 +1972,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi  					// Tab display  					if (phasesDraw == PhasesDraw::one) {  						if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) -							textBack = *vsDraw.whitespaceColours.back; +							textBack = *vsDraw.whitespaceBack;  						surface->FillRectangleAligned(rcSegment, Fill(textBack));  					}  					if (inIndentation && vsDraw.viewIndentationGuides == IndentView::real) { @@ -1988,15 +1988,14 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi  					}  					if (vsDraw.viewWhitespace != WhiteSpace::invisible) {  						if (vsDraw.WhiteSpaceVisible(inIndentation)) { -							if (vsDraw.whitespaceColours.fore) -								textFore = *vsDraw.whitespaceColours.fore;  							const PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight,  								rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);  							const int segmentTop = static_cast<int>(rcSegment.top) + vsDraw.lineHeight / 2; +							const ColourAlpha whiteSpaceFore = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE).value_or(textFore);  							if (!customDrawTabArrow) -								DrawTabArrow(surface, rcTab, segmentTop, vsDraw, Stroke(textFore, 1.0f)); +								DrawTabArrow(surface, rcTab, segmentTop, vsDraw, Stroke(whiteSpaceFore, 1.0f));  							else -								customDrawTabArrow(surface, rcTab, segmentTop, vsDraw, Stroke(textFore, 1.0f)); +								customDrawTabArrow(surface, rcTab, segmentTop, vsDraw, Stroke(whiteSpaceFore, 1.0f));  						}  					}  				} else { @@ -2032,12 +2031,10 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi  					for (int cpos = 0; cpos <= i - ts.start; cpos++) {  						if (ll->chars[cpos + ts.start] == ' ') {  							if (vsDraw.viewWhitespace != WhiteSpace::invisible) { -								if (vsDraw.whitespaceColours.fore) -									textFore = *vsDraw.whitespaceColours.fore;  								if (vsDraw.WhiteSpaceVisible(inIndentation)) {  									const XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;  									if ((phasesDraw == PhasesDraw::one) && drawWhitespaceBackground) { -										textBack = *vsDraw.whitespaceColours.back; +										textBack = *vsDraw.whitespaceBack;  										const PRectangle rcSpace(  											ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),  											rcSegment.top, @@ -2050,7 +2047,8 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi  										rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f);  									rcDot.right = rcDot.left + vsDraw.whitespaceSize;  									rcDot.bottom = rcDot.top + vsDraw.whitespaceSize; -									surface->FillRectangleAligned(rcDot, Fill(textFore)); +									const ColourAlpha whiteSpaceFore = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE).value_or(textFore); +									surface->FillRectangleAligned(rcDot, Fill(whiteSpaceFore));  								}  							}  							if (inIndentation && vsDraw.viewIndentationGuides == IndentView::real) { @@ -2516,8 +2514,7 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur  	// Don't show the selection when printing  	vsPrint.elementColours.clear();  	vsPrint.elementBaseColours.clear(); -	vsPrint.whitespaceColours.back.reset(); -	vsPrint.whitespaceColours.fore.reset(); +	vsPrint.whitespaceBack.reset();  	vsPrint.caretLine.alwaysShow = false;  	// Don't highlight matching braces using indicators  	vsPrint.braceHighlightIndicatorSet = false; diff --git a/src/Editor.cxx b/src/Editor.cxx index 8b6147a5b..62cb170d3 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7512,12 +7512,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		break;  	case SCI_SETWHITESPACEFORE: -		vs.whitespaceColours.fore = OptionalColour(wParam, lParam); -		InvalidateStyleRedraw(); +		if (vs.SetElementColourOptional(SC_ELEMENT_WHITE_SPACE, wParam, lParam)) { +			InvalidateStyleRedraw(); +		}  		break;  	case SCI_SETWHITESPACEBACK: -		vs.whitespaceColours.back = OptionalColour(wParam, lParam); +		vs.whitespaceBack = OptionalColour(wParam, lParam);  		InvalidateStyleRedraw();  		break; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 455a44c1e..3785dec37 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -90,7 +90,6 @@ ViewStyle::ViewStyle(const ViewStyle &source) : markers(MARKER_MAX + 1), indicat  	hotspotColours = source.hotspotColours;  	hotspotUnderline = source.hotspotUnderline; -	whitespaceColours = source.whitespaceColours;  	controlCharSymbol = source.controlCharSymbol;  	controlCharWidth = source.controlCharWidth;  	selbar = source.selbar; @@ -109,6 +108,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) : markers(MARKER_MAX + 1), indicat  	textStart = source.textStart;  	zoomLevel = source.zoomLevel;  	viewWhitespace = source.viewWhitespace; +	whitespaceBack = source.whitespaceBack;  	tabDrawMode = source.tabDrawMode;  	whitespaceSize = source.whitespaceSize;  	viewIndentationGuides = source.viewIndentationGuides; @@ -223,8 +223,6 @@ void ViewStyle::Init(size_t stylesSize_) {  	foldmarginColour.reset();  	foldmarginHighlightColour.reset(); -	whitespaceColours.fore.reset(); -	whitespaceColours.back.reset();  	controlCharSymbol = 0;	/* Draw the control characters */  	controlCharWidth = 0;  	selbar = Platform::Chrome(); @@ -267,8 +265,12 @@ void ViewStyle::Init(size_t stylesSize_) {  	textStart = marginInside ? fixedColumnWidth : leftMarginWidth;  	zoomLevel = 0;  	viewWhitespace = WhiteSpace::invisible; +	whitespaceBack.reset();  	tabDrawMode = TabDrawMode::longArrow;  	whitespaceSize = 1; +	elementColours.erase(SC_ELEMENT_WHITE_SPACE); +	elementAllowsTranslucent.insert(SC_ELEMENT_WHITE_SPACE); +  	viewIndentationGuides = IndentView::none;  	viewEOL = false;  	extraFontFlag = 0; @@ -521,7 +523,7 @@ bool ViewStyle::SelectionTextDrawn() const {  }  bool ViewStyle::WhitespaceBackgroundDrawn() const noexcept { -	return (viewWhitespace != WhiteSpace::invisible) && (whitespaceColours.back); +	return (viewWhitespace != WhiteSpace::invisible) && (whitespaceBack);  }  bool ViewStyle::WhiteSpaceVisible(bool inIndent) const noexcept { @@ -531,7 +533,7 @@ bool ViewStyle::WhiteSpaceVisible(bool inIndent) const noexcept {  }  ColourAlpha ViewStyle::WrapColour() const noexcept { -	return whitespaceColours.fore.value_or(styles[STYLE_DEFAULT].fore); +	return ElementColour(SC_ELEMENT_WHITE_SPACE).value_or(styles[STYLE_DEFAULT].fore);  }  // Insert new edge in sorted order. @@ -581,6 +583,14 @@ bool ViewStyle::SetElementColour(int element, ColourAlpha colour) {  	return changed;  } +bool ViewStyle::SetElementColourOptional(int element, uptr_t wParam, sptr_t lParam) { +	if (wParam) { +		return SetElementColour(element, ColourAlpha::FromRGB(static_cast<int>(lParam))); +	} else { +		return ResetElement(element); +	} +} +  void ViewStyle::SetElementRGB(int element, int rgb) {  	const ColourAlpha current = ElementColour(element).value_or(ColourAlpha(0, 0, 0, 0));  	elementColours[element] = ColourAlpha(ColourAlpha(rgb), current.GetAlpha()); diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 20325a962..b726cc559 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -134,7 +134,6 @@ public:  	SelectionAppearance selection; -	ForeBackColours whitespaceColours;  	int controlCharSymbol;  	XYPOSITION controlCharWidth;  	ColourAlpha selbar; @@ -154,6 +153,7 @@ public:  	int textStart;	///< Starting x position of text within the view  	int zoomLevel;  	WhiteSpace viewWhitespace; +	std::optional<ColourAlpha> whitespaceBack;  	TabDrawMode tabDrawMode;  	int whitespaceSize;  	IndentView viewIndentationGuides; @@ -229,6 +229,7 @@ public:  	bool ElementAllowsTranslucent(int element) const;  	bool ResetElement(int element);  	bool SetElementColour(int element, ColourAlpha colour); +	bool SetElementColourOptional(int element, uptr_t wParam, sptr_t lParam);  	void SetElementRGB(int element, int rgb);  	void SetElementAlpha(int element, int alpha);  	bool ElementIsSet(int element) const; | 
