diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Document.cxx | 6 | ||||
| -rw-r--r-- | src/Document.h | 2 | ||||
| -rw-r--r-- | src/Editor.cxx | 33 | ||||
| -rw-r--r-- | src/Editor.h | 4 | ||||
| -rw-r--r-- | src/PositionCache.cxx | 1 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 1 | ||||
| -rw-r--r-- | src/XPM.h | 6 | 
7 files changed, 26 insertions, 27 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 74c152e85..e7bb9c009 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -15,6 +15,7 @@  #include <string>  #include <vector>  #include <algorithm> +#include <memory>  #define NOEXCEPT @@ -140,8 +141,7 @@ Document::~Document() {  		delete perLineData[j];  		perLineData[j] = 0;  	} -	delete regex; -	regex = 0; +	regex.release();  	delete pli;  	pli = 0;  	delete pcf; @@ -1848,7 +1848,7 @@ long Document::FindText(int minPos, int maxPos, const char *search,  	const bool regExp = (flags & SCFIND_REGEXP) != 0;  	if (regExp) {  		if (!regex) -			regex = CreateRegexSearch(&charClass); +			regex = std::unique_ptr<RegexSearchBase>(CreateRegexSearch(&charClass));  		return regex->FindText(this, minPos, maxPos, search, caseSensitive, word, wordStart, flags, length);  	} else { diff --git a/src/Document.h b/src/Document.h index 2f6531e9f..a76c97141 100644 --- a/src/Document.h +++ b/src/Document.h @@ -234,7 +234,7 @@ private:  	PerLine *perLineData[ldSize];  	bool matchesValid; -	RegexSearchBase *regex; +	std::unique_ptr<RegexSearchBase> regex;  public: diff --git a/src/Editor.cxx b/src/Editor.cxx index cee9cebd7..e5fbc69be 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -816,7 +816,7 @@ void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos,  	if (ensureVisible) {  		// In case in need of wrapping to ensure DisplayFromDoc works.  		if (currentLine >= wrapPending.start) -			WrapLines(wsAll); +			WrapLines(WrapScope::wsAll);  		XYScrollPosition newXY = XYScrollToMakeVisible(  			SelectionRange(posDrag.IsValid() ? posDrag : newPos), xysDefault);  		if (previousPos.IsValid() && (newXY.xOffset == xOffset)) { @@ -1476,7 +1476,7 @@ bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {  // wsVisible: wrap currently visible lines  // wsIdle: wrap one page + 100 lines  // Return true if wrapping occurred. -bool Editor::WrapLines(enum wrapScope ws) { +bool Editor::WrapLines(WrapScope ws) {  	int goodTopLine = topLine;  	bool wrapOccurred = false;  	if (!Wrapping()) { @@ -1494,14 +1494,14 @@ bool Editor::WrapLines(enum wrapScope ws) {  		wrapPending.start = std::min(wrapPending.start, pdoc->LinesTotal());  		if (!SetIdle(true)) {  			// Idle processing not supported so full wrap required. -			ws = wsAll; +			ws = WrapScope::wsAll;  		}  		// Decide where to start wrapping  		int lineToWrap = wrapPending.start;  		int lineToWrapEnd = std::min(wrapPending.end, pdoc->LinesTotal());  		const int lineDocTop = cs.DocFromDisplay(topLine);  		const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop); -		if (ws == wsVisible) { +		if (ws == WrapScope::wsVisible) {  			lineToWrap = Platform::Clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());  			// Priority wrap to just after visible area.  			// Since wrapping could reduce display lines, treat each @@ -1518,7 +1518,7 @@ bool Editor::WrapLines(enum wrapScope ws) {  				// Currently visible text does not need wrapping  				return false;  			} -		} else if (ws == wsIdle) { +		} else if (ws == WrapScope::wsIdle) {  			lineToWrapEnd = lineToWrap + LinesOnScreen() + 100;  		}  		const int lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal()); @@ -1711,7 +1711,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {  	}  	// Wrap the visible lines if needed. -	if (WrapLines(wsVisible)) { +	if (WrapLines(WrapScope::wsVisible)) {  		// The wrapping process has changed the height of some lines so  		// abandon this paint for a complete repaint.  		if (AbandonPaint()) { @@ -1872,10 +1872,6 @@ void Editor::FilterSelections() {  	}  } -static bool cmpSelPtrs(const SelectionRange *a, const SelectionRange *b) { -	return *a < *b; -} -  // AddCharUTF inserts an array of bytes which may or may not be in UTF-8.  void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {  	FilterSelections(); @@ -1888,7 +1884,8 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {  			selPtrs.push_back(&sel.Range(r));  		}  		// Order selections by position in document. -		std::sort(selPtrs.begin(), selPtrs.end(), cmpSelPtrs); +		std::sort(selPtrs.begin(), selPtrs.end(), +			[](const SelectionRange *a, const SelectionRange *b) {return *a < *b;});  		// Loop in reverse to avoid disturbing positions of selections yet to be processed.  		for (std::vector<SelectionRange *>::reverse_iterator rit = selPtrs.rbegin(); @@ -4029,15 +4026,15 @@ long Editor::SearchText(  std::string Editor::CaseMapString(const std::string &s, int caseMapping) {  	std::string ret(s); -	for (size_t i=0; i<ret.size(); i++) { +	for (char &ch : ret) {  		switch (caseMapping) {  			case cmUpper: -				if (ret[i] >= 'a' && ret[i] <= 'z') -					ret[i] = static_cast<char>(ret[i] - 'a' + 'A'); +				if (ch >= 'a' && ch <= 'z') +					ch = static_cast<char>(ch - 'a' + 'A');  				break;  			case cmLower: -				if (ret[i] >= 'A' && ret[i] <= 'Z') -					ret[i] = static_cast<char>(ret[i] - 'A' + 'a'); +				if (ch >= 'A' && ch <= 'Z') +					ch = static_cast<char>(ch - 'A' + 'a');  				break;  		}  	} @@ -4934,7 +4931,7 @@ bool Editor::Idle() {  	if (needWrap) {  		// Wrap lines during idle. -		WrapLines(wsIdle); +		WrapLines(WrapScope::wsIdle);  		// No more wrapping  		needWrap = wrapPending.NeedsWrap();  	} else if (needIdleStyling) { @@ -5373,7 +5370,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {  	// In case in need of wrapping to ensure DisplayFromDoc works.  	if (lineDoc >= wrapPending.start) -		WrapLines(wsAll); +		WrapLines(WrapScope::wsAll);  	if (!cs.GetVisible(lineDoc)) {  		// Back up to find a non-blank line diff --git a/src/Editor.h b/src/Editor.h index c29985c78..985f64bae 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -372,8 +372,8 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	bool Wrapping() const;  	void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge);  	bool WrapOneLine(Surface *surface, int lineToWrap); -	enum wrapScope {wsAll, wsVisible, wsIdle}; -	bool WrapLines(enum wrapScope ws); +	enum class WrapScope {wsAll, wsVisible, wsIdle}; +	bool WrapLines(WrapScope ws);  	void LinesJoin();  	void LinesSplit(int pixelWidth); diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 45731601a..a46c13004 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -15,6 +15,7 @@  #include <vector>  #include <map>  #include <algorithm> +#include <memory>  #include "Platform.h" diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 678dd1487..27ed95135 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -16,6 +16,7 @@  #include <vector>  #include <map>  #include <algorithm> +#include <memory>  #include "Platform.h" @@ -43,9 +43,9 @@ private:   * A translucent image stored as a sequence of RGBA bytes.   */  class RGBAImage { -	// Private so RGBAImage objects can not be copied -	RGBAImage(const RGBAImage &); -	RGBAImage &operator=(const RGBAImage &); +	// Deleted so RGBAImage objects can not be copied +	RGBAImage(const RGBAImage &) = delete; +	RGBAImage &operator=(const RGBAImage &) = delete;  	int height;  	int width;  	float scale; | 
