diff options
| -rw-r--r-- | doc/ScintillaDoc.html | 13 | ||||
| -rw-r--r-- | include/Scintilla.h | 3 | ||||
| -rw-r--r-- | include/Scintilla.iface | 9 | ||||
| -rw-r--r-- | src/Editor.cxx | 76 | ||||
| -rw-r--r-- | src/LineMarker.h | 4 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 2 | ||||
| -rw-r--r-- | src/ViewStyle.h | 1 | 
7 files changed, 95 insertions, 13 deletions
| diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 0139a93f7..2669de6b5 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -2114,6 +2114,8 @@ struct TextToFind {      colour)</a><br />       <a class="message" href="#SCI_SETSELBACK">SCI_SETSELBACK(bool useSelectionBackColour, int      colour)</a><br /> +     <a class="message" href="#SCI_SETSELALPHA">SCI_SETSELALPHA(int alpha)</a><br /> +     <a class="message" href="#SCI_GETSELALPHA">SCI_GETSELALPHA</a><br />       <a class="message" href="#SCI_SETCARETFORE">SCI_SETCARETFORE(int colour)</a><br />       <a class="message" href="#SCI_GETCARETFORE">SCI_GETCARETFORE</a><br />       <a class="message" href="#SCI_SETCARETLINEVISIBLE">SCI_SETCARETLINEVISIBLE(bool @@ -2147,6 +2149,10 @@ struct TextToFind {      you provide is used if you set <code>useSelection*Colour</code> to <code>true</code>. If it is      set to <code>false</code>, the default colour colouring is used and the <code>colour</code>      argument has no effect.</p> +     <p><b id="SCI_SETSELALPHA">SCI_SETSELALPHA(int <a class="jump" href="#alpha">alpha</a>)</b><br /> +     <b id="SCI_GETSELALPHA">SCI_GETSELALPHA</b><br /> +     The selection background can be drawn translucently in the selection background colour by +     setting an alpha value.</p>      <p><b id="SCI_SETCARETFORE">SCI_SETCARETFORE(int <a class="jump"      href="#colour">colour</a>)</b><br /> @@ -2617,6 +2623,8 @@ struct TextToFind {      colour)</a><br />       <a class="message" href="#SCI_MARKERSETBACK">SCI_MARKERSETBACK(int markerNumber, int      colour)</a><br /> +     <a class="message" href="#SCI_MARKERSETALPHA">SCI_MARKERSETALPHA(int markerNumber, int +    alpha)</a><br />       <a class="message" href="#SCI_MARKERADD">SCI_MARKERADD(int line, int markerNumber)</a><br />       <a class="message" href="#SCI_MARKERADDSET">SCI_MARKERADDSET(int line, int markerMask)</a><br />       <a class="message" href="#SCI_MARKERDELETE">SCI_MARKERDELETE(int line, int @@ -2790,6 +2798,11 @@ struct TextToFind {       <b id="SCI_MARKERSETBACK">SCI_MARKERSETBACK(int markerNumber, int <a class="jump"      href="#colour">colour</a>)</b><br />       These two messages set the foreground and background colour of a marker number.</p> +     <p><b id="SCI_MARKERSETALPHA">SCI_MARKERSETALPHA(int markerNumber, int <a class="jump" +    href="#alpha">alpha</a>)</b><br /> +     When markers are drawn in the content area, either because there is no margin for them or +     they are of SC_MARK_BACKGROUND type, they may be drawn translucently by +     setting an alpha value.</p>      <p><b id="SCI_MARKERADD">SCI_MARKERADD(int line, int markerNumber)</b><br />       This message adds marker number <code>markerNumber</code> to a line. The message returns -1 if diff --git a/include/Scintilla.h b/include/Scintilla.h index 035ca04fa..5d2adb218 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -138,6 +138,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_MARKERPREVIOUS 2048  #define SCI_MARKERDEFINEPIXMAP 2049  #define SCI_MARKERADDSET 2466 +#define SCI_MARKERSETALPHA 2476  #define SC_MARGIN_SYMBOL 0  #define SC_MARGIN_NUMBER 1  #define SCI_SETMARGINTYPEN 2240 @@ -196,6 +197,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_STYLESETHOTSPOT 2409  #define SCI_SETSELFORE 2067  #define SCI_SETSELBACK 2068 +#define SCI_GETSELALPHA 2477 +#define SCI_SETSELALPHA 2478  #define SCI_SETCARETFORE 2069  #define SCI_ASSIGNCMDKEY 2070  #define SCI_CLEARCMDKEY 2071 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index d0f9f885d..9a0795f72 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -316,6 +316,9 @@ fun void MarkerDefinePixmap=2049(int markerNumber, string pixmap)  # Add a set of markers to a line.  fun void MarkerAddSet=2466(int line, int set) +# Set the alpha used for a marker that is drawn in the text area, not the margin. +fun void MarkerSetAlpha=2476(int markerNumber, int alpha) +  enu MarginType=SC_MARGIN_  val SC_MARGIN_SYMBOL=0  val SC_MARGIN_NUMBER=1 @@ -431,6 +434,12 @@ fun void SetSelFore=2067(bool useSetting, colour fore)  # Set the background colour of the selection and whether to use this setting.  fun void SetSelBack=2068(bool useSetting, colour back) +# Get the alpha of the selection. +get int GetSelAlpha=2477(,) + +# Set the alpha of the selection. +set void SetSelAlpha=2478(int alpha,) +  # Set the foreground colour of the caret.  set void SetCaretFore=2069(colour fore,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 9b20bfa2d..54a461eff 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2153,7 +2153,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou  ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,                                         ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {  	if (inSelection) { -		if (vsDraw.selbackset) { +		if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {  			if (primarySelection)  				return vsDraw.selbackground.allocated;  			else @@ -2241,7 +2241,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin  	bool eolInSelection = (subLine == (ll->lines - 1)) &&  	                      (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd); -	if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) { +	if (eolInSelection && vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA) && (line < pdoc->LinesTotal() - 1)) {  		if (primarySelection)  			surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated);  		else @@ -2277,6 +2277,12 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin  	}  } +static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) { +	if (alpha != SC_ALPHA_NOALPHA) { +		surface->AlphaRectangle(rc, 0, fill, alpha, fill, alpha, 0); +	} +} +  void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,                        PRectangle rcLine, LineLayout *ll, int subLine) { @@ -2302,7 +2308,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  	if (!overrideBackground) {  		int marks = pdoc->GetMark(line);  		for (int markBit = 0; (markBit < 32) && marks; markBit++) { -			if ((marks & 1) && vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) { +			if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) && +				(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {  				background = vsDraw.markers[markBit].back.allocated;  				overrideBackground = true;  			} @@ -2311,14 +2318,15 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  	}  	if (!overrideBackground) {  		if (vsDraw.maskInLine) { -			int marks = pdoc->GetMark(line) & vsDraw.maskInLine; -			if (marks) { -				for (int markBit = 0; (markBit < 32) && marks; markBit++) { -					if ((marks & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { +			int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; +			if (marksMasked) { +				for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { +					if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) && +						(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {  						overrideBackground = true;  						background = vsDraw.markers[markBit].back.allocated;  					} -					marks >>= 1; +					marksMasked >>= 1;  				}  			}  		} @@ -2646,6 +2654,16 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  		        xStart, subLine, subLineStart, overrideBackground, background,  		        drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);  	} +	if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) && (ll->selStart >= 0) && (ll->selEnd >= 0)) { +		int startPosSel = (ll->selStart < posLineStart) ? posLineStart : ll->selStart; +		int endPosSel = (ll->selEnd < (lineEnd + posLineStart)) ? ll->selEnd : (lineEnd + posLineStart); +		if (startPosSel < endPosSel) { +			rcSegment.left = xStart + ll->positions[startPosSel - posLineStart] - subLineStart; +			rcSegment.right = xStart + ll->positions[endPosSel - posLineStart] - subLineStart; +			SimpleAlphaRectangle(surface, rcSegment, +				primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated, vsDraw.selAlpha); +		} +	}  	if (vsDraw.edgeState == EDGE_LINE) {  		int edgeX = theEdge * vsDraw.spaceWidth; @@ -2654,11 +2672,29 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  		surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);  	} -	if (caret.active && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha != SC_ALPHA_NOALPHA) && ll->containsCaret) { -		rcSegment.left = xStart; -		rcSegment.right = rcLine.right - 1; -		surface->AlphaRectangle(rcSegment, 0, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha, -			vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha, 0); +	// Draw any translucent whole line states +	rcSegment.left = xStart; +	rcSegment.right = rcLine.right - 1; +	if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) { +		SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha); +	} +	int marks = pdoc->GetMark(line); +	for (int markBit = 0; (markBit < 32) && marks; markBit++) { +		if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { +			SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); +		} +		marks >>= 1; +	} +	if (vsDraw.maskInLine) { +		int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; +		if (marksMasked) { +			for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { +				if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { +					SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); +				} +				marksMasked >>= 1; +			} +		}  	}  } @@ -3089,6 +3125,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {  	// Don't show the selection when printing  	vsPrint.selbackset = false;  	vsPrint.selforeset = false; +	vsPrint.selAlpha = SC_ALPHA_NOALPHA;  	vsPrint.whitespaceBackgroundSet = false;  	vsPrint.whitespaceForegroundSet = false;  	vsPrint.showCaretLineBackground = false; @@ -6512,6 +6549,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		InvalidateStyleData();  		RedrawSelMargin();  		break; +	case SCI_MARKERSETALPHA: +		if (wParam <= MARKER_MAX) +			vs.markers[wParam].alpha = lParam; +		InvalidateStyleRedraw(); +		break;  	case SCI_MARKERADD: {  			int markerID = pdoc->AddMark(wParam, lParam);  			return markerID; @@ -6850,6 +6892,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		InvalidateStyleRedraw();  		break; +	case SCI_SETSELALPHA: +		vs.selAlpha = wParam; +		InvalidateStyleRedraw(); +		break; + +	case SCI_GETSELALPHA: +		return vs.selAlpha; +  	case SCI_SETWHITESPACEFORE:  		vs.whitespaceForegroundSet = wParam != 0;  		vs.whitespaceForeground.desired = ColourDesired(lParam); diff --git a/src/LineMarker.h b/src/LineMarker.h index ef5924f75..8ebdce491 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -15,11 +15,13 @@ public:  	int markType;  	ColourPair fore;  	ColourPair back; +	int alpha;  	XPM *pxpm;  	LineMarker() {  		markType = SC_MARK_CIRCLE;  		fore = ColourDesired(0,0,0);  		back = ColourDesired(0xff,0xff,0xff); +		alpha = SC_ALPHA_NOALPHA;  		pxpm = NULL;  	}  	LineMarker(const LineMarker &) { @@ -27,6 +29,7 @@ public:  		markType = SC_MARK_CIRCLE;  		fore = ColourDesired(0,0,0);  		back = ColourDesired(0xff,0xff,0xff); +		alpha = SC_ALPHA_NOALPHA;  		pxpm = NULL;  	}  	~LineMarker() { @@ -37,6 +40,7 @@ public:  		markType = SC_MARK_CIRCLE;  		fore = ColourDesired(0,0,0);  		back = ColourDesired(0xff,0xff,0xff); +		alpha = SC_ALPHA_NOALPHA;  		delete pxpm;  		pxpm = NULL;  		return *this; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index f221af193..930427bb8 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -73,6 +73,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {  	selbackset = source.selbackset;  	selbackground.desired = source.selbackground.desired;  	selbackground2.desired = source.selbackground2.desired; +	selAlpha = source.selAlpha;  	foldmarginColourSet = source.foldmarginColourSet;  	foldmarginColour.desired = source.foldmarginColour.desired; @@ -141,6 +142,7 @@ void ViewStyle::Init() {  	selbackset = true;  	selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);  	selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0); +	selAlpha = SC_ALPHA_NOALPHA;  	foldmarginColourSet = false;  	foldmarginColour.desired = ColourDesired(0xff, 0, 0); diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 90d50b1fb..d0cb87f21 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -53,6 +53,7 @@ public:  	bool selbackset;  	ColourPair selbackground;  	ColourPair selbackground2; +	int selAlpha;  	bool whitespaceForegroundSet;  	ColourPair whitespaceForeground;  	bool whitespaceBackgroundSet; | 
