diff options
-rw-r--r-- | src/EditView.cxx | 9 | ||||
-rw-r--r-- | src/Editor.cxx | 12 | ||||
-rw-r--r-- | src/MarginView.cxx | 2 | ||||
-rw-r--r-- | src/Position.h | 2 | ||||
-rw-r--r-- | src/Style.cxx | 5 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 25 | ||||
-rw-r--r-- | src/ViewStyle.h | 4 |
7 files changed, 31 insertions, 28 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 137d4f4fe..08bdfb55c 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -186,8 +186,7 @@ EditView::EditView() { customDrawWrapMarker = nullptr; } -EditView::~EditView() { -} +EditView::~EditView() = default; bool EditView::SetTwoPhaseDraw(bool twoPhaseDraw) noexcept { const PhasesDraw phasesDrawNew = twoPhaseDraw ? PhasesDraw::two : PhasesDraw::one; @@ -376,7 +375,7 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa return; PLATFORM_ASSERT(line < model.pdoc->LinesTotal()); - PLATFORM_ASSERT(ll->chars != NULL); + PLATFORM_ASSERT(ll->chars); const Sci::Position posLineStart = model.pdoc->LineStart(line); Sci::Position posLineEnd = model.pdoc->LineStart(line + 1); // If the line is very long, limit the treatment to a length that should fit in the viewport @@ -525,6 +524,8 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa case SC_WRAPINDENT_DEEPINDENT: wrapAddIndent = model.pdoc->IndentSize() * 2 * vstyle.spaceWidth; break; + default: // No additional indent for SC_WRAPINDENT_FIXED + break; } ll->wrapIndent = wrapAddIndent; if (vstyle.wrap.indentMode != SC_WRAPINDENT_FIXED) { @@ -1979,7 +1980,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi textFore = *vsDraw.whitespaceColours.fore; const PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); - const int segmentTop = static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2); + const int segmentTop = static_cast<int>(rcSegment.top) + vsDraw.lineHeight / 2; if (!customDrawTabArrow) DrawTabArrow(surface, rcTab, segmentTop, vsDraw, Stroke(textFore, 1.0f)); else diff --git a/src/Editor.cxx b/src/Editor.cxx index 573bdb140..66b8fe47d 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -102,7 +102,7 @@ Timer::Timer() noexcept : ticking(false), ticksToWait(0), tickerID{} {} Idler::Idler() noexcept : - state(false), idlerID(0) {} + state(false), idlerID(nullptr) {} static constexpr bool IsAllSpacesOrTabs(std::string_view sv) noexcept { for (const char ch : sv) { @@ -188,7 +188,7 @@ Editor::Editor() : durationWrapOneLine(0.00001, 0.000001, 0.0001) { modEventMask = SC_MODEVENTMASKALL; commandEvents = true; - pdoc->AddWatcher(this, 0); + pdoc->AddWatcher(this, nullptr); recordingMacro = false; foldAutomatic = 0; @@ -199,7 +199,7 @@ Editor::Editor() : durationWrapOneLine(0.00001, 0.000001, 0.0001) { } Editor::~Editor() { - pdoc->RemoveWatcher(this, 0); + pdoc->RemoveWatcher(this, nullptr); DropGraphics(); } @@ -3959,7 +3959,7 @@ int Editor::KeyDefault(int, int) { int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) { DwellEnd(false); - const int msg = kmap.Find(key, modifiers); + const unsigned int msg = kmap.Find(key, modifiers); if (msg) { if (consumed) *consumed = true; @@ -5273,7 +5273,7 @@ void Editor::SetAnnotationHeights(Sci::Line start, Sci::Line end) { void Editor::SetDocPointer(Document *document) { //Platform::DebugPrintf("** %x setdoc to %x\n", pdoc, document); - pdoc->RemoveWatcher(this, 0); + pdoc->RemoveWatcher(this, nullptr); pdoc->Release(); if (!document) { pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT); @@ -5306,7 +5306,7 @@ void Editor::SetDocPointer(Document *document) { view.ClearAllTabstops(); - pdoc->AddWatcher(this, 0); + pdoc->AddWatcher(this, nullptr); SetScrollBars(); Redraw(); } diff --git a/src/MarginView.cxx b/src/MarginView.cxx index e6fffd178..308923ad8 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -216,7 +216,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back); } - const int lineStartPaint = static_cast<int>(rcMargin.top + ptOrigin.y) / vs.lineHeight; + const Sci::Line lineStartPaint = static_cast<Sci::Line>(rcMargin.top + ptOrigin.y) / vs.lineHeight; Sci::Line visibleLine = model.TopLineOfMain() + lineStartPaint; Sci::Position yposScreen = lineStartPaint * vs.lineHeight - static_cast<Sci::Position>(ptOrigin.y); // Work out whether the top line is whitespace located after a diff --git a/src/Position.h b/src/Position.h index e0bbcb53f..b455124d2 100644 --- a/src/Position.h +++ b/src/Position.h @@ -19,7 +19,7 @@ namespace Sci { typedef ptrdiff_t Position; typedef ptrdiff_t Line; -const Position invalidPosition = -1; +inline constexpr Position invalidPosition = -1; } diff --git a/src/Style.cxx b/src/Style.cxx index ae5fa6aa3..00cf698ab 100644 --- a/src/Style.cxx +++ b/src/Style.cxx @@ -35,7 +35,7 @@ bool FontSpecification::operator<(const FontSpecification &other) const noexcept if (weight != other.weight) return weight < other.weight; if (italic != other.italic) - return italic == false; + return !italic; if (size != other.size) return size < other.size; if (characterSet != other.characterSet) @@ -83,8 +83,7 @@ Style::Style(const Style &source) noexcept : FontSpecification(), FontMeasuremen hotspot = source.hotspot; } -Style::~Style() { -} +Style::~Style() = default; Style &Style::operator=(const Style &source) noexcept { if (this == &source) diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index f5ecf84c8..9d9fd6712 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -40,8 +40,7 @@ MarginStyle::MarginStyle(int style_, int width_, int mask_) noexcept : FontRealised::FontRealised() noexcept = default; -FontRealised::~FontRealised() { -} +FontRealised::~FontRealised() = default; void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs, const char *localeName) { PLATFORM_ASSERT(fs.fontName); @@ -167,6 +166,8 @@ void ViewStyle::CalculateMarginWidthAndMask() noexcept { maskInLine &= ~maskBit; maskDrawInText |= maskDefinedMarkers & maskBit; break; + default: // Other marker types do not affect the masks + break; } } } @@ -296,13 +297,13 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) { } // Ask platform to allocate each unique font. - for (std::pair<const FontSpecification, std::unique_ptr<FontRealised>> &font : fonts) { + for (const std::pair<const FontSpecification, std::unique_ptr<FontRealised>> &font : fonts) { font.second->Realise(surface, zoomLevel, technology, font.first, localeName.c_str()); } // Set the platform font handle and measurements for each style. for (Style &style : styles) { - FontRealised *fr = Find(style); + const FontRealised *fr = Find(style); style.Copy(fr->font, *fr); } @@ -429,6 +430,8 @@ void ViewStyle::CalcLargestMarkerHeight() noexcept { if (marker.image && marker.image->GetHeight() > largestMarkerHeight) largestMarkerHeight = marker.image->GetHeight(); break; + default: // Only images have their own natural heights + break; } } } @@ -509,7 +512,7 @@ void ViewStyle::AddMultiEdge(uptr_t wParam, sptr_t lParam) { EdgeProperties(column, lParam)); } -std::optional<ColourAlpha> ViewStyle::ElementColour(int index) const noexcept { +std::optional<ColourAlpha> ViewStyle::ElementColour(int index) const { auto search = elementColours.find(index); if (search != elementColours.end()) { if (search->second.has_value()) { @@ -519,7 +522,7 @@ std::optional<ColourAlpha> ViewStyle::ElementColour(int index) const noexcept { return {}; } -bool ViewStyle::ElementAllowsTranslucent(int index) const noexcept { +bool ViewStyle::ElementAllowsTranslucent(int index) const { return elementAllowsTranslucent.count(index) > 0; } @@ -627,10 +630,10 @@ FontRealised *ViewStyle::Find(const FontSpecification &fs) { } void ViewStyle::FindMaxAscentDescent() { - for (FontMap::const_iterator it = fonts.cbegin(); it != fonts.cend(); ++it) { - if (maxAscent < it->second->ascent) - maxAscent = it->second->ascent; - if (maxDescent < it->second->descent) - maxDescent = it->second->descent; + for (const auto &font : fonts) { + if (maxAscent < font.second->ascent) + maxAscent = font.second->ascent; + if (maxDescent < font.second->descent) + maxDescent = font.second->descent; } } diff --git a/src/ViewStyle.h b/src/ViewStyle.h index c47c91ee8..27abfdf6f 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -239,8 +239,8 @@ public: void AddMultiEdge(uptr_t wParam, sptr_t lParam); - std::optional<ColourAlpha> ElementColour(int index) const noexcept; - bool ElementAllowsTranslucent(int index) const noexcept; + std::optional<ColourAlpha> ElementColour(int index) const; + bool ElementAllowsTranslucent(int index) const; bool SetWrapState(int wrapState_) noexcept; bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept; |