diff options
author | Neil <nyamatongwe@gmail.com> | 2019-04-08 08:41:47 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2019-04-08 08:41:47 +1000 |
commit | e81d5a59bf0ee796e653616d570f8b93fef1344a (patch) | |
tree | 8b70abcc64f54c361bf8ff7249d3d1b97c3060a4 /src | |
parent | 4333970abdd54863a591f95df3c3e7e968aa2519 (diff) | |
download | scintilla-mirror-e81d5a59bf0ee796e653616d570f8b93fef1344a.tar.gz |
Use noexcept where reasonable in ViewStyle.
Diffstat (limited to 'src')
-rw-r--r-- | src/ViewStyle.cxx | 33 | ||||
-rw-r--r-- | src/ViewStyle.h | 32 |
2 files changed, 32 insertions, 33 deletions
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index f507c5528..aa3c4e477 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -29,12 +29,11 @@ using namespace Scintilla; -MarginStyle::MarginStyle(int style_, int width_, int mask_) : +MarginStyle::MarginStyle(int style_, int width_, int mask_) noexcept : style(style_), width(width_), mask(mask_), sensitive(false), cursor(SC_CURSORREVERSEARROW) { } -FontRealised::FontRealised() { -} +FontRealised::FontRealised() noexcept = default; FontRealised::~FontRealised() { font.Release(); @@ -348,7 +347,7 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) { textStart = marginInside ? fixedColumnWidth : leftMarginWidth; } -void ViewStyle::ReleaseAllExtendedStyles() { +void ViewStyle::ReleaseAllExtendedStyles() noexcept { nextExtendedStyle = 256; } @@ -394,11 +393,11 @@ void ViewStyle::SetStyleFontName(int styleIndex, const char *name) { styles[styleIndex].fontName = fontNames.Save(name); } -bool ViewStyle::ProtectionActive() const { +bool ViewStyle::ProtectionActive() const noexcept { return someStylesProtected; } -int ViewStyle::ExternalMarginWidth() const { +int ViewStyle::ExternalMarginWidth() const noexcept { return marginInside ? 0 : fixedColumnWidth; } @@ -413,7 +412,7 @@ int ViewStyle::MarginFromLocation(Point pt) const { return margin; } -bool ViewStyle::ValidStyle(size_t styleIndex) const { +bool ViewStyle::ValidStyle(size_t styleIndex) const noexcept { return styleIndex < styles.size(); } @@ -433,11 +432,11 @@ void ViewStyle::CalcLargestMarkerHeight() { } } -int ViewStyle::GetFrameWidth() const { +int ViewStyle::GetFrameWidth() const noexcept { return std::clamp(caretLineFrame, 1, lineHeight / 3); } -bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const { +bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const noexcept { return caretLineFrame && (caretActive || alwaysShowCaretLineBackground) && showCaretLineBackground && (caretLineAlpha == SC_ALPHA_NOALPHA) && lineContainsCaret; } @@ -479,16 +478,16 @@ ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lin return background; } -bool ViewStyle::SelectionBackgroundDrawn() const { +bool ViewStyle::SelectionBackgroundDrawn() const noexcept { return selColours.back.isSet && ((selAlpha == SC_ALPHA_NOALPHA) || (selAdditionalAlpha == SC_ALPHA_NOALPHA)); } -bool ViewStyle::WhitespaceBackgroundDrawn() const { +bool ViewStyle::WhitespaceBackgroundDrawn() const noexcept { return (viewWhitespace != wsInvisible) && (whitespaceColours.back.isSet); } -bool ViewStyle::WhiteSpaceVisible(bool inIndent) const { +bool ViewStyle::WhiteSpaceVisible(bool inIndent) const noexcept { return (!inIndent && viewWhitespace == wsVisibleAfterIndent) || (inIndent && viewWhitespace == wsVisibleOnlyInIndent) || viewWhitespace == wsVisibleAlways; @@ -501,7 +500,7 @@ ColourDesired ViewStyle::WrapColour() const { return styles[STYLE_DEFAULT].fore; } -bool ViewStyle::SetWrapState(int wrapState_) { +bool ViewStyle::SetWrapState(int wrapState_) noexcept { WrapMode wrapStateWanted; switch (wrapState_) { case SC_WRAP_WORD: @@ -522,25 +521,25 @@ bool ViewStyle::SetWrapState(int wrapState_) { return changed; } -bool ViewStyle::SetWrapVisualFlags(int wrapVisualFlags_) { +bool ViewStyle::SetWrapVisualFlags(int wrapVisualFlags_) noexcept { const bool changed = wrapVisualFlags != wrapVisualFlags_; wrapVisualFlags = wrapVisualFlags_; return changed; } -bool ViewStyle::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) { +bool ViewStyle::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) noexcept { const bool changed = wrapVisualFlagsLocation != wrapVisualFlagsLocation_; wrapVisualFlagsLocation = wrapVisualFlagsLocation_; return changed; } -bool ViewStyle::SetWrapVisualStartIndent(int wrapVisualStartIndent_) { +bool ViewStyle::SetWrapVisualStartIndent(int wrapVisualStartIndent_) noexcept { const bool changed = wrapVisualStartIndent != wrapVisualStartIndent_; wrapVisualStartIndent = wrapVisualStartIndent_; return changed; } -bool ViewStyle::SetWrapIndentMode(int wrapIndentMode_) { +bool ViewStyle::SetWrapIndentMode(int wrapIndentMode_) noexcept { const bool changed = wrapIndentMode != wrapIndentMode_; wrapIndentMode = wrapIndentMode_; return changed; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 0fb3db093..587eb976a 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -20,7 +20,7 @@ public: int mask; bool sensitive; int cursor; - MarginStyle(int style_= SC_MARGIN_SYMBOL, int width_=0, int mask_=0); + MarginStyle(int style_= SC_MARGIN_SYMBOL, int width_=0, int mask_=0) noexcept; }; /** @@ -30,7 +30,7 @@ public: class FontRealised : public FontMeasurements { public: Font font; - FontRealised(); + FontRealised() noexcept; // FontRealised objects can not be copied. FontRealised(const FontRealised &) = delete; FontRealised(FontRealised &&) = delete; @@ -173,31 +173,31 @@ public: void CalculateMarginWidthAndMask(); void Init(size_t stylesSize_=256); void Refresh(Surface &surface, int tabInChars); - void ReleaseAllExtendedStyles(); + void ReleaseAllExtendedStyles() noexcept; int AllocateExtendedStyles(int numberStyles); void EnsureStyle(size_t index); void ResetDefaultStyle(); void ClearStyles(); void SetStyleFontName(int styleIndex, const char *name); - bool ProtectionActive() const; - int ExternalMarginWidth() const; + bool ProtectionActive() const noexcept; + int ExternalMarginWidth() const noexcept; int MarginFromLocation(Point pt) const; - bool ValidStyle(size_t styleIndex) const; + bool ValidStyle(size_t styleIndex) const noexcept; void CalcLargestMarkerHeight(); - int GetFrameWidth() const; - bool IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const; + int GetFrameWidth() const noexcept; + bool IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const noexcept; ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const; - bool SelectionBackgroundDrawn() const; - bool WhitespaceBackgroundDrawn() const; + bool SelectionBackgroundDrawn() const noexcept; + bool WhitespaceBackgroundDrawn() const noexcept; ColourDesired WrapColour() const; - bool SetWrapState(int wrapState_); - bool SetWrapVisualFlags(int wrapVisualFlags_); - bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_); - bool SetWrapVisualStartIndent(int wrapVisualStartIndent_); - bool SetWrapIndentMode(int wrapIndentMode_); + bool SetWrapState(int wrapState_) noexcept; + bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept; + bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) noexcept; + bool SetWrapVisualStartIndent(int wrapVisualStartIndent_) noexcept; + bool SetWrapIndentMode(int wrapIndentMode_) noexcept; - bool WhiteSpaceVisible(bool inIndent) const; + bool WhiteSpaceVisible(bool inIndent) const noexcept; enum class CaretShape { invisible, line, block, bar }; bool IsBlockCaretStyle() const noexcept; |