aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/EditView.cxx12
-rw-r--r--src/Editor.cxx24
-rw-r--r--src/Editor.h2
-rw-r--r--src/PositionCache.cxx13
-rw-r--r--src/PositionCache.h10
-rw-r--r--src/XPM.cxx6
-rw-r--r--src/XPM.h8
7 files changed, 37 insertions, 38 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx
index b2b2c7552..7616324f1 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -458,7 +458,7 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa
ll->positions[0] = 0;
bool lastSegItalics = false;
- BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, NULL);
+ BreakFinder bfLayout(ll, nullptr, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, nullptr);
while (bfLayout.More()) {
const TextSegment ts = bfLayout.Next();
@@ -1186,7 +1186,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
}
}
-static bool AnnotationBoxedOrIndented(int annotationVisible) {
+static constexpr bool AnnotationBoxedOrIndented(int annotationVisible) noexcept {
return annotationVisible == ANNOTATION_BOXED || annotationVisible == ANNOTATION_INDENTED;
}
@@ -1449,7 +1449,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
// Does not take margin into account but not significant
const int xStartVisible = static_cast<int>(subLineStart)-xStart;
- BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, NULL);
+ BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, nullptr);
const bool drawWhitespaceBackground = vsDraw.WhitespaceBackgroundDrawn() && !background.isSet;
@@ -2025,7 +2025,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
(vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD)));
Sci::Line lineDocPrevious = -1; // Used to avoid laying out one document line multiple times
- AutoLineLayout ll(llc, 0);
+ AutoLineLayout ll(llc, nullptr);
std::vector<DrawPhase> phases;
if ((phasesDraw == phasesMultiple) && !bufferedDraw) {
for (DrawPhase phase = drawBack; phase <= drawCarets; phase = static_cast<DrawPhase>(phase * 2)) {
@@ -2054,7 +2054,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
ElapsedPeriod ep;
#endif
if (lineDoc != lineDocPrevious) {
- ll.Set(0);
+ ll.Set(nullptr);
ll.Set(RetrieveLineLayout(lineDoc, model));
LayoutLine(model, lineDoc, surface, vsDraw, ll, model.wrapWidth);
lineDocPrevious = lineDoc;
@@ -2123,7 +2123,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
visibleLine++;
}
}
- ll.Set(0);
+ ll.Set(nullptr);
#if defined(TIME_PAINTING)
if (durPaint < 0.00000001)
durPaint = 0.00000001;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 7ceef1c50..6fc49d971 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -245,7 +245,7 @@ void Editor::SetRepresentations() {
} else if (pdoc->dbcsCodePage) {
// DBCS invalid single lead bytes
for (int k = 0x80; k < 0x100; k++) {
- char ch = static_cast<char>(k);
+ const char ch = static_cast<char>(k);
if (pdoc->IsDBCSLeadByteNoExcept(ch) || pdoc->IsDBCSLeadByteInvalid(ch)) {
const char hiByte[2] = { ch, 0 };
char hexits[5]; // Really only needs 4 but that causes warning from gcc 7.1
@@ -2281,7 +2281,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
ShowCaretAtCurrentPosition();
}
-int Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta, bool super) {
+int Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta, bool super) noexcept {
return
(shift ? SCI_SHIFT : 0) |
(ctrl ? SCI_CTRL : 0) |
@@ -3207,11 +3207,11 @@ Sci::Position Editor::StartEndDisplayLine(Sci::Position pos, bool start) {
namespace {
-short HighShortFromLong(long x) {
+constexpr short HighShortFromWParam(uptr_t x) {
return static_cast<short>(x >> 16);
}
-short LowShortFromLong(long x) {
+constexpr short LowShortFromWParam(uptr_t x) {
return static_cast<short>(x & 0xffff);
}
@@ -4069,7 +4069,7 @@ Sci::Position Editor::SearchText(
sptr_t lParam) { ///< The text to search for.
const char *txt = CharPtrFromSPtr(lParam);
- Sci::Position pos;
+ Sci::Position pos = INVALID_POSITION;
Sci::Position lengthFound = strlen(txt);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
@@ -4085,9 +4085,9 @@ Sci::Position Editor::SearchText(
}
} catch (RegexError &) {
errorStatus = SC_STATUS_WARN_REGEX;
- return -1;
+ return INVALID_POSITION;
}
- if (pos != -1) {
+ if (pos != INVALID_POSITION) {
SetSelection(pos, pos + lengthFound);
}
@@ -4460,7 +4460,7 @@ void Editor::MouseLeave() {
}
}
-static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) {
+static constexpr bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) noexcept {
return (!rectangular && ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0))
|| (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0));
}
@@ -7264,13 +7264,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.caretWidth;
case SCI_ASSIGNCMDKEY:
- kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)),
- HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));
+ kmap.AssignCmdKey(LowShortFromWParam(wParam),
+ HighShortFromWParam(wParam), static_cast<unsigned int>(lParam));
break;
case SCI_CLEARCMDKEY:
- kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)),
- HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);
+ kmap.AssignCmdKey(LowShortFromWParam(wParam),
+ HighShortFromWParam(wParam), SCI_NULL);
break;
case SCI_CLEARALLCMDKEYS:
diff --git a/src/Editor.h b/src/Editor.h
index bc295260e..e9a0bbf8f 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -412,7 +412,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void DelCharBack(bool allowLineStartDeletion);
virtual void ClaimSelection() = 0;
- static int ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false, bool super=false);
+ static int ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false, bool super=false) noexcept;
virtual void NotifyChange() = 0;
virtual void NotifyFocus(bool focus);
virtual void SetCtrlID(int identifier);
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index df58aa9a7..4d8752e95 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -57,12 +57,11 @@ LineLayout::LineLayout(int maxLineLength_) :
highlightColumn(false),
containsCaret(false),
edgeColumn(0),
+ bracePreviousStyles{},
hotspot(0,0),
widthLine(wrapWidthInfinite),
lines(1),
wrapIndent(0) {
- bracePreviousStyles[0] = 0;
- bracePreviousStyles[1] = 0;
Resize(maxLineLength_);
}
@@ -318,7 +317,7 @@ LineLayout *LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci::Line lineCaret,
}
allInvalidated = false;
Sci::Position pos = -1;
- LineLayout *ret = 0;
+ LineLayout *ret = nullptr;
if (level == llcCaret) {
pos = 0;
} else if (level == llcPage) {
@@ -408,12 +407,12 @@ const Representation *SpecialRepresentations::RepresentationFromCharacter(const
PLATFORM_ASSERT(len <= 4);
const unsigned char ucStart = charBytes[0];
if (!startByteHasReprs[ucStart])
- return 0;
+ return nullptr;
MapRepresentation::const_iterator it = mapReprs.find(KeyFromString(charBytes, len));
if (it != mapReprs.end()) {
return &(it->second);
}
- return 0;
+ return nullptr;
}
bool SpecialRepresentations::Contains(const char *charBytes, size_t len) const {
@@ -432,7 +431,7 @@ void SpecialRepresentations::Clear() {
}
void BreakFinder::Insert(Sci::Position val) {
- int posInLine = static_cast<int>(val);
+ const int posInLine = static_cast<int>(val);
if (posInLine > nextBreak) {
const std::vector<int>::iterator it = std::lower_bound(selAndEdge.begin(), selAndEdge.end(), posInLine);
if (it == selAndEdge.end()) {
@@ -522,7 +521,7 @@ TextSegment BreakFinder::Next() {
if (nextBreak == prev) {
nextBreak += charWidth;
} else {
- repr = 0; // Optimize -> should remember repr
+ repr = nullptr; // Optimize -> should remember repr
}
if ((nextBreak - prev) < lengthStartSubdivision) {
return TextSegment(prev, nextBreak - prev, repr);
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 7f50c4dec..bc70b7f4e 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -10,10 +10,14 @@
namespace Scintilla {
-static inline bool IsEOLChar(char ch) {
+inline constexpr bool IsEOLChar(int ch) noexcept {
return (ch == '\r') || (ch == '\n');
}
+inline constexpr bool IsSpaceOrTab(int ch) noexcept {
+ return ch == ' ' || ch == '\t';
+}
+
/**
* A point in document space.
* Uses double for sufficient resolution in large (>20,000,000 line) documents.
@@ -238,10 +242,6 @@ public:
const char *s, unsigned int len, XYPOSITION *positions, const Document *pdoc);
};
-inline bool IsSpaceOrTab(int ch) {
- return ch == ' ' || ch == '\t';
-}
-
}
#endif
diff --git a/src/XPM.cxx b/src/XPM.cxx
index b2cb6776a..6de9ce98b 100644
--- a/src/XPM.cxx
+++ b/src/XPM.cxx
@@ -57,9 +57,9 @@ unsigned int ValueOfHex(const char ch) noexcept {
}
ColourDesired ColourFromHex(const char *val) noexcept {
- unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]);
- unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]);
- unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]);
+ const unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]);
+ const unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]);
+ const unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]);
return ColourDesired(r, g, b);
}
diff --git a/src/XPM.h b/src/XPM.h
index 92deb9e8a..c3c1fc3b3 100644
--- a/src/XPM.h
+++ b/src/XPM.h
@@ -14,12 +14,12 @@ namespace Scintilla {
* Hold a pixmap in XPM format.
*/
class XPM {
- int height;
- int width;
- int nColours;
+ int height=1;
+ int width=1;
+ int nColours=1;
std::vector<unsigned char> pixels;
ColourDesired colourCodeTable[256];
- char codeTransparent;
+ char codeTransparent=' ';
ColourDesired ColourFromCode(int ch) const;
void FillRun(Surface *surface, int code, int startX, int y, int x) const;
public: