diff options
| author | nyamatongwe <devnull@localhost> | 2007-04-05 10:50:11 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2007-04-05 10:50:11 +0000 | 
| commit | 2a30f053fd7ad4d9dcb8a5a39a3bf4da06f344e8 (patch) | |
| tree | 04c2ad1b9fd3359de89792aeaa9567b9edd56628 /src | |
| parent | d86e4efcf67d2fe73cd74c01f15318fa95d28f5a (diff) | |
| download | scintilla-mirror-2a30f053fd7ad4d9dcb8a5a39a3bf4da06f344e8.tar.gz | |
Implemented decorations which are extended indicators.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Document.cxx | 2 | ||||
| -rw-r--r-- | src/Document.h | 2 | ||||
| -rw-r--r-- | src/DocumentAccessor.cxx | 2 | ||||
| -rw-r--r-- | src/Editor.cxx | 157 | ||||
| -rw-r--r-- | src/Editor.h | 3 | ||||
| -rw-r--r-- | src/Partitioning.h | 2 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 2 | ||||
| -rw-r--r-- | src/SplitVector.h | 4 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 3 | 
9 files changed, 140 insertions, 37 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 8bc1a70b0..964d4808b 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -16,8 +16,10 @@  #include "SVector.h"  #include "SplitVector.h"  #include "Partitioning.h" +#include "RunStyles.h"  #include "CellBuffer.h"  #include "CharClassify.h" +#include "Decoration.h"  #include "Document.h"  #include "RESearch.h" diff --git a/src/Document.h b/src/Document.h index 829ecbd81..90b4fe1b5 100644 --- a/src/Document.h +++ b/src/Document.h @@ -122,6 +122,8 @@ public:  	bool tabIndents;  	bool backspaceUnindents; +	DecorationList decorations; +  	Document();  	virtual ~Document(); diff --git a/src/DocumentAccessor.cxx b/src/DocumentAccessor.cxx index e764bfeac..afe4670a4 100644 --- a/src/DocumentAccessor.cxx +++ b/src/DocumentAccessor.cxx @@ -18,9 +18,11 @@  #include "DocumentAccessor.h"  #include "SplitVector.h"  #include "Partitioning.h" +#include "RunStyles.h"  #include "CellBuffer.h"  #include "Scintilla.h"  #include "CharClassify.h" +#include "Decoration.h"  #include "Document.h"  DocumentAccessor::~DocumentAccessor() { diff --git a/src/Editor.cxx b/src/Editor.cxx index 06ed59144..cdbd81474 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -23,12 +23,14 @@  #include "Partitioning.h"  #include "CellBuffer.h"  #include "KeyMap.h" +#include "RunStyles.h"  #include "Indicator.h"  #include "XPM.h"  #include "LineMarker.h"  #include "Style.h"  #include "ViewStyle.h"  #include "CharClassify.h" +#include "Decoration.h"  #include "Document.h"  #include "Editor.h" @@ -2308,6 +2310,73 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin  	}  } +void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +                      PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) { +	// Draw decorators +	const int posLineStart = pdoc->LineStart(line); +	const int lineStart = ll->LineStart(subLine); +	const int subLineStart = ll->positions[lineStart]; +	const int posLineEnd = posLineStart + lineEnd; + +	if (!under) { +		// Draw indicators +		// foreach indicator... +		for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) { +			if (!(mask & ll->styleBitsSet)) { +				mask <<= 1; +				continue; +			} +			int startPos = -1; +			// foreach style pos in line... +			for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { +				// look for starts... +				if (startPos < 0) { +					// NOT in indicator run, looking for START +					if (indicPos < lineEnd && (ll->indicators[indicPos] & mask)) +						startPos = indicPos; +				} +				// ... or ends +				if (startPos >= 0) { +					// IN indicator run, looking for END +					if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) { +						// AT end of indicator run, DRAW it! +						PRectangle rcIndic( +							ll->positions[startPos] + xStart - subLineStart, +							rcLine.top + vsDraw.maxAscent, +							ll->positions[indicPos] + xStart - subLineStart, +							rcLine.top + vsDraw.maxAscent + 3); +						vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine); +						// RESET control var +						startPos = -1; +					} +				} +			} +			mask <<= 1; +		} +	} + +	for (Decoration *deco=pdoc->decorations.root; deco; deco = deco->next) { +		if (under == (deco->indicator >= 16)) { +			int startPos = posLineStart + subLineStart; +			if (!deco->rs.ValueAt(startPos)) { +				startPos = deco->rs.EndRun(startPos); +			} +			while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) { +				int endPos = deco->rs.EndRun(startPos); +				if (endPos > posLineEnd) +					endPos = posLineEnd; +				PRectangle rcIndic( +					ll->positions[startPos - posLineStart] + xStart - subLineStart, +					rcLine.top + vsDraw.maxAscent, +					ll->positions[endPos - posLineStart] + xStart - subLineStart, +					rcLine.top + vsDraw.maxAscent + 3); +				vsDraw.indicators[deco->indicator].Draw(surface, rcIndic, rcLine); +				startPos = deco->rs.EndRun(endPos); +			} +		} +	} +} +  void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,                        PRectangle rcLine, LineLayout *ll, int subLine) { @@ -2486,6 +2555,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  		        drawWrapMarkEnd, wrapColour);  	} +	DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true); +  	if (vsDraw.edgeState == EDGE_LINE) {  		int edgeX = theEdge * vsDraw.spaceWidth;  		rcSegment.left = edgeX + xStart; @@ -2651,40 +2722,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  		}  	} -	// Draw indicators -	// foreach indicator... -	for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) { -		if (!(mask & ll->styleBitsSet)) { -			mask <<= 1; -			continue; -		} -		int startPos = -1; -		// foreach style pos in line... -		for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { -			// look for starts... -			if (startPos < 0) { -				// NOT in indicator run, looking for START -				if (indicPos < lineEnd && (ll->indicators[indicPos] & mask)) -					startPos = indicPos; -			} -			// ... or ends -			if (startPos >= 0) { -				// IN indicator run, looking for END -				if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) { -					// AT end of indicator run, DRAW it! -					PRectangle rcIndic( -						ll->positions[startPos] + xStart - subLineStart, -						rcLine.top + vsDraw.maxAscent, -						ll->positions[indicPos] + xStart - subLineStart, -						rcLine.top + vsDraw.maxAscent + 3); -					vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine); -					// RESET control var -					startPos = -1; -				} -			} -		} -		mask <<= 1; -	} +	DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, false); +  	// End of the drawing of the current line  	if (!twoPhaseDraw) {  		DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, @@ -3678,6 +3717,18 @@ void Editor::NotifyPainted() {  	NotifyParent(scn);  } +void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) { +	int mask = pdoc->decorations.AllOnFor(position); +	if ((click && mask) || pdoc->decorations.clickNotified) { +		SCNotification scn = {0}; +		pdoc->decorations.clickNotified = click; +		scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE; +		scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); +		scn.position = position; +		NotifyParent(scn); +	} +} +  bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) {  	int marginClicked = -1;  	int x = 0; @@ -3798,11 +3849,13 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) {  			anchor = MovePositionForInsertion(anchor, mh.position, mh.length);  			braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length);  			braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length); +			pdoc->decorations.InsertSpace(mh.position, mh.length);  		} else if (mh.modificationType & SC_MOD_DELETETEXT) {  			currentPos = MovePositionForDeletion(currentPos, mh.position, mh.length);  			anchor = MovePositionForDeletion(anchor, mh.position, mh.length);  			braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length);  			braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length); +			pdoc->decorations.DeleteRange(mh.position, mh.length);  		}  		if (cs.LinesDisplayed() < cs.LinesInDoc()) {  			// Some lines are hidden so may need shown. @@ -5116,6 +5169,8 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b  	if (processed)  		return; +	NotifyIndicatorClick(true, newPos, shift, ctrl, alt); +  	bool inSelMargin = PointInSelMargin(pt);  	if (shift & !inSelMargin) {  		SetSelection(newPos); @@ -5370,6 +5425,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {  		SetMouseCapture(false);  		int newPos = PositionFromLocation(pt);  		newPos = MovePositionOutsideChar(newPos, currentPos - newPos); +		NotifyIndicatorClick(false, newPos, false, false, false);  		if (inDragDrop) {  			int selStart = SelectionStart();  			int selEnd = SelectionEnd(); @@ -7079,6 +7135,39 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  	case SCI_INDICGETFORE:  		return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.desired.AsLong() : 0; +	case SCI_SETINDICATORCURRENT: +		pdoc->decorations.SetCurrentIndicator(wParam); +		break; +	case SCI_GETINDICATORCURRENT: +		return pdoc->decorations.GetCurrentIndicator(); +	case SCI_SETINDICATORVALUE: +		pdoc->decorations.SetCurrentValue(wParam); +		break; +	case SCI_GETINDICATORVALUE: +		return pdoc->decorations.GetCurrentValue(); + +	case SCI_INDICATORFILLRANGE: +		pdoc->decorations.FillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam); +		InvalidateRange(wParam, wParam + lParam); +		break; + +	case SCI_INDICATORCLEARRANGE: +		pdoc->decorations.FillRange(wParam, 0, lParam); +		InvalidateRange(wParam, wParam + lParam); +		break; + +	case SCI_INDICATORALLONFOR: +		return pdoc->decorations.AllOnFor(wParam); + +	case SCI_INDICATORVALUEAT: +		return pdoc->decorations.ValueAt(wParam, lParam); + +	case SCI_INDICATORSTART: +		return pdoc->decorations.Start(wParam, lParam); + +	case SCI_INDICATOREND: +		return pdoc->decorations.End(wParam, lParam); +  	case SCI_LINEDOWN:  	case SCI_LINEDOWNEXTEND:  	case SCI_PARADOWN: diff --git a/src/Editor.h b/src/Editor.h index 3399b70c7..04bf21958 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -395,6 +395,8 @@ protected:	// ScintillaBase subclass needs access to much of Editor  		int line, int lineEnd, int xStart, int subLine, int subLineStart,  		bool overrideBackground, ColourAllocated background,  		bool drawWrapMark, ColourAllocated wrapColour); +	void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +		PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);  	void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,  		PRectangle rcLine, LineLayout *ll, int subLine=0);  	void RefreshPixMaps(Surface *surfaceWindow); @@ -441,6 +443,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);  	void NotifyUpdateUI();  	void NotifyPainted(); +	void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);  	bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);  	void NotifyNeedShown(int pos, int len);  	void NotifyDwelling(Point pt, bool state); diff --git a/src/Partitioning.h b/src/Partitioning.h index e30189d75..175eba7b5 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -86,7 +86,7 @@ public:  	~Partitioning() {  		delete body; -		body = NULL; +		body = 0;  	}  	int Partitions() { diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 0f3b3c093..52a0e2c2c 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -24,6 +24,7 @@  #include "SVector.h"  #include "SplitVector.h"  #include "Partitioning.h" +#include "RunStyles.h"  #include "CellBuffer.h"  #include "CallTip.h"  #include "KeyMap.h" @@ -34,6 +35,7 @@  #include "ViewStyle.h"  #include "AutoComplete.h"  #include "CharClassify.h" +#include "Decoration.h"  #include "Document.h"  #include "Editor.h"  #include "ScintillaBase.h" diff --git a/src/SplitVector.h b/src/SplitVector.h index 4b9875b4a..342be02ad 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -66,7 +66,7 @@ public:  	~SplitVector() {  		delete []body; -		body = NULL; +		body = 0;  	}  	int GetGrowSize() const { @@ -85,7 +85,7 @@ public:  			// Move the gap to the end  			GapTo(lengthBody);  			T *newBody = new T[newSize]; -			if ((size != 0) && (body != NULL)) { +			if ((size != 0) && (body != 0)) {  				memmove(newBody, body, sizeof(T) * lengthBody);  				delete []body;  			} diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index b6b14da9b..403d17a3a 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -10,6 +10,9 @@  #include "Platform.h"  #include "Scintilla.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h"  #include "Indicator.h"  #include "XPM.h"  #include "LineMarker.h" | 
