diff options
| -rw-r--r-- | include/Scintilla.h | 4 | ||||
| -rw-r--r-- | include/Scintilla.iface | 12 | ||||
| -rw-r--r-- | src/Editor.cxx | 45 | ||||
| -rw-r--r-- | src/Editor.h | 1 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 6 | ||||
| -rw-r--r-- | src/ViewStyle.h | 2 | 
6 files changed, 57 insertions, 13 deletions
| diff --git a/include/Scintilla.h b/include/Scintilla.h index da708d16b..cc9eeb593 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -178,6 +178,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_SETLINESTATE 2092  #define SCI_GETLINESTATE 2093  #define SCI_GETMAXLINESTATE 2094 +#define SCI_GETCARETLINEVISIBLE 2095 +#define SCI_SETCARETLINEVISIBLE 2096 +#define SCI_GETCARETLINEBACK 2097 +#define SCI_SETCARETLINEBACK 2098  #define SCI_AUTOCSHOW 2100  #define SCI_AUTOCCANCEL 2101  #define SCI_AUTOCACTIVE 2102 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index e542785fc..cb524f185 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -411,6 +411,18 @@ get int GetLineState=2093(int line,)  # Retrieve the last line number that has line state.  get int GetMaxLineState=2094(,) +# Is the background of the line containing the caret in a different colour? +get bool GetCaretLineVisible=2095(,) + +# Dsplay the background of the line containing the caret in a different colour. +set void SetCaretLineVisible=2096(bool show,) + +# Get the colour of the background of the line containing the caret. +get colour GetCaretLineBack=2097(,) + +# Set the colour of the background of the line containing the caret. +set void SetCaretLineBack=2098(colour back,) +  # Display a auto-completion list.  # The lenEntered parameter indicates how many characters before  # the caret should be used to provide context. diff --git a/src/Editor.cxx b/src/Editor.cxx index 738f25c05..afc127c07 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -876,19 +876,23 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  	// is taken by an individual character - internal leading gives varying results.  	Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; -	int marks = 0; -	Colour markBack = Colour(0, 0, 0); +	bool overrideBackground = false; +	Colour background = Colour(0, 0, 0); +	if (vsDraw.showCaretLineBackground && ll.containsCaret) { +		overrideBackground = true; +		background = vsDraw.caretLineBackground.allocated; +	}  	if (vsDraw.maskInLine) { -		marks = pdoc->GetMark(line) & vsDraw.maskInLine; +		int marks = pdoc->GetMark(line) & vsDraw.maskInLine;  		if (marks) { +			overrideBackground = true;  			for (int markBit = 0; (markBit < 32) && marks; markBit++) {  				if (marks & 1) { -					markBack = vsDraw.markers[markBit].back.allocated; +					background = vsDraw.markers[markBit].back.allocated;  				}  				marks >>= 1;  			}  		} -		marks = pdoc->GetMark(line) & vsDraw.maskInLine;  	}  	bool inIndentation = true; @@ -924,8 +928,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  				if (vsDraw.selforeset)  					textFore = vsDraw.selforeground.allocated;  			} else { -				if (marks) -					textBack = markBack; +				if (overrideBackground) +					textBack = background;  				if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll.edgeColumn) && (ll.chars[i] != '\n') && (ll.chars[i] != '\r'))  					textBack = vsDraw.edgecolour.allocated;  			} @@ -1064,16 +1068,16 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  			surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated);  		else  			surface->FillRectangle(rcSegment, vsDraw.selbackground2.allocated); -	} else if (marks) { -		surface->FillRectangle(rcSegment, markBack); +	} else if (overrideBackground) { +		surface->FillRectangle(rcSegment, background);  	} else {  		surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated);  	}  	rcSegment.left = xEol + vsDraw.aveCharWidth + xStart;  	rcSegment.right = rcLine.right; -	if (marks) { -		surface->FillRectangle(rcSegment, markBack); +	if (overrideBackground) { +		surface->FillRectangle(rcSegment, background);  	} else if (vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].eolFilled) {  		surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated);  	} else { @@ -1223,9 +1227,11 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {  			ll.selStart = SelectionStart(line);  			ll.selEnd = SelectionEnd(line); +			ll.containsCaret = line == lineCaret;  			if (hideSelection) {  				ll.selStart = -1;  				ll.selEnd = -1; +				ll.containsCaret = false;  			}  			// Need to fix this up so takes account of Unicode and DBCS  			ll.edgeColumn = theEdge; @@ -1400,7 +1406,8 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {  	// Don't show the selection when printing  	vsPrint.selbackset = false;  	vsPrint.selforeset = false; - +	vsPrint.showCaretLineBackground = false; +	  	// Set colours for printing according to users settings  	for (int sty = 0;sty <= STYLE_MAX;sty++) {  		if (printColourMode == SC_PRINT_INVERTLIGHT) { @@ -1469,6 +1476,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {  			LayoutLine(line, surfaceMeasure, vsPrint, ll);  			ll.selStart = -1;  			ll.selEnd = -1; +			ll.containsCaret = false;  			// Need to fix this up so takes account of Unicode and DBCS  			ll.edgeColumn = theEdge; @@ -4183,6 +4191,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  	case SCI_GETMAXLINESTATE:  		return pdoc->GetMaxLineState(); +	case SCI_GETCARETLINEVISIBLE: +		return vs.showCaretLineBackground; +	case SCI_SETCARETLINEVISIBLE: +		vs.showCaretLineBackground = wParam; +		InvalidateStyleRedraw(); +		break; +	case SCI_GETCARETLINEBACK: +		return vs.caretLineBackground.desired.AsLong(); +	case SCI_SETCARETLINEBACK: +		vs.caretLineBackground.desired = wParam; +		InvalidateStyleRedraw(); +		break; +	  		// Folding messages  	case SCI_VISIBLEFROMDOCLINE: diff --git a/src/Editor.h b/src/Editor.h index 73d15e340..cf3996ffa 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -42,6 +42,7 @@ public:  	bool highlightColumn;  	int selStart;  	int selEnd; +	bool containsCaret;  	int edgeColumn;  	char chars[maxLineLength+1];  	char styles[maxLineLength+1]; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index c3d6b5008..9d19c418e 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -75,6 +75,8 @@ ViewStyle::ViewStyle(const ViewStyle &source) {  	selbar.desired = source.selbar.desired;  	selbarlight.desired = source.selbarlight.desired;  	caretcolour.desired = source.caretcolour.desired; +	showCaretLineBackground = source.showCaretLineBackground; +	caretLineBackground.desired = source.caretLineBackground.desired;  	edgecolour.desired = source.edgecolour.desired;  	edgeState = source.edgeState;  	caretWidth = source.caretWidth; @@ -122,8 +124,9 @@ void ViewStyle::Init() {  	selbarlight.desired = Platform::ChromeHighlight();  	styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0);  	styles[STYLE_LINENUMBER].back.desired = Platform::Chrome(); -	//caretcolour.desired = Colour(0xff, 0, 0);  	caretcolour.desired = Colour(0, 0, 0); +	showCaretLineBackground = false; +	caretLineBackground.desired = Colour(0xff, 0xff, 0);  	edgecolour.desired = Colour(0xc0, 0xc0, 0xc0);  	edgeState = EDGE_NONE;  	caretWidth = 1; @@ -176,6 +179,7 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {  	pal.WantFind(selbar, want);  	pal.WantFind(selbarlight, want);  	pal.WantFind(caretcolour, want); +	pal.WantFind(caretLineBackground, want);  	pal.WantFind(edgecolour, want);  } diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 63f2940c4..7528638c5 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -69,6 +69,8 @@ public:  	bool viewEOL;  	bool showMarkedLines;  	ColourPair caretcolour; +	bool showCaretLineBackground; +	ColourPair caretLineBackground;  	ColourPair edgecolour;  	int edgeState;  	int caretWidth; | 
