aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-08-13 18:12:55 +1000
committerNeil <nyamatongwe@gmail.com>2022-08-13 18:12:55 +1000
commit7d2f6bd5280613538c4beafac26a39348992d103 (patch)
tree3da3b4dc503778ef6ce45da0477bcfdafd127160
parent059594717cb36423733a0fbdee316f436d2e49a0 (diff)
downloadscintilla-mirror-7d2f6bd5280613538c4beafac26a39348992d103.tar.gz
Reduce warnings with noexcept, fewer casts, and other minor changes.
-rw-r--r--src/EditModel.h2
-rw-r--r--src/EditView.cxx12
-rw-r--r--src/Editor.cxx18
-rw-r--r--src/Editor.h18
-rw-r--r--src/PositionCache.cxx4
-rw-r--r--src/UniConversion.cxx4
-rw-r--r--src/UniConversion.h2
7 files changed, 32 insertions, 28 deletions
diff --git a/src/EditModel.h b/src/EditModel.h
index d86f41250..f62c28b1f 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -63,7 +63,7 @@ public:
EditModel &operator=(const EditModel &) = delete;
EditModel &operator=(EditModel &&) = delete;
virtual ~EditModel();
- virtual Sci::Line TopLineOfMain() const = 0;
+ virtual Sci::Line TopLineOfMain() const noexcept = 0;
virtual Point GetVisibleOriginInMain() const = 0;
virtual Sci::Line LinesOnScreen() const = 0;
bool BidirectionalEnabled() const noexcept;
diff --git a/src/EditView.cxx b/src/EditView.cxx
index d59f99eb2..a40c6c3b8 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -711,7 +711,7 @@ void EditView::UpdateBidiData(const EditModel &model, const ViewStyle &vstyle, L
ll->bidiData->stylesFonts[ll->numCharsInLine].reset();
for (int charsInLine = 0; charsInLine < ll->numCharsInLine; charsInLine++) {
- const int charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(&ll->chars[charsInLine]), ll->numCharsInLine - charsInLine);
+ const int charWidth = UTF8DrawBytes(&ll->chars[charsInLine], ll->numCharsInLine - charsInLine);
const Representation *repr = model.reprs.RepresentationFromCharacter(std::string_view(&ll->chars[charsInLine], charWidth));
ll->bidiData->widthReprs[charsInLine] = 0.0f;
@@ -1328,7 +1328,7 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
if (FlagSet(model.changeHistoryOption, ChangeHistoryOption::Indicators)) {
// Draw editions
- const int indexHistory = static_cast<int>(IndicatorNumbers::HistoryRevertedToOriginInsertion);
+ constexpr int indexHistory = static_cast<int>(IndicatorNumbers::HistoryRevertedToOriginInsertion);
{
// Draw insertions
Sci::Position startPos = posLineStart + lineStart;
@@ -1815,7 +1815,9 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
}
}
-static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, const LineLayout *ll,
+namespace {
+
+void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, const LineLayout *ll,
int xStart, PRectangle rcLine, std::optional<ColourRGBA> background, DrawWrapMarkerFn customDrawWrapMarker,
bool caretActive) {
// default bgnd here..
@@ -1855,7 +1857,7 @@ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, c
// such that, if the caret is inside the main selection, the beginning or end of that selection
// is at the end of a text segment.
// This function should only be called if iDoc is within the main selection.
-static InSelection CharacterInCursesSelection(Sci::Position iDoc, const EditModel &model, const ViewStyle &vsDraw) {
+InSelection CharacterInCursesSelection(Sci::Position iDoc, const EditModel &model, const ViewStyle &vsDraw) noexcept {
const SelectionPosition &posCaret = model.sel.RangeMain().caret;
const bool caretAtStart = posCaret < model.sel.RangeMain().anchor && posCaret.Position() == iDoc;
const bool caretAtEnd = posCaret > model.sel.RangeMain().anchor &&
@@ -1864,6 +1866,8 @@ static InSelection CharacterInCursesSelection(Sci::Position iDoc, const EditMode
return (caretAtStart || caretAtEnd) ? InSelection::inNone : InSelection::inMain;
}
+}
+
void EditView::DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart,
int subLine, std::optional<ColourRGBA> background) const {
diff --git a/src/Editor.cxx b/src/Editor.cxx
index f7d6a784b..812b0a7b4 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -263,7 +263,7 @@ void Editor::DropGraphics() noexcept {
view.DropGraphics();
}
-void Editor::InvalidateStyleData() {
+void Editor::InvalidateStyleData() noexcept {
stylesValid = false;
vs.technology = technology;
DropGraphics();
@@ -306,7 +306,7 @@ PointDocument Editor::DocumentPointFromView(Point ptView) const {
return ptDocument;
}
-Sci::Line Editor::TopLineOfMain() const {
+Sci::Line Editor::TopLineOfMain() const noexcept {
if (wMargin.GetID())
return 0;
else
@@ -432,7 +432,7 @@ Sci::Position Editor::PositionFromLineX(Sci::Line lineDoc, int x) {
return SPositionFromLineX(lineDoc, x).Position();
}
-Sci::Line Editor::LineFromLocation(Point pt) const {
+Sci::Line Editor::LineFromLocation(Point pt) const noexcept {
return pcs->DocFromDisplay(static_cast<int>(pt.y) / vs.lineHeight + topLine);
}
@@ -570,7 +570,7 @@ void Editor::InvalidateRange(Sci::Position start, Sci::Position end) {
RedrawRect(RectangleFromRange(Range(start, end), view.LinesOverlap() ? vs.lineOverlap : 0));
}
-Sci::Position Editor::CurrentPosition() const {
+Sci::Position Editor::CurrentPosition() const noexcept {
return sel.MainCaret();
}
@@ -578,11 +578,11 @@ bool Editor::SelectionEmpty() const noexcept {
return sel.Empty();
}
-SelectionPosition Editor::SelectionStart() {
+SelectionPosition Editor::SelectionStart() noexcept {
return sel.RangeMain().Start();
}
-SelectionPosition Editor::SelectionEnd() {
+SelectionPosition Editor::SelectionEnd() noexcept {
return sel.RangeMain().End();
}
@@ -809,7 +809,7 @@ bool Editor::RangeContainsProtected(Sci::Position start, Sci::Position end) cons
return false;
}
-bool Editor::SelectionContainsProtected() const {
+bool Editor::SelectionContainsProtected() const noexcept {
for (size_t r=0; r<sel.Count(); r++) {
if (RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
@@ -4178,7 +4178,7 @@ Sci::Position Editor::FindTextFull(
* while still setting the selection to found text so the find/select
* operation is self-contained.
*/
-void Editor::SearchAnchor() {
+void Editor::SearchAnchor() noexcept {
searchAnchor = SelectionStart().Position();
}
@@ -4784,7 +4784,7 @@ void Editor::RightButtonDownWithModifiers(Point pt, unsigned int, KeyMod modifie
return;
}
-bool Editor::PositionIsHotspot(Sci::Position position) const {
+bool Editor::PositionIsHotspot(Sci::Position position) const noexcept {
return vs.styles[pdoc->StyleIndexAt(position)].hotspot;
}
diff --git a/src/Editor.h b/src/Editor.h
index a6364be4d..2d30cdb72 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -296,7 +296,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void Initialise() = 0;
virtual void Finalise();
- void InvalidateStyleData();
+ void InvalidateStyleData() noexcept;
void InvalidateStyleRedraw();
void RefreshStyleData();
void SetRepresentations();
@@ -306,7 +306,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
// scroll views where it will be equivalent to the current scroll position.
Point GetVisibleOriginInMain() const override;
PointDocument DocumentPointFromView(Point ptView) const; // Convert a point from view space to document
- Sci::Line TopLineOfMain() const override; // Return the line at Main's y coordinate 0
+ Sci::Line TopLineOfMain() const noexcept final; // Return the line at Main's y coordinate 0
virtual PRectangle GetClientRectangle() const;
virtual PRectangle GetClientDrawingRectangle();
PRectangle GetTextRectangle() const;
@@ -322,7 +322,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
Sci::Position PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false);
SelectionPosition SPositionFromLineX(Sci::Line lineDoc, int x);
Sci::Position PositionFromLineX(Sci::Line lineDoc, int x);
- Sci::Line LineFromLocation(Point pt) const;
+ Sci::Line LineFromLocation(Point pt) const noexcept;
void SetTopLine(Sci::Line topLineNew);
virtual bool AbandonPaint();
@@ -336,10 +336,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool UserVirtualSpace() const noexcept {
return (FlagSet(virtualSpaceOptions, Scintilla::VirtualSpace::UserAccessible));
}
- Sci::Position CurrentPosition() const;
+ Sci::Position CurrentPosition() const noexcept;
bool SelectionEmpty() const noexcept;
- SelectionPosition SelectionStart();
- SelectionPosition SelectionEnd();
+ SelectionPosition SelectionStart() noexcept;
+ SelectionPosition SelectionEnd() noexcept;
void SetRectangularRange();
void ThinRectangularRange();
void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
@@ -353,7 +353,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
enum class AddNumber { one, each };
void MultipleSelectAdd(AddNumber addNumber);
bool RangeContainsProtected(Sci::Position start, Sci::Position end) const noexcept;
- bool SelectionContainsProtected() const;
+ bool SelectionContainsProtected() const noexcept;
Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const;
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd=true) const;
void MovedCaret(SelectionPosition newPos, SelectionPosition previousPos,
@@ -504,7 +504,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual std::unique_ptr<CaseFolder> CaseFolderForEncoding();
Sci::Position FindText(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
Sci::Position FindTextFull(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
- void SearchAnchor();
+ void SearchAnchor() noexcept;
Sci::Position SearchText(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
Sci::Position SearchInTarget(const char *text, Sci::Position length);
void GoToLine(Sci::Line lineNo);
@@ -584,7 +584,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
Sci::Position GetTag(char *tagValue, int tagNumber);
Sci::Position ReplaceTarget(bool replacePatterns, const char *text, Sci::Position length=-1);
- bool PositionIsHotspot(Sci::Position position) const;
+ bool PositionIsHotspot(Sci::Position position) const noexcept;
bool PointIsHotspot(Point pt);
void SetHotSpotRange(const Point *pt);
void SetHoverIndicatorPosition(Sci::Position position);
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index f1298ddd4..0104b8660 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -385,7 +385,7 @@ constexpr bool GraphicASCII(char ch) noexcept {
return ch >= ' ' && ch <= '~';
}
-bool AllGraphicASCII(std::string_view text) noexcept {
+bool AllGraphicASCII(std::string_view text) {
return std::all_of(text.cbegin(), text.cend(), GraphicASCII);
}
@@ -742,7 +742,7 @@ TextSegment BreakFinder::Next() {
const unsigned char ch = chars[0];
if (!UTF8IsAscii(ch) && encodingFamily != EncodingFamily::eightBit) {
if (encodingFamily == EncodingFamily::unicode) {
- charWidth = UTF8DrawBytes(reinterpret_cast<const unsigned char *>(chars), static_cast<int>(lineRange.end - nextBreak));
+ charWidth = UTF8DrawBytes(chars, lineRange.end - nextBreak);
} else {
charWidth = pdoc->DBCSDrawBytes(std::string_view(chars, lineRange.end - nextBreak));
}
diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx
index 91aea6cde..3f3bc5904 100644
--- a/src/UniConversion.cxx
+++ b/src/UniConversion.cxx
@@ -358,8 +358,8 @@ int UTF8Classify(const unsigned char *us, size_t len) noexcept {
return UTF8MaskInvalid | 1;
}
-int UTF8DrawBytes(const unsigned char *us, int len) noexcept {
- const int utf8StatusNext = UTF8Classify(us, len);
+int UTF8DrawBytes(const char *s, size_t len) noexcept {
+ const int utf8StatusNext = UTF8Classify(reinterpret_cast<const unsigned char *>(s), len);
return (utf8StatusNext & UTF8MaskInvalid) ? 1 : (utf8StatusNext & UTF8MaskWidth);
}
diff --git a/src/UniConversion.h b/src/UniConversion.h
index 95ff2ad43..a21a020c3 100644
--- a/src/UniConversion.h
+++ b/src/UniConversion.h
@@ -65,7 +65,7 @@ inline int UTF8Classify(std::string_view sv) noexcept {
// Similar to UTF8Classify but returns a length of 1 for invalid bytes
// instead of setting the invalid flag
-int UTF8DrawBytes(const unsigned char *us, int len) noexcept;
+int UTF8DrawBytes(const char *s, size_t len) noexcept;
// Line separator is U+2028 \xe2\x80\xa8
// Paragraph separator is U+2029 \xe2\x80\xa9