diff options
author | Zufu Liu <unknown> | 2023-11-24 09:01:05 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2023-11-24 09:01:05 +1100 |
commit | 0d84ef7da391ff193c944cb47b7a4eddeb61d8c3 (patch) | |
tree | fd24e0efe2435e97189210847aab2e32d7be36d8 | |
parent | c9668d46c7209e8f1f86a109e9c41aac07232492 (diff) | |
download | scintilla-mirror-0d84ef7da391ff193c944cb47b7a4eddeb61d8c3.tar.gz |
Feature [feature-requests:#1502] Simplify FlagSet expressions.
-rw-r--r-- | src/EditView.cxx | 10 | ||||
-rw-r--r-- | src/Editor.cxx | 14 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 3 |
3 files changed, 10 insertions, 17 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 0e136a8bf..a4fd701a7 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -2060,17 +2060,11 @@ void DrawFoldLines(Surface *surface, const EditModel &model, const ViewStyle &vs const ColourRGBA foldLineColour = vsDraw.ElementColour(Element::FoldLine).value_or( vsDraw.styles[StyleDefault].fore); // Paint the line above the fold - if ((subLine == 0) && - ((expanded && (FlagSet(model.foldFlags, FoldFlag::LineBeforeExpanded))) - || - (!expanded && (FlagSet(model.foldFlags, FoldFlag::LineBeforeContracted))))) { + if ((subLine == 0) && FlagSet(model.foldFlags, (expanded ? FoldFlag::LineBeforeExpanded: FoldFlag::LineBeforeContracted))) { surface->FillRectangleAligned(Side(rcLine, Edge::top, 1.0), foldLineColour); } // Paint the line below the fold - if (lastSubLine && - ((expanded && (FlagSet(model.foldFlags, FoldFlag::LineAfterExpanded))) - || - (!expanded && (FlagSet(model.foldFlags, FoldFlag::LineAfterContracted))))) { + if (lastSubLine && FlagSet(model.foldFlags, (expanded ? FoldFlag::LineAfterExpanded : FoldFlag::LineAfterContracted))) { surface->FillRectangleAligned(Side(rcLine, Edge::bottom, 1.0), foldLineColour); // If contracted fold line drawn then don't overwrite with hidden line // as fold lines are more specific then hidden lines. diff --git a/src/Editor.cxx b/src/Editor.cxx index 3421dc72d..ceaa1398d 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -98,11 +98,12 @@ constexpr bool CanEliminate(const DocModification &mh) noexcept { in a [possibly lengthy] multi-step Undo/Redo sequence */ constexpr bool IsLastStep(const DocModification &mh) noexcept { + constexpr ModificationFlags finalMask = ModificationFlags::MultiStepUndoRedo + | ModificationFlags::LastStepInUndoRedo + | ModificationFlags::MultilineUndoRedo; return FlagSet(mh.modificationType, (ModificationFlags::Undo | ModificationFlags::Redo)) - && (FlagSet(mh.modificationType, ModificationFlags::MultiStepUndoRedo)) - && (FlagSet(mh.modificationType, ModificationFlags::LastStepInUndoRedo)) - && (FlagSet(mh.modificationType, ModificationFlags::MultilineUndoRedo)); + && ((mh.modificationType & finalMask) == finalMask); } } @@ -2727,7 +2728,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert)) { if (pdoc->ContainsLineEnd(mh.text, mh.length) && (mh.position != pdoc->LineStart(lineOfPos))) endNeedShown = pdoc->LineStart(lineOfPos+1); - } else if (FlagSet(mh.modificationType, ModificationFlags::BeforeDelete)) { + } else { // If the deletion includes any EOL then we extend the need shown area. endNeedShown = mh.position + mh.length; Sci::Line lineLast = pdoc->SciLineFromPosition(mh.position+mh.length); @@ -2802,7 +2803,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { SetScrollBars(); } - if ((FlagSet(mh.modificationType, ModificationFlags::ChangeMarker)) || (FlagSet(mh.modificationType, ModificationFlags::ChangeMargin))) { + if (FlagSet(mh.modificationType, (ModificationFlags::ChangeMarker | ModificationFlags::ChangeMargin))) { if ((!willRedrawAll) && ((paintState == PaintState::notPainting) || !PaintContainsMargin())) { if (FlagSet(mh.modificationType, ModificationFlags::ChangeFold)) { // Fold changes can affect the drawing of following lines so redraw whole margin @@ -4646,8 +4647,7 @@ void Editor::MouseLeave() { } static constexpr bool AllowVirtualSpace(VirtualSpace virtualSpaceOptions, bool rectangular) noexcept { - return (!rectangular && (FlagSet(virtualSpaceOptions, VirtualSpace::UserAccessible))) - || (rectangular && (FlagSet(virtualSpaceOptions, VirtualSpace::RectangularSelection))); + return FlagSet(virtualSpaceOptions, (rectangular ? VirtualSpace::RectangularSelection : VirtualSpace::UserAccessible)); } void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) { diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index a669fce4a..04f2de977 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -712,8 +712,7 @@ bool ViewStyle::SetWrapIndentMode(WrapIndentMode wrapIndentMode_) noexcept { bool ViewStyle::IsBlockCaretStyle() const noexcept { return ((caret.style & CaretStyle::InsMask) == CaretStyle::Block) || - FlagSet(caret.style, CaretStyle::OverstrikeBlock) || - FlagSet(caret.style, CaretStyle::Curses); + FlagSet(caret.style, (CaretStyle::OverstrikeBlock | CaretStyle::Curses)); } bool ViewStyle::IsCaretVisible(bool isMainSelection) const noexcept { |