aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/MarginView.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/MarginView.cxx')
-rw-r--r--src/MarginView.cxx142
1 files changed, 72 insertions, 70 deletions
diff --git a/src/MarginView.cxx b/src/MarginView.cxx
index 68c599b1f..20bc78a4e 100644
--- a/src/MarginView.cxx
+++ b/src/MarginView.cxx
@@ -22,14 +22,16 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+#include "ScintillaStructures.h"
+#include "ILoader.h"
+#include "ILexer.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "ILoader.h"
-#include "ILexer.h"
-#include "Scintilla.h"
-
#include "CharacterCategoryMap.h"
#include "Position.h"
#include "UniqueString.h"
@@ -56,12 +58,12 @@
using namespace Scintilla;
-namespace Scintilla {
+namespace Scintilla::Internal {
void DrawWrapMarker(Surface *surface, PRectangle rcPlace,
bool isEndMarker, ColourRGBA wrapColour) {
- const XYPOSITION extraFinalPixel = surface->Supports(SC_SUPPORTS_LINE_DRAWS_FINAL) ? 0.0f : 1.0f;
+ const XYPOSITION extraFinalPixel = surface->SupportsFeature(Supports::LineDrawsFinal) ? 0.0f : 1.0f;
const PRectangle rcAligned = PixelAlignOutside(rcPlace, surface->PixelDivisions());
@@ -164,8 +166,8 @@ void MarginView::RefreshPixMaps(Surface *surfaceWindow, const ViewStyle &vsDraw)
}
}
-static int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault, const ViewStyle &vs) noexcept {
- if (vs.markers[markerCheck].markType == SC_MARK_EMPTY)
+static MarkerOutline SubstituteMarkerIfEmpty(MarkerOutline markerCheck, MarkerOutline markerDefault, const ViewStyle &vs) noexcept {
+ if (vs.markers[static_cast<size_t>(markerCheck)].markType == MarkerSymbol::Empty)
return markerDefault;
return markerCheck;
}
@@ -179,14 +181,14 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
rcSelMargin.bottom = rc.bottom;
const Point ptOrigin = model.GetVisibleOriginInMain();
- const Font *fontLineNumber = vs.styles[STYLE_LINENUMBER].font.get();
+ const Font *fontLineNumber = vs.styles[StyleLineNumber].font.get();
for (size_t margin = 0; margin < vs.ms.size(); margin++) {
if (vs.ms[margin].width > 0) {
rcSelMargin.left = rcSelMargin.right;
rcSelMargin.right = rcSelMargin.left + vs.ms[margin].width;
- if (vs.ms[margin].style != SC_MARGIN_NUMBER) {
+ if (vs.ms[margin].style != MarginType::Number) {
if (vs.ms[margin].ShowsFolding()) {
// Required because of special way brush is created for selection margin
// Ensure patterns line up when scrolling with separate margin view
@@ -197,23 +199,23 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
} else {
ColourRGBA colour;
switch (vs.ms[margin].style) {
- case SC_MARGIN_BACK:
- colour = vs.styles[STYLE_DEFAULT].back;
+ case MarginType::Back:
+ colour = vs.styles[StyleDefault].back;
break;
- case SC_MARGIN_FORE:
- colour = vs.styles[STYLE_DEFAULT].fore;
+ case MarginType::Fore:
+ colour = vs.styles[StyleDefault].fore;
break;
- case SC_MARGIN_COLOUR:
+ case MarginType::Colour:
colour = vs.ms[margin].back;
break;
default:
- colour = vs.styles[STYLE_LINENUMBER].back;
+ colour = vs.styles[StyleLineNumber].back;
break;
}
surface->FillRectangle(rcSelMargin, colour);
}
} else {
- surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back);
+ surface->FillRectangle(rcSelMargin, vs.styles[StyleLineNumber].back);
}
const Sci::Line lineStartPaint = static_cast<Sci::Line>(rcMargin.top + ptOrigin.y) / vs.lineHeight;
@@ -224,13 +226,13 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
// be displayed until the last of a sequence of whitespace.
bool needWhiteClosure = false;
if (vs.ms[margin].ShowsFolding()) {
- const int level = model.pdoc->GetLevel(model.pcs->DocFromDisplay(visibleLine));
+ const FoldLevel level = model.pdoc->GetFoldLevel(model.pcs->DocFromDisplay(visibleLine));
if (LevelIsWhitespace(level)) {
Sci::Line lineBack = model.pcs->DocFromDisplay(visibleLine);
- int levelPrev = level;
+ FoldLevel levelPrev = level;
while ((lineBack > 0) && LevelIsWhitespace(levelPrev)) {
lineBack--;
- levelPrev = model.pdoc->GetLevel(lineBack);
+ levelPrev = model.pdoc->GetFoldLevel(lineBack);
}
if (!LevelIsHeader(levelPrev)) {
if (LevelNumber(level) < LevelNumber(levelPrev))
@@ -245,10 +247,10 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
}
// Old code does not know about new markers needed to distinguish all cases
- const int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
- SC_MARKNUM_FOLDEROPEN, vs);
- const int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
- SC_MARKNUM_FOLDER, vs);
+ const MarkerOutline folderOpenMid = SubstituteMarkerIfEmpty(MarkerOutline::FolderOpenMid,
+ MarkerOutline::FolderOpen, vs);
+ const MarkerOutline folderEnd = SubstituteMarkerIfEmpty(MarkerOutline::FolderEnd,
+ MarkerOutline::Folder, vs);
while ((visibleLine < model.pcs->LinesDisplayed()) && yposScreen < rc.bottom) {
@@ -268,42 +270,42 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
if (vs.ms[margin].ShowsFolding()) {
// Decide which fold indicator should be displayed
- const int level = model.pdoc->GetLevel(lineDoc);
- const int levelNext = model.pdoc->GetLevel(lineDoc + 1);
- const int levelNum = LevelNumber(level);
- const int levelNextNum = LevelNumber(levelNext);
+ const FoldLevel level = model.pdoc->GetFoldLevel(lineDoc);
+ const FoldLevel levelNext = model.pdoc->GetFoldLevel(lineDoc + 1);
+ const FoldLevel levelNum = LevelNumberPart(level);
+ const FoldLevel levelNextNum = LevelNumberPart(levelNext);
if (LevelIsHeader(level)) {
if (firstSubLine) {
if (levelNum < levelNextNum) {
if (model.pcs->GetExpanded(lineDoc)) {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDEROPEN;
+ if (levelNum == FoldLevel::Base)
+ marks |= 1 << MarkerOutline::FolderOpen;
else
marks |= 1 << folderOpenMid;
} else {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDER;
+ if (levelNum == FoldLevel::Base)
+ marks |= 1 << MarkerOutline::Folder;
else
marks |= 1 << folderEnd;
}
- } else if (levelNum > SC_FOLDLEVELBASE) {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ } else if (levelNum > FoldLevel::Base) {
+ marks |= 1 << MarkerOutline::FolderSub;
}
} else {
if (levelNum < levelNextNum) {
if (model.pcs->GetExpanded(lineDoc)) {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
- } else if (levelNum > SC_FOLDLEVELBASE) {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ marks |= 1 << MarkerOutline::FolderSub;
+ } else if (levelNum > FoldLevel::Base) {
+ marks |= 1 << MarkerOutline::FolderSub;
}
- } else if (levelNum > SC_FOLDLEVELBASE) {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ } else if (levelNum > FoldLevel::Base) {
+ marks |= 1 << MarkerOutline::FolderSub;
}
}
needWhiteClosure = false;
const Sci::Line firstFollowupLine = model.pcs->DocFromDisplay(model.pcs->DisplayFromDoc(lineDoc + 1));
- const int firstFollowupLineLevel = model.pdoc->GetLevel(firstFollowupLine);
- const int secondFollowupLineLevelNum = LevelNumber(model.pdoc->GetLevel(firstFollowupLine + 1));
+ const FoldLevel firstFollowupLineLevel = model.pdoc->GetFoldLevel(firstFollowupLine);
+ const FoldLevel secondFollowupLineLevelNum = LevelNumberPart(model.pdoc->GetFoldLevel(firstFollowupLine + 1));
if (!model.pcs->GetExpanded(lineDoc)) {
if (LevelIsWhitespace(firstFollowupLineLevel) &&
(levelNum > secondFollowupLineLevelNum))
@@ -315,42 +317,42 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
} else if (LevelIsWhitespace(level)) {
if (needWhiteClosure) {
if (LevelIsWhitespace(levelNext)) {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
- } else if (levelNextNum > SC_FOLDLEVELBASE) {
- marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL;
+ marks |= 1 << MarkerOutline::FolderSub;
+ } else if (levelNextNum > FoldLevel::Base) {
+ marks |= 1 << MarkerOutline::FolderMidTail;
needWhiteClosure = false;
} else {
- marks |= 1 << SC_MARKNUM_FOLDERTAIL;
+ marks |= 1 << MarkerOutline::FolderTail;
needWhiteClosure = false;
}
- } else if (levelNum > SC_FOLDLEVELBASE) {
+ } else if (levelNum > FoldLevel::Base) {
if (levelNextNum < levelNum) {
- if (levelNextNum > SC_FOLDLEVELBASE) {
- marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL;
+ if (levelNextNum > FoldLevel::Base) {
+ marks |= 1 << MarkerOutline::FolderMidTail;
} else {
- marks |= 1 << SC_MARKNUM_FOLDERTAIL;
+ marks |= 1 << MarkerOutline::FolderTail;
}
} else {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ marks |= 1 << MarkerOutline::FolderSub;
}
}
- } else if (levelNum > SC_FOLDLEVELBASE) {
+ } else if (levelNum > FoldLevel::Base) {
if (levelNextNum < levelNum) {
needWhiteClosure = false;
if (LevelIsWhitespace(levelNext)) {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ marks |= 1 << MarkerOutline::FolderSub;
needWhiteClosure = true;
} else if (lastSubLine) {
- if (levelNextNum > SC_FOLDLEVELBASE) {
- marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL;
+ if (levelNextNum > FoldLevel::Base) {
+ marks |= 1 << MarkerOutline::FolderMidTail;
} else {
- marks |= 1 << SC_MARKNUM_FOLDERTAIL;
+ marks |= 1 << MarkerOutline::FolderTail;
}
} else {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ marks |= 1 << MarkerOutline::FolderSub;
}
} else {
- marks |= 1 << SC_MARKNUM_FOLDERSUB;
+ marks |= 1 << MarkerOutline::FolderSub;
}
}
}
@@ -362,21 +364,21 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
static_cast<XYPOSITION>(yposScreen),
rcSelMargin.right,
static_cast<XYPOSITION>(yposScreen + vs.lineHeight));
- if (vs.ms[margin].style == SC_MARGIN_NUMBER) {
+ if (vs.ms[margin].style == MarginType::Number) {
if (firstSubLine) {
std::string sNumber;
if (lineDoc >= 0) {
sNumber = std::to_string(lineDoc + 1);
}
- if (model.foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) {
+ if (FlagSet(model.foldFlags, FoldFlag::LevelNumbers | FoldFlag::LineState)) {
char number[100] = "";
- if (model.foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
- const int lev = model.pdoc->GetLevel(lineDoc);
+ if (FlagSet(model.foldFlags, FoldFlag::LevelNumbers)) {
+ const FoldLevel lev = model.pdoc->GetFoldLevel(lineDoc);
sprintf(number, "%c%c %03X %03X",
LevelIsHeader(lev) ? 'H' : '_',
LevelIsWhitespace(lev) ? 'W' : '_',
LevelNumber(lev),
- lev >> 16
+ static_cast<int>(lev) >> 16
);
} else {
const int state = model.pdoc->GetLineState(lineDoc);
@@ -389,26 +391,26 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
const XYPOSITION width = surface->WidthText(fontLineNumber, sNumber);
const XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding;
rcNumber.left = xpos;
- DrawTextNoClipPhase(surface, rcNumber, vs.styles[STYLE_LINENUMBER],
+ DrawTextNoClipPhase(surface, rcNumber, vs.styles[StyleLineNumber],
rcNumber.top + vs.maxAscent, sNumber, DrawPhase::all);
- } else if (vs.wrap.visualFlags & SC_WRAPVISUALFLAG_MARGIN) {
+ } else if (FlagSet(vs.wrap.visualFlags, WrapVisualFlag::Margin)) {
PRectangle rcWrapMarker = rcMarker;
rcWrapMarker.right -= wrapMarkerPaddingRight;
- rcWrapMarker.left = rcWrapMarker.right - vs.styles[STYLE_LINENUMBER].aveCharWidth;
+ rcWrapMarker.left = rcWrapMarker.right - vs.styles[StyleLineNumber].aveCharWidth;
if (!customDrawWrapMarker) {
- DrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore);
+ DrawWrapMarker(surface, rcWrapMarker, false, vs.styles[StyleLineNumber].fore);
} else {
- customDrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore);
+ customDrawWrapMarker(surface, rcWrapMarker, false, vs.styles[StyleLineNumber].fore);
}
}
- } else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) {
+ } else if (vs.ms[margin].style == MarginType::Text || vs.ms[margin].style == MarginType::RText) {
const StyledText stMargin = model.pdoc->MarginStyledText(lineDoc);
if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) {
if (firstSubLine) {
surface->FillRectangle(rcMarker,
vs.styles[stMargin.StyleAt(0) + vs.marginStyleOffset].back);
PRectangle rcText = rcMarker;
- if (vs.ms[margin].style == SC_MARGIN_RTEXT) {
+ if (vs.ms[margin].style == MarginType::RText) {
const int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
rcText.left = rcText.right - width - 3;
}
@@ -459,7 +461,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
PRectangle rcBlankMargin = rcMargin;
rcBlankMargin.left = rcSelMargin.right;
- surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back);
+ surface->FillRectangle(rcBlankMargin, vs.styles[StyleDefault].back);
}
}