diff options
| author | Neil <nyamatongwe@gmail.com> | 2014-06-22 13:34:28 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2014-06-22 13:34:28 +1000 | 
| commit | 93c33490b77157f2e5422f4962ac4b88f4aea7c5 (patch) | |
| tree | 13a4dc633414313843a39ab24e29d997e570b308 | |
| parent | df60ea0a4ca15e7fcaad38b47cd8cf4cd642e68c (diff) | |
| download | scintilla-mirror-93c33490b77157f2e5422f4962ac4b88f4aea7c5.tar.gz | |
Further use of const in layout and drawing.
| -rw-r--r-- | src/Editor.cxx | 4 | ||||
| -rw-r--r-- | src/PositionCache.cxx | 14 | ||||
| -rw-r--r-- | src/PositionCache.h | 20 | 
3 files changed, 19 insertions, 19 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index d0f30b05d..e6a72e4cd 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2567,7 +2567,7 @@ void Editor::DrawEOL(Surface *surface, const ViewStyle &vsDraw, PRectangle rcLin  			if (UTF8IsAscii(chEOL)) {  				ctrlChar = ControlCharacterString(chEOL);  			} else { -				Representation *repr = reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos); +				const Representation *repr = reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos);  				if (repr) {  					ctrlChar = repr->stringRep.c_str();  					eolPos = ll->numCharsInLine; @@ -9260,7 +9260,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		break;  	case SCI_GETREPRESENTATION: { -			Representation *repr = reprs.RepresentationFromCharacter( +			const Representation *repr = reprs.RepresentationFromCharacter(  				reinterpret_cast<const char *>(wParam), UTF8MaxBytes);  			if (repr) {  				return StringResult(lParam, repr->stringRep.c_str()); diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 2badeffbc..e35a1714c 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -148,7 +148,7 @@ void LineLayout::SetLineStart(int line, int start) {  	lineStarts[line] = start;  } -void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], +void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[],                                      char bracesMatchStyle, int xHighlight, bool ignoreStyle) {  	if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {  		int braceOffset = braces[0] - rangeLine.start; @@ -170,7 +170,7 @@ void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],  	}  } -void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle) { +void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle) {  	if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {  		int braceOffset = braces[0] - rangeLine.start;  		if (braceOffset < numCharsInLine) { @@ -405,11 +405,11 @@ void SpecialRepresentations::ClearRepresentation(const char *charBytes) {  	}  } -Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) { +const Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) const {  	PLATFORM_ASSERT(len <= 4);  	if (!startByteHasReprs[static_cast<unsigned char>(charBytes[0])])  		return 0; -	MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, len)); +	MapRepresentation::const_iterator it = mapReprs.find(KeyFromString(charBytes, len));  	if (it != mapReprs.end()) {  		return &(it->second);  	} @@ -440,8 +440,8 @@ void BreakFinder::Insert(int val) {  	}  } -BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, -	int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_) : +BreakFinder::BreakFinder(const LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, +	int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_) :  	ll(ll_),  	lineStart(lineStart_),  	lineEnd(lineEnd_), @@ -495,7 +495,7 @@ TextSegment BreakFinder::Next() {  				charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(ll->chars) + nextBreak, lineEnd - nextBreak);  			else if (encodingFamily == efDBCS)  				charWidth = pdoc->IsDBCSLeadByte(ll->chars[nextBreak]) ? 2 : 1; -			Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth); +			const Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth);  			if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) ||  					repr ||  					(nextBreak == saeNext)) { diff --git a/src/PositionCache.h b/src/PositionCache.h index 53b407b71..e26b4b273 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -61,9 +61,9 @@ public:  	Range SubLineRange(int line) const;  	bool InLine(int offset, int line) const;  	void SetLineStart(int line, int start); -	void SetBracesHighlight(Range rangeLine, Position braces[], +	void SetBracesHighlight(Range rangeLine, const Position braces[],  		char bracesMatchStyle, int xHighlight, bool ignoreStyle); -	void RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle); +	void RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle);  	int FindBefore(XYPOSITION x, int lower, int upper) const;  	int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const;  	Point PointFromPosition(int posInLine, int lineHeight) const; @@ -130,7 +130,7 @@ public:  	SpecialRepresentations();  	void SetRepresentation(const char *charBytes, const char *value);  	void ClearRepresentation(const char *charBytes); -	Representation *RepresentationFromCharacter(const char *charBytes, size_t len); +	const Representation *RepresentationFromCharacter(const char *charBytes, size_t len) const;  	bool Contains(const char *charBytes, size_t len) const;  	void Clear();  }; @@ -138,8 +138,8 @@ public:  struct TextSegment {  	int start;  	int length; -	Representation *representation; -	TextSegment(int start_=0, int length_=0, Representation *representation_=0) : +	const Representation *representation; +	TextSegment(int start_=0, int length_=0, const Representation *representation_=0) :  		start(start_), length(length_), representation(representation_) {  	}  	int end() const { @@ -149,7 +149,7 @@ struct TextSegment {  // Class to break a line of text into shorter runs at sensible places.  class BreakFinder { -	LineLayout *ll; +	const LineLayout *ll;  	int lineStart;  	int lineEnd;  	int posLineStart; @@ -158,9 +158,9 @@ class BreakFinder {  	unsigned int saeCurrentPos;  	int saeNext;  	int subBreak; -	Document *pdoc; +	const Document *pdoc;  	EncodingFamily encodingFamily; -	SpecialRepresentations *preprs; +	const SpecialRepresentations *preprs;  	void Insert(int val);  	// Private so BreakFinder objects can not be copied  	BreakFinder(const BreakFinder &); @@ -170,8 +170,8 @@ public:  	enum { lengthStartSubdivision = 300 };  	// Try to make each subdivided run lengthEachSubdivision or shorter.  	enum { lengthEachSubdivision = 100 }; -	BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, -		int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_); +	BreakFinder(const LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, +		int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_);  	~BreakFinder();  	TextSegment Next();  	bool More() const; | 
